- Code Snippets
- Identify If a DLL is 32bit or 64bit
Identify If a DLL is 32bit or 64bit

You do not have to guess if a DLL or assembly is targeting 32bit(x86) or 64bit(x64). Visual Studio comes with handy tool called Corflags. You can access this tool by the Visual Studio command prompt.
I created test assemblies and compiled them in Visual Studio to demonstrate the usage of this tool. You can skip ahead to a particular example through the links below.
# | Target | PE | 32BITREQ |
---|---|---|---|
1 | 32Bit | PE32 | 1 |
2 | 64Bit | PE32+ | 0 |
3 | Any CPU | PE32 | 0 |
4 | Any CPU with Prefer 32 bit | PE32 | 1 |
In Visual Studio 2019, the command prompt can be found under Tools-> Command Line -> Developer Command Prompt
Developer Command Prompt for Corflags Navigate to directory of the DLL then type in the command below.
Command:corflags #dll_name#.dll
Examples Below:
32bit Assembly
32bit Assembly Build Parameters
C:\temp>corflags TestLibrary32Bit.dll
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.8.3928.0
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0x3
ILONLY : 1
32BITREQ : 1
32BITPREF : 0
Signed : 0
When PE equals PE32 and 32BITREQ equals 1
64bit Assembly
64bit Assembly Build Parameters
C:\temp>corflags TestLibrary64Bit.dll
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.8.3928.0
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v4.0.30319
CLR Header: 2.5
PE : PE32+
CorFlags : 0x1
ILONLY : 1
32BITREQ : 0
32BITPREF : 0
Signed : 0
When PE equals PE32+ and 32BITREQ equals 0
Any CPU Assembly
Any CPU Assembly Build Parameters
C:\temp>corflags TestLibraryAnyCPU.dll
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.8.3928.0
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0x1
ILONLY : 1
32BITREQ : 0
32BITPREF : 0
Signed : 0
When PE equals PE32 and 32BITREQ equals 0
Any CPU With Prefer 32bit
Any CPU with Prefer 32bit Assembly Build Parameters
C:\temp>corflags AssemblyTargets64BitOr32Bit.exe
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.8.3928.0
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0x20003
ILONLY : 1
32BITREQ : 0
32BITPREF : 1
Signed : 0
When PE equals PE32 and 32BITREQ equals 1.