ReactOS 0.4.17-dev-683-g0dafdc5
NtMapViewOfSection.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for NtMapViewOfSection
5 * PROGRAMMERS: Timo Kreuzer
6 * Thomas Faber
7 */
8
9#include "precomp.h"
10
11#include <pseh/pseh2.h>
12
13#ifdef _M_IX86
14#define IsX86() TRUE
15#else
16#define IsX86() FALSE
17#endif
18
19void
21{
23 HANDLE SectionHandle;
25 PVOID BaseAddress, BaseAddress2;
27 ULONG OldProtect;
28
29 /* Create a page file backed section with SEC_COMMIT */
30 MaximumSize.QuadPart = 0x20000;
31 Status = NtCreateSection(&SectionHandle,
33 NULL,
37 NULL);
39 if (!NT_SUCCESS(Status))
40 return;
41
42 /* Try to map a page at an address that is not 64k aligned */
43 BaseAddress = (PVOID)0x30001000;
44 SectionOffset.QuadPart = 0;
45 ViewSize = 0x1000;
46 Status = NtMapViewOfSection(SectionHandle,
49 0,
50 0,
52 &ViewSize,
54 0,
57
58 /* Try to map a page with execute rights */
59 BaseAddress = (PVOID)0x30000000;
60 SectionOffset.QuadPart = 0;
61 ViewSize = 0x1000;
62 Status = NtMapViewOfSection(SectionHandle,
65 0,
66 0,
68 &ViewSize,
70 0,
73
74 /* Try to map 2 pages with MEM_COMMIT */
75 BaseAddress = (PVOID)0x30000000;
76 SectionOffset.QuadPart = 0;
77 ViewSize = 0x2000;
78 Status = NtMapViewOfSection(SectionHandle,
81 0,
84 &ViewSize,
89
90 /* Try to map 1 page, with free base address and zero bits compatible with 64k granularity */
92 SectionOffset.QuadPart = 0;
93 ViewSize = 0x1000;
94 Status = NtMapViewOfSection(SectionHandle,
97 10,
98 0,
100 &ViewSize,
101 ViewShare,
102 0,
105 ok(((ULONG_PTR)BaseAddress & 0x0000FFFF) == 0, "BaseAddress not 64k aligned: %p\n", BaseAddress);
106 ok(((ULONG_PTR)BaseAddress & (ULONG_PTR)0xFFFFFFFFFFC00000ULL) == 0, "Upper bits are not all zero: %p\n", BaseAddress);
109
110 /* Try to map 1 page, with free base address and zero bits incompatible with 64k granularity.
111 * Note: On 64 bit Windows, ZeroBits != 0 means that the upper (32 + ZeroBits) bits must be zero.
112 * While the documented maximum for ZeroBits is "less than 21", to not break 64 bit alignment,
113 * we need to keep at least 17 bits (i.e., ZeroBits must be less than 16). */
115 SectionOffset.QuadPart = 0;
116 ViewSize = 0x1000;
117 Status = NtMapViewOfSection(SectionHandle,
120 (32 - 16),
121 0,
123 &ViewSize,
124 ViewShare,
125 0,
128
129 /* Try to map 1 page, with base address and zero bits being compatible */
130 BaseAddress = (PVOID)0x30000000;
131 SectionOffset.QuadPart = 0;
132 ViewSize = 0x1000;
133 Status = NtMapViewOfSection(SectionHandle,
136 2,
137 0,
139 &ViewSize,
140 ViewShare,
141 0,
146
147 /* Try to map 1 page, with base address and zero bits being incompatible */
148 BaseAddress = (PVOID)0x30000000;
149 SectionOffset.QuadPart = 0;
150 ViewSize = 0x1000;
151 Status = NtMapViewOfSection(SectionHandle,
154 3,
155 0,
157 &ViewSize,
158 ViewShare,
159 0,
162
163 /* Try using ZeroBits like a bitmask */
165 SectionOffset.QuadPart = 0;
166 ViewSize = 0x1000;
167 Status = NtMapViewOfSection(SectionHandle,
170 0x0FFFFFFF,
171 0,
173 &ViewSize,
174 ViewShare,
175 0,
178 {
180 ok(((ULONG_PTR)BaseAddress & 0x0000FFFF) == 0, "BaseAddress not 64k aligned: %p\n", BaseAddress);
181 ok(((ULONG_PTR)BaseAddress & (ULONG_PTR)0xFFFFFFFFF0000000ULL) == 0, "Upper bits are not all zero: %p\n", BaseAddress);
182 }
183 else
184 {
186 if (!NT_SUCCESS(Status))
187 return;
188 }
189
190 /* Map 2 pages, without MEM_COMMIT */
191 BaseAddress = (PVOID)0x30000000;
192 SectionOffset.QuadPart = 0;
193 ViewSize = 0x2000;
194 Status = NtMapViewOfSection(SectionHandle,
197 0,
198 0,
200 &ViewSize,
201 ViewShare,
202 0,
205
206 /* We must be able to access the memory */
208 {
209 *(PULONG)BaseAddress = 1;
210 }
211 _SEH2_EXCEPT(1)
212 {
213 ok(FALSE, "Got an exception\n");
214 }
215 _SEH2_END;
216
217 /* Commit a page in the section */
218 BaseAddress = (PVOID)0x30000000;
219 ViewSize = 0x1000;
222 0,
223 &ViewSize,
227
228 /* Try to decommit a page in the section */
231 &ViewSize,
234
235 /* Try to commit a range larger than the section */
236 BaseAddress = (PVOID)0x30000000;
237 ViewSize = 0x3000;
240 0,
241 &ViewSize,
245
246 /* Try to commit a page after the section */
247 BaseAddress = (PVOID)0x30002000;
248 ViewSize = 0x1000;
251 0,
252 &ViewSize,
256
257 /* Try to allocate a page after the section */
258 BaseAddress = (PVOID)0x30002000;
259 ViewSize = 0x1000;
262 0,
263 &ViewSize,
267
268 /* Need to go to next 64k boundary */
269 BaseAddress = (PVOID)0x30010000;
270 ViewSize = 0x1000;
273 0,
274 &ViewSize,
278 if (!NT_SUCCESS(Status))
279 return;
280
281 /* Free the allocation */
282 BaseAddress = (PVOID)0x30010000;
283 ViewSize = 0x1000;
286 &ViewSize,
288 ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed with Status %lx\n", Status);
289
290 /* Try to release the section mapping with NtFreeVirtualMemory */
291 BaseAddress = (PVOID)0x30000000;
292 ViewSize = 0x1000;
295 &ViewSize,
298
299 /* Commit a page in the section */
300 BaseAddress = (PVOID)0x30001000;
301 ViewSize = 0x1000;
304 0,
305 &ViewSize,
309
310 /* Try to decommit the page */
311 BaseAddress = (PVOID)0x30001000;
312 ViewSize = 0x1000;
315 &ViewSize,
318
319 BaseAddress = UlongToPtr(0x40000000);
320 SectionOffset.QuadPart = 0;
321 ViewSize = 0x1000;
322 Status = NtMapViewOfSection(SectionHandle,
325 0,
326 0,
328 &ViewSize,
329 ViewShare,
330 0,
333 if (!NT_SUCCESS(Status))
334 return;
335
336 ok(BaseAddress == UlongToPtr(0x40000000), "Invalid BaseAddress: %p\n", BaseAddress);
337
338 BaseAddress = (PVOID)0x40080000;
339 SectionOffset.QuadPart = 0x10000;
340 ViewSize = 0x1000;
341 Status = NtMapViewOfSection(SectionHandle,
344 0,
345 0,
347 &ViewSize,
348 ViewShare,
349 0,
352
353 ok(BaseAddress == (PVOID)0x40080000, "Invalid BaseAddress: %p\n", BaseAddress);
354
355 /* Commit a page in the section */
356 BaseAddress = (PVOID)0x40000000;
359 0,
360 &ViewSize,
364
365 /* Close the mapping */
368 BaseAddress = (PVOID)0x30000000;
371 Status = NtClose(SectionHandle);
373
374 /* Create a page file backed section, but only reserved */
375 MaximumSize.QuadPart = 0x20000;
376 Status = NtCreateSection(&SectionHandle,
378 NULL,
382 NULL);
384
385 /* Try to map 1 page, passing MEM_RESERVE */
387 SectionOffset.QuadPart = 0;
389 Status = NtMapViewOfSection(SectionHandle,
392 0,
393 PAGE_SIZE,
395 &ViewSize,
396 ViewShare,
400
401 /* Try to map 1 page using MEM_COMMIT */
403 SectionOffset.QuadPart = 0;
405 Status = NtMapViewOfSection(SectionHandle,
408 0,
409 PAGE_SIZE,
411 &ViewSize,
412 ViewShare,
416
417 /* Map 2 pages, but commit 1 */
419 SectionOffset.QuadPart = 0;
420 ViewSize = 2 * PAGE_SIZE;
421 Status = NtMapViewOfSection(SectionHandle,
424 0,
425 PAGE_SIZE,
427 &ViewSize,
428 ViewShare,
429 0,
432
433 /* We must be able to access the 1st page */
436 {
437 *(PUCHAR)BaseAddress = 1;
438 }
439 _SEH2_EXCEPT(1)
440 {
442 }
443 _SEH2_END;
445
446 /* We must not be able to access the 2nd page */
449 {
450 *((PUCHAR)BaseAddress + PAGE_SIZE) = 1;
451 }
452 _SEH2_EXCEPT(1)
453 {
455 }
456 _SEH2_END;
458
459 /* Map the 2 pages again into a different memory location */
460 BaseAddress2 = NULL;
461 Status = NtMapViewOfSection(SectionHandle,
463 &BaseAddress2,
464 0,
465 0,
467 &ViewSize,
468 ViewShare,
469 0,
472
473 /* Commit a the 2nd page in the 2nd memory location */
474 BaseAddress2 = (PUCHAR)BaseAddress2 + PAGE_SIZE;
477 &BaseAddress2,
478 0,
479 &ViewSize,
483
484 /* Try to commit again (the already committed page) */
486 &BaseAddress2,
487 0,
488 &ViewSize,
492
493 /* We must be able to access the memory in the 2nd page of the 1st memory location */
496 {
497 *((PUCHAR)BaseAddress + PAGE_SIZE) = 2;
498 }
499 _SEH2_EXCEPT(1)
500 {
502 }
503 _SEH2_END;
505
506 ok(*(PULONG)BaseAddress2 == 2, "Value in memory was wrong\n");
507
508 /* Close the mapping */
513 Status = NtClose(SectionHandle);
515
516 /* Try to create a 512 GB page file backed section with committed pages */
517 MaximumSize.QuadPart = 0x8000000000;
518 Status = NtCreateSection(&SectionHandle,
520 NULL,
524 NULL);
526
527 /* Try to create a huge page file backed section with PAGE_NOACCESS protection */
528 MaximumSize.QuadPart = 0x8000000000;
529 Status = NtCreateSection(&SectionHandle,
531 NULL,
535 NULL);
537
538 /* Try to create a very huge page file backed section, but only reserved */
539 MaximumSize.QuadPart = 0x80000000000;
540 Status = NtCreateSection(&SectionHandle,
542 NULL,
546 NULL);
547#ifdef _WIN64
549#else
550 /* WoW64 returns STATUS_INSUFFICIENT_RESOURCES */
552 "got wrong Status: 0x%lx\n", Status);
553#endif
554
555 /* Try to create a even huger page file backed section, but only reserved */
556 MaximumSize.QuadPart = 0x800000000000;
557 Status = NtCreateSection(&SectionHandle,
559 NULL,
563 NULL);
565
566 /* Create a 8 GB page file backed section, but only reserved */
567 MaximumSize.QuadPart = 0x200000000;
568 Status = NtCreateSection(&SectionHandle,
570 NULL,
574 NULL);
576
577 /* Pass a too large region size */
579 SectionOffset.QuadPart = 0;
581 Status = NtMapViewOfSection(SectionHandle,
584 0,
585 0,
587 &ViewSize,
588 ViewShare,
589 0,
591#ifdef _WIN64
593#else
594 /* WoW64 returns STATUS_INVALID_PARAMETER_4 */
596 ok(Status == STATUS_INVALID_PARAMETER, "got wrong Status: 0x%lx\n", Status);
597 else
599 "got wrong Status: 0x%lx\n", Status);
600#endif
601
602 /* Pass 0 region size */
604 SectionOffset.QuadPart = 0;
605 ViewSize = 0;
606 Status = NtMapViewOfSection(SectionHandle,
609 0,
610 0,
612 &ViewSize,
613 ViewShare,
614 0,
616#ifdef _WIN64
618 ok(ViewSize == 0x200000000, "wrong ViewSize: 0x%Ix\n", ViewSize);
619#else
620 /* WoW64 returns STATUS_NO_MEMORY */
622 "got wrong Status: 0x%lx\n", Status);
623 ok(ViewSize == 0, "wrong ViewSize: 0x%Ix\n", ViewSize);
624#endif
625
626 /* Map with PAGE_NOACCESS */
628 SectionOffset.QuadPart = 0;
629 ViewSize = 0x20000000;
630 Status = NtMapViewOfSection(SectionHandle,
633 0,
634 0,
636 &ViewSize,
637 ViewShare,
638 0,
641
642 /* Try to change protection to read/write */
643 ViewSize = 0x1000;
644 OldProtect = -1;
645 BaseAddress2 = BaseAddress;
646 Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress2, &ViewSize, PAGE_READWRITE, &OldProtect);
648 // Windows 2003 returns bogus
649 //ok(OldProtect == PAGE_READWRITE, "Wrong protection returned: %u\n", OldProtect);
650
651 /* Test read access */
654 {
655 (void)(*(volatile char*)BaseAddress2);
656 }
658 {
660 }
661 _SEH2_END;
663
664 /* Try to change protection to read/write */
665 ViewSize = 0x1000;
666 OldProtect = -1;
667 BaseAddress2 = BaseAddress;
668 Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress2, &ViewSize, PAGE_READWRITE, &OldProtect);
670#ifdef _WIN64
671 ok(OldProtect == PAGE_NOACCESS, "Wrong protection returned: 0x%lx\n", OldProtect);
672#else
673 // Windows 2003 returns bogus
674#endif
675
676 /* Try to change protection to readonly */
677 ViewSize = 0x1000;
678 OldProtect = -1;
679 BaseAddress2 = BaseAddress;
680 Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress2, &ViewSize, PAGE_READONLY, &OldProtect);
682#ifdef _WIN64
683 //ok(OldProtect == 0, "Wrong protection returned: 0x%lx\n", OldProtect);
684#else
685 // Windows 2003 returns bogus
686#endif
687
688 /* Commit a page */
689 ViewSize = 0x1000;
690 BaseAddress2 = BaseAddress;
693 ok(BaseAddress2 == BaseAddress, "Invalid base address: %p\n", BaseAddress2);
694
695 /* Commit the page again */
696 ViewSize = 0x1000;
697 BaseAddress2 = BaseAddress;
700 ok(BaseAddress2 == BaseAddress, "Invalid base address: %p\n", BaseAddress2);
701
702 /* Test read access */
705 {
706 (void)(*(volatile char*)BaseAddress2);
707 }
709 {
711 }
712 _SEH2_END;
714
715 /* Test write access */
718 {
719 *(char*)BaseAddress2 = 1;
720 }
722 {
724 }
725 _SEH2_END;
727
728 /* Update protection to PAGE_READWRITE */
729 ViewSize = 0x1000;
730 BaseAddress2 = BaseAddress;
733
734 /* Test write access */
737 {
738 *(char*)BaseAddress2 = 1;
739 }
741 {
743 }
744 _SEH2_END;
746
747 /* Update protection to PAGE_EXECUTE_READWRITE (1 page) */
748 ViewSize = 0x1000;
749 BaseAddress2 = BaseAddress;
752
755 Status = NtClose(SectionHandle);
757}
758
759void
761{
766 WCHAR TestDllPath[MAX_PATH];
767 HANDLE FileHandle, DataSectionHandle, ImageSectionHandle;
768 PVOID DataBase, ImageBase;
770
771 GetModuleFileNameW(NULL, TestDllPath, RTL_NUMBER_OF(TestDllPath));
772 wcsrchr(TestDllPath, L'\\')[1] = UNICODE_NULL;
773 StringCbCatW(TestDllPath, sizeof(TestDllPath), L"testdata\\test.dll");
774 if (!RtlDosPathNameToNtPathName_U(TestDllPath,
775 &FileName,
776 NULL,
777 NULL))
778 {
779 ok(0, "RtlDosPathNameToNtPathName_U failed\n");
780 return;
781 }
782
784 &FileName,
785 0,
786 NULL,
787 NULL);
788
796 if (!NT_SUCCESS(Status))
797 {
798 skip("Failed to open file %s\n", wine_dbgstr_wn(FileName.Buffer, FileName.Length / sizeof(WCHAR)));
799 RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
800 return;
801 }
802 RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
803
804 /* Create a data section with write access */
805 Status = NtCreateSection(&DataSectionHandle,
806 SECTION_ALL_ACCESS, // DesiredAccess
807 NULL, // ObjectAttributes
808 NULL, // MaximumSize
809 PAGE_READWRITE, // SectionPageProtection
810 SEC_COMMIT, // AllocationAttributes
811 FileHandle);
813 if (!NT_SUCCESS(Status))
814 {
815 skip("Failed to create data section\n");
817 return;
818 }
819
820 /* Map the data section as flat mapping */
821 DataBase = NULL;
822 ViewSize = 0;
823 Status = NtMapViewOfSection(DataSectionHandle,
825 &DataBase,
826 0,
827 0,
828 NULL,
829 &ViewSize,
830 ViewShare,
831 0,
834 //ok(ViewSize == 0x3f95cc48, "ViewSize wrong: 0x%lx\n");
835 if (!NT_SUCCESS(Status))
836 {
837 skip("Failed to map view of data section\n");
838 NtClose(DataSectionHandle);
840 return;
841 }
842
843 /* Check the original data */
844 ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
845
846 /* Modify the PE header (but do not flush!) */
847 *(ULONG*)DataBase = 0xdeadbabe;
848 ok(*(ULONG*)DataBase == 0xdeadbabe, "Header not ok\n");
849
850 /* Modify data in the .data section (but do not flush!) */
851 ok(*(ULONG*)((PUCHAR)DataBase + 0x800) == 0x12345678,
852 "Data in .data section invalid: 0x%lx!\n", *(ULONG*)((PUCHAR)DataBase + 0x800));
853 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0x87654321;
854
855 /* Now try to create an image section (should fail) */
856 Status = NtCreateSection(&ImageSectionHandle,
857 SECTION_ALL_ACCESS, // DesiredAccess
858 NULL, // ObjectAttributes
859 NULL, // MaximumSize
860 PAGE_READWRITE, // SectionPageProtection
861 SEC_IMAGE, // AllocationAttributes
862 FileHandle);
864 if (NT_SUCCESS(Status)) NtClose(ImageSectionHandle);
865
866 /* Restore the original header */
867 *(ULONG*)DataBase = 0x00905a4d;
868
869 /* Modify data in the .data section (but do not flush!) */
870 ok_hex(*(ULONG*)((PUCHAR)DataBase + 0x800), 0x87654321);
871 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0xdeadbabe;
872
873 /* Try to create an image section again */
874 Status = NtCreateSection(&ImageSectionHandle,
875 SECTION_ALL_ACCESS, // DesiredAccess
876 NULL, // ObjectAttributes
877 NULL, // MaximumSize
878 PAGE_READWRITE, // SectionPageProtection
879 SEC_IMAGE, // AllocationAttributes
880 FileHandle);
882 if (!NT_SUCCESS(Status))
883 {
884 skip("Failed to create image section\n");
885 NtClose(DataSectionHandle);
887 return;
888 }
889
890 /* Map the image section */
891 ImageBase = NULL;
892 ViewSize = 0;
893 Status = NtMapViewOfSection(ImageSectionHandle,
895 &ImageBase,
896 0, // ZeroBits
897 0, // CommitSize
898 NULL, // SectionOffset
899 &ViewSize,
900 ViewShare,
901 0, // AllocationType
903#ifdef _M_IX86
905#else
907#endif
908 if (!NT_SUCCESS(Status))
909 {
910 skip("Failed to map view of image section\n");
911 NtClose(ImageSectionHandle);
912 NtClose(DataSectionHandle);
914 return;
915 }
916
917 /* Check the header */
918 ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
919 ok(*(ULONG*)ImageBase == 0x00905a4d, "Header not ok\n");
920
921 /* Check the data section. Either of these can be present! */
922 ok((*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x87654321) ||
923 (*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x12345678),
924 "Wrong value in data section: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
925
926 /* Now modify the data again */
927 *(ULONG*)DataBase = 0xdeadbabe;
928 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0xf00dada;
929
930 /* Check the data */
931 ok(*(ULONG*)DataBase == 0xdeadbabe, "Header not ok\n");
932 ok(*(ULONG*)ImageBase == 0x00905a4d, "Data should not be synced!\n");
933 ok((*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x87654321) ||
934 (*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x12345678),
935 "Wrong value in data section: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
936
937 /* Flush the view */
938 ViewSize = 0x1000;
940 &DataBase,
941 &ViewSize,
944
945 /* Check the data again */
946 ok(*(ULONG*)ImageBase == 0x00905a4d, "Data should not be synced!\n");
947 ok((*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x87654321) ||
948 (*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x12345678),
949 "Wrong value in data section: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
950
951 /* Restore the original header */
952 *(ULONG*)DataBase = 0x00905a4d;
953 ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
954
955 /* Close the image mapping */
957 NtClose(ImageSectionHandle);
958
959 /* Create an image section again */
960 Status = NtCreateSection(&ImageSectionHandle,
961 SECTION_ALL_ACCESS, // DesiredAccess
962 NULL, // ObjectAttributes
963 NULL, // MaximumSize
964 PAGE_READWRITE, // SectionPageProtection
965 SEC_IMAGE, // AllocationAttributes
966 FileHandle);
968 if (!NT_SUCCESS(Status))
969 {
970 skip("Failed to create image section\n");
971 NtClose(DataSectionHandle);
973 return;
974 }
975
976 /* Map the image section again */
977 ImageBase = NULL;
978 ViewSize = 0;
979 Status = NtMapViewOfSection(ImageSectionHandle,
981 &ImageBase,
982 0,
983 0,
984 NULL,
985 &ViewSize,
986 ViewShare,
987 0,
989#ifdef _M_IX86
991#else
993#endif
994 if (!NT_SUCCESS(Status))
995 {
996 skip("Failed to map view of image section\n");
997 NtClose(ImageSectionHandle);
998 NtClose(DataSectionHandle);
1000 return;
1001 }
1002
1003 // This one doesn't always work, needs investigation
1004 /* Check the .data section again */
1005 //ok(*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0xf00dada,
1006 // "Data should be synced: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
1007
1008 /* Restore the original data */
1009 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0x12345678;
1010
1011 /* Close the data mapping */
1013
1014 NtClose(DataSectionHandle);
1015
1016 /* Try to allocate memory inside the image mapping */
1017 DataBase = (PUCHAR)ImageBase + 0x20000;
1018 ViewSize = 0x1000;
1021
1022 /* Cleanup */
1024 NtClose(ImageSectionHandle);
1026}
1027
1028void
1030{
1035 HANDLE FileHandle, ImageSectionHandle;
1036 PVOID ImageBase, BaseAddress;
1039
1040 if (!RtlDosPathNameToNtPathName_U(L"testdata\\nvoglv32.dll",
1041 &FileName,
1042 NULL,
1043 NULL))
1044 {
1045 ok(0, "RtlDosPathNameToNtPathName_U failed\n");
1046 return;
1047 }
1048
1050 &FileName,
1051 0,
1052 NULL,
1053 NULL);
1054
1061 RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
1063 printf("Opened file with handle %p\n", FileHandle);
1064
1065 /* Create a data section with write access */
1066 MaximumSize.QuadPart = 0x20000;
1067 Status = NtCreateSection(&ImageSectionHandle,
1068 SECTION_ALL_ACCESS, // DesiredAccess
1069 NULL, // ObjectAttributes
1070 &MaximumSize, // MaximumSize
1071 PAGE_READWRITE, // SectionPageProtection
1072 SEC_IMAGE, // AllocationAttributes
1073 FileHandle);
1075
1076 printf("Created image section with handle %p\n", ImageSectionHandle);
1077 //system("PAUSE");
1078
1079 /* Map the image section */
1080 ImageBase = NULL;
1081 ViewSize = 0x0000;
1082 SectionOffset.QuadPart = 0x00000;
1083 Status = NtMapViewOfSection(ImageSectionHandle,
1085 &ImageBase,
1086 0,
1087 0,
1089 &ViewSize,
1090 ViewShare,
1091 0,
1094
1095 printf("Mapped image section at %p, value in text section: %lx\n",
1096 ImageBase, *((ULONG*)((PCHAR)ImageBase + 0x1196)));
1097 system("PAUSE");
1098
1099 /* Try to allocate a page after the section */
1100 BaseAddress = (PUCHAR)ImageBase + 0x10000;
1101 ViewSize = 0x1000;
1103 &BaseAddress,
1104 0,
1105 &ViewSize,
1108 printf("allocation status: %lx\n", Status);
1109 system("PAUSE");
1110
1111}
1112
1113// doesn't work with WoW64!
1114void
1116{
1118 HANDLE SectionHandle1, SectionHandle2;
1120 PVOID BaseAddress1, BaseAddress2;
1122
1123 /* Create a based section with SEC_COMMIT */
1124 MaximumSize.QuadPart = 0x1000;
1125 Status = NtCreateSection(&SectionHandle1,
1127 NULL,
1128 &MaximumSize,
1131 NULL);
1133
1134 /* Map the 1st section */
1135 BaseAddress1 = NULL;
1136 SectionOffset.QuadPart = 0;
1137 ViewSize = 0;
1138 Status = NtMapViewOfSection(SectionHandle1,
1140 &BaseAddress1,
1141 0,
1142 0,
1144 &ViewSize,
1145 ViewShare,
1146 0,
1148#if 0 // WOW64?
1150#else
1152#endif
1153
1154 /* Create a 2nd based section with SEC_COMMIT */
1155 MaximumSize.QuadPart = 0x1000;
1156 Status = NtCreateSection(&SectionHandle2,
1158 NULL,
1159 &MaximumSize,
1162 NULL);
1164
1165 /* Map the 2nd section */
1166 BaseAddress2 = NULL;
1167 SectionOffset.QuadPart = 0;
1168 ViewSize = 0;
1169 Status = NtMapViewOfSection(SectionHandle2,
1171 &BaseAddress2,
1172 0,
1173 0,
1175 &ViewSize,
1176 ViewShare,
1177 0,
1179#if 0 // WOW64?
1181#else
1183 ok((ULONG_PTR)BaseAddress2 < (ULONG_PTR)BaseAddress1,
1184 "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
1185 ok(((ULONG_PTR)BaseAddress1 - (ULONG_PTR)BaseAddress2) == 0x10000,
1186 "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
1187#endif
1188}
1189
1190#define BYTES4(x) x, x, x, x
1191#define BYTES8(x) BYTES4(x), BYTES4(x)
1192#define BYTES16(x) BYTES8(x), BYTES8(x)
1193#define BYTES32(x) BYTES16(x), BYTES16(x)
1194#define BYTES64(x) BYTES32(x), BYTES32(x)
1195#define BYTES128(x) BYTES64(x), BYTES64(x)
1196#define BYTES256(x) BYTES128(x), BYTES128(x)
1197#define BYTES512(x) BYTES256(x), BYTES256(x)
1198#define BYTES1024(x) BYTES512(x), BYTES512(x)
1199
1201{
1209#ifdef _WIN64
1210 BYTE pad[472];
1211#else
1212 BYTE pad[488];
1213#endif
1219{
1220 /* IMAGE_DOS_HEADER */
1221 {
1222 IMAGE_DOS_SIGNATURE, 144, 3, 0, 4, 0, 0xFFFF, 0, 0xB8, 0, 0, 0, 0x40,
1223 0, { 0 }, 0, 0, { 0 }, 0x80
1224 },
1225 /* binary to print "This program cannot be run in DOS mode." */
1226 {
1227 0x1F0E, 0x0EBA, 0xB400, 0xCD09, 0xB821, 0x4C01, 0x21CD, 0x6854, 0x7369,
1228 0x7020, 0x6F72, 0x7267, 0x6D61, 0x6320, 0x6E61, 0x6F6E, 0x2074, 0x6562,
1229 0x7220, 0x6E75, 0x6920, 0x206E, 0x4F44, 0x2053, 0x6F6D, 0x6564, 0x0D2E,
1230 0x0A0D, 0x0024, 0x0000, 0x0000, 0x0000
1231 },
1232 /* IMAGE_NT_HEADERS */
1233 {
1234 IMAGE_NT_SIGNATURE, /* Signature */
1235 /* IMAGE_FILE_HEADER */
1236 {
1237 IMAGE_FILE_MACHINE_NATIVE, /* Machine */
1238 4, /* NumberOfSections */
1239 0x47EFDF09, /* TimeDateStamp */
1240 0, /* PointerToSymbolTable */
1241 0, /* NumberOfSymbols */
1242#ifdef _WIN64
1243 0xF0, /* SizeOfOptionalHeader */
1244#else
1245 0xE0, /* SizeOfOptionalHeader */
1246#endif
1249 IMAGE_FILE_DLL, /* Characteristics */
1250 },
1251 /* IMAGE_OPTIONAL_HEADER */
1252 {
1253#ifdef _WIN64
1255#else
1257#endif
1258 8, /* MajorLinkerVersion */
1259 0, /* MinorLinkerVersion */
1260 0x400, /* SizeOfCode */
1261 0x000, /* SizeOfInitializedData */
1262 0, /* SizeOfUninitializedData */
1263 0x2000, /* AddressOfEntryPoint */
1264 0x2000, /* BaseOfCode */
1265#ifndef _WIN64
1266 0x0000, /* BaseOfData */
1267#endif
1268 0x400000, /* ImageBase */
1269 0x2000, /* SectionAlignment */
1270 0x200, /* FileAlignment */
1271 4, /* MajorOperatingSystemVersion */
1272 0, /* MinorOperatingSystemVersion */
1273 0, /* MajorImageVersion */
1274 0, /* MinorImageVersion */
1275 4, /* MajorSubsystemVersion */
1276 0, /* MinorSubsystemVersion */
1277 0, /* Win32VersionValue */
1278 0xa000, /* SizeOfImage */
1279 0x400, /* SizeOfHeaders */
1280 0x0, /* CheckSum */
1281 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
1284 IMAGE_DLLCHARACTERISTICS_NX_COMPAT, /* DllCharacteristics */
1285 0x100000, /* SizeOfStackReserve */
1286 0x1000, /* SizeOfStackCommit */
1287 0x100000, /* SizeOfHeapReserve */
1288 0x1000, /* SizeOfHeapCommit */
1289 0, /* LoaderFlags */
1290 0x10, /* NumberOfRvaAndSizes */
1291 /* IMAGE_DATA_DIRECTORY */
1292 {
1293 { 0 }, /* Export Table */
1294 { 0 }, /* Import Table */
1295 { 0 }, /* Resource Table */
1296 { 0 }, /* Exception Table */
1297 { 0 }, /* Certificate Table */
1298 { 0 }, /* Base Relocation Table */
1299 { 0 }, /* Debug */
1300 { 0 }, /* Copyright */
1301 { 0 }, /* Global Ptr */
1302 { 0 }, /* TLS Table */
1303 { 0 }, /* Load Config Table */
1304 { 0 }, /* Bound Import */
1305 { 0 }, /* IAT */
1306 { 0 }, /* Delay Import Descriptor */
1307 { 0 }, /* CLI Header */
1308 { 0 } /* Reserved */
1309 }
1310 }
1311 },
1312 /* IMAGE_SECTION_HEADER */
1313 {
1314 ".text", /* Name */
1315 { 0x394 }, /* Misc.VirtualSize */
1316 0x2000, /* VirtualAddress */
1317 0x400, /* SizeOfRawData */
1318 0x400, /* PointerToRawData */
1319 0, /* PointerToRelocations */
1320 0, /* PointerToLinenumbers */
1321 0, /* NumberOfRelocations */
1322 0, /* NumberOfLinenumbers */
1324 IMAGE_SCN_CNT_CODE, /* Characteristics */
1325 },
1326 /* IMAGE_SECTION_HEADER */
1327 {
1328 ".rossym", /* Name */
1329 { 0x100 }, /* Misc.VirtualSize */
1330 0x4000, /* VirtualAddress */
1331 0x400, /* SizeOfRawData */
1332 0x800, /* PointerToRawData */
1333 0, /* PointerToRelocations */
1334 0, /* PointerToLinenumbers */
1335 0, /* NumberOfRelocations */
1336 0, /* NumberOfLinenumbers */
1337 /* CORE-8384 */
1338 IMAGE_SCN_MEM_READ | IMAGE_SCN_TYPE_NOLOAD, /* Characteristics */
1339 },
1340 /* IMAGE_SECTION_HEADER */
1341 {
1342 ".rsrc", /* Name */
1343 { 0x100 }, /* Misc.VirtualSize */
1344 0x6000, /* VirtualAddress */
1345 0x400, /* SizeOfRawData */
1346 0xC00, /* PointerToRawData */
1347 0, /* PointerToRelocations */
1348 0, /* PointerToLinenumbers */
1349 0, /* NumberOfRelocations */
1350 0, /* NumberOfLinenumbers */
1352 IMAGE_SCN_CNT_INITIALIZED_DATA, /* Characteristics */
1353 },
1354 /* IMAGE_SECTION_HEADER */
1355 {
1356 ".clc", /* Name */
1357 { 0x2000 }, /* Misc.VirtualSize */
1358 0x8000, /* VirtualAddress */
1359 0x1000, /* SizeOfRawData */
1360 0x1000, /* PointerToRawData */
1361 0, /* PointerToRelocations */
1362 0, /* PointerToLinenumbers */
1363 0, /* NumberOfRelocations */
1364 0, /* NumberOfLinenumbers */
1365 /* CORE-12582 */
1368 },
1369 /* fill */
1370 { 0 },
1371 /* text */
1372 { 0xc3, 0 },
1373 /* rossym */
1374 {
1375 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1376 BYTES8(0xaa),
1377 BYTES16(0xbb),
1378 BYTES32(0xcc),
1379 BYTES64(0xdd),
1380 BYTES64(0xee),
1381 BYTES64(0xff),
1382 },
1383 /* rsrc */
1384 {
1385 BYTES128(0xee),
1386 BYTES128(0x55),
1387 BYTES128(0xee),
1388 BYTES128(0x11),
1389 BYTES128(0xff),
1390 BYTES128(0x00),
1391 BYTES128(0x00),
1392 BYTES128(0xdd),
1393 },
1394 /* clc */
1395 {
1396 BYTES512(0x11),
1397 BYTES512(0x22),
1398 BYTES512(0x33),
1399 BYTES512(0x44),
1400 BYTES512(0x55),
1401 BYTES512(0x66),
1402 BYTES512(0x77),
1403 BYTES512(0x88),
1404 },
1406
1411
1412static
1413void
1415{
1417 WCHAR TempPath[MAX_PATH];
1419 HANDLE Handle;
1420 HANDLE SectionHandle;
1424 ULONG Written;
1425 ULONG Length;
1426 BOOL Success;
1427
1428 Length = GetTempPathW(MAX_PATH, TempPath);
1429 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1430 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1431 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1434 0,
1435 NULL,
1437 0,
1438 NULL);
1440 {
1441 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
1442 return;
1443 }
1444 if (Relocate)
1445 {
1446#ifdef _WIN64
1447 ok((ULONG_PTR)GetModuleHandle(NULL) <= 0x00007FFFFFFFFFFF, "Module at %p\n", GetModuleHandle(NULL));
1448#else
1449 ok((ULONG_PTR)GetModuleHandle(NULL) <= 0x80000000, "Module at %p\n", GetModuleHandle(NULL));
1450#endif
1451 SectionContentsImageFile.nthdrs.OptionalHeader.ImageBase = (ULONG_PTR)GetModuleHandle(NULL);
1452 }
1453 else
1454 {
1455 SectionContentsImageFile.nthdrs.OptionalHeader.ImageBase = 0xe400000;
1456 }
1457
1461 &Written,
1462 NULL);
1463 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
1464 ok(Written == sizeof(SectionContentsImageFile), "WriteFile wrote %lu bytes\n", Written);
1465
1466 Status = NtCreateSection(&SectionHandle,
1468 NULL,
1469 NULL,
1471 SEC_IMAGE,
1472 Handle);
1474
1475 if (NT_SUCCESS(Status))
1476 {
1477 /* Map the section with */
1478 BaseAddress = NULL;
1479 SectionOffset.QuadPart = 0;
1480 ViewSize = 0;
1481 Status = NtMapViewOfSection(SectionHandle,
1483 &BaseAddress,
1484 0,
1485 0,
1487 &ViewSize,
1488 ViewShare,
1489 0,
1491 if (Relocate)
1493 else
1495 if (NT_SUCCESS(Status))
1496 {
1498#define TEST_BYTE(n, v) StartSeh() ok_hex(Bytes[n], v); EndSeh(STATUS_SUCCESS);
1499#define TEST_WRITE(n) StartSeh() *(volatile UCHAR *)&Bytes[n] = Bytes[n]; EndSeh(STATUS_SUCCESS);
1500#define TEST_NOWRITE(n) StartSeh() *(volatile UCHAR *)&Bytes[n] = Bytes[n]; EndSeh(STATUS_ACCESS_VIOLATION);
1501 TEST_NOWRITE(0x2000);
1502 TEST_BYTE(0x2000, 0xc3);
1503 TEST_BYTE(0x2001, 0x00);
1504 TEST_NOWRITE(0x4000);
1505 TEST_BYTE(0x4000, 0x01);
1506 TEST_BYTE(0x4001, 0x23);
1507 TEST_BYTE(0x4007, 0xef);
1508 TEST_BYTE(0x4008, 0xaa);
1509 TEST_BYTE(0x4010, 0xbb);
1510 TEST_BYTE(0x4020, 0xcc);
1511 TEST_BYTE(0x4040, 0xdd);
1512 TEST_BYTE(0x4080, 0xee);
1513 TEST_BYTE(0x40c0, 0xff);
1514 TEST_BYTE(0x40ff, 0xff);
1515 TEST_BYTE(0x4100, 0x00);
1516 TEST_BYTE(0x41ff, 0x00);
1517 TEST_NOWRITE(0x6000);
1518 TEST_BYTE(0x6000, 0xee);
1519 TEST_BYTE(0x60ff, 0x55);
1520 TEST_BYTE(0x6100, 0xee);
1521 TEST_BYTE(0x63ff, 0xdd);
1522 TEST_BYTE(0x6400, 0x00);
1523 TEST_WRITE(0x8000);
1524 TEST_BYTE(0x8000, 0x11);
1525 TEST_BYTE(0x8400, 0x33);
1526#undef TEST_BYTE
1527#undef TEST_WRITE
1528#undef TEST_NOWRITE
1531 }
1532 Status = NtClose(SectionHandle);
1534 }
1535
1538}
1539
1541{
1550 BYTE pad[448];
1555{
1556 /* IMAGE_DOS_HEADER */
1557 {
1558 IMAGE_DOS_SIGNATURE, 144, 3, 0, 4, 0, 0xFFFF, 0, 0xB8, 0, 0, 0, 0x40,
1559 0, { 0 }, 0, 0, { 0 }, 0x80
1560 },
1561 /* binary to print "This program cannot be run in DOS mode." */
1562 {
1563 0x1F0E, 0x0EBA, 0xB400, 0xCD09, 0xB821, 0x4C01, 0x21CD, 0x6854, 0x7369,
1564 0x7020, 0x6F72, 0x7267, 0x6D61, 0x6320, 0x6E61, 0x6F6E, 0x2074, 0x6562,
1565 0x7220, 0x6E75, 0x6920, 0x206E, 0x4F44, 0x2053, 0x6F6D, 0x6564, 0x0D2E,
1566 0x0A0D, 0x0024, 0x0000, 0x0000, 0x0000
1567 },
1568 /* IMAGE_NT_HEADERS32 */
1569 {
1570 IMAGE_NT_SIGNATURE, /* Signature */
1571 /* IMAGE_FILE_HEADER */
1572 {
1573 IMAGE_FILE_MACHINE_I386, /* Machine */
1574 5, /* NumberOfSections */
1575 0x47EFDF09, /* TimeDateStamp */
1576 0, /* PointerToSymbolTable */
1577 0, /* NumberOfSymbols */
1578 0xE0, /* SizeOfOptionalHeader */
1581 IMAGE_FILE_DLL, /* Characteristics */
1582 },
1583 /* IMAGE_OPTIONAL_HEADER32 */
1584 {
1586 8, /* MajorLinkerVersion */
1587 0, /* MinorLinkerVersion */
1588 0x400, /* SizeOfCode */
1589 0x000, /* SizeOfInitializedData */
1590 0, /* SizeOfUninitializedData */
1591 0x1000, /* AddressOfEntryPoint */
1592 0x1000, /* BaseOfCode */
1593 0x0000, /* BaseOfData */
1594 0x400000, /* ImageBase */
1595 0x1000, /* SectionAlignment */
1596 0x200, /* FileAlignment */
1597 4, /* MajorOperatingSystemVersion */
1598 0, /* MinorOperatingSystemVersion */
1599 0, /* MajorImageVersion */
1600 0, /* MinorImageVersion */
1601 4, /* MajorSubsystemVersion */
1602 0, /* MinorSubsystemVersion */
1603 0, /* Win32VersionValue */
1604 0x6000, /* SizeOfImage */
1605 0x400, /* SizeOfHeaders */
1606 0x0, /* CheckSum */
1607 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
1610 IMAGE_DLLCHARACTERISTICS_NX_COMPAT, /* DllCharacteristics */
1611 0x100000, /* SizeOfStackReserve */
1612 0x1000, /* SizeOfStackCommit */
1613 0x100000, /* SizeOfHeapReserve */
1614 0x1000, /* SizeOfHeapCommit */
1615 0, /* LoaderFlags */
1616 0x10, /* NumberOfRvaAndSizes */
1617 /* IMAGE_DATA_DIRECTORY */
1618 {
1619 { 0 }, /* Export Table */
1620 { 0 }, /* Import Table */
1621 { 0 }, /* Resource Table */
1622 { 0 }, /* Exception Table */
1623 { 0 }, /* Certificate Table */
1624 { 0 }, /* Base Relocation Table */
1625 { 0 }, /* Debug */
1626 { 0 }, /* Copyright */
1627 { 0 }, /* Global Ptr */
1628 { 0 }, /* TLS Table */
1629 { 0 }, /* Load Config Table */
1630 { 0 }, /* Bound Import */
1631 { 0 }, /* IAT */
1632 { 0 }, /* Delay Import Descriptor */
1633 { 0 }, /* CLI Header */
1634 { 0 } /* Reserved */
1635 }
1636 }
1637 },
1638 /* IMAGE_SECTION_HEADER */
1639 {
1640 /* SizeOfRawData larger than VirtualSize */
1641 ".text", /* Name */
1642 { 0x1000 }, /* Misc.VirtualSize */
1643 0x1000, /* VirtualAddress */
1644 0x1200, /* SizeOfRawData */
1645 0x400, /* PointerToRawData */
1646 0, /* PointerToRelocations */
1647 0, /* PointerToLinenumbers */
1648 0, /* NumberOfRelocations */
1649 0, /* NumberOfLinenumbers */
1651 IMAGE_SCN_CNT_CODE, /* Characteristics */
1652 },
1653 /* IMAGE_SECTION_HEADER */
1654 {
1655 /* SizeOfRawData larger than VirtualSize */
1656 ".data", /* Name */
1657 { 0x100 }, /* Misc.VirtualSize */
1658 0x2000, /* VirtualAddress */
1659 0x1200, /* SizeOfRawData */
1660 0x1600, /* PointerToRawData */
1661 0, /* PointerToRelocations */
1662 0, /* PointerToLinenumbers */
1663 0, /* NumberOfRelocations */
1664 0, /* NumberOfLinenumbers */
1666 IMAGE_SCN_CNT_INITIALIZED_DATA, /* Characteristics */
1667 },
1668 /* IMAGE_SECTION_HEADER */
1669 {
1670 /* SizeOfRawData = 0 */
1671 ".zdata", /* Name */
1672 { 0x100 }, /* Misc.VirtualSize */
1673 0x3000, /* VirtualAddress */
1674 0, /* SizeOfRawData */
1675 0x2800, /* PointerToRawData */
1676 0, /* PointerToRelocations */
1677 0, /* PointerToLinenumbers */
1678 0, /* NumberOfRelocations */
1679 0, /* NumberOfLinenumbers */
1681 IMAGE_SCN_CNT_UNINITIALIZED_DATA, /* Characteristics */
1682 },
1683 /* IMAGE_SECTION_HEADER */
1684 {
1685 /* VirtualSize larger than SizeOfRawData */
1686 ".rsrc", /* Name */
1687 { 0x300 }, /* Misc.VirtualSize */
1688 0x4000, /* VirtualAddress */
1689 0x200, /* SizeOfRawData */
1690 0x2800, /* PointerToRawData */
1691 0, /* PointerToRelocations */
1692 0, /* PointerToLinenumbers */
1693 0, /* NumberOfRelocations */
1694 0, /* NumberOfLinenumbers */
1696 IMAGE_SCN_CNT_INITIALIZED_DATA, /* Characteristics */
1697 },
1698 /* IMAGE_SECTION_HEADER */
1699 {
1700 /* PointerToRawData = 0 while SizeOfRawData != 0, CORE-18797 */
1701 ".bss", /* Name */
1702 { 0x400 }, /* Misc.VirtualSize */
1703 0x5000, /* VirtualAddress */
1704 0x600, /* SizeOfRawData */
1705 0, /* PointerToRawData */
1706 0, /* PointerToRelocations */
1707 0, /* PointerToLinenumbers */
1708 0, /* NumberOfRelocations */
1709 0, /* NumberOfLinenumbers */
1711 IMAGE_SCN_CNT_UNINITIALIZED_DATA, /* Characteristics */
1712 },
1713 /* fill */
1714 { 0 },
1715 /* text */
1716 {
1717 0xc3, 0, 0, 0, 0, 0, 0, 0,
1718 BYTES8(1),
1719 BYTES16(2),
1720 BYTES32(3),
1721 BYTES64(4),
1722 BYTES128(5),
1723 BYTES256(6),
1724 BYTES512(7),
1725 BYTES1024(8),
1726 BYTES1024(9),
1727 BYTES1024(0xa),
1728 BYTES512(0xb),
1729 },
1730 /* data */
1731 {
1732 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1733 BYTES8(0xaa),
1734 BYTES16(0xbb),
1735 BYTES32(0xcc),
1736 BYTES64(0xdd),
1737 BYTES128(0xee),
1738 BYTES256(0xff),
1739 BYTES512(0xee),
1740 BYTES1024(0xdd),
1741 BYTES1024(0xcc),
1742 BYTES1024(0xbb),
1743 BYTES512(0xaa),
1744 },
1745 /* rsrc */
1746 {
1747 BYTES256(0xff),
1748 BYTES128(0xee),
1749 BYTES64(0xdd),
1750 BYTES32(0xcc),
1751 BYTES16(0xbb),
1752 BYTES8(0xaa),
1753 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01,
1754 },
1756
1757C_ASSERT(FIELD_OFFSET(struct _RAW_SIZE_IMAGE_FILE, text_data) == 0x400);
1758C_ASSERT(FIELD_OFFSET(struct _RAW_SIZE_IMAGE_FILE, data_data) == 0x1600);
1759C_ASSERT(FIELD_OFFSET(struct _RAW_SIZE_IMAGE_FILE, rsrc_data) == 0x2800);
1760
1761// CORE-17284
1762static
1763void
1765{
1767 WCHAR TempPath[MAX_PATH];
1769 HANDLE Handle;
1770 HANDLE SectionHandle;
1774 ULONG Written;
1775 ULONG Length;
1776 BOOL Success;
1777
1778 Length = GetTempPathW(MAX_PATH, TempPath);
1779 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1780 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1781 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1784 0,
1785 NULL,
1787 0,
1788 NULL);
1790 {
1791 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
1792 return;
1793 }
1794 RawSizeImageFile.nthdrs.OptionalHeader.ImageBase = 0xe400000;
1795 if (TestNumber == 1)
1796 {
1797 /* Just for fun, show that these flags don't matter. */
1802 }
1803 else if (TestNumber == 2)
1804 {
1805 /* SizeOfRawData is too large and will overflow.
1806 * This should cause failure to load the file */
1807 RawSizeImageFile.rsrc_header.SizeOfRawData = (ULONG)-0x200;
1808 }
1809
1812 sizeof(RawSizeImageFile),
1813 &Written,
1814 NULL);
1815 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
1816 ok(Written == sizeof(RawSizeImageFile), "WriteFile wrote %lu bytes\n", Written);
1817
1818 Status = NtCreateSection(&SectionHandle,
1820 NULL,
1821 NULL,
1823 SEC_IMAGE,
1824 Handle);
1825 if (TestNumber == 2)
1826 {
1827 /* overflow in SizeOfRawData */
1829 }
1830 else
1831 {
1833 }
1834
1835 if (NT_SUCCESS(Status))
1836 {
1837 /* Map the section with */
1838 BaseAddress = NULL;
1839 SectionOffset.QuadPart = 0;
1840 ViewSize = 0;
1841 Status = NtMapViewOfSection(SectionHandle,
1843 &BaseAddress,
1844 0,
1845 0,
1847 &ViewSize,
1848 ViewShare,
1849 0,
1852 if (NT_SUCCESS(Status))
1853 {
1856
1857 /* .text section header is unmodified */
1858 ok_hex(ImageFile->text_header.Misc.VirtualSize, RawSizeImageFile.text_header.Misc.VirtualSize);
1859 ok_hex(ImageFile->text_header.VirtualAddress, RawSizeImageFile.text_header.VirtualAddress);
1860 ok_hex(ImageFile->text_header.SizeOfRawData, RawSizeImageFile.text_header.SizeOfRawData);
1861 ok_hex(ImageFile->text_header.PointerToRawData, RawSizeImageFile.text_header.PointerToRawData);
1862
1863 /* SizeOfRawData = 0 resets PointerToRawData to 0 */
1864 ok_hex(ImageFile->zdata_header.Misc.VirtualSize, RawSizeImageFile.zdata_header.Misc.VirtualSize);
1865 ok_hex(ImageFile->zdata_header.VirtualAddress, RawSizeImageFile.zdata_header.VirtualAddress);
1866 ok_hex(ImageFile->zdata_header.SizeOfRawData, RawSizeImageFile.zdata_header.SizeOfRawData);
1867 ok_hex(ImageFile->zdata_header.PointerToRawData, 0);
1868
1869 /* .bss section is unmodified */
1870 ok_hex(ImageFile->bss_header.SizeOfRawData, 0x600);
1871 ok_hex(ImageFile->bss_header.PointerToRawData, 0);
1872
1873#define TEST_BYTE(n, v) \
1874 StartSeh() \
1875 ok(Bytes[n] == v, "[%lu] Bytes[%u] = 0x%x, expected 0x%x\n", \
1876 TestNumber, n, Bytes[n], v); \
1877 EndSeh(STATUS_SUCCESS);
1878 /* .text section data matches file up to 0x1000 */
1879 TEST_BYTE(0x1000, 0xc3);
1880 TEST_BYTE(0x1001, 0x00);
1881 TEST_BYTE(0x1008, 0x01);
1882 TEST_BYTE(0x1010, 0x02);
1883 TEST_BYTE(0x1fff, 0x0a);
1884
1885 /* .data section data matches file up to 0x1000 */
1886 TEST_BYTE(0x2000, 0x01);
1887 TEST_BYTE(0x2001, 0x23);
1888 TEST_BYTE(0x20ff, 0xee);
1889 TEST_BYTE(0x2100, 0xff);
1890 TEST_BYTE(0x2fff, 0xbb);
1891
1892 /* .zdata section data is all zeroes */
1893 TEST_BYTE(0x3000, 0x00);
1894 TEST_BYTE(0x3001, 0x00);
1895 TEST_BYTE(0x3800, 0x00);
1896 TEST_BYTE(0x3fff, 0x00);
1897
1898 /* .rsrc section data matches file up to VirtualSize 0x200 */
1899 TEST_BYTE(0x4000, 0xff);
1900 TEST_BYTE(0x4100, 0xee);
1901 TEST_BYTE(0x4180, 0xdd);
1902 TEST_BYTE(0x41c0, 0xcc);
1903 TEST_BYTE(0x41e0, 0xbb);
1904 TEST_BYTE(0x41f0, 0xaa);
1905 TEST_BYTE(0x41fe, 0x23);
1906 TEST_BYTE(0x41ff, 0x01);
1907 TEST_BYTE(0x4200, 0x00);
1908 TEST_BYTE(0x4fff, 0x00);
1909#undef TEST_BYTE
1912 }
1913 Status = NtClose(SectionHandle);
1915 }
1916
1919}
1920
1921static void
1923{
1925 WCHAR TempPath[MAX_PATH];
1927 HANDLE Handle;
1928 HANDLE SectionHandle;
1929 ULONG Length;
1930
1931 Length = GetTempPathW(MAX_PATH, TempPath);
1932 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1933 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1934 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1937 0,
1938 NULL,
1940 0,
1941 NULL);
1943 {
1944 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
1945 return;
1946 }
1947
1948 Status = NtCreateSection(&SectionHandle,
1952
1953 if (NT_SUCCESS(Status))
1954 NtClose(SectionHandle);
1955
1956 Status = NtCreateSection(&SectionHandle,
1960
1961 if (NT_SUCCESS(Status))
1962 NtClose(SectionHandle);
1963
1966}
1967
1968// CORE-11206
1969static void
1971{
1972 WCHAR TempPath[MAX_PATH];
1975 SIZE_T ViewSize = 0;
1976 HANDLE Handle;
1977 HANDLE SectionHandle;
1978
1979 SIZE_T Length;
1980 BOOL Success;
1981 DWORD Written, Error;
1983
1984 Length = GetTempPathW(MAX_PATH, TempPath);
1985 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1986 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1987 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1989
1990 Success = WriteFile(Handle, "TESTDATA", 8, &Written, NULL);
1991 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
1992 ok(Written == 8, "WriteFile wrote %lu bytes\n", Written);
1993
1994 Written = SetFilePointer(Handle, 6, NULL, FILE_BEGIN);
1995 ok(Written == 6, "SetFilePointer returned %lu bytes\n", Written);
1997 ok(Success == TRUE, "SetEndOfFile failed with %lu\n", GetLastError());
1998
1999 Status = NtCreateSection(&SectionHandle,
2003 BaseAddress = NULL;
2004 ViewSize = 0;
2005 Status = NtMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0,
2006 0, 0, &ViewSize, ViewShare, 0, PAGE_READONLY);
2008
2009 if (BaseAddress)
2010 {
2011 // First we test data that was truncated even before the file mapping was opened
2012 Length = strlen((char*)BaseAddress);
2013 ok(Length == 6, "Old data was not properly erased! (Length=%lu)\n", Length);
2014 }
2015
2016 // Now we truncate the file on disk some more
2017 Written = SetFilePointer(Handle, 4, NULL, FILE_BEGIN);
2018 ok(Written == 4, "SetFilePointer returned %lu bytes\n", Written);
2020 Error = GetLastError();
2021 ok(Success == FALSE, "SetEndOfFile succeeded\n");
2022 ok(Error == ERROR_USER_MAPPED_FILE, "SetEndOfFile did not set error to ERROR_USER_MAPPED_FILE (%lu)\n", Error);
2023
2024 if (BaseAddress)
2025 {
2026 Length = strlen((char*)BaseAddress);
2027 ok(Length == 6, "Length should not have changed! (Length=%lu)\n", Length);
2028 }
2029
2030 // Unmap and set the end shorter.
2033 Success = CloseHandle(SectionHandle);
2034 ok(Success == TRUE, "CloseHandle failed with %lu\n", GetLastError());
2035
2036 Written = SetFilePointer(Handle, 4, NULL, FILE_BEGIN);
2037 ok(Written == 4, "SetFilePointer returned %lu bytes\n", Written);
2039 ok(Success == TRUE, "SetEndOfFile failed with %lu\n", GetLastError());
2040
2041 Status = NtCreateSection(&SectionHandle,
2045 BaseAddress = NULL;
2046 ViewSize = 0;
2047 Status = NtMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0,
2048 0, 0, &ViewSize, ViewShare, 0, PAGE_READONLY);
2050
2051 // CLEANUP
2054 Success = CloseHandle(SectionHandle);
2055 ok(Success == TRUE, "CloseHandle failed with %lu\n", GetLastError());
2057 ok(Success == TRUE, "CloseHandle failed with %lu\n", GetLastError());
2058
2060 ok(Success == TRUE, "DeleteFileW failed with %lu\n", GetLastError());
2061}
2062
2064{
2070 Test_RawSize(0);
2071 Test_RawSize(1);
2072 Test_RawSize(2);
2074 Test_Truncate();
2075}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3498
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3090
NTSTATUS NTAPI NtMapViewOfSection(_In_ HANDLE SectionHandle, _In_ HANDLE ProcessHandle, _Outptr_result_bytebuffer_(*ViewSize) _Pre_valid_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_range_(ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Win32Protect)
Definition: section.c:3271
#define BYTES512(x)
#define BYTES256(x)
#define BYTES128(x)
#define BYTES32(x)
#define BYTES1024(x)
void Test_ImageSection2(void)
#define TEST_WRITE(n)
static void Test_SectionContents(BOOL Relocate)
#define TEST_NOWRITE(n)
void Test_PageFileSection(void)
#define BYTES64(x)
#define TEST_BYTE(n, v)
void Test_ImageSection(void)
static void Test_EmptyFile(VOID)
#define IsX86()
#define BYTES8(x)
static struct _SECTION_CONTENTS_IMAGE_FILE SectionContentsImageFile
void Test_BasedSection(void)
static struct _RAW_SIZE_IMAGE_FILE RawSizeImageFile
static void Test_RawSize(ULONG TestNumber)
static void Test_Truncate(VOID)
#define BYTES16(x)
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define GetNTVersion()
Definition: apitest.h:17
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
BOOL Error
Definition: chkdsk.c:66
#define MAXULONG_PTR
Definition: basetsd.h:97
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define FILE_BEGIN
Definition: compat.h:761
#define SECTION_MAP_READ
Definition: compat.h:139
#define wcsrchr
Definition: compat.h:16
#define SetFilePointer
Definition: compat.h:743
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:989
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:1999
_ACRTIMP int __cdecl system(const char *)
Definition: process.c:1297
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
#define L(x)
Definition: resources.c:13
#define UlongToPtr(u)
Definition: config.h:106
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
@ Success
Definition: eventcreate.c:712
struct _FileName FileName
Definition: fatprocs.h:897
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define STATUS_ACCESS_VIOLATION
#define printf
Definition: freeldr.h:103
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:24
static PWSTR ImageFile
Definition: imagefile.c:10
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define C_ASSERT(e)
Definition: intsafe.h:73
_In_ UINT Bytes
Definition: mmcopy.h:9
#define CREATE_ALWAYS
Definition: disk.h:72
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:411
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:366
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID * BaseAddress
Definition: mmfuncs.h:408
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:412
#define SEC_COMMIT
Definition: mmtypes.h:100
#define SEC_IMAGE
Definition: mmtypes.h:97
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define SYNCHRONIZE
Definition: nt_native.h:61
#define MEM_DECOMMIT
Definition: nt_native.h:1318
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1296
#define SECTION_QUERY
Definition: nt_native.h:1290
#define SEC_RESERVE
Definition: nt_native.h:1326
#define NtCurrentProcess()
Definition: nt_native.h:1660
@ ViewShare
Definition: nt_native.h:1281
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3429
#define MEM_RESERVE
Definition: nt_native.h:1317
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define MEM_RELEASE
Definition: nt_native.h:1319
#define GENERIC_WRITE
Definition: nt_native.h:90
#define MEM_COMMIT
Definition: nt_native.h:1316
#define PAGE_NOACCESS
Definition: nt_native.h:1305
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1311
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:100
#define SEC_BASED
#define IMAGE_SCN_MEM_WRITE
Definition: ntimage.h:241
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
Definition: ntimage.h:438
#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT
Definition: ntimage.h:457
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: ntimage.h:377
#define IMAGE_SCN_CNT_CODE
Definition: ntimage.h:230
#define IMAGE_SCN_MEM_EXECUTE
Definition: ntimage.h:239
#define IMAGE_DLLCHARACTERISTICS_NO_SEH
Definition: ntimage.h:459
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA
Definition: ntimage.h:232
#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
Definition: ntimage.h:455
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5192
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
Definition: virtual.c:3076
NTSTATUS NTAPI NtFlushVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToFlush, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: virtual.c:4000
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4457
#define STATUS_INVALID_VIEW_SIZE
Definition: ntstatus.h:361
#define STATUS_MAPPED_ALIGNMENT
Definition: ntstatus.h:798
#define STATUS_SECTION_PROTECTION
Definition: ntstatus.h:408
#define STATUS_UNABLE_TO_DELETE_SECTION
Definition: ntstatus.h:357
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:453
#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH
Definition: ntstatus.h:203
#define STATUS_INVALID_PARAMETER_9
Definition: ntstatus.h:577
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:572
#define STATUS_INVALID_IMAGE_NOT_MZ
Definition: ntstatus.h:633
#define STATUS_INVALID_FILE_FOR_SECTION
Definition: ntstatus.h:362
#define STATUS_MAPPED_FILE_SIZE_ZERO
Definition: ntstatus.h:616
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:354
#define STATUS_INVALID_PAGE_PROTECTION
Definition: ntstatus.h:399
#define STATUS_SECTION_TOO_BIG
Definition: ntstatus.h:394
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:571
#define STATUS_IMAGE_NOT_AT_BASE
Definition: ntstatus.h:192
#define STATUS_COMMITMENT_LIMIT
Definition: ntstatus.h:631
#define IMAGE_SCN_TYPE_NOLOAD
Definition: pecoff.h:20
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED
Definition: pedump.c:162
short WCHAR
Definition: pedump.c:58
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_FILE_DLL
Definition: pedump.c:169
#define IMAGE_FILE_LINE_NUMS_STRIPPED
Definition: pedump.c:161
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define IMAGE_FILE_32BIT_MACHINE
Definition: pedump.c:164
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define wine_dbgstr_wn
Definition: testlist.c:2
#define _WIN32_WINNT_WIN10
Definition: sdkddkver.h:32
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
IMAGE_NT_HEADERS32 nthdrs
IMAGE_SECTION_HEADER zdata_header
IMAGE_SECTION_HEADER data_header
IMAGE_SECTION_HEADER bss_header
IMAGE_SECTION_HEADER text_header
IMAGE_SECTION_HEADER rsrc_header
IMAGE_SECTION_HEADER rossym_header
IMAGE_SECTION_HEADER text_header
IMAGE_SECTION_HEADER rsrc_header
Definition: stubgen.c:11
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PWDFDEVICE_INIT _In_ PWDF_FILEOBJECT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES FileObjectAttributes
Definition: wdfdevice.h:3406
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3548
#define ERROR_USER_MAPPED_FILE
Definition: winerror.h:1056
unsigned char BYTE
Definition: xxhash.c:193