Changed memory management functions in CreateRemoteThread/THREAD_Start
Alexander Yaworsky
yaworsky at migusoft.ru
Wed Sep 22 03:46:19 CDT 2004
Hello
ChangeLog:
Changed memory management functions in CreateRemoteThread/THREAD_Start
Index: dlls/kernel/thread.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/thread.c,v
retrieving revision 1.20
diff -u -r1.20 thread.c
--- dlls/kernel/thread.c 22 Sep 2004 02:54:13 -0000 1.20
+++ dlls/kernel/thread.c 22 Sep 2004 08:13:24 -0000
@@ -96,7 +96,7 @@
LPTHREAD_START_ROUTINE func = info->func;
void *arg = info->arg;
- RtlFreeHeap( GetProcessHeap(), 0, info );
+ VirtualFree( info, 0, MEM_RELEASE );
if (TRACE_ON(relay))
DPRINTF("%04lx:Starting thread (entryproc=%p)\n", GetCurrentThreadId(), func );
@@ -138,8 +138,6 @@
* Failure: NULL. Use GetLastError() to find the error cause.
*
* BUGS
- * Improper memory allocation: there's no ability to free new_thread_info
- * in other process.
* Bad start address for RtlCreateUserThread because the library
* may be loaded at different address in other process.
*/
@@ -153,13 +151,21 @@
SIZE_T stack_reserve = 0, stack_commit = 0;
struct new_thread_info *info;
- if (!(info = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*info) )))
+ if (!(info = VirtualAllocEx( hProcess, NULL, sizeof(*info),
+ MEM_COMMIT, PAGE_READWRITE )))
+ return 0;
+
+ if( GetProcessId( hProcess ) == GetCurrentProcessId() )
+ {
+ info->func = start;
+ info->arg = param;
+ }
+ else
{
- SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+ ERR("Unsupported on other process\n");
+ VirtualFreeEx( hProcess, info, 0, MEM_RELEASE );
return 0;
}
- info->func = start;
- info->arg = param;
if (flags & STACK_SIZE_PARAM_IS_A_RESERVATION) stack_reserve = stack;
else stack_commit = stack;
@@ -175,7 +181,7 @@
}
else
{
- RtlFreeHeap( GetProcessHeap(), 0, info );
+ VirtualFreeEx( hProcess, info, 0, MEM_RELEASE );
SetLastError( RtlNtStatusToDosError(status) );
handle = 0;
}
More information about the wine-patches
mailing list