简体   繁体   English

错误的反汇编输出(BeaEngine)

[英]Incorrect disassemble output (BeaEngine)

I've gone through significant trouble to achieve what I believe to be a correct setup of BeaEngine with visual studio. 我遇到了很大的麻烦,以实现我认为是Visual Studio的BeaEngine正确设置。 I will sum up the setup process very quickly : build of with cmake 3.6 x64, sourcefile -> C:/Users/Ulysse/Documents/beaengine-master CmakeLogs : Configuring done Generating done After which I opened the solution within visual studio and compiled in release mode to obtain .lib and .dll files : BeaEngine_stdcall_64.dll and BeaEngine_stdcall_64.lib. 我将非常快速地总结设置过程:使用cmake 3.6 x64构建源文件-> C:/ Users / Ulysse / Documents / beaengine-master CmakeLogs:配置完成生成完成之后,我在Visual Studio中打开解决方案并进行编译释放模式以获取.lib和.dll文件:BeaEngine_stdcall_64.dll和BeaEngine_stdcall_64.lib。 I have included include and lib folders and have added the lib file to the linker->input->additionnal dependencies within my Visual Studio 2015 x64 project. 我已经包含了include和lib文件夹,并且已将lib文件添加到Visual Studio 2015 x64项目中的链接器->输入->附加依赖项。 The project is a 32 bit console application. 该项目是一个32位控制台应用程序。 I am now trying to run an example taken from BeaEngine website, It compiles, it runs but provides no correct output of disassembled instructions, code is here : 我现在尝试运行一个从BeaEngine网站获取的示例,它可以编译,可以运行,但是没有提供反汇编指令的正确输出,代码在这里:

int main(void)
{
/* ============================= Init datas */
DISASM MyDisasm;
int nfalse = 0, ntrue = 1;
int len, i = 0;
bool Error = nfalse;

/* ============================= Init the Disasm structure (important !)*/
(void)memset(&MyDisasm, 0, sizeof(DISASM));

/* ============================= Init EIP */
int n;
_asm
{
    push eax
    call get_eip
        jmp out1
        get_eip : mov eax, [esp]
        ret
        out1 :
    mov n, eax
        pop eax
}
MyDisasm.EIP = n; //0x401000;

/* ============================= Loop for Disasm */
while ((!Error) && (i<100)) {
    len = Disasm(&MyDisasm);
    if (len != UNKNOWN_OPCODE) {
        puts(MyDisasm.CompleteInstr);
        MyDisasm.EIP = MyDisasm.EIP + len;
        cout << i << endl;
        cout << MyDisasm.CompleteInstr << endl;
        std::printf("%c", MyDisasm.CompleteInstr);
        i++;
    }
    else {
        Error = true;
    }
};
Sleep(100000);
return 0;
}

Note that I've had to add the inline asm part because the example given by BeaEngine's author would crash the program (false EIP as my compiled program never starts at 0x401000). 请注意,我必须添加内联asm部分,因为BeaEngine的作者给出的示例将使程序崩溃(错误的EIP,因为我的编译程序永远不会从0x401000开始)。 Now that I have corrected the EIP the program no longer crashes but puts fonction prints non printable characters and the printf which I have added show always the same character (which isn't ASCII). 现在,我已经更正了EIP,该程序不再崩溃,而是将fonction打印不可打印的字符,并且我添加的printf始终显示相同的字符(不是ASCII)。 Spent the whole day on this, am i missing something obvious ? 一整天都花在这里,我是否缺少明显的东西?

Okay it took me a whole other day but I found the problem. 好的,我花了整整一天的时间,但我发现了问题。 It's strange that a console win 32 was successfully compiled with the x64 version of the library and that half the program didn't not crash and almost ran perfectly (as it only failed at the last process of the disassembling). 奇怪的是,使用库的x64版本成功编译了win32控制台,并且该程序的一半没有崩溃并且几乎完美运行(因为它仅在拆卸的最后一个过程中失败)。 I went through the source code of the project and finally i just tried every single cmake build. 我浏览了该项目的源代码,最后我只是尝试了每一个cmake构建。 The actual problem is that the stdcall option of the cmake gui program wasn't selected. 实际的问题是未选择cmake gui程序的stdcall选项。 Note that the first few lines of the CMakeLists.txt file are : project (BeaEngine) cmake_minimum_required (VERSION 2.6) 请注意,CMakeLists.txt文件的前几行是:project(BeaEngine)cmake_minimum_required(VERSION 2.6)

set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") 设置(CMAKE_MODULE_PATH“ $ {CMAKE_SOURCE_DIR} / cmake”)

set (CMAKE_VERBOSE_MAKEFILE ON) 设置(CMAKE_VERBOSE_MAKEFILE ON)

option (optHAS_OPTIMIZED "Turn Optimizations ON" OFF) option (optHAS_SYMBOLS "Build with debug Symbols" ON) option (optBUILD_64BIT "Build 64 bits executable" OFF) option (optBUILD_DLL "Build Shared Objects" OFF) option (optBUILD_STDCALL "Build using stdcall" OFF) 选项(optHAS_OPTIMIZED“打开优化打开”关闭)选项(o​​ptHAS_SYMBOLS“构建调试符号”打开)选项(o​​ptBUILD_64BIT“构建64位可执行文件”关闭)选项(o​​ptBUILD_DLL“构建共享对象”关闭)选项(o​​ptBUILD_STDCALL“使用stdcall构建”关闭)

However if you get here by trying to get this library working make sure that you use these 2 core options while compiling : DLL->ON STDCALL -> ON. 但是,如果通过尝试使该库正常运行而到达此处,请确保在编译时使用以下两个核心选项:DLL-> ON STDCALL-> ON。 Then build with msvc and you will good to go. 然后使用msvc进行构建,您将一切顺利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM