ReactOS  0.4.14-dev-384-g5b37caa
LoadLibraryExW.c File Reference
#include "precomp.h"
Include dependency graph for LoadLibraryExW.c:

Go to the source code of this file.

Typedefs

typedef DWORD(WINAPILPGETVERSION) ()
 

Functions

HANDLE _CreateActCtxFromFile (LPCWSTR FileName, int line)
 
VOID _ActivateCtx (HANDLE h, ULONG_PTR *cookie, int line)
 
VOID _DeactivateCtx (ULONG_PTR cookie, int line)
 
VOID _TestVesion (HANDLE dll, DWORD ExpectedVersion, int line)
 
VOID TestDllRedirection ()
 
 START_TEST (LoadLibraryExW)
 

Typedef Documentation

◆ LPGETVERSION

typedef DWORD(WINAPI * LPGETVERSION) ()

Definition at line 25 of file LoadLibraryExW.c.

Function Documentation

◆ _ActivateCtx()

VOID _ActivateCtx ( HANDLE  h,
ULONG_PTR cookie,
int  line 
)

Definition at line 96 of file FindActCtxSectionStringW.c.

97 {
98  BOOL res;
99 
100  SetLastError(0xdeaddead);
101  res = ActivateActCtx(h, cookie);
102  ok_(__FILE__, line)(res == TRUE, "ActivateActCtx failed\n");
103  ok_(__FILE__, line)(GetLastError() == 0xdeaddead, "Wrong last error. Expected %lu, got %lu\n", (DWORD)(0xdeaddead), GetLastError());
104 }
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define DWORD
Definition: nt_native.h:44
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:417
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by START_TEST(), and TestDllRedirection().

◆ _CreateActCtxFromFile()

HANDLE _CreateActCtxFromFile ( LPCWSTR  FileName,
int  line 
)

Definition at line 74 of file FindActCtxSectionStringW.c.

75 {
76  ACTCTXW ActCtx = {sizeof(ACTCTX)};
77  HANDLE h;
79 
80  ok (GetModuleFileNameW(NULL, buffer, MAX_PATH), "GetModuleFileName failed\n");
81  separator = wcsrchr(buffer, L'\\');
82  if (separator)
84 
85  ActCtx.lpSource = buffer;
86 
87  SetLastError(0xdeaddead);
89  ok_(__FILE__, line)(h != INVALID_HANDLE_VALUE, "CreateActCtx failed for %S\n", FileName);
90  // In win10 last error is unchanged and in win2k3 it is ERROR_BAD_EXE_FORMAT
91  ok_(__FILE__, line)(GetLastError() == ERROR_BAD_EXE_FORMAT || GetLastError() == 0xdeaddead, "Wrong last error %lu\n", GetLastError());
92 
93  return h;
94 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
static const WCHAR separator[]
Definition: asmname.c:65
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:251
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:417
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
struct _FileName FileName
Definition: fatprocs.h:884
#define ok(value,...)
Definition: atltest.h:57
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:104
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by START_TEST(), and TestDllRedirection().

◆ _DeactivateCtx()

VOID _DeactivateCtx ( ULONG_PTR  cookie,
int  line 
)

Definition at line 106 of file FindActCtxSectionStringW.c.

107 {
108  BOOL res;
109 
110  SetLastError(0xdeaddead);
111  res = DeactivateActCtx(0, cookie);
112  ok_(__FILE__, line)(res == TRUE, "DeactivateActCtx failed\n");
113  ok_(__FILE__, line)(GetLastError() == 0xdeaddead, "Wrong last error. Expected %lu, got %lu\n", (DWORD)(0xdeaddead), GetLastError());
114 }
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define DWORD
Definition: nt_native.h:44
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:417
GLuint res
Definition: glext.h:9613
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by START_TEST(), and TestDllRedirection().

◆ _TestVesion()

VOID _TestVesion ( HANDLE  dll,
DWORD  ExpectedVersion,
int  line 
)

Definition at line 27 of file LoadLibraryExW.c.

28 {
30  DWORD version = proc();
31  ok_(__FILE__, line)(version == ExpectedVersion, "Got version %lu, expected %lu\n", version, ExpectedVersion);
32 }
static HANDLE proc()
Definition: pdb.c:32
static HMODULE dll
Definition: str.c:188
static const WCHAR version[]
Definition: asmname.c:66
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD(WINAPI * LPGETVERSION)()
#define GetProcAddress(x, y)
Definition: compat.h:418
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by TestDllRedirection().

◆ START_TEST()

START_TEST ( LoadLibraryExW  )

Definition at line 85 of file LoadLibraryExW.c.

86 {
88 }
VOID TestDllRedirection()

◆ TestDllRedirection()

VOID TestDllRedirection ( )

Definition at line 34 of file LoadLibraryExW.c.

35 {
36  HANDLE dll1, dll2, h;
37  ULONG_PTR cookie;
38 
39  /* Try to load the libraries without sxs */
40  dll1 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
41  ok (dll1 != NULL, "LoadLibraryExW failed\n");
42  dll2 = LoadLibraryExW(L"testdata\\kernel32test_versioned.dll",0 , 0);
43  ok (dll2 != NULL, "LoadLibraryExW failed\n");
44 
45  ok (dll1 != dll2, "\n");
46  _TestVesion(dll1, 1, __LINE__);
47  _TestVesion(dll2, 2, __LINE__);
48 
49  FreeLibrary(dll1);
50  FreeLibrary(dll2);
51 
52  dll1 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
53  ok (dll1 != NULL, "LoadLibraryExW failed\n");
54 
55  /* redir2dep.manifest defines an assembly with nothing but a dependency on redirtest2 assembly */
56  /* redirtest2.manifest defines an assembly that contains kernel32test_versioned.dll */
57  /* In win10 it is enought to load and activate redirtest2 */
58  /* In win2k3 however the only way to trigger the redirection is to load and activate redir2dep */
59  h = _CreateActCtxFromFile(L"testdata\\redir2dep.manifest", __LINE__);
60  _ActivateCtx(h, &cookie, __LINE__);
61  dll2 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
62  _DeactivateCtx(cookie, __LINE__);
63  ok (dll2 != NULL, "LoadLibraryExW failed\n");
64 
65  ok (dll1 != dll2, "\n");
66  _TestVesion(dll1, 1, __LINE__);
67  _TestVesion(dll2, 2, __LINE__);
68 
69  FreeLibrary(dll1);
70  FreeLibrary(dll2);
71 
72  dll1 = LoadLibraryExW(L"comctl32.dll",0 ,0);
73  ok (dll1 != NULL, "LoadLibraryExW failed\n");
74 
75  h = _CreateActCtxFromFile(L"comctl32dep.manifest", __LINE__);
76  _ActivateCtx(h, &cookie, __LINE__);
77  dll2 = LoadLibraryExW(L"comctl32.dll",0 , 0);
78  _DeactivateCtx(cookie, __LINE__);
79  ok (dll2 != NULL, "LoadLibraryExW failed\n");
80 
81  ok (dll1 != dll2, "\n");
82 
83 }
VOID _TestVesion(HANDLE dll, DWORD ExpectedVersion, int line)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
VOID _DeactivateCtx(ULONG_PTR cookie, int line)
VOID _ActivateCtx(HANDLE h, ULONG_PTR *cookie, int line)
#define FreeLibrary(x)
Definition: compat.h:413
static const WCHAR L[]
Definition: oid.c:1250
#define ok(value,...)
Definition: atltest.h:57
HANDLE _CreateActCtxFromFile(LPCWSTR FileName, int line)

Referenced by START_TEST().