From 22d82968487fb521dbeab9faef149d2f92eb418a Mon Sep 17 00:00:00 2001 From: mingkuang Date: Mon, 1 Jul 2019 10:43:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E7=A7=8D=20lib=20?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Build.cmd | 27 ++++++++++++++++++++++++++- src/delayhlp.cpp | 10 +++++++++- src/pfnDliFailureHook2.c | 3 +++ src/pfnDliNotifyHook2.c | 3 +++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/pfnDliFailureHook2.c create mode 100644 src/pfnDliNotifyHook2.c diff --git a/src/Build.cmd b/src/Build.cmd index eac0eb1..7e3dff6 100644 --- a/src/Build.cmd +++ b/src/Build.cmd @@ -5,6 +5,7 @@ pushd "%~dp0.." if "%Platform%"=="" set Platform=x86 +set AdditionalOptions=/O1 /Os /Oi /GS- /Z7 /MT /Zl /c /D "NDEBUG" call:Build%Platform% @@ -15,30 +16,54 @@ goto:eof :: BuildObj YY_Thunks_for_Vista.obj NTDDI_WIN6 :BuildObj -cl /O1 /Os /Oi /GS- /arch:IA32 /Z7 /MT /Fo"objs\\%Platform%\\%1" /Zl /c /D "NDEBUG" /D "__YY_GUARD_MIN_SUPPORT=%2" "%~dp0delayhlp.cpp" +mkdir "objs\\%Platform%" +cl %AdditionalOptions% /Fo"objs\\%Platform%\\%1" /D "__YY_GUARD_MIN_SUPPORT=%2" "%~dp0delayhlp.cpp" LibMaker.exe FixObj "%~dp0..\\objs\\%Platform%\\%1" /WeakExternFix:__pfnDliNotifyHook2=%PointType% LibMaker.exe FixObj "%~dp0..\\objs\\%Platform%\\%1" /WeakExternFix:__pfnDliFailureHook2=%PointType% +echo "objs\\%Platform%\\%1" +goto:eof + +:: BuildLIB YY_Thunks_for_Vista.lib NTDDI_WIN6 +:BuildLIB +mkdir "Out\\%Platform%" +mkdir "Libs\\%Platform%" + +cl %AdditionalOptions% /D "__YY_GUADD_BUILD_LIBS" /D "__YY_GUARD_MIN_SUPPORT=%2" /Fo"Out\\%Platform%\\delayhlp.obj" "%~dp0delayhlp.cpp" +cl %AdditionalOptions% /D "__YY_GUARD_MIN_SUPPORT=%2" /Fo"Out\\%Platform%\\YY-Guard.obj" "%~dp0YY-Guard.cpp" +cl %AdditionalOptions% /Fo"Out\\%Platform%\\pfnDliFailureHook2.obj" "%~dp0pfnDliFailureHook2.c" +cl %AdditionalOptions% /Fo"Out\\%Platform%\\pfnDliNotifyHook2.obj" "%~dp0pfnDliNotifyHook2.c" + +lib "Out\%Platform%\*.obj" /out:"Libs\%Platform%\%1" + +echo "Libs\%Platform%\%1" + goto:eof :Buildx86 set PointType=4 +set AdditionalOptions=%AdditionalOptions% /arch:IA32 + call:BuildObj YY_Guard.obj NTDDI_WINXP +call:BuildLIB delayimp.lib NTDDI_WINXP goto:eof :Buildx64 set PointType=8 call:BuildObj YY_Guard.obj NTDDI_WS03SP1 +call:BuildLIB delayimp.lib NTDDI_WS03SP1 goto:eof :Buildarm set PointType=4 call:BuildObj YY_Guard.obj NTDDI_WIN8 +call:BuildLIB delayimp.lib NTDDI_WIN8 goto:eof :Buildarm64 set PointType=8 call:BuildObj YY_Guard.obj NTDDI_WIN10_RS3 +call:BuildLIB delayimp.lib NTDDI_WIN10_RS3 goto:eof \ No newline at end of file diff --git a/src/delayhlp.cpp b/src/delayhlp.cpp index 5aca66d..bf27e39 100644 --- a/src/delayhlp.cpp +++ b/src/delayhlp.cpp @@ -28,7 +28,15 @@ #define DLOAD_UNLOAD 1 #include "dloadsup.h" + +#ifdef __YY_GUADD_BUILD_LIBS +#include "..\YY-Guard.h" +#else #include "YY-Guard.cpp" +#endif + +using namespace YY; + // // Local copies of strlen, memcmp, and memcpy to make sure we do not need the CRT // @@ -282,7 +290,7 @@ __delayLoadHelper2( hmod = HMODULE(((*__pfnDliNotifyHook2)(dliNotePreLoadLibrary, &dli))); } if (hmod == 0 && hmod != INVALID_HANDLE_VALUE) { - hmod = YY::YY_LoadLibraryFormSystem32A(dli.szDll); + hmod = YY_LoadLibraryFormSystem32A(dli.szDll); } if (hmod == 0 || hmod == INVALID_HANDLE_VALUE) { dli.dwLastError = ::GetLastError(); diff --git a/src/pfnDliFailureHook2.c b/src/pfnDliFailureHook2.c new file mode 100644 index 0000000..2d38111 --- /dev/null +++ b/src/pfnDliFailureHook2.c @@ -0,0 +1,3 @@ + + +void* const __pfnDliFailureHook2; \ No newline at end of file diff --git a/src/pfnDliNotifyHook2.c b/src/pfnDliNotifyHook2.c new file mode 100644 index 0000000..ff13b38 --- /dev/null +++ b/src/pfnDliNotifyHook2.c @@ -0,0 +1,3 @@ + + +void* const __pfnDliNotifyHook2; \ No newline at end of file