174{
179 BYTE DirectoryEntry [512];
184 ULONG EntryCount = 0;
185
186
192 };
193
194
195 RawUszAsz (DirectoryNameW->Buffer, DirectoryNameA);
196
197
198
201 DirectoryNameW,
202 0,
205 );
206
207
208
213 );
215 {
217 "Failed to open directory object \"%s\" (Status: %s)\n",
218 DirectoryNameA,
220 );
222 }
223 printf (
"\n Directory of %s\n\n", DirectoryNameA);
224
225 for(;;)
226 {
227
228
229
232 pDirectoryEntries,
233 sizeof DirectoryEntry,
238 );
240 {
242 "Failed to query directory object (Status: %s)\n",
244 );
247 }
249 {
250 break;
251 }
252 pDirectoryEntry = pDirectoryEntries;
254 {
258
260 {
262 DirectoryNameW,
263 & pDirectoryEntry->
Name,
264 & TargetObjectName
265 )
266 )
267 {
268
270 "%-16s %s -> %s\n",
274 );
275 }
276 else
277 {
279 "%-16s %s -> (error!)\n",
282 );
283 }
284 }
285 else
286 {
288 "%-16s %s\n",
291 );
292 }
293 ++ pDirectoryEntry;
294 ++ EntryCount;
295 }
296 };
297 printf (
"\n\t%lu object(s)\n", EntryCount);
298
299
300
302
303
304
305 if (
FALSE != Recurse)
306 {
309 {
311 {
314
315 CurrentName [0] =
L'\0';
316 wcscpy (CurrentName, DirectoryNameW->Buffer);
317 if (
wcslen (CurrentName) > 1)
318 {
320 }
324 }
325 ++ pDirectoryEntry;
326 }
327 }
329}
static HANDLE DirectoryHandle
WCHAR CurrentDirectory[1024]
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define InitializeObjectAttributes(p, n, a, r, s)
struct _OBJECT_DIRECTORY_INFORMATION * POBJECT_DIRECTORY_INFORMATION
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_NO_MORE_ENTRIES
NTSTATUS NTAPI NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
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)
static PCHAR WINAPI RawUszAsz(PWCHAR szU, PCHAR szA)
BOOL WINAPI ExpandSymbolicLink(IN PUNICODE_STRING DirectoryName, IN PUNICODE_STRING SymbolicLinkName, IN OUT PUNICODE_STRING TargetObjectName)
BOOL WINAPI ListDirectory(IN PUNICODE_STRING DirectoryNameW, IN BOOL Recurse)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)