سؤال

I am trying to determine if the PC my app is running on is x64 or x86.

Here is my current code:

format PE GUI 4.0
include "Win32A.Inc"


entry start


section ".idata" import data readable writable

        library kernel32,"KERNEL32.DLL",user32,"USER32.DLL"

        import  kernel32,\
                IsWow64Process,"IsWow64Process",\
                GetCurrentProcess,"GetCurrentProcess",\
                ExitProcess,"ExitProcess"

        import  user32,\
                MessageBox,"MessageBoxA"

section '.data' data readable writeable

hProcess        dd ?
hResult         dd ?

section '.code' code readable executable

start:

        invoke     GetCurrentProcess
        mov        [hProcess],eax
        invoke     IsWow64Process,hProcess,hResult
        cmp        [hResult],1
        je         Is64
        cmp        [hResult],0
        je         Is32
        invoke     ExitProcess,0

Is64:

            invoke       MessageBox,0,'64','AR',0
            invoke       ExitProcess,0
Is32:

            invoke       MessageBox,0,'32','AR',0
            invoke       ExitProcess,0 

It simply crashes upon execution.

What is the proper way to check the value of a boolean, am I doing that part correctly?

Thanks for any help solving this issue.

هل كانت مفيدة؟

المحلول

To be able to declare inline strings, you need to include the extended headers:

include "Win32AX.Inc"

or else '64' and so on will be interpreted as constants.

You're also not passing hProcess as a value:

invoke     IsWow64Process,[hProcess],hResult
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top