ReactOS 0.4.15-dev-7777-g2f6b175
IoEaTest.cpp
Go to the documentation of this file.
1// IoEaTest.cpp : Defines the entry point for the console application.
2//
3
4#include "stdafx.h"
5
6#include <stdio.h>
7#include <windows.h>
8
9typedef struct _FILE_FULL_EA_INFORMATION {
14 CHAR EaName[1];
16
17#define ULONG_PTR unsigned char*
18
19#define NTSTATUS unsigned int
20
21#define STATUS_EA_LIST_INCONSISTENT 0x80000014L
22#define STATUS_SUCCESS 0x00000000L
23
24/*
25 * @implemented
26 */
31 OUT PULONG ErrorOffset)
32{
33 PFILE_FULL_EA_INFORMATION EaBufferEnd;
34 ULONG NextEaBufferOffset;
35 UINT IntEaLength;
36
37 /* Length of the rest. Initialize it to EaLength */
38 IntEaLength = EaLength;
39 /* Initialize EaBuffer to EaBuffer */
40 EaBufferEnd = EaBuffer;
41
42 /* The rest length of the buffer */
43 /* 8 = sizeof(ULONG) + sizeof(UCHAR) + sizeof(UCHAR) + sizeof(USHORT) */
44 while (IntEaLength >= 8)
45 {
46 /* The rest of the buffer must be greater than sizeof(FILE_FULL_EA_INFORMATION) + buffer */
47 NextEaBufferOffset = EaBufferEnd->EaNameLength+EaBufferEnd->EaValueLength + 9;
48 if (IntEaLength >= NextEaBufferOffset)
49 {
50 /* is the EaBufferName terminated with zero? */
51 if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0)
52 {
53 /* more EaBuffers ahead */
54 if (EaBufferEnd->NextEntryOffset == 0)
55 {
56 /* test the rest buffersize */
57 IntEaLength = IntEaLength - NextEaBufferOffset;
58 if (IntEaLength>=0)
59 {
60 return STATUS_SUCCESS;
61 }
62 }
63 else
64 {
65 /*
66 From MSDN (http://msdn2.microsoft.com/en-us/library/ms795740.aspx).
67 For all entries except the last, the value of NextEntryOffset must be greater
68 than zero and must fall on a ULONG boundary.
69 */
70 NextEaBufferOffset = ((NextEaBufferOffset + 3) & 0xFFFFFFFC);
71 if ((EaBufferEnd->NextEntryOffset == NextEaBufferOffset) && (EaBufferEnd->NextEntryOffset>0))
72 {
73 /* The rest of the buffer must be greater than the next offset */
74 IntEaLength = IntEaLength - EaBufferEnd->NextEntryOffset;
75 if (IntEaLength>=0)
76 {
77 EaBufferEnd = (PFILE_FULL_EA_INFORMATION)((ULONG_PTR)EaBufferEnd + EaBufferEnd->NextEntryOffset);
78 continue;
79 }
80 }
81 }
82 }
83 }
84 break;
85 }
86
87 if (ErrorOffset != NULL)
88 {
89 /* calculate the error offset. */
90 *ErrorOffset = (ULONG)((ULONG_PTR)EaBufferEnd - (ULONG_PTR)EaBuffer);
91 }
92
94}
95
96
97
98
99
100void CheckROSAgainstWinAndPrintResult(PFILE_FULL_EA_INFORMATION WinEaBuffer,PFILE_FULL_EA_INFORMATION ROSEaBuffer,NTSTATUS WinStatus,NTSTATUS ROSStatus,ULONG WinErrorOffset,ULONG ROSErrorOffset,int iBufferLength,int iTestCount,ULONG TestEaLength)
101{
102 printf("Subtest:%i Status:%x EaErrorOffset:%x TestEaLength:%i passed - ",iTestCount,WinStatus,WinErrorOffset,TestEaLength);
103 if (memcmp(WinEaBuffer,ROSEaBuffer,iBufferLength)==0)
104 {
105 if (WinStatus == ROSStatus)
106 {
107 if (WinErrorOffset == ROSErrorOffset)
108 {
109 printf("okay\n");
110 return;
111 }
112 }
113 }
114 printf("*failed*\n");
115}
116
117typedef NTSTATUS (*NTAPI pIoCheckEaBufferValidity) (IN PFILE_FULL_EA_INFORMATION EaBuffer,IN ULONG EaLength,OUT PULONG ErrorOffset);
118
119typedef PVOID (*NTAPI pMmPageEntireDriver) (IN PVOID AddressWithinSection);
120
121#define RANDOM_INIT_ERROR 0xDEADBAD0
122#define TEST_BUFFER_LEN 256
123
124int _tmain(int argc, _TCHAR* argv[])
125{
126 void *pFunction;
127 pIoCheckEaBufferValidity IoCheckEaBufferValidity;
128
129 HMODULE hKrnlMod = LoadLibrary(L"ntoskrnl.exe");
130 if (hKrnlMod)
131 {
132 pFunction = GetProcAddress(hKrnlMod,"IoCheckEaBufferValidity");
133 IoCheckEaBufferValidity = (pIoCheckEaBufferValidity)pFunction;
135 {
136 /* Check tes Windows Function */
137 ULONG ulWinError;
138 ULONG ulROSError;
139 NTSTATUS WinStatus;
140 NTSTATUS ROSStatus;
141 PFILE_FULL_EA_INFORMATION WinEaBuffer;
142 PFILE_FULL_EA_INFORMATION ROSEaBuffer;
143 char szTest[100] = "FltMgr";
144 int iTestCount,i;
145 ULONG TestEaLength;
146 UCHAR TestEaBufferFlags;
147
148 // Test the flag
149 TestEaBufferFlags = 0;
150
151 iTestCount = 1;
154
155
156 printf("1.) Test : *********************\n");
157
158 /* Check EaLength calculation */
159 /* Here all zero : only i>9 pass the test with STATUS_SUCCESS */
160
161 for (i=0;i<TEST_BUFFER_LEN;i++)
162 {
163 TestEaLength = i;
164 // Windows
165 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
166 ulWinError = RANDOM_INIT_ERROR;
167 WinEaBuffer->Flags = TestEaBufferFlags;
168 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
169
170 // ROS
171 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
172 ulROSError = RANDOM_INIT_ERROR;
173 ROSEaBuffer->Flags = TestEaBufferFlags;
174 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
175
176 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
177 iTestCount++;
178 }
179
180 printf("2.) Test : *********************\n");
181
182 /* Here all zero but EaBuffer::EaName is set : will always end in STATUS_EA_LIST_INCONSISTENT */
183 /* There must a link to EaBuffer::EaName */
184 for (i=0;i<TEST_BUFFER_LEN;i++)
185 {
186 TestEaLength = i;
187 // Windows
188 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
189 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
190 ulWinError = RANDOM_INIT_ERROR;
191 WinEaBuffer->Flags = TestEaBufferFlags;
192 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
193
194 // ROS
195 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
196 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
197 ulROSError = RANDOM_INIT_ERROR;
198 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
199
200 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
201 iTestCount++;
202 }
203
204 printf("3.) Test : *********************\n");
205
206 /* Here EaBuffer::EaName is set and EaBuffer::EaNameLength is count up. EaLength is maxbuffer: STATUS_SUCCESS when EaBuffer::EaNameLength>strlen(EaBuffer::EaName) */
207 TestEaLength = TEST_BUFFER_LEN;
208 for (i=0;i<TEST_BUFFER_LEN;i++)
209 {
210
211 // Windows
212 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
213 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
214 WinEaBuffer->EaNameLength = i;
215 ulWinError = RANDOM_INIT_ERROR;
216 WinEaBuffer->Flags = TestEaBufferFlags;
217 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
218
219 // ROS
220 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
221 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
222 ROSEaBuffer->EaNameLength = i;
223 ulROSError = RANDOM_INIT_ERROR;
224 ROSEaBuffer->Flags = TestEaBufferFlags;
225 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
226
227 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
228 iTestCount++;
229 }
230
231 printf("4.) Test : *********************\n");
232
233 /* Here EaBuffer::EaName is set and EaBuffer::EaNameLength is strlen(EaBuffer::EaName). EaLength is count: STATUS_SUCCESS when EaLength>=17 (EaBuffer::EaNameLength+9) */
234 for (i=0;i<TEST_BUFFER_LEN;i++)
235 {
236 TestEaLength = i;
237 // Windows
238 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
239 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
240 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName);
241 ulWinError = RANDOM_INIT_ERROR;
242 WinEaBuffer->Flags = TestEaBufferFlags;
243 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
244
245 // ROS
246 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
247 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
248 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName);
249 ulROSError = RANDOM_INIT_ERROR;
250 ROSEaBuffer->Flags = TestEaBufferFlags;
251 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
252
253 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
254 iTestCount++;
255 }
256
257 printf("5.) Test : *********************\n");
258
259 /* Here EaBuffer::EaName is set and EaBuffer::EaNameLength is strlen(EaBuffer::EaName) EaBuffer::EaValueLength is strlen(EaBuffer::EaName)+1. EaLength is count: STATUS_SUCCESS when EaLength>=26 (EaBuffer::EaNameLength+EaBuffer::EaValueLength+9) */
260 for (i=0;i<TEST_BUFFER_LEN;i++)
261 {
262 TestEaLength = i;
263 // Windows
264 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
265 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
266 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName);
267 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName)+1;
268 ulWinError = RANDOM_INIT_ERROR;
269 WinEaBuffer->Flags = TestEaBufferFlags;
270 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
271
272 // ROS
273 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
274 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
275 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName);
276 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName)+1;
277 ulROSError = RANDOM_INIT_ERROR;
278 ROSEaBuffer->Flags = TestEaBufferFlags;
279 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
280
281 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
282 iTestCount++;
283 }
284
285
286 printf("6.) Test : *********************\n");
287
288 /* The same test like 5.) but more data in the buffer*/
289 /* Here EaBuffer::EaName is set and EaBuffer::EaNameLength is strlen(EaBuffer::EaName) EaBuffer::EaValueLength is strlen(EaBuffer::EaName)+1. EaLength is count: STATUS_SUCCESS when EaLength>=26 (EaBuffer::EaNameLength+EaBuffer::EaValueLength+9) */
290
291 for (i=0;i<TEST_BUFFER_LEN;i++)
292 {
293 TestEaLength = i;
294 // Windows
295 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
297 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
298 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName);
299 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName)+1;
300 ulWinError = RANDOM_INIT_ERROR;
301 WinEaBuffer->Flags = TestEaBufferFlags;
302 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
303
304 // ROS
305 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
307 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
308 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName);
309 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName)+1;
310 ulROSError = RANDOM_INIT_ERROR;
311 ROSEaBuffer->Flags = TestEaBufferFlags;
312 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
313
314 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
315 iTestCount++;
316 }
317
318 printf("7.) Test : *********************\n");
319
320 /* The same test like 6.) but wrong strlen */
321 /* Here EaBuffer::EaName is set and EaBuffer::EaNameLength is strlen(EaBuffer::EaName) EaBuffer::EaValueLength is strlen(EaBuffer::EaName)+1. EaLength is count: will always end in STATUS_EA_LIST_INCONSISTENT */
322 for (i=0;i<TEST_BUFFER_LEN;i++)
323 {
324 TestEaLength = i;
325 // Windows
326 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
328 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
329 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName)-1;
330 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName)+2;
331 ulWinError = RANDOM_INIT_ERROR;
332 WinEaBuffer->Flags = TestEaBufferFlags;
333 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
334
335 // ROS
336 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
338 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
339 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName)-1;
340 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName)+2;
341 ulROSError = RANDOM_INIT_ERROR;
342 ROSEaBuffer->Flags = TestEaBufferFlags;
343 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
344
345 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
346 iTestCount++;
347 }
348
349
350 printf("8.) Test : *********************\n");
351
352 /* Here WinEaBuffer->NextEntryOffset test : STATUS_SUCCESS when NextEntryOffset=0 else STATUS_EA_LIST_INCONSISTENT when NextEntryOffset = 28 = 8+8+9 ((WinEaBuffer->EaNameLength+WinEaBuffer->EaNameLength+9)+3)&0xFFFFFFFC then ErrorOffset 28 */
353 /* From the MSDN (http://msdn2.microsoft.com/en-us/library/ms795740.aspx). For all entries except the last, the value of NextEntryOffset must be greater than zero and must fall on a ULONG boundary.*/
354 for (i=0;i<TEST_BUFFER_LEN;i++)
355 {
356 TestEaLength = TEST_BUFFER_LEN;
357 // Windows
358 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
360 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
361 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName);
362 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName);
363 ulWinError = RANDOM_INIT_ERROR;
364 WinEaBuffer->Flags = TestEaBufferFlags;
365 WinEaBuffer->NextEntryOffset = i;
366 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
367
368 // ROS
369 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
371 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
372 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName);
373 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName);
374 ulROSError = RANDOM_INIT_ERROR;
375 ROSEaBuffer->Flags = TestEaBufferFlags;
376 ROSEaBuffer->NextEntryOffset = i;
377 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
378
379 printf("%i-",ROSEaBuffer->NextEntryOffset);
380 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
381 iTestCount++;
382 }
383
384 printf("9.) Test : *********************\n");
385
386 /* Here WinEaBuffer->NextEntryOffset test wrong strlen: STATUS_SUCCESS NextEntryOffset=0 & NextEntryOffset = 28 = 8+8+9 ((WinEaBuffer->EaNameLength+WinEaBuffer->EaNameLength+9)+3)&0xFFFFFFFC */
387 /* From the MSDN (http://msdn2.microsoft.com/en-us/library/ms795740.aspx). For all entries except the last, the value of NextEntryOffset must be greater than zero and must fall on a ULONG boundary.*/
388 for (i=0;i<TEST_BUFFER_LEN;i++)
389 {
390 TestEaLength = TEST_BUFFER_LEN;
391 // Windows
392 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
393 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
394
395 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName)-1;
396 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName);
397 ulWinError = RANDOM_INIT_ERROR;
398 WinEaBuffer->Flags = TestEaBufferFlags;
399 WinEaBuffer->NextEntryOffset = i;
400 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
401
402 // ROS
403 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
404 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
405
406 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName)-1;
407 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName);
408 ulROSError = RANDOM_INIT_ERROR;
409 ROSEaBuffer->Flags = TestEaBufferFlags;
410 ROSEaBuffer->NextEntryOffset = i;
411 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
412
413 printf("%i-",ROSEaBuffer->NextEntryOffset);
414 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
415 iTestCount++;
416 }
417
418 printf("10.) Test : *********************\n");
419
420 /* Here WinEaBuffer->NextEntryOffset test wrong strlen: STATUS_SUCCESS NextEntryOffset=0 & NextEntryOffset = 28 = 8+8+9 ((WinEaBuffer->EaNameLength+WinEaBuffer->EaNameLength+9)+3)&0xFFFFFFFC */
421 /* From the MSDN (http://msdn2.microsoft.com/en-us/library/ms795740.aspx). For all entries except the last, the value of NextEntryOffset must be greater than zero and must fall on a ULONG boundary.*/
422 for (i=0;i<TEST_BUFFER_LEN;i++)
423 {
424 TestEaLength = TEST_BUFFER_LEN;
425 // Windows
426 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
427 sprintf(WinEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
428
429 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName)+1;
430 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName)+1;
431 ulWinError = RANDOM_INIT_ERROR;
432 WinEaBuffer->Flags = TestEaBufferFlags;
433 WinEaBuffer->NextEntryOffset = i;
434 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
435
436 // ROS
437 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
438 sprintf(ROSEaBuffer->EaName,"%x",RANDOM_INIT_ERROR);
439
440 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName)+1;
441 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName)+1;
442 ulROSError = RANDOM_INIT_ERROR;
443 ROSEaBuffer->Flags = TestEaBufferFlags;
444 ROSEaBuffer->NextEntryOffset = i;
445 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
446
447 printf("%i-",ROSEaBuffer->NextEntryOffset);
448 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
449 iTestCount++;
450 }
451
452 printf("11.) Test : *********************\n");
453
454 /* Here WinEaBuffer->NextEntryOffset : */
455 for (i=0;i<TEST_BUFFER_LEN;i++)
456 {
457 TestEaLength = TEST_BUFFER_LEN;
458 // Windows
459 memset(WinEaBuffer,0,TEST_BUFFER_LEN);
461
462 WinEaBuffer->EaNameLength = (UCHAR)strlen(WinEaBuffer->EaName);
463 WinEaBuffer->EaValueLength = (UCHAR)strlen(WinEaBuffer->EaName);
464 ulWinError = RANDOM_INIT_ERROR;
465 WinEaBuffer->Flags = TestEaBufferFlags;
466 WinEaBuffer->NextEntryOffset = ((WinEaBuffer->EaNameLength+WinEaBuffer->EaNameLength+9)+3)&0xFFFFFFFC;
467 WinStatus = IoCheckEaBufferValidity(WinEaBuffer,TestEaLength,&ulWinError);
468
469 // ROS
470 memset(ROSEaBuffer,0,TEST_BUFFER_LEN);
472
473 ROSEaBuffer->EaNameLength = (UCHAR)strlen(ROSEaBuffer->EaName);
474 ROSEaBuffer->EaValueLength = (UCHAR)strlen(ROSEaBuffer->EaName);
475 ulROSError = RANDOM_INIT_ERROR;
476 ROSEaBuffer->Flags = TestEaBufferFlags;
477 ROSEaBuffer->NextEntryOffset = ((ROSEaBuffer->EaNameLength+ROSEaBuffer->EaNameLength+9)+3)&0xFFFFFFFC;
478 ROSStatus = IoCheckEaBufferValidityROS(ROSEaBuffer,TestEaLength,&ulROSError);
479
480 printf("%i-",ROSEaBuffer->NextEntryOffset);
481 CheckROSAgainstWinAndPrintResult(WinEaBuffer,ROSEaBuffer,WinStatus,ROSStatus,ulWinError,ulWinError,TEST_BUFFER_LEN,iTestCount,TestEaLength);
482 iTestCount++;
483 }
484
485
486 free(WinEaBuffer);
487 free(ROSEaBuffer);
488 }
489
490 FreeLibrary(hKrnlMod);
491 }
492 else
493 {
494 DWORD dwLastError = GetLastError();
495 switch (dwLastError)
496 {
498 printf("ERROR_MOD_NOT_FOUND\n");
499 break;
501 printf("ERROR_BAD_EXE_FORMAT\n");
502 break;
503 }
504 }
505 return 0;
506}
507
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
void CheckROSAgainstWinAndPrintResult(PFILE_FULL_EA_INFORMATION WinEaBuffer, PFILE_FULL_EA_INFORMATION ROSEaBuffer, NTSTATUS WinStatus, NTSTATUS ROSStatus, ULONG WinErrorOffset, ULONG ROSErrorOffset, int iBufferLength, int iTestCount, ULONG TestEaLength)
Definition: IoEaTest.cpp:100
#define RANDOM_INIT_ERROR
Definition: IoEaTest.cpp:121
#define TEST_BUFFER_LEN
Definition: IoEaTest.cpp:122
#define ULONG_PTR
Definition: IoEaTest.cpp:17
NTSTATUS NTAPI IoCheckEaBufferValidityROS(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:29
#define STATUS_EA_LIST_INCONSISTENT
Definition: IoEaTest.cpp:21
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define NTSTATUS
Definition: IoEaTest.cpp:19
struct _FILE_FULL_EA_INFORMATION FILE_FULL_EA_INFORMATION
#define STATUS_SUCCESS
Definition: IoEaTest.cpp:22
static int argc
Definition: ServiceArgs.c:12
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:878
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:93
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
#define _tmain
Definition: tchar.h:497
char _TCHAR
Definition: tchar.h:1392
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define argv
Definition: mplay32.c:18
unsigned int UINT
Definition: ndis.h:50
NTSTATUS NTAPI IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: util.c:191
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define memset(x, y, z)
Definition: compat.h:39
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LoadLibrary
Definition: winbase.h:3797
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:251
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG _In_opt_ PVOID EaBuffer
Definition: iofuncs.h:845
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175