https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7059421a23f1169dbb848…
commit 7059421a23f1169dbb848ced63177f89e6899217
Author: Giannis Adamopoulos <gadamopoulos(a)reactos.org>
AuthorDate: Wed Oct 4 11:10:59 2017 +0300
[NTDLL_APITEST] Add several tests for RtlDosApplyFileIsolationRedirection_Ustr
---
modules/rostests/apitests/ntdll/CMakeLists.txt | 1 +
.../RtlDosApplyFileIsolationRedirection_Ustr.c | 269 ++++++++++++++++++++-
modules/rostests/apitests/ntdll/ntdlltest.manifest | 16 ++
3 files changed, 280 insertions(+), 6 deletions(-)
diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt
b/modules/rostests/apitests/ntdll/CMakeLists.txt
index 42fc3fbdb8..c1a3aead68 100644
--- a/modules/rostests/apitests/ntdll/CMakeLists.txt
+++ b/modules/rostests/apitests/ntdll/CMakeLists.txt
@@ -77,3 +77,4 @@ add_rostests_file(TARGET ntdll_apitest SUBDIR testdata)
add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/ntdll_apitest.exe.local"
SUBDIR testdata)
add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/shell32.dll" SUBDIR
testdata)
add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/test.dll" SUBDIR testdata)
+add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/ntdlltest.manifest" SUBDIR
testdata)
diff --git a/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
b/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
index 9b9f15955b..fb2b51694a 100644
--- a/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
+++ b/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
@@ -33,6 +33,11 @@ struct test_data Tests[] =
{__LINE__, STATUS_SUCCESS, L"COMCTL32.DLL",
L"\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82"},
{__LINE__, STATUS_SUCCESS, L"comctl32.DLL",
L"\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82"},
{__LINE__, STATUS_SUCCESS, L"c:\\windows\\system32\\comctl32.DLL",
L"\\winsxs\\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82"},
+ /* Files defined in the manifest, one exists, one doesn't */
+ {__LINE__, STATUS_SUCCESS, L"deptest.dll", EXPECT_IN_SAME_DIR},
+ {__LINE__, STATUS_SUCCESS, L"adllfile.dll", EXPECT_IN_SAME_DIR},
+ /* A file that exists in the same dir but isn't mentioned in the manifest */
+ {__LINE__, STATUS_SUCCESS, L"fil1.txt", EXPECT_IN_SAME_DIR},
/* This is a weird case; the source doesn't exist but does get redirected */
{__LINE__, STATUS_SUCCESS, L"c:\\windows\\system32\\gdiplus.DLL",
L"\\winsxs\\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1."},
/* But redirecting gdiplus from a different directory doesn't work */
@@ -48,6 +53,28 @@ struct test_data Tests[] =
{__LINE__, STATUS_SUCCESS, L"c:\\shell32.dll", EXPECT_IN_SAME_DIR}
};
+HANDLE _CreateActCtxFromFile(LPCWSTR FileName, int line)
+{
+ ACTCTXW ActCtx = {sizeof(ACTCTX)};
+ HANDLE h;
+ WCHAR buffer[MAX_PATH] , *separator;
+
+ ok (GetModuleFileNameW(NULL, buffer, MAX_PATH), "GetModuleFileName
failed\n");
+ separator = wcsrchr(buffer, L'\\');
+ if (separator)
+ wcscpy(separator + 1, FileName);
+
+ ActCtx.lpSource = buffer;
+
+ SetLastError(0xdeaddead);
+ h = CreateActCtxW(&ActCtx);
+ ok_(__FILE__, line)(h != INVALID_HANDLE_VALUE, "CreateActCtx failed for
%S\n", FileName);
+ // In win10 last error is unchanged and in win2k3 it is ERROR_BAD_EXE_FORMAT
+ ok_(__FILE__, line)(GetLastError() == ERROR_BAD_EXE_FORMAT || GetLastError() ==
0xdeaddead, "Wrong last error %lu\n", GetLastError());
+
+ return h;
+}
+
void TestRedirection(void)
{
WCHAR SystemDir[MAX_PATH];
@@ -92,12 +119,6 @@ void TestRedirection(void)
NULL);
ok(Status == Tests[i].ExpectedStatus, "%d: Status 0x%lx, expected
0x%lx\n", Tests[i].testline, Status, Tests[i].ExpectedStatus);
- if (DynamicString.Buffer)
- {
- BOOL exists = RtlDoesFileExists_U(DynamicString.Buffer);
- ok(exists, "%d: Expected file %S to exist!\n", Tests[i].testline,
DynamicString.Buffer);
- }
-
if(Tests[i].ExpectedSubString && DynamicString.Buffer == NULL)
{
ok(0, "%d: Expected a returned string\n", Tests[i].testline);
@@ -118,6 +139,231 @@ void TestRedirection(void)
}
}
+void TestBuffers()
+{
+ UNICODE_STRING Param, DynamicString, StaticString;
+ PUNICODE_STRING StringUsed = NULL;
+ NTSTATUS Status;
+ WCHAR buffer[MAX_PATH];
+
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ NULL,
+ NULL,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_INVALID_PARAMETER, "0x%lx\n", Status);
+
+ RtlInitEmptyUnicodeString(&Param, NULL, 0);
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SXS_KEY_NOT_FOUND, "0x%lx\n", Status);
+
+ /* Tests for NULL termination of OriginalName */
+ Param.MaximumLength = Param.Length = 12 * sizeof(WCHAR);
+ Param.Buffer = L"comctl32.dllcrapcrap";
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+
+ /* Tests for the Extension parameter */
+ RtlInitUnicodeString(&Param, L"comctl32.dll");
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+
+ RtlInitUnicodeString(&Param, L"comctl32");
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SXS_KEY_NOT_FOUND, "0x%lx\n", Status);
+
+ RtlInitUnicodeString(&Param, L"comctl32");
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ &DotDll,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+
+ /* Tests for the DynamicString parameter */
+ RtlInitUnicodeString(&Param, L"comctl32.dll");
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ NULL,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+ ok(DynamicString.Length >0 , "\n");
+ ok(DynamicString.MaximumLength == DynamicString.Length + sizeof(WCHAR) ,
"\n");
+ if (DynamicString.Buffer && DynamicString.Length)
+ ok(wcslen(DynamicString.Buffer) * sizeof(WCHAR) == DynamicString.Length,
"got %d and %d\n", wcslen(DynamicString.Buffer) * sizeof(WCHAR) ,
DynamicString.Length);
+ else
+ ok(DynamicString.Buffer != NULL, "Expected non NULL buffer\n");
+ ok(StringUsed == &DynamicString, "\n");
+
+ /* Tests for the StaticString parameter */
+ wcscpy(buffer, L"comctl32.dll");
+ StaticString.Buffer = buffer;
+ StaticString.Length = sizeof(L"comctl32.dll");
+ StaticString.MaximumLength = sizeof(buffer);
+ Param = StaticString;
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ &StaticString,
+ NULL,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SXS_KEY_NOT_FOUND, "0x%lx\n", Status);
+
+ wcscpy(buffer, L"comctl32.dll");
+ StaticString.Buffer = buffer;
+ StaticString.Length = sizeof(L"comctl32.dll");
+ StaticString.MaximumLength = sizeof(buffer);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &StaticString,
+ NULL,
+ &StaticString,
+ NULL,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SXS_KEY_NOT_FOUND, "0x%lx\n", Status);
+
+ RtlInitUnicodeString(&Param, L"comctl32.dll");
+ RtlInitEmptyUnicodeString(&StaticString, buffer, sizeof(buffer));
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ &StaticString,
+ NULL,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+ ok(StaticString.Length >0 , "\n");
+ ok(StaticString.MaximumLength == sizeof(buffer) , "\n");
+ if (StaticString.Buffer && StaticString.Length)
+ ok(wcslen(StaticString.Buffer) * sizeof(WCHAR) == StaticString.Length, "got
%d and %d\n", wcslen(StaticString.Buffer) * sizeof(WCHAR) , StaticString.Length);
+ else
+ ok(StaticString.Length != 0, "Expected non 0 lenght\n");
+ ok(StringUsed == &StaticString, "\n");
+
+ RtlInitEmptyUnicodeString(&StaticString, buffer, 5 * sizeof(WCHAR));
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ &StaticString,
+ NULL,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status == STATUS_BUFFER_TOO_SMALL, "0x%lx\n", Status);
+
+ RtlInitUnicodeString(&Param, L"comctl32.dll");
+ RtlInitEmptyUnicodeString(&StaticString, buffer, sizeof(buffer));
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ &StaticString,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+ ok(StaticString.Length >0 , "\n");
+ ok(StaticString.MaximumLength == sizeof(buffer) , "\n");
+ if (StaticString.Buffer && StaticString.Length)
+ ok(wcslen(StaticString.Buffer) * sizeof(WCHAR) == StaticString.Length, "got
%d and %d\n", wcslen(StaticString.Buffer) * sizeof(WCHAR) , StaticString.Length);
+ else
+ ok(StaticString.Length != 0, "Expected non 0 lenght\n");
+ ok(DynamicString.Buffer == NULL, "\n");
+ ok(DynamicString.Length == 0, "\n");
+ ok(DynamicString.MaximumLength == 0, "\n");
+ ok(StringUsed == &StaticString, "\n");
+
+ /* Test a small buffer and a dynamic buffer */
+ RtlInitUnicodeString(&Param, L"comctl32.dll");
+ RtlInitEmptyUnicodeString(&StaticString, buffer, 5 * sizeof(WCHAR));
+ RtlInitEmptyUnicodeString(&DynamicString, NULL, 0);
+ StaticString.Buffer[0] = 1;
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &Param,
+ NULL,
+ &StaticString,
+ &DynamicString,
+ &StringUsed,
+ NULL,
+ NULL,
+ NULL);
+ ok(Status ==STATUS_SUCCESS, "\n");
+ ok(StaticString.Buffer == buffer, "\n");
+ ok(StaticString.Length == 0 , "%d\n", StaticString.Length);
+ ok(StaticString.Buffer[0] == 0, "\n");
+ ok(StaticString.MaximumLength == 5 * sizeof(WCHAR) , "%d\n",
StaticString.MaximumLength);
+ ok(DynamicString.Length >0 , "\n");
+ ok(DynamicString.MaximumLength == DynamicString.Length + sizeof(WCHAR) ,
"\n");
+ if (DynamicString.Buffer && DynamicString.Length)
+ ok(wcslen(DynamicString.Buffer) * sizeof(WCHAR) == DynamicString.Length,
"got %d and %d\n", wcslen(DynamicString.Buffer) * sizeof(WCHAR) ,
DynamicString.Length);
+ else
+ ok(DynamicString.Length != 0, "Expected non 0 lenght\n");
+
+ ok(StringUsed == &DynamicString, "\n");
+}
+
START_TEST(RtlDosApplyFileIsolationRedirection_Ustr)
{
int argc;
@@ -125,7 +371,18 @@ START_TEST(RtlDosApplyFileIsolationRedirection_Ustr)
argc = winetest_get_mainargs( &test_argv );
if (argc >= 3)
{
+ HANDLE h = _CreateActCtxFromFile(L"ntdlltest.manifest", __LINE__);
+ BOOL bactivated = FALSE;
+ ULONG_PTR cookie;
+
+ if (h != INVALID_HANDLE_VALUE)
+ bactivated = ActivateActCtx(h, &cookie);
+
TestRedirection();
+ TestBuffers();
+
+ if (bactivated)
+ DeactivateActCtx(0, cookie);
}
else
{
diff --git a/modules/rostests/apitests/ntdll/ntdlltest.manifest
b/modules/rostests/apitests/ntdll/ntdlltest.manifest
new file mode 100644
index 0000000000..a91a9b68a2
--- /dev/null
+++ b/modules/rostests/apitests/ntdll/ntdlltest.manifest
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
+ <assemblyIdentity type="win32" name="ntdll_apitest"
version="1.0.0.0"/>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type="win32"
name="Microsoft.Windows.GdiPlus" version="1.0.100.0"
language="*" processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"/>
+ </dependentAssembly>
+ </dependency>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="5.82.0.0"
language="*" processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"/>
+ </dependentAssembly>
+ </dependency>
+ <file name="deptest.dll"/>
+ <file name="adllfile.dll"/>
+</assembly>