1 /* 2 * reactos/apps/lpc/dumpinfo.c 3 * 4 * ReactOS Operating System 5 * 6 * Dump a kernel object's attributes by its handle. 7 * 8 * 19990627 (Emanuele Aliberti) 9 * Initial implementation. 10 * 19990704 (EA) 11 * Added code to find the basic information buffer size 12 * for the LPC port object. 13 * 19990710 (EA) 14 * 15 */ 16 #include <windows.h> 17 #include <stdio.h> 18 #include <stdlib.h> 19 #include <ddk/ntddk.h> 20 21 #define BUF_SIZE 1024 22 #define MAX_BASIC_INFO_SIZE 512 23 24 25 extern 26 NTSTATUS 27 (WINAPI * QueryObject)( 28 IN HANDLE ObjectHandle, 29 IN CINT ObjectInformationClass, 30 OUT PVOID ObjectInformation, 31 IN ULONG Length, 32 OUT PULONG ResultLength 33 ); 34 35 extern 36 NTSTATUS 37 (WINAPI * QueryInformationPort)( 38 IN HANDLE PortHandle, 39 IN CINT PortInformationClass, /* guess */ 40 OUT PVOID PortInformation, /* guess */ 41 IN ULONG PortInformationLength, /* guess */ 42 OUT PULONG ReturnLength /* guess */ 43 ); 44 45 46 /* 47 static 48 VOID 49 DumpBuffer( 50 char *Name, 51 BYTE *buffer, 52 ULONG size 53 ) 54 { 55 register ULONG i = 0; 56 57 printf("%s [%d] = ",Name,size); 58 for ( i = 0; 59 i != size; 60 ++i 61 ) 62 { 63 printf("%02X",buffer[i]); 64 } 65 printf("\n"); 66 } 67 */ 68 69 VOID 70 DumpInfo ( 71 LPCWSTR Name, 72 NTSTATUS Status, 73 LPCWSTR Comment, 74 HANDLE Port 75 ) 76 { 77 BYTE ObjectInformation [BUF_SIZE] = {0}; 78 ULONG ResultLength; 79 80 wprintf( 81 L"Port \"%s\" %s:\n", 82 Name, 83 Comment 84 ); 85 86 printf("\tStatus = %08X\n",Status); 87 printf("\tPort = %08X\n\n",Port); 88 /* 89 * Query object information. 90 */ 91 printf("Basic Information:\n"); 92 Status = QueryObject( 93 Port, 94 ObjectBasicInformation, 95 ObjectInformation, 96 sizeof (LPC_PORT_BASIC_INFORMATION), 97 & ResultLength 98 ); 99 if (Status == STATUS_SUCCESS) 100 { 101 PLPC_PORT_BASIC_INFORMATION i; 102 103 i = (PLPC_PORT_BASIC_INFORMATION) ObjectInformation; 104 105 printf( "\tUnknown01 = 0x%08X\n", i->Unknown0 ); 106 printf( "\tUnknown02 = 0x%08X\n", i->Unknown1 ); 107 printf( "\tUnknown03 = 0x%08X\n", i->Unknown2 ); 108 printf( "\tUnknown04 = 0x%08X\n", i->Unknown3 ); 109 printf( "\tUnknown05 = 0x%08X\n", i->Unknown4 ); 110 printf( "\tUnknown06 = 0x%08X\n", i->Unknown5 ); 111 printf( "\tUnknown07 = 0x%08X\n", i->Unknown6 ); 112 printf( "\tUnknown08 = 0x%08X\n", i->Unknown7 ); 113 printf( "\tUnknown09 = 0x%08X\n", i->Unknown8 ); 114 printf( "\tUnknown10 = 0x%08X\n", i->Unknown9 ); 115 printf( "\tUnknown11 = 0x%08X\n", i->Unknown10 ); 116 printf( "\tUnknown12 = 0x%08X\n", i->Unknown11 ); 117 printf( "\tUnknown13 = 0x%08X\n", i->Unknown12 ); 118 printf( "\tUnknown14 = 0x%08X\n", i->Unknown13 ); 119 } 120 else 121 { 122 printf("\tStatus = %08X\n",Status); 123 } 124 printf("Type Information:\n"); 125 Status = QueryObject( 126 Port, 127 ObjectTypeInformation, 128 ObjectInformation, 129 sizeof ObjectInformation, 130 & ResultLength 131 ); 132 if (Status == STATUS_SUCCESS) 133 { 134 OBJECT_TYPE_INFORMATION * i; 135 136 i = (OBJECT_TYPE_INFORMATION *) ObjectInformation; 137 138 wprintf( 139 L"\tName: \"%s\"\n", 140 (i->Name.Length ? i->Name.Buffer : L"") 141 ); 142 /* 143 FIXME: why this always raise an access violation exception? 144 wprintf( 145 L"\tType: \"%s\"\n", 146 (i->Type.Length ? i->Type.Buffer : L"") 147 ); 148 /**/ 149 printf( 150 "\tTotal Handles: %d\n", 151 i->TotalHandles 152 ); 153 printf( 154 "\tReference Count: %d\n", 155 i->ReferenceCount 156 ); 157 } 158 else 159 { 160 printf("\tStatus = %08X\n",Status); 161 } 162 printf("Name Information:\n"); 163 Status = QueryObject( 164 Port, 165 ObjectNameInformation, 166 ObjectInformation, 167 sizeof ObjectInformation, 168 & ResultLength 169 ); 170 if (Status == STATUS_SUCCESS) 171 { 172 OBJECT_NAME_INFORMATION * i; 173 174 i = (OBJECT_NAME_INFORMATION *) ObjectInformation; 175 wprintf( 176 L"\tName: \"%s\"\n", 177 (i->Name.Length ? i->Name.Buffer : L"") 178 ); 179 } 180 else 181 { 182 printf("\tStatus = %08X\n",Status); 183 } 184 printf("Data Information:\n"); 185 Status = QueryObject( 186 Port, 187 ObjectDataInformation, 188 ObjectInformation, 189 sizeof ObjectInformation, 190 & ResultLength 191 ); 192 if (Status == STATUS_SUCCESS) 193 { 194 OBJECT_DATA_INFORMATION * i; 195 196 i = (OBJECT_DATA_INFORMATION *) ObjectInformation; 197 printf( 198 "\tInherit Handle: %s\n", 199 (i->bInheritHandle ? "TRUE" : "FALSE") 200 ); 201 printf( 202 "\tProtect from Close: %s\n", 203 (i->bProtectFromClose ? "TRUE" : "FALSE") 204 ); 205 } 206 else 207 { 208 printf("\tStatus = %08X\n",Status); 209 } 210 //--- 211 printf("Port Information:\n"); 212 /* Status = QueryInformationPort( 213 Port, 214 1, /* info class * / 215 ObjectInformation, 216 sizeof ObjectInformation, 217 & ResultLength 218 ); 219 if (Status == STATUS_SUCCESS) 220 { 221 DWORD * i = ObjectInformation; 222 int j = 0; 223 224 while (j < ResultLength / sizeof (DWORD)) 225 { 226 printf("\t%08X\n",i[j]); 227 ++j; 228 } 229 } 230 else 231 { 232 printf("\tStatus = %08X\n",Status); 233 } 234 */ 235 } 236 237 238 /* EOF */ 239