[REACTOS]
[reactos.git] / rostests / kmtests / ntos_mm / MmSection.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Section Object test
5 * PROGRAMMER: Thomas Faber <thfabba@gmx.de>
6 */
7
8 #include <kmt_test.h>
9
10 #define CheckObject(Handle, Pointers, Handles) do \
11 { \
12 PUBLIC_OBJECT_BASIC_INFORMATION ObjectInfo; \
13 Status = ZwQueryObject(Handle, ObjectBasicInformation, \
14 &ObjectInfo, sizeof ObjectInfo, NULL); \
15 ok_eq_hex(Status, STATUS_SUCCESS); \
16 ok_eq_ulong(ObjectInfo.PointerCount, Pointers); \
17 ok_eq_ulong(ObjectInfo.HandleCount, Handles); \
18 } while (0)
19
20 #define CheckSection(SectionObject, SectionFlag) do \
21 { \
22 SECTION_BASIC_INFORMATION Sbi; \
23 HANDLE SectionHandle = NULL; \
24 NTSTATUS Status; \
25 if (skip(SectionObject != NULL && \
26 SectionObject != (PVOID)0x5555555555555555ULL, \
27 "No section object\n")) \
28 break; \
29 Status = ObOpenObjectByPointer(SectionObject, OBJ_KERNEL_HANDLE, \
30 NULL, 0, MmSectionObjectType, \
31 KernelMode, &SectionHandle); \
32 ok_eq_hex(Status, STATUS_SUCCESS); \
33 ok(SectionHandle != NULL, "Section handle null\n"); \
34 if (!skip(NT_SUCCESS(Status) && SectionHandle, \
35 "No section handle\n")) \
36 { \
37 Status = ZwQuerySection(SectionHandle, SectionBasicInformation, \
38 &Sbi, sizeof Sbi, NULL); \
39 ok_eq_hex(Status, STATUS_SUCCESS); \
40 ok_eq_pointer(Sbi.BaseAddress, NULL); \
41 ok_eq_longlong(Sbi.Size.QuadPart, 1LL); \
42 ok_eq_hex(Sbi.Attributes, SectionFlag | SEC_FILE); \
43 ZwClose(SectionHandle); \
44 } \
45 } while (0)
46
47 #define TestMapView(SectionObject, ExpectAtBase, ExpectM) do \
48 { \
49 NTSTATUS Status; \
50 PVOID BaseAddress = NULL; \
51 SIZE_T ViewSize = 0; \
52 LARGE_INTEGER SectionOffset; \
53 if (skip(SectionObject != NULL && \
54 SectionObject != (PVOID)0x5555555555555555ULL, \
55 "No section object\n")) \
56 break; \
57 \
58 SectionOffset.QuadPart = 0; \
59 Status = MmMapViewOfSection(SectionObject, PsGetCurrentProcess(), \
60 &BaseAddress, 0, 1, &SectionOffset, \
61 &ViewSize, ViewUnmap, 0, PAGE_READONLY); \
62 ok_eq_hex(Status, ExpectAtBase ? STATUS_SUCCESS : STATUS_IMAGE_NOT_AT_BASE);\
63 if (!skip(NT_SUCCESS(Status), "Section not mapped\n")) \
64 { \
65 ok_eq_uint(*(PUCHAR)BaseAddress, ExpectM ? 'M' : 0); \
66 Status = MmUnmapViewOfSection(PsGetCurrentProcess(), BaseAddress); \
67 ok_eq_hex(Status, STATUS_SUCCESS); \
68 } \
69 } while (0)
70
71 static
72 VOID
73 TestCreateSection(
74 IN HANDLE FileHandle1,
75 IN PFILE_OBJECT FileObject1,
76 IN HANDLE FileHandle2,
77 IN PFILE_OBJECT FileObject2)
78 {
79 NTSTATUS Status = STATUS_SUCCESS;
80 NTSTATUS ExceptionStatus;
81 PVOID SectionObject;
82 LARGE_INTEGER MaximumSize;
83 ULONG PointerCount1, PointerCount2;
84
85 KmtStartSeh()
86 Status = MmCreateSection(NULL, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL);
87 KmtEndSeh(STATUS_SUCCESS);
88 ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
89
90 if (!KmtIsCheckedBuild)
91 {
92 /* PAGE_NOACCESS and missing SEC_RESERVE/SEC_COMMIT/SEC_IMAGE assert */
93 KmtStartSeh()
94 Status = MmCreateSection(NULL, 0, NULL, NULL, PAGE_NOACCESS, SEC_RESERVE, NULL, NULL);
95 KmtEndSeh(STATUS_ACCESS_VIOLATION);
96
97 KmtStartSeh()
98 Status = MmCreateSection(NULL, 0, NULL, NULL, PAGE_NOACCESS, 0, NULL, NULL);
99 KmtEndSeh(STATUS_ACCESS_VIOLATION);
100 }
101
102 SectionObject = KmtInvalidPointer;
103 KmtStartSeh()
104 Status = MmCreateSection(&SectionObject, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL);
105 KmtEndSeh(STATUS_SUCCESS);
106 ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
107 ok_eq_pointer(SectionObject, KmtInvalidPointer);
108
109 if (SectionObject && SectionObject != KmtInvalidPointer)
110 ObDereferenceObject(SectionObject);
111
112 KmtStartSeh()
113 Status = MmCreateSection(NULL, 0, NULL, NULL, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
114 KmtEndSeh(STATUS_ACCESS_VIOLATION);
115
116 SectionObject = KmtInvalidPointer;
117 KmtStartSeh()
118 Status = MmCreateSection(&SectionObject, 0, NULL, NULL, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
119 KmtEndSeh(STATUS_ACCESS_VIOLATION);
120 ok_eq_pointer(SectionObject, KmtInvalidPointer);
121
122 if (SectionObject && SectionObject != KmtInvalidPointer)
123 ObDereferenceObject(SectionObject);
124
125 SectionObject = KmtInvalidPointer;
126 MaximumSize.QuadPart = 0;
127 KmtStartSeh()
128 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, NULL);
129 KmtEndSeh(STATUS_SUCCESS);
130 ok_eq_hex(Status, STATUS_INVALID_FILE_FOR_SECTION);
131 ok_eq_longlong(MaximumSize.QuadPart, 0LL);
132 ok_eq_pointer(SectionObject, KmtInvalidPointer);
133
134 if (SectionObject && SectionObject != KmtInvalidPointer)
135 ObDereferenceObject(SectionObject);
136
137 MaximumSize.QuadPart = 0;
138 KmtStartSeh()
139 Status = MmCreateSection(NULL, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
140 KmtEndSeh(STATUS_SUCCESS);
141 ok_eq_hex(Status, STATUS_INVALID_PARAMETER_4);
142 ok_eq_longlong(MaximumSize.QuadPart, 0LL);
143
144 if (SectionObject && SectionObject != KmtInvalidPointer)
145 ObDereferenceObject(SectionObject);
146
147 MaximumSize.QuadPart = 1;
148 KmtStartSeh()
149 Status = MmCreateSection(NULL, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
150 KmtEndSeh(STATUS_ACCESS_VIOLATION);
151 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
152
153 if (SectionObject && SectionObject != KmtInvalidPointer)
154 ObDereferenceObject(SectionObject);
155
156 SectionObject = KmtInvalidPointer;
157 MaximumSize.QuadPart = 0;
158 KmtStartSeh()
159 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
160 KmtEndSeh(STATUS_SUCCESS);
161 ok_eq_hex(Status, STATUS_INVALID_PARAMETER_4);
162 ok_eq_longlong(MaximumSize.QuadPart, 0LL);
163 ok_eq_pointer(SectionObject, KmtInvalidPointer);
164
165 if (SectionObject && SectionObject != KmtInvalidPointer)
166 ObDereferenceObject(SectionObject);
167
168 /* page file section */
169 SectionObject = KmtInvalidPointer;
170 MaximumSize.QuadPart = 1;
171 KmtStartSeh()
172 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
173 KmtEndSeh(STATUS_SUCCESS);
174 ok_eq_hex(Status, STATUS_SUCCESS);
175 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
176 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
177 ok(SectionObject != NULL, "Section object pointer NULL\n");
178
179 if (SectionObject && SectionObject != KmtInvalidPointer)
180 ObDereferenceObject(SectionObject);
181
182 if (!skip(FileHandle1 != NULL && FileObject1 != NULL &&
183 FileHandle2 != NULL && FileObject2 != NULL, "No file handle or object\n"))
184 {
185 PointerCount1 = 3;
186 PointerCount2 = 3;
187 /* image section */
188 CheckObject(FileHandle2, PointerCount2, 1L);
189 SectionObject = KmtInvalidPointer;
190 MaximumSize.QuadPart = 1;
191 KmtStartSeh()
192 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, NULL);
193 KmtEndSeh(STATUS_SUCCESS);
194 ok_eq_hex(Status, STATUS_SUCCESS);
195 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
196 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
197 ok(SectionObject != NULL, "Section object pointer NULL\n");
198 CheckObject(FileHandle2, PointerCount2, 1L);
199 CheckSection(SectionObject, SEC_IMAGE);
200 TestMapView(SectionObject, FALSE, TRUE);
201
202 if (SectionObject && SectionObject != KmtInvalidPointer)
203 ObDereferenceObject(SectionObject);
204
205 CheckObject(FileHandle2, PointerCount2, 1L);
206 SectionObject = KmtInvalidPointer;
207 MaximumSize.QuadPart = 1;
208 KmtStartSeh()
209 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject2);
210 KmtEndSeh(STATUS_SUCCESS);
211 ok_eq_hex(Status, STATUS_SUCCESS);
212 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
213 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
214 ok(SectionObject != NULL, "Section object pointer NULL\n");
215 ++PointerCount2;
216 CheckObject(FileHandle2, PointerCount2, 1L);
217 CheckSection(SectionObject, 0);
218 TestMapView(SectionObject, TRUE, TRUE);
219
220 if (SectionObject && SectionObject != KmtInvalidPointer)
221 ObDereferenceObject(SectionObject);
222 //--PointerCount2; // ????
223
224 CheckObject(FileHandle2, PointerCount2, 1L);
225 SectionObject = KmtInvalidPointer;
226 MaximumSize.QuadPart = 1;
227 KmtStartSeh()
228 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject2);
229 KmtEndSeh(STATUS_SUCCESS);
230 ok_eq_hex(Status, STATUS_SUCCESS);
231 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
232 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
233 ok(SectionObject != NULL, "Section object pointer NULL\n");
234 CheckObject(FileHandle2, PointerCount2, 1L);
235 CheckSection(SectionObject, 0);
236 TestMapView(SectionObject, TRUE, TRUE);
237
238 if (SectionObject && SectionObject != KmtInvalidPointer)
239 ObDereferenceObject(SectionObject);
240
241 /* image section with inappropriate file */
242 CheckObject(FileHandle1, PointerCount1, 1L);
243 SectionObject = KmtInvalidPointer;
244 MaximumSize.QuadPart = 1;
245 KmtStartSeh()
246 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, NULL);
247 KmtEndSeh(STATUS_SUCCESS);
248 ok_eq_hex(Status, STATUS_INVALID_IMAGE_NOT_MZ);
249 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
250 ok_eq_pointer(SectionObject, KmtInvalidPointer);
251 CheckObject(FileHandle1, PointerCount1, 1L);
252
253 if (SectionObject && SectionObject != KmtInvalidPointer)
254 ObDereferenceObject(SectionObject);
255
256 CheckObject(FileHandle1, PointerCount1, 1L);
257 SectionObject = KmtInvalidPointer;
258 MaximumSize.QuadPart = 1;
259 KmtStartSeh()
260 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject1);
261 KmtEndSeh(STATUS_SUCCESS);
262 ok_eq_hex(Status, STATUS_SUCCESS);
263 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
264 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
265 ok(SectionObject != NULL, "Section object pointer NULL\n");
266 ++PointerCount1;
267 CheckObject(FileHandle1, PointerCount1, 1L);
268 CheckSection(SectionObject, 0);
269 TestMapView(SectionObject, TRUE, FALSE);
270
271 if (SectionObject && SectionObject != KmtInvalidPointer)
272 ObDereferenceObject(SectionObject);
273 //--PointerCount1; // ????
274
275 CheckObject(FileHandle1, PointerCount1, 1L);
276 SectionObject = KmtInvalidPointer;
277 MaximumSize.QuadPart = 1;
278 KmtStartSeh()
279 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject1);
280 KmtEndSeh(STATUS_SUCCESS);
281 ok_eq_hex(Status, STATUS_SUCCESS);
282 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
283 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
284 ok(SectionObject != NULL, "Section object pointer NULL\n");
285 CheckObject(FileHandle1, PointerCount1, 1L);
286 CheckSection(SectionObject, 0);
287 TestMapView(SectionObject, TRUE, FALSE);
288
289 if (SectionObject && SectionObject != KmtInvalidPointer)
290 ObDereferenceObject(SectionObject);
291
292 /* image section with two different files */
293 CheckObject(FileHandle1, PointerCount1, 1L);
294 SectionObject = KmtInvalidPointer;
295 MaximumSize.QuadPart = 1;
296 KmtStartSeh()
297 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject2);
298 KmtEndSeh(STATUS_SUCCESS);
299 ok_eq_hex(Status, STATUS_SUCCESS);
300 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
301 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
302 ok(SectionObject != NULL, "Section object pointer NULL\n");
303 CheckObject(FileHandle1, PointerCount1, 1L);
304 CheckObject(FileHandle2, PointerCount2, 1L);
305 CheckSection(SectionObject, 0);
306 TestMapView(SectionObject, TRUE, TRUE);
307
308 if (SectionObject && SectionObject != KmtInvalidPointer)
309 ObDereferenceObject(SectionObject);
310
311 CheckObject(FileHandle1, PointerCount1, 1L);
312 SectionObject = KmtInvalidPointer;
313 MaximumSize.QuadPart = 1;
314 KmtStartSeh()
315 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject1);
316 KmtEndSeh(STATUS_SUCCESS);
317 ok_eq_hex(Status, STATUS_SUCCESS);
318 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
319 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
320 ok(SectionObject != NULL, "Section object pointer NULL\n");
321 CheckObject(FileHandle1, PointerCount1, 1L);
322 CheckObject(FileHandle2, PointerCount2, 1L);
323 CheckSection(SectionObject, 0);
324 TestMapView(SectionObject, TRUE, FALSE);
325
326 if (SectionObject && SectionObject != KmtInvalidPointer)
327 ObDereferenceObject(SectionObject);
328
329 /* data file section */
330 CheckObject(FileHandle1, PointerCount1, 1L);
331 SectionObject = KmtInvalidPointer;
332 MaximumSize.QuadPart = 1;
333 KmtStartSeh()
334 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, FileHandle1, NULL);
335 KmtEndSeh(STATUS_SUCCESS);
336 ok_eq_hex(Status, STATUS_SUCCESS);
337 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
338 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
339 ok(SectionObject != NULL, "Section object pointer NULL\n");
340 CheckObject(FileHandle1, PointerCount1, 1L);
341 CheckSection(SectionObject, 0);
342 TestMapView(SectionObject, TRUE, FALSE);
343
344 if (SectionObject && SectionObject != KmtInvalidPointer)
345 ObDereferenceObject(SectionObject);
346
347 CheckObject(FileHandle1, PointerCount1, 1L);
348 SectionObject = KmtInvalidPointer;
349 MaximumSize.QuadPart = 1;
350 KmtStartSeh()
351 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, FileObject1);
352 KmtEndSeh(STATUS_SUCCESS);
353 ok_eq_hex(Status, STATUS_SUCCESS);
354 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
355 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
356 ok(SectionObject != NULL, "Section object pointer NULL\n");
357 CheckObject(FileHandle1, PointerCount1, 1L);
358 CheckSection(SectionObject, 0);
359 TestMapView(SectionObject, TRUE, FALSE);
360
361 if (SectionObject && SectionObject != KmtInvalidPointer)
362 ObDereferenceObject(SectionObject);
363
364 CheckObject(FileHandle1, PointerCount1, 1L);
365 SectionObject = KmtInvalidPointer;
366 MaximumSize.QuadPart = 1;
367 KmtStartSeh()
368 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, FileHandle1, FileObject1);
369 KmtEndSeh(STATUS_SUCCESS);
370 ok_eq_hex(Status, STATUS_SUCCESS);
371 ok_eq_longlong(MaximumSize.QuadPart, 1LL);
372 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
373 ok(SectionObject != NULL, "Section object pointer NULL\n");
374 CheckObject(FileHandle1, PointerCount1, 1L);
375 CheckSection(SectionObject, 0);
376 TestMapView(SectionObject, TRUE, FALSE);
377
378 if (SectionObject && SectionObject != KmtInvalidPointer)
379 ObDereferenceObject(SectionObject);
380
381 CheckObject(FileHandle1, PointerCount1, 1L);
382 }
383 }
384
385 START_TEST(MmSection)
386 {
387 NTSTATUS Status;
388 HANDLE FileHandle1 = NULL, FileHandle2 = NULL;
389 PFILE_OBJECT FileObject1 = NULL, FileObject2 = NULL;
390 OBJECT_ATTRIBUTES ObjectAttributes;
391 IO_STATUS_BLOCK IoStatusBlock;
392 UNICODE_STRING FileName1 = RTL_CONSTANT_STRING(L"\\SystemRoot\\kmtest-MmSection.txt");
393 UNICODE_STRING FileName2 = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
394 LARGE_INTEGER FileOffset;
395 UCHAR FileData = 0;
396
397 ok(ExGetPreviousMode() == UserMode, "Previous mode is kernel mode\n");
398 /* create a one-byte file that we can use */
399 InitializeObjectAttributes(&ObjectAttributes, &FileName1, OBJ_CASE_INSENSITIVE, NULL, NULL);
400 Status = ZwCreateFile(&FileHandle1, GENERIC_WRITE | SYNCHRONIZE, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_SUPERSEDE, FILE_NON_DIRECTORY_FILE, NULL, 0);
401 ok_eq_hex(Status, STATUS_SUCCESS);
402 ok_eq_ulongptr(IoStatusBlock.Information, FILE_CREATED);
403 ok(FileHandle1 != NULL, "FileHandle1 is NULL\n");
404 if (FileHandle1)
405 {
406 FileOffset.QuadPart = 0;
407 Status = ZwWriteFile(FileHandle1, NULL, NULL, NULL, &IoStatusBlock, &FileData, sizeof FileData, &FileOffset, NULL);
408 ok(Status == STATUS_SUCCESS || Status == STATUS_PENDING, "Status = 0x%08lx\n", Status);
409 Status = ZwWaitForSingleObject(FileHandle1, FALSE, NULL);
410 ok_eq_hex(Status, STATUS_SUCCESS);
411 ok_eq_ulongptr(IoStatusBlock.Information, 1);
412 Status = ZwClose(FileHandle1);
413 ok_eq_hex(Status, STATUS_SUCCESS);
414 FileHandle1 = NULL;
415 }
416
417 InitializeObjectAttributes(&ObjectAttributes, &FileName1, OBJ_CASE_INSENSITIVE, NULL, NULL);
418 Status = ZwCreateFile(&FileHandle1, GENERIC_ALL, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_DELETE_ON_CLOSE, NULL, 0);
419 ok_eq_hex(Status, STATUS_SUCCESS);
420 ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED);
421 ok(FileHandle1 != NULL, "FileHandle1 is NULL\n");
422 CheckObject(FileHandle1, 2L, 1L);
423
424 InitializeObjectAttributes(&ObjectAttributes, &FileName2, OBJ_CASE_INSENSITIVE, NULL, NULL);
425 Status = ZwCreateFile(&FileHandle2, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0);
426 ok_eq_hex(Status, STATUS_SUCCESS);
427 ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED);
428 ok(FileHandle2 != NULL, "FileHandle2 is NULL\n");
429
430 if (!skip(Status == STATUS_SUCCESS && FileHandle1 != NULL, "Failed to open file 1\n"))
431 {
432 Status = ObReferenceObjectByHandle(FileHandle1, FILE_READ_DATA | FILE_WRITE_DATA, IoFileObjectType, KernelMode, (PVOID *)&FileObject1, NULL);
433 ok_eq_hex(Status, STATUS_SUCCESS);
434 ok(FileObject1 != NULL, "FileObject1 is NULL\n");
435 CheckObject(FileHandle1, 3L, 1L);
436 }
437
438 if (!skip(Status == STATUS_SUCCESS && FileHandle2 != NULL, "Failed to open file 2\n"))
439 {
440 Status = ObReferenceObjectByHandle(FileHandle2, FILE_READ_DATA | FILE_WRITE_DATA, IoFileObjectType, KernelMode, (PVOID *)&FileObject2, NULL);
441 ok_eq_hex(Status, STATUS_SUCCESS);
442 ok(FileObject2 != NULL, "FileObject2 is NULL\n");
443 }
444
445 trace("FileHandle1=%p, FileObject1=%p\n", FileHandle1, FileObject1);
446 trace("FileHandle2=%p, FileObject2=%p\n", FileHandle2, FileObject2);
447 TestCreateSection(FileHandle1, FileObject1, FileHandle2, FileObject2);
448
449 if (FileObject2)
450 ObDereferenceObject(FileObject2);
451 if (FileObject1)
452 ObDereferenceObject(FileObject1);
453 if (FileHandle2)
454 ZwClose(FileHandle2);
455 if (FileHandle1)
456 ZwClose(FileHandle1);
457 }