mirror of
https://github.com/reactos/reactos.git
synced 2024-07-28 15:19:09 +00:00
Jeffrey Morlan <mrnobo1024@yahoo.com>
- Wrap libwine's memory allocations, avoiding msvcrt imports in kernel32 - The cause is that libwine/debug.c uses functions (malloc, free, realloc, _strdup) which are only present in a complete CRT, creating imports from msvcrt.dll in any module that uses it, including kernel32.dll. Since kernel32 is currently importing from msvcrt, kernel32 gets DLL_PROCESS_DETACHed first, creating a problem for msvcrt's DLL_PROCESS_DETACH which, as a result of a recent bugfix, now uses kernel32 functions that depend on the resources that were freed. - Fix this by implementing those 4 functions as wrappers around the Local* APIs, in order to avoid the problematic imports. See issue #3373 for more details. svn path=/trunk/; revision=34037
This commit is contained in:
parent
b22a7f63e8
commit
a04bcca3a3
32
reactos/lib/3rdparty/libwine/debug_ros.c
vendored
Normal file
32
reactos/lib/3rdparty/libwine/debug_ros.c
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* The use of these four functions was creating unwanted imports
|
||||
* from msvcrt.dll in kernel32.dll. */
|
||||
|
||||
#define malloc libwine_malloc
|
||||
#define free libwine_free
|
||||
#define realloc libwine_realloc
|
||||
#define _strdup libwine__strdup
|
||||
|
||||
#include "debug.c"
|
||||
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
return LocalAlloc(0, size);
|
||||
}
|
||||
|
||||
void free(void *ptr)
|
||||
{
|
||||
LocalFree(ptr);
|
||||
}
|
||||
|
||||
void *realloc(void *ptr, size_t size)
|
||||
{
|
||||
if (ptr == NULL) return malloc(size);
|
||||
return LocalReAlloc(ptr, size, LMEM_MOVEABLE);
|
||||
}
|
||||
|
||||
char *_strdup(const char *str)
|
||||
{
|
||||
char *newstr = malloc(strlen(str) + 1);
|
||||
if (newstr) strcpy(newstr, str);
|
||||
return newstr;
|
||||
}
|
2
reactos/lib/3rdparty/libwine/libwine.rbuild
vendored
2
reactos/lib/3rdparty/libwine/libwine.rbuild
vendored
|
@ -3,6 +3,6 @@
|
|||
<module name="wine" type="staticlibrary">
|
||||
<define name="_DISABLE_TIDENTS" />
|
||||
<file>config.c</file>
|
||||
<file>debug.c</file>
|
||||
<file>debug_ros.c</file>
|
||||
<file>string.c</file>
|
||||
</module>
|
||||
|
|
Loading…
Reference in a new issue