Alexandre Julliard : ntdll: Add a helper function to retrieve the NT headers of the main exe.
Alexandre Julliard
julliard at winehq.org
Fri Jul 10 16:30:30 CDT 2020
Module: wine
Branch: master
Commit: eccd21e38735fb08e31a4be1a8897ebe248747b4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=eccd21e38735fb08e31a4be1a8897ebe248747b4
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Jul 10 07:56:18 2020 +0200
ntdll: Add a helper function to retrieve the NT headers of the main exe.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/server.c | 2 +-
dlls/ntdll/unix/unix_private.h | 6 ++++++
dlls/ntdll/unix/virtual.c | 4 ++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 813c926cf4..4e65b0eab2 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -1454,7 +1454,7 @@ void server_init_process(void)
void CDECL server_init_process_done( void *relay )
{
PEB *peb = NtCurrentTeb()->Peb;
- IMAGE_NT_HEADERS *nt = RtlImageNtHeader( peb->ImageBaseAddress );
+ IMAGE_NT_HEADERS *nt = get_exe_nt_header();
void *entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint;
NTSTATUS status;
int suspend;
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 6090190ee0..2a73f17e10 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -264,6 +264,12 @@ static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
while (len--) *dst++ = (unsigned char)*src++;
}
+static inline IMAGE_NT_HEADERS *get_exe_nt_header(void)
+{
+ IMAGE_DOS_HEADER *module = (IMAGE_DOS_HEADER *)NtCurrentTeb()->Peb->ImageBaseAddress;
+ return (IMAGE_NT_HEADERS *)((char *)module + module->e_lfanew);
+}
+
static inline size_t ntdll_wcslen( const WCHAR *str )
{
const WCHAR *s = str;
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 868dd57055..7592234ccc 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -2728,7 +2728,7 @@ NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_si
if (!reserve_size || !commit_size)
{
- IMAGE_NT_HEADERS *nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress );
+ IMAGE_NT_HEADERS *nt = get_exe_nt_header();
if (!reserve_size) reserve_size = nt->OptionalHeader.SizeOfStackReserve;
if (!commit_size) commit_size = nt->OptionalHeader.SizeOfStackCommit;
}
@@ -3325,7 +3325,7 @@ void CDECL virtual_release_address_space(void)
*/
void CDECL virtual_set_large_address_space(void)
{
- IMAGE_NT_HEADERS *nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress );
+ IMAGE_NT_HEADERS *nt = get_exe_nt_header();
if (!(nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE)) return;
/* no large address space on win9x */
More information about the wine-cvs
mailing list