ReactOS  0.4.15-dev-489-g75a0787
CEnumNTDirectory Class Reference
Inheritance diagram for CEnumNTDirectory:
Collaboration diagram for CEnumNTDirectory:

Public Member Functions

 CEnumNTDirectory ()
 
 ~CEnumNTDirectory ()
 
HRESULT Initialize (PCWSTR path)
 
HRESULT EnumerateNext (LPITEMIDLIST *ppidl)
 
virtual HRESULT STDMETHODCALLTYPE Next (ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched)
 
virtual HRESULT STDMETHODCALLTYPE Skip (ULONG celt)
 
virtual HRESULT STDMETHODCALLTYPE Reset ()
 
virtual HRESULT STDMETHODCALLTYPE Clone (IEnumIDList **ppenum)
 
- 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)
 
- 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 561 of file ntobjenum.cpp.

Constructor & Destructor Documentation

◆ CEnumNTDirectory()

CEnumNTDirectory::CEnumNTDirectory ( )
inline

Definition at line 572 of file ntobjenum.cpp.

574  {
575  }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416

◆ ~CEnumNTDirectory()

CEnumNTDirectory::~CEnumNTDirectory ( )
inline

Definition at line 577 of file ntobjenum.cpp.

578  {
580  }
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399

Member Function Documentation

◆ Clone()

virtual HRESULT STDMETHODCALLTYPE CEnumNTDirectory::Clone ( IEnumIDList **  ppenum)
inlinevirtual

Implements IEnumIDList.

Definition at line 725 of file ntobjenum.cpp.

726  {
727  return E_NOTIMPL;
728  }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ EnumerateNext()

HRESULT CEnumNTDirectory::EnumerateNext ( LPITEMIDLIST ppidl)
inline

Definition at line 599 of file ntobjenum.cpp.

600  {
601  BYTE dirbuffer[2048];
603  return S_FALSE;
604 
605  m_first = FALSE;
606 
607  // if ppidl is NULL, assume the caller was Skip(),
608  // so we don't care about the info
609  if (!ppidl)
610  return S_OK;
611 
613 
614  if (info->Name.Buffer)
615  {
616  StringCbCopyNW(m_pend, sizeof(buffer), info->Name.Buffer, info->Name.Length);
617  }
618 
619  OBJECT_TYPE otype = MapTypeNameToType(info->TypeName.Buffer, info->TypeName.Length);
620 
621  DWORD entryBufferLength = FIELD_OFFSET(NtPidlEntry, entryName) + sizeof(WCHAR);
622  if (info->Name.Buffer)
623  entryBufferLength += info->Name.Length;
624 
625  if (otype < 0)
626  {
627  entryBufferLength += FIELD_OFFSET(NtPidlTypeData, typeName) + sizeof(WCHAR);
628 
629  if (info->TypeName.Buffer)
630  {
631  entryBufferLength += info->TypeName.Length;
632  }
633  }
634 
635  // allocate space for the terminator
636  entryBufferLength += FIELD_OFFSET(SHITEMID, abID);
637 
638  NtPidlEntry* entry = (NtPidlEntry*) CoTaskMemAlloc(entryBufferLength);
639  if (!entry)
640  return E_OUTOFMEMORY;
641 
642  memset(entry, 0, entryBufferLength);
643 
644  entry->cb = FIELD_OFFSET(NtPidlEntry, entryName);
645  entry->magic = NT_OBJECT_PIDL_MAGIC;
646  entry->objectType = otype;
647 
648  if (info->Name.Buffer)
649  {
650  entry->entryNameLength = info->Name.Length;
651  StringCbCopyNW(entry->entryName, entryBufferLength, info->Name.Buffer, info->Name.Length);
652  entry->cb += entry->entryNameLength + sizeof(WCHAR);
653  }
654  else
655  {
656  entry->entryNameLength = 0;
657  entry->entryName[0] = 0;
658  entry->cb += sizeof(WCHAR);
659  }
660 
661  if (otype < 0)
662  {
663  NtPidlTypeData * typedata = (NtPidlTypeData*) ((PBYTE) entry + entry->cb);
664  DWORD remainingSpace = entryBufferLength - ((PBYTE) (typedata->typeName) - (PBYTE) entry);
665 
666  if (info->TypeName.Buffer)
667  {
668  typedata->typeNameLength = info->TypeName.Length;
669  StringCbCopyNW(typedata->typeName, remainingSpace, info->TypeName.Buffer, info->TypeName.Length);
670 
671  entry->cb += typedata->typeNameLength + sizeof(WCHAR);
672  }
673  else
674  {
675  typedata->typeNameLength = 0;
676  typedata->typeName[0] = 0;
677  entry->cb += typedata->typeNameLength + sizeof(WCHAR);
678  }
679  }
680 
681  *ppidl = (LPITEMIDLIST) entry;
682 
683  return S_OK;
684  }
#define TRUE
Definition: types.h:120
OBJECT_TYPE MapTypeNameToType(LPCWSTR TypeName, DWORD cbTypeName)
Definition: ntobjenum.cpp:92
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
Definition: strsafe.h:255
GLuint buffer
Definition: glext.h:5915
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:498
WCHAR typeName[ANYSIZE_ARRAY]
Definition: ntobjenum.h:56
#define NT_OBJECT_PIDL_MAGIC
Definition: ntobjenum.h:35
struct _OBJECT_DIRECTORY_INFORMATION * POBJECT_DIRECTORY_INFORMATION
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
OBJECT_TYPE
Definition: ntobjenum.h:23
USHORT typeNameLength
Definition: ntobjenum.h:55
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t entry
Definition: isohybrid.c:63
unsigned char BYTE
Definition: xxhash.c:193
#define S_OK
Definition: intsafe.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
BYTE * PBYTE
Definition: pedump.c:66
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

◆ Initialize()

HRESULT CEnumNTDirectory::Initialize ( PCWSTR  path)
inline

Definition at line 582 of file ntobjenum.cpp.

583  {
584  StringCbCopyExW(buffer, sizeof(buffer), path, &m_pend, NULL, 0);
585 
587  if (!NT_SUCCESS(err))
588  {
589  ERR("NtOpenDirectoryObject failed for path %S with status=%x\n", buffer, err);
590  return HRESULT_FROM_NT(err);
591  }
592 
593  if (m_pend[-1] != '\\')
594  *m_pend++ = '\\';
595 
596  return S_OK;
597  }
GLuint buffer
Definition: glext.h:5915
STRSAFEAPI StringCbCopyExW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcbRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:210
smooth NULL
Definition: ftsmooth.c:416
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define HRESULT_FROM_NT(x)
Definition: winerror.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define err(...)
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
static DWORD NtOpenObject(OBJECT_TYPE type, PHANDLE phandle, DWORD access, LPCWSTR path)
Definition: ntobjenum.cpp:61

◆ Next()

virtual HRESULT STDMETHODCALLTYPE CEnumNTDirectory::Next ( ULONG  celt,
LPITEMIDLIST rgelt,
ULONG pceltFetched 
)
inlinevirtual

Definition at line 686 of file ntobjenum.cpp.

687  {
688  if (pceltFetched)
689  *pceltFetched = 0;
690 
691  while (celt-- > 0)
692  {
693  HRESULT hr = EnumerateNext(rgelt);
694  if (hr != S_OK)
695  return hr;
696 
697  if (pceltFetched)
698  (*pceltFetched)++;
699  if (rgelt)
700  rgelt++;
701  }
702 
703  return S_OK;
704  }
HRESULT hr
Definition: shlfolder.c:183
HRESULT EnumerateNext(LPITEMIDLIST *ppidl)
Definition: ntobjenum.cpp:599
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59

◆ Reset()

virtual HRESULT STDMETHODCALLTYPE CEnumNTDirectory::Reset ( void  )
inlinevirtual

Implements IEnumIDList.

Definition at line 720 of file ntobjenum.cpp.

721  {
722  return E_NOTIMPL;
723  }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Skip()

virtual HRESULT STDMETHODCALLTYPE CEnumNTDirectory::Skip ( ULONG  celt)
inlinevirtual

Implements IEnumIDList.

Definition at line 706 of file ntobjenum.cpp.

707  {
708  while (celt > 0)
709  {
711  if (FAILED(hr))
712  return hr;
713  if (hr != S_OK)
714  break;
715  }
716 
717  return S_OK;
718  }
HRESULT hr
Definition: shlfolder.c:183
HRESULT EnumerateNext(LPITEMIDLIST *ppidl)
Definition: ntobjenum.cpp:599
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59

Member Data Documentation

◆ buffer

WCHAR CEnumNTDirectory::buffer[MAX_PATH]
private

Definition at line 565 of file ntobjenum.cpp.

◆ m_directory

HANDLE CEnumNTDirectory::m_directory
private

Definition at line 566 of file ntobjenum.cpp.

◆ m_enumContext

ULONG CEnumNTDirectory::m_enumContext
private

Definition at line 568 of file ntobjenum.cpp.

◆ m_first

BOOL CEnumNTDirectory::m_first
private

Definition at line 567 of file ntobjenum.cpp.

◆ m_pend

PWSTR CEnumNTDirectory::m_pend
private

Definition at line 569 of file ntobjenum.cpp.


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