Sinisterly
[FASM] Heaven's gate - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Assembly (https://sinister.ly/Forum-Assembly)
+--- Thread: [FASM] Heaven's gate (/Thread-FASM-Heaven-s-gate)



[FASM] Heaven's gate - dopamine - 12-12-2014

Code:
include 'win32ax.inc' ;We want to run as a x86 process

.data
        szMessageCaption        DB "DeadlyVermilion", 0
        szMessageText32         DB "This seems to be running on a 32 bit operating system.", 0

.code

proc Our64Proc ;This proc is x64 code
     use64
        CALL @F
        DB "This was generated using 64 bit ASM code.", 0
@@:
        POP RAX
        MOV RCX, RAX

     use32
        RETF
endp

start:
        ;invoke DebugBreak ;Used for debugging

        MOV AX, CS
        CMP AL, 1Bh ;1Bh for 32 bits native, 33h if 64 bits native, 23h for wow64
        JE Its32BitsNative
        CMP AL, 33h
        JE ExitCode

        XOR ECX, ECX
        CALL 33h:Our64Proc

        invoke MessageBox, 0, ECX, szMessageCaption, MB_OK
        JMP ExitCode

Its32BitsNative:
        invoke MessageBox, 0, szMessageText32, szMessageCaption, MB_OK


ExitCode:
        invoke ExitProcess, 0
.end start

Author: DeadlyVermillion