I need to put markers to C++ code that should be visible in assembly or binary. It seems it’s straight forward to do it for 32 using inline assembly:
__asm {
NOP
NOP
NOP
}
or using DB assembly statement:
__asm {
DB 0x00, 0xFF, 0x10
}
But VisualStudio 2005 and better does not support inline assembly for x64. Is there any way to do it? Probably I can make a function in separate assembly module but how I can be sure that linker will put an actual assembly there instead of CALL?
Define a global volatile variable somewhere, say
volatile __int64 blah = 0;. Then wherever you want some marker, use_InterlockedCompareExchange64(&blah, SOME_UNIQUE_CONSTANT1, SOME_UNIQUE_CONSTANT2);. You’ll be guaranteed to find instructions loadingECX:EBXwithSOME_UNIQUE_CONSTANT1andEDX:EAXwithSOME_UNIQUE_CONSTANT2followed byLOCK CMPXCHG8B(0xF0, 0x0F, 0xC7, etc — see instruction encoding details).