Commit a24f29cd authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

imagehlp/tests: Enable compilation with long types.

parent 7576f6be
EXTRADEFS = -DWINE_NO_LONG_TYPES
TESTDLL = imagehlp.dll
IMPORTS = imagehlp psapi
......
......@@ -41,11 +41,11 @@ static char *load_resource(const char *name)
strcat(path, name);
file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %u.\n",
ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %lu.\n",
debugstr_a(path), GetLastError());
res = FindResourceA(NULL, name, "TESTDLL");
ok(!!res, "Failed to load resource, error %u.\n", GetLastError());
ok(!!res, "Failed to load resource, error %lu.\n", GetLastError());
ptr = LockResource(LoadResource(GetModuleHandleA(NULL), res));
WriteFile(file, ptr, SizeofResource( GetModuleHandleA(NULL), res), &written, NULL);
ok(written == SizeofResource(GetModuleHandleA(NULL), res), "Failed to write resource.\n");
......@@ -204,15 +204,15 @@ static void check_updates(LPCSTR header, const struct expected_update_accum *exp
DWORD i;
todo_wine_if (expected->todo)
ok(expected->cUpdates == got->cUpdates, "%s: expected %d updates, got %d\n",
ok(expected->cUpdates == got->cUpdates, "%s: expected %ld updates, got %ld\n",
header, expected->cUpdates, got->cUpdates);
for (i = 0; i < min(expected->cUpdates, got->cUpdates); i++)
{
ok(expected->updates[i].cb == got->updates[i].cb, "%s, update %d: expected %d bytes, got %d\n",
ok(expected->updates[i].cb == got->updates[i].cb, "%s, update %ld: expected %ld bytes, got %ld\n",
header, i, expected->updates[i].cb, got->updates[i].cb);
if (expected->updates[i].cb && expected->updates[i].cb == got->updates[i].cb)
ok(!memcmp(expected->updates[i].pb, got->updates[i].pb, got->updates[i].cb),
"%s, update %d: unexpected value\n", header, i);
"%s, update %ld: unexpected value\n", header, i);
}
}
......@@ -304,7 +304,7 @@ static void test_get_digest_stream(void)
SetLastError(0xdeadbeef);
ret = ImageGetDigestStream(NULL, 0, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
"expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
file = create_temp_file(temp_file);
if (file == INVALID_HANDLE_VALUE)
{
......@@ -314,16 +314,16 @@ static void test_get_digest_stream(void)
SetLastError(0xdeadbeef);
ret = ImageGetDigestStream(file, 0, NULL, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
"expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ImageGetDigestStream(NULL, 0, accumulating_stream_output, &accum);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
"expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
/* Even with "valid" parameters, it fails with an empty file */
SetLastError(0xdeadbeef);
ret = ImageGetDigestStream(file, 0, accumulating_stream_output, &accum);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
"expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
/* Finally, with a valid executable in the file, it succeeds. Note that
* the file pointer need not be positioned at the beginning.
*/
......@@ -337,12 +337,12 @@ static void test_get_digest_stream(void)
bin.nt_headers.OptionalHeader.SizeOfImage = 0;
ret = ImageGetDigestStream(file, 0, accumulating_stream_output, &accum);
ok(ret, "ImageGetDigestStream failed: %d\n", GetLastError());
ok(ret, "ImageGetDigestStream failed: %ld\n", GetLastError());
check_updates("flags = 0", &a1, &accum);
free_updates(&accum);
ret = ImageGetDigestStream(file, CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO,
accumulating_stream_output, &accum);
ok(ret, "ImageGetDigestStream failed: %d\n", GetLastError());
ok(ret, "ImageGetDigestStream failed: %ld\n", GetLastError());
check_updates("flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO", &a2, &accum);
free_updates(&accum);
CloseHandle(file);
......@@ -374,7 +374,7 @@ static BOOL WINAPI bind_image_cb(IMAGEHLP_STATUS_REASON reason, const char *file
todo_wine ok(!!va, "expected nonzero VA\n");
ret = SearchPathA(NULL, last_module, ".dll", sizeof(full_path), full_path, NULL);
ok(ret, "got error %u\n", GetLastError());
ok(ret, "got error %lu\n", GetLastError());
ok(!strcmp(module, full_path), "expected %s, got %s\n", debugstr_a(full_path), debugstr_a(module));
if (!strcmp((const char *)param, "SysAllocString"))
......@@ -410,17 +410,17 @@ static void test_bind_image_ex(void)
"nonexistent.dll", 0, 0, bind_image_cb);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_INVALID_PARAMETER,
"got error %u\n", GetLastError());
"got error %lu\n", GetLastError());
ret = BindImageEx(BIND_ALL_IMAGES | BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE,
filename, NULL, NULL, bind_image_cb);
ok(ret, "got error %u\n", GetLastError());
ok(ret, "got error %lu\n", GetLastError());
ok(got_SysAllocString == 1, "got %u imports of SysAllocString\n", got_SysAllocString);
ok(got_GetOpenFileNameA == 1, "got %u imports of GetOpenFileNameA\n", got_GetOpenFileNameA);
todo_wine ok(got_SHRegGetIntW == 1, "got %u imports of SHRegGetIntW\n", got_SHRegGetIntW);
ret = DeleteFileA(filename);
ok(ret, "got error %u\n", GetLastError());
ok(ret, "got error %lu\n", GetLastError());
}
static void test_image_load(void)
......@@ -460,7 +460,7 @@ static void test_image_load(void)
"FileHeader doesn't point to IMAGE_NT_HEADERS32\n");
}
ok(img->NumberOfSections == 3,
"unexpected NumberOfSections, got %d instead of 3\n", img->NumberOfSections);
"unexpected NumberOfSections, got %ld instead of 3\n", img->NumberOfSections);
if (img->NumberOfSections >= 3)
{
ok(!strcmp((const char *)img->Sections[0].Name, ".text"),
......@@ -474,7 +474,7 @@ static void test_image_load(void)
(const char *)img->Sections[2].Name);
}
ok(img->Characteristics == 0x102,
"unexpected Characteristics, got 0x%x instead of 0x102\n", img->Characteristics);
"unexpected Characteristics, got 0x%lx instead of 0x102\n", img->Characteristics);
ok(img->fSystemImage == 0,
"unexpected fSystemImage, got %d instead of 0\n", img->fSystemImage);
ok(img->fDOSImage == 0,
......@@ -484,14 +484,14 @@ static void test_image_load(void)
todo_wine ok(img->Version == 1 || broken(!img->Version) /* <= WinXP */,
"unexpected Version, got %d instead of 1\n", img->Version);
ok(img->SizeOfImage == 0x600,
"unexpected SizeOfImage, got 0x%x instead of 0x600\n", img->SizeOfImage);
"unexpected SizeOfImage, got 0x%lx instead of 0x600\n", img->SizeOfImage);
count = 0xdeadbeef;
ret = GetImageUnusedHeaderBytes(img, &count);
todo_wine
ok(ret == 448, "GetImageUnusedHeaderBytes returned %u instead of 448\n", ret);
ok(ret == 448, "GetImageUnusedHeaderBytes returned %lu instead of 448\n", ret);
todo_wine
ok(count == 64, "unexpected size for unused header bytes, got %u instead of 64\n", count);
ok(count == 64, "unexpected size for unused header bytes, got %lu instead of 64\n", count);
ImageUnload(img);
}
......
......@@ -183,8 +183,8 @@ static DWORD test_add_certificate(const char *cert_data, int len)
CopyMemory(cert->bCertificate, cert_data, len);
ret = ImageAddCertificate(hFile, cert, &index);
ok(ret, "Unable to add certificate to image, error %x\n", GetLastError());
trace("added cert index %d\n", index);
ok(ret, "Unable to add certificate to image, error %lx\n", GetLastError());
trace("added cert index %ld\n", index);
HeapFree(GetProcessHeap(), 0, cert);
CloseHandle(hFile);
......@@ -210,7 +210,7 @@ static void test_get_certificate(const char *cert_data, int index)
ret = ImageGetCertificateData(hFile, index, NULL, &cert_len);
err = GetLastError();
ok ((ret == FALSE) && (err == ERROR_INSUFFICIENT_BUFFER), "ImageGetCertificateData gave unexpected result; ret=%d / err=%x\n", ret, err);
ok ((ret == FALSE) && (err == ERROR_INSUFFICIENT_BUFFER), "ImageGetCertificateData gave unexpected result; ret=%d / err=%lx\n", ret, err);
cert = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cert_len);
......@@ -222,7 +222,7 @@ static void test_get_certificate(const char *cert_data, int index)
}
ret = ImageGetCertificateData(hFile, index, cert, &cert_len);
ok(ret, "Unable to retrieve certificate; err=%x\n", GetLastError());
ok(ret, "Unable to retrieve certificate; err=%lx\n", GetLastError());
ok(memcmp(cert->bCertificate, cert_data, cert_len - sizeof(WIN_CERTIFICATE)) == 0, "Certificate retrieved did not match original\n");
HeapFree(GetProcessHeap(), 0, cert);
......@@ -244,13 +244,13 @@ static void test_remove_certificate(int index)
}
ret = ImageEnumerateCertificates(hFile, CERT_SECTION_TYPE_ANY, &orig_count, NULL, 0);
ok (ret, "Unable to enumerate certificates in file; err=%x\n", GetLastError());
ok (ret, "Unable to enumerate certificates in file; err=%lx\n", GetLastError());
ret = ImageRemoveCertificate(hFile, index);
ok (ret, "Unable to remove certificate from file; err=%x\n", GetLastError());
ok (ret, "Unable to remove certificate from file; err=%lx\n", GetLastError());
/* Test to see if the certificate has actually been removed */
ImageEnumerateCertificates(hFile, CERT_SECTION_TYPE_ANY, &count, NULL, 0);
ok (count == orig_count - 1, "Certificate count mismatch; orig=%d new=%d\n", orig_count, count);
ok (count == orig_count - 1, "Certificate count mismatch; orig=%ld new=%ld\n", orig_count, count);
CloseHandle(hFile);
}
......@@ -268,60 +268,60 @@ static void test_pe_checksum(void)
ret = CheckSumMappedFile(NULL, 0, &checksum_orig, &checksum_new);
ok(!ret, "Expected CheckSumMappedFile to fail, got %p\n", ret);
ok(((GetLastError() == ERROR_INVALID_PARAMETER)||(GetLastError() == 0xdeadbeef)),
"Expected 0xdeadbeef (XP) or ERROR_INVALID_PARAMETER (Vista+), got %x\n", GetLastError());
"Expected 0xdeadbeef (XP) or ERROR_INVALID_PARAMETER (Vista+), got %lx\n", GetLastError());
SetLastError(0xdeadbeef);
ret = CheckSumMappedFile((void *)0xdeadbeef, 0, &checksum_orig, &checksum_new);
ok(!ret, "Expected CheckSumMappedFile to fail, got %p\n", ret);
ok(((GetLastError() == ERROR_INVALID_PARAMETER)||(GetLastError() == 0xdeadbeef)),
"Expected 0xdeadbeef (XP) or ERROR_INVALID_PARAMETER (Vista+), got %x\n", GetLastError());
"Expected 0xdeadbeef (XP) or ERROR_INVALID_PARAMETER (Vista+), got %lx\n", GetLastError());
/* basic checksum tests */
memset(buffer, 0x11, sizeof(buffer));
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(buffer, sizeof(buffer), &checksum_orig, &checksum_new);
ok(ret == NULL, "Expected NULL, got %p\n", ret);
todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
todo_wine ok(checksum_new == 0xaabe, "Expected 0xaabe, got %x\n", checksum_new);
todo_wine ok(checksum_orig == 0, "Expected 0, got %lx\n", checksum_orig);
todo_wine ok(checksum_new == 0xaabe, "Expected 0xaabe, got %lx\n", checksum_new);
memset(buffer, 0x22, sizeof(buffer));
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(buffer, sizeof(buffer), &checksum_orig, &checksum_new);
ok(ret == NULL, "Expected NULL, got %p\n", ret);
todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
todo_wine ok(checksum_new == 0x5569, "Expected 0x5569, got %x\n", checksum_new);
todo_wine ok(checksum_orig == 0, "Expected 0, got %lx\n", checksum_orig);
todo_wine ok(checksum_new == 0x5569, "Expected 0x5569, got %lx\n", checksum_new);
memset(buffer, 0x22, sizeof(buffer));
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(buffer, 10, &checksum_orig, &checksum_new);
ok(ret == NULL, "Expected NULL, got %p\n", ret);
todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
todo_wine ok(checksum_new == 0xaab4, "Expected 0xaab4, got %x\n", checksum_new);
todo_wine ok(checksum_orig == 0, "Expected 0, got %lx\n", checksum_orig);
todo_wine ok(checksum_new == 0xaab4, "Expected 0xaab4, got %lx\n", checksum_new);
memset(buffer, 0x22, sizeof(buffer));
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(buffer, 11, &checksum_orig, &checksum_new);
ok(ret == NULL, "Expected NULL, got %p\n", ret);
todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
todo_wine ok(checksum_new == 0xaad7, "Expected 0xaad7, got %x\n", checksum_new);
todo_wine ok(checksum_orig == 0, "Expected 0, got %lx\n", checksum_orig);
todo_wine ok(checksum_new == 0xaad7, "Expected 0xaad7, got %lx\n", checksum_new);
/* test checksum of PE module */
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(test_pe_executable, sizeof(test_pe_executable),
&checksum_orig, &checksum_new);
ok((char *)ret == test_pe_executable + 0x80, "Expected %p, got %p\n", test_pe_executable + 0x80, ret);
ok(checksum_orig == 0xabcdef11, "Expected 0xabcdef11, got %x\n", checksum_orig);
ok(checksum_new == 0xaa4, "Expected 0xaa4, got %x\n", checksum_new);
ok(checksum_orig == 0xabcdef11, "Expected 0xabcdef11, got %lx\n", checksum_orig);
ok(checksum_new == 0xaa4, "Expected 0xaa4, got %lx\n", checksum_new);
ret_bool = GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(NULL),
&modinfo, sizeof(modinfo));
ok(ret_bool, "GetModuleInformation failed, error: %x\n", GetLastError());
ok(ret_bool, "GetModuleInformation failed, error: %lx\n", GetLastError());
SetLastError(0xdeadbeef);
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(modinfo.lpBaseOfDll, modinfo.SizeOfImage, &checksum_orig, &checksum_new);
ok(ret != NULL, "Expected CheckSumMappedFile to succeed\n");
ok(GetLastError() == 0xdeadbeef, "Expected err=0xdeadbeef, got %x\n", GetLastError());
ok(GetLastError() == 0xdeadbeef, "Expected err=0xdeadbeef, got %lx\n", GetLastError());
ok(checksum_orig != 0xdeadbeef, "Expected orig checksum != 0xdeadbeef\n");
ok(checksum_new != 0xdeadbeef, "Expected new checksum != 0xdeadbeef\n");
......@@ -330,9 +330,9 @@ static void test_pe_checksum(void)
ret = CheckSumMappedFile((char *)modinfo.lpBaseOfDll + 100, modinfo.SizeOfImage - 100,
&checksum_orig, &checksum_new);
ok(!ret, "Expected CheckSumMappedFile to fail, got %p\n", ret);
ok(GetLastError() == 0xdeadbeef, "Expected err=0xdeadbeef, got %x\n", GetLastError());
todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
todo_wine ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %x\n", checksum_new);
ok(GetLastError() == 0xdeadbeef, "Expected err=0xdeadbeef, got %lx\n", GetLastError());
todo_wine ok(checksum_orig == 0, "Expected 0, got %lx\n", checksum_orig);
todo_wine ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %lx\n", checksum_new);
nt_header = ImageNtHeader( modinfo.lpBaseOfDll );
checksum_correct = nt_header->OptionalHeader.CheckSum;
......@@ -341,28 +341,28 @@ static void test_pe_checksum(void)
ret = CheckSumMappedFile(modinfo.lpBaseOfDll, (char *)nt_header - (char *)modinfo.lpBaseOfDll,
&checksum_orig, &checksum_new);
ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret);
ok((checksum_orig == 0) || (checksum_orig == checksum_correct), "Expected %x, got %x\n", checksum_correct, checksum_orig);
ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %x\n", checksum_new);
ok((checksum_orig == 0) || (checksum_orig == checksum_correct), "Expected %lx, got %lx\n", checksum_correct, checksum_orig);
ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %lx\n", checksum_new);
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(modinfo.lpBaseOfDll, sizeof(IMAGE_DOS_HEADER),
&checksum_orig, &checksum_new);
ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret);
ok((checksum_orig == 0) || (checksum_orig == checksum_correct), "Expected %x, got %x\n", checksum_correct, checksum_orig);
ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %x\n", checksum_new);
ok((checksum_orig == 0) || (checksum_orig == checksum_correct), "Expected %lx, got %lx\n", checksum_correct, checksum_orig);
ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %lx\n", checksum_new);
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile(modinfo.lpBaseOfDll, 0, &checksum_orig, &checksum_new);
ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret);
ok((checksum_orig == 0xdeadbeef) || (checksum_orig == checksum_correct), "Expected %x, got %x\n", checksum_correct, checksum_orig);
ok((checksum_new == 0xdeadbeef) || (checksum_new != 0 && checksum_new != 0xdeadbeef), "Got unexpected value %x\n", checksum_new);
ok((checksum_orig == 0xdeadbeef) || (checksum_orig == checksum_correct), "Expected %lx, got %lx\n", checksum_correct, checksum_orig);
ok((checksum_new == 0xdeadbeef) || (checksum_new != 0 && checksum_new != 0xdeadbeef), "Got unexpected value %lx\n", checksum_new);
checksum_orig = checksum_new = 0xdeadbeef;
ret = CheckSumMappedFile((char *)modinfo.lpBaseOfDll + 1, 0,
&checksum_orig, &checksum_new);
ok(ret == NULL, "Expected NULL, got %p\n", ret);
ok((checksum_orig == 0) || (checksum_orig == 0xdeadbeef), "Expected 0, got %x\n", checksum_orig);
ok((checksum_new == 0) || (checksum_new == 0xdeadbeef), "Expected 0, got %x\n", checksum_new);
ok((checksum_orig == 0) || (checksum_orig == 0xdeadbeef), "Expected 0, got %lx\n", checksum_orig);
ok((checksum_new == 0) || (checksum_new == 0xdeadbeef), "Expected 0, got %lx\n", checksum_new);
}
START_TEST(integrity)
......@@ -379,12 +379,12 @@ START_TEST(integrity)
test_remove_certificate(first);
file_size = get_file_size();
ok(file_size == file_size_orig, "File size different after add and remove (old: %d; new: %d)\n", file_size_orig, file_size);
ok(file_size == file_size_orig, "File size different after add and remove (old: %ld; new: %ld)\n", file_size_orig, file_size);
/* Try adding multiple certificates */
first = test_add_certificate(test_cert_data, sizeof(test_cert_data));
second = test_add_certificate(test_cert_data_2, sizeof(test_cert_data_2));
ok(second == first + 1, "got %d %d\n", first, second);
ok(second == first + 1, "got %ld %ld\n", first, second);
test_get_certificate(test_cert_data, first);
test_get_certificate(test_cert_data_2, second);
......@@ -397,7 +397,7 @@ START_TEST(integrity)
test_remove_certificate(second);
file_size = get_file_size();
ok(file_size == file_size_orig, "File size different after add and remove (old: %d; new: %d)\n", file_size_orig, file_size);
ok(file_size == file_size_orig, "File size different after add and remove (old: %ld; new: %ld)\n", file_size_orig, file_size);
test_pe_checksum();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment