09.02.2014 Views

Windows sysinternals

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2 <strong>Windows</strong> Core Concepts 27<br />

A symbol file must be built at the same time as its corresponding executable or it will not be<br />

correct and the debug engine might refuse to use it. Older versions of Microsoft Visual C++<br />

created symbol files only for Debug builds unless the developer explicitly changed the build<br />

configuration. Newer versions now create symbol files for Release builds as well, writing them<br />

into the same folder with the executable files. Microsoft Visual Basic 6 can create symbol files,<br />

but it does not do so by default.<br />

Symbol files can contain differing levels of detail. Full symbol files (sometimes called private<br />

symbol files) contain details that are not found in public symbol files, including the path to<br />

and the line number within the source file where the symbol is defined, function parameter<br />

names and types, and variable names and types. Software companies that make symbol files<br />

externally available typically release only public symbol files, while retaining the full symbol<br />

files for internal use.<br />

The Debugging Tools for <strong>Windows</strong> make it possible to download correct symbol files on<br />

demand from a symbol server. The server can store symbol files for many different builds of<br />

a given executable file, and the Debugging Tools will download the one that matches the<br />

image you are debugging. (It uses the timestamp and checksum stored in the executable’s<br />

header as a unique identifier.)<br />

Microsoft has a symbol server accessible over the Web that makes <strong>Windows</strong>’ public symbol<br />

files freely available. By installing the Debugging Tools for <strong>Windows</strong> and configuring the<br />

Sysinternals utilities to use the Microsoft symbol server, you can easily see what <strong>Windows</strong><br />

functions are being invoked by your processes.<br />

Figure 2-5 shows a call stack for an event captured with Process Monitor. The presence of<br />

MSVBVM60.DLL on the stack (frames 15 and 17–21) indicates that this is a Visual Basic 6<br />

program because MSVBVM60.DLL is the Visual Basic 6 runtime DLL. The large offsets for<br />

the MSVBVM60 frames suggest that symbols are not available for that module and that the<br />

names shown are not the actual functions being called. Frame 14 shows a call into a function<br />

named Form1::cmdCreate_Click in the main executable (LuaBugs_VB6.exe). This frame also<br />

shows a source file path, indicating that we have full symbolic information for this third-party<br />

module. This function then calls CWshShell::RegWrite in Wshom.ocx (frame 13), indicating<br />

that this Visual Basic 6 program is using a <strong>Windows</strong> Script Host ActiveX to write to the registry.<br />

CWshShell::RegWrite calls an internal function in the same module (frame 12), which calls<br />

the documented RegCreateKeyExA <strong>Windows</strong> API in Kernel32.dll (frame 11). Execution passes<br />

through Kernel32 internal functions (frames 8–10) and then into the ZwCreateKey native API<br />

in Ntdll.dll (frame 7). So far, all of these functions have executed in user mode, as indicated by<br />

the U in the Frame column, but in frame 6 the program transitions to kernel mode, indicated<br />

by the K. The two-letter prefixes of the kernel functions (frames 0–6) identify the executive<br />

components to which they belong. For example, Cm refers to the Configuration Manager,<br />

which is responsible for the registry, and Ob refers to the Object Manager. It was during the<br />

processing of CmpCallCallBacks (frame 0) that this stack trace was captured. Note that the<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!