I have a C++ application (under Win32) for which I need to provide performance counter information. I'm using Perflib v2, so have created a manifest which is processed by CTRPP.
My provider then calls PerfAutoInitialize and PerfCreateInstance with no errors.
When I go to add the counter in Perfmon, my application crashes. Tracing through the disassembly shows the code in the perflib worker thread calling the internal function (pcwum.dll) PerfpAddOrRemoveCounter. This calls on to PerfpValidateCounter which returns an address in edi; this address is invalid and when caller dereferences it, the application crashes.
If I restart my provider, the counter is still visible in Perfmon and increments correctly.
Manifest follows
<instrumentationManifest xsi:schemaLocation="http://schemas.microsoft.com/win/2004/08/events eventman.xsd"
xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:trace="http://schemas.microsoft.com/win/2004/08/events/trace">
<instrumentation>
<counters xmlns="http://schemas.microsoft.com/win/2005/12/counters">
<provider callback = "custom"
applicationIdentity = "TPerfStatsCollector.exe"
providerName = "TPerfstatscollector"
providerType = "userMode"
providerGuid = "{33d68436-4cf9-4f58-9976-44b048b072f3}"
symbol = "symbolGUID">
<counterSet guid = "{381300a5-3be6-46d8-8615-12d8b259aae4}"
uri = "A.AxPServ开发者_Go百科er.Counters.Basic"
name = "Basic counters"
description = "These are the sample counters"
instances = "Single"
symbol = "setGUID">
<counter id = "1"
uri = "A.AxPServer.Counters.Basic.Session"
name = "Sessions"
description = "Number of sessions"
type = "perf_counter_rawcount"
detailLevel = "standard"
defaultScale = "1">
</counter>
</counterSet>
</provider>
</counters>
</instrumentation>
</instrumentationManifest>
My bad. This was a 64/32 bit issue and I realised that I was building a 32 bit provider to run on a 64 bit OS. All works fine when this was straightened out.
精彩评论