LM_Assemble
Assembles a single assembly instruction into machine code.The assembly instruction to be assembled.Example:
"mov eax, ebx"Pointer to an
lm_inst_t structure that will be populated with the assembled instruction.Returns
LM_TRUE if the instruction was successfully assembled, LM_FALSE otherwise.LM_AssembleEx
Assembles multiple assembly instructions into machine code with full control over architecture and runtime address.The assembly instructions to be assembled. Multiple instructions can be separated by semicolons.Example:
"mov eax, ebx ; jmp eax"The target architecture for assembly. Can be:
LM_ARCH_X86- x86 32-bitLM_ARCH_X64- x86 64-bitLM_ARCH_ARMV7,LM_ARCH_ARMV8,LM_ARCH_AARCH64- ARM variants- And more (see
lm_arch_tenum)
The runtime address used to resolve addressing (e.g., relative jumps will be calculated based on this address).Use
0 if you don’t need specific address resolution.Pointer that will receive the assembled machine code buffer.Important: Must be freed with
LM_FreePayload() after use.Returns the size of the assembled instructions in bytes on success, or
0 on failure.LM_FreePayload
Frees memory allocated byLM_AssembleEx.
The payload buffer that was allocated by
LM_AssembleEx.Example (Rust)
This example demonstrates using the assembler API to patch a function:lm_inst_t Structure
Thelm_inst_t structure represents a single instruction: