Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Supersedes: 213297-213305
I'll resend the HID patches later, I'd really like to move them to dlls/hid/tests, unless there's reasons not to, probably by copying the code from dlls/ntoskrnl.exe/tests.
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index dc10497caee..4434e61bcb8 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -946,7 +946,7 @@ static void do_return_status(ULONG ioctl, struct return_status_params *params) static void test_return_status(void) { struct return_status_params params; - unsigned int i, j, k; + unsigned int i, j, k, old_threshold;
static const ULONG method_tests[] = { @@ -968,6 +968,9 @@ static void test_return_status(void) 0xceadbeef, };
+ old_threshold = winetest_mute_threshold; + winetest_mute_threshold = 1; + for (i = 0; i < ARRAY_SIZE(status_tests); ++i) { for (j = 0; j < ARRAY_SIZE(status_tests); ++j) @@ -989,6 +992,8 @@ static void test_return_status(void) } } } + + winetest_mute_threshold = old_threshold; }
static BOOL compare_unicode_string(const WCHAR *buffer, ULONG len, const WCHAR *expect)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 343 ++++++++++++----------------- 1 file changed, 135 insertions(+), 208 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 4434e61bcb8..86d04eab59f 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1347,6 +1347,137 @@ static void add_file_to_catalog(HANDLE catalog, const WCHAR *file) } }
+static void pnp_driver_stop(void) +{ + SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; + WCHAR path[MAX_PATH], dest[MAX_PATH], *filepart; + SC_HANDLE manager, service; + HDEVINFO set; + HANDLE file; + BOOL ret; + DWORD i; + + set = SetupDiCreateDeviceInfoList(NULL, NULL); + ok(set != INVALID_HANDLE_VALUE, "failed to create device list, error %u\n", GetLastError()); + + ret = SetupDiOpenDeviceInfoW(set, L"root\winetest\0", NULL, 0, &device); + ok(ret, "failed to open device, error %u\n", GetLastError()); + + ret = SetupDiCallClassInstaller(DIF_REMOVE, set, &device); + ok(ret, "failed to remove device, error %#x\n", GetLastError()); + + file = CreateFileW(L"\\?\root#winetest#0#{deadbeef-29ef-4538-a5fd-b69573a362c0}", 0, 0, NULL, OPEN_EXISTING, 0, NULL); + ok(file == INVALID_HANDLE_VALUE, "expected failure\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError()); + + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "failed to destroy set, error %#x\n", GetLastError()); + + set = SetupDiGetClassDevsA(NULL, "wine", NULL, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError()); + + for (i = 0; SetupDiEnumDeviceInfo(set, i, &device); ++i) + { + ret = SetupDiCallClassInstaller(DIF_REMOVE, set, &device); + ok(ret, "failed to remove device, error %#x\n", GetLastError()); + } + + /* Windows stops the service but does not delete it. */ + manager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT); + ok(!!manager, "failed to open service manager, error %u\n", GetLastError()); + service = OpenServiceW(manager, L"winetest", SERVICE_STOP | DELETE); + ok(!!service, "failed to open service, error %u\n", GetLastError()); + unload_driver(service); + CloseServiceHandle(manager); + + cat_okfile(); + + GetFullPathNameW(L"winetest.inf", ARRAY_SIZE(path), path, NULL); + ret = SetupCopyOEMInfW(path, NULL, 0, 0, dest, ARRAY_SIZE(dest), NULL, &filepart); + ok(ret, "Failed to copy INF, error %#x\n", GetLastError()); + ret = SetupUninstallOEMInfW(filepart, 0, NULL); + ok(ret, "Failed to uninstall INF, error %u\n", GetLastError()); + + ret = DeleteFileW(L"winetest.cat"); + ok(ret, "Failed to delete file, error %u\n", GetLastError()); + ret = DeleteFileW(L"winetest.inf"); + ok(ret, "Failed to delete file, error %u\n", GetLastError()); + ret = DeleteFileW(L"winetest.sys"); + ok(ret, "Failed to delete file, error %u\n", GetLastError()); + /* Windows 10 apparently deletes the image in SetupUninstallOEMInf(). */ + ret = DeleteFileW(L"C:/windows/system32/drivers/winetest.sys"); + ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "Failed to delete file, error %u\n", GetLastError()); +} + +static void pnp_driver_start(struct testsign_context *ctx, const WCHAR *resource) +{ + static const WCHAR hardware_id[] = L"test_hardware_id\0"; + SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; + WCHAR path[MAX_PATH], filename[MAX_PATH]; + BOOL ret, need_reboot; + HANDLE catalog; + HDEVINFO set; + FILE *f; + + load_resource(resource, filename); + ret = MoveFileExW(filename, L"winetest.sys", MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING); + ok(ret, "failed to move file, error %u\n", GetLastError()); + + f = fopen("winetest.inf", "w"); + ok(!!f, "failed to open winetest.inf: %s\n", strerror(errno)); + fputs(inf_text, f); + fclose(f); + + /* Create the catalog file. */ + + catalog = CryptCATOpen((WCHAR *)L"winetest.cat", CRYPTCAT_OPEN_CREATENEW, 0, CRYPTCAT_VERSION_1, 0); + ok(catalog != INVALID_HANDLE_VALUE, "Failed to create catalog, error %#x\n", GetLastError()); + + ret = !!CryptCATPutCatAttrInfo(catalog, (WCHAR *)L"HWID1", + CRYPTCAT_ATTR_NAMEASCII | CRYPTCAT_ATTR_DATAASCII | CRYPTCAT_ATTR_AUTHENTICATED, + sizeof(L"test_hardware_id"), (BYTE *)L"test_hardware_id"); + todo_wine ok(ret, "failed to add attribute, error %#x\n", GetLastError()); + + ret = !!CryptCATPutCatAttrInfo(catalog, (WCHAR *)L"OS", + CRYPTCAT_ATTR_NAMEASCII | CRYPTCAT_ATTR_DATAASCII | CRYPTCAT_ATTR_AUTHENTICATED, + sizeof(L"VistaX64"), (BYTE *)L"VistaX64"); + todo_wine ok(ret, "failed to add attribute, error %#x\n", GetLastError()); + + add_file_to_catalog(catalog, L"winetest.sys"); + add_file_to_catalog(catalog, L"winetest.inf"); + + ret = CryptCATPersistStore(catalog); + todo_wine ok(ret, "Failed to write catalog, error %u\n", GetLastError()); + + ret = CryptCATClose(catalog); + ok(ret, "Failed to close catalog, error %u\n", GetLastError()); + + testsign_sign(ctx, L"winetest.cat"); + + /* Install the driver. */ + + set = SetupDiCreateDeviceInfoList(NULL, NULL); + ok(set != INVALID_HANDLE_VALUE, "failed to create device list, error %#x\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoW(set, L"root\winetest\0", &GUID_NULL, NULL, NULL, 0, &device); + ok(ret, "failed to create device, error %#x\n", GetLastError()); + + ret = SetupDiSetDeviceRegistryPropertyW( set, &device, SPDRP_HARDWAREID, + (const BYTE *)hardware_id, sizeof(hardware_id) ); + ok(ret, "failed to create set hardware ID, error %#x\n", GetLastError()); + + ret = SetupDiCallClassInstaller(DIF_REGISTERDEVICE, set, &device); + ok(ret, "failed to register device, error %#x\n", GetLastError()); + + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "failed to destroy set, error %u\n", GetLastError()); + + GetFullPathNameW(L"winetest.inf", ARRAY_SIZE(path), path, NULL); + ret = UpdateDriverForPlugAndPlayDevicesW(NULL, hardware_id, path, INSTALLFLAG_FORCE, &need_reboot); + ok(ret, "failed to install device, error %#x\n", GetLastError()); + ok(!need_reboot, "expected no reboot necessary\n"); +} + static const GUID bus_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc1}}; static const GUID child_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc2}};
@@ -1705,127 +1836,15 @@ static void test_pnp_devices(void)
static void test_pnp_driver(struct testsign_context *ctx) { - static const char hardware_id[] = "test_hardware_id\0"; - char path[MAX_PATH], dest[MAX_PATH], *filepart; - SP_DEVINFO_DATA device = {sizeof(device)}; char cwd[MAX_PATH], tempdir[MAX_PATH]; - WCHAR driver_filename[MAX_PATH]; - SC_HANDLE manager, service; - BOOL ret, need_reboot; - HANDLE catalog, file; - unsigned int i; - HDEVINFO set; - FILE *f;
GetCurrentDirectoryA(ARRAY_SIZE(cwd), cwd); GetTempPathA(ARRAY_SIZE(tempdir), tempdir); SetCurrentDirectoryA(tempdir);
- load_resource(L"driver_pnp.dll", driver_filename); - ret = MoveFileExW(driver_filename, L"winetest.sys", MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING); - ok(ret, "failed to move file, error %u\n", GetLastError()); - - f = fopen("winetest.inf", "w"); - ok(!!f, "failed to open winetest.inf: %s\n", strerror(errno)); - fputs(inf_text, f); - fclose(f); - - /* Create the catalog file. */ - - catalog = CryptCATOpen((WCHAR *)L"winetest.cat", CRYPTCAT_OPEN_CREATENEW, 0, CRYPTCAT_VERSION_1, 0); - ok(catalog != INVALID_HANDLE_VALUE, "Failed to create catalog, error %#x\n", GetLastError()); - - ret = !!CryptCATPutCatAttrInfo(catalog, (WCHAR *)L"HWID1", - CRYPTCAT_ATTR_NAMEASCII | CRYPTCAT_ATTR_DATAASCII | CRYPTCAT_ATTR_AUTHENTICATED, - sizeof(L"test_hardware_id"), (BYTE *)L"test_hardware_id"); - todo_wine ok(ret, "failed to add attribute, error %#x\n", GetLastError()); - - ret = !!CryptCATPutCatAttrInfo(catalog, (WCHAR *)L"OS", - CRYPTCAT_ATTR_NAMEASCII | CRYPTCAT_ATTR_DATAASCII | CRYPTCAT_ATTR_AUTHENTICATED, - sizeof(L"VistaX64"), (BYTE *)L"VistaX64"); - todo_wine ok(ret, "failed to add attribute, error %#x\n", GetLastError()); - - add_file_to_catalog(catalog, L"winetest.sys"); - add_file_to_catalog(catalog, L"winetest.inf"); - - ret = CryptCATPersistStore(catalog); - todo_wine ok(ret, "Failed to write catalog, error %u\n", GetLastError()); - - ret = CryptCATClose(catalog); - ok(ret, "Failed to close catalog, error %u\n", GetLastError()); - - testsign_sign(ctx, L"winetest.cat"); - - /* Install the driver. */ - - set = SetupDiCreateDeviceInfoList(NULL, NULL); - ok(set != INVALID_HANDLE_VALUE, "failed to create device list, error %#x\n", GetLastError()); - - ret = SetupDiCreateDeviceInfoA(set, "root\winetest\0", &GUID_NULL, NULL, NULL, 0, &device); - ok(ret, "failed to create device, error %#x\n", GetLastError()); - - ret = SetupDiSetDeviceRegistryPropertyA( set, &device, SPDRP_HARDWAREID, - (const BYTE *)hardware_id, sizeof(hardware_id) ); - ok(ret, "failed to create set hardware ID, error %#x\n", GetLastError()); - - ret = SetupDiCallClassInstaller(DIF_REGISTERDEVICE, set, &device); - ok(ret, "failed to register device, error %#x\n", GetLastError()); - - GetFullPathNameA("winetest.inf", sizeof(path), path, NULL); - ret = UpdateDriverForPlugAndPlayDevicesA(NULL, hardware_id, path, INSTALLFLAG_FORCE, &need_reboot); - ok(ret, "failed to install device, error %#x\n", GetLastError()); - ok(!need_reboot, "expected no reboot necessary\n"); - - /* Tests. */ - + pnp_driver_start(ctx, L"driver_pnp.dll"); test_pnp_devices(); - - /* Clean up. */ - - ret = SetupDiCallClassInstaller(DIF_REMOVE, set, &device); - ok(ret, "failed to remove device, error %#x\n", GetLastError()); - - file = CreateFileA("\\?\root#winetest#0#{deadbeef-29ef-4538-a5fd-b69573a362c0}", 0, 0, NULL, OPEN_EXISTING, 0, NULL); - ok(file == INVALID_HANDLE_VALUE, "expected failure\n"); - ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError()); - - ret = SetupDiDestroyDeviceInfoList(set); - ok(ret, "failed to destroy set, error %#x\n", GetLastError()); - - set = SetupDiGetClassDevsA(NULL, "wine", NULL, DIGCF_ALLCLASSES); - ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError()); - - for (i = 0; SetupDiEnumDeviceInfo(set, i, &device); ++i) - { - ret = SetupDiCallClassInstaller(DIF_REMOVE, set, &device); - ok(ret, "failed to remove device, error %#x\n", GetLastError()); - } - - /* Windows stops the service but does not delete it. */ - manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT); - ok(!!manager, "failed to open service manager, error %u\n", GetLastError()); - service = OpenServiceA(manager, "winetest", SERVICE_STOP | DELETE); - ok(!!service, "failed to open service, error %u\n", GetLastError()); - unload_driver(service); - CloseServiceHandle(manager); - - cat_okfile(); - - GetFullPathNameA("winetest.inf", sizeof(path), path, NULL); - ret = SetupCopyOEMInfA(path, NULL, 0, 0, dest, sizeof(dest), NULL, &filepart); - ok(ret, "Failed to copy INF, error %#x\n", GetLastError()); - ret = SetupUninstallOEMInfA(filepart, 0, NULL); - ok(ret, "Failed to uninstall INF, error %u\n", GetLastError()); - - ret = DeleteFileA("winetest.cat"); - ok(ret, "Failed to delete file, error %u\n", GetLastError()); - ret = DeleteFileA("winetest.inf"); - ok(ret, "Failed to delete file, error %u\n", GetLastError()); - ret = DeleteFileA("winetest.sys"); - ok(ret, "Failed to delete file, error %u\n", GetLastError()); - /* Windows 10 apparently deletes the image in SetupUninstallOEMInf(). */ - ret = DeleteFileA("C:/windows/system32/drivers/winetest.sys"); - ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "Failed to delete file, error %u\n", GetLastError()); + pnp_driver_stop();
SetCurrentDirectoryA(cwd); } @@ -3302,18 +3321,9 @@ static void test_hid_device(DWORD report_id, DWORD polled)
static void test_hid_driver(struct testsign_context *ctx, DWORD report_id, DWORD polled) { - static const char hardware_id[] = "test_hardware_id\0"; - char path[MAX_PATH], dest[MAX_PATH], *filepart; - SP_DEVINFO_DATA device = {sizeof(device)}; char cwd[MAX_PATH], tempdir[MAX_PATH]; - WCHAR driver_filename[MAX_PATH]; - SC_HANDLE manager, service; - BOOL ret, need_reboot; - HANDLE catalog, file; LSTATUS status; - HDEVINFO set; HKEY hkey; - FILE *f;
GetCurrentDirectoryA(ARRAY_SIZE(cwd), cwd); GetTempPathA(ARRAY_SIZE(tempdir), tempdir); @@ -3328,92 +3338,9 @@ static void test_hid_driver(struct testsign_context *ctx, DWORD report_id, DWORD status = RegSetValueExW(hkey, L"PolledMode", 0, REG_DWORD, (void *)&polled, sizeof(polled)); ok(!status, "RegSetValueExW returned %#x\n", status);
- load_resource(L"driver_hid.dll", driver_filename); - ret = MoveFileExW(driver_filename, L"winetest.sys", MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING); - ok(ret, "failed to move file, error %u\n", GetLastError()); - - f = fopen("winetest.inf", "w"); - ok(!!f, "failed to open winetest.inf: %s\n", strerror(errno)); - fputs(inf_text, f); - fclose(f); - - /* Create the catalog file. */ - - catalog = CryptCATOpen((WCHAR *)L"winetest.cat", CRYPTCAT_OPEN_CREATENEW, 0, CRYPTCAT_VERSION_1, 0); - ok(catalog != INVALID_HANDLE_VALUE, "Failed to create catalog, error %#x\n", GetLastError()); - - add_file_to_catalog(catalog, L"winetest.sys"); - add_file_to_catalog(catalog, L"winetest.inf"); - - ret = CryptCATPersistStore(catalog); - todo_wine ok(ret, "Failed to write catalog, error %u\n", GetLastError()); - - ret = CryptCATClose(catalog); - ok(ret, "Failed to close catalog, error %u\n", GetLastError()); - - testsign_sign(ctx, L"winetest.cat"); - - /* Install the driver. */ - - set = SetupDiCreateDeviceInfoList(NULL, NULL); - ok(set != INVALID_HANDLE_VALUE, "failed to create device list, error %#x\n", GetLastError()); - - ret = SetupDiCreateDeviceInfoA(set, "root\winetest\0", &GUID_NULL, NULL, NULL, 0, &device); - ok(ret, "failed to create device, error %#x\n", GetLastError()); - - ret = SetupDiSetDeviceRegistryPropertyA( set, &device, SPDRP_HARDWAREID, - (const BYTE *)hardware_id, sizeof(hardware_id) ); - ok(ret, "failed to create set hardware ID, error %#x\n", GetLastError()); - - ret = SetupDiCallClassInstaller(DIF_REGISTERDEVICE, set, &device); - ok(ret, "failed to register device, error %#x\n", GetLastError()); - - GetFullPathNameA("winetest.inf", sizeof(path), path, NULL); - ret = UpdateDriverForPlugAndPlayDevicesA(NULL, hardware_id, path, INSTALLFLAG_FORCE, &need_reboot); - ok(ret, "failed to install device, error %#x\n", GetLastError()); - ok(!need_reboot, "expected no reboot necessary\n"); - - /* Tests. */ - + pnp_driver_start(ctx, L"driver_hid.dll"); test_hid_device(report_id, polled); - - /* Clean up. */ - - ret = SetupDiCallClassInstaller(DIF_REMOVE, set, &device); - ok(ret, "failed to remove device, error %#x\n", GetLastError()); - - file = CreateFileA("\\?\root#winetest#0#{deadbeef-29ef-4538-a5fd-b69573a362c0}", 0, 0, NULL, OPEN_EXISTING, 0, NULL); - ok(file == INVALID_HANDLE_VALUE, "expected failure\n"); - ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError()); - - ret = SetupDiDestroyDeviceInfoList(set); - ok(ret, "failed to destroy set, error %#x\n", GetLastError()); - - /* Windows stops the service but does not delete it. */ - manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT); - ok(!!manager, "failed to open service manager, error %u\n", GetLastError()); - service = OpenServiceA(manager, "winetest", SERVICE_STOP | DELETE); - ok(!!service, "failed to open service, error %u\n", GetLastError()); - unload_driver(service); - CloseServiceHandle(manager); - - cat_okfile(); - - GetFullPathNameA("winetest.inf", sizeof(path), path, NULL); - ret = SetupCopyOEMInfA(path, NULL, 0, 0, dest, sizeof(dest), NULL, &filepart); - ok(ret, "Failed to copy INF, error %#x\n", GetLastError()); - ret = SetupUninstallOEMInfA(filepart, 0, NULL); - ok(ret, "Failed to uninstall INF, error %u\n", GetLastError()); - - ret = DeleteFileA("winetest.cat"); - ok(ret, "Failed to delete file, error %u\n", GetLastError()); - ret = DeleteFileA("winetest.inf"); - ok(ret, "Failed to delete file, error %u\n", GetLastError()); - ret = DeleteFileA("winetest.sys"); - ok(ret, "Failed to delete file, error %u\n", GetLastError()); - /* Windows 10 apparently deletes the image in SetupUninstallOEMInf(). */ - ret = DeleteFileA("C:/windows/system32/drivers/winetest.sys"); - ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "Failed to delete file, error %u\n", GetLastError()); + pnp_driver_stop();
SetCurrentDirectoryA(cwd); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 86d04eab59f..4221bc4d9fb 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -92,10 +92,11 @@ struct testsign_context HCERTSTORE root_store, publisher_store; };
+static const WCHAR container_name[] = L"wine_testsign"; + static BOOL testsign_create_cert(struct testsign_context *ctx) { BYTE encoded_name[100], encoded_key_id[200], public_key_info_buffer[1000]; - WCHAR container_name[26]; BYTE hash_buffer[16], cert_buffer[1000], provider_nameA[100], serial[16]; CERT_PUBLIC_KEY_INFO *public_key_info = (CERT_PUBLIC_KEY_INFO *)public_key_info_buffer; CRYPT_KEY_PROV_INFO provider_info = {0}; @@ -110,10 +111,13 @@ static BOOL testsign_create_cert(struct testsign_context *ctx)
memset(ctx, 0, sizeof(*ctx));
- srand(time(NULL)); - swprintf(container_name, ARRAY_SIZE(container_name), L"wine_testsign%u", rand()); - ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); + if (!ret && GetLastError() == NTE_EXISTS) + { + ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); + ok(ret, "Failed to delete container, error %#x\n", GetLastError()); + ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); + } ok(ret, "Failed to create container, error %#x\n", GetLastError());
ret = CryptGenKey(ctx->provider, AT_SIGNATURE, CRYPT_EXPORTABLE, &key); @@ -245,6 +249,9 @@ static void testsign_cleanup(struct testsign_context *ctx)
ret = CryptReleaseContext(ctx->provider, 0); ok(ret, "failed to release context, error %u\n", GetLastError()); + + ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); + ok(ret, "Failed to delete container, error %#x\n", GetLastError()); }
static void testsign_sign(struct testsign_context *ctx, const WCHAR *filename)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 4221bc4d9fb..b7926232cfb 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -87,7 +87,6 @@ static void load_resource(const WCHAR *name, WCHAR *filename)
struct testsign_context { - HCRYPTPROV provider; const CERT_CONTEXT *cert, *root_cert, *publisher_cert; HCERTSTORE root_store, publisher_store; }; @@ -105,26 +104,27 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) CERT_INFO cert_info = {0}; WCHAR provider_nameW[100]; CERT_EXTENSION extension; + HCRYPTPROV provider; HCRYPTKEY key; DWORD size; BOOL ret;
memset(ctx, 0, sizeof(*ctx));
- ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); + ret = CryptAcquireContextW(&provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { - ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); + ret = CryptAcquireContextW(&provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "Failed to delete container, error %#x\n", GetLastError()); - ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); + ret = CryptAcquireContextW(&provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); } ok(ret, "Failed to create container, error %#x\n", GetLastError());
- ret = CryptGenKey(ctx->provider, AT_SIGNATURE, CRYPT_EXPORTABLE, &key); + ret = CryptGenKey(provider, AT_SIGNATURE, CRYPT_EXPORTABLE, &key); ok(ret, "Failed to create key, error %#x\n", GetLastError()); ret = CryptDestroyKey(key); ok(ret, "Failed to destroy key, error %#x\n", GetLastError()); - ret = CryptGetUserKey(ctx->provider, AT_SIGNATURE, &key); + ret = CryptGetUserKey(provider, AT_SIGNATURE, &key); ok(ret, "Failed to get user key, error %#x\n", GetLastError()); ret = CryptDestroyKey(key); ok(ret, "Failed to destroy key, error %#x\n", GetLastError()); @@ -136,12 +136,12 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) key_info.CertIssuer.pbData = encoded_name;
size = sizeof(public_key_info_buffer); - ret = CryptExportPublicKeyInfo(ctx->provider, AT_SIGNATURE, X509_ASN_ENCODING, public_key_info, &size); + ret = CryptExportPublicKeyInfo(provider, AT_SIGNATURE, X509_ASN_ENCODING, public_key_info, &size); ok(ret, "Failed to export public key, error %#x\n", GetLastError()); cert_info.SubjectPublicKeyInfo = *public_key_info;
size = sizeof(hash_buffer); - ret = CryptHashPublicKeyInfo(ctx->provider, CALG_MD5, 0, X509_ASN_ENCODING, public_key_info, hash_buffer, &size); + ret = CryptHashPublicKeyInfo(provider, CALG_MD5, 0, X509_ASN_ENCODING, public_key_info, hash_buffer, &size); ok(ret, "Failed to hash public key, error %#x\n", GetLastError());
key_info.KeyId.cbData = size; @@ -172,7 +172,7 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) cert_info.rgExtension = &extension; algid.pszObjId = (char *)szOID_RSA_SHA1RSA; size = sizeof(cert_buffer); - ret = CryptSignAndEncodeCertificate(ctx->provider, AT_SIGNATURE, X509_ASN_ENCODING, + ret = CryptSignAndEncodeCertificate(provider, AT_SIGNATURE, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &cert_info, &algid, NULL, cert_buffer, &size); ok(ret, "Failed to create certificate, error %#x\n", GetLastError());
@@ -180,7 +180,7 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) ok(!!ctx->cert, "Failed to create context, error %#x\n", GetLastError());
size = sizeof(provider_nameA); - ret = CryptGetProvParam(ctx->provider, PP_NAME, provider_nameA, &size, 0); + ret = CryptGetProvParam(provider, PP_NAME, provider_nameA, &size, 0); ok(ret, "Failed to get prov param, error %#x\n", GetLastError()); MultiByteToWideChar(CP_ACP, 0, (char *)provider_nameA, -1, provider_nameW, ARRAY_SIZE(provider_nameW));
@@ -191,6 +191,9 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) ret = CertSetCertificateContextProperty(ctx->cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &provider_info); ok(ret, "Failed to set provider info, error %#x\n", GetLastError());
+ ret = CryptReleaseContext(provider, 0); + ok(ret, "failed to release context, error %u\n", GetLastError()); + ctx->root_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, "root"); if (!ctx->root_store && GetLastError() == ERROR_ACCESS_DENIED) { @@ -198,8 +201,6 @@ static BOOL testsign_create_cert(struct testsign_context *ctx)
ret = CertFreeCertificateContext(ctx->cert); ok(ret, "Failed to free certificate, error %u\n", GetLastError()); - ret = CryptReleaseContext(ctx->provider, 0); - ok(ret, "failed to release context, error %u\n", GetLastError());
return FALSE; } @@ -213,8 +214,6 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) ok(ret, "Failed to free certificate, error %u\n", GetLastError()); ret = CertCloseStore(ctx->root_store, CERT_CLOSE_STORE_CHECK_FLAG); ok(ret, "Failed to close store, error %u\n", GetLastError()); - ret = CryptReleaseContext(ctx->provider, 0); - ok(ret, "failed to release context, error %u\n", GetLastError());
return FALSE; } @@ -232,6 +231,7 @@ static BOOL testsign_create_cert(struct testsign_context *ctx)
static void testsign_cleanup(struct testsign_context *ctx) { + HCRYPTPROV provider; BOOL ret;
ret = CertFreeCertificateContext(ctx->cert); @@ -247,10 +247,7 @@ static void testsign_cleanup(struct testsign_context *ctx) ret = CertCloseStore(ctx->publisher_store, CERT_CLOSE_STORE_CHECK_FLAG); ok(ret, "Failed to close store, error %u\n", GetLastError());
- ret = CryptReleaseContext(ctx->provider, 0); - ok(ret, "failed to release context, error %u\n", GetLastError()); - - ret = CryptAcquireContextW(&ctx->provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); + ret = CryptAcquireContextW(&provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "Failed to delete container, error %#x\n", GetLastError()); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 133 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 62 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index b7926232cfb..99487cc0116 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -85,15 +85,9 @@ static void load_resource(const WCHAR *name, WCHAR *filename) CloseHandle( file ); }
-struct testsign_context -{ - const CERT_CONTEXT *cert, *root_cert, *publisher_cert; - HCERTSTORE root_store, publisher_store; -}; - static const WCHAR container_name[] = L"wine_testsign";
-static BOOL testsign_create_cert(struct testsign_context *ctx) +static const CERT_CONTEXT *testsign_create_cert(void) { BYTE encoded_name[100], encoded_key_id[200], public_key_info_buffer[1000]; BYTE hash_buffer[16], cert_buffer[1000], provider_nameA[100], serial[16]; @@ -101,16 +95,16 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) CRYPT_KEY_PROV_INFO provider_info = {0}; CRYPT_ALGORITHM_IDENTIFIER algid = {0}; CERT_AUTHORITY_KEY_ID_INFO key_info; + HCERTSTORE root_store, pub_store; CERT_INFO cert_info = {0}; WCHAR provider_nameW[100]; + const CERT_CONTEXT *cert; CERT_EXTENSION extension; HCRYPTPROV provider; HCRYPTKEY key; DWORD size; BOOL ret;
- memset(ctx, 0, sizeof(*ctx)); - ret = CryptAcquireContextW(&provider, container_name, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); if (!ret && GetLastError() == NTE_EXISTS) { @@ -176,8 +170,8 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) X509_CERT_TO_BE_SIGNED, &cert_info, &algid, NULL, cert_buffer, &size); ok(ret, "Failed to create certificate, error %#x\n", GetLastError());
- ctx->cert = CertCreateCertificateContext(X509_ASN_ENCODING, cert_buffer, size); - ok(!!ctx->cert, "Failed to create context, error %#x\n", GetLastError()); + cert = CertCreateCertificateContext(X509_ASN_ENCODING, cert_buffer, size); + ok(!!cert, "Failed to create context, error %#x\n", GetLastError());
size = sizeof(provider_nameA); ret = CryptGetProvParam(provider, PP_NAME, provider_nameA, &size, 0); @@ -188,70 +182,85 @@ static BOOL testsign_create_cert(struct testsign_context *ctx) provider_info.pwszProvName = provider_nameW; provider_info.dwProvType = PROV_RSA_FULL; provider_info.dwKeySpec = AT_SIGNATURE; - ret = CertSetCertificateContextProperty(ctx->cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &provider_info); + ret = CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &provider_info); ok(ret, "Failed to set provider info, error %#x\n", GetLastError());
ret = CryptReleaseContext(provider, 0); ok(ret, "failed to release context, error %u\n", GetLastError());
- ctx->root_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, "root"); - if (!ctx->root_store && GetLastError() == ERROR_ACCESS_DENIED) + root_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, "root"); + if (!root_store && GetLastError() == ERROR_ACCESS_DENIED) { skip("Failed to open root store.\n"); - - ret = CertFreeCertificateContext(ctx->cert); + ret = CertFreeCertificateContext(cert); ok(ret, "Failed to free certificate, error %u\n", GetLastError()); - - return FALSE; + return NULL; } - ok(!!ctx->root_store, "Failed to open store, error %u\n", GetLastError()); - ret = CertAddCertificateContextToStore(ctx->root_store, ctx->cert, CERT_STORE_ADD_ALWAYS, &ctx->root_cert); + ok(!!root_store, "Failed to open store, error %u\n", GetLastError()); + ret = CertAddCertificateContextToStore(root_store, cert, CERT_STORE_ADD_ALWAYS, NULL); if (!ret && GetLastError() == ERROR_ACCESS_DENIED) { skip("Failed to add self-signed certificate to store.\n");
- ret = CertFreeCertificateContext(ctx->cert); + ret = CertFreeCertificateContext(cert); ok(ret, "Failed to free certificate, error %u\n", GetLastError()); - ret = CertCloseStore(ctx->root_store, CERT_CLOSE_STORE_CHECK_FLAG); + ret = CertCloseStore(root_store, CERT_CLOSE_STORE_CHECK_FLAG); ok(ret, "Failed to close store, error %u\n", GetLastError());
- return FALSE; + return NULL; } ok(ret, "Failed to add certificate, error %u\n", GetLastError()); + ret = CertCloseStore(root_store, CERT_CLOSE_STORE_CHECK_FLAG); + ok(ret, "Failed to close store, error %u\n", GetLastError());
- ctx->publisher_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, + pub_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, "trustedpublisher"); - ok(!!ctx->publisher_store, "Failed to open store, error %u\n", GetLastError()); - ret = CertAddCertificateContextToStore(ctx->publisher_store, ctx->cert, - CERT_STORE_ADD_ALWAYS, &ctx->publisher_cert); + ok(!!pub_store, "Failed to open store, error %u\n", GetLastError()); + ret = CertAddCertificateContextToStore(pub_store, cert, CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "Failed to add certificate, error %u\n", GetLastError()); + ret = CertCloseStore(pub_store, CERT_CLOSE_STORE_CHECK_FLAG); + ok(ret, "Failed to close store, error %u\n", GetLastError());
- return TRUE; + return cert; }
-static void testsign_cleanup(struct testsign_context *ctx) +static void testsign_cleanup(const CERT_CONTEXT *cert) { + HCERTSTORE root_store, pub_store; + const CERT_CONTEXT *store_cert; HCRYPTPROV provider; BOOL ret;
- ret = CertFreeCertificateContext(ctx->cert); - ok(ret, "Failed to free certificate, error %u\n", GetLastError()); - - ret = CertDeleteCertificateFromStore(ctx->root_cert); + root_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, + CERT_SYSTEM_STORE_LOCAL_MACHINE, "root"); + ok(!!root_store, "Failed to open store, error %u\n", GetLastError()); + store_cert = CertFindCertificateInStore(root_store, X509_ASN_ENCODING, 0, + CERT_FIND_EXISTING, cert, NULL); + ok(!!store_cert, "Failed to find root certificate, error %u\n", GetLastError()); + ret = CertDeleteCertificateFromStore(store_cert); ok(ret, "Failed to remove certificate, error %u\n", GetLastError()); - ret = CertCloseStore(ctx->root_store, CERT_CLOSE_STORE_CHECK_FLAG); + ret = CertCloseStore(root_store, CERT_CLOSE_STORE_CHECK_FLAG); ok(ret, "Failed to close store, error %u\n", GetLastError());
- ret = CertDeleteCertificateFromStore(ctx->publisher_cert); + pub_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_A, 0, 0, + CERT_SYSTEM_STORE_LOCAL_MACHINE, "trustedpublisher"); + ok(!!pub_store, "Failed to open store, error %u\n", GetLastError()); + store_cert = CertFindCertificateInStore(pub_store, X509_ASN_ENCODING, 0, + CERT_FIND_EXISTING, cert, NULL); + ok(!!store_cert, "Failed to find publisher certificate, error %u\n", GetLastError()); + ret = CertDeleteCertificateFromStore(store_cert); ok(ret, "Failed to remove certificate, error %u\n", GetLastError()); - ret = CertCloseStore(ctx->publisher_store, CERT_CLOSE_STORE_CHECK_FLAG); + ret = CertCloseStore(pub_store, CERT_CLOSE_STORE_CHECK_FLAG); ok(ret, "Failed to close store, error %u\n", GetLastError());
+ ret = CertFreeCertificateContext(cert); + ok(ret, "Failed to free certificate, error %u\n", GetLastError()); + ret = CryptAcquireContextW(&provider, container_name, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET); ok(ret, "Failed to delete container, error %#x\n", GetLastError()); }
-static void testsign_sign(struct testsign_context *ctx, const WCHAR *filename) +static void testsign_sign(const CERT_CONTEXT *cert, const WCHAR *filename) { SIGNER_ATTR_AUTHCODE authcode = {sizeof(authcode)}; SIGNER_SIGNATURE_INFO signature = {sizeof(signature)}; @@ -268,7 +277,7 @@ static void testsign_sign(struct testsign_context *ctx, const WCHAR *filename) file.pwszFileName = (WCHAR *)filename; cert_info.dwCertChoice = 2; cert_info.pCertStoreInfo = &store; - store.pSigningCert = ctx->cert; + store.pSigningCert = cert; store.dwCertPolicy = 0; signature.algidHash = CALG_SHA_256; signature.dwAttrChoice = SIGNER_AUTHCODE_ATTR; @@ -298,7 +307,7 @@ static void unload_driver(SC_HANDLE service) CloseServiceHandle(service); }
-static SC_HANDLE load_driver(struct testsign_context *ctx, WCHAR *filename, +static SC_HANDLE load_driver(const CERT_CONTEXT *cert, WCHAR *filename, const WCHAR *resname, const WCHAR *driver_name) { SC_HANDLE manager, service; @@ -316,7 +325,7 @@ static SC_HANDLE load_driver(struct testsign_context *ctx, WCHAR *filename, if (service) unload_driver(service);
load_resource(resname, filename); - testsign_sign(ctx, filename); + testsign_sign(cert, filename); trace("Trying to load driver %s\n", debugstr_w(filename));
service = CreateServiceW(manager, driver_name, driver_name, @@ -1136,13 +1145,13 @@ static void test_object_info(void) CloseHandle(file); }
-static void test_driver3(struct testsign_context *ctx) +static void test_driver3(const CERT_CONTEXT *cert) { WCHAR filename[MAX_PATH]; SC_HANDLE service; BOOL ret;
- service = load_driver(ctx, filename, L"driver3.dll", L"WineTestDriver3"); + service = load_driver(cert, filename, L"driver3.dll", L"WineTestDriver3"); ok(service != NULL, "driver3 failed to load\n");
ret = StartServiceA(service, 0, NULL); @@ -1216,14 +1225,14 @@ static DWORD WINAPI wsk_test_thread(void *parameter) return TRUE; }
-static void test_driver_netio(struct testsign_context *ctx) +static void test_driver_netio(const CERT_CONTEXT *cert) { WCHAR filename[MAX_PATH]; SC_HANDLE service; HANDLE hthread; BOOL ret;
- if (!(service = load_driver(ctx, filename, L"driver_netio.dll", L"winetest_netio"))) + if (!(service = load_driver(cert, filename, L"driver_netio.dll", L"winetest_netio"))) return;
if (!start_driver(service, TRUE)) @@ -1413,7 +1422,7 @@ static void pnp_driver_stop(void) ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "Failed to delete file, error %u\n", GetLastError()); }
-static void pnp_driver_start(struct testsign_context *ctx, const WCHAR *resource) +static void pnp_driver_start(const CERT_CONTEXT *cert, const WCHAR *resource) { static const WCHAR hardware_id[] = L"test_hardware_id\0"; SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; @@ -1456,7 +1465,7 @@ static void pnp_driver_start(struct testsign_context *ctx, const WCHAR *resource ret = CryptCATClose(catalog); ok(ret, "Failed to close catalog, error %u\n", GetLastError());
- testsign_sign(ctx, L"winetest.cat"); + testsign_sign(cert, L"winetest.cat");
/* Install the driver. */
@@ -1838,7 +1847,7 @@ static void test_pnp_devices(void) UnregisterClassA("ntoskrnl_test_wc", GetModuleHandleA(NULL)); }
-static void test_pnp_driver(struct testsign_context *ctx) +static void test_pnp_driver(const CERT_CONTEXT *cert) { char cwd[MAX_PATH], tempdir[MAX_PATH];
@@ -1846,7 +1855,7 @@ static void test_pnp_driver(struct testsign_context *ctx) GetTempPathA(ARRAY_SIZE(tempdir), tempdir); SetCurrentDirectoryA(tempdir);
- pnp_driver_start(ctx, L"driver_pnp.dll"); + pnp_driver_start(cert, L"driver_pnp.dll"); test_pnp_devices(); pnp_driver_stop();
@@ -3323,7 +3332,7 @@ static void test_hid_device(DWORD report_id, DWORD polled) winetest_pop_context(); }
-static void test_hid_driver(struct testsign_context *ctx, DWORD report_id, DWORD polled) +static void test_hid_driver(const CERT_CONTEXT *cert, DWORD report_id, DWORD polled) { char cwd[MAX_PATH], tempdir[MAX_PATH]; LSTATUS status; @@ -3342,7 +3351,7 @@ static void test_hid_driver(struct testsign_context *ctx, DWORD report_id, DWORD status = RegSetValueExW(hkey, L"PolledMode", 0, REG_DWORD, (void *)&polled, sizeof(polled)); ok(!status, "RegSetValueExW returned %#x\n", status);
- pnp_driver_start(ctx, L"driver_hid.dll"); + pnp_driver_start(cert, L"driver_hid.dll"); test_hid_device(report_id, polled); pnp_driver_stop();
@@ -3352,8 +3361,8 @@ static void test_hid_driver(struct testsign_context *ctx, DWORD report_id, DWORD START_TEST(ntoskrnl) { WCHAR filename[MAX_PATH], filename2[MAX_PATH]; - struct testsign_context ctx; SC_HANDLE service, service2; + const CERT_CONTEXT *cert; BOOL ret, is_wow64; HANDLE mapping; DWORD written; @@ -3372,7 +3381,7 @@ START_TEST(ntoskrnl) return; }
- if (!testsign_create_cert(&ctx)) + if (!(cert = testsign_create_cert())) return;
mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, @@ -3388,7 +3397,7 @@ START_TEST(ntoskrnl) ok(okfile != INVALID_HANDLE_VALUE, "failed to create file, error %u\n", GetLastError());
subtest("driver"); - if (!(service = load_driver(&ctx, filename, L"driver.dll", L"WineTestDriver"))) + if (!(service = load_driver(cert, filename, L"driver.dll", L"WineTestDriver"))) goto out;
if (!start_driver(service, FALSE)) @@ -3396,7 +3405,7 @@ START_TEST(ntoskrnl) DeleteFileW(filename); goto out; } - service2 = load_driver(&ctx, filename2, L"driver2.dll", L"WineTestDriver2"); + service2 = load_driver(cert, filename2, L"driver2.dll", L"WineTestDriver2");
device = CreateFileA("\\.\WineTestDriver", 0, 0, NULL, OPEN_EXISTING, 0, NULL); ok(device != INVALID_HANDLE_VALUE, "failed to open device: %u\n", GetLastError()); @@ -3428,21 +3437,21 @@ START_TEST(ntoskrnl)
cat_okfile();
- test_driver3(&ctx); + test_driver3(cert); subtest("driver_netio"); - test_driver_netio(&ctx); + test_driver_netio(cert);
subtest("driver_pnp"); - test_pnp_driver(&ctx); + test_pnp_driver(cert);
subtest("driver_hid"); - test_hid_driver(&ctx, 0, FALSE); - test_hid_driver(&ctx, 1, FALSE); - test_hid_driver(&ctx, 0, TRUE); - test_hid_driver(&ctx, 1, TRUE); + test_hid_driver(cert, 0, FALSE); + test_hid_driver(cert, 1, FALSE); + test_hid_driver(cert, 0, TRUE); + test_hid_driver(cert, 1, TRUE);
out: - testsign_cleanup(&ctx); + testsign_cleanup(cert); UnmapViewOfFile(test_data); CloseHandle(mapping); CloseHandle(okfile);
On 9/6/21 5:27 AM, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 133 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 62 deletions(-)
I like 3/5 and 4/5, but this seems like less obviously an improvement. Is there a motivation for this besides getting rid of the testsign_context structure?
On 9/6/21 11:15 PM, Zebediah Figura wrote:
On 9/6/21 5:27 AM, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 133 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 62 deletions(-)
I like 3/5 and 4/5, but this seems like less obviously an improvement. Is there a motivation for this besides getting rid of the testsign_context structure?
Mostly to reduce the required state for the functions, and get rid of the structure yes.
I'm planning on copying the code to have a driver based dinput test case, and I'm already not very happy with the code duplication, I wanted to not duplicate the structure if we could do without it.
It's not very important though, the dinput code will probably have small differences.
On 9/6/21 4:23 PM, Rémi Bernon wrote:
On 9/6/21 11:15 PM, Zebediah Figura wrote:
On 9/6/21 5:27 AM, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 133 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 62 deletions(-)
I like 3/5 and 4/5, but this seems like less obviously an improvement. Is there a motivation for this besides getting rid of the testsign_context structure?
Mostly to reduce the required state for the functions, and get rid of the structure yes.
I'm planning on copying the code to have a driver based dinput test case, and I'm already not very happy with the code duplication, I wanted to not duplicate the structure if we could do without it.
It's not very important though, the dinput code will probably have small differences.
I tried to design the testsign_* stuff to be independent and portable, not least because I have ancient tests written for setupapi that I never finished or submitted. I don't see how this patch helps with portability, though...?
On 9/6/21 11:36 PM, Zebediah Figura wrote:
On 9/6/21 4:23 PM, Rémi Bernon wrote:
On 9/6/21 11:15 PM, Zebediah Figura wrote:
On 9/6/21 5:27 AM, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 133 +++++++++++++++-------------- 1 file changed, 71 insertions(+), 62 deletions(-)
I like 3/5 and 4/5, but this seems like less obviously an improvement. Is there a motivation for this besides getting rid of the testsign_context structure?
Mostly to reduce the required state for the functions, and get rid of the structure yes.
I'm planning on copying the code to have a driver based dinput test case, and I'm already not very happy with the code duplication, I wanted to not duplicate the structure if we could do without it.
It's not very important though, the dinput code will probably have small differences.
I tried to design the testsign_* stuff to be independent and portable, not least because I have ancient tests written for setupapi that I never finished or submitted. I don't see how this patch helps with portability, though...?
It doesn't much, but it removes the need for an additional custom structure, which in the end still means less duplication.