The MASM Forum

General => The Campus => Topic started by: flashcoder on May 01, 2017, 11:45:44 PM

Title: inline ASM to C++ code
Post by: flashcoder on May 01, 2017, 11:45:44 PM
Hello friends,

already that inline asm not is compatible with x64 compiler on MS Visual Studio ( and some others IDEs ), i'm needing pass this asm code below
to C++ to be compatible with both compilers ( x32 and x64 ).


__declspec(naked) void DllCall_stub(HMODULE hMod)
{
   _asm
   {
      push 0
      push 1
      push [esp+0Ch]
      mov eax, 0xDEADBEEF   
      call eax
      ret
   }
}

__declspec(naked) void DC_stubend(void) { }


The asm code above is part of a Manual Mapping injector ( attached in this topic) that compiles with success ( only to x86, because of this inline asm  :(  )

Someone could help me please?

thank you to all.
Title: Re: inline ASM to C++ code
Post by: hutch-- on May 02, 2017, 02:02:09 AM
Flash,

As far as I know 64 bit Microsoft C/C++ does not support inline assembler. You will need to write the assembler code with an assembler. You can use ML64 or if you are familiar with them, any of the 64 bit capable Watcom clones. If you do this in both 32 and 64 bit, you only need to swap the assembler module at build.
Title: Re: inline ASM to C++ code
Post by: newrobert on May 02, 2017, 07:58:00 AM
write xxx.asm source code will let assembler more pure .
Title: Re: inline ASM to C++ code
Post by: flashcoder on May 02, 2017, 08:23:09 AM
Quote from: newrobert on May 02, 2017, 07:58:00 AM
write xxx.asm source code will let assembler more pure .

@newrobert, ok.

Now how must be the structure of .asm file with this code above?

Could give a example?