ReactOS 0.4.15-dev-8100-g1887773
ntobjenum.cpp File Reference
#include "precomp.h"
#include <strsafe.h>
Include dependency graph for ntobjenum.cpp:

Go to the source code of this file.

Classes

struct  RootKeyEntry
 
class  CEnumRegRoot
 
class  CEnumRegKey
 
class  CEnumNTDirectory
 

Macros

#define MAX_EMBEDDED_DATA   32
 

Typedefs

typedef NTSTATUS(__stdcallpfnNtGenericOpen) (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES)
 
typedef NTSTATUS(__stdcallpfnNtOpenFile) (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, ULONG, ULONG)
 

Functions

static DWORD NtOpenObject (OBJECT_TYPE type, PHANDLE phandle, DWORD access, LPCWSTR path)
 
OBJECT_TYPE MapTypeNameToType (LPCWSTR TypeName, DWORD cbTypeName)
 
HRESULT ReadRegistryValue (HKEY root, PCWSTR path, PCWSTR valueName, PVOID *valueData, PDWORD valueLength)
 
HRESULT GetNTObjectSymbolicLinkTarget (LPCWSTR path, LPCWSTR entryName, PUNICODE_STRING LinkTarget)
 
HRESULT GetEnumRegistryRoot (IEnumIDList **ppil)
 
HRESULT GetEnumRegistryKey (LPCWSTR path, HKEY root, IEnumIDList **ppil)
 
HRESULT GetEnumNTDirectory (LPCWSTR path, IEnumIDList **ppil)
 

Variables

static struct RootKeyEntry RootKeys []
 
const LPCWSTR ObjectTypeNames []
 
const LPCWSTR RegistryTypeNames []
 

Macro Definition Documentation

◆ MAX_EMBEDDED_DATA

#define MAX_EMBEDDED_DATA   32

Typedef Documentation

◆ pfnNtGenericOpen

typedef NTSTATUS(__stdcall * pfnNtGenericOpen) (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES)

Definition at line 22 of file ntobjenum.cpp.

◆ pfnNtOpenFile

Definition at line 23 of file ntobjenum.cpp.

Function Documentation

◆ GetEnumNTDirectory()

HRESULT GetEnumNTDirectory ( LPCWSTR  path,
IEnumIDList **  ppil 
)

Definition at line 737 of file ntobjenum.cpp.

738{
739 return ShellObjectCreatorInit<CEnumNTDirectory>(path, IID_PPV_ARG(IEnumIDList, ppil));
740}
#define IID_PPV_ARG(Itype, ppType)

Referenced by CNtObjectFolder::EnumObjects().

◆ GetEnumRegistryKey()

HRESULT GetEnumRegistryKey ( LPCWSTR  path,
HKEY  root,
IEnumIDList **  ppil 
)

Definition at line 732 of file ntobjenum.cpp.

733{
734 return ShellObjectCreatorInit<CEnumRegKey>(path, root, IID_PPV_ARG(IEnumIDList, ppil));
735}

Referenced by CRegistryFolder::EnumObjects().

◆ GetEnumRegistryRoot()

HRESULT GetEnumRegistryRoot ( IEnumIDList **  ppil)

Definition at line 727 of file ntobjenum.cpp.

728{
729 return ShellObjectCreator<CEnumRegRoot>(IID_PPV_ARG(IEnumIDList, ppil));
730}

Referenced by CRegistryFolder::EnumObjects().

◆ GetNTObjectSymbolicLinkTarget()

HRESULT GetNTObjectSymbolicLinkTarget ( LPCWSTR  path,
LPCWSTR  entryName,
PUNICODE_STRING  LinkTarget 
)

Definition at line 151 of file ntobjenum.cpp.

152{
155 LPWSTR pend = buffer;
156
157 StringCbCopyExW(buffer, sizeof(buffer), path, &pend, NULL, 0);
158
159 if (pend[-1] != '\\')
160 {
161 *pend++ = '\\';
162 *pend = 0;
163 }
164
165 StringCbCatW(buffer, sizeof(buffer), entryName);
166
167 DbgPrint("GetNTObjectSymbolicLinkTarget %d\n", buffer);
168
169 LinkTarget->Length = 0;
170
172 if (!NT_SUCCESS(err))
173 return HRESULT_FROM_NT(err);
174
176 if (!NT_SUCCESS(err))
177 return HRESULT_FROM_NT(err);
178
180
181 return S_OK;
182}
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
#define DbgPrint
Definition: hal.h:12
#define S_OK
Definition: intsafe.h:52
#define SYMBOLIC_LINK_QUERY
Definition: nt_native.h:1265
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
static DWORD NtOpenObject(OBJECT_TYPE type, PHANDLE phandle, DWORD access, LPCWSTR path)
Definition: ntobjenum.cpp:50
@ SYMBOLICLINK_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
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define HRESULT_FROM_NT(x)
Definition: winerror.h:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Inout_ PUNICODE_STRING LinkTarget
Definition: zwfuncs.h:292

Referenced by CNtObjectFolder::CompareIDs(), CNtObjectFolder::GetDetailsEx(), CNtObjectFolder::GetDetailsOf(), and CNtObjectFolder::ResolveSymLink().

◆ MapTypeNameToType()

OBJECT_TYPE MapTypeNameToType ( LPCWSTR  TypeName,
DWORD  cbTypeName 
)

Definition at line 81 of file ntobjenum.cpp.

82{
83 if (!TypeName)
85
86 for (UINT i = 0; i < _countof(ObjectTypeNames); i++)
87 {
88 LPCWSTR typeName = ObjectTypeNames[i];
89 if (!StrCmpNW(typeName, TypeName, cbTypeName / sizeof(WCHAR)))
90 {
91 return (OBJECT_TYPE) i;
92 }
93 }
94
96}
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:504
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
const LPCWSTR ObjectTypeNames[]
Definition: ntobjenum.cpp:25
OBJECT_TYPE
Definition: ntobjenum.h:13
@ UNKNOWN_OBJECT_TYPE
Definition: ntobjenum.h:21
#define _countof(array)
Definition: sndvol32.h:70
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CEnumNTDirectory::EnumerateNext().

◆ NtOpenObject()

static DWORD NtOpenObject ( OBJECT_TYPE  type,
PHANDLE  phandle,
DWORD  access,
LPCWSTR  path 
)
static

Definition at line 50 of file ntobjenum.cpp.

51{
52 UNICODE_STRING ustr;
53
55
56 OBJECT_ATTRIBUTES open_struct = { sizeof(OBJECT_ATTRIBUTES), 0x00, &ustr, 0x40 };
57
58 if (type != FILE_OBJECT)
60
61 IO_STATUS_BLOCK ioStatusBlock;
62
63 switch (type)
64 {
65 case DIRECTORY_OBJECT: return NtOpenDirectoryObject(phandle, access, &open_struct);
66 case SYMBOLICLINK_OBJECT: return NtOpenSymbolicLinkObject(phandle, access, &open_struct);
67 case MUTANT_OBJECT: return NtOpenMutant(phandle, access, &open_struct);
68 case SECTION_OBJECT: return NtOpenSection(phandle, access, &open_struct);
69 case EVENT_OBJECT: return NtOpenEvent(phandle, access, &open_struct);
70 case SEMAPHORE_OBJECT: return NtOpenSemaphore(phandle, access, &open_struct);
71 case TIMER_OBJECT: return NtOpenTimer(phandle, access, &open_struct);
72 case KEY_OBJECT: return NtOpenKey(phandle, access, &open_struct);
73 case EVENTPAIR_OBJECT: return NtOpenEventPair(phandle, access, &open_struct);
74 case IOCOMPLETION_OBJECT: return NtOpenIoCompletion(phandle, access, &open_struct);
75 case FILE_OBJECT: return NtOpenFile(phandle, access, &open_struct, &ioStatusBlock, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0);
76 default:
78 }
79}
NTSTATUS NTAPI NtOpenSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: section.c:3569
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define FILE_SHARE_READ
Definition: compat.h:136
NTSTATUS NTAPI NtOpenEventPair(OUT PHANDLE EventPairHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: evtpair.c:136
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
NTSTATUS NTAPI NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: iocomp.c:326
NTSTATUS NTAPI NtOpenMutant(OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: mutant.c:162
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65
@ KEY_OBJECT
Definition: ntobjenum.h:16
@ MUTANT_OBJECT
Definition: ntobjenum.h:15
@ EVENT_OBJECT
Definition: ntobjenum.h:15
@ FILE_OBJECT
Definition: ntobjenum.h:17
@ IOCOMPLETION_OBJECT
Definition: ntobjenum.h:16
@ SECTION_OBJECT
Definition: ntobjenum.h:15
@ DIRECTORY_OBJECT
Definition: ntobjenum.h:14
@ SEMAPHORE_OBJECT
Definition: ntobjenum.h:15
@ EVENTPAIR_OBJECT
Definition: ntobjenum.h:16
@ TIMER_OBJECT
Definition: ntobjenum.h:16
NTSTATUS NTAPI NtOpenEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: event.c:181
NTSTATUS NTAPI NtOpenTimer(OUT PHANDLE TimerHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: timer.c:463
NTSTATUS NTAPI NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:393
NTSTATUS NTAPI NtOpenSemaphore(OUT PHANDLE SemaphoreHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: sem.c:161
struct _OBJECT_ATTRIBUTES OBJECT_ATTRIBUTES

Referenced by GetNTObjectSymbolicLinkTarget(), CEnumNTDirectory::Initialize(), CEnumRegKey::Initialize(), NtObjDirectory::read_directory(), and ReadRegistryValue().

◆ ReadRegistryValue()

HRESULT ReadRegistryValue ( HKEY  root,
PCWSTR  path,
PCWSTR  valueName,
PVOID valueData,
PDWORD  valueLength 
)

Definition at line 98 of file ntobjenum.cpp.

99{
100 HKEY hkey;
101
102 DWORD res;
103 if (root)
104 {
105 res = RegOpenKeyExW(root, *path == '\\' ? path + 1 : path, 0, STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &hkey);
106 }
107 else
108 {
110 }
111 if (!NT_SUCCESS(res))
112 {
113 ERR("RegOpenKeyExW failed for path %S with status=%x\n", path, res);
114 return HRESULT_FROM_NT(res);
115 }
116
117 res = RegQueryValueExW(hkey, valueName, NULL, NULL, NULL, valueLength);
118 if (!NT_SUCCESS(res))
119 {
120 ERR("RegQueryValueExW failed for path %S with status=%x\n", path, res);
121 return HRESULT_FROM_NT(res);
122 }
123
124 if (*valueLength > 0)
125 {
126 PBYTE data = (PBYTE) CoTaskMemAlloc(*valueLength);
127 *valueData = data;
128
129 res = RegQueryValueExW(hkey, valueName, NULL, NULL, data, valueLength);
130 if (!NT_SUCCESS(res))
131 {
133 *valueData = NULL;
134
135 RegCloseKey(hkey);
136
137 ERR("RegOpenKeyExW failed for path %S with status=%x\n", path, res);
138 return HRESULT_FROM_NT(res);
139 }
140 }
141 else
142 {
143 *valueData = NULL;
144 }
145
146 RegCloseKey(hkey);
147
148 return S_OK;
149}
#define ERR(fmt,...)
Definition: debug.h:113
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
BYTE * PBYTE
Definition: pedump.c:66

Variable Documentation

◆ ObjectTypeNames

const LPCWSTR ObjectTypeNames[]
Initial value:
= {
L"Directory", L"SymbolicLink",
L"Mutant", L"Section", L"Event", L"Semaphore",
L"Timer", L"Key", L"EventPair", L"IoCompletion",
L"Device", L"File", L"Controller", L"Profile",
L"Type", L"Desktop", L"WindowStation", L"Driver",
L"Token", L"Process", L"Thread", L"Adapter", L"Port",
0
}
#define L(x)
Definition: ntvdm.h:50

Definition at line 25 of file ntobjenum.cpp.

Referenced by CNtObjectFolder::GetDetailsEx(), CNtObjectFolder::GetDetailsOf(), and MapTypeNameToType().

◆ RegistryTypeNames

const LPCWSTR RegistryTypeNames[]
Initial value:
= {
L"REG_NONE",
L"REG_SZ",
L"REG_EXPAND_SZ",
L"REG_BINARY",
L"REG_DWORD",
L"REG_DWORD_BIG_ENDIAN",
L"REG_LINK",
L"REG_MULTI_SZ",
L"REG_RESOURCE_LIST",
L"REG_FULL_RESOURCE_DESCRIPTOR",
L"REG_RESOURCE_REQUIREMENTS_LIST",
L"REG_QWORD"
}

Definition at line 35 of file ntobjenum.cpp.

Referenced by CRegistryFolder::GetDetailsEx(), and CRegistryFolder::GetDetailsOf().

◆ RootKeys

struct RootKeyEntry RootKeys[]
static
Initial value:
= {
{ HKEY_CLASSES_ROOT, L"HKEY_CLASSES_ROOT" },
{ HKEY_CURRENT_USER, L"HKEY_CURRENT_USER" },
{ HKEY_LOCAL_MACHINE, L"HKEY_LOCAL_MACHINE" },
{ HKEY_USERS, L"HKEY_USERS" },
{ HKEY_CURRENT_CONFIG, L"HKEY_CURRENT_CONFIG" }
}
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_USERS
Definition: winreg.h:13

Referenced by CEnumRegRoot::EnumerateNext().