Sign in to follow this  
Followers 0
Hewijnabob

DLL Calling, Structs, Performance Data Helper (PDH), Performance Data

5 posts in this topic

I am having some trouble gathering performance data using the PDH.dll. I have read many many posts from Acend4nt (this is mostly borrowed from his work) and I have checked out Monoceres DLL PDF. I have also read the MSDN information for how to use it, but I am a little lost. I am trying to get performance sample values via the "PdhGetFormattedCounterValue" call. I don't seem to be getting them either via the direct return, or in the struct (which is where I think they should be coming from.) I partially built the struct to match the definition, but I am not sure if I need to do that or not. I also don't know how to handle the union portion of the struct. Please take a look at the code and point me in the right direction if you can. I embedded links to MSDN for the functions.

Original PDH.au3

Share this post


Link to post
Share on other sites

I decided to upload the current Work-In-Progress version of my PDH Performance Counters project. See the link in my signature.. or heck:

http://www.autoitscript.com/forum/index.php?showtopic=90736

Share this post


Link to post
Share on other sites

Your welcome :)

I hate Unions, especially ones containing structs withing structs within structs etc.. drives me crazy. And now with x64, everything needs to be rechecked and recalculated, and padding needs to be reconsidered.. grr..

In this particular structure (PDH_COUNTER_INFO) which you just gotta love, I've recalculated the info for x64 mode. Instead of 'PDH_COUNTER_PATH_ELEMENTS' being the largest element of the union (in 32-bit mode), in 64-bit mode its now 'PDH_DATA_ITEM_PATH_ELEMENTS' (or the embedded 'struct' definition in the union, which contains the same datatypes).

I have to check for x64 mode now and adjust the Structure string appropriately. And now I'm finding more x64 issues to sort out. Fun!:idea:

Share this post


Link to post
Share on other sites

I am having some trouble gathering performance data using the PDH.dll. I have read many many posts from Acend4nt (this is mostly borrowed from his work) and I have checked out Monoceres DLL PDF. I have also read the MSDN information for how to use it, but I am a little lost. I am trying to get performance sample values via the "PdhGetFormattedCounterValue" call. I don't seem to be getting them either via the direct return, or in the struct (which is where I think they should be coming from.) I partially built the struct to match the definition, but I am not sure if I need to do that or not. I also don't know how to handle the union portion of the struct. Please take a look at the code and point me in the right direction if you can. I embedded links to MSDN for the functions.

typedef struct _PDH_FMT_COUNTERVALUE {
  DWORD CStatus;
  union {
    LONG longValue;
    double doubleValue;
    LONGLONG largeValue;
    LPCSTR AnsiStringValue;
    LPCWSTR WideStringValue;
  } ;
} PDH_FMT_COUNTERVALUE, *PPDH_FMT_COUNTERVALUE;

C ++ SizeOf(PDH_FMT_COUNTERVALUE) = 16 BYTE

DWORD = 4 BYTE

union = 16 - 4 = 12

$Tag_PDH_FMT_COUNTERVALUE = "DWORD CStatus;BYTE union[12]"

$PDH_FMT_COUNTERVALUE = DllStructCreate($Tag_PDH_FMT_COUNTERVALUE)

$PPDH_FMT_COUNTERVALUE = DllStructGetPtr($PDH_FMT_COUNTERVALUE)

$CStatus = DllStructGetData($PDH_FMT_COUNTERVALUE,"CStatus")

$union = DllStructCreate("BYTE union[12]",DllStructGetPtr($PDH_FMT_COUNTERVALUE,2))

$union Data To Autoit Operators Compared

Operators Compared in Different Languages

http://msdn.microsoft.com/en-us/library/2hxce09y%28VS.71%29.aspx

; C ++ SizeOf(PDH_FMT_COUNTERVALUE) = 16 BYTE
;DWORD = 4 BYTE
; union = 16 - 4 = 12
$Tag_PDH_FMT_COUNTERVALUE = "DWORD CStatus;BYTE union[12]"
$PDH_FMT_COUNTERVALUE = DllStructCreate($Tag_PDH_FMT_COUNTERVALUE)
$PPDH_FMT_COUNTERVALUE = DllStructGetPtr($PDH_FMT_COUNTERVALUE)
$CStatus = DllStructGetData($PDH_FMT_COUNTERVALUE,"CStatus")
$union = DllStructCreate("BYTE union[12]",DllStructGetPtr($PDH_FMT_COUNTERVALUE,2))
;$union Data To autoit Operators Compared

;Operators Compared in Different Languages
;http://msdn.microsoft.com/en-us/library/2hxce09y%28VS.71%29.aspx

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0