ReactOS 0.4.15-dev-8207-gd73a838
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);
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}
#define ok_(x1, x2)
Definition: atltest.h:61
#define TRUE
Definition: types.h:120
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define DWORD
Definition: nt_native.h:44
Definition: cookie.c:34
Definition: parser.c:49
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

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}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define wcsrchr
Definition: compat.h:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
static const WCHAR separator[]
Definition: asmname.c:65
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:102
struct _FileName FileName
Definition: fatprocs.h:896
GLuint buffer
Definition: glext.h:5915
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:251
__wchar_t WCHAR
Definition: xmlstorage.h:180

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);
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}
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268

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}
DWORD(WINAPI * LPGETVERSION)()
#define GetProcAddress(x, y)
Definition: compat.h:753
static const WCHAR version[]
Definition: asmname.c:66
unsigned long DWORD
Definition: ntddk_ex.h:95
static HMODULE dll
Definition: str.c:188
static HANDLE proc()
Definition: pdb.c:34

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;
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)
VOID _DeactivateCtx(ULONG_PTR cookie, int line)
HANDLE _CreateActCtxFromFile(LPCWSTR FileName, int line)
VOID _ActivateCtx(HANDLE h, ULONG_PTR *cookie, int line)
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by START_TEST().