Notes: (1) I'm working in Windows 7 64-bit and (2) I've already seen How can I test a Windows DLL file to determine if it is 32 bit or 64 bit?.
I'm trying to write a C program that checks a DLL's bitness. Using the Windows API and the Debug Help Library, I am able to get to the NT Header's FileHeader.Machine.
My program seems to work for 32-bit DLLs, but misrecognizes C:\Windows\System32\KERNEL32.DLL as 32-bit (Why do 64-bit DLLs go to System32 and 32-bit DLLs to SysWoW64 on 64-bit Windows?).
I've looked at Dependency Walker, but I get inconsistent results between the 32- and 64-bit versions of depends.exe -- C:\Windows\System32\KERNEL32.DLL is recognized by the 32-bit version of depends.exe as 32-bit (CPU: x86), but is recognized by the 64-bit version as 64-bit (CPU: x64).
Is FileHeader.Machine not the way to go? How is the 64-bit version of depends.exe able to recognize a DLL as 64-bit?