Microsoft KB Archive/117681

= Profiling Windows NT Services =

Article ID: 117681

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Source Profiler 1.0
 * Microsoft Source Profiler 1.2

-



This article was previously published under Q117681



The information in this article is included in the documentation starting with Visual C++ 5.0. Look there for future revisions.



SUMMARY
This article provides information about profiling Windows NT service processes. This information is not available in Microsoft Source Profiler documentation.



MORE INFORMATION
Use the service sample from the directory MSVCNT\SAMPLES\SERVICE, and follow these steps to get timing information for its service functions:  Set necessary environment variables using the System control panel applet. You will find system environment variables like ComSpec, windir, and Path. Add two new environment variables:

__ProfilePBI=

__ProfilePBO=

Note the exact spelling and two leading underscores. If these are not correctly set, you will get messages from PROFILE.DLL warning you that these settings cannot be found.

In this example, if your compiler is on your D drive, these variables would be:

d:\msvcnt\samples\service\simple.pbi d:\msvcnt\samples\service\simple.pbi

 Copy the profiler, DLL PROFILE.DLL, from the MSVCNT\BIN subdirectory to either the directory where the service .EXE resides or to one of the directories listed in the PATH environment variable. Build the sample, SIMPLE.EXE. Instruct the linker to create a .MAP file. Run PREP to create SIMPLE._XE, which has been modified for profiling:

prep /om /ft /sf _worker_thread simple.exe

This command also sets up the code to follow the call stack from the worker_thread routine. By default, the profiler profiles calls from the main thread, so servicing requests from a secondary thread without specifying the /sf option will produce incomplete results. In the sample, this second thread is created by calling CreateThread to service the requests. If the main thread was servicing the requests, then you wouldn't need to use the /sf option.</li> Copy SIMPLE._XE to SIMPLE.EXE. This overwrites the original executable file with the modified version that has the profile hooks added to the code.</li> Start the service by using the Control Panel Services applet and run the client application. Stop the service using the Control Panel. You can get the timing information by executing:

prep /m simple

plist simple

</li></ol>

Additional query words: 1.00 1.10

Keywords: KB117681

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.