Bug 1460022: Part 9 - Update sandboxing code to work with revised DLL interceptor interface; r=bobowen

This commit is contained in:
Aaron Klotz 2018-06-27 11:51:29 -06:00
parent d88f616e24
commit fab8ec82c6

View File

@ -15,7 +15,7 @@ namespace mozilla {
namespace sandboxing {
typedef BOOL(WINAPI* CloseHandle_func) (HANDLE hObject);
static CloseHandle_func stub_CloseHandle = nullptr;
static WindowsDllInterceptor::FuncHookType<CloseHandle_func> stub_CloseHandle;
typedef BOOL(WINAPI* DuplicateHandle_func)(HANDLE hSourceProcessHandle,
HANDLE hSourceHandle,
@ -24,7 +24,8 @@ typedef BOOL(WINAPI* DuplicateHandle_func)(HANDLE hSourceProcessHandle,
DWORD dwDesiredAccess,
BOOL bInheritHandle,
DWORD dwOptions);
static DuplicateHandle_func stub_DuplicateHandle = nullptr;
static WindowsDllInterceptor::FuncHookType<DuplicateHandle_func>
stub_DuplicateHandle;
static BOOL WINAPI
patched_CloseHandle(HANDLE hObject)
@ -62,17 +63,14 @@ EnableHandleCloseMonitoring()
{
Kernel32Intercept.Init("kernel32.dll");
bool hooked =
Kernel32Intercept.AddHook("CloseHandle",
reinterpret_cast<intptr_t>(patched_CloseHandle),
(void**)&stub_CloseHandle);
stub_CloseHandle.Set(Kernel32Intercept, "CloseHandle", &patched_CloseHandle);
if (!hooked) {
return false;
}
hooked =
Kernel32Intercept.AddHook("DuplicateHandle",
reinterpret_cast<intptr_t>(patched_DuplicateHandle),
(void**)&stub_DuplicateHandle);
stub_DuplicateHandle.Set(Kernel32Intercept, "DuplicateHandle",
&patched_DuplicateHandle);
if (!hooked) {
return false;
}