189 ok(
FALSE,
"Got an exception\n");
482 ok(*(
PULONG)BaseAddress2 == 2,
"Value in memory was wrong\n");
528 "got wrong Status: 0x%lx\n",
Status);
572 "got wrong Status: 0x%lx\n",
Status);
595 "got wrong Status: 0x%lx\n",
Status);
628 (
void)(*(
volatile char*)BaseAddress2);
644 ok(OldProtect == 0,
"Wrong protection returned: 0x%lx\n", OldProtect);
666 ok(BaseAddress2 ==
BaseAddress,
"Invalid base address: %p\n", BaseAddress2);
673 ok(BaseAddress2 ==
BaseAddress,
"Invalid base address: %p\n", BaseAddress2);
679 (
void)(*(
volatile char*)BaseAddress2);
692 *(
char*)BaseAddress2 = 1;
711 *(
char*)BaseAddress2 = 1;
741 PVOID DataBase, ImageBase;
746 StringCbCatW(TestDllPath,
sizeof(TestDllPath),
L"testdata\\test.dll");
752 ok(0,
"RtlDosPathNameToNtPathName_U failed\n");
786 skip(
"Failed to create data section\n");
808 skip(
"Failed to map view of data section\n");
815 ok(*(
ULONG*)DataBase == 0x00905a4d,
"Header not ok\n");
818 *(
ULONG*)DataBase = 0xdeadbabe;
819 ok(*(
ULONG*)DataBase == 0xdeadbabe,
"Header not ok\n");
823 "Data in .data section invalid: 0x%lx!\n", *(
ULONG*)((
PUCHAR)DataBase + 0x800));
838 *(
ULONG*)DataBase = 0x00905a4d;
855 skip(
"Failed to create image section\n");
881 skip(
"Failed to map view of image section\n");
889 ok(*(
ULONG*)DataBase == 0x00905a4d,
"Header not ok\n");
890 ok(*(
ULONG*)ImageBase == 0x00905a4d,
"Header not ok\n");
894 (*(
ULONG*)((
PUCHAR)ImageBase + 0x80000) == 0x12345678),
895 "Wrong value in data section: 0x%lx!\n", *(
ULONG*)((
PUCHAR)ImageBase + 0x80000));
898 *(
ULONG*)DataBase = 0xdeadbabe;
902 ok(*(
ULONG*)DataBase == 0xdeadbabe,
"Header not ok\n");
903 ok(*(
ULONG*)ImageBase == 0x00905a4d,
"Data should not be synced!\n");
905 (*(
ULONG*)((
PUCHAR)ImageBase + 0x80000) == 0x12345678),
906 "Wrong value in data section: 0x%lx!\n", *(
ULONG*)((
PUCHAR)ImageBase + 0x80000));
917 ok(*(
ULONG*)ImageBase == 0x00905a4d,
"Data should not be synced!\n");
919 (*(
ULONG*)((
PUCHAR)ImageBase + 0x80000) == 0x12345678),
920 "Wrong value in data section: 0x%lx!\n", *(
ULONG*)((
PUCHAR)ImageBase + 0x80000));
923 *(
ULONG*)DataBase = 0x00905a4d;
924 ok(*(
ULONG*)DataBase == 0x00905a4d,
"Header not ok\n");
941 skip(
"Failed to create image section\n");
967 skip(
"Failed to map view of image section\n");
988 DataBase = (
PUCHAR)ImageBase + 0x20000;
1016 ok(0,
"RtlDosPathNameToNtPathName_U failed\n");
1046 printf(
"Created image section with handle %p\n", ImageSectionHandle);
1065 printf(
"Mapped image section at %p, value in text section: %lx\n",
1066 ImageBase, *((
ULONG*)((
PCHAR)ImageBase + 0x1196)));
1088 HANDLE SectionHandle1, SectionHandle2;
1090 PVOID BaseAddress1, BaseAddress2;
1105 BaseAddress1 =
NULL;
1136 BaseAddress2 =
NULL;
1154 "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
1156 "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
1160#define BYTES4(x) x, x, x, x
1161#define BYTES8(x) BYTES4(x), BYTES4(x)
1162#define BYTES16(x) BYTES8(x), BYTES8(x)
1163#define BYTES32(x) BYTES16(x), BYTES16(x)
1164#define BYTES64(x) BYTES32(x), BYTES32(x)
1165#define BYTES128(x) BYTES64(x), BYTES64(x)
1166#define BYTES256(x) BYTES128(x), BYTES128(x)
1167#define BYTES512(x) BYTES256(x), BYTES256(x)
1168#define BYTES1024(x) BYTES512(x), BYTES512(x)
1188 IMAGE_DOS_SIGNATURE, 144, 3, 0, 4, 0, 0xFFFF, 0, 0xB8, 0, 0, 0, 0x40,
1189 0, { 0 }, 0, 0, { 0 }, 0x80
1193 0x1F0E, 0x0EBA, 0xB400, 0xCD09, 0xB821, 0x4C01, 0x21CD, 0x6854, 0x7369,
1194 0x7020, 0x6F72, 0x7267, 0x6D61, 0x6320, 0x6E61, 0x6F6E, 0x2074, 0x6562,
1195 0x7220, 0x6E75, 0x6920, 0x206E, 0x4F44, 0x2053, 0x6F6D, 0x6564, 0x0D2E,
1196 0x0A0D, 0x0024, 0x0000, 0x0000, 0x0000
1331 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1450#define TEST_BYTE(n, v) StartSeh() ok_hex(Bytes[n], v); EndSeh(STATUS_SUCCESS);
1451#define TEST_WRITE(n) StartSeh() *(volatile UCHAR *)&Bytes[n] = Bytes[n]; EndSeh(STATUS_SUCCESS);
1452#define TEST_NOWRITE(n) StartSeh() *(volatile UCHAR *)&Bytes[n] = Bytes[n]; EndSeh(STATUS_ACCESS_VIOLATION);
1510 IMAGE_DOS_SIGNATURE, 144, 3, 0, 4, 0, 0xFFFF, 0, 0xB8, 0, 0, 0, 0x40,
1511 0, { 0 }, 0, 0, { 0 }, 0x80
1515 0x1F0E, 0x0EBA, 0xB400, 0xCD09, 0xB821, 0x4C01, 0x21CD, 0x6854, 0x7369,
1516 0x7020, 0x6F72, 0x7267, 0x6D61, 0x6320, 0x6E61, 0x6F6E, 0x2074, 0x6562,
1517 0x7220, 0x6E75, 0x6920, 0x206E, 0x4F44, 0x2053, 0x6F6D, 0x6564, 0x0D2E,
1518 0x0A0D, 0x0024, 0x0000, 0x0000, 0x0000
1669 0xc3, 0, 0, 0, 0, 0, 0, 0,
1684 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1705 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01,
1747 if (TestNumber == 1)
1755 else if (TestNumber == 2)
1777 if (TestNumber == 2)
1825#define TEST_BYTE(n, v) \
1827 ok(Bytes[n] == v, "[%lu] Bytes[%u] = 0x%x, expected 0x%x\n", \
1828 TestNumber, n, Bytes[n], v); \
1829 EndSeh(STATUS_SUCCESS);
1944 ok(Written == 8,
"WriteFile wrote %lu bytes\n", Written);
1947 ok(Written == 6,
"SetFilePointer returned %lu bytes\n", Written);
1965 ok(
Length == 6,
"Old data was not properly erased! (Length=%lu)\n",
Length);
1970 ok(Written == 4,
"SetFilePointer returned %lu bytes\n", Written);
1979 ok(
Length == 6,
"Length should not have changed! (Length=%lu)\n",
Length);
1989 ok(Written == 4,
"SetFilePointer returned %lu bytes\n", Written);
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
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)
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)
void Test_ImageSection2(void)
static void Test_SectionContents(BOOL Relocate)
void Test_PageFileSection(void)
void Test_ImageSection(void)
static void Test_EmptyFile(VOID)
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)
ACPI_SIZE strlen(const char *String)
#define ok_hex(expression, result)
#define ok_ntstatus(status, expected)
#define NT_SUCCESS(StatCode)
#define INVALID_HANDLE_VALUE
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
BOOL WINAPI SetEndOfFile(HANDLE hFile)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
struct _FileName FileName
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
#define EXCEPTION_EXECUTE_HANDLER
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR ZeroBits
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
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)
#define SECTION_ALL_ACCESS
#define NtCurrentProcess()
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define PAGE_EXECUTE_READWRITE
#define STANDARD_RIGHTS_REQUIRED
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IMAGE_SCN_MEM_WRITE
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT
#define IMAGE_SCN_CNT_INITIALIZED_DATA
#define IMAGE_SCN_CNT_CODE
#define IMAGE_SCN_MEM_EXECUTE
#define IMAGE_DLLCHARACTERISTICS_NO_SEH
#define IMAGE_SCN_MEM_READ
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA
#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
NTSTATUS NTAPI NtFlushVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToFlush, OUT PIO_STATUS_BLOCK IoStatusBlock)
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)
#define STATUS_INVALID_VIEW_SIZE
#define STATUS_MAPPED_ALIGNMENT
#define STATUS_SECTION_PROTECTION
#define STATUS_UNABLE_TO_DELETE_SECTION
#define STATUS_INVALID_IMAGE_FORMAT
#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH
#define STATUS_INVALID_PARAMETER_9
#define STATUS_INVALID_PARAMETER_4
#define STATUS_INVALID_IMAGE_NOT_MZ
#define STATUS_INVALID_FILE_FOR_SECTION
#define STATUS_ACCESS_VIOLATION
#define STATUS_MAPPED_FILE_SIZE_ZERO
#define STATUS_CONFLICTING_ADDRESSES
#define STATUS_INVALID_PAGE_PROTECTION
#define STATUS_SECTION_TOO_BIG
#define STATUS_INVALID_PARAMETER_3
#define STATUS_IMAGE_NOT_AT_BASE
#define STATUS_COMMITMENT_LIMIT
#define IMAGE_SCN_TYPE_NOLOAD
#define IMAGE_FILE_EXECUTABLE_IMAGE
#define IMAGE_FILE_MACHINE_I386
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED
#define IMAGE_NT_SIGNATURE
#define IMAGE_FILE_LINE_NUMS_STRIPPED
#define IMAGE_DOS_SIGNATURE
#define IMAGE_FILE_32BIT_MACHINE
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
int __cdecl system(_In_opt_z_ const char *_Command)
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
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 clc_header
IMAGE_SECTION_HEADER text_header
IMAGE_NT_HEADERS32 nthdrs
IMAGE_SECTION_HEADER rsrc_header
#define FIELD_OFFSET(t, f)
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PWDFDEVICE_INIT _In_ PWDF_FILEOBJECT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES FileObjectAttributes
DWORD WINAPI GetLastError(void)
#define ERROR_USER_MAPPED_FILE