+Test code to dump root directory contents to stdout
authorshort <>
Sat, 23 Nov 2002 02:54:45 +0000 (02:54 +0000)
committershort <>
Sat, 23 Nov 2002 02:54:45 +0000 (02:54 +0000)
 - Psyche root directory successfuly retrieved!

src/libcaptive/client/init.c

index beaa325..28f04ed 100644 (file)
@@ -38,6 +38,7 @@
 #include "captive/storage.h"
 #include "captive/signal.h"    /* for captive_signal_init() */
 #include "reactos/ddk/psfuncs.h"       /* for PsGetCurrentThread() */
+#include <stdio.h>
 
 
 /* Are we initialized? */
@@ -73,9 +74,7 @@ NTSTATUS err;
 gboolean errbool;
 OBJECT_ATTRIBUTES root_ObjectAttributes;
 IO_STATUS_BLOCK root_IoStatusBlock;
-#if 0
-FILE_ID_BOTH_DIR_INFORMATION *FileIdBothDirInformation;
-#endif
+FILE_ID_BOTH_DIR_INFORMATION *FileIdBothDirInformation,*FileIdBothDirInformation_next;
 char QueryDirectory_buf[0x10000];
 
 #ifdef MAINTAINER_MODE
@@ -206,6 +205,48 @@ char QueryDirectory_buf[0x10000];
        g_return_val_if_fail(NT_SUCCESS(err),FALSE);
        g_return_val_if_fail(NT_SUCCESS(root_IoStatusBlock.Status),FALSE);
 
+       for (FileIdBothDirInformation=(gpointer)QueryDirectory_buf;
+                       (gpointer)FileIdBothDirInformation < (gpointer)(QueryDirectory_buf+root_IoStatusBlock.Information);
+                       FileIdBothDirInformation=FileIdBothDirInformation_next) {
+gint i;
+
+               FileIdBothDirInformation_next=(gpointer)(((char *)FileIdBothDirInformation)+FileIdBothDirInformation->NextEntryOffset);
+               /* do not exceed the returned buffer by this record */
+               g_assert((gpointer)FileIdBothDirInformation_next<=(gpointer)(QueryDirectory_buf+root_IoStatusBlock.Information));
+
+               printf("@%ld: FileIndex=%lu,EndOfFile=%lld,AllocationSize=%lld,FileId=0x%llX,",
+                               (long)(((char *)FileIdBothDirInformation)-((char *)QueryDirectory_buf)),        /* @%ld */
+                               FileIdBothDirInformation->FileIndex,
+                               FileIdBothDirInformation->EndOfFile.QuadPart,
+                               FileIdBothDirInformation->AllocationSize.QuadPart,
+                               (unsigned long long)FileIdBothDirInformation->FileId.QuadPart);
+               printf("ShortName=\"");
+               g_assert((FileIdBothDirInformation->ShortNameLength%sizeof(*FileIdBothDirInformation->ShortName))==0);
+               for (i=0;(unsigned)i<FileIdBothDirInformation->ShortNameLength/sizeof(*FileIdBothDirInformation->ShortName);i++) {
+gunichar uc=FileIdBothDirInformation->ShortName[i];
+
+                       if (g_unichar_isprint(uc) && uc<=0xFF)
+                               putchar(uc);
+                       else
+                               printf("[0x%X]",(unsigned)uc);
+                       }
+               printf("\",");
+               printf("FileName: ");
+               g_assert((FileIdBothDirInformation->FileNameLength)%sizeof(*FileIdBothDirInformation->FileName)==0);
+               for (i=0;(unsigned)i<FileIdBothDirInformation->FileNameLength/sizeof(*FileIdBothDirInformation->FileName);i++) {
+gunichar uc=FileIdBothDirInformation->FileName[i];
+
+                       if (g_unichar_isprint(uc) && uc<=0xFF)
+                               putchar(uc);
+                       else
+                               printf("[0x%X]",(unsigned)uc);
+                       }
+               printf("\n");
+               /* Last entry may be also marked by: 0==FileIdBothDirInformation->NextEntryOffset */
+               if (FileIdBothDirInformation_next==FileIdBothDirInformation)
+                       break;
+               }
+
 
        active=TRUE;
        return TRUE;