Module: wine Branch: master Commit: 526b9fc89bc3aea2e972a5541a0f09766cd773c9 URL: https://gitlab.winehq.org/wine/wine/-/commit/526b9fc89bc3aea2e972a5541a0f097...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Oct 4 15:19:12 2023 +0200
ntdll: Support relocating the main exe.
---
dlls/ntdll/loader.c | 3 ++- dlls/ntdll/unix/env.c | 2 +- dlls/ntdll/unix/loader.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 5b2f9bdce0d..cfb1e833cc6 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2041,7 +2041,8 @@ static NTSTATUS perform_relocations( void *module, IMAGE_NT_HEADERS *nt, SIZE_T if (nt->OptionalHeader.SectionAlignment < page_size) return STATUS_SUCCESS;
- if (!(nt->FileHeader.Characteristics & IMAGE_FILE_DLL) && NtCurrentTeb()->Peb->ImageBaseAddress) + if (!(nt->FileHeader.Characteristics & IMAGE_FILE_DLL) && + module != NtCurrentTeb()->Peb->ImageBaseAddress) return STATUS_SUCCESS;
relocs = &nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]; diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index feae7d4b954..80f151c4cb9 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -2116,7 +2116,7 @@ void init_startup_info(void)
status = load_main_exe( params->ImagePathName.Buffer, NULL, params->CommandLine.Buffer, machine, &image, &module ); - if (status) + if (!NT_SUCCESS(status)) { MESSAGE( "wine: failed to start %s\n", debugstr_us(¶ms->ImagePathName) ); NtTerminateProcess( GetCurrentProcess(), status ); diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 5eab3d519c8..0b83d11d373 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1743,7 +1743,7 @@ NTSTATUS load_start_exe( WCHAR **image, void **module ) wcscat( *image, startW ); init_unicode_string( &nt_name, *image ); status = find_builtin_dll( &nt_name, module, &size, &main_image_info, 0, 0, current_machine, 0, FALSE ); - if (status) + if (!NT_SUCCESS(status)) { MESSAGE( "wine: failed to load start.exe: %x\n", status ); NtTerminateProcess( GetCurrentProcess(), status );