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>
10 #define CheckObject(Handle, Pointers, Handles) do \
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); \
20 #define CheckSection(SectionObject, SectionFlag) do \
22 SECTION_BASIC_INFORMATION Sbi; \
23 HANDLE SectionHandle = NULL; \
25 if (skip(SectionObject != NULL && \
26 SectionObject != (PVOID)0x5555555555555555ULL, \
27 "No section object\n")) \
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")) \
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); \
47 #define TestMapView(SectionObject, ExpectAtBase, ExpectM) do \
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")) \
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")) \
65 ok_eq_uint(*(PUCHAR)BaseAddress, ExpectM ? 'M' : 0); \
66 Status = MmUnmapViewOfSection(PsGetCurrentProcess(), BaseAddress); \
67 ok_eq_hex(Status, STATUS_SUCCESS); \
74 IN HANDLE FileHandle1
,
75 IN PFILE_OBJECT FileObject1
,
76 IN HANDLE FileHandle2
,
77 IN PFILE_OBJECT FileObject2
)
79 NTSTATUS Status
= STATUS_SUCCESS
;
80 NTSTATUS ExceptionStatus
;
82 LARGE_INTEGER MaximumSize
;
83 ULONG PointerCount1
, PointerCount2
;
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
);
90 if (!KmtIsCheckedBuild
)
92 /* PAGE_NOACCESS and missing SEC_RESERVE/SEC_COMMIT/SEC_IMAGE assert */
94 Status
= MmCreateSection(NULL
, 0, NULL
, NULL
, PAGE_NOACCESS
, SEC_RESERVE
, NULL
, NULL
);
95 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
98 Status
= MmCreateSection(NULL
, 0, NULL
, NULL
, PAGE_NOACCESS
, 0, NULL
, NULL
);
99 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
102 SectionObject
= KmtInvalidPointer
;
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
);
109 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
110 ObDereferenceObject(SectionObject
);
113 Status
= MmCreateSection(NULL
, 0, NULL
, NULL
, PAGE_READONLY
, SEC_RESERVE
, NULL
, NULL
);
114 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
116 SectionObject
= KmtInvalidPointer
;
118 Status
= MmCreateSection(&SectionObject
, 0, NULL
, NULL
, PAGE_READONLY
, SEC_RESERVE
, NULL
, NULL
);
119 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
120 ok_eq_pointer(SectionObject
, KmtInvalidPointer
);
122 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
123 ObDereferenceObject(SectionObject
);
125 SectionObject
= KmtInvalidPointer
;
126 MaximumSize
.QuadPart
= 0;
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
);
134 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
135 ObDereferenceObject(SectionObject
);
137 MaximumSize
.QuadPart
= 0;
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);
144 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
145 ObDereferenceObject(SectionObject
);
147 MaximumSize
.QuadPart
= 1;
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);
153 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
154 ObDereferenceObject(SectionObject
);
156 SectionObject
= KmtInvalidPointer
;
157 MaximumSize
.QuadPart
= 0;
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
);
165 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
166 ObDereferenceObject(SectionObject
);
168 /* page file section */
169 SectionObject
= KmtInvalidPointer
;
170 MaximumSize
.QuadPart
= 1;
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");
179 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
180 ObDereferenceObject(SectionObject
);
182 if (!skip(FileHandle1
!= NULL
&& FileObject1
!= NULL
&&
183 FileHandle2
!= NULL
&& FileObject2
!= NULL
, "No file handle or object\n"))
188 CheckObject(FileHandle2
, PointerCount2
, 1L);
189 SectionObject
= KmtInvalidPointer
;
190 MaximumSize
.QuadPart
= 1;
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
);
202 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
203 ObDereferenceObject(SectionObject
);
205 CheckObject(FileHandle2
, PointerCount2
, 1L);
206 SectionObject
= KmtInvalidPointer
;
207 MaximumSize
.QuadPart
= 1;
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");
216 CheckObject(FileHandle2
, PointerCount2
, 1L);
217 CheckSection(SectionObject
, 0);
218 TestMapView(SectionObject
, TRUE
, TRUE
);
220 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
221 ObDereferenceObject(SectionObject
);
222 //--PointerCount2; // ????
224 CheckObject(FileHandle2
, PointerCount2
, 1L);
225 SectionObject
= KmtInvalidPointer
;
226 MaximumSize
.QuadPart
= 1;
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
);
238 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
239 ObDereferenceObject(SectionObject
);
241 /* image section with inappropriate file */
242 CheckObject(FileHandle1
, PointerCount1
, 1L);
243 SectionObject
= KmtInvalidPointer
;
244 MaximumSize
.QuadPart
= 1;
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);
253 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
254 ObDereferenceObject(SectionObject
);
256 CheckObject(FileHandle1
, PointerCount1
, 1L);
257 SectionObject
= KmtInvalidPointer
;
258 MaximumSize
.QuadPart
= 1;
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");
267 CheckObject(FileHandle1
, PointerCount1
, 1L);
268 CheckSection(SectionObject
, 0);
269 TestMapView(SectionObject
, TRUE
, FALSE
);
271 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
272 ObDereferenceObject(SectionObject
);
273 //--PointerCount1; // ????
275 CheckObject(FileHandle1
, PointerCount1
, 1L);
276 SectionObject
= KmtInvalidPointer
;
277 MaximumSize
.QuadPart
= 1;
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
);
289 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
290 ObDereferenceObject(SectionObject
);
292 /* image section with two different files */
293 CheckObject(FileHandle1
, PointerCount1
, 1L);
294 SectionObject
= KmtInvalidPointer
;
295 MaximumSize
.QuadPart
= 1;
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
);
308 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
309 ObDereferenceObject(SectionObject
);
311 CheckObject(FileHandle1
, PointerCount1
, 1L);
312 SectionObject
= KmtInvalidPointer
;
313 MaximumSize
.QuadPart
= 1;
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
);
326 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
327 ObDereferenceObject(SectionObject
);
329 /* data file section */
330 CheckObject(FileHandle1
, PointerCount1
, 1L);
331 SectionObject
= KmtInvalidPointer
;
332 MaximumSize
.QuadPart
= 1;
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
);
344 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
345 ObDereferenceObject(SectionObject
);
347 CheckObject(FileHandle1
, PointerCount1
, 1L);
348 SectionObject
= KmtInvalidPointer
;
349 MaximumSize
.QuadPart
= 1;
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
);
361 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
362 ObDereferenceObject(SectionObject
);
364 CheckObject(FileHandle1
, PointerCount1
, 1L);
365 SectionObject
= KmtInvalidPointer
;
366 MaximumSize
.QuadPart
= 1;
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
);
378 if (SectionObject
&& SectionObject
!= KmtInvalidPointer
)
379 ObDereferenceObject(SectionObject
);
381 CheckObject(FileHandle1
, PointerCount1
, 1L);
385 START_TEST(MmSection
)
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
;
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");
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
);
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);
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");
430 if (!skip(Status
== STATUS_SUCCESS
&& FileHandle1
!= NULL
, "Failed to open file 1\n"))
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);
438 if (!skip(Status
== STATUS_SUCCESS
&& FileHandle2
!= NULL
, "Failed to open file 2\n"))
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");
445 trace("FileHandle1=%p, FileObject1=%p\n", FileHandle1
, FileObject1
);
446 trace("FileHandle2=%p, FileObject2=%p\n", FileHandle2
, FileObject2
);
447 TestCreateSection(FileHandle1
, FileObject1
, FileHandle2
, FileObject2
);
450 ObDereferenceObject(FileObject2
);
452 ObDereferenceObject(FileObject1
);
454 ZwClose(FileHandle2
);
456 ZwClose(FileHandle1
);