0

i have this code in asm:

cmp ecx,46DC0E00
je 1A380021
nop dword ptr [eax+00]
mov [edx+00000584],ecx
mov [edx+00000584],00000000
jmp game.exe+A42067
mov [edx+00000584],ecx
jmp game.exe+A42067

and i have this code on C++:

__asm
   {
      cmp ecx, 0x46DC0E00
      je $ + 0x19 //25 bytes

      **i need put NOP DWORD here**

      mov[edx + 0x00000584], ecx
      mov[edx + 0x00000584], 0
      jmp JmpBack
      mov[edx + 0x00000584], ecx
      jmp JmpBack
   }

how do I put this nop dword in the c++ code? if I write normally, visual studio returns an error.

visual studio error image

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • IIRC, MSVC has `_emit` so it might be possible to encode it manually if MSVC doesn't have mnemonics for different lengths of NOPs. IDK if you can use `_emit` inside a larger `asm{}` block, and I'm pretty sure MSVC doesn't allow `db`. (If you were using gcc, clang, or ICC, this would be no problem; they allow `.byte`. Of course, jumping out of an asm statement or block is generally not supported on those compilers; IDK if it is on MSVC). – Peter Cordes Aug 12 '21 at 04:25
  • 4
    However, are you sure you even want a `nop` in your inline asm? The original code probably just had it for performance reasons like aligning the top of a loop, and in the compiler-generated code that contains your asm, the cmp/je will likely start at a different offset relative to a 16 byte boundary. Use labels for your jump targets instead of hard-coding `$ + 0x19`. It's an interesting question, but this doesn't look like a good use-case for any kind of NOP. – Peter Cordes Aug 12 '21 at 04:27
  • 1
    Please don't post images. Put the error message in your question. – prl Aug 12 '21 at 05:33
  • Thanks so much peter, it work, I have no idea but it wasn't working without nop dword but now it's working fine haha ;;;;;; prl, Ok, thanks so much <3 – devNotonePiece Aug 12 '21 at 05:40

0 Answers0