How to encode the instruction like this mov eax, 0x00123456
and get b8 56 34 12 00?
I know how to encode but how to get the output in the buffer using AsmJit because encoding manually is not a good way to solve problem? It can be done more easily using AsmJit.
            Asked
            
        
        
            Active
            
        
            Viewed 247 times
        
    1
            
            
        
        Aligator
        
- 11
 - 2
 
- 
                    2I don't understand the question. Have you tried writing the bytes to the buffer? – fuz Jun 20 '22 at 21:31
 - 
                    The asmjit documentation should show how to use it. I'd expect you can pass it a string like `"mov eax, 0x00123456"` or whatever form it wants you to specify mnemonic and operands in. It would write the 5-byte machine code into the output buffer you give it, and return the length. I haven't used asmjit myself, but this seems like a "hello world" type of problem for asmjit. That's all you're asking for, right? – Peter Cordes Jun 21 '22 at 06:15
 - 
                    Seems pretty similar to [AsmJit equivalent of mov eax,\[ecx+0CC\]](https://stackoverflow.com/q/35195420) but with a different source operand, and you want to know the length and read the buffer. – Peter Cordes Jun 21 '22 at 06:17
 - 
                    But how to get output. I know how to encode but getting output is the problem. I cant find function which provides me output data – Aligator Jun 21 '22 at 10:04
 - 
                    Docs say it assembles into a `CodeBuffer` (https://asmjit.com/doc/structasmjit_1_1CodeBuffer.html), which as `uint8_t* data()` member function, and size and capacity. – Peter Cordes Jun 21 '22 at 12:47
 - 
                    AsmJit has an online documentation, which discusses how to get raw bytes: https://asmjit.com/doc/group__asmjit__core.html See `More About Environment` section. – Petr Jun 22 '22 at 17:55