I'm trying to add performance counters and custom events to a piece of software, so that I can view these using Windows Performance Toolkit programs such as XPerf and GPUView. I am going to refrain, using all my powers of restraint, from launching into a cathartic rant regarding the state of the documentation for the software and the time I've now wasted trying to tease clues from the web. I'm going to describe how I got to where I am now, just in case this is of use to other lost souls.
So far, I've gathered that I have to write an Event manifest for my performance counters and events. You can do this by hand or by using a tool called 'ecmangen.exe'. The documentation for that program gives a nice step by step guide for event creating manifests but doesn't explain how to integrate these with your code.
The next step, as far as I can work out, is to use two cryptic command line applications 'MC.exe' and 'CTRPP.exe'. These seem to generate C or C# headers, source and resource files for adding event and counter instrumentation to your code, respectively. Next, you have to build your code (look at the samples in 'C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\winbase\Eventing') and then we come to where I'm currently stuck: the correct use of the next cryptic tool 'wevtutil.exe'
This tool needs two things: the binary (exe or DLL) that you've compiled with those resources in it and the manifest file you used to generate those resources. The trouble I'm having is that it's very picky about where the binary file is and I've been unable to determine the form of this pickiness. Incantations and goat sacrifices have yielded no results.
If I have a path defined in the 'resourceFileName' field of the 'provider' tag in the manifest file such as 'c:\MYDIR\TEd.exe' then it is fine. If, however, I put the same exe in a different folder (one that failed was C:\tw\TEd.exe), it complains.
The error message given is 'Warning: Publisher TEd-Event-Provider resources are not accessible.' but no more explanation as to why, or where it tried to look.
So, am I going about adding instrumentation in the wrong way, is there already a guide that explains all the gotchas and what is the nature of 'wevtutil.exe's strange selectivity towards directory names.
Thanks in advance,
Tim.
I've just had exactly the same message, and struggled for an hour to resolve it, before I had a brainwave and read the error msg ;-).
The solution to my problem was simply to add the ".rc" file to my project, and then re-build. Looking back it is fairly obvious, but it had me stumped for a while.
Hope this helps.
Edit - 4th Feb Ok, not too sure if I know what your problem is, but the following batch script is how I did it all. Good luck.
rem -------------------------------------------------------------------
rem Do all of this from the project directory
rem -------------------------------------------------------------------
rem Generate Header and Resource - remove the ReadOnly attrib to "help" it along
attrib -r MyModuleTracing.h
mc.exe -um MyModuleTracing.xml
rem This generates MyModuleTracing.h and MyModuleTracing.rc, add both to your project
rem -------------------------------------------------------------------
rem ** Now build the project **
rem -------------------------------------------------------------------
rem Register MyModule Tracing with the system
if exist MyModuleTracing.xml (
wevtutil um MyModuleTracing.xml
copy MyModuleTracing.xml Release
cd Release
copy MyModule.dll %SystemRoot%\System32
wevtutil im MyModuleTracing.xml
)
rem -------------------------------------------------------------------
rem Do a capture, and also export the results to an XML file.
xperf -start MyModuleSession -on [REPLACE_WITH_YOUR_GUID] -f MyModuleSession.etl
xperf -on base -f Kernel.etl
rem Run the app, wait until exit, and then stop the capture
start /wait MyModule.exe
xperf -stop
xperf -stop MyModuleSession
xperf -merge MyModuleSession.etl Kernel.etl MyModuleSessionMerged.etl
tracerpt MyModuleSessionMerged.etl -o MyModuleSessionMerged.xml -of XML
I had the same problem - as best I can tell, there's a directory length limit on wevtutil. When I installed the file from a directory with a shorter path, it worked.
In case anyone else comes across this, you can actually get things working from an arbitrary directory:
Add USER Read&Execute privs to a directory containing or above your project:
icacls
projectdir/grant BUILTIN\Users:(OI)(CI)(RX)
Then installing the manifest should work with no errors:
wevtutil im
yourmanifest.man/rf:
c:\full\path\to\yourprogram.exe/mf:
c:\full\path\to\yourprogram.exe
来源:https://stackoverflow.com/questions/4679445/problem-installing-wpt-manifest-using-wevtutil