tags:

views:

123

answers:

1

Hello,

I need to extract code (but not data!) from classic win32 exe/dll files. It's clear I can't do this only with extraction of code segment content (because code segment contains also the data -- jump tables for example) and that I need some help from compiler.

*.map files are nice but they only contain addresses of functions, i.e. the safest thing I can do is to start at that address and to process until the first return / jump instruction (because part of the function could be mentioned data)

*.pdb files are better but I'm not sure what tools to use to extract information like this -- I took a look at DbgHelp and DIA SDK, the latter one seems to be the right tool but it doesn't look very simple. So my question/questions:

  1. To your knowledge, it is possible to extract information about code/data position (address + length) only via DbgHelp?
  2. If the DIA SDK is the only way, any idea what should I call for getting information like that? (that COM stuff is pretty heavy)
  3. Is there any other way?

Of course my concern is about Visual Studio, C/C++ source compilation in the first place.

Thanks for any hint.

A: 

Well, I just happened to read the other day that DIA is a lot easier to use from C# (links to source for a simple program); another program that keeps coming up on my google searches is PDB Cracker, which also has source code, and is probably more relevant to your intended application.

SamB