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
7ddd79b8
Commit
7ddd79b8
authored
Sep 27, 2021
by
Paul Gofman
Committed by
Alexandre Julliard
Sep 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Sanitize flags in GetModuleHandleExW().
Signed-off-by:
Paul Gofman
<
pgofman@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
cf0a828b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
module.c
dlls/kernel32/tests/module.c
+17
-0
loader.c
dlls/kernelbase/loader.c
+10
-0
No files found.
dlls/kernel32/tests/module.c
View file @
7ddd79b8
...
...
@@ -1011,6 +1011,23 @@ static void testGetModuleHandleEx(void)
ok
(
error
==
ERROR_MOD_NOT_FOUND
,
"got %u
\n
"
,
error
);
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
GetModuleHandleExW
(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
|
GET_MODULE_HANDLE_EX_FLAG_PIN
,
(
LPCWSTR
)
mod_kernel32
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
SetLastError
(
0xdeadbeef
);
mod
=
(
HMODULE
)
0xdeadbeef
;
ret
=
GetModuleHandleExW
(
8
,
kernel32W
,
&
mod
);
error
=
GetLastError
();
ok
(
!
ret
,
"unexpected success
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u
\n
"
,
error
);
ok
(
mod
==
NULL
,
"got %p
\n
"
,
mod
);
FreeLibrary
(
mod_kernel32
);
}
...
...
dlls/kernelbase/loader.c
View file @
7ddd79b8
...
...
@@ -384,6 +384,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExW( DWORD flags, LPCWSTR name, HMO
return
FALSE
;
}
if
((
flags
&
~
(
GET_MODULE_HANDLE_EX_FLAG_PIN
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
|
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
))
||
(
flags
&
(
GET_MODULE_HANDLE_EX_FLAG_PIN
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
))
==
(
GET_MODULE_HANDLE_EX_FLAG_PIN
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
))
{
*
module
=
NULL
;
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
/* if we are messing with the refcount, grab the loader lock */
lock
=
(
flags
&
GET_MODULE_HANDLE_EX_FLAG_PIN
)
||
!
(
flags
&
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
);
if
(
lock
)
LdrLockLoaderLock
(
0
,
NULL
,
&
magic
);
...
...
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