diff --git a/copying.txt b/copying.txt index a6660123844..b1bb62a8089 100644 --- a/copying.txt +++ b/copying.txt @@ -1199,85 +1199,87 @@ e) modify or distribute the source code of any Distributable Code so that any pa This applies to MinHook, available from http://github.com/RaMMicHaeL/minhook ``` -/* - * MinHook - The Minimalistic API Hooking Library for x64/x86 - * Copyright (c) 2009 Tsuda Kageyu. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ +MinHook - The Minimalistic API Hooking Library for x64/x86 +Copyright (C) 2009-2017 Tsuda Kageyu. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================================ Portions of this software are Copyright (c) 2008-2009, Vyacheslav Patkov. ================================================================================ -/* - * Hacker Disassembler Engine 32 C - * Copyright (c) 2008-2009, Vyacheslav Patkov. - * All rights reserved. - * - */ +Hacker Disassembler Engine 32 C +Copyright (c) 2008-2009, Vyacheslav Patkov. +All rights reserved. -/* - * Hacker Disassembler Engine 64 C - * Copyright (c) 2008-2009, Vyacheslav Patkov. - * All rights reserved. - * - */ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: -================================================================================ -Portions of this software are Copyright (c) 2005-2007 Paul Hsieh. -================================================================================ -/* A portable stdint.h - **************************************************************************** - * BSD License: - **************************************************************************** - * - * Copyright (c) 2005-2007 Paul Hsieh - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------- +Hacker Disassembler Engine 64 C +Copyright (c) 2008-2009, Vyacheslav Patkov. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` = The MIT License = diff --git a/include/minhook b/include/minhook index ed5b5119afb..8fda4f5481f 160000 --- a/include/minhook +++ b/include/minhook @@ -1 +1 @@ -Subproject commit ed5b5119afb4127dd66905e2899c3265d8040aea +Subproject commit 8fda4f5481fed5797dc2651cd91e238e9b3928c6 diff --git a/nvdaHelper/minHook/sconscript b/nvdaHelper/minHook/sconscript index 71d06f69b36..fa8b56481e8 100644 --- a/nvdaHelper/minHook/sconscript +++ b/nvdaHelper/minHook/sconscript @@ -10,15 +10,13 @@ env=env.Clone(CPPPATH=minhookPath.Dir('include')) if 'analyze' in env['nvdaHelperDebugFlags']: env.Append(CCFLAGS='/analyze-') -HDESourceFile='HDE64/src/HDE64.c' if env['TARGET_ARCH']=='x86_64' else 'HDE32/HDE32.c' +HDESourceFile='HDE/HDE64.c' if env['TARGET_ARCH']=='x86_64' else 'HDE/HDE32.c' sourceFiles=[ HDESourceFile, - 'buffer.cpp', - 'export.cpp', - 'hook.cpp', - 'thread.cpp', - 'trampoline.cpp', + 'buffer.c', + 'hook.c', + 'trampoline.c', ] objFiles=[env.Object('_minHook_%s.obj'%x.replace('/','_'),minhookPath.File('src/%s'%x)) for x in sourceFiles] diff --git a/nvdaHelper/remote/apiHook.cpp b/nvdaHelper/remote/apiHook.cpp index 4c9848e5a51..3e855cc63e1 100644 --- a/nvdaHelper/remote/apiHook.cpp +++ b/nvdaHelper/remote/apiHook.cpp @@ -36,9 +36,9 @@ bool error_setNHFP=false; //function pointer typedefs for all minHook functions for use with getProcAddress typedef MH_STATUS(WINAPI *MH_Initialize_funcType)(); typedef MH_STATUS(WINAPI *MH_Uninitialize_funcType)(); -typedef MH_STATUS(WINAPI *MH_CreateHook_funcType)(void*,void*,void**); -typedef MH_STATUS(WINAPI *MH_EnableHook_funcType)(void*); -typedef MH_STATUS(WINAPI *MH_DisableHook_funcType)(void*); +typedef MH_STATUS(WINAPI *MH_CreateHook_funcType)(LPVOID,LPVOID,LPVOID*); +typedef MH_STATUS(WINAPI *MH_EnableHook_funcType)(LPVOID); +typedef MH_STATUS(WINAPI *MH_DisableHook_funcType)(LPVOID); #define defMHFP(funcName) funcName##_funcType funcName##_fp=NULL @@ -58,7 +58,6 @@ defMHFP(MH_DisableHook); bool apiHook_initialize() { LOG_DEBUG("calling MH_Initialize"); - int res; wstring dllPath=dllDirectory; dllPath+=L"\\minhook.dll"; if((minhookLibHandle=LoadLibrary(dllPath.c_str()))==NULL) { @@ -77,8 +76,9 @@ defMHFP(MH_DisableHook); minhookLibHandle=NULL; return false; } - if ((res=MH_Initialize_fp())!=MH_OK) { - LOG_ERROR("MH_CreateHook failed with " << res); + MH_STATUS res = MH_Initialize_fp(); + if (res!=MH_OK) { + LOG_ERROR("MH_Initialize failed with " << res); FreeLibrary(minhookLibHandle); minhookLibHandle=NULL; return false; @@ -104,9 +104,9 @@ void* apiHook_hookFunction(const char* moduleName, const char* functionName, voi } LOG_DEBUG("requesting to hook function " << functionName << " at address 0X" << std::hex << realFunc << " in module " << moduleName << " at address 0X" << moduleHandle << " with new function at address 0X" << newHookProc); void* origFunc; - int res; - if((res=MH_CreateHook_fp(realFunc,newHookProc,&origFunc))!=MH_OK) { - LOG_ERROR("MH_CreateHook failed with " << res); + MH_STATUS res = MH_CreateHook_fp(realFunc,newHookProc,&origFunc); + if(res!=MH_OK) { + LOG_ERROR("MH_CreateHook for function " << functionName << " in module " << moduleName << " failed with " << res); FreeLibrary(moduleHandle); return NULL; } @@ -117,25 +117,23 @@ void* apiHook_hookFunction(const char* moduleName, const char* functionName, voi } bool apiHook_enableHooks() { - int res; if(!minhookLibHandle) { LOG_ERROR(L"apiHooks not initialized"); return false; } - res=MH_EnableHook_fp(MH_ALL_HOOKS); + MH_STATUS res=MH_EnableHook_fp(MH_ALL_HOOKS); nhAssert(res==MH_OK); return TRUE; } bool apiHook_terminate() { - int res; //If the process is exiting then minHook will have already removed all hooks and unloaded if(isProcessExiting) return true; if(!minhookLibHandle) { LOG_ERROR(L"apiHooks not initialized"); return false; } - res=MH_DisableHook_fp(MH_ALL_HOOKS); + MH_STATUS res=MH_DisableHook_fp(MH_ALL_HOOKS); nhAssert(res==MH_OK); g_hookedFunctions.clear(); //Give enough time for all hook functions to complete.