And call it from kernel32 to get access to kernelbase global data.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/heap.c | 5 +++++ dlls/kernel32/kernel_main.c | 1 + dlls/kernel32/kernel_private.h | 11 +++++++++++ dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/memory.c | 20 ++++++++++++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c index 36353c82b90..cf8af2bd0c6 100644 --- a/dlls/kernel32/heap.c +++ b/dlls/kernel32/heap.c @@ -33,6 +33,9 @@ #include "winerror.h" #include "winnt.h" #include "winternl.h" + +#include "kernel_private.h" + #include "wine/exception.h" #include "wine/debug.h"
@@ -156,6 +159,8 @@ struct mem_entry
#include "poppack.h"
+struct kernelbase_global_data *kernelbase_global_data; + #define MAGIC_LOCAL_USED 0x5342 #define POINTER_TO_HANDLE( p ) (*(((const HGLOBAL *)( p )) - 2)) /* align the storage needed for the HLOCAL on an 8-byte boundary thus diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c index 352a873933f..7b45db73257 100644 --- a/dlls/kernel32/kernel_main.c +++ b/dlls/kernel32/kernel_main.c @@ -123,6 +123,7 @@ static BOOL process_attach( HMODULE module ) RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter );
NtQuerySystemInformation( SystemBasicInformation, &system_info, sizeof(system_info), NULL ); + kernelbase_global_data = KernelBaseGetGlobalData();
copy_startup_info();
diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h index 633511d6140..980a12b25a6 100644 --- a/dlls/kernel32/kernel_private.h +++ b/dlls/kernel32/kernel_private.h @@ -21,6 +21,17 @@ #ifndef __WINE_KERNEL_PRIVATE_H #define __WINE_KERNEL_PRIVATE_H
+/* not compatible with windows */ +struct kernelbase_global_data +{ + struct mem_entry *mem_entries; + struct mem_entry *mem_entries_end; +}; + +void *WINAPI KernelBaseGetGlobalData(void); + +extern struct kernelbase_global_data *kernelbase_global_data; + NTSTATUS WINAPI BaseGetNamedObjectDirectory( HANDLE *dir );
static inline BOOL set_ntstatus( NTSTATUS status ) diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index a59d8581ff0..b5116ae9b5a 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -943,7 +943,7 @@ @ stdcall K32InitializeProcessForWsWatch(long) InitializeProcessForWsWatch @ stdcall K32QueryWorkingSet(long ptr long) QueryWorkingSet @ stdcall K32QueryWorkingSetEx(long ptr long) QueryWorkingSetEx -@ stub KernelBaseGetGlobalData +@ stdcall KernelBaseGetGlobalData() @ stdcall LCIDToLocaleName(long ptr long long) @ stdcall LCMapStringA(long long str long ptr long) @ stdcall LCMapStringEx(wstr long wstr long ptr long ptr ptr long) diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index e81d38564e7..6d42316760b 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -578,6 +578,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH HeapWalk( HANDLE heap, PROCESS_HEAP_ENTRY *entry ) * Global/local heap functions ***********************************************************************/
+/* not compatible with windows */ +struct kernelbase_global_data +{ + struct mem_entry *mem_entries; + struct mem_entry *mem_entries_end; +}; + #include "pshpack1.h"
struct mem_entry @@ -590,6 +597,8 @@ struct mem_entry
#include "poppack.h"
+static struct kernelbase_global_data kernelbase_global_data = {0}; + #define MAGIC_LOCAL_USED 0x5342 /* align the storage needed for the HLOCAL on an 8-byte boundary thus * LocalAlloc/LocalReAlloc'ing with LMEM_MOVEABLE of memory with @@ -617,6 +626,17 @@ static inline void *unsafe_ptr_from_HLOCAL( HLOCAL handle ) return handle; }
+ +/*********************************************************************** + * KernelBaseGetGlobalData (kernelbase.@) + */ +void *WINAPI KernelBaseGetGlobalData(void) +{ + WARN_(globalmem)( "semi-stub!\n" ); + return &kernelbase_global_data; +} + + /*********************************************************************** * GlobalAlloc (kernelbase.@) */