ReactOS 0.4.15-dev-7961-gdcf9eb0
LdrLoadDll.c File Reference
#include "precomp.h"
Include dependency graph for LdrLoadDll.c:

Go to the source code of this file.

Functions

 START_TEST (LdrLoadDll)
 

Function Documentation

◆ START_TEST()

START_TEST ( LdrLoadDll  )

Definition at line 24 of file LdrLoadDll.c.

25{
27 UNICODE_STRING DllName;
28 PVOID BaseAddress, BaseAddress2;
29 WCHAR szWinDir[MAX_PATH], szSysDir[MAX_PATH], szPath[MAX_PATH];
30 WCHAR *pch;
31
32 RtlInitEmptyUnicodeString(&DllName, NULL, 0);
33 GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
34 GetSystemDirectoryW(szSysDir, _countof(szSysDir));
35
36 Status = 0xDEADFACE;
37 StartSeh()
38 Status = LdrLoadDll(NULL, NULL, &DllName, NULL);
40 ok_ntstatus(Status, 0xDEADFACE);
41
42 Status = 0xDEADFACE;
44 StartSeh()
45 Status = LdrLoadDll(NULL, NULL, &DllName, &BaseAddress);
47 ok_ntstatus(Status, 0xDEADFACE);
49
50 Status = 0xDEADFACE;
51 StartSeh()
52 Status = LdrLoadDll(L"", NULL, &DllName, NULL);
54 ok_ntstatus(Status, 0xDEADFACE);
55
56 Status = 0xDEADFACE;
58 StartSeh()
59 Status = LdrLoadDll(L"", NULL, &DllName, &BaseAddress);
61 ok_ntstatus(Status, 0xDEADFACE);
63
64 RtlInitUnicodeString(&DllName, L"advapi32.dll");
65
66 Status = 0xDEADFACE;
68 StartSeh()
69 Status = LdrLoadDll(NULL, NULL, &DllName, NULL);
73 ok_ntstatus(Status, 0xDEADFACE);
75
76 RtlInitUnicodeString(&DllName, L"advapi32.dll");
77 Status = 0xDEADFACE;
79 StartSeh()
81 Status = LdrLoadDll(NULL, NULL, &DllName, &BaseAddress);
85 {
86 BaseAddress2 = InvalidPointer;
87 Status = LdrLoadDll(NULL, NULL, &DllName, &BaseAddress2);
89 ok_ptr(BaseAddress2, BaseAddress);
91 }
94 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
95
96 RtlInitUnicodeString(&DllName, L"advapi32.dll");
97 Status = 0xDEADFACE;
99 StartSeh()
100 Status = LdrLoadDll(L"\\SystemRoot\\System32", NULL, &DllName, NULL);
102 ok_ntstatus(Status, 0xDEADFACE);
104
105 /* Test with only backslashes in path; no file extension */
106 StringCchPrintfW(szPath, _countof(szPath), L"%s\\advapi32", szSysDir);
107 RtlInitUnicodeString(&DllName, szPath);
108 Status = 0xDEADFACE;
110 StartSeh()
111 Status = LdrLoadDll(szWinDir, NULL, &DllName, &BaseAddress);
117 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
118
119 /* Test with only backslashes in path; with file extension */
120 StringCchPrintfW(szPath, _countof(szPath), L"%s\\advapi32.dll", szSysDir);
121 RtlInitUnicodeString(&DllName, szPath);
122 Status = 0xDEADFACE;
124 StartSeh()
125 Status = LdrLoadDll(szWinDir, NULL, &DllName, &BaseAddress);
131 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
132
133 /* Test with one forward slash in path; no file extension */
134 StringCchPrintfW(szPath, _countof(szPath), L"%s/advapi32", szSysDir);
135 RtlInitUnicodeString(&DllName, szPath);
136 Status = 0xDEADFACE;
138 StartSeh()
139 Status = LdrLoadDll(szWinDir, NULL, &DllName, &BaseAddress);
145 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
146
147 /* Test with one forward slash in path; with file extension */
148 StringCchPrintfW(szPath, _countof(szPath), L"%s/advapi32.dll", szSysDir);
149 RtlInitUnicodeString(&DllName, szPath);
150 Status = 0xDEADFACE;
152 StartSeh()
153 Status = LdrLoadDll(szWinDir, NULL, &DllName, &BaseAddress);
159 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
160
161 /* Test with only forward slashes in path; no file extension */
162 StringCchPrintfW(szPath, _countof(szPath), L"%s\\advapi32", szSysDir);
163 for (pch = szPath; *pch != UNICODE_NULL; ++pch)
164 {
165 if (*pch == L'\\')
166 *pch = L'/';
167 }
168
169 RtlInitUnicodeString(&DllName, szPath);
170 Status = 0xDEADFACE;
172 StartSeh()
173 Status = LdrLoadDll(szWinDir, NULL, &DllName, &BaseAddress);
179 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
180
181 /* Test with only forward slashes in path; with file extension */
182 /* Test with only forward slashes in path; with file extension */
183 StringCchPrintfW(szPath, _countof(szPath), L"%s\\advapi32.dll", szSysDir);
184 for (pch = szPath; *pch != UNICODE_NULL; ++pch)
185 {
186 if (*pch == L'\\')
187 *pch = L'/';
188 }
189
190 RtlInitUnicodeString(&DllName, szPath);
191 Status = 0xDEADFACE;
193 StartSeh()
194 Status = LdrLoadDll(szWinDir, NULL, &DllName, &BaseAddress);
200 ok(BaseAddress != NULL, "BaseAddress was NULL\n");
201}
#define InvalidPointer
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define ok(value,...)
Definition: atltest.h:57
#define ok_ptr(expression, result)
Definition: atltest.h:108
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR SystemRoot[]
Definition: reg.c:38
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
Status
Definition: gdiplustypes.h:25
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
NTSTATUS NTAPI LdrUnloadDll(_In_ PVOID BaseAddress)
Definition: ldrapi.c:1331
NTSTATUS NTAPI DECLSPEC_HOTPATCH LdrLoadDll(_In_opt_ PWSTR SearchPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_ PVOID *BaseAddress)
Definition: ldrapi.c:312
if(dx< 0)
Definition: linetemp.h:194
#define pch(ap)
Definition: match.c:418
#define for
Definition: utility.h:88
LPCWSTR szPath
Definition: env.c:37
static HMODULE dll
Definition: str.c:188
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
__wchar_t WCHAR
Definition: xmlstorage.h:180