How can I determine whether a process is 32 or 64 bit?

前端 未结 3 1494
忘掉有多难
忘掉有多难 2021-02-07 19:36

Given a Windows process handle, how can I determine, using C++ code, whether the process is 32 bit or 64 bit?

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-07 20:37

    If you have handle to the module then you can do this:

    IMAGE_NT_HEADERS * headers = ImageNtHeader(handle);
    
    if ( headers->FileHeader.Machine == IMAGE_FILE_MACHINE_I386 )
    {
        //module is x86
    }
    else if  ( headers->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64 )
    {
        //module is x64
    }
    

    I took help from my own answer.

提交回复
热议问题