ReactOS 0.4.16-dev-258-g81860b4
RtlDosApplyFileIsolationRedirection_Ustr.c File Reference
#include "precomp.h"
Include dependency graph for RtlDosApplyFileIsolationRedirection_Ustr.c:

Go to the source code of this file.

Classes

struct  test_data
 

Macros

#define EXPECT_IN_SAME_DIR   (WCHAR*)0xdead
 

Functions

HANDLE _CreateActCtxFromFile (LPCWSTR FileName, int line)
 
void TestRedirection (void)
 
void TestBuffers ()
 
 START_TEST (RtlDosApplyFileIsolationRedirection_Ustr)
 

Variables

UNICODE_STRING DotDll = RTL_CONSTANT_STRING(L".DLL")
 
struct test_data Tests []
 

Macro Definition Documentation

◆ EXPECT_IN_SAME_DIR

#define EXPECT_IN_SAME_DIR   (WCHAR*)0xdead

Definition at line 10 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

Function Documentation

◆ _CreateActCtxFromFile()

HANDLE _CreateActCtxFromFile ( LPCWSTR  FileName,
int  line 
)

Definition at line 56 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

57{
58 ACTCTXW ActCtx = {sizeof(ACTCTX)};
59 HANDLE h;
61
62 ok (GetModuleFileNameW(NULL, buffer, MAX_PATH), "GetModuleFileName failed\n");
63 separator = wcsrchr(buffer, L'\\');
64 if (separator)
66
67 ActCtx.lpSource = buffer;
68
69 SetLastError(0xdeaddead);
71 ok_(__FILE__, line)(h != INVALID_HANDLE_VALUE, "CreateActCtx failed for %S\n", FileName);
72 // In win10 last error is unchanged and in win2k3 it is ERROR_BAD_EXE_FORMAT
73 ok_(__FILE__, line)(GetLastError() == ERROR_BAD_EXE_FORMAT || GetLastError() == 0xdeaddead, "Wrong last error %lu\n", GetLastError());
74
75 return h;
76}
#define ok(value,...)
Definition: atltest.h:57
#define ok_(x1, x2)
Definition: atltest.h:61
#define NULL
Definition: types.h:112
#define wcsrchr
Definition: compat.h:16
#define SetLastError(x)
Definition: compat.h:752
#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:897
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
_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)
Definition: parser.c:49
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_BAD_EXE_FORMAT
Definition: winerror.h:251
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST(), and TestDllRedirection().

◆ START_TEST()

Definition at line 367 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

368{
369 int argc;
370 char **test_argv;
372 if (argc >= 3)
373 {
374 HANDLE h = _CreateActCtxFromFile(L"ntdlltest.manifest", __LINE__);
375 BOOL bactivated = FALSE;
377
378 if (h != INVALID_HANDLE_VALUE)
379 bactivated = ActivateActCtx(h, &cookie);
380
382 TestBuffers();
383
384 if (bactivated)
386 }
387 else
388 {
389 WCHAR TestPath[MAX_PATH];
391 STARTUPINFOW si = { sizeof(si) };
393 BOOL created;
394
395 GetModuleFileNameW(NULL, TestPath, MAX_PATH);
396 separator = wcsrchr(TestPath, L'\\');
397 separator++;
398 wcscpy(separator, L"testdata\\ntdll_apitest.exe RtlDosApplyFileIsolationRedirection_Ustr DoTest");
399
400 created = CreateProcessW(NULL, TestPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
401 ok(created, "Expected CreateProcess to succeed\n");
402 if (created)
403 {
405 CloseHandle(pi.hThread);
406 CloseHandle(pi.hProcess);
407 }
408 }
409}
HANDLE _CreateActCtxFromFile(LPCWSTR FileName, int line)
static int argc
Definition: ServiceArgs.c:12
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4598
unsigned int BOOL
Definition: ntddk_ex.h:94
static refpint_t pi[]
Definition: server.c:96
static char ** test_argv
Definition: cursoricon.c:296
int winetest_get_mainargs(char ***pargv)
void winetest_wait_child_process(HANDLE process)
Definition: cookie.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ TestBuffers()

void TestBuffers ( )

Definition at line 142 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

143{
148
149 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
151 NULL,
152 NULL,
153 NULL,
155 &StringUsed,
156 NULL,
157 NULL,
158 NULL);
160
161 RtlInitEmptyUnicodeString(&Param, NULL, 0);
162 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
164 &Param,
165 NULL,
166 NULL,
168 &StringUsed,
169 NULL,
170 NULL,
171 NULL);
173
174 /* Tests for NULL termination of OriginalName */
175 Param.MaximumLength = Param.Length = 12 * sizeof(WCHAR);
176 Param.Buffer = L"comctl32.dllcrapcrap";
177 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
179 &Param,
180 NULL,
181 NULL,
183 &StringUsed,
184 NULL,
185 NULL,
186 NULL);
187 ok(Status ==STATUS_SUCCESS, "\n");
188
189 /* Tests for the Extension parameter */
190 RtlInitUnicodeString(&Param, L"comctl32.dll");
191 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
193 &Param,
194 NULL,
195 NULL,
197 &StringUsed,
198 NULL,
199 NULL,
200 NULL);
201 ok(Status ==STATUS_SUCCESS, "\n");
202
203 RtlInitUnicodeString(&Param, L"comctl32");
204 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
206 &Param,
207 NULL,
208 NULL,
210 &StringUsed,
211 NULL,
212 NULL,
213 NULL);
215
216 RtlInitUnicodeString(&Param, L"comctl32");
217 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
219 &Param,
220 &DotDll,
221 NULL,
223 &StringUsed,
224 NULL,
225 NULL,
226 NULL);
227 ok(Status ==STATUS_SUCCESS, "\n");
228
229 /* Tests for the DynamicString parameter */
230 RtlInitUnicodeString(&Param, L"comctl32.dll");
231 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
233 &Param,
234 NULL,
235 NULL,
237 &StringUsed,
238 NULL,
239 NULL,
240 NULL);
241 ok(Status ==STATUS_SUCCESS, "\n");
242 ok(DynamicString.Length >0 , "\n");
246 else
247 ok(DynamicString.Buffer != NULL, "Expected non NULL buffer\n");
248 ok(StringUsed == &DynamicString, "\n");
249
250 /* Tests for the StaticString parameter */
251 wcscpy(buffer, L"comctl32.dll");
253 StaticString.Length = sizeof(L"comctl32.dll");
255 Param = StaticString;
257 &Param,
258 NULL,
260 NULL,
261 &StringUsed,
262 NULL,
263 NULL,
264 NULL);
266
267 wcscpy(buffer, L"comctl32.dll");
269 StaticString.Length = sizeof(L"comctl32.dll");
273 NULL,
275 NULL,
276 &StringUsed,
277 NULL,
278 NULL,
279 NULL);
281
282 RtlInitUnicodeString(&Param, L"comctl32.dll");
283 RtlInitEmptyUnicodeString(&StaticString, buffer, sizeof(buffer));
285 &Param,
286 NULL,
288 NULL,
289 &StringUsed,
290 NULL,
291 NULL,
292 NULL);
293 ok(Status ==STATUS_SUCCESS, "\n");
294 ok(StaticString.Length >0 , "\n");
295 ok(StaticString.MaximumLength == sizeof(buffer) , "\n");
297 ok(wcslen(StaticString.Buffer) * sizeof(WCHAR) == StaticString.Length, "got %d and %d\n", wcslen(StaticString.Buffer) * sizeof(WCHAR) , StaticString.Length);
298 else
299 ok(StaticString.Length != 0, "Expected non 0 lenght\n");
300 ok(StringUsed == &StaticString, "\n");
301
302 RtlInitEmptyUnicodeString(&StaticString, buffer, 5 * sizeof(WCHAR));
304 &Param,
305 NULL,
307 NULL,
308 &StringUsed,
309 NULL,
310 NULL,
311 NULL);
312 ok(Status == STATUS_BUFFER_TOO_SMALL, "0x%lx\n", Status);
313
314 RtlInitUnicodeString(&Param, L"comctl32.dll");
315 RtlInitEmptyUnicodeString(&StaticString, buffer, sizeof(buffer));
316 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
318 &Param,
319 NULL,
322 &StringUsed,
323 NULL,
324 NULL,
325 NULL);
326 ok(Status ==STATUS_SUCCESS, "\n");
327 ok(StaticString.Length >0 , "\n");
328 ok(StaticString.MaximumLength == sizeof(buffer) , "\n");
330 ok(wcslen(StaticString.Buffer) * sizeof(WCHAR) == StaticString.Length, "got %d and %d\n", wcslen(StaticString.Buffer) * sizeof(WCHAR) , StaticString.Length);
331 else
332 ok(StaticString.Length != 0, "Expected non 0 lenght\n");
333 ok(DynamicString.Buffer == NULL, "\n");
334 ok(DynamicString.Length == 0, "\n");
335 ok(DynamicString.MaximumLength == 0, "\n");
336 ok(StringUsed == &StaticString, "\n");
337
338 /* Test a small buffer and a dynamic buffer */
339 RtlInitUnicodeString(&Param, L"comctl32.dll");
340 RtlInitEmptyUnicodeString(&StaticString, buffer, 5 * sizeof(WCHAR));
341 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
342 StaticString.Buffer[0] = 1;
344 &Param,
345 NULL,
348 &StringUsed,
349 NULL,
350 NULL,
351 NULL);
352 ok(Status ==STATUS_SUCCESS, "\n");
353 ok(StaticString.Buffer == buffer, "\n");
354 ok(StaticString.Length == 0 , "%d\n", StaticString.Length);
355 ok(StaticString.Buffer[0] == 0, "\n");
357 ok(DynamicString.Length >0 , "\n");
361 else
362 ok(DynamicString.Length != 0, "Expected non 0 lenght\n");
363
364 ok(StringUsed == &DynamicString, "\n");
365}
IN PUNICODE_STRING StaticString
IN PUNICODE_STRING IN PUNICODE_STRING DynamicString
IN PUNICODE_STRING IN PUNICODE_STRING IN PUNICODE_STRING * StringUsed
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI RtlDosApplyFileIsolationRedirection_Ustr(IN ULONG Flags, IN PUNICODE_STRING OriginalName, IN PUNICODE_STRING Extension, IN OUT PUNICODE_STRING StaticString, IN OUT PUNICODE_STRING DynamicString, IN OUT PUNICODE_STRING *NewName, IN PULONG NewFlags, IN PSIZE_T FileNameSize, IN PSIZE_T RequiredLength)
Definition: libsupp.c:820
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_SXS_KEY_NOT_FOUND
Definition: ntstatus.h:1389
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by START_TEST().

◆ TestRedirection()

void TestRedirection ( void  )

Definition at line 78 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

79{
80 WCHAR SystemDir[MAX_PATH];
81 WCHAR TestPath[MAX_PATH];
82 WCHAR ParameterBuffer[MAX_PATH];
85 int i;
86
87 GetSystemDirectoryW(SystemDir, MAX_PATH);
89 separator = wcsrchr(TestPath, L'\\');
90 separator++;
91 *separator = 0;
92
93 for (i = 0; i < _countof(Tests); i ++)
94 {
95 UNICODE_STRING OriginalName, DynamicString;
97
98 if (memcmp(Tests[i].Param, L"c:\\windows\\system32", 38) == 0)
99 {
100 wcscpy(ParameterBuffer, SystemDir);
101 wcscat(ParameterBuffer, &Tests[i].Param[19]);
102 }
103 else
104 {
105 wcscpy(ParameterBuffer, Tests[i].Param);
106 }
107
108 RtlInitUnicodeString(&OriginalName, ParameterBuffer);
109 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
110
112 &OriginalName,
113 &DotDll,
114 NULL,
116 &StringUsed,
117 NULL,
118 NULL,
119 NULL);
120 ok(Status == Tests[i].ExpectedStatus, "%d: Status 0x%lx, expected 0x%lx\n", Tests[i].testline, Status, Tests[i].ExpectedStatus);
121
122 if(Tests[i].ExpectedSubString && DynamicString.Buffer == NULL)
123 {
124 ok(0, "%d: Expected a returned string\n", Tests[i].testline);
125 }
126
127 if (Tests[i].ExpectedSubString && DynamicString.Buffer != NULL)
128 {
129 if (Tests[i].ExpectedSubString == EXPECT_IN_SAME_DIR)
130 {
131 ok(wcsstr(DynamicString.Buffer, TestPath) != 0, "%d: Expected string %S in %S\n", Tests[i].testline, TestPath, DynamicString.Buffer);
132 }
133 else
134 {
136 ok(wcsstr(DynamicString.Buffer, Tests[i].ExpectedSubString) != 0, "%d: Expected string %S in %S\n", Tests[i].testline, Tests[i].ExpectedSubString, DynamicString.Buffer);
137 }
138 }
139 }
140}
struct test_data Tests[]
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
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
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
NTSYSAPI NTSTATUS WINAPI RtlDowncaseUnicodeString(UNICODE_STRING *, const UNICODE_STRING *, BOOLEAN)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define _countof(array)
Definition: sndvol32.h:70

Referenced by START_TEST().

Variable Documentation

◆ DotDll

Definition at line 12 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

Referenced by TestBuffers(), and TestRedirection().

◆ Tests