A forum for reverse engineering, OS internals and malware analysis 

Ask your beginner questions here.
 #32243  by zer0cat
 Sat Nov 10, 2018 7:48 pm
Hello
I have some code in C++, which invokes Asm procedure. One procedure is 32 bit (asm x86), and other is 64 bit (asm x64).
Example:
Code: Select all
x86 proc
mov eax,dword ptr[edx]
ret
x86 proc

x64 proc
mov rax,qword ptr [rdx]
ret
x64 proc
Can I compile the code into a 32-bit PE file that detects the architecture and, depending on the bit depth of Windows, calls x86 or x64 proc? Or it is impossible?
 #32253  by Vrtule
 Wed Nov 14, 2018 12:18 pm
You can write two ASM procedures: one for 32-bit and one for 64-bit platform, and use preprocessor macros (ifdefs) to compile only the procedure appropriate to the selected target.