To illustrate how Log Monitor can be
used to delve into application problems, in this section uses an
example to illustrate. Here cmd.exe is packaged with Thinstall and
run with logging being recorded.
To simulate an application behaving incorrectly, a simple invalid
command is issued. In this case, we have requested cmd.exe to
execute the command "foobar," and cmd.exe prints out the message
"'foobar' is not recognized as an internal or external command." By
viewing the resulting trace file we can dig into what cmd.exe is
doing in much greater detail and learn how it operates. All
applications will manifest misbehavior in different ways, so there
is no one set way to track down issues.
The first place to check in a log file is the section near the end
labeled "---- Potential Errors Detected ---".
In this section, you can find all the API functions in which the
GetLastError code was modified. The paths highlighted in bold
indicate locations that cmd.exe was looking for foobar, and paths
in red indicate locations in the virtual file system that were
probed for these file system probes. ---- Potential Errors Detected ---
*** Unable to determine if any services need to be auto-started, error 2
001550 *** FindFirstFileW 'C:\test\cmd_test\bin\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\test\cmd_test\bin\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW ->HANDLE=ffffffffh .. *** GetLastError() returns 2 [203]: The system cannot find the file specified.
*** FindFirstFileW 'C:\test\cmd_test\bin\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %drive_C%\test\cmd_test\bin\foobar][fs entry not found %drive_C%\test\cmd_test\bin]
*** FindFirstFileW 'C:\WINDOWS\system32\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\WINDOWS\system32\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\WINDOWS\system32\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %SystemSystem%\foobar]
*** FindFirstFileW 'C:\WINDOWS\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\WINDOWS\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\WINDOWS\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %SystemRoot%\foobar]
*** FindFirstFileW 'C:\WINDOWS\System32\Wbem\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\WINDOWS\System32\Wbem\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\WINDOWS\System32\Wbem\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %SystemSystem%\Wbem\foobar]
*** FindFirstFileW 'c:\program files\subversion\bin\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe c:\program files\subversion\bin\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'c:\program files\subversion\bin\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %ProgramFilesDir%\subversion\bin\foobar][fs entry not found %ProgramFilesDir%\subversion\bin]
*** FindFirstFileW 'c:\Program Files\Microsoft SQL Server\90\Tools\binn\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe c:\Program Files\Microsoft SQL Server\90\Tools\binn\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'c:\Program Files\Microsoft SQL Server\90\Tools\binn\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %ProgramFilesDir%\Microsoft SQL Server\90\Tools\binn\foobar][fs entry not found %ProgramFilesDir%\Microsoft SQL Server\90\Tools\binn]
*** FindFirstFileW 'c:\bin\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe c:\bin\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'c:\bin\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %drive_c%\bin\foobar][fs entry not found %drive_c%\bin]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\Common\Tools\WinNT\foobar][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\Common\Tools\WinNT]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\Common\MSDev98\Bin\foobar][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\Common\MSDev98\Bin]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\Common\Tools\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\Program Files\Microsoft Visual Studio\Common\Tools\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\Common\Tools\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\Common\Tools\foobar][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\Common\Tools]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\VC98\bin\foobar.*' -> INVALID_HANDLE_VALUE *** failed [system probe C:\Program Files\Microsoft Visual Studio\VC98\bin\foobar.* -> ffffffffh][no virtual or system matches]
*** FindFirstFileW 'C:\Program Files\Microsoft Visual Studio\VC98\bin\foobar' -> INVALID_HANDLE_VALUE *** failed [FS missing in view 0][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\VC98\bin\foobar][fs entry not found %ProgramFilesDir%\Microsoft Visual Studio\VC98\bin] As you
can see, the "potential errors" did a good job of highlighting
possible areas where the application is failing.
Let's
suppose we want to find out why cmd.exe is probing the location
c:\test\cmd_test\bin
We can search the log for this line of text using the log entry number and find out what is occuring
before this call. In the bold excerpts below you can two
possible places where cmd.exe obtained the path c:\test\cmd_test.
The first is by calling GetCurrentDirectoryW, and the second is
from it calling GetFullPathNameW with "." as the path specified. In
both cases, this returns the path for the current working directory
- so now we know exactly how cmd.exe is obtaining this path. You
can even see in the log file how cmd.exe creates the
"c:\test\cmd_test\bin>" prompt - it does this by querying the
environment variable "PROMPT" which returns "$P$G" and then uses
the API function WriteConsoleW to print the prompt to the screen
after internally expanding "$P$G" to "c:\test\cmd_test\bin>"
000824 0a88 cmd.exe :4ad0697a<-ADVAPI32.dll:77dd038f
FormatMessageW ->DWORD=29h (OUT LPWSTR
lpBuffer=*4AD38BA0h->L"(C) Copyright 1985-2001 Microsoft
Corp.\0Dh\0Ah")
000825 0a88 cmd.exe :4ad069d1->ADVAPI32.dll:77dd038f
FormatMessageW (IN DWORD dwFlags=1800h, IN LPCVOID lpSource=*0h, IN
DWORD dwMessageId=2334h, IN DWORD dwLanguageId=0h, IN DWORD
nSize=2000h, IN *Arguments=*13DD40h->...)
000826 0a88 FormatMessageW FORMAT_MESSAGE_FROM_HMODULE
FORMAT_MESSAGE_FROM_SYSTEM line_width=unlimited lpSource=0x0,
dwMessageId=0x2334, dwLanguageId=0x0
-> 0x29 ((C) Copyright 1985-2001 Microsoft Corp.