zyantific / zydis

Fast and lightweight x86/x86-64 disassembler and code generation library
https://zydis.re
MIT License
3.3k stars 427 forks source link

Encoding possible issue/help #515

Closed colbster255 closed 1 week ago

colbster255 commented 2 weeks ago

Hi everyone, ive been trying to encode an instruction: "movaps xmm(0-9), [reg]" and no matter what I try it fails to encode. Its an issue with movaps xmm as I do the same 2nd op settings other places in my code and its fine. I was wondering if someone saw anything wrong with this and or could leave an example on how they would do it.

Thanks alot,

zydis

mappzor commented 2 weeks ago

Memory size should be 16 (128 bits).

colbster255 commented 2 weeks ago

Memory size should be 16 (128 bits).

But that's only for the second operand, no? r15 is a 64 but register so i assumed it would need to be 8 bytes. I'll give it a try when im home, but i'd love to learn why aswell

mappzor commented 2 weeks ago

You are confusing size of base register with size of memory operand. Currently you are trying to encode movaps xmm9, qword ptr [r15]. Such instruction cannot exist, as movaps requires access to 16 bytes of memory (movaps xmm9, xmmword ptr [r15]).

colbster255 commented 2 weeks ago

You are confusing size of base register with size of memory operand. Currently you are trying to encode movaps xmm9, qword ptr [r15]. Such instruction cannot exist, as movaps requires access to 16 bytes of memory (movaps xmm9, xmmword ptr [r15]).

Interesting, thanks so much! I appreciate it a lot. That makes sense, I was confused why I was manually setting the size of the register.

colbster255 commented 2 weeks ago

You are confusing size of base register with size of memory operand. Currently you are trying to encode movaps xmm9, qword ptr [r15]. Such instruction cannot exist, as movaps requires access to 16 bytes of memory (movaps xmm9, xmmword ptr [r15]).

Worked, thanks so much for the help.