ReactOS 0.4.16-dev-2284-g3529151
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 return;
800 }
801
802 /* Create a data section with write access */
803 Status = NtCreateSection(&DataSectionHandle,
804 SECTION_ALL_ACCESS, // DesiredAccess
805 NULL, // ObjectAttributes
806 NULL, // MaximumSize
807 PAGE_READWRITE, // SectionPageProtection
808 SEC_COMMIT, // AllocationAttributes
809 FileHandle);
811 if (!NT_SUCCESS(Status))
812 {
813 skip("Failed to create data section\n");
815 return;
816 }
817
818 /* Map the data section as flat mapping */
819 DataBase = NULL;
820 ViewSize = 0;
821 Status = NtMapViewOfSection(DataSectionHandle,
823 &DataBase,
824 0,
825 0,
826 NULL,
827 &ViewSize,
828 ViewShare,
829 0,
832 //ok(ViewSize == 0x3f95cc48, "ViewSize wrong: 0x%lx\n");
833 if (!NT_SUCCESS(Status))
834 {
835 skip("Failed to map view of data section\n");
836 NtClose(DataSectionHandle);
838 return;
839 }
840
841 /* Check the original data */
842 ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
843
844 /* Modify the PE header (but do not flush!) */
845 *(ULONG*)DataBase = 0xdeadbabe;
846 ok(*(ULONG*)DataBase == 0xdeadbabe, "Header not ok\n");
847
848 /* Modify data in the .data section (but do not flush!) */
849 ok(*(ULONG*)((PUCHAR)DataBase + 0x800) == 0x12345678,
850 "Data in .data section invalid: 0x%lx!\n", *(ULONG*)((PUCHAR)DataBase + 0x800));
851 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0x87654321;
852
853 /* Now try to create an image section (should fail) */
854 Status = NtCreateSection(&ImageSectionHandle,
855 SECTION_ALL_ACCESS, // DesiredAccess
856 NULL, // ObjectAttributes
857 NULL, // MaximumSize
858 PAGE_READWRITE, // SectionPageProtection
859 SEC_IMAGE, // AllocationAttributes
860 FileHandle);
862 if (NT_SUCCESS(Status)) NtClose(ImageSectionHandle);
863
864 /* Restore the original header */
865 *(ULONG*)DataBase = 0x00905a4d;
866
867 /* Modify data in the .data section (but do not flush!) */
868 ok_hex(*(ULONG*)((PUCHAR)DataBase + 0x800), 0x87654321);
869 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0xdeadbabe;
870
871 /* Try to create an image section again */
872 Status = NtCreateSection(&ImageSectionHandle,
873 SECTION_ALL_ACCESS, // DesiredAccess
874 NULL, // ObjectAttributes
875 NULL, // MaximumSize
876 PAGE_READWRITE, // SectionPageProtection
877 SEC_IMAGE, // AllocationAttributes
878 FileHandle);
880 if (!NT_SUCCESS(Status))
881 {
882 skip("Failed to create image section\n");
883 NtClose(DataSectionHandle);
885 return;
886 }
887
888 /* Map the image section */
889 ImageBase = NULL;
890 ViewSize = 0;
891 Status = NtMapViewOfSection(ImageSectionHandle,
893 &ImageBase,
894 0, // ZeroBits
895 0, // CommitSize
896 NULL, // SectionOffset
897 &ViewSize,
898 ViewShare,
899 0, // AllocationType
901#ifdef _M_IX86
903#else
905#endif
906 if (!NT_SUCCESS(Status))
907 {
908 skip("Failed to map view of image section\n");
909 NtClose(ImageSectionHandle);
910 NtClose(DataSectionHandle);
912 return;
913 }
914
915 /* Check the header */
916 ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
917 ok(*(ULONG*)ImageBase == 0x00905a4d, "Header not ok\n");
918
919 /* Check the data section. Either of these can be present! */
920 ok((*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x87654321) ||
921 (*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x12345678),
922 "Wrong value in data section: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
923
924 /* Now modify the data again */
925 *(ULONG*)DataBase = 0xdeadbabe;
926 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0xf00dada;
927
928 /* Check the data */
929 ok(*(ULONG*)DataBase == 0xdeadbabe, "Header not ok\n");
930 ok(*(ULONG*)ImageBase == 0x00905a4d, "Data should not be synced!\n");
931 ok((*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x87654321) ||
932 (*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x12345678),
933 "Wrong value in data section: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
934
935 /* Flush the view */
936 ViewSize = 0x1000;
938 &DataBase,
939 &ViewSize,
942
943 /* Check the data again */
944 ok(*(ULONG*)ImageBase == 0x00905a4d, "Data should not be synced!\n");
945 ok((*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x87654321) ||
946 (*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0x12345678),
947 "Wrong value in data section: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
948
949 /* Restore the original header */
950 *(ULONG*)DataBase = 0x00905a4d;
951 ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
952
953 /* Close the image mapping */
955 NtClose(ImageSectionHandle);
956
957 /* Create an image section again */
958 Status = NtCreateSection(&ImageSectionHandle,
959 SECTION_ALL_ACCESS, // DesiredAccess
960 NULL, // ObjectAttributes
961 NULL, // MaximumSize
962 PAGE_READWRITE, // SectionPageProtection
963 SEC_IMAGE, // AllocationAttributes
964 FileHandle);
966 if (!NT_SUCCESS(Status))
967 {
968 skip("Failed to create image section\n");
969 NtClose(DataSectionHandle);
971 return;
972 }
973
974 /* Map the image section again */
975 ImageBase = NULL;
976 ViewSize = 0;
977 Status = NtMapViewOfSection(ImageSectionHandle,
979 &ImageBase,
980 0,
981 0,
982 NULL,
983 &ViewSize,
984 ViewShare,
985 0,
987#ifdef _M_IX86
989#else
991#endif
992 if (!NT_SUCCESS(Status))
993 {
994 skip("Failed to map view of image section\n");
995 NtClose(ImageSectionHandle);
996 NtClose(DataSectionHandle);
998 return;
999 }
1000
1001 // This one doesn't always work, needs investigation
1002 /* Check the .data section again */
1003 //ok(*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0xf00dada,
1004 // "Data should be synced: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
1005
1006 /* Restore the original data */
1007 *(ULONG*)((PUCHAR)DataBase + 0x800) = 0x12345678;
1008
1009 /* Close the data mapping */
1011
1012 NtClose(DataSectionHandle);
1013
1014 /* Try to allocate memory inside the image mapping */
1015 DataBase = (PUCHAR)ImageBase + 0x20000;
1016 ViewSize = 0x1000;
1019
1020 /* Cleanup */
1022 NtClose(ImageSectionHandle);
1024}
1025
1026void
1028{
1033 HANDLE FileHandle, ImageSectionHandle;
1034 PVOID ImageBase, BaseAddress;
1037
1038 if (!RtlDosPathNameToNtPathName_U(L"testdata\\nvoglv32.dll",
1039 &FileName,
1040 NULL,
1041 NULL))
1042 {
1043 ok(0, "RtlDosPathNameToNtPathName_U failed\n");
1044 return;
1045 }
1046
1048 &FileName,
1049 0,
1050 NULL,
1051 NULL);
1052
1060 printf("Opened file with handle %p\n", FileHandle);
1061
1062 /* Create a data section with write access */
1063 MaximumSize.QuadPart = 0x20000;
1064 Status = NtCreateSection(&ImageSectionHandle,
1065 SECTION_ALL_ACCESS, // DesiredAccess
1066 NULL, // ObjectAttributes
1067 &MaximumSize, // MaximumSize
1068 PAGE_READWRITE, // SectionPageProtection
1069 SEC_IMAGE, // AllocationAttributes
1070 FileHandle);
1072
1073 printf("Created image section with handle %p\n", ImageSectionHandle);
1074 //system("PAUSE");
1075
1076 /* Map the image section */
1077 ImageBase = NULL;
1078 ViewSize = 0x0000;
1079 SectionOffset.QuadPart = 0x00000;
1080 Status = NtMapViewOfSection(ImageSectionHandle,
1082 &ImageBase,
1083 0,
1084 0,
1086 &ViewSize,
1087 ViewShare,
1088 0,
1091
1092 printf("Mapped image section at %p, value in text section: %lx\n",
1093 ImageBase, *((ULONG*)((PCHAR)ImageBase + 0x1196)));
1094 system("PAUSE");
1095
1096 /* Try to allocate a page after the section */
1097 BaseAddress = (PUCHAR)ImageBase + 0x10000;
1098 ViewSize = 0x1000;
1100 &BaseAddress,
1101 0,
1102 &ViewSize,
1105 printf("allocation status: %lx\n", Status);
1106 system("PAUSE");
1107
1108}
1109
1110// doesn't work with WoW64!
1111void
1113{
1115 HANDLE SectionHandle1, SectionHandle2;
1117 PVOID BaseAddress1, BaseAddress2;
1119
1120 /* Create a based section with SEC_COMMIT */
1121 MaximumSize.QuadPart = 0x1000;
1122 Status = NtCreateSection(&SectionHandle1,
1124 NULL,
1125 &MaximumSize,
1128 NULL);
1130
1131 /* Map the 1st section */
1132 BaseAddress1 = NULL;
1133 SectionOffset.QuadPart = 0;
1134 ViewSize = 0;
1135 Status = NtMapViewOfSection(SectionHandle1,
1137 &BaseAddress1,
1138 0,
1139 0,
1141 &ViewSize,
1142 ViewShare,
1143 0,
1145#if 0 // WOW64?
1147#else
1149#endif
1150
1151 /* Create a 2nd based section with SEC_COMMIT */
1152 MaximumSize.QuadPart = 0x1000;
1153 Status = NtCreateSection(&SectionHandle2,
1155 NULL,
1156 &MaximumSize,
1159 NULL);
1161
1162 /* Map the 2nd section */
1163 BaseAddress2 = NULL;
1164 SectionOffset.QuadPart = 0;
1165 ViewSize = 0;
1166 Status = NtMapViewOfSection(SectionHandle2,
1168 &BaseAddress2,
1169 0,
1170 0,
1172 &ViewSize,
1173 ViewShare,
1174 0,
1176#if 0 // WOW64?
1178#else
1180 ok((ULONG_PTR)BaseAddress2 < (ULONG_PTR)BaseAddress1,
1181 "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
1182 ok(((ULONG_PTR)BaseAddress1 - (ULONG_PTR)BaseAddress2) == 0x10000,
1183 "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
1184#endif
1185}
1186
1187#define BYTES4(x) x, x, x, x
1188#define BYTES8(x) BYTES4(x), BYTES4(x)
1189#define BYTES16(x) BYTES8(x), BYTES8(x)
1190#define BYTES32(x) BYTES16(x), BYTES16(x)
1191#define BYTES64(x) BYTES32(x), BYTES32(x)
1192#define BYTES128(x) BYTES64(x), BYTES64(x)
1193#define BYTES256(x) BYTES128(x), BYTES128(x)
1194#define BYTES512(x) BYTES256(x), BYTES256(x)
1195#define BYTES1024(x) BYTES512(x), BYTES512(x)
1196
1198{
1206#ifdef _WIN64
1207 BYTE pad[472];
1208#else
1209 BYTE pad[488];
1210#endif
1216{
1217 /* IMAGE_DOS_HEADER */
1218 {
1219 IMAGE_DOS_SIGNATURE, 144, 3, 0, 4, 0, 0xFFFF, 0, 0xB8, 0, 0, 0, 0x40,
1220 0, { 0 }, 0, 0, { 0 }, 0x80
1221 },
1222 /* binary to print "This program cannot be run in DOS mode." */
1223 {
1224 0x1F0E, 0x0EBA, 0xB400, 0xCD09, 0xB821, 0x4C01, 0x21CD, 0x6854, 0x7369,
1225 0x7020, 0x6F72, 0x7267, 0x6D61, 0x6320, 0x6E61, 0x6F6E, 0x2074, 0x6562,
1226 0x7220, 0x6E75, 0x6920, 0x206E, 0x4F44, 0x2053, 0x6F6D, 0x6564, 0x0D2E,
1227 0x0A0D, 0x0024, 0x0000, 0x0000, 0x0000
1228 },
1229 /* IMAGE_NT_HEADERS */
1230 {
1231 IMAGE_NT_SIGNATURE, /* Signature */
1232 /* IMAGE_FILE_HEADER */
1233 {
1234 IMAGE_FILE_MACHINE_NATIVE, /* Machine */
1235 4, /* NumberOfSections */
1236 0x47EFDF09, /* TimeDateStamp */
1237 0, /* PointerToSymbolTable */
1238 0, /* NumberOfSymbols */
1239#ifdef _WIN64
1240 0xF0, /* SizeOfOptionalHeader */
1241#else
1242 0xE0, /* SizeOfOptionalHeader */
1243#endif
1246 IMAGE_FILE_DLL, /* Characteristics */
1247 },
1248 /* IMAGE_OPTIONAL_HEADER */
1249 {
1250#ifdef _WIN64
1252#else
1254#endif
1255 8, /* MajorLinkerVersion */
1256 0, /* MinorLinkerVersion */
1257 0x400, /* SizeOfCode */
1258 0x000, /* SizeOfInitializedData */
1259 0, /* SizeOfUninitializedData */
1260 0x2000, /* AddressOfEntryPoint */
1261 0x2000, /* BaseOfCode */
1262#ifndef _WIN64
1263 0x0000, /* BaseOfData */
1264#endif
1265 0x400000, /* ImageBase */
1266 0x2000, /* SectionAlignment */
1267 0x200, /* FileAlignment */
1268 4, /* MajorOperatingSystemVersion */
1269 0, /* MinorOperatingSystemVersion */
1270 0, /* MajorImageVersion */
1271 0, /* MinorImageVersion */
1272 4, /* MajorSubsystemVersion */
1273 0, /* MinorSubsystemVersion */
1274 0, /* Win32VersionValue */
1275 0xa000, /* SizeOfImage */
1276 0x400, /* SizeOfHeaders */
1277 0x0, /* CheckSum */
1278 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
1281 IMAGE_DLLCHARACTERISTICS_NX_COMPAT, /* DllCharacteristics */
1282 0x100000, /* SizeOfStackReserve */
1283 0x1000, /* SizeOfStackCommit */
1284 0x100000, /* SizeOfHeapReserve */
1285 0x1000, /* SizeOfHeapCommit */
1286 0, /* LoaderFlags */
1287 0x10, /* NumberOfRvaAndSizes */
1288 /* IMAGE_DATA_DIRECTORY */
1289 {
1290 { 0 }, /* Export Table */
1291 { 0 }, /* Import Table */
1292 { 0 }, /* Resource Table */
1293 { 0 }, /* Exception Table */
1294 { 0 }, /* Certificate Table */
1295 { 0 }, /* Base Relocation Table */
1296 { 0 }, /* Debug */
1297 { 0 }, /* Copyright */
1298 { 0 }, /* Global Ptr */
1299 { 0 }, /* TLS Table */
1300 { 0 }, /* Load Config Table */
1301 { 0 }, /* Bound Import */
1302 { 0 }, /* IAT */
1303 { 0 }, /* Delay Import Descriptor */
1304 { 0 }, /* CLI Header */
1305 { 0 } /* Reserved */
1306 }
1307 }
1308 },
1309 /* IMAGE_SECTION_HEADER */
1310 {
1311 ".text", /* Name */
1312 { 0x394 }, /* Misc.VirtualSize */
1313 0x2000, /* VirtualAddress */
1314 0x400, /* SizeOfRawData */
1315 0x400, /* PointerToRawData */
1316 0, /* PointerToRelocations */
1317 0, /* PointerToLinenumbers */
1318 0, /* NumberOfRelocations */
1319 0, /* NumberOfLinenumbers */
1321 IMAGE_SCN_CNT_CODE, /* Characteristics */
1322 },
1323 /* IMAGE_SECTION_HEADER */
1324 {
1325 ".rossym", /* Name */
1326 { 0x100 }, /* Misc.VirtualSize */
1327 0x4000, /* VirtualAddress */
1328 0x400, /* SizeOfRawData */
1329 0x800, /* PointerToRawData */
1330 0, /* PointerToRelocations */
1331 0, /* PointerToLinenumbers */
1332 0, /* NumberOfRelocations */
1333 0, /* NumberOfLinenumbers */
1334 /* CORE-8384 */
1335 IMAGE_SCN_MEM_READ | IMAGE_SCN_TYPE_NOLOAD, /* Characteristics */
1336 },
1337 /* IMAGE_SECTION_HEADER */
1338 {
1339 ".rsrc", /* Name */
1340 { 0x100 }, /* Misc.VirtualSize */
1341 0x6000, /* VirtualAddress */
1342 0x400, /* SizeOfRawData */
1343 0xC00, /* PointerToRawData */
1344 0, /* PointerToRelocations */
1345 0, /* PointerToLinenumbers */
1346 0, /* NumberOfRelocations */
1347 0, /* NumberOfLinenumbers */
1349 IMAGE_SCN_CNT_INITIALIZED_DATA, /* Characteristics */
1350 },
1351 /* IMAGE_SECTION_HEADER */
1352 {
1353 ".clc", /* Name */
1354 { 0x2000 }, /* Misc.VirtualSize */
1355 0x8000, /* VirtualAddress */
1356 0x1000, /* SizeOfRawData */
1357 0x1000, /* PointerToRawData */
1358 0, /* PointerToRelocations */
1359 0, /* PointerToLinenumbers */
1360 0, /* NumberOfRelocations */
1361 0, /* NumberOfLinenumbers */
1362 /* CORE-12582 */
1365 },
1366 /* fill */
1367 { 0 },
1368 /* text */
1369 { 0xc3, 0 },
1370 /* rossym */
1371 {
1372 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1373 BYTES8(0xaa),
1374 BYTES16(0xbb),
1375 BYTES32(0xcc),
1376 BYTES64(0xdd),
1377 BYTES64(0xee),
1378 BYTES64(0xff),
1379 },
1380 /* rsrc */
1381 {
1382 BYTES128(0xee),
1383 BYTES128(0x55),
1384 BYTES128(0xee),
1385 BYTES128(0x11),
1386 BYTES128(0xff),
1387 BYTES128(0x00),
1388 BYTES128(0x00),
1389 BYTES128(0xdd),
1390 },
1391 /* clc */
1392 {
1393 BYTES512(0x11),
1394 BYTES512(0x22),
1395 BYTES512(0x33),
1396 BYTES512(0x44),
1397 BYTES512(0x55),
1398 BYTES512(0x66),
1399 BYTES512(0x77),
1400 BYTES512(0x88),
1401 },
1403
1408
1409static
1410void
1412{
1414 WCHAR TempPath[MAX_PATH];
1416 HANDLE Handle;
1417 HANDLE SectionHandle;
1421 ULONG Written;
1422 ULONG Length;
1423 BOOL Success;
1424
1425 Length = GetTempPathW(MAX_PATH, TempPath);
1426 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1427 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1428 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1431 0,
1432 NULL,
1434 0,
1435 NULL);
1437 {
1438 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
1439 return;
1440 }
1441 if (Relocate)
1442 {
1443#ifdef _WIN64
1444 ok((ULONG_PTR)GetModuleHandle(NULL) <= 0x00007FFFFFFFFFFF, "Module at %p\n", GetModuleHandle(NULL));
1445#else
1446 ok((ULONG_PTR)GetModuleHandle(NULL) <= 0x80000000, "Module at %p\n", GetModuleHandle(NULL));
1447#endif
1448 SectionContentsImageFile.nthdrs.OptionalHeader.ImageBase = (ULONG_PTR)GetModuleHandle(NULL);
1449 }
1450 else
1451 {
1452 SectionContentsImageFile.nthdrs.OptionalHeader.ImageBase = 0xe400000;
1453 }
1454
1458 &Written,
1459 NULL);
1460 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
1461 ok(Written == sizeof(SectionContentsImageFile), "WriteFile wrote %lu bytes\n", Written);
1462
1463 Status = NtCreateSection(&SectionHandle,
1465 NULL,
1466 NULL,
1468 SEC_IMAGE,
1469 Handle);
1471
1472 if (NT_SUCCESS(Status))
1473 {
1474 /* Map the section with */
1475 BaseAddress = NULL;
1476 SectionOffset.QuadPart = 0;
1477 ViewSize = 0;
1478 Status = NtMapViewOfSection(SectionHandle,
1480 &BaseAddress,
1481 0,
1482 0,
1484 &ViewSize,
1485 ViewShare,
1486 0,
1488 if (Relocate)
1490 else
1492 if (NT_SUCCESS(Status))
1493 {
1495#define TEST_BYTE(n, v) StartSeh() ok_hex(Bytes[n], v); EndSeh(STATUS_SUCCESS);
1496#define TEST_WRITE(n) StartSeh() *(volatile UCHAR *)&Bytes[n] = Bytes[n]; EndSeh(STATUS_SUCCESS);
1497#define TEST_NOWRITE(n) StartSeh() *(volatile UCHAR *)&Bytes[n] = Bytes[n]; EndSeh(STATUS_ACCESS_VIOLATION);
1498 TEST_NOWRITE(0x2000);
1499 TEST_BYTE(0x2000, 0xc3);
1500 TEST_BYTE(0x2001, 0x00);
1501 TEST_NOWRITE(0x4000);
1502 TEST_BYTE(0x4000, 0x01);
1503 TEST_BYTE(0x4001, 0x23);
1504 TEST_BYTE(0x4007, 0xef);
1505 TEST_BYTE(0x4008, 0xaa);
1506 TEST_BYTE(0x4010, 0xbb);
1507 TEST_BYTE(0x4020, 0xcc);
1508 TEST_BYTE(0x4040, 0xdd);
1509 TEST_BYTE(0x4080, 0xee);
1510 TEST_BYTE(0x40c0, 0xff);
1511 TEST_BYTE(0x40ff, 0xff);
1512 TEST_BYTE(0x4100, 0x00);
1513 TEST_BYTE(0x41ff, 0x00);
1514 TEST_NOWRITE(0x6000);
1515 TEST_BYTE(0x6000, 0xee);
1516 TEST_BYTE(0x60ff, 0x55);
1517 TEST_BYTE(0x6100, 0xee);
1518 TEST_BYTE(0x63ff, 0xdd);
1519 TEST_BYTE(0x6400, 0x00);
1520 TEST_WRITE(0x8000);
1521 TEST_BYTE(0x8000, 0x11);
1522 TEST_BYTE(0x8400, 0x33);
1523#undef TEST_BYTE
1524#undef TEST_WRITE
1525#undef TEST_NOWRITE
1528 }
1529 Status = NtClose(SectionHandle);
1531 }
1532
1535}
1536
1538{
1547 BYTE pad[448];
1552{
1553 /* IMAGE_DOS_HEADER */
1554 {
1555 IMAGE_DOS_SIGNATURE, 144, 3, 0, 4, 0, 0xFFFF, 0, 0xB8, 0, 0, 0, 0x40,
1556 0, { 0 }, 0, 0, { 0 }, 0x80
1557 },
1558 /* binary to print "This program cannot be run in DOS mode." */
1559 {
1560 0x1F0E, 0x0EBA, 0xB400, 0xCD09, 0xB821, 0x4C01, 0x21CD, 0x6854, 0x7369,
1561 0x7020, 0x6F72, 0x7267, 0x6D61, 0x6320, 0x6E61, 0x6F6E, 0x2074, 0x6562,
1562 0x7220, 0x6E75, 0x6920, 0x206E, 0x4F44, 0x2053, 0x6F6D, 0x6564, 0x0D2E,
1563 0x0A0D, 0x0024, 0x0000, 0x0000, 0x0000
1564 },
1565 /* IMAGE_NT_HEADERS32 */
1566 {
1567 IMAGE_NT_SIGNATURE, /* Signature */
1568 /* IMAGE_FILE_HEADER */
1569 {
1570 IMAGE_FILE_MACHINE_I386, /* Machine */
1571 5, /* NumberOfSections */
1572 0x47EFDF09, /* TimeDateStamp */
1573 0, /* PointerToSymbolTable */
1574 0, /* NumberOfSymbols */
1575 0xE0, /* SizeOfOptionalHeader */
1578 IMAGE_FILE_DLL, /* Characteristics */
1579 },
1580 /* IMAGE_OPTIONAL_HEADER32 */
1581 {
1583 8, /* MajorLinkerVersion */
1584 0, /* MinorLinkerVersion */
1585 0x400, /* SizeOfCode */
1586 0x000, /* SizeOfInitializedData */
1587 0, /* SizeOfUninitializedData */
1588 0x1000, /* AddressOfEntryPoint */
1589 0x1000, /* BaseOfCode */
1590 0x0000, /* BaseOfData */
1591 0x400000, /* ImageBase */
1592 0x1000, /* SectionAlignment */
1593 0x200, /* FileAlignment */
1594 4, /* MajorOperatingSystemVersion */
1595 0, /* MinorOperatingSystemVersion */
1596 0, /* MajorImageVersion */
1597 0, /* MinorImageVersion */
1598 4, /* MajorSubsystemVersion */
1599 0, /* MinorSubsystemVersion */
1600 0, /* Win32VersionValue */
1601 0x6000, /* SizeOfImage */
1602 0x400, /* SizeOfHeaders */
1603 0x0, /* CheckSum */
1604 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
1607 IMAGE_DLLCHARACTERISTICS_NX_COMPAT, /* DllCharacteristics */
1608 0x100000, /* SizeOfStackReserve */
1609 0x1000, /* SizeOfStackCommit */
1610 0x100000, /* SizeOfHeapReserve */
1611 0x1000, /* SizeOfHeapCommit */
1612 0, /* LoaderFlags */
1613 0x10, /* NumberOfRvaAndSizes */
1614 /* IMAGE_DATA_DIRECTORY */
1615 {
1616 { 0 }, /* Export Table */
1617 { 0 }, /* Import Table */
1618 { 0 }, /* Resource Table */
1619 { 0 }, /* Exception Table */
1620 { 0 }, /* Certificate Table */
1621 { 0 }, /* Base Relocation Table */
1622 { 0 }, /* Debug */
1623 { 0 }, /* Copyright */
1624 { 0 }, /* Global Ptr */
1625 { 0 }, /* TLS Table */
1626 { 0 }, /* Load Config Table */
1627 { 0 }, /* Bound Import */
1628 { 0 }, /* IAT */
1629 { 0 }, /* Delay Import Descriptor */
1630 { 0 }, /* CLI Header */
1631 { 0 } /* Reserved */
1632 }
1633 }
1634 },
1635 /* IMAGE_SECTION_HEADER */
1636 {
1637 /* SizeOfRawData larger than VirtualSize */
1638 ".text", /* Name */
1639 { 0x1000 }, /* Misc.VirtualSize */
1640 0x1000, /* VirtualAddress */
1641 0x1200, /* SizeOfRawData */
1642 0x400, /* PointerToRawData */
1643 0, /* PointerToRelocations */
1644 0, /* PointerToLinenumbers */
1645 0, /* NumberOfRelocations */
1646 0, /* NumberOfLinenumbers */
1648 IMAGE_SCN_CNT_CODE, /* Characteristics */
1649 },
1650 /* IMAGE_SECTION_HEADER */
1651 {
1652 /* SizeOfRawData larger than VirtualSize */
1653 ".data", /* Name */
1654 { 0x100 }, /* Misc.VirtualSize */
1655 0x2000, /* VirtualAddress */
1656 0x1200, /* SizeOfRawData */
1657 0x1600, /* PointerToRawData */
1658 0, /* PointerToRelocations */
1659 0, /* PointerToLinenumbers */
1660 0, /* NumberOfRelocations */
1661 0, /* NumberOfLinenumbers */
1663 IMAGE_SCN_CNT_INITIALIZED_DATA, /* Characteristics */
1664 },
1665 /* IMAGE_SECTION_HEADER */
1666 {
1667 /* SizeOfRawData = 0 */
1668 ".zdata", /* Name */
1669 { 0x100 }, /* Misc.VirtualSize */
1670 0x3000, /* VirtualAddress */
1671 0, /* SizeOfRawData */
1672 0x2800, /* PointerToRawData */
1673 0, /* PointerToRelocations */
1674 0, /* PointerToLinenumbers */
1675 0, /* NumberOfRelocations */
1676 0, /* NumberOfLinenumbers */
1678 IMAGE_SCN_CNT_UNINITIALIZED_DATA, /* Characteristics */
1679 },
1680 /* IMAGE_SECTION_HEADER */
1681 {
1682 /* VirtualSize larger than SizeOfRawData */
1683 ".rsrc", /* Name */
1684 { 0x300 }, /* Misc.VirtualSize */
1685 0x4000, /* VirtualAddress */
1686 0x200, /* SizeOfRawData */
1687 0x2800, /* PointerToRawData */
1688 0, /* PointerToRelocations */
1689 0, /* PointerToLinenumbers */
1690 0, /* NumberOfRelocations */
1691 0, /* NumberOfLinenumbers */
1693 IMAGE_SCN_CNT_INITIALIZED_DATA, /* Characteristics */
1694 },
1695 /* IMAGE_SECTION_HEADER */
1696 {
1697 /* PointerToRawData = 0 while SizeOfRawData != 0, CORE-18797 */
1698 ".bss", /* Name */
1699 { 0x400 }, /* Misc.VirtualSize */
1700 0x5000, /* VirtualAddress */
1701 0x600, /* SizeOfRawData */
1702 0, /* PointerToRawData */
1703 0, /* PointerToRelocations */
1704 0, /* PointerToLinenumbers */
1705 0, /* NumberOfRelocations */
1706 0, /* NumberOfLinenumbers */
1708 IMAGE_SCN_CNT_UNINITIALIZED_DATA, /* Characteristics */
1709 },
1710 /* fill */
1711 { 0 },
1712 /* text */
1713 {
1714 0xc3, 0, 0, 0, 0, 0, 0, 0,
1715 BYTES8(1),
1716 BYTES16(2),
1717 BYTES32(3),
1718 BYTES64(4),
1719 BYTES128(5),
1720 BYTES256(6),
1721 BYTES512(7),
1722 BYTES1024(8),
1723 BYTES1024(9),
1724 BYTES1024(0xa),
1725 BYTES512(0xb),
1726 },
1727 /* data */
1728 {
1729 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1730 BYTES8(0xaa),
1731 BYTES16(0xbb),
1732 BYTES32(0xcc),
1733 BYTES64(0xdd),
1734 BYTES128(0xee),
1735 BYTES256(0xff),
1736 BYTES512(0xee),
1737 BYTES1024(0xdd),
1738 BYTES1024(0xcc),
1739 BYTES1024(0xbb),
1740 BYTES512(0xaa),
1741 },
1742 /* rsrc */
1743 {
1744 BYTES256(0xff),
1745 BYTES128(0xee),
1746 BYTES64(0xdd),
1747 BYTES32(0xcc),
1748 BYTES16(0xbb),
1749 BYTES8(0xaa),
1750 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01,
1751 },
1753
1754C_ASSERT(FIELD_OFFSET(struct _RAW_SIZE_IMAGE_FILE, text_data) == 0x400);
1755C_ASSERT(FIELD_OFFSET(struct _RAW_SIZE_IMAGE_FILE, data_data) == 0x1600);
1756C_ASSERT(FIELD_OFFSET(struct _RAW_SIZE_IMAGE_FILE, rsrc_data) == 0x2800);
1757
1758// CORE-17284
1759static
1760void
1762{
1764 WCHAR TempPath[MAX_PATH];
1766 HANDLE Handle;
1767 HANDLE SectionHandle;
1771 ULONG Written;
1772 ULONG Length;
1773 BOOL Success;
1774
1775 Length = GetTempPathW(MAX_PATH, TempPath);
1776 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1777 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1778 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1781 0,
1782 NULL,
1784 0,
1785 NULL);
1787 {
1788 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
1789 return;
1790 }
1791 RawSizeImageFile.nthdrs.OptionalHeader.ImageBase = 0xe400000;
1792 if (TestNumber == 1)
1793 {
1794 /* Just for fun, show that these flags don't matter. */
1799 }
1800 else if (TestNumber == 2)
1801 {
1802 /* SizeOfRawData is too large and will overflow.
1803 * This should cause failure to load the file */
1804 RawSizeImageFile.rsrc_header.SizeOfRawData = (ULONG)-0x200;
1805 }
1806
1809 sizeof(RawSizeImageFile),
1810 &Written,
1811 NULL);
1812 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
1813 ok(Written == sizeof(RawSizeImageFile), "WriteFile wrote %lu bytes\n", Written);
1814
1815 Status = NtCreateSection(&SectionHandle,
1817 NULL,
1818 NULL,
1820 SEC_IMAGE,
1821 Handle);
1822 if (TestNumber == 2)
1823 {
1824 /* overflow in SizeOfRawData */
1826 }
1827 else
1828 {
1830 }
1831
1832 if (NT_SUCCESS(Status))
1833 {
1834 /* Map the section with */
1835 BaseAddress = NULL;
1836 SectionOffset.QuadPart = 0;
1837 ViewSize = 0;
1838 Status = NtMapViewOfSection(SectionHandle,
1840 &BaseAddress,
1841 0,
1842 0,
1844 &ViewSize,
1845 ViewShare,
1846 0,
1849 if (NT_SUCCESS(Status))
1850 {
1853
1854 /* .text section header is unmodified */
1855 ok_hex(ImageFile->text_header.Misc.VirtualSize, RawSizeImageFile.text_header.Misc.VirtualSize);
1856 ok_hex(ImageFile->text_header.VirtualAddress, RawSizeImageFile.text_header.VirtualAddress);
1857 ok_hex(ImageFile->text_header.SizeOfRawData, RawSizeImageFile.text_header.SizeOfRawData);
1858 ok_hex(ImageFile->text_header.PointerToRawData, RawSizeImageFile.text_header.PointerToRawData);
1859
1860 /* SizeOfRawData = 0 resets PointerToRawData to 0 */
1861 ok_hex(ImageFile->zdata_header.Misc.VirtualSize, RawSizeImageFile.zdata_header.Misc.VirtualSize);
1862 ok_hex(ImageFile->zdata_header.VirtualAddress, RawSizeImageFile.zdata_header.VirtualAddress);
1863 ok_hex(ImageFile->zdata_header.SizeOfRawData, RawSizeImageFile.zdata_header.SizeOfRawData);
1864 ok_hex(ImageFile->zdata_header.PointerToRawData, 0);
1865
1866 /* .bss section is unmodified */
1867 ok_hex(ImageFile->bss_header.SizeOfRawData, 0x600);
1868 ok_hex(ImageFile->bss_header.PointerToRawData, 0);
1869
1870#define TEST_BYTE(n, v) \
1871 StartSeh() \
1872 ok(Bytes[n] == v, "[%lu] Bytes[%u] = 0x%x, expected 0x%x\n", \
1873 TestNumber, n, Bytes[n], v); \
1874 EndSeh(STATUS_SUCCESS);
1875 /* .text section data matches file up to 0x1000 */
1876 TEST_BYTE(0x1000, 0xc3);
1877 TEST_BYTE(0x1001, 0x00);
1878 TEST_BYTE(0x1008, 0x01);
1879 TEST_BYTE(0x1010, 0x02);
1880 TEST_BYTE(0x1fff, 0x0a);
1881
1882 /* .data section data matches file up to 0x1000 */
1883 TEST_BYTE(0x2000, 0x01);
1884 TEST_BYTE(0x2001, 0x23);
1885 TEST_BYTE(0x20ff, 0xee);
1886 TEST_BYTE(0x2100, 0xff);
1887 TEST_BYTE(0x2fff, 0xbb);
1888
1889 /* .zdata section data is all zeroes */
1890 TEST_BYTE(0x3000, 0x00);
1891 TEST_BYTE(0x3001, 0x00);
1892 TEST_BYTE(0x3800, 0x00);
1893 TEST_BYTE(0x3fff, 0x00);
1894
1895 /* .rsrc section data matches file up to VirtualSize 0x200 */
1896 TEST_BYTE(0x4000, 0xff);
1897 TEST_BYTE(0x4100, 0xee);
1898 TEST_BYTE(0x4180, 0xdd);
1899 TEST_BYTE(0x41c0, 0xcc);
1900 TEST_BYTE(0x41e0, 0xbb);
1901 TEST_BYTE(0x41f0, 0xaa);
1902 TEST_BYTE(0x41fe, 0x23);
1903 TEST_BYTE(0x41ff, 0x01);
1904 TEST_BYTE(0x4200, 0x00);
1905 TEST_BYTE(0x4fff, 0x00);
1906#undef TEST_BYTE
1909 }
1910 Status = NtClose(SectionHandle);
1912 }
1913
1916}
1917
1918static void
1920{
1922 WCHAR TempPath[MAX_PATH];
1924 HANDLE Handle;
1925 HANDLE SectionHandle;
1926 ULONG Length;
1927
1928 Length = GetTempPathW(MAX_PATH, TempPath);
1929 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1930 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1931 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1934 0,
1935 NULL,
1937 0,
1938 NULL);
1940 {
1941 skip("Failed to create temp file %ls, error %lu\n", FileName, GetLastError());
1942 return;
1943 }
1944
1945 Status = NtCreateSection(&SectionHandle,
1949
1950 if (NT_SUCCESS(Status))
1951 NtClose(SectionHandle);
1952
1953 Status = NtCreateSection(&SectionHandle,
1957
1958 if (NT_SUCCESS(Status))
1959 NtClose(SectionHandle);
1960
1963}
1964
1965// CORE-11206
1966static void
1968{
1969 WCHAR TempPath[MAX_PATH];
1972 SIZE_T ViewSize = 0;
1973 HANDLE Handle;
1974 HANDLE SectionHandle;
1975
1976 SIZE_T Length;
1977 BOOL Success;
1978 DWORD Written, Error;
1980
1981 Length = GetTempPathW(MAX_PATH, TempPath);
1982 ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
1983 Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
1984 ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
1986
1987 Success = WriteFile(Handle, "TESTDATA", 8, &Written, NULL);
1988 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
1989 ok(Written == 8, "WriteFile wrote %lu bytes\n", Written);
1990
1991 Written = SetFilePointer(Handle, 6, NULL, FILE_BEGIN);
1992 ok(Written == 6, "SetFilePointer returned %lu bytes\n", Written);
1994 ok(Success == TRUE, "SetEndOfFile failed with %lu\n", GetLastError());
1995
1996 Status = NtCreateSection(&SectionHandle,
2000 BaseAddress = NULL;
2001 ViewSize = 0;
2002 Status = NtMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0,
2003 0, 0, &ViewSize, ViewShare, 0, PAGE_READONLY);
2005
2006 if (BaseAddress)
2007 {
2008 // First we test data that was truncated even before the file mapping was opened
2009 Length = strlen((char*)BaseAddress);
2010 ok(Length == 6, "Old data was not properly erased! (Length=%lu)\n", Length);
2011 }
2012
2013 // Now we truncate the file on disk some more
2014 Written = SetFilePointer(Handle, 4, NULL, FILE_BEGIN);
2015 ok(Written == 4, "SetFilePointer returned %lu bytes\n", Written);
2017 Error = GetLastError();
2018 ok(Success == FALSE, "SetEndOfFile succeeded\n");
2019 ok(Error == ERROR_USER_MAPPED_FILE, "SetEndOfFile did not set error to ERROR_USER_MAPPED_FILE (%lu)\n", Error);
2020
2021 if (BaseAddress)
2022 {
2023 Length = strlen((char*)BaseAddress);
2024 ok(Length == 6, "Length should not have changed! (Length=%lu)\n", Length);
2025 }
2026
2027 // Unmap and set the end shorter.
2030 Success = CloseHandle(SectionHandle);
2031 ok(Success == TRUE, "CloseHandle failed with %lu\n", GetLastError());
2032
2033 Written = SetFilePointer(Handle, 4, NULL, FILE_BEGIN);
2034 ok(Written == 4, "SetFilePointer returned %lu bytes\n", Written);
2036 ok(Success == TRUE, "SetEndOfFile failed with %lu\n", GetLastError());
2037
2038 Status = NtCreateSection(&SectionHandle,
2042 BaseAddress = NULL;
2043 ViewSize = 0;
2044 Status = NtMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0,
2045 0, 0, &ViewSize, ViewShare, 0, PAGE_READONLY);
2047
2048 // CLEANUP
2051 Success = CloseHandle(SectionHandle);
2052 ok(Success == TRUE, "CloseHandle failed with %lu\n", GetLastError());
2054 ok(Success == TRUE, "CloseHandle failed with %lu\n", GetLastError());
2055
2057 ok(Success == TRUE, "DeleteFileW failed with %lu\n", GetLastError());
2058}
2059
2061{
2067 Test_RawSize(0);
2068 Test_RawSize(1);
2069 Test_RawSize(2);
2071 Test_Truncate();
2072}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3483
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:3076
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3257
#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
#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:988
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
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:1592
#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:104
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
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:106
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:362
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:407
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
#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:3953
#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:3402
#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:75
#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
#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:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#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:3576
#define ERROR_USER_MAPPED_FILE
Definition: winerror.h:1056
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193