views:

99

answers:

5

Is there a way to follow a program's execution through DLL code in hex?

For example, I want to see what sections have just been read when I press a button. It has to work for x64 DLL's.

Thanks!

+3  A: 

Yes you load the process into debugger and single step it.

Preet Sangha
How would this work, I only can see the function calls and I'm really not experienced with debugging :(
rubenvb
@rubenvb: Now's the time to get experienced with debugging. It's doing what you want - you can set breakpoints wherever you wish, and see the assembly-language representation of the code.
Borealid
A: 

You can use the tool at http://ircdb.org to log function calls arbitrary DLLs.

It's name is SocketSpy, because initially it was created for tracing winsock.dll only, but it does allow you to trace other dlls.

From http://fixunix.com/programmer/95098-tracing-library-dll-calls-win32.html

Use Option->Default Break Point List Menu to add or remove soft breakpoints from attached DLLs. Put soft breakpoints only at function you need to maximize execution time.

Soft breakpoint means that socketspy does not stop at this breakpoint, only log breakpoint information. Hard breakpoint means that socketspy DOES STOP at this breakpoint, and Breakpoint dialog is opened. Specify what calls should be captured ALL, FROM EXE FILE or from DLLs (Combobox).

Specify log file File->Open Log File menu if you want to save function DLLs' calls into the text file, enable logging (check box).

Then select a new or already action process (Select Process button). The tool can be used in NT/2000/XP only

Alternatively, there is StraceNT, which can trace arbitrary Dlls. It is available for free from http://www.intellectualheaven.com/default.asp?BH=projects&H=strace.htm

mdma
These don't work for x64 DLL's (I've just tried both).
rubenvb
Sorry, I'd forgotten that requirement.
mdma
A: 

I've not used it, but I once stumble upon an Intel tool, which samples the context of the Instruction Pointer, and is able to use symbol files to convert IP to an actual function name... VTune maybe?

I guess there might be other such tools

UPDATE: aka. "statistical profilers"...

pascal
+2  A: 
  1. Load the project in visual studio.
  2. Press 'Play' or F5 to start the program in the debugger.
  3. You will need to eventually halt execution sometime so you can start stepping through code or assembly code. You can do this by inserting a breakpoint, or breaking the execution by hitting the break command in the visual studio IDE.
  4. Once halted, you can right click in the code view window, and select "Show Disassembly". Then it will show you the machine instructions.
  5. Also in the watch window in the visual studio debugger, the right click pop up menu has an option to display all variables as hexidecimal. I'm beginning to prefer hex myself lately, because I can see invalid memory patterns easier.
C Johnson
Will this work without any source code?
rubenvb
A DLL contains source code. albeit, machine assembly instructions types source code. So yes, the visual studio debugger can let you single step through assembly instructions even if you don't have the source code.
C Johnson
This seems like it might work, now to install my free student Visual Studio 2010...
rubenvb
A: 

Debugging using IDE does not show you the assembly language equivalent of the execution of an IL instruction. You need to write your own hooks to a proper disassembler.

Carnotaurus
Assuming of course he wants to debug .NET. Then of course he simply needs reflector to do that. No need to ask a question like that above.
C Johnson