winex11: Post internal WM_IME_NOTIFY wparam on composition updates.
[wine.git] / dlls / winecrt0 / unix_lib.c
blob5b809b6949d28932cd26a367ecc4d8bfb9e3413d
1 /*
2 * Support for the Unix part of builtin dlls
4 * Copyright 2019 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "ntstatus.h"
24 #define WIN32_NO_STATUS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winternl.h"
28 #include "wine/unixlib.h"
30 static inline void *image_base(void)
32 #ifdef __WINE_PE_BUILD
33 extern IMAGE_DOS_HEADER __ImageBase;
34 return (void *)&__ImageBase;
35 #else
36 extern IMAGE_NT_HEADERS __wine_spec_nt_header;
37 return (void *)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff);
38 #endif
41 static NTSTATUS WINAPI unix_call_fallback( unixlib_handle_t handle, unsigned int code, void *args )
43 return STATUS_DLL_NOT_FOUND;
46 unixlib_handle_t __wine_unixlib_handle = 0;
47 NTSTATUS (WINAPI *__wine_unix_call_dispatcher)( unixlib_handle_t, unsigned int, void * ) = unix_call_fallback;
49 NTSTATUS WINAPI __wine_init_unix_call(void)
51 NTSTATUS status;
52 HMODULE module = GetModuleHandleW( L"ntdll.dll" );
53 void **p__wine_unix_call_dispatcher = (void **)GetProcAddress( module, "__wine_unix_call_dispatcher" );
55 if (!p__wine_unix_call_dispatcher) return STATUS_DLL_NOT_FOUND;
56 status = NtQueryVirtualMemory( GetCurrentProcess(), image_base(), MemoryWineUnixFuncs,
57 &__wine_unixlib_handle, sizeof(__wine_unixlib_handle), NULL );
58 if (!status) __wine_unix_call_dispatcher = *p__wine_unix_call_dispatcher;
59 return status;