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
7133c000
Commit
7133c000
authored
Apr 05, 2012
by
Hans Leidekker
Committed by
Alexandre Julliard
Apr 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add tests for GetModuleHandleEx.
parent
cd860959
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
184 additions
and
1 deletion
+184
-1
module.c
dlls/kernel32/tests/module.c
+184
-1
No files found.
dlls/kernel32/tests/module.c
View file @
7133c000
...
...
@@ -23,8 +23,9 @@
static
DWORD
(
WINAPI
*
pGetDllDirectoryA
)(
DWORD
,
LPSTR
);
static
DWORD
(
WINAPI
*
pGetDllDirectoryW
)(
DWORD
,
LPWSTR
);
static
BOOL
(
WINAPI
*
pSetDllDirectoryA
)(
LPCSTR
);
static
BOOL
(
WINAPI
*
pGetModuleHandleExA
)(
DWORD
,
LPCSTR
,
HMODULE
*
);
static
BOOL
(
WINAPI
*
pGetModuleHandleExW
)(
DWORD
,
LPCWSTR
,
HMODULE
*
);
static
BOOL
is_unicode_enabled
=
TRUE
;
...
...
@@ -495,9 +496,190 @@ static void init_pointers(void)
MAKEFUNC
(
GetDllDirectoryA
);
MAKEFUNC
(
GetDllDirectoryW
);
MAKEFUNC
(
SetDllDirectoryA
);
MAKEFUNC
(
GetModuleHandleExA
);
MAKEFUNC
(
GetModuleHandleExW
);
#undef MAKEFUNC
}
static
void
testGetModuleHandleEx
(
void
)
{
static
const
WCHAR
kernel32W
[]
=
{
'k'
,
'e'
,
'r'
,
'n'
,
'e'
,
'l'
,
'3'
,
'2'
,
0
};
static
const
WCHAR
nosuchmodW
[]
=
{
'n'
,
'o'
,
's'
,
'u'
,
'c'
,
'h'
,
'm'
,
'o'
,
'd'
,
0
};
BOOL
ret
;
DWORD
error
;
HMODULE
mod
,
mod_kernel32
;
if
(
!
pGetModuleHandleExA
||
!
pGetModuleHandleExW
)
{
win_skip
(
"GetModuleHandleEx not available
\n
"
);
return
;
}
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExA
(
0
,
NULL
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExA
(
0
,
"kernel32"
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExA
(
0
,
"kernel32"
,
&
mod
);
ok
(
ret
,
"unexpected failure %u
\n
"
,
GetLastError
()
);
ok
(
mod
!=
(
HMODULE
)
0xdeadbeef
,
"got %p
\n
"
,
mod
);
FreeLibrary
(
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExA
(
0
,
"nosuchmod"
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
todo_wine
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExW
(
0
,
NULL
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExW
(
0
,
kernel32W
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExW
(
0
,
kernel32W
,
&
mod
);
ok
(
ret
,
"unexpected failure %u
\n
"
,
GetLastError
()
);
ok
(
mod
!=
(
HMODULE
)
0xdeadbeef
,
"got %p
\n
"
,
mod
);
FreeLibrary
(
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExW
(
0
,
nosuchmodW
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
todo_wine
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
NULL
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
"kernel32"
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
"kernel32"
,
&
mod
);
ok
(
ret
,
"unexpected failure %u
\n
"
,
GetLastError
()
);
ok
(
mod
!=
(
HMODULE
)
0xdeadbeef
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
"nosuchmod"
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
todo_wine
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
NULL
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
kernel32W
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
kernel32W
,
&
mod
);
ok
(
ret
,
"unexpected failure %u
\n
"
,
GetLastError
()
);
ok
(
mod
!=
(
HMODULE
)
0xdeadbeef
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
,
nosuchmodW
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
todo_wine
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
mod_kernel32
=
LoadLibraryA
(
"kernel32"
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
NULL
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
(
LPCSTR
)
mod_kernel32
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
(
LPCSTR
)
mod_kernel32
,
&
mod
);
ok
(
ret
,
"unexpected failure %u
\n
"
,
GetLastError
()
);
ok
(
mod
==
mod_kernel32
,
"got %p
\n
"
,
mod
);
FreeLibrary
(
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExA
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
(
LPCSTR
)
0xbeefdead
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
NULL
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
(
LPCWSTR
)
mod_kernel32
,
NULL
);
error
=
GetLastError
();
todo_wine
ok
(
!
ret
,
"unexpected success
\n
"
);
todo_wine
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
(
LPCWSTR
)
mod_kernel32
,
&
mod
);
ok
(
ret
,
"unexpected failure %u
\n
"
,
GetLastError
()
);
ok
(
mod
==
mod_kernel32
,
"got %p
\n
"
,
mod
);
FreeLibrary
(
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
pGetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
,
(
LPCWSTR
)
0xbeefdead
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
FreeLibrary
(
mod_kernel32
);
}
START_TEST
(
module
)
{
WCHAR
filenameW
[
MAX_PATH
];
...
...
@@ -525,4 +707,5 @@ START_TEST(module)
testLoadLibraryA_Wrong
();
testGetProcAddress_Wrong
();
testLoadLibraryEx
();
testGetModuleHandleEx
();
}
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