mirror of
https://github.com/x64dbg/x64dbg.git
synced 2024-11-23 04:50:07 +00:00
PROJECT: remove capstone
This commit is contained in:
parent
55d99b5647
commit
e5f950308a
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
||||
[submodule "src/capstone_wrapper"]
|
||||
path = src/capstone_wrapper
|
||||
url = https://github.com/x64dbg/capstone_wrapper.git
|
||||
[submodule "src/gui/Translations"]
|
||||
path = src/gui/Translations
|
||||
url = https://github.com/x64dbg/Translations.git
|
||||
|
@ -60,9 +60,9 @@ if "%2"=="" (
|
||||
echo Building with SonarQube
|
||||
build-wrapper --out-dir bw-output build.bat %2
|
||||
if not defined APPVEYOR_PULL_REQUEST_NUMBER (
|
||||
sonar-scanner -Dsonar.projectKey=x64dbg -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=mrexodia-github -Dsonar.login=%SONARQUBE_TOKEN% -Dsonar.exclusions=src/capstone_wrapper/**,src/dbg/btparser/**,src/gui_build/**,src/zydis_wrapper/zydis/**
|
||||
sonar-scanner -Dsonar.projectKey=x64dbg -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=mrexodia-github -Dsonar.login=%SONARQUBE_TOKEN% -Dsonar.exclusions=src/dbg/btparser/**,src/gui_build/**,src/zydis_wrapper/zydis/**
|
||||
) else (
|
||||
sonar-scanner -Dsonar.projectKey=x64dbg -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=mrexodia-github -Dsonar.login=%SONARQUBE_TOKEN% -Dsonar.exclusions=src/capstone_wrapper/**,src/dbg/btparser/**,src/gui_build/**,src/zydis_wrapper/zydis/** -Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=%APPVEYOR_PULL_REQUEST_NUMBER% -Dsonar.github.repository=x64dbg/x64dbg -Dsonar.github.oauth=%GITHUB_TOKEN%
|
||||
sonar-scanner -Dsonar.projectKey=x64dbg -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=mrexodia-github -Dsonar.login=%SONARQUBE_TOKEN% -Dsonar.exclusions=src/dbg/btparser/**,src/gui_build/**,src/zydis_wrapper/zydis/** -Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=%APPVEYOR_PULL_REQUEST_NUMBER% -Dsonar.github.repository=x64dbg/x64dbg -Dsonar.github.oauth=%GITHUB_TOKEN%
|
||||
)
|
||||
goto :restorepath
|
||||
|
||||
|
2
deps
2
deps
@ -1 +1 @@
|
||||
Subproject commit ccb293e2ff6076e07d5e01e08717a168487e7b4a
|
||||
Subproject commit 67f089f8416d806101913ec619cbb557540d2f64
|
@ -6,7 +6,6 @@ mkdir %RELEASEDIR%
|
||||
echo pluginsdk
|
||||
|
||||
mkdir %RELEASEDIR%\pluginsdk
|
||||
mkdir %RELEASEDIR%\pluginsdk\capstone
|
||||
mkdir %RELEASEDIR%\pluginsdk\dbghelp
|
||||
mkdir %RELEASEDIR%\pluginsdk\DeviceNameResolver
|
||||
mkdir %RELEASEDIR%\pluginsdk\jansson
|
||||
@ -16,7 +15,6 @@ mkdir %RELEASEDIR%\pluginsdk\XEDParse
|
||||
mkdir %RELEASEDIR%\pluginsdk\yara
|
||||
mkdir %RELEASEDIR%\pluginsdk\yara\yara
|
||||
|
||||
xcopy src\capstone_wrapper\capstone %RELEASEDIR%\pluginsdk\capstone /S /Y
|
||||
xcopy src\dbg\dbghelp %RELEASEDIR%\pluginsdk\dbghelp /S /Y
|
||||
xcopy src\dbg\DeviceNameResolver %RELEASEDIR%\pluginsdk\DeviceNameResolver /S /Y
|
||||
xcopy src\dbg\jansson %RELEASEDIR%\pluginsdk\jansson /S /Y
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 578d387f3c89692613990f049317194d70be1c14
|
@ -320,14 +320,6 @@
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\capstone_wrapper\capstone_wrapper.vcxproj">
|
||||
<Project>{c9b06e6e-3534-4e7b-9c00-c3ea33cc4e15}</Project>
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E6548308-401E-3A8A-5819-905DB90522A6}</ProjectGuid>
|
||||
@ -376,26 +368,26 @@
|
||||
<OutDir>$(ProjectDir)..\..\bin\x32\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<TargetName>x32dbg</TargetName>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir)..\capstone_wrapper;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\bin\x32d\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
<TargetName>x32dbg</TargetName>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir)..\capstone_wrapper;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\bin\x64\</OutDir>
|
||||
<TargetName>x64dbg</TargetName>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir)..\capstone_wrapper;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)..\..\bin\x64d\</OutDir>
|
||||
<TargetName>x64dbg</TargetName>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir)..\capstone_wrapper;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\zydis_wrapper;$(ProjectDir)..\zydis_wrapper\zydis\include;$(ProjectDir);$(ProjectDir)analysis;$(ProjectDir)commands;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
@ -419,7 +411,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ntdll\ntdll_x86.lib;keystone\keystone_x86.lib;$(ProjectDir)..\zydis_wrapper\bin\x32\zydis_wrapper.lib;$(ProjectDir)..\capstone_wrapper\bin\x32\capstone_wrapper.lib;$(ProjectDir)..\capstone_wrapper\capstone\capstone_x86.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ntdll\ntdll_x86.lib;keystone\keystone_x86.lib;$(ProjectDir)..\zydis_wrapper\bin\x32\zydis_wrapper.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@ -440,7 +432,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<AdditionalDependencies>ntdll\ntdll_x86.lib;keystone\keystone_x86.lib;$(ProjectDir)..\zydis_wrapper\bin\x32d\zydis_wrapper.lib;$(ProjectDir)..\capstone_wrapper\bin\x32d\capstone_wrapper.lib;$(ProjectDir)..\capstone_wrapper\capstone\capstone_x86.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32d\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>ntdll\ntdll_x86.lib;keystone\keystone_x86.lib;$(ProjectDir)..\zydis_wrapper\bin\x32d\zydis_wrapper.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32d\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@ -467,7 +459,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>$(ProjectDir)..\zydis_wrapper\bin\x64\zydis_wrapper.lib;$(ProjectDir)..\capstone_wrapper\bin\x64\capstone_wrapper.lib;$(ProjectDir)..\capstone_wrapper\capstone\capstone_x64.lib;ntdll\ntdll_x64.lib;keystone\keystone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(ProjectDir)..\zydis_wrapper\bin\x64\zydis_wrapper.lib;ntdll\ntdll_x64.lib;keystone\keystone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@ -491,7 +483,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<AdditionalDependencies>$(ProjectDir)..\zydis_wrapper\bin\x64d\zydis_wrapper.lib;$(ProjectDir)..\capstone_wrapper\bin\x64d\capstone_wrapper.lib;$(ProjectDir)..\capstone_wrapper\capstone\capstone_x64.lib;ntdll\ntdll_x64.lib;keystone\keystone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64d\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(ProjectDir)..\zydis_wrapper\bin\x64d\zydis_wrapper.lib;ntdll\ntdll_x64.lib;keystone\keystone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64d\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;ws2_32.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "MainWindow.h"
|
||||
#include "CachedFontMetrics.h"
|
||||
#include "QBeaEngine.h"
|
||||
#include "CsQBeaEngine.h"
|
||||
#include "MemoryPage.h"
|
||||
|
||||
Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent), mDisassemblyPopup(this)
|
||||
@ -34,8 +33,6 @@ Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent), mDisassem
|
||||
|
||||
mDisasm = new QBeaEngine(maxModuleSize);
|
||||
mDisasm->UpdateConfig();
|
||||
mCsDisasm = new CsQBeaEngine(maxModuleSize);
|
||||
mCsDisasm->UpdateConfig();
|
||||
|
||||
mCodeFoldingManager = nullptr;
|
||||
duint setting;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
class CodeFoldingHelper;
|
||||
class QBeaEngine;
|
||||
class CsQBeaEngine;
|
||||
class MemoryPage;
|
||||
|
||||
class Disassembly : public AbstractTableView
|
||||
@ -224,7 +223,6 @@ protected:
|
||||
bool mPopupEnabled;
|
||||
MemoryPage* mMemPage;
|
||||
QBeaEngine* mDisasm;
|
||||
CsQBeaEngine* mCsDisasm;
|
||||
bool mShowMnemonicBrief;
|
||||
XREF_INFO mXrefInfo;
|
||||
CodeFoldingHelper* mCodeFoldingManager;
|
||||
|
@ -1,329 +0,0 @@
|
||||
#include "CsQBeaEngine.h"
|
||||
#include "StringUtil.h"
|
||||
#include "EncodeMap.h"
|
||||
#include "CodeFolding.h"
|
||||
|
||||
CsQBeaEngine::CsQBeaEngine(int maxModuleSize)
|
||||
: _tokenizer(maxModuleSize), mCodeFoldingManager(nullptr), _bLongDataInst(false)
|
||||
{
|
||||
CsCapstoneTokenizer::UpdateColors();
|
||||
UpdateDataInstructionMap();
|
||||
this->mEncodeMap = new EncodeMap();
|
||||
}
|
||||
|
||||
CsQBeaEngine::~CsQBeaEngine()
|
||||
{
|
||||
delete this->mEncodeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the address of the nth instruction before the instruction pointed by ip. @n
|
||||
* This function has been grabbed from OllyDbg ("Disassembleback" in asmserv.c)
|
||||
*
|
||||
* @param[in] data Address of the data to disassemble
|
||||
* @param[in] base Original base address of the memory page (Required to disassemble destination addresses)
|
||||
* @param[in] size Size of the data block pointed by data
|
||||
* @param[in] ip RVA of the current instruction (Relative to data pointer)
|
||||
* @param[in] n Number of instruction back
|
||||
*
|
||||
* @return Return the RVA (Relative to the data pointer) of the nth instruction before the instruction pointed by ip
|
||||
*/
|
||||
ulong CsQBeaEngine::DisassembleBack(byte_t* data, duint base, duint size, duint ip, int n)
|
||||
{
|
||||
int i;
|
||||
uint abuf[128], addr, back, cmdsize;
|
||||
unsigned char* pdata;
|
||||
|
||||
// Reset Disasm Structure
|
||||
Capstone cp;
|
||||
|
||||
// Check if the pointer is not null
|
||||
if(data == NULL)
|
||||
return 0;
|
||||
|
||||
// Round the number of back instructions to 127
|
||||
if(n < 0)
|
||||
n = 0;
|
||||
else if(n > 127)
|
||||
n = 127;
|
||||
|
||||
// Check if the instruction pointer ip is not outside the memory range
|
||||
if(ip >= size)
|
||||
ip = size - 1;
|
||||
|
||||
// Obvious answer
|
||||
if(n == 0)
|
||||
return ip;
|
||||
|
||||
if(ip < (uint)n)
|
||||
return ip;
|
||||
|
||||
//TODO: buffer overflow due to unchecked "back" value
|
||||
back = MAX_DISASM_BUFFER * (n + 3); // Instruction length limited to 16
|
||||
|
||||
if(ip < back)
|
||||
back = ip;
|
||||
|
||||
addr = ip - back;
|
||||
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(addr + base))
|
||||
{
|
||||
duint newback = mCodeFoldingManager->getFoldBegin(addr + base);
|
||||
if(newback >= base && newback < size + base)
|
||||
addr = newback - base;
|
||||
}
|
||||
|
||||
pdata = data + addr;
|
||||
|
||||
for(i = 0; addr < ip; i++)
|
||||
{
|
||||
abuf[i % 128] = addr;
|
||||
|
||||
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(addr + base))
|
||||
{
|
||||
duint newaddr = mCodeFoldingManager->getFoldBegin(addr + base);
|
||||
if(newaddr >= base)
|
||||
{
|
||||
addr = newaddr - base;
|
||||
}
|
||||
cmdsize = mCodeFoldingManager->getFoldEnd(addr + base) - (addr + base) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!cp.DisassembleSafe(addr + base, pdata, (int)size))
|
||||
cmdsize = 2; //heuristic for better output (FF FE or FE FF are usually part of an instruction)
|
||||
else
|
||||
cmdsize = cp.Size();
|
||||
|
||||
cmdsize = mEncodeMap->getDataSize(base + addr, cmdsize);
|
||||
|
||||
}
|
||||
|
||||
|
||||
pdata += cmdsize;
|
||||
addr += cmdsize;
|
||||
back -= cmdsize;
|
||||
size -= cmdsize;
|
||||
}
|
||||
|
||||
if(i < n)
|
||||
return abuf[0];
|
||||
else
|
||||
return abuf[(i - n + 128) % 128];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the address of the nth instruction after the instruction pointed by ip. @n
|
||||
* This function has been grabbed from OllyDbg ("Disassembleforward" in asmserv.c)
|
||||
*
|
||||
* @param[in] data Address of the data to disassemble
|
||||
* @param[in] base Original base address of the memory page (Required to disassemble destination addresses)
|
||||
* @param[in] size Size of the data block pointed by data
|
||||
* @param[in] ip RVA of the current instruction (Relative to data pointer)
|
||||
* @param[in] n Number of instruction next
|
||||
*
|
||||
* @return Return the RVA (Relative to the data pointer) of the nth instruction after the instruction pointed by ip
|
||||
*/
|
||||
ulong CsQBeaEngine::DisassembleNext(byte_t* data, duint base, duint size, duint ip, int n)
|
||||
{
|
||||
int i;
|
||||
uint cmdsize;
|
||||
unsigned char* pdata;
|
||||
|
||||
// Reset Disasm Structure
|
||||
Capstone cp;
|
||||
|
||||
if(data == NULL)
|
||||
return 0;
|
||||
|
||||
if(ip >= size)
|
||||
ip = size - 1;
|
||||
|
||||
if(n <= 0)
|
||||
return ip;
|
||||
|
||||
|
||||
pdata = data + ip;
|
||||
size -= ip;
|
||||
|
||||
for(i = 0; i < n && size > 0; i++)
|
||||
{
|
||||
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(ip + base))
|
||||
{
|
||||
cmdsize = mCodeFoldingManager->getFoldEnd(ip + base) - (ip + base) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!cp.DisassembleSafe(ip + base, pdata, (int)size))
|
||||
cmdsize = 1;
|
||||
else
|
||||
cmdsize = cp.Size();
|
||||
|
||||
cmdsize = mEncodeMap->getDataSize(base + ip, cmdsize);
|
||||
|
||||
}
|
||||
|
||||
pdata += cmdsize;
|
||||
ip += cmdsize;
|
||||
size -= cmdsize;
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disassemble the instruction at the given ip RVA.
|
||||
*
|
||||
* @param[in] data Pointer to memory data (Can be either a buffer or the original data memory)
|
||||
* @param[in] size Size of the memory pointed by data (Can be the memory page size if data points to the original memory page base address)
|
||||
* @param[in] origBase Original base address of the memory page (Required to disassemble destination addresses)
|
||||
* @param[in] origInstRVA Original Instruction RVA of the instruction to disassemble
|
||||
*
|
||||
* @return Return the disassembled instruction
|
||||
*/
|
||||
Instruction_t CsQBeaEngine::DisassembleAt(byte_t* data, duint size, duint origBase, duint origInstRVA, bool datainstr)
|
||||
{
|
||||
if(datainstr)
|
||||
{
|
||||
ENCODETYPE type = mEncodeMap->getDataType(origBase + origInstRVA);
|
||||
if(!mEncodeMap->isCode(type))
|
||||
return DecodeDataAt(data, size, origBase, origInstRVA, type);
|
||||
}
|
||||
//tokenize
|
||||
CapstoneTokenizer::InstructionToken cap;
|
||||
_tokenizer.Tokenize(origBase + origInstRVA, data, size, cap);
|
||||
int len = _tokenizer.Size();
|
||||
|
||||
const auto & cp = _tokenizer.GetCapstone();
|
||||
bool success = cp.Success();
|
||||
|
||||
|
||||
auto branchType = Instruction_t::None;
|
||||
Instruction_t wInst;
|
||||
if(success && (cp.InGroup(CS_GRP_JUMP) || cp.IsLoop() || cp.InGroup(CS_GRP_CALL) || cp.InGroup(CS_GRP_RET)))
|
||||
{
|
||||
wInst.branchDestination = DbgGetBranchDestination(origBase + origInstRVA);
|
||||
switch(cp.GetId())
|
||||
{
|
||||
case X86_INS_JMP:
|
||||
case X86_INS_LJMP:
|
||||
branchType = Instruction_t::Unconditional;
|
||||
break;
|
||||
case X86_INS_CALL:
|
||||
case X86_INS_LCALL:
|
||||
branchType = Instruction_t::Call;
|
||||
break;
|
||||
default:
|
||||
branchType = cp.InGroup(CS_GRP_RET) ? Instruction_t::None : Instruction_t::Conditional;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
wInst.branchDestination = 0;
|
||||
|
||||
wInst.instStr = QString(cp.InstructionText().c_str());
|
||||
wInst.dump = QByteArray((const char*)data, len);
|
||||
wInst.rva = origInstRVA;
|
||||
if(mCodeFoldingManager && mCodeFoldingManager->isFolded(origInstRVA))
|
||||
wInst.length = mCodeFoldingManager->getFoldEnd(origInstRVA + origBase) - (origInstRVA + origBase) + 1;
|
||||
else
|
||||
wInst.length = len;
|
||||
wInst.branchType = branchType;
|
||||
wInst.tokens = cap;
|
||||
|
||||
if(success)
|
||||
{
|
||||
cp.RegInfo(reginfo);
|
||||
cp.FlagInfo(flaginfo);
|
||||
|
||||
auto flaginfo2reginfo = [](uint8_t info)
|
||||
{
|
||||
auto result = 0;
|
||||
#define checkFlag(test, reg) result |= (info & test) == test ? reg : 0
|
||||
checkFlag(Capstone::Modify, Capstone::Write);
|
||||
checkFlag(Capstone::Prior, Capstone::None);
|
||||
checkFlag(Capstone::Reset, Capstone::Write);
|
||||
checkFlag(Capstone::Set, Capstone::Write);
|
||||
checkFlag(Capstone::Test, Capstone::Read);
|
||||
checkFlag(Capstone::Undefined, Capstone::None);
|
||||
#undef checkFlag
|
||||
return result;
|
||||
};
|
||||
|
||||
for(uint8_t i = Capstone::FLAG_INVALID; i < Capstone::FLAG_ENDING; i++)
|
||||
if(flaginfo[i])
|
||||
{
|
||||
reginfo[X86_REG_EFLAGS] = Capstone::None;
|
||||
wInst.regsReferenced.push_back({cp.FlagName(Capstone::Flag(i)), flaginfo2reginfo(flaginfo[i])});
|
||||
}
|
||||
|
||||
reginfo[ArchValue(X86_REG_EIP, X86_REG_RIP)] = Capstone::None;
|
||||
for(uint8_t i = X86_REG_INVALID; i < X86_REG_ENDING; i++)
|
||||
if(reginfo[i])
|
||||
wInst.regsReferenced.push_back({cp.RegName(x86_reg(i)), reginfo[i]});
|
||||
}
|
||||
|
||||
return wInst;
|
||||
}
|
||||
|
||||
Instruction_t CsQBeaEngine::DecodeDataAt(byte_t* data, duint size, duint origBase, duint origInstRVA, ENCODETYPE type)
|
||||
{
|
||||
//tokenize
|
||||
CapstoneTokenizer::InstructionToken cap;
|
||||
|
||||
auto infoIter = dataInstMap.constFind(type);
|
||||
if(infoIter == dataInstMap.end())
|
||||
infoIter = dataInstMap.constFind(enc_byte);
|
||||
|
||||
int len = mEncodeMap->getDataSize(origBase + origInstRVA, 1);
|
||||
|
||||
QString mnemonic = _bLongDataInst ? infoIter.value().longName : infoIter.value().shortName;
|
||||
|
||||
len = std::min(len, (int)size);
|
||||
|
||||
QString datastr = GetDataTypeString(data, len, type);
|
||||
|
||||
_tokenizer.TokenizeData(mnemonic, datastr, cap);
|
||||
|
||||
Instruction_t wInst;
|
||||
wInst.instStr = mnemonic + " " + datastr;
|
||||
wInst.dump = QByteArray((const char*)data, len);
|
||||
wInst.rva = origInstRVA;
|
||||
wInst.length = len;
|
||||
wInst.branchType = Instruction_t::None;
|
||||
wInst.branchDestination = 0;
|
||||
wInst.tokens = cap;
|
||||
|
||||
return wInst;
|
||||
}
|
||||
|
||||
void CsQBeaEngine::UpdateDataInstructionMap()
|
||||
{
|
||||
dataInstMap.clear();
|
||||
dataInstMap.insert(enc_byte, {"db", "byte", "int8"});
|
||||
dataInstMap.insert(enc_word, {"dw", "word", "short"});
|
||||
dataInstMap.insert(enc_dword, {"dd", "dword", "int"});
|
||||
dataInstMap.insert(enc_fword, {"df", "fword", "fword"});
|
||||
dataInstMap.insert(enc_qword, {"dq", "qword", "long"});
|
||||
dataInstMap.insert(enc_tbyte, {"tbyte", "tbyte", "tbyte"});
|
||||
dataInstMap.insert(enc_oword, {"oword", "oword", "oword"});
|
||||
dataInstMap.insert(enc_mmword, {"mmword", "mmword", "long long"});
|
||||
dataInstMap.insert(enc_xmmword, {"xmmword", "xmmword", "_m128"});
|
||||
dataInstMap.insert(enc_ymmword, {"ymmword", "ymmword", "_m256"});
|
||||
dataInstMap.insert(enc_real4, {"real4", "real4", "float"});
|
||||
dataInstMap.insert(enc_real8, {"real8", "real8", "double"});
|
||||
dataInstMap.insert(enc_real10, {"real10", "real10", "long double"});
|
||||
dataInstMap.insert(enc_ascii, {"ascii", "ascii", "string"});
|
||||
dataInstMap.insert(enc_unicode, {"unicode", "unicode", "wstring"});
|
||||
}
|
||||
|
||||
void CsQBeaEngine::setCodeFoldingManager(CodeFoldingHelper* CodeFoldingManager)
|
||||
{
|
||||
mCodeFoldingManager = CodeFoldingManager;
|
||||
}
|
||||
|
||||
void CsQBeaEngine::UpdateConfig()
|
||||
{
|
||||
_bLongDataInst = ConfigBool("Disassembler", "LongDataInstruction");
|
||||
_tokenizer.UpdateConfig();
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
#ifndef CSQBEAENGINE_H
|
||||
#define CSQBEAENGINE_H
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
#include "cs_capstone_gui.h"
|
||||
#include "QBeaEngine.h" // for instruction_t
|
||||
|
||||
class EncodeMap;
|
||||
class CodeFoldingHelper;
|
||||
|
||||
class CsQBeaEngine
|
||||
{
|
||||
public:
|
||||
explicit CsQBeaEngine(int maxModuleSize);
|
||||
~CsQBeaEngine();
|
||||
ulong DisassembleBack(byte_t* data, duint base, duint size, duint ip, int n);
|
||||
ulong DisassembleNext(byte_t* data, duint base, duint size, duint ip, int n);
|
||||
Instruction_t DisassembleAt(byte_t* data, duint size, duint origBase, duint origInstRVA, bool datainstr = true);
|
||||
Instruction_t DecodeDataAt(byte_t* data, duint size, duint origBase, duint origInstRVA, ENCODETYPE type);
|
||||
void setCodeFoldingManager(CodeFoldingHelper* CodeFoldingManager);
|
||||
void UpdateConfig();
|
||||
|
||||
EncodeMap* getEncodeMap()
|
||||
{
|
||||
return mEncodeMap;
|
||||
}
|
||||
|
||||
private:
|
||||
struct DataInstructionInfo
|
||||
{
|
||||
QString shortName;
|
||||
QString longName;
|
||||
QString cName;
|
||||
};
|
||||
|
||||
void UpdateDataInstructionMap();
|
||||
CsCapstoneTokenizer _tokenizer;
|
||||
QHash<ENCODETYPE, DataInstructionInfo> dataInstMap;
|
||||
bool _bLongDataInst;
|
||||
EncodeMap* mEncodeMap;
|
||||
CodeFoldingHelper* mCodeFoldingManager;
|
||||
uint8_t reginfo[X86_REG_ENDING];
|
||||
uint8_t flaginfo[Capstone::FLAG_ENDING];
|
||||
};
|
||||
|
||||
#endif // CSQBEAENGINE_H
|
@ -1,630 +0,0 @@
|
||||
#include "cs_capstone_gui.h"
|
||||
#include "Configuration.h"
|
||||
#include "StringUtil.h"
|
||||
#include "CachedFontMetrics.h"
|
||||
|
||||
CsCapstoneTokenizer::CsCapstoneTokenizer(int maxModuleLength)
|
||||
: _maxModuleLength(maxModuleLength),
|
||||
_success(false),
|
||||
isNop(false),
|
||||
_mnemonicType(CapstoneTokenizer::TokenType::Uncategorized)
|
||||
{
|
||||
SetConfig(false, false, false, false, false, false, false, false, false);
|
||||
}
|
||||
|
||||
static CapstoneTokenizer::TokenColor colorNamesMap[CapstoneTokenizer::TokenType::Last];
|
||||
QHash<QString, int> CsCapstoneTokenizer::stringPoolMap;
|
||||
int CsCapstoneTokenizer::poolId = 0;
|
||||
|
||||
void CsCapstoneTokenizer::addColorName(CapstoneTokenizer::TokenType type, QString color, QString backgroundColor)
|
||||
{
|
||||
colorNamesMap[int(type)] = CapstoneTokenizer::TokenColor(color, backgroundColor);
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::addStringsToPool(const QString & strings)
|
||||
{
|
||||
QStringList stringList = strings.split(' ', QString::SkipEmptyParts);
|
||||
for(const QString & string : stringList)
|
||||
stringPoolMap.insert(string, poolId);
|
||||
poolId++;
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::UpdateColors()
|
||||
{
|
||||
//filling
|
||||
addColorName(CapstoneTokenizer::TokenType::Comma, "InstructionCommaColor", "InstructionCommaBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::Space, "", "");
|
||||
addColorName(CapstoneTokenizer::TokenType::ArgumentSpace, "", "");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryOperatorSpace, "", "");
|
||||
//general instruction parts
|
||||
addColorName(CapstoneTokenizer::TokenType::Prefix, "InstructionPrefixColor", "InstructionPrefixBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::Uncategorized, "InstructionUncategorizedColor", "InstructionUncategorizedBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::Address, "InstructionAddressColor", "InstructionAddressBackgroundColor"); //jump/call destinations
|
||||
addColorName(CapstoneTokenizer::TokenType::Value, "InstructionValueColor", "InstructionValueBackgroundColor");
|
||||
//mnemonics
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicNormal, "InstructionMnemonicColor", "InstructionMnemonicBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicPushPop, "InstructionPushPopColor", "InstructionPushPopBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicCall, "InstructionCallColor", "InstructionCallBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicRet, "InstructionRetColor", "InstructionRetBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicCondJump, "InstructionConditionalJumpColor", "InstructionConditionalJumpBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicUncondJump, "InstructionUnconditionalJumpColor", "InstructionUnconditionalJumpBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicNop, "InstructionNopColor", "InstructionNopBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicFar, "InstructionFarColor", "InstructionFarBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicInt3, "InstructionInt3Color", "InstructionInt3BackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MnemonicUnusual, "InstructionUnusualColor", "InstructionUnusualBackgroundColor");
|
||||
//memory
|
||||
addColorName(CapstoneTokenizer::TokenType::MemorySize, "InstructionMemorySizeColor", "InstructionMemorySizeBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemorySegment, "InstructionMemorySegmentColor", "InstructionMemorySegmentBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryBrackets, "InstructionMemoryBracketsColor", "InstructionMemoryBracketsBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryStackBrackets, "InstructionMemoryStackBracketsColor", "InstructionMemoryStackBracketsBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryBaseRegister, "InstructionMemoryBaseRegisterColor", "InstructionMemoryBaseRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryIndexRegister, "InstructionMemoryIndexRegisterColor", "InstructionMemoryIndexRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryScale, "InstructionMemoryScaleColor", "InstructionMemoryScaleBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MemoryOperator, "InstructionMemoryOperatorColor", "InstructionMemoryOperatorBackgroundColor");
|
||||
//registers
|
||||
addColorName(CapstoneTokenizer::TokenType::GeneralRegister, "InstructionGeneralRegisterColor", "InstructionGeneralRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::FpuRegister, "InstructionFpuRegisterColor", "InstructionFpuRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::MmxRegister, "InstructionMmxRegisterColor", "InstructionMmxRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::XmmRegister, "InstructionXmmRegisterColor", "InstructionXmmRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::YmmRegister, "InstructionYmmRegisterColor", "InstructionYmmRegisterBackgroundColor");
|
||||
addColorName(CapstoneTokenizer::TokenType::ZmmRegister, "InstructionZmmRegisterColor", "InstructionZmmRegisterBackgroundColor");
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::UpdateStringPool()
|
||||
{
|
||||
poolId = 0;
|
||||
stringPoolMap.clear();
|
||||
// These registers must be in lower case.
|
||||
addStringsToPool("rax eax ax al ah");
|
||||
addStringsToPool("rbx ebx bx bl bh");
|
||||
addStringsToPool("rcx ecx cx cl ch");
|
||||
addStringsToPool("rdx edx dx dl dh");
|
||||
addStringsToPool("rsi esi si sil");
|
||||
addStringsToPool("rdi edi di dil");
|
||||
addStringsToPool("rbp ebp bp bpl");
|
||||
addStringsToPool("rsp esp sp spl");
|
||||
addStringsToPool("r8 r8d r8w r8b");
|
||||
addStringsToPool("r9 r9d r9w r9b");
|
||||
addStringsToPool("r10 r10d r10w r10b");
|
||||
addStringsToPool("r11 r11d r11w r11b");
|
||||
addStringsToPool("r12 r12d r12w r12b");
|
||||
addStringsToPool("r13 r13d r13w r13b");
|
||||
addStringsToPool("r14 r14d r14w r14b");
|
||||
addStringsToPool("r15 r15d r15w r15b");
|
||||
addStringsToPool("xmm0 ymm0");
|
||||
addStringsToPool("xmm1 ymm1");
|
||||
addStringsToPool("xmm2 ymm2");
|
||||
addStringsToPool("xmm3 ymm3");
|
||||
addStringsToPool("xmm4 ymm4");
|
||||
addStringsToPool("xmm5 ymm5");
|
||||
addStringsToPool("xmm6 ymm6");
|
||||
addStringsToPool("xmm7 ymm7");
|
||||
addStringsToPool("xmm8 ymm8");
|
||||
addStringsToPool("xmm9 ymm9");
|
||||
addStringsToPool("xmm10 ymm10");
|
||||
addStringsToPool("xmm11 ymm11");
|
||||
addStringsToPool("xmm12 ymm12");
|
||||
addStringsToPool("xmm13 ymm13");
|
||||
addStringsToPool("xmm14 ymm14");
|
||||
addStringsToPool("xmm15 ymm15");
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::Tokenize(duint addr, const unsigned char* data, int datasize, CapstoneTokenizer::InstructionToken & instruction)
|
||||
{
|
||||
_inst = CapstoneTokenizer::InstructionToken();
|
||||
|
||||
_success = _cp.DisassembleSafe(addr, data, datasize);
|
||||
if(_success)
|
||||
{
|
||||
isNop = _cp.IsNop();
|
||||
if(!tokenizeMnemonic())
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < _cp.OpCount(); i++)
|
||||
{
|
||||
if(i)
|
||||
{
|
||||
addToken(CapstoneTokenizer::TokenType::Comma, ",");
|
||||
if(_bArgumentSpaces)
|
||||
addToken(CapstoneTokenizer::TokenType::ArgumentSpace, " ");
|
||||
}
|
||||
if(!tokenizeOperand(_cp[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isNop = false;
|
||||
addToken(CapstoneTokenizer::TokenType::MnemonicUnusual, "???");
|
||||
}
|
||||
|
||||
if(_bNoHighlightOperands)
|
||||
{
|
||||
while(_inst.tokens.size() && _inst.tokens[_inst.tokens.size() - 1].type == CapstoneTokenizer::TokenType::Space)
|
||||
_inst.tokens.pop_back();
|
||||
for(CapstoneTokenizer::SingleToken & token : _inst.tokens)
|
||||
token.type = _mnemonicType;
|
||||
}
|
||||
|
||||
instruction = _inst;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::TokenizeData(const QString & datatype, const QString & data, CapstoneTokenizer::InstructionToken & instruction)
|
||||
{
|
||||
_inst = CapstoneTokenizer::InstructionToken();
|
||||
isNop = false;
|
||||
|
||||
if(!tokenizeMnemonic(CapstoneTokenizer::TokenType::MnemonicNormal, datatype))
|
||||
return false;
|
||||
|
||||
addToken(CapstoneTokenizer::TokenType::Value, data);
|
||||
|
||||
instruction = _inst;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::UpdateConfig()
|
||||
{
|
||||
SetConfig(ConfigBool("Disassembler", "Uppercase"),
|
||||
ConfigBool("Disassembler", "TabbedMnemonic"),
|
||||
ConfigBool("Disassembler", "ArgumentSpaces"),
|
||||
ConfigBool("Disassembler", "HidePointerSizes"),
|
||||
ConfigBool("Disassembler", "HideNormalSegments"),
|
||||
ConfigBool("Disassembler", "MemorySpaces"),
|
||||
ConfigBool("Disassembler", "NoHighlightOperands"),
|
||||
ConfigBool("Disassembler", "NoCurrentModuleText"),
|
||||
ConfigBool("Disassembler", "0xPrefixValues"));
|
||||
_maxModuleLength = (int)ConfigUint("Disassembler", "MaxModuleSize");
|
||||
UpdateStringPool();
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bArgumentSpaces, bool bHidePointerSizes, bool bHideNormalSegments, bool bMemorySpaces, bool bNoHighlightOperands, bool bNoCurrentModuleText, bool b0xPrefixValues)
|
||||
{
|
||||
_bUppercase = bUppercase;
|
||||
_bTabbedMnemonic = bTabbedMnemonic;
|
||||
_bArgumentSpaces = bArgumentSpaces;
|
||||
_bHidePointerSizes = bHidePointerSizes;
|
||||
_bHideNormalSegments = bHideNormalSegments;
|
||||
_bMemorySpaces = bMemorySpaces;
|
||||
_bNoHighlightOperands = bNoHighlightOperands;
|
||||
_bNoCurrentModuleText = bNoCurrentModuleText;
|
||||
_b0xPrefixValues = b0xPrefixValues;
|
||||
}
|
||||
|
||||
int CsCapstoneTokenizer::Size() const
|
||||
{
|
||||
return _success ? _cp.Size() : 1;
|
||||
}
|
||||
|
||||
const Capstone & CsCapstoneTokenizer::GetCapstone() const
|
||||
{
|
||||
return _cp;
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::TokenToRichText(const CapstoneTokenizer::InstructionToken & instr, RichTextPainter::List & richTextList, const CapstoneTokenizer::SingleToken* highlightToken)
|
||||
{
|
||||
QColor highlightColor = ConfigColor("InstructionHighlightColor");
|
||||
for(const auto & token : instr.tokens)
|
||||
{
|
||||
RichTextPainter::CustomRichText_t richText;
|
||||
richText.highlight = TokenEquals(&token, highlightToken);
|
||||
richText.highlightColor = highlightColor;
|
||||
richText.flags = RichTextPainter::FlagNone;
|
||||
richText.text = token.text;
|
||||
if(token.type < CapstoneTokenizer::TokenType::Last)
|
||||
{
|
||||
const auto & tokenColor = colorNamesMap[int(token.type)];
|
||||
richText.flags = tokenColor.flags;
|
||||
richText.textColor = tokenColor.color;
|
||||
richText.textBackground = tokenColor.backgroundColor;
|
||||
}
|
||||
richTextList.push_back(richText);
|
||||
}
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::TokenFromX(const CapstoneTokenizer::InstructionToken & instr, CapstoneTokenizer::SingleToken & token, int x, CachedFontMetrics* fontMetrics)
|
||||
{
|
||||
if(x < instr.x) //before the first token
|
||||
return false;
|
||||
int len = int(instr.tokens.size());
|
||||
for(int i = 0, xStart = instr.x; i < len; i++)
|
||||
{
|
||||
const auto & curToken = instr.tokens.at(i);
|
||||
int curWidth = fontMetrics->width(curToken.text);
|
||||
int xEnd = xStart + curWidth;
|
||||
if(x >= xStart && x < xEnd)
|
||||
{
|
||||
token = curToken;
|
||||
return true;
|
||||
}
|
||||
xStart = xEnd;
|
||||
}
|
||||
return false; //not found
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::IsHighlightableToken(const CapstoneTokenizer::SingleToken & token)
|
||||
{
|
||||
switch(token.type)
|
||||
{
|
||||
case CapstoneTokenizer::TokenType::Comma:
|
||||
case CapstoneTokenizer::TokenType::Space:
|
||||
case CapstoneTokenizer::TokenType::ArgumentSpace:
|
||||
case CapstoneTokenizer::TokenType::Uncategorized:
|
||||
case CapstoneTokenizer::TokenType::MemoryOperatorSpace:
|
||||
case CapstoneTokenizer::TokenType::MemoryBrackets:
|
||||
case CapstoneTokenizer::TokenType::MemoryStackBrackets:
|
||||
case CapstoneTokenizer::TokenType::MemoryOperator:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenTextPoolEquals(const QString & a, const QString & b)
|
||||
{
|
||||
if(a.compare(b, Qt::CaseInsensitive) == 0)
|
||||
return true;
|
||||
auto found1 = stringPoolMap.find(a.toLower());
|
||||
auto found2 = stringPoolMap.find(b.toLower());
|
||||
if(found1 == stringPoolMap.end() || found2 == stringPoolMap.end())
|
||||
return false;
|
||||
return found1.value() == found2.value();
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::TokenEquals(const CapstoneTokenizer::SingleToken* a, const CapstoneTokenizer::SingleToken* b, bool ignoreSize)
|
||||
{
|
||||
if(!a || !b)
|
||||
return false;
|
||||
if(a->value.size != 0 && b->value.size != 0) //we have a value
|
||||
{
|
||||
if(!ignoreSize && a->value.size != b->value.size)
|
||||
return false;
|
||||
else if(a->value.value != b->value.value)
|
||||
return false;
|
||||
}
|
||||
return tokenTextPoolEquals(a->text, b->text);
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::addToken(CapstoneTokenizer::TokenType type, QString text, const CapstoneTokenizer::TokenValue & value)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case CapstoneTokenizer::TokenType::Space:
|
||||
case CapstoneTokenizer::TokenType::ArgumentSpace:
|
||||
case CapstoneTokenizer::TokenType::MemoryOperatorSpace:
|
||||
break;
|
||||
default:
|
||||
text = text.trimmed();
|
||||
break;
|
||||
}
|
||||
if(_bUppercase && !value.size)
|
||||
text = text.toUpper();
|
||||
_inst.tokens.push_back(CapstoneTokenizer::SingleToken(isNop ? CapstoneTokenizer::TokenType::MnemonicNop : type, text, value));
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::addToken(CapstoneTokenizer::TokenType type, const QString & text)
|
||||
{
|
||||
addToken(type, text, CapstoneTokenizer::TokenValue());
|
||||
}
|
||||
|
||||
void CsCapstoneTokenizer::addMemoryOperator(char operatorText)
|
||||
{
|
||||
if(_bMemorySpaces)
|
||||
addToken(CapstoneTokenizer::TokenType::MemoryOperatorSpace, " ");
|
||||
QString text;
|
||||
text += operatorText;
|
||||
addToken(CapstoneTokenizer::TokenType::MemoryOperator, text);
|
||||
if(_bMemorySpaces)
|
||||
addToken(CapstoneTokenizer::TokenType::MemoryOperatorSpace, " ");
|
||||
}
|
||||
|
||||
QString CsCapstoneTokenizer::printValue(const CapstoneTokenizer::TokenValue & value, bool expandModule, int maxModuleLength) const
|
||||
{
|
||||
QString labelText;
|
||||
char label_[MAX_LABEL_SIZE] = "";
|
||||
char module_[MAX_MODULE_SIZE] = "";
|
||||
QString moduleText;
|
||||
duint addr = value.value;
|
||||
bool bHasLabel = DbgGetLabelAt(addr, SEG_DEFAULT, label_);
|
||||
labelText = QString(label_);
|
||||
bool bHasModule;
|
||||
if(_bNoCurrentModuleText)
|
||||
{
|
||||
duint size, base;
|
||||
base = DbgMemFindBaseAddr(this->GetCapstone().Address(), &size);
|
||||
if(addr >= base && addr < base + size)
|
||||
bHasModule = false;
|
||||
else
|
||||
bHasModule = (expandModule && DbgGetModuleAt(addr, module_) && !QString(labelText).startsWith("JMP.&"));
|
||||
}
|
||||
else
|
||||
bHasModule = (expandModule && DbgGetModuleAt(addr, module_) && !QString(labelText).startsWith("JMP.&"));
|
||||
moduleText = QString(module_);
|
||||
if(maxModuleLength != -1)
|
||||
moduleText.truncate(maxModuleLength);
|
||||
if(moduleText.length())
|
||||
moduleText += ".";
|
||||
QString addrText = ToHexString(addr);
|
||||
QString finalText;
|
||||
if(bHasLabel && bHasModule) //<module.label>
|
||||
finalText = QString("<%1%2>").arg(moduleText).arg(labelText);
|
||||
else if(bHasModule) //module.addr
|
||||
finalText = QString("%1%2").arg(moduleText).arg(addrText);
|
||||
else if(bHasLabel) //<label>
|
||||
finalText = QString("<%1>").arg(labelText);
|
||||
else if(_b0xPrefixValues)
|
||||
finalText = QString("0x") + addrText;
|
||||
else
|
||||
finalText = addrText;
|
||||
return finalText;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizePrefix()
|
||||
{
|
||||
bool hasPrefix = true;
|
||||
QString prefixText;
|
||||
//TODO: look at multiple prefixes on one instruction (https://github.com/aquynh/capstone/blob/921904888d7c1547c558db3a24fa64bcf97dede4/arch/X86/X86DisassemblerDecoder.c#L540)
|
||||
switch(_cp.x86().prefix[0])
|
||||
{
|
||||
case X86_PREFIX_LOCK:
|
||||
prefixText = "lock";
|
||||
break;
|
||||
case X86_PREFIX_REP:
|
||||
prefixText = "rep";
|
||||
break;
|
||||
case X86_PREFIX_REPNE:
|
||||
prefixText = "repne";
|
||||
break;
|
||||
default:
|
||||
hasPrefix = false;
|
||||
}
|
||||
|
||||
if(hasPrefix)
|
||||
{
|
||||
addToken(CapstoneTokenizer::TokenType::Prefix, prefixText);
|
||||
addToken(CapstoneTokenizer::TokenType::Space, " ");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeMnemonic()
|
||||
{
|
||||
QString mnemonic = QString(_cp.Mnemonic().c_str());
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicNormal;
|
||||
auto id = _cp.GetId();
|
||||
if(isNop)
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicNop;
|
||||
else if(_cp.InGroup(CS_GRP_CALL))
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicCall;
|
||||
else if(_cp.InGroup(CS_GRP_JUMP) || _cp.IsLoop())
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
case X86_INS_JMP:
|
||||
case X86_INS_LJMP:
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicUncondJump;
|
||||
break;
|
||||
default:
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicCondJump;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(_cp.IsInt3())
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicInt3;
|
||||
else if(_cp.IsUnusual())
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicUnusual;
|
||||
else if(_cp.InGroup(CS_GRP_RET))
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicRet;
|
||||
else
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
case X86_INS_PUSH:
|
||||
case X86_INS_PUSHF:
|
||||
case X86_INS_PUSHFD:
|
||||
case X86_INS_PUSHFQ:
|
||||
case X86_INS_PUSHAL:
|
||||
case X86_INS_PUSHAW:
|
||||
case X86_INS_POP:
|
||||
case X86_INS_POPF:
|
||||
case X86_INS_POPFD:
|
||||
case X86_INS_POPFQ:
|
||||
case X86_INS_POPAL:
|
||||
case X86_INS_POPAW:
|
||||
_mnemonicType = CapstoneTokenizer::TokenType::MnemonicPushPop;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tokenizeMnemonic(_mnemonicType, mnemonic);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeMnemonic(CapstoneTokenizer::TokenType type, const QString & mnemonic)
|
||||
{
|
||||
addToken(type, mnemonic);
|
||||
if(_bTabbedMnemonic)
|
||||
{
|
||||
int spaceCount = 7 - mnemonic.length();
|
||||
if(spaceCount > 0)
|
||||
{
|
||||
for(int i = 0; i < spaceCount; i++)
|
||||
addToken(CapstoneTokenizer::TokenType::Space, " ");
|
||||
}
|
||||
}
|
||||
addToken(CapstoneTokenizer::TokenType::Space, " ");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeOperand(const cs_x86_op & op)
|
||||
{
|
||||
switch(op.type)
|
||||
{
|
||||
case X86_OP_REG:
|
||||
return tokenizeRegOperand(op);
|
||||
case X86_OP_IMM:
|
||||
return tokenizeImmOperand(op);
|
||||
case X86_OP_MEM:
|
||||
return tokenizeMemOperand(op);
|
||||
case X86_OP_INVALID:
|
||||
return tokenizeInvalidOperand(op);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeRegOperand(const cs_x86_op & op)
|
||||
{
|
||||
auto registerType = CapstoneTokenizer::TokenType::GeneralRegister;
|
||||
auto reg = op.reg;
|
||||
if(reg >= X86_REG_FP0 && reg <= X86_REG_FP7)
|
||||
registerType = CapstoneTokenizer::TokenType::FpuRegister;
|
||||
else if(reg >= X86_REG_ST0 && reg <= X86_REG_ST7)
|
||||
registerType = CapstoneTokenizer::TokenType::FpuRegister;
|
||||
else if(reg >= X86_REG_MM0 && reg <= X86_REG_MM7)
|
||||
registerType = CapstoneTokenizer::TokenType::MmxRegister;
|
||||
else if(reg >= X86_REG_XMM0 && reg <= X86_REG_XMM31)
|
||||
registerType = CapstoneTokenizer::TokenType::XmmRegister;
|
||||
else if(reg >= X86_REG_YMM0 && reg <= X86_REG_YMM31)
|
||||
registerType = CapstoneTokenizer::TokenType::YmmRegister;
|
||||
else if(reg >= X86_REG_ZMM0 && reg <= X86_REG_ZMM31)
|
||||
registerType = CapstoneTokenizer::TokenType::ZmmRegister;
|
||||
else if(reg == ArchValue(X86_REG_FS, X86_REG_GS))
|
||||
registerType = CapstoneTokenizer::TokenType::MnemonicUnusual;
|
||||
addToken(registerType, _cp.RegName(reg));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeImmOperand(const cs_x86_op & op)
|
||||
{
|
||||
auto value = duint(op.imm) & (duint(-1) >> (op.size ? 8 * (sizeof(duint) - op.size) : 0));
|
||||
auto valueType = CapstoneTokenizer::TokenType::Value;
|
||||
if(_cp.InGroup(CS_GRP_JUMP) || _cp.InGroup(CS_GRP_CALL) || _cp.IsLoop())
|
||||
valueType = CapstoneTokenizer::TokenType::Address;
|
||||
auto tokenValue = CapstoneTokenizer::TokenValue(op.size, value);
|
||||
addToken(valueType, printValue(tokenValue, true, _maxModuleLength), tokenValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeMemOperand(const cs_x86_op & op)
|
||||
{
|
||||
//memory size
|
||||
if(!_bHidePointerSizes)
|
||||
{
|
||||
const char* sizeText = _cp.MemSizeName(op.size);
|
||||
if(!sizeText)
|
||||
return false;
|
||||
addToken(CapstoneTokenizer::TokenType::MemorySize, QString(sizeText) + " ptr");
|
||||
addToken(CapstoneTokenizer::TokenType::Space, " ");
|
||||
}
|
||||
|
||||
const auto & mem = op.mem;
|
||||
|
||||
//memory segment
|
||||
bool bUnusualSegment = (mem.segment == X86_REG_FS || mem.segment == X86_REG_GS);
|
||||
if(!_bHideNormalSegments || bUnusualSegment)
|
||||
{
|
||||
const char* segmentText = _cp.RegName(mem.segment);
|
||||
if(mem.segment == X86_REG_INVALID) //segment not set
|
||||
{
|
||||
switch(mem.base)
|
||||
{
|
||||
case X86_REG_RSP:
|
||||
case X86_REG_RBP:
|
||||
case X86_REG_ESP:
|
||||
case X86_REG_EBP:
|
||||
case X86_REG_SP:
|
||||
case X86_REG_BP:
|
||||
segmentText = "ss";
|
||||
break;
|
||||
default:
|
||||
segmentText = "ds";
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto segmentType = op.reg == ArchValue(X86_REG_FS, X86_REG_GS)
|
||||
? CapstoneTokenizer::TokenType::MnemonicUnusual : CapstoneTokenizer::TokenType::MemorySegment;
|
||||
addToken(segmentType, segmentText);
|
||||
addToken(CapstoneTokenizer::TokenType::Uncategorized, ":");
|
||||
}
|
||||
|
||||
//memory opening bracket
|
||||
auto bracketsType = CapstoneTokenizer::TokenType::MemoryBrackets;
|
||||
switch(mem.base)
|
||||
{
|
||||
case X86_REG_ESP:
|
||||
case X86_REG_RSP:
|
||||
case X86_REG_EBP:
|
||||
case X86_REG_RBP:
|
||||
bracketsType = CapstoneTokenizer::TokenType::MemoryStackBrackets;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
addToken(bracketsType, "[");
|
||||
|
||||
//stuff inside the brackets
|
||||
if(mem.base == X86_REG_RIP) //rip-relative (#replacement)
|
||||
{
|
||||
duint addr = _cp.Address() + duint(mem.disp) + _cp.Size();
|
||||
CapstoneTokenizer::TokenValue value = CapstoneTokenizer::TokenValue(op.size, addr);
|
||||
auto displacementType = DbgMemIsValidReadPtr(addr) ? CapstoneTokenizer::TokenType::Address : CapstoneTokenizer::TokenType::Value;
|
||||
addToken(displacementType, printValue(value, false, _maxModuleLength), value);
|
||||
}
|
||||
else //#base + #index * #scale + #displacement
|
||||
{
|
||||
bool prependPlus = false;
|
||||
if(mem.base != X86_REG_INVALID) //base register
|
||||
{
|
||||
addToken(CapstoneTokenizer::TokenType::MemoryBaseRegister, _cp.RegName(mem.base));
|
||||
prependPlus = true;
|
||||
}
|
||||
if(mem.index != X86_REG_INVALID) //index register
|
||||
{
|
||||
if(prependPlus)
|
||||
addMemoryOperator('+');
|
||||
addToken(CapstoneTokenizer::TokenType::MemoryIndexRegister, _cp.RegName(mem.index));
|
||||
if(mem.scale > 1)
|
||||
{
|
||||
addMemoryOperator('*');
|
||||
addToken(CapstoneTokenizer::TokenType::MemoryScale, QString().sprintf("%d", mem.scale));
|
||||
}
|
||||
prependPlus = true;
|
||||
}
|
||||
if(mem.disp)
|
||||
{
|
||||
char operatorText = '+';
|
||||
CapstoneTokenizer::TokenValue value(op.size, duint(mem.disp));
|
||||
auto displacementType = DbgMemIsValidReadPtr(duint(mem.disp)) ? CapstoneTokenizer::TokenType::Address : CapstoneTokenizer::TokenType::Value;
|
||||
QString valueText;
|
||||
if(mem.disp < 0 && prependPlus)
|
||||
{
|
||||
operatorText = '-';
|
||||
valueText = printValue(CapstoneTokenizer::TokenValue(op.size, duint(mem.disp * -1)), false, _maxModuleLength);
|
||||
}
|
||||
else
|
||||
valueText = printValue(value, false, _maxModuleLength);
|
||||
if(prependPlus)
|
||||
addMemoryOperator(operatorText);
|
||||
addToken(displacementType, valueText, value);
|
||||
}
|
||||
else if(!prependPlus)
|
||||
addToken(CapstoneTokenizer::TokenType::Value, "0");
|
||||
}
|
||||
|
||||
//closing bracket
|
||||
addToken(bracketsType, "]");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CsCapstoneTokenizer::tokenizeInvalidOperand(const cs_x86_op & op)
|
||||
{
|
||||
addToken(CapstoneTokenizer::TokenType::MnemonicUnusual, "???");
|
||||
return true;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
#ifndef CS_CAPSTONE_GUI_H
|
||||
#define CS_CAPSTONE_GUI_H
|
||||
|
||||
#include <capstone_wrapper.h>
|
||||
#include "RichTextPainter.h"
|
||||
#include "Configuration.h"
|
||||
#include <map>
|
||||
#include <QHash>
|
||||
#include <QtCore>
|
||||
|
||||
#include "capstone_gui.h"
|
||||
|
||||
class CsCapstoneTokenizer
|
||||
{
|
||||
public:
|
||||
CsCapstoneTokenizer(int maxModuleLength);
|
||||
bool Tokenize(duint addr, const unsigned char* data, int datasize, CapstoneTokenizer::InstructionToken & instruction);
|
||||
bool TokenizeData(const QString & datatype, const QString & data, CapstoneTokenizer::InstructionToken & instruction);
|
||||
void UpdateConfig();
|
||||
void SetConfig(bool bUppercase, bool bTabbedMnemonic, bool bArgumentSpaces, bool bHidePointerSizes, bool bHideNormalSegments, bool bMemorySpaces, bool bNoHighlightOperands, bool bNoCurrentModuleText, bool b0xPrefixValues);
|
||||
int Size() const;
|
||||
const Capstone & GetCapstone() const;
|
||||
|
||||
static void UpdateColors();
|
||||
static void UpdateStringPool();
|
||||
static void TokenToRichText(const CapstoneTokenizer::InstructionToken & instr, RichTextPainter::List & richTextList, const CapstoneTokenizer::SingleToken* highlightToken);
|
||||
static bool TokenFromX(const CapstoneTokenizer::InstructionToken & instr, CapstoneTokenizer::SingleToken & token, int x, CachedFontMetrics* fontMetrics);
|
||||
static bool IsHighlightableToken(const CapstoneTokenizer::SingleToken & token);
|
||||
static bool TokenEquals(const CapstoneTokenizer::SingleToken* a, const CapstoneTokenizer::SingleToken* b, bool ignoreSize = true);
|
||||
static void addColorName(CapstoneTokenizer::TokenType type, QString color, QString backgroundColor);
|
||||
static void addStringsToPool(const QString & regs);
|
||||
static bool tokenTextPoolEquals(const QString & a, const QString & b);
|
||||
|
||||
private:
|
||||
Capstone _cp;
|
||||
bool isNop;
|
||||
CapstoneTokenizer::InstructionToken _inst;
|
||||
bool _success;
|
||||
int _maxModuleLength;
|
||||
bool _bUppercase;
|
||||
bool _bTabbedMnemonic;
|
||||
bool _bArgumentSpaces;
|
||||
bool _bHidePointerSizes;
|
||||
bool _bHideNormalSegments;
|
||||
bool _bMemorySpaces;
|
||||
bool _bNoHighlightOperands;
|
||||
bool _bNoCurrentModuleText;
|
||||
bool _b0xPrefixValues;
|
||||
CapstoneTokenizer::TokenType _mnemonicType;
|
||||
|
||||
void addToken(CapstoneTokenizer::TokenType type, QString text, const CapstoneTokenizer::TokenValue & value);
|
||||
void addToken(CapstoneTokenizer::TokenType type, const QString & text);
|
||||
void addMemoryOperator(char operatorText);
|
||||
QString printValue(const CapstoneTokenizer::TokenValue & value, bool expandModule, int maxModuleLength) const;
|
||||
|
||||
static QHash<QString, int> stringPoolMap;
|
||||
static int poolId;
|
||||
|
||||
bool tokenizePrefix();
|
||||
bool tokenizeMnemonic();
|
||||
bool tokenizeMnemonic(CapstoneTokenizer::TokenType type, const QString & mnemonic);
|
||||
bool tokenizeOperand(const cs_x86_op & op);
|
||||
bool tokenizeRegOperand(const cs_x86_op & op);
|
||||
bool tokenizeImmOperand(const cs_x86_op & op);
|
||||
bool tokenizeMemOperand(const cs_x86_op & op);
|
||||
bool tokenizeInvalidOperand(const cs_x86_op & op);
|
||||
};
|
||||
|
||||
#endif //CS_CAPSTONE_GUI_H
|
@ -1,6 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "zydis_wrapper.h"
|
||||
#include "capstone_wrapper.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Configuration.h"
|
||||
#include <QTextCodec>
|
||||
@ -109,7 +108,6 @@ int main(int argc, char* argv[])
|
||||
|
||||
// initialize capstone
|
||||
Zydis::GlobalInitialize();
|
||||
Capstone::GlobalInitialize();
|
||||
|
||||
// load config file + set config font
|
||||
mConfiguration = new Configuration;
|
||||
|
@ -67,7 +67,6 @@ INCLUDEPATH += \
|
||||
Src/Utils \
|
||||
Src/ThirdPartyLibs/snowman \
|
||||
Src/ThirdPartyLibs/ldconvert \
|
||||
../capstone_wrapper \
|
||||
../zydis_wrapper \
|
||||
../zydis_wrapper/zydis/include
|
||||
|
||||
@ -84,9 +83,7 @@ SOURCES += \
|
||||
Src/BasicView/HexDump.cpp \
|
||||
Src/BasicView/AbstractTableView.cpp \
|
||||
Src/Disassembler/QBeaEngine.cpp \
|
||||
Src/Disassembler/CsQBeaEngine.cpp \
|
||||
Src/Disassembler/capstone_gui.cpp \
|
||||
Src/Disassembler/cs_capstone_gui.cpp \
|
||||
Src/Memory/MemoryPage.cpp \
|
||||
Src/Bridge/Bridge.cpp \
|
||||
Src/BasicView/StdTable.cpp \
|
||||
@ -201,9 +198,7 @@ HEADERS += \
|
||||
Src/BasicView/HexDump.h \
|
||||
Src/BasicView/AbstractTableView.h \
|
||||
Src/Disassembler/QBeaEngine.h \
|
||||
Src/Disassembler/CsQBeaEngine.h \
|
||||
Src/Disassembler/capstone_gui.h \
|
||||
Src/Disassembler/cs_capstone_gui.h \
|
||||
Src/Memory/MemoryPage.h \
|
||||
Src/Bridge/Bridge.h \
|
||||
Src/Exports.h \
|
||||
@ -365,16 +360,12 @@ LIBS += -luser32 -ladvapi32 -lwinmm -lshell32
|
||||
!contains(QMAKE_HOST.arch, x86_64) {
|
||||
# Windows x86 (32bit) specific build
|
||||
LIBS += -L"$$PWD/../zydis_wrapper/bin/x32$${DIR_SUFFIX}" -lzydis_wrapper
|
||||
LIBS += -L"$$PWD/../capstone_wrapper/capstone" -lcapstone_x86
|
||||
LIBS += -L"$$PWD/../capstone_wrapper/bin/x32$${DIR_SUFFIX}" -lcapstone_wrapper
|
||||
LIBS += -L"$$PWD/Src/ThirdPartyLibs/snowman" -lsnowman_x86
|
||||
LIBS += -L"$$PWD/Src/ThirdPartyLibs/ldconvert" -lldconvert_x86
|
||||
LIBS += -L"$${X64_BIN_DIR}" -lx32bridge
|
||||
} else {
|
||||
# Windows x64 (64bit) specific build
|
||||
LIBS += -L"$$PWD/../zydis_wrapper/bin/x64$${DIR_SUFFIX}" -lzydis_wrapper
|
||||
LIBS += -L"$$PWD/../capstone_wrapper/capstone" -lcapstone_x64
|
||||
LIBS += -L"$$PWD/../capstone_wrapper/bin/x64$${DIR_SUFFIX}" -lcapstone_wrapper
|
||||
LIBS += -L"$$PWD/Src/ThirdPartyLibs/snowman" -lsnowman_x64
|
||||
LIBS += -L"$$PWD/Src/ThirdPartyLibs/ldconvert" -lldconvert_x64
|
||||
LIBS += -L"$${X64_BIN_DIR}" -lx64bridge
|
||||
|
11
x64dbg.sln
11
x64dbg.sln
@ -13,13 +13,10 @@ EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64dbg_dbg", "src\dbg\x64dbg_dbg.vcxproj", "{E6548308-401E-3A8A-5819-905DB90522A6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{944D9923-CB1A-6F6C-BCBC-9E00A71954C1} = {944D9923-CB1A-6F6C-BCBC-9E00A71954C1}
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15} = {C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64dbg_launcher", "src\launcher\x64dbg_launcher.vcxproj", "{AC3F927A-4079-4C97-B8BE-8D04546802E7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "capstone_wrapper", "src\capstone_wrapper\capstone_wrapper.vcxproj", "{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zydis_wrapper", "src\zydis_wrapper\zydis_wrapper.vcxproj", "{3B2C1EE1-FDEC-4D85-BE46-3C6A5EA69883}"
|
||||
EndProject
|
||||
Global
|
||||
@ -62,14 +59,6 @@ Global
|
||||
{AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|Win32.Build.0 = Release|Win32
|
||||
{AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|x64.ActiveCfg = Release|Win32
|
||||
{AC3F927A-4079-4C97-B8BE-8D04546802E7}.Release|x64.Build.0 = Release|Win32
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Debug|x64.Build.0 = Debug|x64
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Release|Win32.Build.0 = Release|Win32
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Release|x64.ActiveCfg = Release|x64
|
||||
{C9B06E6E-3534-4E7B-9C00-C3EA33CC4E15}.Release|x64.Build.0 = Release|x64
|
||||
{3B2C1EE1-FDEC-4D85-BE46-3C6A5EA69883}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3B2C1EE1-FDEC-4D85-BE46-3C6A5EA69883}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3B2C1EE1-FDEC-4D85-BE46-3C6A5EA69883}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
Loading…
Reference in New Issue
Block a user