mirror of https://github.com/x64dbg/TitanEngine
- better library loaders (file mapping to send the file to debug)
- fixed module base reserving (before it was always reserved) - some code refactoring in TitanEngine.Debugger
This commit is contained in:
parent
adce077e48
commit
b06908df98
|
|
@ -2,6 +2,7 @@
|
|||
#include "definitions.h"
|
||||
#include "Global.Debugger.h"
|
||||
#include "Global.Engine.h"
|
||||
#include "Global.Breakpoints.h"
|
||||
|
||||
HARDWARE_DATA DebugRegister[4] = {};
|
||||
PROCESS_INFORMATION dbgProcessInformation = {};
|
||||
|
|
@ -17,6 +18,7 @@ ULONG_PTR DebugAttachedProcessCallBack = NULL;
|
|||
ULONG_PTR DebugReserveModuleBase = NULL;
|
||||
ULONG_PTR DebugDebuggingMainModuleBase = NULL;
|
||||
ULONG_PTR DebugDebuggingDLLBase = NULL;
|
||||
HANDLE DebugDLLFileMapping;
|
||||
bool DebugAttachedToProcess = false;
|
||||
bool DebugRemoveDebugPrivilege = false;
|
||||
bool DebugDebuggingDLL = false;
|
||||
|
|
@ -45,7 +47,7 @@ long DebugLoopInSecondThread(LPVOID InputParameter)
|
|||
{
|
||||
__try
|
||||
{
|
||||
if(InputParameter == NULL)
|
||||
if(InputParameter == NULL) //IsFileDll
|
||||
{
|
||||
InitDebugExW(expertDebug.szFileName, expertDebug.szCommandLine, expertDebug.szCurrentFolder, expertDebug.EntryCallBack);
|
||||
}
|
||||
|
|
@ -68,6 +70,7 @@ void DebuggerReset()
|
|||
{
|
||||
RtlZeroMemory(&myDBGCustomHandler, sizeof CustomHandler);
|
||||
}
|
||||
std::vector<BreakPointDetail>().swap(BreakPointBuffer);
|
||||
}
|
||||
|
||||
void ClearProcessList()
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ extern bool DebugRemoveDebugPrivilege;
|
|||
extern ULONG_PTR DebugReserveModuleBase;
|
||||
extern ULONG_PTR DebugDebuggingMainModuleBase;
|
||||
extern ULONG_PTR DebugDebuggingDLLBase;
|
||||
extern HANDLE DebugDLLFileMapping;
|
||||
extern bool DebugDebuggingDLL;
|
||||
extern wchar_t* DebugDebuggingDLLFullFileName;
|
||||
extern wchar_t* DebugDebuggingDLLFileName;
|
||||
|
|
|
|||
|
|
@ -127,12 +127,6 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
|||
DLLPatchAddress = (ULONG_PTR)DBGEvent.u.CreateProcessInfo.lpBaseOfImage;
|
||||
DLLPatchAddress = (ULONG_PTR)DLLPatchAddress + UE_MODULEx86;
|
||||
#endif
|
||||
if(!WriteProcessMemory(DBGEvent.u.CreateProcessInfo.hProcess, (LPVOID)DLLPatchAddress, DebugDebuggingDLLFullFileName, lstrlenW(DebugDebuggingDLLFullFileName) * 2, &NumberOfBytesReadWritten))
|
||||
{
|
||||
StopDebug();
|
||||
EngineCloseHandle(DBGFileHandle); //close file handle
|
||||
return;
|
||||
}
|
||||
if(DebugReserveModuleBase) //reserve original image base
|
||||
{
|
||||
VirtualAllocEx(dbgProcessInformation.hProcess, (void*)DebugReserveModuleBase, 0x1000, MEM_RESERVE, PAGE_READWRITE); //return value nt used, yea just ignore. return value doesnt matter and there is no possible fix when failed :D this is only used to make sure DLL loads on another image base
|
||||
|
|
@ -325,6 +319,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
|||
{
|
||||
if(lstrcmpiW(&DLLDebugFileName[i+1], DebugDebuggingDLLFileName) == NULL)
|
||||
{
|
||||
CloseHandle(DebugDLLFileMapping); //close file mapping handle
|
||||
SetBPX(DebugModuleEntryPoint + (ULONG_PTR)DBGEvent.u.LoadDll.lpBaseOfDll, UE_SINGLESHOOT, DebugModuleEntryPointCallBack);
|
||||
DebugDebuggingDLLBase = (ULONG_PTR)DBGEvent.u.LoadDll.lpBaseOfDll;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#include "Global.Debugger.h"
|
||||
#include "Global.Engine.h"
|
||||
#include "Global.Handle.h"
|
||||
#include "Global.Breakpoints.h"
|
||||
#include "Global.Threader.h"
|
||||
|
||||
static wchar_t szBackupDebuggedFileName[512];
|
||||
|
|
@ -44,54 +43,43 @@ __declspec(dllexport) void* TITCALL InitDebug(char* szFileName, char* szCommandL
|
|||
}
|
||||
__declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder)
|
||||
{
|
||||
wchar_t szCreateWithCmdLine[1024];
|
||||
int DebugConsoleFlag = NULL;
|
||||
|
||||
DebuggerReset();
|
||||
if(engineRemoveConsoleForDebugee)
|
||||
if(DebugDebuggingDLL)
|
||||
{
|
||||
DebugConsoleFlag = CREATE_NO_WINDOW|CREATE_SUSPENDED;
|
||||
}
|
||||
else if(engineRemoveConsoleForDebugee)
|
||||
{
|
||||
DebugConsoleFlag = CREATE_NO_WINDOW;
|
||||
}
|
||||
std::vector<BreakPointDetail>().swap(BreakPointBuffer);
|
||||
|
||||
if(engineEnableDebugPrivilege)
|
||||
{
|
||||
EngineSetDebugPrivilege(GetCurrentProcess(), true);
|
||||
DebugRemoveDebugPrivilege = true;
|
||||
}
|
||||
wchar_t* szFileNameCreateProcess;
|
||||
wchar_t* szCommandLineCreateProcess;
|
||||
if(szCommandLine == NULL || !lstrlenW(szCommandLine))
|
||||
{
|
||||
if(CreateProcessW(szFileName, NULL, NULL, NULL, false, DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS|DebugConsoleFlag|CREATE_NEW_CONSOLE, NULL, szCurrentFolder, &dbgStartupInfo, &dbgProcessInformation))
|
||||
{
|
||||
if(engineEnableDebugPrivilege)
|
||||
EngineSetDebugPrivilege(GetCurrentProcess(), false);
|
||||
DebugAttachedToProcess = false;
|
||||
DebugAttachedProcessCallBack = NULL;
|
||||
std::vector<BreakPointDetail>().swap(BreakPointBuffer);
|
||||
return &dbgProcessInformation;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
if(engineEnableDebugPrivilege)
|
||||
{
|
||||
EngineSetDebugPrivilege(GetCurrentProcess(), false);
|
||||
DebugRemoveDebugPrivilege = false;
|
||||
}
|
||||
memset(&dbgProcessInformation, 0, sizeof(PROCESS_INFORMATION));
|
||||
SetLastError(lastError);
|
||||
return 0;
|
||||
}
|
||||
szCommandLineCreateProcess=0;
|
||||
szFileNameCreateProcess=szFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t szCreateWithCmdLine[1024];
|
||||
wsprintfW(szCreateWithCmdLine, L"\"%s\" %s", szFileName, szCommandLine);
|
||||
if(CreateProcessW(NULL, szCreateWithCmdLine, NULL, NULL, false, DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS|DebugConsoleFlag|CREATE_NEW_CONSOLE, NULL, szCurrentFolder, &dbgStartupInfo, &dbgProcessInformation))
|
||||
szCommandLineCreateProcess=szCreateWithCmdLine;
|
||||
szFileNameCreateProcess=0;
|
||||
}
|
||||
if(CreateProcessW(szFileNameCreateProcess, szCommandLineCreateProcess, NULL, NULL, false, DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS|DebugConsoleFlag|CREATE_NEW_CONSOLE, NULL, szCurrentFolder, &dbgStartupInfo, &dbgProcessInformation))
|
||||
{
|
||||
if(engineEnableDebugPrivilege)
|
||||
EngineSetDebugPrivilege(GetCurrentProcess(), false);
|
||||
DebugAttachedToProcess = false;
|
||||
DebugAttachedProcessCallBack = NULL;
|
||||
std::vector<BreakPointDetail>().swap(BreakPointBuffer);
|
||||
return &dbgProcessInformation;
|
||||
}
|
||||
else
|
||||
|
|
@ -106,7 +94,6 @@ __declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szC
|
|||
SetLastError(lastError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(dllexport) void* TITCALL InitDebugEx(char* szFileName, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack)
|
||||
|
|
@ -158,25 +145,17 @@ __declspec(dllexport) void* TITCALL InitDLLDebug(char* szFileName, bool ReserveM
|
|||
|
||||
__declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool ReserveModuleBase, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack)
|
||||
{
|
||||
|
||||
int i = NULL;
|
||||
int j = NULL;
|
||||
bool ReturnData = false;
|
||||
DebugReserveModuleBase = NULL;
|
||||
|
||||
RtlZeroMemory(&szDebuggerName, sizeof szDebuggerName);
|
||||
if(lstrlenW(szFileName) < 512)
|
||||
memset(szDebuggerName, 0, sizeof(szDebuggerName));
|
||||
if(lstrlenW(szFileName) < sizeof(szDebuggerName))
|
||||
{
|
||||
RtlZeroMemory(&szBackupDebuggedFileName, sizeof szBackupDebuggedFileName);
|
||||
memset(szBackupDebuggedFileName, 0, sizeof(szBackupDebuggedFileName));
|
||||
lstrcpyW(szBackupDebuggedFileName, szFileName);
|
||||
szFileName = &szBackupDebuggedFileName[0];
|
||||
}
|
||||
lstrcpyW(szDebuggerName, szFileName);
|
||||
i = lstrlenW(szDebuggerName);
|
||||
int i = lstrlenW(szDebuggerName);
|
||||
while(szDebuggerName[i] != '\\' && i)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
wchar_t DLLLoaderName[64]=L"";
|
||||
#ifdef _WIN64
|
||||
wsprintfW(DLLLoaderName, L"DLLLoader64_%.4X.exe", GetTickCount()&0xFFFF);
|
||||
|
|
@ -189,27 +168,40 @@ __declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool Rese
|
|||
lstrcpyW(szDebuggerName, DLLLoaderName);
|
||||
|
||||
#if defined(_WIN64)
|
||||
ReturnData = EngineExtractResource("LOADERX64", szDebuggerName);
|
||||
if(EngineExtractResource("LOADERX64", szDebuggerName))
|
||||
#else
|
||||
ReturnData = EngineExtractResource("LOADERX86", szDebuggerName);
|
||||
if(EngineExtractResource("LOADERX86", szDebuggerName))
|
||||
#endif
|
||||
if(ReturnData)
|
||||
{
|
||||
DebugDebuggingDLL = true;
|
||||
i = lstrlenW(szFileName);
|
||||
while(szFileName[i] != 0x5C && i >= NULL)
|
||||
{
|
||||
int i = lstrlenW(szFileName);
|
||||
while(szFileName[i] != '\\' && i)
|
||||
i--;
|
||||
}
|
||||
DebugDebuggingDLLBase = NULL;
|
||||
DebugDebuggingMainModuleBase = NULL;
|
||||
DebugDebuggingDLLFullFileName = szFileName;
|
||||
DebugDebuggingDLLFileName = &szFileName[i+1];
|
||||
DebugModuleImageBase = (ULONG_PTR)GetPE32DataW(szFileName, NULL, UE_IMAGEBASE);
|
||||
DebugReserveModuleBase = DebugModuleImageBase;
|
||||
DebugModuleEntryPoint = (ULONG_PTR)GetPE32DataW(szFileName, NULL, UE_OEP);
|
||||
DebugModuleEntryPointCallBack = EntryCallBack;
|
||||
return InitDebugW(szDebuggerName, szCommandLine, szCurrentFolder);
|
||||
DebugReserveModuleBase = 0;
|
||||
if(ReserveModuleBase)
|
||||
DebugReserveModuleBase = DebugModuleImageBase;
|
||||
PPROCESS_INFORMATION ReturnValue = (PPROCESS_INFORMATION)InitDebugW(szDebuggerName, szCommandLine, szCurrentFolder);
|
||||
wchar_t szName[256]=L"";
|
||||
swprintf(szName, L"Global\\szLibraryName%X", (unsigned int)ReturnValue->dwProcessId);
|
||||
DebugDLLFileMapping=CreateFileMappingW(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 512*sizeof(wchar_t), szName);
|
||||
if(DebugDLLFileMapping)
|
||||
{
|
||||
wchar_t* szLibraryPathMapping=(wchar_t*)MapViewOfFile(DebugDLLFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 512*sizeof(wchar_t));
|
||||
if(szLibraryPathMapping)
|
||||
{
|
||||
wcscpy(szLibraryPathMapping, DebugDebuggingDLLFullFileName);
|
||||
UnmapViewOfFile(szLibraryPathMapping);
|
||||
}
|
||||
}
|
||||
ResumeThread(ReturnValue->hThread);
|
||||
return ReturnValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -234,7 +226,7 @@ __declspec(dllexport) bool TITCALL AttachDebugger(DWORD ProcessId, bool KillOnEx
|
|||
|
||||
if(ProcessId != NULL && dbgProcessInformation.hProcess == NULL)
|
||||
{
|
||||
std::vector<BreakPointDetail>().swap(BreakPointBuffer);
|
||||
DebuggerReset();
|
||||
if(engineEnableDebugPrivilege)
|
||||
{
|
||||
EngineSetDebugPrivilege(GetCurrentProcess(), true);
|
||||
|
|
@ -253,7 +245,6 @@ __declspec(dllexport) bool TITCALL AttachDebugger(DWORD ProcessId, bool KillOnEx
|
|||
myDebugSetProcessKillOnExit(KillOnExit);
|
||||
}
|
||||
}
|
||||
std::vector<BreakPointDetail>().swap(BreakPointBuffer);
|
||||
DebugDebuggingDLL = false;
|
||||
DebugAttachedToProcess = true;
|
||||
DebugAttachedProcessCallBack = (ULONG_PTR)CallBack;
|
||||
|
|
@ -353,7 +344,7 @@ __declspec(dllexport) void TITCALL AutoDebugEx(char* szFileName, bool ReserveMod
|
|||
|
||||
__declspec(dllexport) void TITCALL AutoDebugExW(wchar_t* szFileName, bool ReserveModuleBase, wchar_t* szCommandLine, wchar_t* szCurrentFolder, DWORD TimeOut, LPVOID EntryCallBack)
|
||||
{
|
||||
DebugReserveModuleBase = NULL;
|
||||
DebugReserveModuleBase = 0;
|
||||
DWORD ThreadId;
|
||||
DWORD ExitCode = 0;
|
||||
HANDLE hSecondThread;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#include <windows.h>
|
||||
|
||||
wchar_t szLibraryPath[512];
|
||||
|
||||
int main()
|
||||
{
|
||||
memset(szLibraryPath, 0, sizeof(szLibraryPath));
|
||||
wchar_t szName[256]=L"";
|
||||
wsprintfW(szName, L"Global\\szLibraryName%X", (unsigned int)GetCurrentProcessId());
|
||||
HANDLE hMapFile=OpenFileMappingW(FILE_MAP_READ, false, szName);
|
||||
if(hMapFile)
|
||||
{
|
||||
const wchar_t* szLibraryPathMapping=(const wchar_t*)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, sizeof(szLibraryPath));
|
||||
if(szLibraryPathMapping)
|
||||
{
|
||||
lstrcpyW(szLibraryPath, szLibraryPathMapping);
|
||||
UnmapViewOfFile(szLibraryPathMapping);
|
||||
}
|
||||
CloseHandle(hMapFile);
|
||||
}
|
||||
if(szLibraryPath[0])
|
||||
return (LoadLibraryW(szLibraryPath)!=NULL);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibraryLoader", "LibraryLoader.vcxproj", "{92C90AAD-036E-474D-902C-CFD1E7422899}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{92C90AAD-036E-474D-902C-CFD1E7422899}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{92C90AAD-036E-474D-902C-CFD1E7422899}.Release|Win32.Build.0 = Release|Win32
|
||||
{92C90AAD-036E-474D-902C-CFD1E7422899}.Release|x64.ActiveCfg = Release|x64
|
||||
{92C90AAD-036E-474D-902C-CFD1E7422899}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LibraryLoader.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{92C90AAD-036E-474D-902C-CFD1E7422899}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>LibraryLoader</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v100</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v100</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v100</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v100</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(ProjectDir)x32\</OutDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(ProjectDir)x64\</OutDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)ntdll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)ntdll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)ntdll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)ntdll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LibraryLoader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
format PE GUI
|
||||
entry start
|
||||
|
||||
section '.text' code readable executable
|
||||
start:
|
||||
push szLibraryName
|
||||
call [LoadLibraryW]
|
||||
cmp eax,1
|
||||
sbb ecx,ecx
|
||||
and ecx,61703078h
|
||||
push ecx
|
||||
call [ExitProcess]
|
||||
|
||||
section '.data' data readable writeable
|
||||
szLibraryName dw 512 dup (?)
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
dd 0,0,0,rva kernel_name,rva kernel_table
|
||||
dd 0,0,0,0,0
|
||||
|
||||
kernel_table:
|
||||
ExitProcess dd rva _ExitProcess
|
||||
LoadLibraryW dd rva _LoadLibraryW
|
||||
dd 0
|
||||
|
||||
kernel_name db 'kernel32.dll',0
|
||||
|
||||
_ExitProcess dw 0
|
||||
db 'ExitProcess',0
|
||||
_LoadLibraryW dw 0
|
||||
db 'LoadLibraryW',0
|
||||
Binary file not shown.
|
|
@ -1,31 +0,0 @@
|
|||
format PE64 GUI
|
||||
entry start
|
||||
|
||||
section '.text' code readable executable
|
||||
start:
|
||||
sub rsp,8*5
|
||||
lea rcx,[szLibraryName]
|
||||
call [LoadLibraryW]
|
||||
cmp rax,1
|
||||
sbb ecx,ecx
|
||||
and ecx,61703078h
|
||||
call [ExitProcess]
|
||||
|
||||
section '.data' data readable writeable
|
||||
szLibraryName dw 512 dup (?)
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
dd 0,0,0,rva kernel_name,rva kernel_table
|
||||
dd 0,0,0,0,0
|
||||
|
||||
kernel_table:
|
||||
ExitProcess dq rva _ExitProcess
|
||||
LoadLibraryW dq rva _LoadLibraryW
|
||||
dq 0
|
||||
|
||||
kernel_name db 'KERNEL32.DLL',0
|
||||
|
||||
_ExitProcess dw 0
|
||||
db 'ExitProcess',0
|
||||
_LoadLibraryW dw 0
|
||||
db 'LoadLibraryW',0
|
||||
Binary file not shown.
Loading…
Reference in New Issue