News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Looking for help with debug pgm, MASM error list & how to Disassemble LIB files

Started by ROBOSPOOK, June 04, 2014, 10:22:48 AM

Previous topic - Next topic

ROBOSPOOK

Ok new topic
actually three questions.

1. is there an accepted way to debug a program that you are working on.  By this I mean how do I single step through each instruction like you used to be able to do with Borland's TURBO DEBUGGER when using Turbo C or Turbo ASM?  This is a wonderful way to learn exactly what a program does even though it is often a lengthy process.   

2. Is there a complete (or nearly so) list of the MASM error codes that one may see when compiling and linking programs? I have run into several errors that I could not identify in the past (don't have anything right now off the top of my head) and it would be great to know where I have err'd.

3. What is the best way to disassemble say WIN32K.LIB so that I can see what is in it. 
I am having problems knowing what functions/procedures are even available for me to use when I write a program let alone when I am looking at what someone else has written.

ROBO

dedndave

there are probably at least 100,000 windows functions, structures, and constants
memorize them - test on friday

most of the commonly used functions are listed in the different INC files (\masm32\include folder)
in the same folder, windows.inc and winextra.inc contain structures and constants
you can also access MSDN, in a couple different ways
it's available in CD form (or maybe download) - the entire library - kinda big

another way is to use the MSDN site
you can typically google a function or structure name, one of the first hits will be the MSDN page
example.....
google "WriteFile"

first hit, "WriteFile function (Windows) - MSDN - Microsoft"
"(Windows)" is a sign you probably have the right one
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747%28v=vs.85%29.aspx

notice on the left side of the page
you can browse through all the different levels of MSDN documentation
some of it is purely informational (descriptive)
most of it describes specific functions, structures, constants, etc

dedndave

i am not familiar with win32k library
but - most of the libraries in masm32\lib are import libraries, meaning they have no code
the actual code resides in DLL's, Windows\System32\*.dll

the masm32.lib library is accessible by looking at the source files in masm32\m32lib
and, the macros are in masm32\macros\macros.asm

both of those folders are great for learning

there are ways to get at the disassembled code in other LIB's
but - reading disassembled code is not as easy as reading source code

many of us use Olly debugger
some use WinDebug
it's a tossup - i like Olly
you can make it the "just in time" error handler, replacing Dr Watson
when an exception occurs, your debugger pops up instead of a message box with error text

then, you can cause an exception in your program (int 3 is used)
your program will run up to that point, generate an exception, and the debugger pops up
then, with Olly....
F7 = step forward and go inside procs
F8 = step forward but don't go inside procs (this is probably what you want)
F9 = go until you hit ExitProcess or an exception (e.g. int 3)

dedndave

there are a few other tools that are handy to have.....

dependency walker
WinSpy++
ResHacker

besides a debugger, those are probably the most-used

also nice to have some sort of PE viewer/editor, although i rarely use it

HxD - use it all the time, even for non-programming uses

dedndave

masm and link error codes are on MSDN
i find it helps to put the ".exe" on the end to google

"msdn masm.exe"
"msdn link.exe"

ROBOSPOOK

Thanks  dedndave,

That answers most of the questions, well at least the ones I asked.  Time for me to go back and start reading some more.  I have been trying to figure out what how MichaelW accessed actual disk sectors with his program.  Tis NEAT!  this will take a little work because it is way different than 16 bit asm.

thanks again

Robo

Gunther

Robo,

Quote from: ROBOSPOOK on June 04, 2014, 01:28:26 PM
That answers most of the questions, well at least the ones I asked.  Time for me to go back and start reading some more.  I have been trying to figure out what how MichaelW accessed actual disk sectors with his program.  Tis NEAT!  this will take a little work because it is way different than 16 bit asm.

Don't forget to inspect the examples of the MASM32 package. They're very instructive.

Gunther
You have to know the facts before you can distort them.

sinsi


MichaelW

Quote from: ROBOSPOOK on June 04, 2014, 01:28:26 PM
I have been trying to figure out what how MichaelW accessed actual disk sectors with his program.

Most of what you need to know is in the documentation for CreateFile.
Well Microsoft, here's another nice mess you've gotten us into.

Vortex

Hi Robo,

You can use PEview to view the internals of an import library :

http://wjradburn.com/software/

Concerning static libraries, you can extract all the object modules with Pelle's librarian Polib and disassemble the modules with Agner Fog's objconv :

http://www.agner.org/optimize/

dedndave

almost forgot....
in the masm32\bin folder is a program named dumppe.exe
dumppe -disasm MyProgram.exe >MyProgram.txt
works for DLL's, too