2

I would like to be able to write my own version of a dependency walker tool (I think this is a good way to learn things). However, I don't have the necessery knowledge to be able to know, given a PE file (dll/exe) - what are it's depenencies.

I would appreciate a reference to a place that can supply me this knowledge (tutorial / article / literature / etc..).

Thanks!

Lost_DM
  • 941
  • 2
  • 10
  • 24

1 Answers1

2

It's straight forward in principle (pseudo-code off the top of my head):

Create empty dependency list (list 1)
Create empty list of references yet to be looked at (list 2)
Add main module to list 2
repeat
  Select first module in list 2
  Open the PE file
  Parse header to find import section
  Enumerate import modules
  for each module imported
    if not already in list 1, Add it
    if not already in list 2, Add it
  Remove from list 2
until list 2 is empty.
Result in list 1.

To figure out how to actually parse the relevant parts of a PE, you can get the Portable Executable specification off of msdn.microsoft.com.