-
|
I've been having an issue referencing data embedded using the Here's a snippet that demonstrates the issue: let mut a = CodeAssembler::new(32)?;
let mut skip_data = a.create_label();
let mut data = a.create_label();
a.jmp(skip_data)?;
a.set_label(&mut data)?;
a.db(b"\x90\xCC\xF1\x90")?;
a.set_label(&mut skip_data)?;
a.lea(eax, dword_ptr(data))?;
a.assemble(0x0)?;Calling Is this a case of user error or a bug within the library? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
That example is from the README and uses 64-bit mode and will fail in 16/32-bit mode. One workaround is to get the address of the label after assembling it (see Another one is to do something like: call there
my_data:
db 1,2,3,4
there:
pop eax
I created an issue: #281 |
Beta Was this translation helpful? Give feedback.
That example is from the README and uses 64-bit mode and will fail in 16/32-bit mode.
One workaround is to get the address of the label after assembling it (see
assemble_options()?.label_ip()and then patching an instruction, eg. a 'mov eax,imm32' instruction. You can get the offset of the imm32 by passing inBlockEncoderOptions::RETURN_CONSTANT_OFFSETS | BlockEncoderOptions::RETURN_NEW_INSTRUCTION_OFFSETStoassemble_options().Another one is to do something like:
eaxnow has the address ofmy_data.I created an issue: #281