j4nSolo
j4nSolo

Reputation: 402

Identify whether a dll is built in debug or release with python

Is there any way to determine whether a dll built in MS Visual Studio 2005 (C++) was compiled in debug or in release with python?

I know VS is able to load the dll and show you the manifest where some metadata stores this information. Would any python module be able to do it as well?

Another option would be to identify this dll's dependencies on other dlls and look for debug-only ones e.g.: msvcr80D.dll, if that is possible.

Upvotes: 1

Views: 303

Answers (1)

Karakil
Karakil

Reputation: 38

Pefile can help you parse PE executable. You can find some usage examples on the project's page.

Regarding the second part of your question you could do something like this to retrieve the list of the dll's dependencies (taken from the examples):

import pefile

path_to_dll = r"path_to_your_dll"
pe =  pefile.PE(path_to_dll, fast_load=True)

# If the PE file was loaded using the fast_load=True argument, we will need to parse the data directories:
pe.parse_data_directories()
for entry in pe.DIRECTORY_ENTRY_IMPORT:
    print entry.dll

In my case I got the following output: KERNEL32.dll, MSVCP80D.dll, MSVCR80D.dll, ADVAPI32.dll.

Upvotes: 2

Related Questions