ReactOS 0.4.15-dev-7906-g1b85a5f
CEnumNTDirectory Class Reference
Inheritance diagram for CEnumNTDirectory:
Collaboration diagram for CEnumNTDirectory:

Public Member Functions

 CEnumNTDirectory ()
 
 ~CEnumNTDirectory ()
 
HRESULT Initialize (PCWSTR path)
 
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

WCHAR buffer [MAX_PATH]
 
HANDLE m_directory
 
BOOL m_first
 
ULONG m_enumContext
 
PWSTR m_pend
 

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 550 of file ntobjenum.cpp.

Constructor & Destructor Documentation

◆ CEnumNTDirectory()

CEnumNTDirectory::CEnumNTDirectory ( )
inline

Definition at line 561 of file ntobjenum.cpp.

563 {
564 }
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120

◆ ~CEnumNTDirectory()

CEnumNTDirectory::~CEnumNTDirectory ( )
inline

Definition at line 566 of file ntobjenum.cpp.

567 {
569 }
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402

Member Function Documentation

◆ Clone()

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

Implements IEnumIDList.

Definition at line 714 of file ntobjenum.cpp.

715 {
716 return E_NOTIMPL;
717 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ EnumerateNext()

HRESULT CEnumNTDirectory::EnumerateNext ( LPITEMIDLIST ppidl)
inline

Definition at line 588 of file ntobjenum.cpp.

589 {
590 BYTE dirbuffer[2048];
592 return S_FALSE;
593
594 m_first = FALSE;
595
596 // if ppidl is NULL, assume the caller was Skip(),
597 // so we don't care about the info
598 if (!ppidl)
599 return S_OK;
600
602
603 if (info->Name.Buffer)
604 {
605 StringCbCopyNW(m_pend, sizeof(buffer), info->Name.Buffer, info->Name.Length);
606 }
607
608 OBJECT_TYPE otype = MapTypeNameToType(info->TypeName.Buffer, info->TypeName.Length);
609
610 DWORD entryBufferLength = FIELD_OFFSET(NtPidlEntry, entryName) + sizeof(WCHAR);
611 if (info->Name.Buffer)
612 entryBufferLength += info->Name.Length;
613
614 if (otype < 0)
615 {
616 entryBufferLength += FIELD_OFFSET(NtPidlTypeData, typeName) + sizeof(WCHAR);
617
618 if (info->TypeName.Buffer)
619 {
620 entryBufferLength += info->TypeName.Length;
621 }
622 }
623
624 // allocate space for the terminator
625 entryBufferLength += FIELD_OFFSET(SHITEMID, abID);
626
627 NtPidlEntry* entry = (NtPidlEntry*) CoTaskMemAlloc(entryBufferLength);
628 if (!entry)
629 return E_OUTOFMEMORY;
630
631 memset(entry, 0, entryBufferLength);
632
633 entry->cb = FIELD_OFFSET(NtPidlEntry, entryName);
635 entry->objectType = otype;
636
637 if (info->Name.Buffer)
638 {
639 entry->entryNameLength = info->Name.Length;
640 StringCbCopyNW(entry->entryName, entryBufferLength, info->Name.Buffer, info->Name.Length);
641 entry->cb += entry->entryNameLength + sizeof(WCHAR);
642 }
643 else
644 {
645 entry->entryNameLength = 0;
646 entry->entryName[0] = 0;
647 entry->cb += sizeof(WCHAR);
648 }
649
650 if (otype < 0)
651 {
652 NtPidlTypeData * typedata = (NtPidlTypeData*) ((PBYTE) entry + entry->cb);
653 DWORD remainingSpace = entryBufferLength - ((PBYTE) (typedata->typeName) - (PBYTE) entry);
654
655 if (info->TypeName.Buffer)
656 {
657 typedata->typeNameLength = info->TypeName.Length;
658 StringCbCopyNW(typedata->typeName, remainingSpace, info->TypeName.Buffer, info->TypeName.Length);
659
660 entry->cb += typedata->typeNameLength + sizeof(WCHAR);
661 }
662 else
663 {
664 typedata->typeNameLength = 0;
665 typedata->typeName[0] = 0;
666 entry->cb += typedata->typeNameLength + sizeof(WCHAR);
667 }
668 }
669
670 *ppidl = (LPITEMIDLIST) entry;
671
672 return S_OK;
673 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
uint32_t entry
Definition: isohybrid.c:63
struct _OBJECT_DIRECTORY_INFORMATION * POBJECT_DIRECTORY_INFORMATION
OBJECT_TYPE MapTypeNameToType(LPCWSTR TypeName, DWORD cbTypeName)
Definition: ntobjenum.cpp:81
OBJECT_TYPE
Definition: ntobjenum.h:13
#define NT_OBJECT_PIDL_MAGIC
Definition: ntobjenum.h:25
NTSTATUS NTAPI NtQueryDirectoryObject(IN HANDLE DirectoryHandle, OUT PVOID Buffer, IN ULONG BufferLength, IN BOOLEAN ReturnSingleEntry, IN BOOLEAN RestartScan, IN OUT PULONG Context, OUT PULONG ReturnLength OPTIONAL)
Definition: obdir.c:490
BYTE * PBYTE
Definition: pedump.c:66
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
Definition: strsafe.h:255
WCHAR typeName[ANYSIZE_ARRAY]
Definition: ntobjenum.h:46
USHORT typeNameLength
Definition: ntobjenum.h:45
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define S_FALSE
Definition: winerror.h:2357
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

◆ Initialize()

HRESULT CEnumNTDirectory::Initialize ( PCWSTR  path)
inline

Definition at line 571 of file ntobjenum.cpp.

572 {
573 StringCbCopyExW(buffer, sizeof(buffer), path, &m_pend, NULL, 0);
574
576 if (!NT_SUCCESS(err))
577 {
578 ERR("NtOpenDirectoryObject failed for path %S with status=%x\n", buffer, err);
579 return HRESULT_FROM_NT(err);
580 }
581
582 if (m_pend[-1] != '\\')
583 *m_pend++ = '\\';
584
585 return S_OK;
586 }
#define ERR(fmt,...)
Definition: debug.h:110
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
static DWORD NtOpenObject(OBJECT_TYPE type, PHANDLE phandle, DWORD access, LPCWSTR path)
Definition: ntobjenum.cpp:50
@ DIRECTORY_OBJECT
Definition: ntobjenum.h:14
#define err(...)
STRSAFEAPI StringCbCopyExW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcbRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:210
#define HRESULT_FROM_NT(x)
Definition: winerror.h:94

◆ Next()

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

Definition at line 675 of file ntobjenum.cpp.

676 {
677 if (pceltFetched)
678 *pceltFetched = 0;
679
680 while (celt-- > 0)
681 {
682 HRESULT hr = EnumerateNext(rgelt);
683 if (hr != S_OK)
684 return hr;
685
686 if (pceltFetched)
687 (*pceltFetched)++;
688 if (rgelt)
689 rgelt++;
690 }
691
692 return S_OK;
693 }
HRESULT EnumerateNext(LPITEMIDLIST *ppidl)
Definition: ntobjenum.cpp:588
HRESULT hr
Definition: shlfolder.c:183

◆ Reset()

STDMETHODIMP CEnumNTDirectory::Reset ( )
inlineoverride

Implements IEnumIDList.

Definition at line 709 of file ntobjenum.cpp.

710 {
711 return E_NOTIMPL;
712 }

◆ Skip()

STDMETHODIMP CEnumNTDirectory::Skip ( ULONG  celt)
inlineoverride

Implements IEnumIDList.

Definition at line 695 of file ntobjenum.cpp.

696 {
697 while (celt > 0)
698 {
700 if (FAILED(hr))
701 return hr;
702 if (hr != S_OK)
703 break;
704 }
705
706 return S_OK;
707 }
#define FAILED(hr)
Definition: intsafe.h:51

Member Data Documentation

◆ buffer

WCHAR CEnumNTDirectory::buffer[MAX_PATH]
private

Definition at line 554 of file ntobjenum.cpp.

◆ m_directory

HANDLE CEnumNTDirectory::m_directory
private

Definition at line 555 of file ntobjenum.cpp.

◆ m_enumContext

ULONG CEnumNTDirectory::m_enumContext
private

Definition at line 557 of file ntobjenum.cpp.

◆ m_first

BOOL CEnumNTDirectory::m_first
private

Definition at line 556 of file ntobjenum.cpp.

◆ m_pend

PWSTR CEnumNTDirectory::m_pend
private

Definition at line 558 of file ntobjenum.cpp.


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