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