ReactOS 0.4.15-dev-6694-g4ba8af9
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 ok_eq_hex(value, expected)   ok((value) == (expected), #value " = 0x%lx, expected 0x%lx\n", value, expected)
 
#define ok_eq_pointer(value, expected)   ok((value) == (expected), #value " = %p, expected %p\n", value, expected)
 
#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 13 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

◆ ok_eq_hex

#define ok_eq_hex (   value,
  expected 
)    ok((value) == (expected), #value " = 0x%lx, expected 0x%lx\n", value, expected)

Definition at line 10 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

◆ ok_eq_pointer

#define ok_eq_pointer (   value,
  expected 
)    ok((value) == (expected), #value " = %p, expected %p\n", value, expected)

Definition at line 11 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

Function Documentation

◆ _CreateActCtxFromFile()

HANDLE _CreateActCtxFromFile ( LPCWSTR  FileName,
int  line 
)

Definition at line 59 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

60{
61 ACTCTXW ActCtx = {sizeof(ACTCTX)};
62 HANDLE h;
64
65 ok (GetModuleFileNameW(NULL, buffer, MAX_PATH), "GetModuleFileName failed\n");
66 separator = wcsrchr(buffer, L'\\');
67 if (separator)
69
70 ActCtx.lpSource = buffer;
71
72 SetLastError(0xdeaddead);
74 ok_(__FILE__, line)(h != INVALID_HANDLE_VALUE, "CreateActCtx failed for %S\n", FileName);
75 // In win10 last error is unchanged and in win2k3 it is ERROR_BAD_EXE_FORMAT
76 ok_(__FILE__, line)(GetLastError() == ERROR_BAD_EXE_FORMAT || GetLastError() == 0xdeaddead, "Wrong last error %lu\n", GetLastError());
77
78 return h;
79}
#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:104
struct _FileName FileName
Definition: fatprocs.h:896
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 370 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

371{
372 int argc;
373 char **test_argv;
375 if (argc >= 3)
376 {
377 HANDLE h = _CreateActCtxFromFile(L"ntdlltest.manifest", __LINE__);
378 BOOL bactivated = FALSE;
380
381 if (h != INVALID_HANDLE_VALUE)
382 bactivated = ActivateActCtx(h, &cookie);
383
385 TestBuffers();
386
387 if (bactivated)
389 }
390 else
391 {
392 WCHAR TestPath[MAX_PATH];
394 STARTUPINFOW si = { sizeof(si) };
396 BOOL created;
397
398 GetModuleFileNameW(NULL, TestPath, MAX_PATH);
399 separator = wcsrchr(TestPath, L'\\');
400 separator++;
401 wcscpy(separator, L"testdata\\ntdll_apitest.exe RtlDosApplyFileIsolationRedirection_Ustr DoTest");
402
403 created = CreateProcessW(NULL, TestPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
404 ok(created, "Expected CreateProcess to succeed\n");
405 if (created)
406 {
408 CloseHandle(pi.hThread);
409 CloseHandle(pi.hProcess);
410 }
411 }
412}
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:4592
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 145 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

146{
151
152 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
154 NULL,
155 NULL,
156 NULL,
158 &StringUsed,
159 NULL,
160 NULL,
161 NULL);
163
164 RtlInitEmptyUnicodeString(&Param, NULL, 0);
165 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
167 &Param,
168 NULL,
169 NULL,
171 &StringUsed,
172 NULL,
173 NULL,
174 NULL);
176
177 /* Tests for NULL termination of OriginalName */
178 Param.MaximumLength = Param.Length = 12 * sizeof(WCHAR);
179 Param.Buffer = L"comctl32.dllcrapcrap";
180 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
182 &Param,
183 NULL,
184 NULL,
186 &StringUsed,
187 NULL,
188 NULL,
189 NULL);
190 ok(Status ==STATUS_SUCCESS, "\n");
191
192 /* Tests for the Extension parameter */
193 RtlInitUnicodeString(&Param, L"comctl32.dll");
194 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
196 &Param,
197 NULL,
198 NULL,
200 &StringUsed,
201 NULL,
202 NULL,
203 NULL);
204 ok(Status ==STATUS_SUCCESS, "\n");
205
206 RtlInitUnicodeString(&Param, L"comctl32");
207 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
209 &Param,
210 NULL,
211 NULL,
213 &StringUsed,
214 NULL,
215 NULL,
216 NULL);
218
219 RtlInitUnicodeString(&Param, L"comctl32");
220 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
222 &Param,
223 &DotDll,
224 NULL,
226 &StringUsed,
227 NULL,
228 NULL,
229 NULL);
230 ok(Status ==STATUS_SUCCESS, "\n");
231
232 /* Tests for the DynamicString parameter */
233 RtlInitUnicodeString(&Param, L"comctl32.dll");
234 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
236 &Param,
237 NULL,
238 NULL,
240 &StringUsed,
241 NULL,
242 NULL,
243 NULL);
244 ok(Status ==STATUS_SUCCESS, "\n");
245 ok(DynamicString.Length >0 , "\n");
249 else
250 ok(DynamicString.Buffer != NULL, "Expected non NULL buffer\n");
251 ok(StringUsed == &DynamicString, "\n");
252
253 /* Tests for the StaticString parameter */
254 wcscpy(buffer, L"comctl32.dll");
256 StaticString.Length = sizeof(L"comctl32.dll");
258 Param = StaticString;
260 &Param,
261 NULL,
263 NULL,
264 &StringUsed,
265 NULL,
266 NULL,
267 NULL);
269
270 wcscpy(buffer, L"comctl32.dll");
272 StaticString.Length = sizeof(L"comctl32.dll");
276 NULL,
278 NULL,
279 &StringUsed,
280 NULL,
281 NULL,
282 NULL);
284
285 RtlInitUnicodeString(&Param, L"comctl32.dll");
286 RtlInitEmptyUnicodeString(&StaticString, buffer, sizeof(buffer));
288 &Param,
289 NULL,
291 NULL,
292 &StringUsed,
293 NULL,
294 NULL,
295 NULL);
296 ok(Status ==STATUS_SUCCESS, "\n");
297 ok(StaticString.Length >0 , "\n");
298 ok(StaticString.MaximumLength == sizeof(buffer) , "\n");
300 ok(wcslen(StaticString.Buffer) * sizeof(WCHAR) == StaticString.Length, "got %d and %d\n", wcslen(StaticString.Buffer) * sizeof(WCHAR) , StaticString.Length);
301 else
302 ok(StaticString.Length != 0, "Expected non 0 lenght\n");
303 ok(StringUsed == &StaticString, "\n");
304
305 RtlInitEmptyUnicodeString(&StaticString, buffer, 5 * sizeof(WCHAR));
307 &Param,
308 NULL,
310 NULL,
311 &StringUsed,
312 NULL,
313 NULL,
314 NULL);
315 ok(Status == STATUS_BUFFER_TOO_SMALL, "0x%lx\n", Status);
316
317 RtlInitUnicodeString(&Param, L"comctl32.dll");
318 RtlInitEmptyUnicodeString(&StaticString, buffer, sizeof(buffer));
319 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
321 &Param,
322 NULL,
325 &StringUsed,
326 NULL,
327 NULL,
328 NULL);
329 ok(Status ==STATUS_SUCCESS, "\n");
330 ok(StaticString.Length >0 , "\n");
331 ok(StaticString.MaximumLength == sizeof(buffer) , "\n");
333 ok(wcslen(StaticString.Buffer) * sizeof(WCHAR) == StaticString.Length, "got %d and %d\n", wcslen(StaticString.Buffer) * sizeof(WCHAR) , StaticString.Length);
334 else
335 ok(StaticString.Length != 0, "Expected non 0 lenght\n");
336 ok(DynamicString.Buffer == NULL, "\n");
337 ok(DynamicString.Length == 0, "\n");
338 ok(DynamicString.MaximumLength == 0, "\n");
339 ok(StringUsed == &StaticString, "\n");
340
341 /* Test a small buffer and a dynamic buffer */
342 RtlInitUnicodeString(&Param, L"comctl32.dll");
343 RtlInitEmptyUnicodeString(&StaticString, buffer, 5 * sizeof(WCHAR));
344 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
345 StaticString.Buffer[0] = 1;
347 &Param,
348 NULL,
351 &StringUsed,
352 NULL,
353 NULL,
354 NULL);
355 ok(Status ==STATUS_SUCCESS, "\n");
356 ok(StaticString.Buffer == buffer, "\n");
357 ok(StaticString.Length == 0 , "%d\n", StaticString.Length);
358 ok(StaticString.Buffer[0] == 0, "\n");
360 ok(DynamicString.Length >0 , "\n");
364 else
365 ok(DynamicString.Length != 0, "Expected non 0 lenght\n");
366
367 ok(StringUsed == &DynamicString, "\n");
368}
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:821
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 81 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

82{
83 WCHAR SystemDir[MAX_PATH];
84 WCHAR TestPath[MAX_PATH];
85 WCHAR ParameterBuffer[MAX_PATH];
88 int i;
89
90 GetSystemDirectoryW(SystemDir, MAX_PATH);
92 separator = wcsrchr(TestPath, L'\\');
93 separator++;
94 *separator = 0;
95
96 for (i = 0; i < _countof(Tests); i ++)
97 {
98 UNICODE_STRING OriginalName, DynamicString;
100
101 if (memcmp(Tests[i].Param, L"c:\\windows\\system32", 38) == 0)
102 {
103 wcscpy(ParameterBuffer, SystemDir);
104 wcscat(ParameterBuffer, &Tests[i].Param[19]);
105 }
106 else
107 {
108 wcscpy(ParameterBuffer, Tests[i].Param);
109 }
110
111 RtlInitUnicodeString(&OriginalName, ParameterBuffer);
112 RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
113
115 &OriginalName,
116 &DotDll,
117 NULL,
119 &StringUsed,
120 NULL,
121 NULL,
122 NULL);
123 ok(Status == Tests[i].ExpectedStatus, "%d: Status 0x%lx, expected 0x%lx\n", Tests[i].testline, Status, Tests[i].ExpectedStatus);
124
125 if(Tests[i].ExpectedSubString && DynamicString.Buffer == NULL)
126 {
127 ok(0, "%d: Expected a returned string\n", Tests[i].testline);
128 }
129
130 if (Tests[i].ExpectedSubString && DynamicString.Buffer != NULL)
131 {
132 if (Tests[i].ExpectedSubString == EXPECT_IN_SAME_DIR)
133 {
134 ok(wcsstr(DynamicString.Buffer, TestPath) != 0, "%d: Expected string %S in %S\n", Tests[i].testline, TestPath, DynamicString.Buffer);
135 }
136 else
137 {
139 ok(wcsstr(DynamicString.Buffer, Tests[i].ExpectedSubString) != 0, "%d: Expected string %S in %S\n", Tests[i].testline, Tests[i].ExpectedSubString, DynamicString.Buffer);
140 }
141 }
142 }
143}
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:68

Referenced by START_TEST().

Variable Documentation

◆ DotDll

Definition at line 15 of file RtlDosApplyFileIsolationRedirection_Ustr.c.

Referenced by TestBuffers(), and TestRedirection().

◆ Tests