Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
a24f29cd
Commit
a24f29cd
authored
Feb 28, 2022
by
Eric Pouech
Committed by
Alexandre Julliard
Feb 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imagehlp/tests: Enable compilation with long types.
Signed-off-by:
Eric Pouech
<
eric.pouech@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7576f6be
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
56 deletions
+55
-56
Makefile.in
dlls/imagehlp/tests/Makefile.in
+0
-1
image.c
dlls/imagehlp/tests/image.c
+20
-20
integrity.c
dlls/imagehlp/tests/integrity.c
+35
-35
No files found.
dlls/imagehlp/tests/Makefile.in
View file @
a24f29cd
EXTRADEFS
=
-DWINE_NO_LONG_TYPES
TESTDLL
=
imagehlp.dll
TESTDLL
=
imagehlp.dll
IMPORTS
=
imagehlp psapi
IMPORTS
=
imagehlp psapi
...
...
dlls/imagehlp/tests/image.c
View file @
a24f29cd
...
@@ -41,11 +41,11 @@ static char *load_resource(const char *name)
...
@@ -41,11 +41,11 @@ static char *load_resource(const char *name)
strcat
(
path
,
name
);
strcat
(
path
,
name
);
file
=
CreateFileA
(
path
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
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 %
l
u.
\n
"
,
debugstr_a
(
path
),
GetLastError
());
debugstr_a
(
path
),
GetLastError
());
res
=
FindResourceA
(
NULL
,
name
,
"TESTDLL"
);
res
=
FindResourceA
(
NULL
,
name
,
"TESTDLL"
);
ok
(
!!
res
,
"Failed to load resource, error %u.
\n
"
,
GetLastError
());
ok
(
!!
res
,
"Failed to load resource, error %
l
u.
\n
"
,
GetLastError
());
ptr
=
LockResource
(
LoadResource
(
GetModuleHandleA
(
NULL
),
res
));
ptr
=
LockResource
(
LoadResource
(
GetModuleHandleA
(
NULL
),
res
));
WriteFile
(
file
,
ptr
,
SizeofResource
(
GetModuleHandleA
(
NULL
),
res
),
&
written
,
NULL
);
WriteFile
(
file
,
ptr
,
SizeofResource
(
GetModuleHandleA
(
NULL
),
res
),
&
written
,
NULL
);
ok
(
written
==
SizeofResource
(
GetModuleHandleA
(
NULL
),
res
),
"Failed to write resource.
\n
"
);
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
...
@@ -204,15 +204,15 @@ static void check_updates(LPCSTR header, const struct expected_update_accum *exp
DWORD
i
;
DWORD
i
;
todo_wine_if
(
expected
->
todo
)
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 %l
d
\n
"
,
header
,
expected
->
cUpdates
,
got
->
cUpdates
);
header
,
expected
->
cUpdates
,
got
->
cUpdates
);
for
(
i
=
0
;
i
<
min
(
expected
->
cUpdates
,
got
->
cUpdates
);
i
++
)
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 %l
d
\n
"
,
header
,
i
,
expected
->
updates
[
i
].
cb
,
got
->
updates
[
i
].
cb
);
header
,
i
,
expected
->
updates
[
i
].
cb
,
got
->
updates
[
i
].
cb
);
if
(
expected
->
updates
[
i
].
cb
&&
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
),
ok
(
!
memcmp
(
expected
->
updates
[
i
].
pb
,
got
->
updates
[
i
].
pb
,
got
->
updates
[
i
].
cb
),
"%s, update %d: unexpected value
\n
"
,
header
,
i
);
"%s, update %
l
d: unexpected value
\n
"
,
header
,
i
);
}
}
}
}
...
@@ -304,7 +304,7 @@ static void test_get_digest_stream(void)
...
@@ -304,7 +304,7 @@ static void test_get_digest_stream(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
ImageGetDigestStream
(
NULL
,
0
,
NULL
,
NULL
);
ret
=
ImageGetDigestStream
(
NULL
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
"expected ERROR_INVALID_PARAMETER, got %
l
d
\n
"
,
GetLastError
());
file
=
create_temp_file
(
temp_file
);
file
=
create_temp_file
(
temp_file
);
if
(
file
==
INVALID_HANDLE_VALUE
)
if
(
file
==
INVALID_HANDLE_VALUE
)
{
{
...
@@ -314,16 +314,16 @@ static void test_get_digest_stream(void)
...
@@ -314,16 +314,16 @@ static void test_get_digest_stream(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
ImageGetDigestStream
(
file
,
0
,
NULL
,
NULL
);
ret
=
ImageGetDigestStream
(
file
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
"expected ERROR_INVALID_PARAMETER, got %
l
d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
ImageGetDigestStream
(
NULL
,
0
,
accumulating_stream_output
,
&
accum
);
ret
=
ImageGetDigestStream
(
NULL
,
0
,
accumulating_stream_output
,
&
accum
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
"expected ERROR_INVALID_PARAMETER, got %
l
d
\n
"
,
GetLastError
());
/* Even with "valid" parameters, it fails with an empty file */
/* Even with "valid" parameters, it fails with an empty file */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
ImageGetDigestStream
(
file
,
0
,
accumulating_stream_output
,
&
accum
);
ret
=
ImageGetDigestStream
(
file
,
0
,
accumulating_stream_output
,
&
accum
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
"expected ERROR_INVALID_PARAMETER, got %
l
d
\n
"
,
GetLastError
());
/* Finally, with a valid executable in the file, it succeeds. Note that
/* Finally, with a valid executable in the file, it succeeds. Note that
* the file pointer need not be positioned at the beginning.
* the file pointer need not be positioned at the beginning.
*/
*/
...
@@ -337,12 +337,12 @@ static void test_get_digest_stream(void)
...
@@ -337,12 +337,12 @@ static void test_get_digest_stream(void)
bin
.
nt_headers
.
OptionalHeader
.
SizeOfImage
=
0
;
bin
.
nt_headers
.
OptionalHeader
.
SizeOfImage
=
0
;
ret
=
ImageGetDigestStream
(
file
,
0
,
accumulating_stream_output
,
&
accum
);
ret
=
ImageGetDigestStream
(
file
,
0
,
accumulating_stream_output
,
&
accum
);
ok
(
ret
,
"ImageGetDigestStream failed: %d
\n
"
,
GetLastError
());
ok
(
ret
,
"ImageGetDigestStream failed: %
l
d
\n
"
,
GetLastError
());
check_updates
(
"flags = 0"
,
&
a1
,
&
accum
);
check_updates
(
"flags = 0"
,
&
a1
,
&
accum
);
free_updates
(
&
accum
);
free_updates
(
&
accum
);
ret
=
ImageGetDigestStream
(
file
,
CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO
,
ret
=
ImageGetDigestStream
(
file
,
CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO
,
accumulating_stream_output
,
&
accum
);
accumulating_stream_output
,
&
accum
);
ok
(
ret
,
"ImageGetDigestStream failed: %d
\n
"
,
GetLastError
());
ok
(
ret
,
"ImageGetDigestStream failed: %
l
d
\n
"
,
GetLastError
());
check_updates
(
"flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO"
,
&
a2
,
&
accum
);
check_updates
(
"flags = CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO"
,
&
a2
,
&
accum
);
free_updates
(
&
accum
);
free_updates
(
&
accum
);
CloseHandle
(
file
);
CloseHandle
(
file
);
...
@@ -374,7 +374,7 @@ static BOOL WINAPI bind_image_cb(IMAGEHLP_STATUS_REASON reason, const char *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
"
);
todo_wine
ok
(
!!
va
,
"expected nonzero VA
\n
"
);
ret
=
SearchPathA
(
NULL
,
last_module
,
".dll"
,
sizeof
(
full_path
),
full_path
,
NULL
);
ret
=
SearchPathA
(
NULL
,
last_module
,
".dll"
,
sizeof
(
full_path
),
full_path
,
NULL
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
ok
(
ret
,
"got error %
l
u
\n
"
,
GetLastError
());
ok
(
!
strcmp
(
module
,
full_path
),
"expected %s, got %s
\n
"
,
debugstr_a
(
full_path
),
debugstr_a
(
module
));
ok
(
!
strcmp
(
module
,
full_path
),
"expected %s, got %s
\n
"
,
debugstr_a
(
full_path
),
debugstr_a
(
module
));
if
(
!
strcmp
((
const
char
*
)
param
,
"SysAllocString"
))
if
(
!
strcmp
((
const
char
*
)
param
,
"SysAllocString"
))
...
@@ -410,17 +410,17 @@ static void test_bind_image_ex(void)
...
@@ -410,17 +410,17 @@ static void test_bind_image_ex(void)
"nonexistent.dll"
,
0
,
0
,
bind_image_cb
);
"nonexistent.dll"
,
0
,
0
,
bind_image_cb
);
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
!
ret
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
||
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
||
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"got error %u
\n
"
,
GetLastError
());
"got error %
l
u
\n
"
,
GetLastError
());
ret
=
BindImageEx
(
BIND_ALL_IMAGES
|
BIND_NO_BOUND_IMPORTS
|
BIND_NO_UPDATE
,
ret
=
BindImageEx
(
BIND_ALL_IMAGES
|
BIND_NO_BOUND_IMPORTS
|
BIND_NO_UPDATE
,
filename
,
NULL
,
NULL
,
bind_image_cb
);
filename
,
NULL
,
NULL
,
bind_image_cb
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
ok
(
ret
,
"got error %
l
u
\n
"
,
GetLastError
());
ok
(
got_SysAllocString
==
1
,
"got %u imports of SysAllocString
\n
"
,
got_SysAllocString
);
ok
(
got_SysAllocString
==
1
,
"got %u imports of SysAllocString
\n
"
,
got_SysAllocString
);
ok
(
got_GetOpenFileNameA
==
1
,
"got %u imports of GetOpenFileNameA
\n
"
,
got_GetOpenFileNameA
);
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
);
todo_wine
ok
(
got_SHRegGetIntW
==
1
,
"got %u imports of SHRegGetIntW
\n
"
,
got_SHRegGetIntW
);
ret
=
DeleteFileA
(
filename
);
ret
=
DeleteFileA
(
filename
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
ok
(
ret
,
"got error %
l
u
\n
"
,
GetLastError
());
}
}
static
void
test_image_load
(
void
)
static
void
test_image_load
(
void
)
...
@@ -460,7 +460,7 @@ 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
"
);
"FileHeader doesn't point to IMAGE_NT_HEADERS32
\n
"
);
}
}
ok
(
img
->
NumberOfSections
==
3
,
ok
(
img
->
NumberOfSections
==
3
,
"unexpected NumberOfSections, got %d instead of 3
\n
"
,
img
->
NumberOfSections
);
"unexpected NumberOfSections, got %
l
d instead of 3
\n
"
,
img
->
NumberOfSections
);
if
(
img
->
NumberOfSections
>=
3
)
if
(
img
->
NumberOfSections
>=
3
)
{
{
ok
(
!
strcmp
((
const
char
*
)
img
->
Sections
[
0
].
Name
,
".text"
),
ok
(
!
strcmp
((
const
char
*
)
img
->
Sections
[
0
].
Name
,
".text"
),
...
@@ -474,7 +474,7 @@ static void test_image_load(void)
...
@@ -474,7 +474,7 @@ static void test_image_load(void)
(
const
char
*
)
img
->
Sections
[
2
].
Name
);
(
const
char
*
)
img
->
Sections
[
2
].
Name
);
}
}
ok
(
img
->
Characteristics
==
0x102
,
ok
(
img
->
Characteristics
==
0x102
,
"unexpected Characteristics, got 0x%x instead of 0x102
\n
"
,
img
->
Characteristics
);
"unexpected Characteristics, got 0x%
l
x instead of 0x102
\n
"
,
img
->
Characteristics
);
ok
(
img
->
fSystemImage
==
0
,
ok
(
img
->
fSystemImage
==
0
,
"unexpected fSystemImage, got %d instead of 0
\n
"
,
img
->
fSystemImage
);
"unexpected fSystemImage, got %d instead of 0
\n
"
,
img
->
fSystemImage
);
ok
(
img
->
fDOSImage
==
0
,
ok
(
img
->
fDOSImage
==
0
,
...
@@ -484,14 +484,14 @@ static void test_image_load(void)
...
@@ -484,14 +484,14 @@ static void test_image_load(void)
todo_wine
ok
(
img
->
Version
==
1
||
broken
(
!
img
->
Version
)
/* <= WinXP */
,
todo_wine
ok
(
img
->
Version
==
1
||
broken
(
!
img
->
Version
)
/* <= WinXP */
,
"unexpected Version, got %d instead of 1
\n
"
,
img
->
Version
);
"unexpected Version, got %d instead of 1
\n
"
,
img
->
Version
);
ok
(
img
->
SizeOfImage
==
0x600
,
ok
(
img
->
SizeOfImage
==
0x600
,
"unexpected SizeOfImage, got 0x%x instead of 0x600
\n
"
,
img
->
SizeOfImage
);
"unexpected SizeOfImage, got 0x%
l
x instead of 0x600
\n
"
,
img
->
SizeOfImage
);
count
=
0xdeadbeef
;
count
=
0xdeadbeef
;
ret
=
GetImageUnusedHeaderBytes
(
img
,
&
count
);
ret
=
GetImageUnusedHeaderBytes
(
img
,
&
count
);
todo_wine
todo_wine
ok
(
ret
==
448
,
"GetImageUnusedHeaderBytes returned %u instead of 448
\n
"
,
ret
);
ok
(
ret
==
448
,
"GetImageUnusedHeaderBytes returned %
l
u instead of 448
\n
"
,
ret
);
todo_wine
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 %
l
u instead of 64
\n
"
,
count
);
ImageUnload
(
img
);
ImageUnload
(
img
);
}
}
...
...
dlls/imagehlp/tests/integrity.c
View file @
a24f29cd
...
@@ -183,8 +183,8 @@ static DWORD test_add_certificate(const char *cert_data, int len)
...
@@ -183,8 +183,8 @@ static DWORD test_add_certificate(const char *cert_data, int len)
CopyMemory
(
cert
->
bCertificate
,
cert_data
,
len
);
CopyMemory
(
cert
->
bCertificate
,
cert_data
,
len
);
ret
=
ImageAddCertificate
(
hFile
,
cert
,
&
index
);
ret
=
ImageAddCertificate
(
hFile
,
cert
,
&
index
);
ok
(
ret
,
"Unable to add certificate to image, error %x
\n
"
,
GetLastError
());
ok
(
ret
,
"Unable to add certificate to image, error %
l
x
\n
"
,
GetLastError
());
trace
(
"added cert index %d
\n
"
,
index
);
trace
(
"added cert index %
l
d
\n
"
,
index
);
HeapFree
(
GetProcessHeap
(),
0
,
cert
);
HeapFree
(
GetProcessHeap
(),
0
,
cert
);
CloseHandle
(
hFile
);
CloseHandle
(
hFile
);
...
@@ -210,7 +210,7 @@ static void test_get_certificate(const char *cert_data, int index)
...
@@ -210,7 +210,7 @@ static void test_get_certificate(const char *cert_data, int index)
ret
=
ImageGetCertificateData
(
hFile
,
index
,
NULL
,
&
cert_len
);
ret
=
ImageGetCertificateData
(
hFile
,
index
,
NULL
,
&
cert_len
);
err
=
GetLastError
();
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=%
l
x
\n
"
,
ret
,
err
);
cert
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
cert_len
);
cert
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
cert_len
);
...
@@ -222,7 +222,7 @@ static void test_get_certificate(const char *cert_data, int index)
...
@@ -222,7 +222,7 @@ static void test_get_certificate(const char *cert_data, int index)
}
}
ret
=
ImageGetCertificateData
(
hFile
,
index
,
cert
,
&
cert_len
);
ret
=
ImageGetCertificateData
(
hFile
,
index
,
cert
,
&
cert_len
);
ok
(
ret
,
"Unable to retrieve certificate; err=%x
\n
"
,
GetLastError
());
ok
(
ret
,
"Unable to retrieve certificate; err=%
l
x
\n
"
,
GetLastError
());
ok
(
memcmp
(
cert
->
bCertificate
,
cert_data
,
cert_len
-
sizeof
(
WIN_CERTIFICATE
))
==
0
,
"Certificate retrieved did not match original
\n
"
);
ok
(
memcmp
(
cert
->
bCertificate
,
cert_data
,
cert_len
-
sizeof
(
WIN_CERTIFICATE
))
==
0
,
"Certificate retrieved did not match original
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
cert
);
HeapFree
(
GetProcessHeap
(),
0
,
cert
);
...
@@ -244,13 +244,13 @@ static void test_remove_certificate(int index)
...
@@ -244,13 +244,13 @@ static void test_remove_certificate(int index)
}
}
ret
=
ImageEnumerateCertificates
(
hFile
,
CERT_SECTION_TYPE_ANY
,
&
orig_count
,
NULL
,
0
);
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=%
l
x
\n
"
,
GetLastError
());
ret
=
ImageRemoveCertificate
(
hFile
,
index
);
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=%
l
x
\n
"
,
GetLastError
());
/* Test to see if the certificate has actually been removed */
/* Test to see if the certificate has actually been removed */
ImageEnumerateCertificates
(
hFile
,
CERT_SECTION_TYPE_ANY
,
&
count
,
NULL
,
0
);
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=%l
d
\n
"
,
orig_count
,
count
);
CloseHandle
(
hFile
);
CloseHandle
(
hFile
);
}
}
...
@@ -268,60 +268,60 @@ static void test_pe_checksum(void)
...
@@ -268,60 +268,60 @@ static void test_pe_checksum(void)
ret
=
CheckSumMappedFile
(
NULL
,
0
,
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
NULL
,
0
,
&
checksum_orig
,
&
checksum_new
);
ok
(
!
ret
,
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
ok
(
!
ret
,
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
ok
(((
GetLastError
()
==
ERROR_INVALID_PARAMETER
)
||
(
GetLastError
()
==
0xdeadbeef
)),
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 %
l
x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
CheckSumMappedFile
((
void
*
)
0xdeadbeef
,
0
,
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
((
void
*
)
0xdeadbeef
,
0
,
&
checksum_orig
,
&
checksum_new
);
ok
(
!
ret
,
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
ok
(
!
ret
,
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
ok
(((
GetLastError
()
==
ERROR_INVALID_PARAMETER
)
||
(
GetLastError
()
==
0xdeadbeef
)),
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 %
l
x
\n
"
,
GetLastError
());
/* basic checksum tests */
/* basic checksum tests */
memset
(
buffer
,
0x11
,
sizeof
(
buffer
));
memset
(
buffer
,
0x11
,
sizeof
(
buffer
));
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
buffer
,
sizeof
(
buffer
),
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
buffer
,
sizeof
(
buffer
),
&
checksum_orig
,
&
checksum_new
);
ok
(
ret
==
NULL
,
"Expected NULL, got %p
\n
"
,
ret
);
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_orig
==
0
,
"Expected 0, got %
l
x
\n
"
,
checksum_orig
);
todo_wine
ok
(
checksum_new
==
0xaabe
,
"Expected 0xaabe, got %x
\n
"
,
checksum_new
);
todo_wine
ok
(
checksum_new
==
0xaabe
,
"Expected 0xaabe, got %
l
x
\n
"
,
checksum_new
);
memset
(
buffer
,
0x22
,
sizeof
(
buffer
));
memset
(
buffer
,
0x22
,
sizeof
(
buffer
));
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
buffer
,
sizeof
(
buffer
),
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
buffer
,
sizeof
(
buffer
),
&
checksum_orig
,
&
checksum_new
);
ok
(
ret
==
NULL
,
"Expected NULL, got %p
\n
"
,
ret
);
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_orig
==
0
,
"Expected 0, got %
l
x
\n
"
,
checksum_orig
);
todo_wine
ok
(
checksum_new
==
0x5569
,
"Expected 0x5569, got %x
\n
"
,
checksum_new
);
todo_wine
ok
(
checksum_new
==
0x5569
,
"Expected 0x5569, got %
l
x
\n
"
,
checksum_new
);
memset
(
buffer
,
0x22
,
sizeof
(
buffer
));
memset
(
buffer
,
0x22
,
sizeof
(
buffer
));
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
buffer
,
10
,
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
buffer
,
10
,
&
checksum_orig
,
&
checksum_new
);
ok
(
ret
==
NULL
,
"Expected NULL, got %p
\n
"
,
ret
);
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_orig
==
0
,
"Expected 0, got %
l
x
\n
"
,
checksum_orig
);
todo_wine
ok
(
checksum_new
==
0xaab4
,
"Expected 0xaab4, got %x
\n
"
,
checksum_new
);
todo_wine
ok
(
checksum_new
==
0xaab4
,
"Expected 0xaab4, got %
l
x
\n
"
,
checksum_new
);
memset
(
buffer
,
0x22
,
sizeof
(
buffer
));
memset
(
buffer
,
0x22
,
sizeof
(
buffer
));
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
buffer
,
11
,
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
buffer
,
11
,
&
checksum_orig
,
&
checksum_new
);
ok
(
ret
==
NULL
,
"Expected NULL, got %p
\n
"
,
ret
);
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_orig
==
0
,
"Expected 0, got %
l
x
\n
"
,
checksum_orig
);
todo_wine
ok
(
checksum_new
==
0xaad7
,
"Expected 0xaad7, got %x
\n
"
,
checksum_new
);
todo_wine
ok
(
checksum_new
==
0xaad7
,
"Expected 0xaad7, got %
l
x
\n
"
,
checksum_new
);
/* test checksum of PE module */
/* test checksum of PE module */
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
test_pe_executable
,
sizeof
(
test_pe_executable
),
ret
=
CheckSumMappedFile
(
test_pe_executable
,
sizeof
(
test_pe_executable
),
&
checksum_orig
,
&
checksum_new
);
&
checksum_orig
,
&
checksum_new
);
ok
((
char
*
)
ret
==
test_pe_executable
+
0x80
,
"Expected %p, got %p
\n
"
,
test_pe_executable
+
0x80
,
ret
);
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_orig
==
0xabcdef11
,
"Expected 0xabcdef11, got %
l
x
\n
"
,
checksum_orig
);
ok
(
checksum_new
==
0xaa4
,
"Expected 0xaa4, got %x
\n
"
,
checksum_new
);
ok
(
checksum_new
==
0xaa4
,
"Expected 0xaa4, got %
l
x
\n
"
,
checksum_new
);
ret_bool
=
GetModuleInformation
(
GetCurrentProcess
(),
GetModuleHandleA
(
NULL
),
ret_bool
=
GetModuleInformation
(
GetCurrentProcess
(),
GetModuleHandleA
(
NULL
),
&
modinfo
,
sizeof
(
modinfo
));
&
modinfo
,
sizeof
(
modinfo
));
ok
(
ret_bool
,
"GetModuleInformation failed, error: %x
\n
"
,
GetLastError
());
ok
(
ret_bool
,
"GetModuleInformation failed, error: %
l
x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
modinfo
.
SizeOfImage
,
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
modinfo
.
SizeOfImage
,
&
checksum_orig
,
&
checksum_new
);
ok
(
ret
!=
NULL
,
"Expected CheckSumMappedFile to succeed
\n
"
);
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 %
l
x
\n
"
,
GetLastError
());
ok
(
checksum_orig
!=
0xdeadbeef
,
"Expected orig checksum != 0xdeadbeef
\n
"
);
ok
(
checksum_orig
!=
0xdeadbeef
,
"Expected orig checksum != 0xdeadbeef
\n
"
);
ok
(
checksum_new
!=
0xdeadbeef
,
"Expected new checksum != 0xdeadbeef
\n
"
);
ok
(
checksum_new
!=
0xdeadbeef
,
"Expected new checksum != 0xdeadbeef
\n
"
);
...
@@ -330,9 +330,9 @@ static void test_pe_checksum(void)
...
@@ -330,9 +330,9 @@ static void test_pe_checksum(void)
ret
=
CheckSumMappedFile
((
char
*
)
modinfo
.
lpBaseOfDll
+
100
,
modinfo
.
SizeOfImage
-
100
,
ret
=
CheckSumMappedFile
((
char
*
)
modinfo
.
lpBaseOfDll
+
100
,
modinfo
.
SizeOfImage
-
100
,
&
checksum_orig
,
&
checksum_new
);
&
checksum_orig
,
&
checksum_new
);
ok
(
!
ret
,
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
ok
(
!
ret
,
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected err=0xdeadbeef, got %x
\n
"
,
GetLastError
());
ok
(
GetLastError
()
==
0xdeadbeef
,
"Expected err=0xdeadbeef, got %
l
x
\n
"
,
GetLastError
());
todo_wine
ok
(
checksum_orig
==
0
,
"Expected 0, got %x
\n
"
,
checksum_orig
);
todo_wine
ok
(
checksum_orig
==
0
,
"Expected 0, got %
l
x
\n
"
,
checksum_orig
);
todo_wine
ok
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
,
"Got unexpected value %x
\n
"
,
checksum_new
);
todo_wine
ok
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
,
"Got unexpected value %
l
x
\n
"
,
checksum_new
);
nt_header
=
ImageNtHeader
(
modinfo
.
lpBaseOfDll
);
nt_header
=
ImageNtHeader
(
modinfo
.
lpBaseOfDll
);
checksum_correct
=
nt_header
->
OptionalHeader
.
CheckSum
;
checksum_correct
=
nt_header
->
OptionalHeader
.
CheckSum
;
...
@@ -341,28 +341,28 @@ static void test_pe_checksum(void)
...
@@ -341,28 +341,28 @@ static void test_pe_checksum(void)
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
(
char
*
)
nt_header
-
(
char
*
)
modinfo
.
lpBaseOfDll
,
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
(
char
*
)
nt_header
-
(
char
*
)
modinfo
.
lpBaseOfDll
,
&
checksum_orig
,
&
checksum_new
);
&
checksum_orig
,
&
checksum_new
);
ok
(
!
ret
||
(
ret
==
nt_header
),
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
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_orig
==
0
)
||
(
checksum_orig
==
checksum_correct
),
"Expected %
lx, got %l
x
\n
"
,
checksum_correct
,
checksum_orig
);
ok
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
,
"Got unexpected value %x
\n
"
,
checksum_new
);
ok
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
,
"Got unexpected value %
l
x
\n
"
,
checksum_new
);
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
sizeof
(
IMAGE_DOS_HEADER
),
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
sizeof
(
IMAGE_DOS_HEADER
),
&
checksum_orig
,
&
checksum_new
);
&
checksum_orig
,
&
checksum_new
);
ok
(
!
ret
||
(
ret
==
nt_header
),
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
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_orig
==
0
)
||
(
checksum_orig
==
checksum_correct
),
"Expected %
lx, got %l
x
\n
"
,
checksum_correct
,
checksum_orig
);
ok
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
,
"Got unexpected value %x
\n
"
,
checksum_new
);
ok
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
,
"Got unexpected value %
l
x
\n
"
,
checksum_new
);
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
0
,
&
checksum_orig
,
&
checksum_new
);
ret
=
CheckSumMappedFile
(
modinfo
.
lpBaseOfDll
,
0
,
&
checksum_orig
,
&
checksum_new
);
ok
(
!
ret
||
(
ret
==
nt_header
),
"Expected CheckSumMappedFile to fail, got %p
\n
"
,
ret
);
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_orig
==
0xdeadbeef
)
||
(
checksum_orig
==
checksum_correct
),
"Expected %
lx, got %l
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_new
==
0xdeadbeef
)
||
(
checksum_new
!=
0
&&
checksum_new
!=
0xdeadbeef
),
"Got unexpected value %
l
x
\n
"
,
checksum_new
);
checksum_orig
=
checksum_new
=
0xdeadbeef
;
checksum_orig
=
checksum_new
=
0xdeadbeef
;
ret
=
CheckSumMappedFile
((
char
*
)
modinfo
.
lpBaseOfDll
+
1
,
0
,
ret
=
CheckSumMappedFile
((
char
*
)
modinfo
.
lpBaseOfDll
+
1
,
0
,
&
checksum_orig
,
&
checksum_new
);
&
checksum_orig
,
&
checksum_new
);
ok
(
ret
==
NULL
,
"Expected NULL, got %p
\n
"
,
ret
);
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_orig
==
0
)
||
(
checksum_orig
==
0xdeadbeef
),
"Expected 0, got %
l
x
\n
"
,
checksum_orig
);
ok
((
checksum_new
==
0
)
||
(
checksum_new
==
0xdeadbeef
),
"Expected 0, got %x
\n
"
,
checksum_new
);
ok
((
checksum_new
==
0
)
||
(
checksum_new
==
0xdeadbeef
),
"Expected 0, got %
l
x
\n
"
,
checksum_new
);
}
}
START_TEST
(
integrity
)
START_TEST
(
integrity
)
...
@@ -379,12 +379,12 @@ START_TEST(integrity)
...
@@ -379,12 +379,12 @@ START_TEST(integrity)
test_remove_certificate
(
first
);
test_remove_certificate
(
first
);
file_size
=
get_file_size
();
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: %l
d)
\n
"
,
file_size_orig
,
file_size
);
/* Try adding multiple certificates */
/* Try adding multiple certificates */
first
=
test_add_certificate
(
test_cert_data
,
sizeof
(
test_cert_data
));
first
=
test_add_certificate
(
test_cert_data
,
sizeof
(
test_cert_data
));
second
=
test_add_certificate
(
test_cert_data_2
,
sizeof
(
test_cert_data_2
));
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 %l
d
\n
"
,
first
,
second
);
test_get_certificate
(
test_cert_data
,
first
);
test_get_certificate
(
test_cert_data
,
first
);
test_get_certificate
(
test_cert_data_2
,
second
);
test_get_certificate
(
test_cert_data_2
,
second
);
...
@@ -397,7 +397,7 @@ START_TEST(integrity)
...
@@ -397,7 +397,7 @@ START_TEST(integrity)
test_remove_certificate
(
second
);
test_remove_certificate
(
second
);
file_size
=
get_file_size
();
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: %l
d)
\n
"
,
file_size_orig
,
file_size
);
test_pe_checksum
();
test_pe_checksum
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment