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