Skip to content

Commit

Permalink
x64 architecture support for decompilation through a helper symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
BoyC committed Apr 16, 2024
1 parent 701a686 commit ee3eff1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 2 additions & 4 deletions ExeToKKPUncompressed/ExeToKKPUncompressed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ BOOL CALLBACK EnumSymbols(SYMBOL_INFO* info, ULONG size, void* param)
sym.name = info->Name;
sym.fileID = 0;
sym.VA = info->Address;
sym.size = info->Size;
sym.isCode = false;
sym.size = size ? size : info->Size;
sym.isCode = info->Tag == SymTagFunction;

/*
if ( sym.size == 0 )
Expand Down Expand Up @@ -151,8 +151,6 @@ BOOL CALLBACK EnumSymbols(SYMBOL_INFO* info, ULONG size, void* param)

sym.fileID = -1;

IMAGEHLP_LINE64 LineInfo;
LineInfo.SizeOfStruct = sizeof( IMAGEHLP_LINE64 );
symbols.emplace_back( sym );

return TRUE;
Expand Down
8 changes: 7 additions & 1 deletion kkp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ void BuildSymbolList( std::vector<KKP::KKPSymbol>& target, const KKP::KKPSymbol&
}
}

bool KKP::isX64 = false;

void KKP::Load( const std::string& fileName )
{
isX64 = false;
root = KKPSymbol();
files.clear();
bytes.clear();
Expand Down Expand Up @@ -337,7 +340,10 @@ void KKP::Load( const std::string& fileName )

s.originalSymbolID = x;

AddSymbol( s );
if ( s.name == "Code::<arch: x64>" )
isX64 = true;
else
AddSymbol( s );
}
}

Expand Down
2 changes: 2 additions & 0 deletions kkp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class KKP
{
public:

static bool isX64;

#pragma pack(push)
#pragma pack(1)
struct KKPFile
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void SelectByte( KKP::KKPByteData& byte )

ZyanUSize offset = 0;
ZydisDisassembledInstruction instruction;
while ( ZYAN_SUCCESS( ZydisDisassembleIntel( ZYDIS_MACHINE_MODE_LONG_COMPAT_32, address, data + offset, symbol.unpackedSize - offset, &instruction ) ) )
while ( ZYAN_SUCCESS( ZydisDisassembleIntel( KKP::isX64 ? ZYDIS_MACHINE_MODE_LONG_64 : ZYDIS_MACHINE_MODE_LONG_COMPAT_32, address, data + offset, symbol.unpackedSize - offset, &instruction ) ) )
{
DisassemblyLine line;
line.address = (int)address;
Expand Down

0 comments on commit ee3eff1

Please sign in to comment.