FasmManaged ( managed C++ wrapper for the library version of Flat Assembler)这是 FASM 的作者在此线程中发布的 Flat Assembler 库版本的托管 C++ 包装器。包括完整的 C++ 源代码和 C# 使用示例。在 C++ 源文件 fasmdll_managed.cpp 中,还可以找到如何从非托管代码调用 FASM.OBJ(包含在源代码下载中)的示例。
它有什么作用?
基本上,它允许 C# 和 VB.NET 程序员比普通方法更容易地组装和注入代码到另一个进程中。
(This is a managed C++ wrapper for the library version of Flat Assembler released by FASM's author in this thread. Included is the full C++ source code and a C# example of use. In the C++ source file fasmdll_managed.cpp, one can also find an example of how to invoke FASM.OBJ (included in source download) from unmanaged code.
What does it do?
Basically, it allows C# and VB.NET programmers to assemble and inject code into another process with far greater ease than normal methods.
Can you give me a step-by-step example of use?
1. Use either the class constructor or fasm.SetProcessHandle(IntPtr) to set the process handle to that of the process into which code will be injected.
2. Use fasm.AddLine(string) to add to the list of mnemonics to be assembled. FASM uses Intel syntax. You can find the FASM Programmer's Manual here.
3. a. Call fasm.Assemble() which will return the bytecode in the form of a byte-array.
b. Call fasm.Inject(), fasm.InjectAndExecute(), or fasm.InjectAndExecuteEx() to inject your code into the process. Each of these takes at least one parameter: the address at which code will be injected; optionally, you can specify a handle to the process into which code will be injected and, in the case of the latter two, a parameter to be passed to the code upon injection.)