Paul Gofman : ntdll: Remove a special case for entry point not in executable section in map_image_into_view().

Alexandre Julliard julliard at winehq.org
Wed Dec 8 15:46:31 CST 2021


Module: wine
Branch: master
Commit: d2e35b04fb21ac51a02edd6d21ece1d3ac248f27
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d2e35b04fb21ac51a02edd6d21ece1d3ac248f27

Author: Paul Gofman <pgofman at codeweavers.com>
Date:   Wed Dec  8 17:29:10 2021 +0300

ntdll: Remove a special case for entry point not in executable section in map_image_into_view().

Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/loader.c | 18 +++++++++++-------
 dlls/ntdll/unix/virtual.c    |  5 -----
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 4f1b11338a6..308cf1a44a0 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -1967,12 +1967,6 @@ static void test_section_access(void)
         nt_header.OptionalHeader.FileAlignment = 0x200;
         nt_header.OptionalHeader.SizeOfImage = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + page_size;
         nt_header.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER);
-        SetLastError(0xdeadbeef);
-        ret = WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
-        SetLastError(0xdeadbeef);
-        ret = WriteFile(hfile, &nt_header.OptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
 
         section.SizeOfRawData = sizeof(section_data);
         section.PointerToRawData = nt_header.OptionalHeader.FileAlignment;
@@ -1980,6 +1974,16 @@ static void test_section_access(void)
         section.Misc.VirtualSize = section.SizeOfRawData;
         section.Characteristics = td[i].scn_file_access;
         SetLastError(0xdeadbeef);
+
+        nt_header.OptionalHeader.AddressOfEntryPoint = section.VirtualAddress;
+
+        SetLastError(0xdeadbeef);
+        ret = WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
+        ok(ret, "WriteFile error %d\n", GetLastError());
+        SetLastError(0xdeadbeef);
+        ret = WriteFile(hfile, &nt_header.OptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER), &dummy, NULL);
+        ok(ret, "WriteFile error %d\n", GetLastError());
+
         ret = WriteFile(hfile, &section, sizeof(section), &dummy, NULL);
         ok(ret, "WriteFile error %d\n", GetLastError());
 
@@ -1997,7 +2001,7 @@ static void test_section_access(void)
         CloseHandle(hfile);
 
         SetLastError(0xdeadbeef);
-        hlib = LoadLibraryA(dll_name);
+        hlib = LoadLibraryExA(dll_name, NULL, DONT_RESOLVE_DLL_REFERENCES);
         ok(hlib != 0, "LoadLibrary error %d\n", GetLastError());
 
         SetLastError(0xdeadbeef);
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 259968a890c..e496c604aa7 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -2412,11 +2412,6 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena
         if (sec->Characteristics & IMAGE_SCN_MEM_WRITE)   vprot |= VPROT_WRITECOPY;
         if (sec->Characteristics & IMAGE_SCN_MEM_EXECUTE) vprot |= VPROT_EXEC;
 
-        /* Dumb game crack lets the AOEP point into a data section. Adjust. */
-        if ((nt->OptionalHeader.AddressOfEntryPoint >= sec->VirtualAddress) &&
-            (nt->OptionalHeader.AddressOfEntryPoint < sec->VirtualAddress + size))
-            vprot |= VPROT_EXEC;
-
         if (!set_vprot( view, ptr + sec->VirtualAddress, size, vprot ) && (vprot & VPROT_EXEC))
             ERR( "failed to set %08x protection on %s section %.8s, noexec filesystem?\n",
                  sec->Characteristics, debugstr_w(filename), sec->Name );




More information about the wine-cvs mailing list