Skip to content

Commit

Permalink
备份Microcode处理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
fjqisba committed Aug 30, 2022
1 parent 9a246ad commit 1e9eb5b
Show file tree
Hide file tree
Showing 11 changed files with 537 additions and 9 deletions.
2 changes: 2 additions & 0 deletions E-Decompiler/E-Decompiler.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<ClCompile Include="Module\EAppControlXref.cpp" />
<ClCompile Include="Module\CTreeFixer.cpp" />
<ClCompile Include="Module\ECSigMaker.cpp" />
<ClCompile Include="Module\MicroCodeFixer.cpp" />
<ClCompile Include="Module\ShowEventList.cpp" />
<ClCompile Include="Module\ShowImports.cpp" />
<ClCompile Include="SectionManager.cpp" />
Expand Down Expand Up @@ -189,6 +190,7 @@
<ClInclude Include="Module\EAppControlXref.h" />
<ClInclude Include="Module\CTreeFixer.h" />
<ClInclude Include="Module\ECSigMaker.h" />
<ClInclude Include="Module\MicroCodeFixer.h" />
<ClInclude Include="Module\ShowEventList.h" />
<ClInclude Include="Module\ShowImports.h" />
<ClInclude Include="PropertyDelegate.h" />
Expand Down
6 changes: 6 additions & 0 deletions E-Decompiler/E-Decompiler.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
<ClCompile Include="Module\ShowImports.cpp">
<Filter>Module</Filter>
</ClCompile>
<ClCompile Include="Module\MicroCodeFixer.cpp">
<Filter>Module</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SectionManager.h">
Expand Down Expand Up @@ -294,6 +297,9 @@
<ClInclude Include="Module\ShowImports.h">
<Filter>Module</Filter>
</ClInclude>
<ClInclude Include="Module\MicroCodeFixer.h">
<Filter>Module</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="E-Decompiler.rc" />
Expand Down
7 changes: 6 additions & 1 deletion E-Decompiler/EDecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ EDecompiler::~EDecompiler()
gMenu_ShowImportsInfo->DestroyMenu();
gMenu_ShowImportsInfo = nullptr;
}

cTreeFixer.UnInstall();
UnInstallMicroCodeFixer();
term_hexrays_plugin();
unhook_from_notification_point(HT_UI, PluginUI_Callback,this);
}


bool idaapi EDecompiler::run(size_t)
{
show_wait_box(getUTF8String("等待IDA初始化分析完毕").c_str());
Expand Down Expand Up @@ -107,6 +109,9 @@ bool EDecompiler::InitDecompilerEngine()
if (eSymbol.tmpImportsApiList.size() > 0) {
gMenu_ShowGUIInfo = IDAMenu::CreateMenu(getUTF8String("易语言/用户导入表").c_str(), ShowImports, &eSymbol);
}

cTreeFixer.Install();
InstallMicroCodeFixer(eSymbol);
return true;
}

Expand Down
1 change: 1 addition & 0 deletions E-Decompiler/EDecompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "./Module/CTreeFixer.h"
#include "./Module/ECSigMaker.h"
#include "./Module/EAppControlXref.h"
#include "./Module/MicroCodeFixer.h"

enum EArchitectureType
{
Expand Down
20 changes: 18 additions & 2 deletions E-Decompiler/ESymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ bool ESymbol::scanBasicFunction()
if (!pFunc) {
continue;
}
if (pFunc->start_ea >= userCodeEndAddr) {
continue;
}
if (eSymbolFuncTypeMap[pFunc->start_ea] != 0x0) {
continue;
}
Expand All @@ -264,6 +267,8 @@ bool ESymbol::scanBasicFunction()
}
else if (funcName == "连续省略参数") {
IDAWrapper::apply_cdecl(pFunc->start_ea, "void __usercall pushDefaultParam(int argCount@<ebx>);");
eSymbolFuncTypeMap[pFunc->start_ea] = eFunc_PushDefaultArg;
handlePushDefaultArgFunc(pFunc->start_ea);
}
else if (funcName == "文本比较") {
IDAWrapper::apply_cdecl(pFunc->start_ea, "int __cdecl strcmp(char* _Str1,char* _Str2);");
Expand All @@ -272,6 +277,13 @@ bool ESymbol::scanBasicFunction()
return true;
}

bool ESymbol::handlePushDefaultArgFunc(unsigned int funcAddr)
{
std::vector<unsigned int> xrefList = IDAWrapper::getAllCodeXrefAddr(funcAddr);

return true;
}

bool ESymbol::loadKrnlInterface(unsigned int lpKrnlEntry)
{
qstring jmpOtherHelpHex;
Expand Down Expand Up @@ -336,6 +348,8 @@ bool ESymbol::loadKrnlInterface(unsigned int lpKrnlEntry)
eSymbolFuncTypeMap[krnlJmp.Jmp_MWriteProperty] = eFunc_KrnlWriteProperty;
eSymbolFuncTypeMap[krnlJmp.Jmp_MCallKrnlLibCmd] = eFunc_KrnlLibFunc;
eSymbolFuncTypeMap[krnlJmp.Jmp_MCallDllCmd] = eFunc_KrnlDllCmd;
eSymbolFuncTypeMap[krnlJmp.Jmp_MReportError] = eFunc_KrnlReportError;
eSymbolFuncTypeMap[krnlJmp.Jmp_MFree] = eFunc_KrnlFreeMem;

IDAWrapper::apply_cdecl(krnlJmp.Jmp_MCallDllCmd, "krnlRet __usercall CallDllCmd@<eax:edx>(unsigned int index@<eax>,...);");
IDAWrapper::apply_cdecl(krnlJmp.Jmp_MCallLibCmd, "krnlRet __usercall CallLibCmd@<eax:edx>(unsigned int libFunc@<ebx>, int argCount, ...);");
Expand Down Expand Up @@ -548,8 +562,10 @@ bool ESymbol::loadUserImports(unsigned int dwApiCount, unsigned int lpModuleName
if (iIndex != -1) {
eImportsApi.libName = eImportsApi.libName.substr(0, iIndex);
}
eImportsApi.libName = eImportsApi.libName + "." + eImportsApi.apiName;
tmpImportsApiList.push_back(LocalCpToUtf8(eImportsApi.libName.c_str()));
if (!eImportsApi.libName.empty()) {
eImportsApi.apiName = eImportsApi.libName + "." + eImportsApi.apiName;
}
tmpImportsApiList.push_back(LocalCpToUtf8(eImportsApi.apiName.c_str()));
pszLibnameAddr += 4;
pszApinameAddr += 4;
}
Expand Down
8 changes: 8 additions & 0 deletions E-Decompiler/ESymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,14 @@ enum eSymbolFuncType
eFunc_KrnlWriteProperty,
//调用DLL命令
eFunc_KrnlDllCmd,
//错误回调
eFunc_KrnlReportError,
//释放内存
eFunc_KrnlFreeMem,
//文本相加
eFunc_Strcat,
//连续省略参数,
eFunc_PushDefaultArg,
};

struct EAppControl;
Expand Down Expand Up @@ -240,6 +246,8 @@ class ESymbol
bool scanELibFunction(unsigned int lpLibStartAddr, unsigned int dwLibCount);
//扫描并识别易语言基础命令
bool scanBasicFunction();
//处理连续省略参数函数
bool handlePushDefaultArgFunc(unsigned int funcAddr);
//加载易语言核心函数
bool loadKrnlInterface(unsigned int lpKrnlEntry);
//加载界面资源信息
Expand Down
Loading

0 comments on commit 1e9eb5b

Please sign in to comment.