Skip to content

Commit

Permalink
新增一种 lib 编译方式。
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Jul 1, 2019
1 parent 16b1c2d commit 22d8296
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
27 changes: 26 additions & 1 deletion src/Build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand All @@ -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
10 changes: 9 additions & 1 deletion src/delayhlp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/pfnDliFailureHook2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


void* const __pfnDliFailureHook2;
3 changes: 3 additions & 0 deletions src/pfnDliNotifyHook2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


void* const __pfnDliNotifyHook2;

0 comments on commit 22d8296

Please sign in to comment.