ReactOS 0.4.15-dev-7958-gcd0bb1a
CEnumRegKey Class Reference
Inheritance diagram for CEnumRegKey:
Collaboration diagram for CEnumRegKey:

Public Member Functions

 CEnumRegKey ()
 
 ~CEnumRegKey ()
 
HRESULT Initialize (PCWSTR path, HKEY root)
 
HRESULT NextKey (LPITEMIDLIST *ppidl)
 
HRESULT NextValue (LPITEMIDLIST *ppidl)
 
HRESULT EnumerateNext (LPITEMIDLIST *ppidl)
 
STDMETHODIMP Next (ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched) override
 
STDMETHODIMP Skip (ULONG celt) override
 
STDMETHODIMP Reset () override
 
STDMETHODIMP Clone (IEnumIDList **ppenum) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IEnumIDList
HRESULT Next ([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] PITEMID_CHILD *rgelt, [out] ULONG *pceltFetched)
 
HRESULT Skip ([in] ULONG celt)
 
HRESULT Reset ()
 
HRESULT Clone ([out] IEnumIDList **ppenum)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Attributes

PCWSTR m_path
 
HKEY m_hkey
 
BOOL m_values
 
int m_idx
 

Additional Inherited Members

- Public Types inherited from IEnumIDList
typedef IEnumIDListLPENUMIDLIST
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 299 of file ntobjenum.cpp.

Constructor & Destructor Documentation

◆ CEnumRegKey()

CEnumRegKey::CEnumRegKey ( )
inline

Definition at line 309 of file ntobjenum.cpp.

311 {
312 }
PCWSTR m_path
Definition: ntobjenum.cpp:303
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117

◆ ~CEnumRegKey()

CEnumRegKey::~CEnumRegKey ( )
inline

Definition at line 314 of file ntobjenum.cpp.

315 {
317 }
#define RegCloseKey(hKey)
Definition: registry.h:49

Member Function Documentation

◆ Clone()

STDMETHODIMP CEnumRegKey::Clone ( IEnumIDList **  ppenum)
inlineoverride

Implements IEnumIDList.

Definition at line 537 of file ntobjenum.cpp.

538 {
539 return E_NOTIMPL;
540 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ EnumerateNext()

HRESULT CEnumRegKey::EnumerateNext ( LPITEMIDLIST ppidl)
inline

Definition at line 482 of file ntobjenum.cpp.

483 {
484 if (!m_values)
485 {
486 HRESULT hr = NextKey(ppidl);
487 if (hr != S_FALSE)
488 return hr;
489
490 // switch to values.
491 m_values = TRUE;
492 m_idx = 0;
493 }
494
495 return NextValue(ppidl);
496 }
HRESULT NextKey(LPITEMIDLIST *ppidl)
Definition: ntobjenum.cpp:341
HRESULT NextValue(LPITEMIDLIST *ppidl)
Definition: ntobjenum.cpp:406
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define S_FALSE
Definition: winerror.h:2357

◆ Initialize()

HRESULT CEnumRegKey::Initialize ( PCWSTR  path,
HKEY  root 
)
inline

Definition at line 319 of file ntobjenum.cpp.

320 {
321 m_path = path;
322
323 DWORD res;
324 if (root)
325 {
327 }
328 else
329 {
331 }
332 if (!NT_SUCCESS(res))
333 {
334 ERR("RegOpenKeyExW failed for path %S with status=%x\n", path, res);
335 return HRESULT_FROM_NT(res);
336 }
337
338 return S_OK;
339 }
#define ERR(fmt,...)
Definition: debug.h:110
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define S_OK
Definition: intsafe.h:52
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
static DWORD NtOpenObject(OBJECT_TYPE type, PHANDLE phandle, DWORD access, LPCWSTR path)
Definition: ntobjenum.cpp:50
@ KEY_OBJECT
Definition: ntobjenum.h:16
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define HRESULT_FROM_NT(x)
Definition: winerror.h:94

◆ Next()

STDMETHODIMP CEnumRegKey::Next ( ULONG  celt,
LPITEMIDLIST rgelt,
ULONG pceltFetched 
)
inlineoverride

Definition at line 498 of file ntobjenum.cpp.

499 {
500 if (pceltFetched)
501 *pceltFetched = 0;
502
503 while (celt-- > 0)
504 {
505 HRESULT hr = EnumerateNext(rgelt);
506 if (hr != S_OK)
507 return hr;
508
509 if (pceltFetched)
510 (*pceltFetched)++;
511 if (rgelt)
512 rgelt++;
513 }
514
515 return S_OK;
516 }
HRESULT EnumerateNext(LPITEMIDLIST *ppidl)
Definition: ntobjenum.cpp:482

◆ NextKey()

HRESULT CEnumRegKey::NextKey ( LPITEMIDLIST ppidl)
inline

Definition at line 341 of file ntobjenum.cpp.

342 {
345
346 WCHAR className[MAX_PATH];
347 DWORD cchClass = _countof(className);
348
349 if (RegEnumKeyExW(m_hkey, m_idx++, name, &cchName, 0, className, &cchClass, NULL))
350 return S_FALSE;
351
352 name[cchName] = 0;
353 className[cchClass] = 0;
354
356
357 DWORD entryBufferLength = FIELD_OFFSET(RegPidlEntry, entryName) + sizeof(WCHAR) + cchName * sizeof(WCHAR);
358
359 if (cchClass > 0)
360 {
361 entryBufferLength += sizeof(WCHAR) + cchClass * sizeof(WCHAR);
362 }
363
364 // allocate space for the terminator
365 entryBufferLength += FIELD_OFFSET(SHITEMID, abID);
366
367 RegPidlEntry* entry = (RegPidlEntry*) CoTaskMemAlloc(entryBufferLength);
368 if (!entry)
369 return E_OUTOFMEMORY;
370
371 memset(entry, 0, entryBufferLength);
372
373 entry->cb = FIELD_OFFSET(RegPidlEntry, entryName);
374 entry->magic = REGISTRY_PIDL_MAGIC;
375 entry->entryType = otype;
376
377 if (cchName > 0)
378 {
379 entry->entryNameLength = cchName * sizeof(WCHAR);
380 StringCbCopyNW(entry->entryName, entryBufferLength, name, entry->entryNameLength);
381 entry->cb += entry->entryNameLength + sizeof(WCHAR);
382 }
383 else
384 {
385 entry->entryNameLength = 0;
386 entry->entryName[0] = 0;
387 entry->cb += sizeof(WCHAR);
388 }
389
390 if (cchClass)
391 {
392 PWSTR contentData = (PWSTR) ((PBYTE) entry + entry->cb);
393 DWORD remainingSpace = entryBufferLength - entry->cb;
394
395 entry->contentsLength = cchClass * sizeof(WCHAR);
396 StringCbCopyNW(contentData, remainingSpace, className, entry->contentsLength);
397
398 entry->cb += entry->contentsLength + sizeof(WCHAR);
399 }
400
401 if (ppidl)
402 *ppidl = (LPITEMIDLIST) entry;
403 return S_OK;
404 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define MAX_PATH
Definition: compat.h:34
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
uint32_t entry
Definition: isohybrid.c:63
#define REGISTRY_PIDL_MAGIC
Definition: ntobjenum.h:26
REG_ENTRY_TYPE
Definition: ntobjenum.h:51
@ REG_ENTRY_KEY
Definition: ntobjenum.h:53
BYTE * PBYTE
Definition: pedump.c:66
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
Definition: strsafe.h:255
Definition: name.c:39
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2767
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ NextValue()

HRESULT CEnumRegKey::NextValue ( LPITEMIDLIST ppidl)
inline

Definition at line 406 of file ntobjenum.cpp.

407 {
410 DWORD type = 0;
411 DWORD dataSize = 0;
412
414 return S_FALSE;
415
417
418 DWORD entryBufferLength = FIELD_OFFSET(RegPidlEntry, entryName) + sizeof(WCHAR) + cchName * sizeof(WCHAR);
419
420#define MAX_EMBEDDED_DATA 32
421 BOOL copyData = dataSize <= MAX_EMBEDDED_DATA;
422 if (copyData)
423 {
424 entryBufferLength += dataSize + sizeof(WCHAR);
425
427 }
428
429 // allocate space for the terminator
430 entryBufferLength += FIELD_OFFSET(SHITEMID, abID);
431
432 RegPidlEntry* entry = (RegPidlEntry*) CoTaskMemAlloc(entryBufferLength);
433 if (!entry)
434 return E_OUTOFMEMORY;
435
436 memset(entry, 0, entryBufferLength);
437
438 entry->cb = FIELD_OFFSET(RegPidlEntry, entryName);
439 entry->magic = REGISTRY_PIDL_MAGIC;
440 entry->entryType = otype;
441 entry->contentType = type;
442
443 if (cchName > 0)
444 {
445 entry->entryNameLength = cchName * sizeof(WCHAR);
446 StringCbCopyNW(entry->entryName, entryBufferLength, name, entry->entryNameLength);
447 entry->cb += entry->entryNameLength + sizeof(WCHAR);
448 }
449 else
450 {
451 entry->entryNameLength = 0;
452 entry->entryName[0] = 0;
453 entry->cb += sizeof(WCHAR);
454 }
455
456 if (copyData)
457 {
458 PBYTE contentData = (PBYTE) ((PBYTE) entry + entry->cb);
459
460 entry->contentsLength = dataSize;
461
462 // In case it's an unterminated string, RegGetValue will add the NULL termination
463 dataSize += sizeof(WCHAR);
464
465 if (!RegQueryValueExW(m_hkey, name, NULL, NULL, contentData, &dataSize))
466 {
467 entry->cb += entry->contentsLength + sizeof(WCHAR);
468 }
469 else
470 {
471 entry->contentsLength = 0;
472 entry->cb += sizeof(WCHAR);
473 }
474
475 }
476
477 if (ppidl)
478 *ppidl = (LPITEMIDLIST) entry;
479 return S_OK;
480 }
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei dataSize
Definition: glext.h:11123
#define MAX_EMBEDDED_DATA
@ REG_ENTRY_VALUE_WITH_CONTENT
Definition: ntobjenum.h:55
@ REG_ENTRY_VALUE
Definition: ntobjenum.h:54

◆ Reset()

STDMETHODIMP CEnumRegKey::Reset ( )
inlineoverride

Implements IEnumIDList.

Definition at line 532 of file ntobjenum.cpp.

533 {
534 return E_NOTIMPL;
535 }

◆ Skip()

STDMETHODIMP CEnumRegKey::Skip ( ULONG  celt)
inlineoverride

Implements IEnumIDList.

Definition at line 518 of file ntobjenum.cpp.

519 {
520 while (celt > 0)
521 {
523 if (FAILED(hr))
524 return hr;
525 if (hr != S_OK)
526 break;
527 }
528
529 return S_OK;
530 }
#define FAILED(hr)
Definition: intsafe.h:51

Member Data Documentation

◆ m_hkey

HKEY CEnumRegKey::m_hkey
private

Definition at line 304 of file ntobjenum.cpp.

◆ m_idx

int CEnumRegKey::m_idx
private

Definition at line 306 of file ntobjenum.cpp.

◆ m_path

PCWSTR CEnumRegKey::m_path
private

Definition at line 303 of file ntobjenum.cpp.

◆ m_values

BOOL CEnumRegKey::m_values
private

Definition at line 305 of file ntobjenum.cpp.


The documentation for this class was generated from the following file: