mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 04:34:48 +00:00
winecrt0: Call __wine_unix_call through an explicit pointer in the helper macro.
This commit is contained in:
parent
12a129586b
commit
7c0b3a408c
|
@ -27,34 +27,6 @@
|
||||||
#include "winternl.h"
|
#include "winternl.h"
|
||||||
#include "wine/unixlib.h"
|
#include "wine/unixlib.h"
|
||||||
|
|
||||||
#ifdef __WINE_PE_BUILD
|
|
||||||
|
|
||||||
static NTSTATUS (WINAPI *p__wine_unix_call)( unixlib_handle_t, unsigned int, void * );
|
|
||||||
|
|
||||||
static void load_func( void **func, const char *name, void *def )
|
|
||||||
{
|
|
||||||
if (!*func)
|
|
||||||
{
|
|
||||||
HMODULE module = GetModuleHandleW( L"ntdll.dll" );
|
|
||||||
void *proc = GetProcAddress( module, name );
|
|
||||||
InterlockedExchangePointer( func, proc ? proc : def );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#define LOAD_FUNC(name) load_func( (void **)&p ## name, #name, fallback ## name )
|
|
||||||
|
|
||||||
static NTSTATUS __cdecl fallback__wine_unix_call( unixlib_handle_t handle, unsigned int code, void *args )
|
|
||||||
{
|
|
||||||
return STATUS_DLL_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS WINAPI __wine_unix_call( unixlib_handle_t handle, unsigned int code, void *args )
|
|
||||||
{
|
|
||||||
LOAD_FUNC( __wine_unix_call );
|
|
||||||
return p__wine_unix_call( handle, code, args );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __WINE_PE_BUILD */
|
|
||||||
|
|
||||||
static inline void *image_base(void)
|
static inline void *image_base(void)
|
||||||
{
|
{
|
||||||
#ifdef __WINE_PE_BUILD
|
#ifdef __WINE_PE_BUILD
|
||||||
|
@ -66,10 +38,23 @@ static inline void *image_base(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NTSTATUS WINAPI unix_call_fallback( unixlib_handle_t handle, unsigned int code, void *args )
|
||||||
|
{
|
||||||
|
return STATUS_DLL_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
unixlib_handle_t __wine_unixlib_handle = 0;
|
unixlib_handle_t __wine_unixlib_handle = 0;
|
||||||
|
NTSTATUS (WINAPI *__wine_unix_call_ptr)( unixlib_handle_t, unsigned int, void * ) = unix_call_fallback;
|
||||||
|
|
||||||
NTSTATUS WINAPI __wine_init_unix_call(void)
|
NTSTATUS WINAPI __wine_init_unix_call(void)
|
||||||
{
|
{
|
||||||
return NtQueryVirtualMemory( GetCurrentProcess(), image_base(), MemoryWineUnixFuncs,
|
NTSTATUS status;
|
||||||
&__wine_unixlib_handle, sizeof(__wine_unixlib_handle), NULL );
|
HMODULE module = GetModuleHandleW( L"ntdll.dll" );
|
||||||
|
void *proc = GetProcAddress( module, "__wine_unix_call" );
|
||||||
|
|
||||||
|
if (!proc) return STATUS_DLL_NOT_FOUND;
|
||||||
|
status = NtQueryVirtualMemory( GetCurrentProcess(), image_base(), MemoryWineUnixFuncs,
|
||||||
|
&__wine_unixlib_handle, sizeof(__wine_unixlib_handle), NULL );
|
||||||
|
if (!status) __wine_unix_call_ptr = proc;
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
||||||
DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
|
DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
|
||||||
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_GPU_VULKAN_UUID, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5c, 2);
|
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_GPU_VULKAN_UUID, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5c, 2);
|
||||||
|
|
||||||
NTSTATUS (WINAPI *p_vk_direct_unix_call)(unixlib_handle_t handle, unsigned int code, void *args) = __wine_unix_call;
|
NTSTATUS (WINAPI *p_vk_direct_unix_call)(unixlib_handle_t handle, unsigned int code, void *args) = NULL;
|
||||||
|
|
||||||
static HINSTANCE hinstance;
|
static HINSTANCE hinstance;
|
||||||
|
|
||||||
|
@ -234,9 +234,10 @@ VkResult WINAPI vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supported_ver
|
||||||
|
|
||||||
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
|
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
|
||||||
{
|
{
|
||||||
if (__wine_init_unix_call())
|
NTSTATUS status = __wine_init_unix_call();
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
|
p_vk_direct_unix_call = __wine_unix_call_ptr;
|
||||||
|
if (status) return FALSE;
|
||||||
return !vk_unix_call(unix_init, &p_vk_direct_unix_call);
|
return !vk_unix_call(unix_init, &p_vk_direct_unix_call);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,9 +268,10 @@ static inline ULONG ntdll_wcstoul( const WCHAR *s, WCHAR **end, int base )
|
||||||
#else /* WINE_UNIX_LIB */
|
#else /* WINE_UNIX_LIB */
|
||||||
|
|
||||||
extern unixlib_handle_t __wine_unixlib_handle DECLSPEC_HIDDEN;
|
extern unixlib_handle_t __wine_unixlib_handle DECLSPEC_HIDDEN;
|
||||||
|
extern NTSTATUS (WINAPI *__wine_unix_call_ptr)( unixlib_handle_t, unsigned int, void * ) DECLSPEC_HIDDEN;
|
||||||
extern NTSTATUS WINAPI __wine_init_unix_call(void) DECLSPEC_HIDDEN;
|
extern NTSTATUS WINAPI __wine_init_unix_call(void) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
#define WINE_UNIX_CALL(code,args) __wine_unix_call( __wine_unixlib_handle, (code), (args) )
|
#define WINE_UNIX_CALL(code,args) __wine_unix_call_ptr( __wine_unixlib_handle, (code), (args) )
|
||||||
|
|
||||||
#endif /* WINE_UNIX_LIB */
|
#endif /* WINE_UNIX_LIB */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue