1

Possible Duplicate:
How to know a process is 32-bit or 64-bit programmatically

I'm writing an app that injects a dll into other applications. In order for this to work properly, I need to know if the other application is running in 32 or 64 bit mode. Is there any way to detect this, without attempting to parse the PE header of the application?

Please do not suggest IsWow64Process. This does not do what I want, specifically this bit makes it useless:

If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE.
Community
  • 1
  • 1
devicenull
  • 484
  • 1
  • 4
  • 14
  • What language? I assume C or C++ – Ganesh R. Jan 04 '13 at 16:19
  • May not be the best way. But can we try looking at size of int ptr and based on its size, determine if 32 bit or 64 bit? – Ganesh R. Jan 04 '13 at 16:21
  • That's won't help. It would let me detect the architecture of my process, but it would not help in detecting the architecture of the other process (which is not controlled by me) – devicenull Jan 04 '13 at 16:22
  • 1
    Wouldn't it work to obtain the information you need anyway? First check the environment your application is running on; if it's 32-bit, then all processes will be 32-bit. If you're on 64-bit AND IsWow64Process() returns True, then the process is running in 32-bit mode, otherwise 64. – OnoSendai Jan 04 '13 at 16:26
  • Just out curiosity,are you writing some "crack" program? – Jack Jan 04 '13 at 16:32
  • Just info see http://madcoderspeak.blogspot.in/2009/06/how-to-create-global-system-windows.html and http://msdn.microsoft.com/en-us/library/ms644990%28VS.85%29.aspx – Ganesh R. Jan 04 '13 at 16:33
  • It's a compatibility shim, not a crack. – devicenull Jan 04 '13 at 18:00

1 Answers1

1

Try the code from this page, it takes the size of an int to check, if you want this in C#.

How to determine programmatically whether a particular process is 32-bit or 64-bit

Or perhaps this in C++.

How can I dynamically get the system architecture?

Community
  • 1
  • 1
  • The C# code is pretty much what I want to do. I just realized that IsWow64Process is indeed what I want, I just need to make sure I'm running on a 64bit machine before using it. – devicenull Jan 04 '13 at 16:25
  • @devicenull Nice :) But seriously good luck. –  Jan 04 '13 at 16:26
  • 2
    I don't think posting links to other question/answer are worthy answers. There are always comments for that. – netcoder Jan 04 '13 at 17:21