2012-10-16 31 views
1

我想確定我的應用程序運行的PC是x64還是x86。FASM - IsWow64Process - 檢查布爾結果

這裏是我當前的代碼:

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 

它只是崩潰後執行。

什麼是檢查布爾值的正確方法,我正確地做那部分?

感謝您解決此問題的任何幫助。

回答

1

爲了能夠在線聲明字符串,你需要包括擴展頭:

include "Win32AX.Inc" 

或者「64」等將被解釋爲常數。

你還沒有通過hProcess作爲一種價值:

invoke  IsWow64Process,[hProcess],hResult