Disassembler functions lazarus / 62-General ---------------------------------------------------------------------- LemonParty · 2016-12-11 18:35 Lazarus can use disassembler to show code in assembler (window shown when some bug occur). Is it some libraries to return compiled code in assembler mnemonics? I want parse binary code. Something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Assemble(Proc{procedure address}: Pointer): AsmCode;Maybe it is possible to use built-in disassembler? ---------------------------------------------------------------------- marcov · 2016-12-11 18:42 I think that that is GDB output, not Pascal code. ---------------------------------------------------------------------- guest58172 · 2016-12-11 19:16 You can use beaengine. I used it in 2011 in Hexalt (made with Delphi) so it can certainly be linked with FPC. https://github.com/BeaEngine/beaengine ---------------------------------------------------------------------- LemonParty · 2016-12-11 20:34 This is what I looking for. I download git sources. Then try to build clear program on Windows, on x32 compiler, but received "Error: Can't open object file: BeaEngineLib.obj". I found this file, download and put in project dir. So new problem sound like "Error: Illegal COFF Magic while reading BeaEngineLib.obj". What's wrong? ---------------------------------------------------------------------- guest58172 · 2016-12-11 21:09 which compiler did you use to build beaengine ? Would it be possible that it produced an OMF object ? ---------------------------------------------------------------------- Akira1364 · 2016-12-11 21:44 The FPDebug package that comes with Lazarus includes a native disassembler in fpdbgdisasx86.pp, which you call with the following procedure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure Disassemble(var AAddress: Pointer; const A64Bit: Boolean; out ACodeBytes: String; out ACode: String); ---------------------------------------------------------------------- LemonParty · 2016-12-11 21:55 I found ready decision: https://github.com/stievie/TCapstone. Those framework have working TCapstone class for disassemble (to compile test.lpi comment line {$R *.res} inside). (use Visual Studio) (Thank, Akira1364, try it later) ---------------------------------------------------------------------- guest58172 · 2016-12-11 22:11 I've attached the right object generated with mingw32. Tested Ok however it's a pita to link because you have to declare and export several C functions from the standard library (_strlen, _strcmp, _strcpy, _memset and _printf). The gcc comd line is simple: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i gcc -c  -DBEA_ENGINE_STATIC -Iinclude -obin/coff32/beaengine.obj "BeaEngine.c" ---------------------------------------------------------------------- LemonParty · 2016-12-11 22:14 Download capstone.dll http://www.capstone-engine.org/download.html from "Windows - Core engine" paragraph. ---------------------------------------------------------------------- LemonParty · 2016-12-12 12:29 FpDbgDisasX86 unit usage example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; {$mode objfpc}{$H+}{$AsmMode intel} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} FpDbgDisasX86; {$R *.res}var  b: byte; W: Word;  P: pointer;procedure AAA;begin b:= 5; W:= 3; asm  mov ax, w; end;end;{instructions to be disassemble}procedure Go(N: byte);var CB, C: String;begin for N:= 1 to N do begin  Disassemble(P, false, CB, C);  Writeln(CB:25, ' ', C); end;end; begin P:= @AAA; Go(7); readln;end.