ReactOS 0.4.16-dev-1453-g06343fa
loader.c File Reference
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "ddk/ntddk.h"
#include "kernelbase.h"
#include "wine/list.h"
#include "wine/asm.h"
#include "wine/debug.h"
#include "wine/exception.h"
Include dependency graph for loader.c:

Go to the source code of this file.

Classes

struct  exclusive_datafile
 

Macros

#define WIN32_NO_STATUS
 
#define IS_INTRESOURCE(x)   (((ULONG_PTR)(x) >> 16) == 0)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (module)
 
FARPROC WINAPI get_proc_address (HMODULE module, LPCSTR function)
 
static BOOL load_library_as_datafile (LPCWSTR load_path, DWORD flags, LPCWSTR name, HMODULE *mod_ret)
 
static HMODULE load_library (const UNICODE_STRING *libname, DWORD flags)
 
DLL_DIRECTORY_COOKIE WINAPI DECLSPEC_HOTPATCH AddDllDirectory (const WCHAR *dir)
 
FARPROC WINAPI DECLSPEC_HOTPATCH DelayLoadFailureHook (LPCSTR name, LPCSTR function)
 
BOOL WINAPI DECLSPEC_HOTPATCH DisableThreadLibraryCalls (HMODULE module)
 
BOOL WINAPI DECLSPEC_HOTPATCH FreeLibrary (HINSTANCE module)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameA (HMODULE module, LPSTR filename, DWORD size)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameW (HMODULE module, LPWSTR filename, DWORD size)
 
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA (LPCSTR module)
 
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleW (LPCWSTR module)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExA (DWORD flags, LPCSTR name, HMODULE *module)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExW (DWORD flags, LPCWSTR name, HMODULE *module)
 
FARPROC WINAPI DECLSPEC_HOTPATCH GetProcAddress (HMODULE module, LPCSTR function)
 
BOOL WINAPI IsApiSetImplemented (LPCSTR name)
 
HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryA (LPCSTR name)
 
HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryW (LPCWSTR name)
 
HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA (LPCSTR name, HANDLE file, DWORD flags)
 
HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW (LPCWSTR name, HANDLE file, DWORD flags)
 
HMODULE WINAPI LoadPackagedLibrary (LPCWSTR name, DWORD reserved)
 
void WINAPI LoadAppInitDlls (void)
 
BOOL WINAPI DECLSPEC_HOTPATCH RemoveDllDirectory (DLL_DIRECTORY_COOKIE cookie)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetDefaultDllDirectories (DWORD flags)
 
static NTSTATUS get_res_nameA (LPCSTR name, UNICODE_STRING *str)
 
static NTSTATUS get_res_nameW (LPCWSTR name, UNICODE_STRING *str)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceLanguagesExA (HMODULE module, LPCSTR type, LPCSTR name, ENUMRESLANGPROCA func, LONG_PTR param, DWORD flags, LANGID lang)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceLanguagesExW (HMODULE module, LPCWSTR type, LPCWSTR name, ENUMRESLANGPROCW func, LONG_PTR param, DWORD flags, LANGID lang)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExA (HMODULE module, LPCSTR type, ENUMRESNAMEPROCA func, LONG_PTR param, DWORD flags, LANGID lang)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExW (HMODULE module, LPCWSTR type, ENUMRESNAMEPROCW func, LONG_PTR param, DWORD flags, LANGID lang)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesW (HMODULE module, LPCWSTR type, ENUMRESNAMEPROCW func, LONG_PTR param)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExA (HMODULE module, ENUMRESTYPEPROCA func, LONG_PTR param, DWORD flags, LANGID lang)
 
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExW (HMODULE module, ENUMRESTYPEPROCW func, LONG_PTR param, DWORD flags, LANGID lang)
 
HRSRC WINAPI DECLSPEC_HOTPATCH FindResourceExW (HMODULE module, LPCWSTR type, LPCWSTR name, WORD lang)
 
HRSRC WINAPI DECLSPEC_HOTPATCH FindResourceW (HINSTANCE module, LPCWSTR name, LPCWSTR type)
 
BOOL WINAPI DECLSPEC_HOTPATCH FreeResource (HGLOBAL handle)
 
HGLOBAL WINAPI DECLSPEC_HOTPATCH LoadResource (HINSTANCE module, HRSRC rsrc)
 
LPVOID WINAPI DECLSPEC_HOTPATCH LockResource (HGLOBAL handle)
 
DWORD WINAPI DECLSPEC_HOTPATCH SizeofResource (HINSTANCE module, HRSRC rsrc)
 
BOOL WINAPI DECLSPEC_HOTPATCH ActivateActCtx (HANDLE context, ULONG_PTR *cookie)
 
void WINAPI DECLSPEC_HOTPATCH AddRefActCtx (HANDLE context)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateActCtxW (PCACTCTXW ctx)
 
BOOL WINAPI DECLSPEC_HOTPATCH DeactivateActCtx (DWORD flags, ULONG_PTR cookie)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindActCtxSectionGuid (DWORD flags, const GUID *ext_guid, ULONG id, const GUID *guid, PACTCTX_SECTION_KEYED_DATA info)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindActCtxSectionStringW (DWORD flags, const GUID *ext_guid, ULONG id, LPCWSTR str, PACTCTX_SECTION_KEYED_DATA info)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCurrentActCtx (HANDLE *pcontext)
 
BOOL WINAPI DECLSPEC_HOTPATCH QueryActCtxSettingsW (DWORD flags, HANDLE ctx, const WCHAR *ns, const WCHAR *settings, WCHAR *buffer, SIZE_T size, SIZE_T *written)
 
BOOL WINAPI DECLSPEC_HOTPATCH QueryActCtxW (DWORD flags, HANDLE context, PVOID inst, ULONG class, PVOID buffer, SIZE_T size, SIZE_T *written)
 
void WINAPI DECLSPEC_HOTPATCH ReleaseActCtx (HANDLE context)
 
BOOL WINAPI DECLSPEC_HOTPATCH ZombifyActCtx (HANDLE context)
 

Variables

static struct list exclusive_datafile_list = LIST_INIT( exclusive_datafile_list )
 
static CRITICAL_SECTION exclusive_datafile_list_section = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 

Macro Definition Documentation

◆ IS_INTRESOURCE

#define IS_INTRESOURCE (   x)    (((ULONG_PTR)(x) >> 16) == 0)

Definition at line 613 of file loader.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 26 of file loader.c.

Function Documentation

◆ ActivateActCtx()

BOOL WINAPI DECLSPEC_HOTPATCH ActivateActCtx ( HANDLE  context,
ULONG_PTR cookie 
)

Definition at line 1149 of file loader.c.

1150{
1152}
static __inline BOOL set_ntstatus(NTSTATUS status)
Definition: security.c:227
NTSYSAPI NTSTATUS WINAPI RtlActivateActivationContext(DWORD, HANDLE, ULONG_PTR *)
Definition: http.c:7252
Definition: cookie.c:34

◆ AddDllDirectory()

Definition at line 188 of file loader.c.

189{
191 void *cookie;
192
194 if (!set_ntstatus( LdrAddDllDirectory( &str, &cookie ))) return NULL;
195 return cookie;
196}
unsigned int dir
Definition: maze.c:112
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
const WCHAR * str

Referenced by init_pointers().

◆ AddRefActCtx()

void WINAPI DECLSPEC_HOTPATCH AddRefActCtx ( HANDLE  context)

Definition at line 1158 of file loader.c.

1159{
1161}
NTSYSAPI void WINAPI RtlAddRefActivationContext(HANDLE)
Definition: actctx.c:5373

◆ CreateActCtxW()

HANDLE WINAPI DECLSPEC_HOTPATCH CreateActCtxW ( PCACTCTXW  ctx)

Definition at line 1167 of file loader.c.

1168{
1170
1171 TRACE( "%p %08lx\n", ctx, ctx ? ctx->dwFlags : 0 );
1172
1174 return context;
1175}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
NTSYSAPI NTSTATUS WINAPI RtlCreateActivationContext(HANDLE *, const void *)
#define TRACE(s)
Definition: solgame.cpp:4

◆ DeactivateActCtx()

BOOL WINAPI DECLSPEC_HOTPATCH DeactivateActCtx ( DWORD  flags,
ULONG_PTR  cookie 
)

Definition at line 1181 of file loader.c.

1182{
1184 return TRUE;
1185}
#define TRUE
Definition: types.h:120
GLbitfield flags
Definition: glext.h:7161
NTSYSAPI void WINAPI RtlDeactivateActivationContext(DWORD, ULONG_PTR)

◆ DelayLoadFailureHook()

FARPROC WINAPI DECLSPEC_HOTPATCH DelayLoadFailureHook ( LPCSTR  name,
LPCSTR  function 
)

Definition at line 202 of file loader.c.

203{
204 ULONG_PTR args[2];
205
206 if ((ULONG_PTR)function >> 16)
207 ERR( "failed to delay load %s.%s\n", name, function );
208 else
209 ERR( "failed to delay load %s.%u\n", name, LOWORD(function) );
210 args[0] = (ULONG_PTR)name;
211 args[1] = (ULONG_PTR)function;
213 return NULL;
214}
#define ERR(fmt,...)
Definition: precomp.h:57
VOID WINAPI RaiseException(_In_ DWORD dwExceptionCode, _In_ DWORD dwExceptionFlags, _In_ DWORD nNumberOfArguments, _In_opt_ const ULONG_PTR *lpArguments)
Definition: except.c:700
#define ULONG_PTR
Definition: config.h:101
#define LOWORD(l)
Definition: pedump.c:82
Definition: match.c:390
Definition: name.c:39
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23
#define EXCEPTION_WINE_STUB
Definition: stubs.h:31
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ DisableThreadLibraryCalls()

BOOL WINAPI DECLSPEC_HOTPATCH DisableThreadLibraryCalls ( HMODULE  module)

Definition at line 220 of file loader.c.

221{
223}
NTSTATUS NTAPI LdrDisableThreadCalloutsForDll(_In_ PVOID BaseAddress)
Definition: ldrapi.c:1154

◆ EnumResourceLanguagesExA()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceLanguagesExA ( HMODULE  module,
LPCSTR  type,
LPCSTR  name,
ENUMRESLANGPROCA  func,
LONG_PTR  param,
DWORD  flags,
LANGID  lang 
)

Definition at line 662 of file loader.c.

665{
666 int i;
667 BOOL ret = FALSE;
671 const IMAGE_RESOURCE_DIRECTORY *basedir, *resdir;
673
674 TRACE( "%p %s %s %p %Ix %lx %d\n", module, debugstr_a(type), debugstr_a(name),
675 func, param, flags, lang );
676
677 if (flags & (RESOURCE_ENUM_MUI | RESOURCE_ENUM_MUI_SYSTEM | RESOURCE_ENUM_VALIDATE))
678 FIXME( "unimplemented flags: %lx\n", flags );
679
680 if (!flags) flags = RESOURCE_ENUM_LN | RESOURCE_ENUM_MUI;
681 if (!(flags & RESOURCE_ENUM_LN)) return ret;
682
683 if (!module) module = GetModuleHandleW( 0 );
684 typeW.Buffer = nameW.Buffer = NULL;
685 if ((status = LdrFindResourceDirectory_U( module, NULL, 0, &basedir )) != STATUS_SUCCESS)
686 goto done;
688 goto done;
690 goto done;
691 info.Type = (ULONG_PTR)typeW.Buffer;
692 info.Name = (ULONG_PTR)nameW.Buffer;
693 if ((status = LdrFindResourceDirectory_U( module, &info, 2, &resdir )) != STATUS_SUCCESS)
694 goto done;
695
696 et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
697 __TRY
698 {
699 for (i = 0; i < resdir->NumberOfNamedEntries + resdir->NumberOfIdEntries; i++)
700 {
701 ret = func( module, type, name, et[i].Id, param );
702 if (!ret) break;
703 }
704 }
706 {
707 ret = FALSE;
709 }
711done:
712 if (!IS_INTRESOURCE(typeW.Buffer)) HeapFree( GetProcessHeap(), 0, typeW.Buffer );
713 if (!IS_INTRESOURCE(nameW.Buffer)) HeapFree( GetProcessHeap(), 0, nameW.Buffer );
715 return ret;
716}
DWORD Id
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR nameW[]
Definition: main.c:49
#define FIXME(fmt,...)
Definition: precomp.h:53
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define __TRY
Definition: compat.h:80
#define HeapFree(x, y, z)
Definition: compat.h:735
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define IS_INTRESOURCE(x)
Definition: loader.c:613
static NTSTATUS get_res_nameA(LPCSTR name, UNICODE_STRING *str)
Definition: loader.c:616
static const WCHAR typeW[]
Definition: name.c:51
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum func
Definition: glext.h:6028
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define debugstr_a
Definition: kernel32.h:31
NTSTATUS NTAPI LdrFindResourceDirectory_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DIRECTORY *ResourceDirectory)
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: pedump.c:414
Definition: ps.c:97
static const WCHAR lang[]
Definition: wbemdisp.c:287

◆ EnumResourceLanguagesExW()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceLanguagesExW ( HMODULE  module,
LPCWSTR  type,
LPCWSTR  name,
ENUMRESLANGPROCW  func,
LONG_PTR  param,
DWORD  flags,
LANGID  lang 
)

Definition at line 722 of file loader.c.

725{
726 int i;
727 BOOL ret = FALSE;
731 const IMAGE_RESOURCE_DIRECTORY *basedir, *resdir;
733
734 TRACE( "%p %s %s %p %Ix %lx %d\n", module, debugstr_w(type), debugstr_w(name),
735 func, param, flags, lang );
736
737 if (flags & (RESOURCE_ENUM_MUI | RESOURCE_ENUM_MUI_SYSTEM | RESOURCE_ENUM_VALIDATE))
738 FIXME( "unimplemented flags: %lx\n", flags );
739
740 if (!flags) flags = RESOURCE_ENUM_LN | RESOURCE_ENUM_MUI;
741 if (!(flags & RESOURCE_ENUM_LN)) return ret;
742
743 if (!module) module = GetModuleHandleW( 0 );
744 typeW.Buffer = nameW.Buffer = NULL;
745 if ((status = LdrFindResourceDirectory_U( module, NULL, 0, &basedir )) != STATUS_SUCCESS)
746 goto done;
748 goto done;
750 goto done;
751 info.Type = (ULONG_PTR)typeW.Buffer;
752 info.Name = (ULONG_PTR)nameW.Buffer;
753 if ((status = LdrFindResourceDirectory_U( module, &info, 2, &resdir )) != STATUS_SUCCESS)
754 goto done;
755
756 et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
757 __TRY
758 {
759 for (i = 0; i < resdir->NumberOfNamedEntries + resdir->NumberOfIdEntries; i++)
760 {
761 ret = func( module, type, name, et[i].Id, param );
762 if (!ret) break;
763 }
764 }
766 {
767 ret = FALSE;
769 }
771done:
772 if (!IS_INTRESOURCE(typeW.Buffer)) HeapFree( GetProcessHeap(), 0, typeW.Buffer );
773 if (!IS_INTRESOURCE(nameW.Buffer)) HeapFree( GetProcessHeap(), 0, nameW.Buffer );
775 return ret;
776}
static NTSTATUS get_res_nameW(LPCWSTR name, UNICODE_STRING *str)
Definition: loader.c:637
#define debugstr_w
Definition: kernel32.h:32

◆ EnumResourceNamesExA()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExA ( HMODULE  module,
LPCSTR  type,
ENUMRESNAMEPROCA  func,
LONG_PTR  param,
DWORD  flags,
LANGID  lang 
)

Definition at line 782 of file loader.c.

784{
785 int i;
786 BOOL ret = FALSE;
787 DWORD len = 0, newlen;
788 LPSTR name = NULL;
792 const IMAGE_RESOURCE_DIRECTORY *basedir, *resdir;
795
796 TRACE( "%p %s %p %Ix\n", module, debugstr_a(type), func, param );
797
798 if (flags & (RESOURCE_ENUM_MUI | RESOURCE_ENUM_MUI_SYSTEM | RESOURCE_ENUM_VALIDATE))
799 FIXME( "unimplemented flags: %lx\n", flags );
800
801 if (!flags) flags = RESOURCE_ENUM_LN | RESOURCE_ENUM_MUI;
802 if (!(flags & RESOURCE_ENUM_LN)) return ret;
803
804 if (!module) module = GetModuleHandleW( 0 );
805 typeW.Buffer = NULL;
806 if ((status = LdrFindResourceDirectory_U( module, NULL, 0, &basedir )) != STATUS_SUCCESS)
807 goto done;
809 goto done;
810 info.Type = (ULONG_PTR)typeW.Buffer;
812 goto done;
813
814 et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
815 __TRY
816 {
817 for (i = 0; i < resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries; i++)
818 {
819 if (et[i].NameIsString)
820 {
821 str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)basedir + et[i].NameOffset);
822 newlen = WideCharToMultiByte(CP_ACP, 0, str->NameString, str->Length, NULL, 0, NULL, NULL);
823 if (newlen + 1 > len)
824 {
825 len = newlen + 1;
827 if (!(name = HeapAlloc( GetProcessHeap(), 0, len + 1 )))
828 {
829 ret = FALSE;
830 break;
831 }
832 }
833 WideCharToMultiByte( CP_ACP, 0, str->NameString, str->Length, name, len, NULL, NULL );
834 name[newlen] = 0;
835 ret = func( module, type, name, param );
836 }
837 else
838 {
839 ret = func( module, type, UIntToPtr(et[i].Id), param );
840 }
841 if (!ret) break;
842 }
843 }
845 {
846 ret = FALSE;
848 }
850
851done:
853 if (!IS_INTRESOURCE(typeW.Buffer)) HeapFree( GetProcessHeap(), 0, typeW.Buffer );
855 return ret;
856}
#define UIntToPtr(ui)
Definition: basetsd.h:90
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define WideCharToMultiByte
Definition: compat.h:111
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
if(dx< 0)
Definition: linetemp.h:194
ULONG NameOffset
Definition: ntimage.h:185
char * LPSTR
Definition: xmlstorage.h:182
unsigned char BYTE
Definition: xxhash.c:193

◆ EnumResourceNamesExW()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExW ( HMODULE  module,
LPCWSTR  type,
ENUMRESNAMEPROCW  func,
LONG_PTR  param,
DWORD  flags,
LANGID  lang 
)

Definition at line 862 of file loader.c.

864{
865 int i, len = 0;
866 BOOL ret = FALSE;
867 LPWSTR name = NULL;
871 const IMAGE_RESOURCE_DIRECTORY *basedir, *resdir;
874
875 TRACE( "%p %s %p %Ix\n", module, debugstr_w(type), func, param );
876
877 if (flags & (RESOURCE_ENUM_MUI | RESOURCE_ENUM_MUI_SYSTEM | RESOURCE_ENUM_VALIDATE))
878 FIXME( "unimplemented flags: %lx\n", flags );
879
880 if (!flags) flags = RESOURCE_ENUM_LN | RESOURCE_ENUM_MUI;
881 if (!(flags & RESOURCE_ENUM_LN)) return ret;
882
883 if (!module) module = GetModuleHandleW( 0 );
884 typeW.Buffer = NULL;
885 if ((status = LdrFindResourceDirectory_U( module, NULL, 0, &basedir )) != STATUS_SUCCESS)
886 goto done;
888 goto done;
889 info.Type = (ULONG_PTR)typeW.Buffer;
891 goto done;
892
893 et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
894 __TRY
895 {
896 for (i = 0; i < resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries; i++)
897 {
898 if (et[i].NameIsString)
899 {
900 str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)basedir + et[i].NameOffset);
901 if (str->Length + 1 > len)
902 {
903 len = str->Length + 1;
905 if (!(name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
906 {
907 ret = FALSE;
908 break;
909 }
910 }
911 memcpy(name, str->NameString, str->Length * sizeof (WCHAR));
912 name[str->Length] = 0;
913 ret = func( module, type, name, param );
914 }
915 else
916 {
917 ret = func( module, type, UIntToPtr(et[i].Id), param );
918 }
919 if (!ret) break;
920 }
921 }
923 {
924 ret = FALSE;
926 }
928done:
930 if (!IS_INTRESOURCE(typeW.Buffer)) HeapFree( GetProcessHeap(), 0, typeW.Buffer );
932 return ret;
933}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by EnumResourceNamesW().

◆ EnumResourceNamesW()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesW ( HMODULE  module,
LPCWSTR  type,
ENUMRESNAMEPROCW  func,
LONG_PTR  param 
)

Definition at line 939 of file loader.c.

941{
942 return EnumResourceNamesExW( module, type, func, param, 0, 0 );
943}
BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceNamesExW(HMODULE module, LPCWSTR type, ENUMRESNAMEPROCW func, LONG_PTR param, DWORD flags, LANGID lang)
Definition: loader.c:862

◆ EnumResourceTypesExA()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExA ( HMODULE  module,
ENUMRESTYPEPROCA  func,
LONG_PTR  param,
DWORD  flags,
LANGID  lang 
)

Definition at line 949 of file loader.c.

951{
952 int i;
953 BOOL ret = FALSE;
954 LPSTR type = NULL;
955 DWORD len = 0, newlen;
956 const IMAGE_RESOURCE_DIRECTORY *resdir;
959
960 TRACE( "%p %p %Ix\n", module, func, param );
961
962 if (flags & (RESOURCE_ENUM_MUI | RESOURCE_ENUM_MUI_SYSTEM | RESOURCE_ENUM_VALIDATE))
963 FIXME( "unimplemented flags: %lx\n", flags );
964
965 if (!flags) flags = RESOURCE_ENUM_LN | RESOURCE_ENUM_MUI;
966 if (!(flags & RESOURCE_ENUM_LN)) return ret;
967
968 if (!module) module = GetModuleHandleW( 0 );
969
970 if (!set_ntstatus( LdrFindResourceDirectory_U( module, NULL, 0, &resdir ))) return FALSE;
971
972 et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
973 for (i = 0; i < resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries; i++)
974 {
975 if (et[i].NameIsString)
976 {
977 str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)resdir + et[i].NameOffset);
978 newlen = WideCharToMultiByte( CP_ACP, 0, str->NameString, str->Length, NULL, 0, NULL, NULL);
979 if (newlen + 1 > len)
980 {
981 len = newlen + 1;
983 if (!(type = HeapAlloc( GetProcessHeap(), 0, len ))) return FALSE;
984 }
985 WideCharToMultiByte( CP_ACP, 0, str->NameString, str->Length, type, len, NULL, NULL);
986 type[newlen] = 0;
987 ret = func( module, type, param );
988 }
989 else
990 {
991 ret = func( module, UIntToPtr(et[i].Id), param );
992 }
993 if (!ret) break;
994 }
996 return ret;
997}

◆ EnumResourceTypesExW()

BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExW ( HMODULE  module,
ENUMRESTYPEPROCW  func,
LONG_PTR  param,
DWORD  flags,
LANGID  lang 
)

Definition at line 1003 of file loader.c.

1005{
1006 int i, len = 0;
1007 BOOL ret = FALSE;
1008 LPWSTR type = NULL;
1009 const IMAGE_RESOURCE_DIRECTORY *resdir;
1012
1013 TRACE( "%p %p %Ix\n", module, func, param );
1014
1015 if (!flags) flags = RESOURCE_ENUM_LN | RESOURCE_ENUM_MUI;
1016 if (!(flags & RESOURCE_ENUM_LN)) return ret;
1017
1018 if (!module) module = GetModuleHandleW( 0 );
1019
1020 if (!set_ntstatus( LdrFindResourceDirectory_U( module, NULL, 0, &resdir ))) return FALSE;
1021
1022 et = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(resdir + 1);
1023 for (i = 0; i < resdir->NumberOfNamedEntries + resdir->NumberOfIdEntries; i++)
1024 {
1025 if (et[i].NameIsString)
1026 {
1027 str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const BYTE *)resdir + et[i].NameOffset);
1028 if (str->Length + 1 > len)
1029 {
1030 len = str->Length + 1;
1031 HeapFree( GetProcessHeap(), 0, type );
1032 if (!(type = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE;
1033 }
1034 memcpy(type, str->NameString, str->Length * sizeof (WCHAR));
1035 type[str->Length] = 0;
1036 ret = func( module, type, param );
1037 }
1038 else
1039 {
1040 ret = func( module, UIntToPtr(et[i].Id), param );
1041 }
1042 if (!ret) break;
1043 }
1044 HeapFree( GetProcessHeap(), 0, type );
1045 return ret;
1046}

◆ FindActCtxSectionGuid()

BOOL WINAPI DECLSPEC_HOTPATCH FindActCtxSectionGuid ( DWORD  flags,
const GUID ext_guid,
ULONG  id,
const GUID guid,
PACTCTX_SECTION_KEYED_DATA  info 
)

Definition at line 1191 of file loader.c.

1193{
1195}
GUID guid
Definition: version.c:147
NTSYSAPI NTSTATUS NTAPI RtlFindActivationContextSectionGuid(ULONG flags, const GUID *extguid, ULONG section_kind, const GUID *guid, void *ptr)
Definition: actctx.c:5946

◆ FindActCtxSectionStringW()

BOOL WINAPI DECLSPEC_HOTPATCH FindActCtxSectionStringW ( DWORD  flags,
const GUID ext_guid,
ULONG  id,
LPCWSTR  str,
PACTCTX_SECTION_KEYED_DATA  info 
)

Definition at line 1201 of file loader.c.

1203{
1205
1206 if (!info)
1207 {
1209 return FALSE;
1210 }
1212 return set_ntstatus( RtlFindActivationContextSectionString( flags, ext_guid, id, &us, info ));
1213}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG, const GUID *, ULONG, const UNICODE_STRING *, PVOID)
Definition: actctx.c:5874
static const BYTE us[]
Definition: encode.c:689

◆ FindResourceExW()

HRSRC WINAPI DECLSPEC_HOTPATCH FindResourceExW ( HMODULE  module,
LPCWSTR  type,
LPCWSTR  name,
WORD  lang 
)

Definition at line 1052 of file loader.c.

1053{
1058
1059 TRACE( "%p %s %s %04x\n", module, debugstr_w(type), debugstr_w(name), lang );
1060
1061 if (!module) module = GetModuleHandleW( 0 );
1062 nameW.Buffer = typeW.Buffer = NULL;
1063
1064 __TRY
1065 {
1066 if ((status = get_res_nameW( name, &nameW )) != STATUS_SUCCESS) goto done;
1067 if ((status = get_res_nameW( type, &typeW )) != STATUS_SUCCESS) goto done;
1068 info.Type = (ULONG_PTR)typeW.Buffer;
1069 info.Name = (ULONG_PTR)nameW.Buffer;
1070 info.Language = lang;
1072 done:
1074 }
1076 {
1078 }
1079 __ENDTRY
1080
1081 if (!IS_INTRESOURCE(nameW.Buffer)) HeapFree( GetProcessHeap(), 0, nameW.Buffer );
1082 if (!IS_INTRESOURCE(typeW.Buffer)) HeapFree( GetProcessHeap(), 0, typeW.Buffer );
1083 return (HRSRC)entry;
1084}
uint32_t entry
Definition: isohybrid.c:63
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
Definition: pedump.c:458

Referenced by FindResourceW().

◆ FindResourceW()

HRSRC WINAPI DECLSPEC_HOTPATCH FindResourceW ( HINSTANCE  module,
LPCWSTR  name,
LPCWSTR  type 
)

Definition at line 1090 of file loader.c.

1091{
1093}
HRSRC WINAPI DECLSPEC_HOTPATCH FindResourceExW(HMODULE module, LPCWSTR type, LPCWSTR name, WORD lang)
Definition: loader.c:1052
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_NEUTRAL
Definition: nls.h:167

◆ FreeLibrary()

BOOL WINAPI DECLSPEC_HOTPATCH FreeLibrary ( HINSTANCE  module)

Definition at line 229 of file loader.c.

230{
231 if (!module)
232 {
234 return FALSE;
235 }
236
237 if ((ULONG_PTR)module & 3) /* this is a datafile module */
238 {
239 void *ptr = (void *)((ULONG_PTR)module & ~3);
240 if (!RtlImageNtHeader( ptr ))
241 {
243 return FALSE;
244 }
245 if ((ULONG_PTR)module & 1)
246 {
247 struct exclusive_datafile *file;
248
251 {
252 if (file->module != module) continue;
253 TRACE( "closing %p for module %p\n", file->file, file->module );
254 CloseHandle( file->file );
257 break;
258 }
260 }
261 return UnmapViewOfFile( ptr );
262 }
263
264 return set_ntstatus( LdrUnloadDll( module ));
265}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define CloseHandle
Definition: compat.h:739
#define UnmapViewOfFile
Definition: compat.h:746
#define RtlImageNtHeader
Definition: compat.h:806
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static CRITICAL_SECTION exclusive_datafile_list_section
Definition: loader.c:50
static struct list exclusive_datafile_list
Definition: loader.c:48
NTSTATUS NTAPI LdrUnloadDll(_In_ PVOID BaseAddress)
Definition: ldrapi.c:1291
static PVOID ptr
Definition: dispmode.c:27
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
Definition: fci.c:127
struct list entry
Definition: fci.c:128
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:251

◆ FreeResource()

BOOL WINAPI DECLSPEC_HOTPATCH FreeResource ( HGLOBAL  handle)

Definition at line 1099 of file loader.c.

1100{
1101 return FALSE;
1102}

◆ get_proc_address()

FARPROC WINAPI get_proc_address ( HMODULE  module,
LPCSTR  function 
)

Definition at line 67 of file loader.c.

68{
71
72 if (!module) module = NtCurrentTeb()->Peb->ImageBaseAddress;
73
74 if ((ULONG_PTR)function >> 16)
75 {
76 RtlInitAnsiString( &str, function );
77 if (!set_ntstatus( LdrGetProcedureAddress( module, &str, 0, (void**)&proc ))) return NULL;
78 }
79 else if (!set_ntstatus( LdrGetProcedureAddress( module, NULL, LOWORD(function), (void**)&proc )))
80 return NULL;
81
82 return proc;
83}
int(* FARPROC)()
Definition: compat.h:36
#define NtCurrentTeb
NTSTATUS NTAPI LdrGetProcedureAddress(_In_ PVOID BaseAddress, _In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING Name, _In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG Ordinal, _Out_ PVOID *ProcedureAddress)
Definition: ldrapi.c:789
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
static HANDLE proc()
Definition: pdb.c:34

Referenced by GetProcAddress().

◆ get_res_nameA()

static NTSTATUS get_res_nameA ( LPCSTR  name,
UNICODE_STRING str 
)
static

Definition at line 616 of file loader.c.

617{
618 if (IS_INTRESOURCE(name))
619 {
620 str->Buffer = ULongToPtr( LOWORD(name) );
621 return STATUS_SUCCESS;
622 }
623 if (name[0] == '#')
624 {
625 ULONG value;
626 if (RtlCharToInteger( name + 1, 10, &value ) != STATUS_SUCCESS || HIWORD(value))
628 str->Buffer = ULongToPtr(value);
629 return STATUS_SUCCESS;
630 }
633 return STATUS_SUCCESS;
634}
#define ULongToPtr(ul)
Definition: basetsd.h:92
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI NTSTATUS NTAPI RtlCharToInteger(PCSZ String, ULONG Base, PULONG Value)
Definition: unicode.c:261
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
Definition: pdh_main.c:96

Referenced by EnumResourceLanguagesExA(), and EnumResourceNamesExA().

◆ get_res_nameW()

static NTSTATUS get_res_nameW ( LPCWSTR  name,
UNICODE_STRING str 
)
static

Definition at line 637 of file loader.c.

638{
639 if (IS_INTRESOURCE(name))
640 {
641 str->Buffer = ULongToPtr( LOWORD(name) );
642 return STATUS_SUCCESS;
643 }
644 if (name[0] == '#')
645 {
646 ULONG value;
650 str->Buffer = ULongToPtr(value);
651 return STATUS_SUCCESS;
652 }
655 return STATUS_SUCCESS;
656}
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)

Referenced by EnumResourceLanguagesExW(), EnumResourceNamesExW(), and FindResourceExW().

◆ GetCurrentActCtx()

BOOL WINAPI DECLSPEC_HOTPATCH GetCurrentActCtx ( HANDLE pcontext)

Definition at line 1219 of file loader.c.

1220{
1221 return set_ntstatus( RtlGetActiveActivationContext( pcontext ));
1222}
NTSYSAPI NTSTATUS WINAPI RtlGetActiveActivationContext(HANDLE *)
Definition: actctx.c:5539

◆ GetModuleFileNameA()

DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameA ( HMODULE  module,
LPSTR  filename,
DWORD  size 
)

Definition at line 271 of file loader.c.

272{
273 LPWSTR filenameW = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) );
274 DWORD len;
275
276 if (!filenameW)
277 {
279 return 0;
280 }
282 {
284 if (len < size)
285 filename[len] = 0;
286 else
288 }
290 return len;
291}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
DWORD file_name_WtoA(LPCWSTR src, INT srclen, LPSTR dest, INT destlen)
Definition: file.c:438
GLsizeiptr size
Definition: glext.h:5919
const char * filename
Definition: ioapi.h:137
static const WCHAR filenameW[]
Definition: amstream.c:41

◆ GetModuleFileNameW()

DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameW ( HMODULE  module,
LPWSTR  filename,
DWORD  size 
)

Definition at line 297 of file loader.c.

298{
299 ULONG len = 0;
300 WIN16_SUBSYSTEM_TIB *win16_tib;
303
304 if (!module && ((win16_tib = NtCurrentTeb()->Tib.SubSystemTib)) && win16_tib->exe_name)
305 {
306 len = min( size, win16_tib->exe_name->Length / sizeof(WCHAR) );
307 memcpy( filename, win16_tib->exe_name->Buffer, len * sizeof(WCHAR) );
308 if (len < size) filename[len] = 0;
309 goto done;
310 }
311
312 name.Buffer = filename;
313 name.MaximumLength = min( size, UNICODE_STRING_MAX_CHARS ) * sizeof(WCHAR);
314 status = LdrGetDllFullName( module, &name );
315 if (!status || status == STATUS_BUFFER_TOO_SMALL) len = name.Length / sizeof(WCHAR);
317done:
318 TRACE( "%s\n", debugstr_wn(filename, len) );
319 return len;
320}
#define debugstr_wn
Definition: kernel32.h:33
#define min(a, b)
Definition: monoChain.cc:55
#define UNICODE_STRING_MAX_CHARS
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69

◆ GetModuleHandleA()

HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA ( LPCSTR  module)

Definition at line 326 of file loader.c.

327{
328 HMODULE ret;
329
330 GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, module, &ret );
331 return ret;
332}
BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExA(DWORD flags, LPCSTR name, HMODULE *module)
Definition: loader.c:350

◆ GetModuleHandleExA()

BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExA ( DWORD  flags,
LPCSTR  name,
HMODULE module 
)

Definition at line 350 of file loader.c.

351{
352 WCHAR *nameW;
353
354 if (!module)
355 {
357 return FALSE;
358 }
359
360 if (!name || (flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
362
363 if (!(nameW = file_name_AtoW( name, FALSE )))
364 {
365 *module = NULL;
367 return FALSE;
368 }
370}
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
WCHAR * file_name_AtoW(LPCSTR name, BOOL alloc)
Definition: file.c:411
BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExW(DWORD flags, LPCWSTR name, HMODULE *module)
Definition: loader.c:376
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ GetModuleHandleExW()

BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExW ( DWORD  flags,
LPCWSTR  name,
HMODULE module 
)

Definition at line 376 of file loader.c.

377{
378 HMODULE ret = NULL;
380 void *dummy;
381
382 if (!module)
383 {
385 return FALSE;
386 }
387
388 if ((flags & ~(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
389 | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
390 || (flags & (GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
391 == (GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
392 {
393 *module = NULL;
395 return FALSE;
396 }
397
398 if (name && !(flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
399 {
400 UNICODE_STRING wstr;
401 ULONG ldr_flags = 0;
402
403 if (flags & GET_MODULE_HANDLE_EX_FLAG_PIN)
404 ldr_flags |= LDR_GET_DLL_HANDLE_EX_FLAG_PIN;
405 if (flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)
406 ldr_flags |= LDR_GET_DLL_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
407
408 RtlInitUnicodeString( &wstr, name );
409 status = LdrGetDllHandleEx( ldr_flags, NULL, NULL, &wstr, &ret );
410 }
411 else
412 {
413 ret = name ? RtlPcToFileHeader( (void *)name, &dummy ) : NtCurrentTeb()->Peb->ImageBaseAddress;
414
415 if (ret)
416 {
417 if (!(flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
418 status = LdrAddRefDll( flags & GET_MODULE_HANDLE_EX_FLAG_PIN ? LDR_ADDREF_DLL_PIN : 0, ret );
419 else
422 }
423
424 *module = ret;
425 return set_ntstatus( status );
426}
PVOID NTAPI RtlPcToFileHeader(IN PVOID PcValue, PVOID *BaseOfImage)
Definition: libsupp.c:658
PPEB Peb
Definition: dllmain.c:27
NTSTATUS NTAPI LdrGetDllHandleEx(_In_ ULONG Flags, _In_opt_ PWSTR DllPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_opt_ PVOID *DllHandle)
Definition: ldrapi.c:505
NTSTATUS NTAPI LdrAddRefDll(_In_ ULONG Flags, _In_ PVOID BaseAddress)
Definition: ldrapi.c:1205
#define LDR_ADDREF_DLL_PIN
Definition: ldrtypes.h:75
#define STATUS_DLL_NOT_FOUND
Definition: ntstatus.h:545

◆ GetModuleHandleW()

HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleW ( LPCWSTR  module)

Definition at line 338 of file loader.c.

339{
340 HMODULE ret;
341
342 GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, module, &ret );
343 return ret;
344}

◆ GetProcAddress()

FARPROC WINAPI DECLSPEC_HOTPATCH GetProcAddress ( HMODULE  module,
LPCSTR  function 
)

Definition at line 488 of file loader.c.

489{
490 return get_proc_address( module, function );
491}
FARPROC WINAPI get_proc_address(HMODULE module, LPCSTR function)
Definition: loader.c:67

◆ IsApiSetImplemented()

BOOL WINAPI IsApiSetImplemented ( LPCSTR  name)

Definition at line 499 of file loader.c.

500{
503 BOOLEAN in_schema, present;
504
506 status = ApiSetQueryApiSetPresenceEx( &str, &in_schema, &present );
508 return !status && present;
509}
unsigned char BOOLEAN
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)

◆ load_library()

static HMODULE load_library ( const UNICODE_STRING libname,
DWORD  flags 
)
static

Definition at line 152 of file loader.c.

153{
157 WCHAR *load_path, *dummy;
158
159 if (flags & unsupported_flags) FIXME( "unsupported flag(s) used %#08lx\n", flags );
160
161 if (!set_ntstatus( LdrGetDllPath( libname->Buffer, flags, &load_path, &dummy ))) return 0;
162
165 {
166 if (LdrGetDllHandleEx( 0, load_path, NULL, libname, &module ))
167 load_library_as_datafile( load_path, flags, libname->Buffer, &module );
168 }
169 else
170 {
171 status = LdrLoadDll( load_path, flags, libname, &module );
172 if (!set_ntstatus( status ))
173 {
174 module = 0;
175 if (status == STATUS_DLL_NOT_FOUND && (GetVersion() & 0x80000000))
177 }
178 }
179
180 RtlReleasePath( load_path );
181 return module;
182}
static BOOL load_library_as_datafile(LPCWSTR load_path, DWORD flags, LPCWSTR name, HMODULE *mod_ret)
Definition: loader.c:89
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
NTSTATUS NTAPI DECLSPEC_HOTPATCH LdrLoadDll(_In_opt_ PWSTR SearchPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_ PVOID *BaseAddress)
Definition: ldrapi.c:312
#define LOAD_LIBRARY_REQUIRE_SIGNED_TARGET
Definition: winbase.h:382
#define LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE
Definition: winbase.h:381
#define LOAD_LIBRARY_AS_IMAGE_RESOURCE
Definition: winbase.h:380
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:375
#define LOAD_IGNORE_CODE_AUTHZ_LEVEL
Definition: winbase.h:378
#define ERROR_DLL_NOT_FOUND
Definition: winerror.h:679

Referenced by ITERATE_RegisterTypeLibraries(), and LoadLibraryExW().

◆ load_library_as_datafile()

static BOOL load_library_as_datafile ( LPCWSTR  load_path,
DWORD  flags,
LPCWSTR  name,
HMODULE mod_ret 
)
static

Definition at line 89 of file loader.c.

90{
93 HMODULE module = 0;
94 DWORD protect = PAGE_READONLY;
95
96 *mod_ret = 0;
97
99
101 {
103 NULL, OPEN_EXISTING, 0, 0 );
104 }
105 if (file == INVALID_HANDLE_VALUE) return FALSE;
106
107 mapping = CreateFileMappingW( file, NULL, protect, 0, 0, NULL );
108 if (!mapping) goto failed;
109
112 if (!module) goto failed;
113
115 {
116 /* make sure it's a valid PE file */
117 if (!RtlImageNtHeader( module ))
118 {
120 goto failed;
121 }
122 *mod_ret = (HMODULE)((char *)module + 1); /* set bit 0 for data file module */
123
125 {
126 struct exclusive_datafile *datafile = HeapAlloc( GetProcessHeap(), 0, sizeof(*datafile) );
127 if (!datafile) goto failed;
128 datafile->module = *mod_ret;
129 datafile->file = file;
133 TRACE( "delaying close %p for module %p\n", datafile->file, datafile->module );
134 return TRUE;
135 }
136 }
137 else *mod_ret = (HMODULE)((char *)module + 2); /* set bit 1 for image resource module */
138
139 CloseHandle( file );
140 return TRUE;
141
142failed:
144 CloseHandle( file );
145 return FALSE;
146}
#define ARRAY_SIZE(A)
Definition: main.h:20
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define PAGE_READONLY
Definition: compat.h:138
#define OPEN_EXISTING
Definition: compat.h:775
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
#define L(x)
Definition: resources.c:13
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define SEC_IMAGE
Definition: mmtypes.h:97
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
HMODULE module
Definition: loader.c:45
struct list entry
Definition: loader.c:44
HANDLE HMODULE
Definition: typedefs.h:77

Referenced by load_library().

◆ LoadAppInitDlls()

void WINAPI LoadAppInitDlls ( void  )

Definition at line 584 of file loader.c.

585{
586 TRACE( "\n" );
587}

Referenced by ClientThreadSetupHelper().

◆ LoadLibraryA()

HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryA ( LPCSTR  name)

Definition at line 515 of file loader.c.

516{
517 return LoadLibraryExA( name, 0, 0 );
518}
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159

◆ LoadLibraryExA()

HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA ( LPCSTR  name,
HANDLE  file,
DWORD  flags 
)

Definition at line 533 of file loader.c.

534{
535 WCHAR *nameW;
536
537 if (!(nameW = file_name_AtoW( name, FALSE ))) return 0;
538 return LoadLibraryExW( nameW, file, flags );
539}
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288

◆ LoadLibraryExW()

HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW ( LPCWSTR  name,
HANDLE  file,
DWORD  flags 
)

Definition at line 545 of file loader.c.

546{
549
550 if (!name)
551 {
553 return 0;
554 }
556 if (str.Buffer[str.Length/sizeof(WCHAR) - 1] != ' ') return load_library( &str, flags );
557
558 /* library name has trailing spaces */
560 while (str.Length > sizeof(WCHAR) && str.Buffer[str.Length/sizeof(WCHAR) - 1] == ' ')
561 str.Length -= sizeof(WCHAR);
562
563 str.Buffer[str.Length/sizeof(WCHAR)] = 0;
566 return module;
567}
static HMODULE load_library(const UNICODE_STRING *libname, DWORD flags)
Definition: loader.c:152

◆ LoadLibraryW()

HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryW ( LPCWSTR  name)

Definition at line 524 of file loader.c.

525{
526 return LoadLibraryExW( name, 0, 0 );
527}

◆ LoadPackagedLibrary()

HMODULE WINAPI LoadPackagedLibrary ( LPCWSTR  name,
DWORD  reserved 
)

Definition at line 573 of file loader.c.

574{
575 FIXME( "semi-stub, name %s, reserved %#lx.\n", debugstr_w(name), reserved );
577 return NULL;
578}
r reserved
Definition: btrfs.c:3006
#define APPMODEL_ERROR_NO_PACKAGE
Definition: winerror.h:2337

◆ LoadResource()

HGLOBAL WINAPI DECLSPEC_HOTPATCH LoadResource ( HINSTANCE  module,
HRSRC  rsrc 
)

Definition at line 1108 of file loader.c.

1109{
1110 void *ret;
1111
1112 TRACE( "%p %p\n", module, rsrc );
1113
1114 if (!rsrc) return 0;
1115 if (!module) module = GetModuleHandleW( 0 );
1117 return 0;
1118 return ret;
1119}
NTSTATUS NTAPI LdrAccessResource(_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)

◆ LockResource()

LPVOID WINAPI DECLSPEC_HOTPATCH LockResource ( HGLOBAL  handle)

Definition at line 1125 of file loader.c.

1126{
1127 return handle;
1128}

◆ QueryActCtxSettingsW()

BOOL WINAPI DECLSPEC_HOTPATCH QueryActCtxSettingsW ( DWORD  flags,
HANDLE  ctx,
const WCHAR ns,
const WCHAR settings,
WCHAR buffer,
SIZE_T  size,
SIZE_T written 
)

Definition at line 1228 of file loader.c.

1231{
1233 buffer, size, written ));
1234}
struct mke2fs_defaults settings[]
GLuint buffer
Definition: glext.h:5915
NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings(DWORD flags, HANDLE handle, const WCHAR *ns, const WCHAR *settings, WCHAR *buffer, SIZE_T size, SIZE_T *written)
Definition: actctx.c:5988
Definition: mxnamespace.c:45

◆ QueryActCtxW()

BOOL WINAPI DECLSPEC_HOTPATCH QueryActCtxW ( DWORD  flags,
HANDLE  context,
PVOID  inst,
ULONG  class,
PVOID  buffer,
SIZE_T  size,
SIZE_T written 
)

Definition at line 1240 of file loader.c.

1242{
1244 buffer, size, written ));
1245}
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5572

◆ ReleaseActCtx()

void WINAPI DECLSPEC_HOTPATCH ReleaseActCtx ( HANDLE  context)

Definition at line 1251 of file loader.c.

1252{
1254}
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5384

◆ RemoveDllDirectory()

BOOL WINAPI DECLSPEC_HOTPATCH RemoveDllDirectory ( DLL_DIRECTORY_COOKIE  cookie)

Definition at line 593 of file loader.c.

594{
595 return set_ntstatus( LdrRemoveDllDirectory( cookie ));
596}

Referenced by init_pointers().

◆ SetDefaultDllDirectories()

BOOL WINAPI DECLSPEC_HOTPATCH SetDefaultDllDirectories ( DWORD  flags)

Definition at line 602 of file loader.c.

603{
604 return set_ntstatus( LdrSetDefaultDllDirectories( flags ));
605}

Referenced by init_pointers().

◆ SizeofResource()

DWORD WINAPI DECLSPEC_HOTPATCH SizeofResource ( HINSTANCE  module,
HRSRC  rsrc 
)

Definition at line 1134 of file loader.c.

1135{
1136 if (!rsrc) return 0;
1137 return ((IMAGE_RESOURCE_DATA_ENTRY *)rsrc)->Size;
1138}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( module  )

◆ ZombifyActCtx()

BOOL WINAPI DECLSPEC_HOTPATCH ZombifyActCtx ( HANDLE  context)

Definition at line 1260 of file loader.c.

1261{
1263}
NTSYSAPI NTSTATUS WINAPI RtlZombifyActivationContext(HANDLE)
Definition: actctx.c:5396

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, { (DWORD_PTR)(__FILE__ ": exclusive_datafile_list_section") }
}
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: loader.c:51
LIST_ENTRY ProcessLocksList
Definition: winbase.h:918
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 51 of file loader.c.

◆ exclusive_datafile_list

struct list exclusive_datafile_list = LIST_INIT( exclusive_datafile_list )
static

Definition at line 48 of file loader.c.

Referenced by FreeLibrary(), and load_library_as_datafile().

◆ exclusive_datafile_list_section

static CRITICAL_SECTION exclusive_datafile_list_section = { &critsect_debug, -1, 0, 0, 0, 0 }
static

Definition at line 50 of file loader.c.

Referenced by FreeLibrary(), and load_library_as_datafile().