#1
|
||||
|
||||
C/C++ Library for Evaluate ASM Codes
Hi everyone.
I'm looking for a tiny library (very tiny or lightweight library - because, it's just for simple instructions like the sample below) in C/C++ (or binding) that able to: - Evaluate simple x86/x64 assembly codes (execute codes from a string to get output). - Each asm instruction has callback or hook (at least memory access instruction, for several special purposes, E.g. using ReadProcessMemory to read memory from other process, etc). Maybe a little bit like a VM. Code:
MOV RAX,$INPUT ADD RAX,8 MOV RAX,[RAX] # eg. memory access instruction MOV $OUTPUT,RAX Last edited by vic4key; 07-17-2022 at 01:21. Reason: for more clear |
#2
|
|||
|
|||
This may be what you want:
(1) Chinese introduction https://tboox.org/cn/2016/07/26/x86-script-instruction-virtual-machine/ (2) Source code https://github.com/tboox/vm86 |
#3
|
|||
|
|||
If you are willing to do a bit of coding, ASMJit is a good choice. It's much powerful in capabilities than your needs, but flexible and let's you do anything including execute dynamically. It has an assembly parser called asmtk or the like. It's probably 30 lines of code to do everything you asked for that simple snippet. How inputs and outputs are dealt with would be the only tricky part...both parsing and binding it, but it's feasible
|
The Following 4 Users Say Thank You to chants For This Useful Post: | ||
bigboss-62 (07-15-2022), niculaita (07-14-2022), sh3dow (07-17-2022), vic4key (07-16-2022) |
#4
|
|||
|
|||
well-known x64dbg is using asmjit, some examples of usage over here
https://github.com/x64dbg/x64dbg/blob/development/src/dbg/assemble.cpp |
#5
|
||||
|
||||
Quote:
I'd like to take advantage of the existing codes to avoid rewriting, but it's released under the GNU license, a bit inconvenient, although my software is open source. |
#6
|
||||
|
||||
@BlackWhite @chants I created the topic long time, no one answer, so I think it's being in the hell now and I didn't come back to see your answers. Thank you guys.
Quote:
Quote:
|
#7
|
|||
|
|||
you can use keystone https://github.com/keystone-engine/keystone for parsing the assembly and then use unicorn https://github.com/unicorn-engine/unicorn to execute the instructions, which have all the hooks you want on every instruction execution. if you want to emulate complete pe file then you can use qiling https://github.com/qilingframework/qiling.
|
The Following User Says Thank You to 0xall0c For This Useful Post: | ||
h8er (07-21-2022) |
Thread Tools | |
Display Modes | |
|
|