Alexandre Julliard : ntdll: Force execute permission again on the stack after clearing it.
Alexandre Julliard
julliard at winehq.org
Thu Jun 26 14:50:23 CDT 2008
Module: wine
Branch: master
Commit: 58d076b419c2b5ae01fd37ebcf95da9063103687
URL: http://source.winehq.org/git/wine.git/?a=commit;h=58d076b419c2b5ae01fd37ebcf95da9063103687
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 26 21:10:57 2008 +0200
ntdll: Force execute permission again on the stack after clearing it.
---
dlls/ntdll/loader.c | 6 +-----
dlls/ntdll/ntdll_misc.h | 1 +
dlls/ntdll/virtual.c | 15 +++++++++++++++
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index c05e01f..5d47b19 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2423,11 +2423,7 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3,
status = wine_call_on_stack( attach_process_dlls, wm, NtCurrentTeb()->Tib.StackBase );
if (status != STATUS_SUCCESS) goto error;
- /* clear the stack contents before calling the main entry point, some broken apps need that */
- wine_anon_mmap( NtCurrentTeb()->Tib.StackLimit,
- (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit,
- PROT_READ | PROT_WRITE, MAP_FIXED );
-
+ virtual_clear_thread_stack();
if (nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE) VIRTUAL_UseLargeAddressSpace();
return;
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index cba9643..6f428e0 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -134,6 +134,7 @@ extern unsigned int DIR_get_drives_info( struct drive_info info[MAX_DOS_DRIVES]
/* virtual memory */
extern NTSTATUS virtual_alloc_thread_stack( void *base, SIZE_T stack_size );
+extern void virtual_clear_thread_stack(void);
extern BOOL virtual_handle_stack_fault( void *addr );
extern NTSTATUS VIRTUAL_HandleFault(LPCVOID addr);
extern void VIRTUAL_SetForceExec( BOOL enable );
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 5977300..f14085d 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1243,6 +1243,21 @@ done:
/***********************************************************************
+ * virtual_clear_thread_stack
+ *
+ * Clear the stack contents before calling the main entry point, some broken apps need that.
+ */
+void virtual_clear_thread_stack(void)
+{
+ void *stack = NtCurrentTeb()->Tib.StackLimit;
+ size_t size = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
+
+ wine_anon_mmap( stack, size, PROT_READ | PROT_WRITE, MAP_FIXED );
+ if (force_exec_prot) mprotect( stack, size, PROT_READ | PROT_WRITE | PROT_EXEC );
+}
+
+
+/***********************************************************************
* VIRTUAL_HandleFault
*/
NTSTATUS VIRTUAL_HandleFault( LPCVOID addr )
More information about the wine-cvs
mailing list