.pragma list(push, 0)
ifndef _APISETLIBLOADER_
define _APISETLIBLOADER_

include apiset.inc
include apisetcconv.inc
include minwindef.inc
include minwinbase.inc

define  FIND_RESOURCE_DIRECTORY_TYPES       (0x0100)
define  FIND_RESOURCE_DIRECTORY_NAMES       (0x0200)
define  FIND_RESOURCE_DIRECTORY_LANGUAGES   (0x0400)

define  RESOURCE_ENUM_LN               (0x0001)
define  RESOURCE_ENUM_MUI              (0x0002)
define  RESOURCE_ENUM_MUI_SYSTEM       (0x0004)
define  RESOURCE_ENUM_VALIDATE         (0x0008)
define  RESOURCE_ENUM_MODULE_EXACT     (0x0010)

define SUPPORT_LANG_NUMBER  32

tagENUMUILANG           struct
NumOfEnumUILang         ULONG ?
SizeOfEnumUIBuffer      ULONG ?
pEnumUIBuffer           ptr LANGID ?
tagENUMUILANG           ends
ENUMUILANG              typedef tagENUMUILANG
PENUMUILANG             typedef ptr tagENUMUILANG

ifdef STRICT

CALLBACK(ENUMRESLANGPROCA, :HMODULE, :LPCSTR, :LPCSTR, :WORD, :LONG_PTR)
CALLBACK(ENUMRESLANGPROCW, :HMODULE, :LPCWSTR, :LPCWSTR, :WORD, :LONG_PTR)
ifdef _UNICODE
define ENUMRESLANGPROC  <ENUMRESLANGPROCW>
else
define ENUMRESLANGPROC  <ENUMRESLANGPROCA>
endif

CALLBACK(ENUMRESNAMEPROCA, :HMODULE, :LPCSTR, :LPSTR, :LONG_PTR)
CALLBACK(ENUMRESNAMEPROCW, :HMODULE, :LPCWSTR, :LPWSTR, :LONG_PTR)
ifdef _UNICODE
define ENUMRESNAMEPROC  <ENUMRESNAMEPROCW>
else
define ENUMRESNAMEPROC  <ENUMRESNAMEPROCA>
endif

CALLBACK(ENUMRESTYPEPROCA, :HMODULE, :LPSTR, :LONG_PTR)
CALLBACK(ENUMRESTYPEPROCW, :HMODULE, :LPWSTR, :LONG_PTR)
ifdef _UNICODE
define ENUMRESTYPEPROC  <ENUMRESTYPEPROCW>
else
define ENUMRESTYPEPROC  <ENUMRESTYPEPROCA>
endif

else

ENUMRESTYPEPROCA        typedef FARPROC
ENUMRESTYPEPROCW        typedef FARPROC
ifdef _UNICODE
ENUMRESTYPEPROC         typedef ENUMRESTYPEPROCW
else
ENUMRESTYPEPROC         typedef ENUMRESTYPEPROCA
endif
ENUMRESNAMEPROCA        typedef FARPROC
ENUMRESNAMEPROCW        typedef FARPROC
ifdef _UNICODE
ENUMRESNAMEPROC         typedef ENUMRESNAMEPROCW
else
ENUMRESNAMEPROC         typedef ENUMRESNAMEPROCA
endif
ENUMRESLANGPROCA        typedef FARPROC
ENUMRESLANGPROCW        typedef FARPROC
ifdef _UNICODE
ENUMRESLANGPROC         typedef ENUMRESLANGPROCW
else
ENUMRESLANGPROC         typedef ENUMRESLANGPROCA
endif

endif

DisableThreadLibraryCalls proto WINAPI :HMODULE

FindResourceExW proto WINAPI :HMODULE, :LPCWSTR, :LPCWSTR, :DWORD ; WORD
ifdef _UNICODE
define FindResourceEx  <FindResourceExW>
endif

if (_WIN32_WINNT ge _WIN32_WINNT_WIN7)
FindStringOrdinal proto WINAPI :DWORD, :LPCWSTR, :sdword, :LPCWSTR, :sdword, :BOOL
endif

FreeLibrary proto WINAPI :HMODULE
FreeLibraryAndExitThread proto WINAPI :HMODULE, :DWORD

FreeResource proto WINAPI :HGLOBAL

GetModuleFileNameA proto WINAPI :HMODULE, :LPSTR, :DWORD
GetModuleFileNameW proto WINAPI :HMODULE, :LPWSTR, :DWORD
ifdef _UNICODE
define GetModuleFileName  <GetModuleFileNameW>
else
define GetModuleFileName  <GetModuleFileNameA>
endif

GetModuleHandleA proto WINAPI :LPCSTR
GetModuleHandleW proto WINAPI :LPCWSTR
ifdef _UNICODE
define GetModuleHandle  <GetModuleHandleW>
else
define GetModuleHandle  <GetModuleHandleA>
endif

ifndef RC_INVOKED

define GET_MODULE_HANDLE_EX_FLAG_PIN                 (0x00000001)
define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT  (0x00000002)
define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS        (0x00000004)

CALLBACK(PGET_MODULE_HANDLE_EXA, :DWORD, :LPCSTR, :ptr)
CALLBACK(PGET_MODULE_HANDLE_EXW, :DWORD, :LPCWSTR, :ptr)
ifdef _UNICODE
define PGET_MODULE_HANDLE_EX  <PGET_MODULE_HANDLE_EXW>
else
define PGET_MODULE_HANDLE_EX  <PGET_MODULE_HANDLE_EXA>
endif

GetModuleHandleExA proto WINAPI :DWORD, :LPCSTR, :ptr
GetModuleHandleExW proto WINAPI :DWORD, :LPCWSTR, :ptr
ifdef _UNICODE
define GetModuleHandleEx  <GetModuleHandleExW>
else
define GetModuleHandleEx  <GetModuleHandleExA>
endif

endif

GetProcAddress proto WINAPI :HMODULE, :LPCSTR

define CURRENT_IMPORT_REDIRECTION_VERSION      1

_REDIRECTION_FUNCTION_DESCRIPTOR struct
DllName                 PCSTR ?
FunctionName            PCSTR ?
RedirectionTarget       PVOID ?
_REDIRECTION_FUNCTION_DESCRIPTOR ends
REDIRECTION_FUNCTION_DESCRIPTOR typedef _REDIRECTION_FUNCTION_DESCRIPTOR
PREDIRECTION_FUNCTION_DESCRIPTOR typedef ptr _REDIRECTION_FUNCTION_DESCRIPTOR

PCREDIRECTION_FUNCTION_DESCRIPTOR typedef ptr REDIRECTION_FUNCTION_DESCRIPTOR

_REDIRECTION_DESCRIPTOR struct
Version                 ULONG ?
FunctionCount           ULONG ?
Redirections            PCREDIRECTION_FUNCTION_DESCRIPTOR ?
_REDIRECTION_DESCRIPTOR ends
REDIRECTION_DESCRIPTOR  typedef _REDIRECTION_DESCRIPTOR
PREDIRECTION_DESCRIPTOR typedef ptr _REDIRECTION_DESCRIPTOR

PCREDIRECTION_DESCRIPTOR typedef ptr REDIRECTION_DESCRIPTOR

LoadLibraryExA proto WINAPI :LPCSTR, :HANDLE, :DWORD
LoadLibraryExW proto WINAPI :LPCWSTR, :HANDLE, :DWORD
ifdef _UNICODE
define LoadLibraryEx  <LoadLibraryExW>
else
define LoadLibraryEx  <LoadLibraryExA>
endif

define DONT_RESOLVE_DLL_REFERENCES         0x00000001
define LOAD_LIBRARY_AS_DATAFILE            0x00000002
define LOAD_WITH_ALTERED_SEARCH_PATH       0x00000008
define LOAD_IGNORE_CODE_AUTHZ_LEVEL        0x00000010
define LOAD_LIBRARY_AS_IMAGE_RESOURCE      0x00000020
define LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE  0x00000040
define LOAD_LIBRARY_REQUIRE_SIGNED_TARGET  0x00000080
define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR    0x00000100
define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
define LOAD_LIBRARY_SEARCH_USER_DIRS       0x00000400
define LOAD_LIBRARY_SEARCH_SYSTEM32        0x00000800
define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS    0x00001000

if (NTDDI_VERSION ge NTDDI_WIN10_RS1)
define LOAD_LIBRARY_SAFE_CURRENT_DIRS      0x00002000
define LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER   0x00004000
else
define LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER   LOAD_LIBRARY_SEARCH_SYSTEM32
endif

if (NTDDI_VERSION ge NTDDI_WIN10_RS2)
define LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY   0x00008000
endif

LoadResource proto WINAPI :HMODULE, :HRSRC

LoadStringA proto WINAPI :HINSTANCE, :UINT, :LPSTR, :sdword
LoadStringW proto WINAPI :HINSTANCE, :UINT, :LPWSTR, :sdword
ifdef _UNICODE
define LoadString  <LoadStringW>
else
define LoadString  <LoadStringA>
endif

LockResource proto WINAPI :HGLOBAL
SizeofResource proto WINAPI :HMODULE, :HRSRC

PDLL_DIRECTORY_COOKIE   typedef ptr DLL_DIRECTORY_COOKIE

AddDllDirectory proto WINAPI :PCWSTR
RemoveDllDirectory proto WINAPI :DLL_DIRECTORY_COOKIE
SetDefaultDllDirectories proto WINAPI :DWORD

if (_WIN32_WINNT ge _WIN32_WINNT_VISTA)

EnumResourceLanguagesExA proto WINAPI :HMODULE, :LPCSTR, :LPCSTR, :ENUMRESLANGPROCA, :LONG_PTR, :DWORD, :LANGID
EnumResourceLanguagesExW proto WINAPI :HMODULE, :LPCWSTR, :LPCWSTR, :ENUMRESLANGPROCW, :LONG_PTR, :DWORD, :LANGID
ifdef _UNICODE
define EnumResourceLanguagesEx  <EnumResourceLanguagesExW>
else
define EnumResourceLanguagesEx  <EnumResourceLanguagesExA>
endif

EnumResourceNamesExA proto WINAPI :HMODULE, :LPCSTR, :ENUMRESNAMEPROCA, :LONG_PTR, :DWORD, :LANGID
EnumResourceNamesExW proto WINAPI :HMODULE, :LPCWSTR, :ENUMRESNAMEPROCW, :LONG_PTR, :DWORD, :LANGID
ifdef _UNICODE
define EnumResourceNamesEx  <EnumResourceNamesExW>
else
define EnumResourceNamesEx  <EnumResourceNamesExA>
endif

EnumResourceTypesExA proto WINAPI :HMODULE, :ENUMRESTYPEPROCA, :LONG_PTR, :DWORD, :LANGID
EnumResourceTypesExW proto WINAPI :HMODULE, :ENUMRESTYPEPROCW, :LONG_PTR, :DWORD, :LANGID
ifdef _UNICODE
define EnumResourceTypesEx  <EnumResourceTypesExW>
else
define EnumResourceTypesEx  <EnumResourceTypesExA>
endif

endif

FindResourceW proto WINAPI :HMODULE, :LPCWSTR, :LPCWSTR
ifdef _UNICODE
define FindResource  <FindResourceW>
endif

LoadLibraryA proto WINAPI :LPCSTR
LoadLibraryW proto WINAPI :LPCWSTR
ifdef _UNICODE
define LoadLibrary  <LoadLibraryW>
else
define LoadLibrary  <LoadLibraryA>
endif

EnumResourceNamesW proto WINAPI :HMODULE, :LPCWSTR, :ENUMRESNAMEPROCW, :LONG_PTR
ifdef _UNICODE
define EnumResourceNames  <EnumResourceNamesW>
endif

endif
.pragma list(pop)
