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
26 #define WIN32_NO_STATUS
30 #include "wine/unixlib.h"
32 static NTSTATUS (__cdecl
*p__wine_init_unix_lib
)( HMODULE
, DWORD
, const void *, void * );
33 static NTSTATUS (WINAPI
*p__wine_unix_call
)( unixlib_handle_t
, unsigned int, void * );
35 static void load_func( void **func
, const char *name
, void *def
)
39 HMODULE module
= GetModuleHandleA( "ntdll.dll" );
40 void *proc
= GetProcAddress( module
, name
);
41 InterlockedExchangePointer( func
, proc
? proc
: def
);
44 #define LOAD_FUNC(name) load_func( (void **)&p ## name, #name, fallback ## name )
46 static NTSTATUS __cdecl
fallback__wine_init_unix_lib( HMODULE module
, DWORD reason
, const void *ptr_in
, void *ptr_out
)
48 return STATUS_DLL_NOT_FOUND
;
51 static NTSTATUS __cdecl
fallback__wine_unix_call( unixlib_handle_t handle
, unsigned int code
, void *args
)
53 return STATUS_DLL_NOT_FOUND
;
56 NTSTATUS __cdecl
__wine_init_unix_lib( HMODULE module
, DWORD reason
, const void *ptr_in
, void *ptr_out
)
58 LOAD_FUNC( __wine_init_unix_lib
);
59 return p__wine_init_unix_lib( module
, reason
, ptr_in
, ptr_out
);
62 NTSTATUS WINAPI
__wine_unix_call( unixlib_handle_t handle
, unsigned int code
, void *args
)
64 LOAD_FUNC( __wine_unix_call
);
65 return p__wine_unix_call( handle
, code
, args
);