mirror of https://github.com/x64dbg/GleeBug
initial commit
This commit is contained in:
commit
41cc59a291
|
|
@ -0,0 +1,5 @@
|
||||||
|
Debug/
|
||||||
|
Release/
|
||||||
|
*.suo
|
||||||
|
*.sdf
|
||||||
|
*.opensdf
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.30723.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JoyBug", "JoyBug\JoyBug.vcxproj", "{B65A3680-9B6B-44E6-A046-649F94DF9F56}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B65A3680-9B6B-44E6-A046-649F94DF9F56}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B65A3680-9B6B-44E6-A046-649F94DF9F56}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B65A3680-9B6B-44E6-A046-649F94DF9F56}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B65A3680-9B6B-44E6-A046-649F94DF9F56}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "Debugger.Core.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
namespace Debugger
|
||||||
|
{
|
||||||
|
static DebugState state;
|
||||||
|
|
||||||
|
bool Init(const wchar_t* szFilePath,
|
||||||
|
const wchar_t* szCommandLine,
|
||||||
|
const wchar_t* szCurrentDirectory,
|
||||||
|
ProcessInfo* process)
|
||||||
|
{
|
||||||
|
STARTUPINFOW si;
|
||||||
|
memset(&si, 0, sizeof(si));
|
||||||
|
PROCESS_INFORMATION pi;
|
||||||
|
memset(&pi, 0, sizeof(pi));
|
||||||
|
const wchar_t* szFileNameCreateProcess;
|
||||||
|
wchar_t* szCommandLineCreateProcess;
|
||||||
|
if (szCommandLine == NULL || !wcslen(szCommandLine))
|
||||||
|
{
|
||||||
|
szCommandLineCreateProcess = 0;
|
||||||
|
szFileNameCreateProcess = szFilePath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wchar_t szCreateWithCmdLine[1024];
|
||||||
|
swprintf_s(szCreateWithCmdLine, L"\"%s\" %s", szFilePath, szCommandLine);
|
||||||
|
szCommandLineCreateProcess = szCreateWithCmdLine;
|
||||||
|
szFileNameCreateProcess = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CreateProcessW(szFileNameCreateProcess,
|
||||||
|
szCommandLineCreateProcess,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
FALSE,
|
||||||
|
DEBUG_PROCESS | CREATE_NEW_CONSOLE,
|
||||||
|
NULL,
|
||||||
|
szCurrentDirectory,
|
||||||
|
&si,
|
||||||
|
&pi))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
state.process.hProcess = pi.hProcess;
|
||||||
|
state.process.hThread = pi.hThread;
|
||||||
|
state.process.ProcessId = pi.dwProcessId;
|
||||||
|
state.process.MainThreadId = pi.dwThreadId;
|
||||||
|
if (process)
|
||||||
|
*process = state.process;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Stop()
|
||||||
|
{
|
||||||
|
return !!TerminateProcess(state.process.hProcess, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Detach()
|
||||||
|
{
|
||||||
|
return !!DebugActiveProcessStop(state.process.ProcessId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef _DEBUGGER_CORE_H
|
||||||
|
#define _DEBUGGER_CORE_H
|
||||||
|
|
||||||
|
#include "_global.h"
|
||||||
|
#include "Debugger.State.h"
|
||||||
|
|
||||||
|
namespace Debugger
|
||||||
|
{
|
||||||
|
bool Init(const wchar_t* szFilePath,
|
||||||
|
const wchar_t* szCommandLine,
|
||||||
|
const wchar_t* szCurrentDirectory,
|
||||||
|
ProcessInfo* process);
|
||||||
|
bool Stop();
|
||||||
|
bool Detach();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_DEBUGGER_CORE_H
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef _DEBUG_STATE_H
|
||||||
|
#define _DEBUG_STATE_H
|
||||||
|
|
||||||
|
#include "_global.h"
|
||||||
|
|
||||||
|
struct ProcessInfo
|
||||||
|
{
|
||||||
|
HANDLE hProcess;
|
||||||
|
HANDLE hThread;
|
||||||
|
DWORD ProcessId;
|
||||||
|
DWORD MainThreadId;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DebugState
|
||||||
|
{
|
||||||
|
ProcessInfo process;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_DEBUG_STATE_H
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?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="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{B65A3680-9B6B-44E6-A046-649F94DF9F56}</ProjectGuid>
|
||||||
|
<RootNamespace>JoyBug</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</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 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>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Debugger.Core.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="_global.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Debugger.Core.h" />
|
||||||
|
<ClInclude Include="Debugger.State.h" />
|
||||||
|
<ClInclude Include="_global.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?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="main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Debugger.Core.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="_global.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Debugger.Core.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="_global.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Debugger.State.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
#include "_global.h"
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef _GLOBAL_H
|
||||||
|
#define _GLOBAL_H
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#endif //_GLOBAL_H
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include <cstdio>
|
||||||
|
#include "Debugger.Core.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
wchar_t szFilePath[256] = L"c:\\CodeBlocks\\arma_cert_bin_info\\bin\\arma_cert_bin_info.exe";
|
||||||
|
wchar_t szCommandLine[256] = L"";
|
||||||
|
wchar_t szCurrentDir[256] = L"c:\\CodeBlocks\\arma_cert_bin_info\\bin";
|
||||||
|
ProcessInfo process;
|
||||||
|
if (Debugger::Init(szFilePath, NULL, szCurrentDir, &process))
|
||||||
|
{
|
||||||
|
printf("Debugger::Init success! PID: %X\n", process.ProcessId);
|
||||||
|
bool bDetached = Debugger::Detach();
|
||||||
|
printf("Debugger::Detach returned %s\n", bDetached ? "true" : "false");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
puts("Debugger::Init failed!");
|
||||||
|
}
|
||||||
|
system("pause");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue