Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
a83509c7
Commit
a83509c7
authored
Sep 29, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 01, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdh: Implement PdhCalculateCounterFromRawValue.
parent
0389ec60
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
37 deletions
+72
-37
pdh.spec
dlls/pdh/pdh.spec
+1
-1
pdh_main.c
dlls/pdh/pdh_main.c
+71
-36
No files found.
dlls/pdh/pdh.spec
View file @
a83509c7
...
...
@@ -11,7 +11,7 @@
@ stub PdhBrowseCountersHA
@ stub PdhBrowseCountersHW
@ stub PdhBrowseCountersW
@ st
ub PdhCalculateCounterFromRawValue
@ st
dcall PdhCalculateCounterFromRawValue(ptr long ptr ptr ptr)
@ stub PdhCloseLog
@ stdcall PdhCloseQuery(ptr)
@ stdcall PdhCollectQueryData(ptr)
...
...
dlls/pdh/pdh_main.c
View file @
a83509c7
...
...
@@ -96,6 +96,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
return
TRUE
;
}
union
value
{
LONG
longvalue
;
double
doublevalue
;
LONGLONG
largevalue
;
};
struct
counter
{
DWORD
magic
;
/* signature */
...
...
@@ -110,18 +117,8 @@ struct counter
LONGLONG
base
;
/* samples per second */
FILETIME
stamp
;
/* time stamp */
void
(
CALLBACK
*
collect
)(
struct
counter
*
);
/* collect callback */
union
{
LONG
longvalue
;
double
doublevalue
;
LONGLONG
largevalue
;
}
one
;
/* first value */
union
{
LONG
longvalue
;
double
doublevalue
;
LONGLONG
largevalue
;
}
two
;
/* second value */
union
value
one
;
/* first value */
union
value
two
;
/* second value */
};
#define PDH_MAGIC_COUNTER 0x50444831
/* 'PDH1' */
...
...
@@ -319,6 +316,64 @@ PDH_STATUS WINAPI PdhAddEnglishCounterW( PDH_HQUERY query, LPCWSTR path,
return
PdhAddCounterW
(
query
,
path
,
userdata
,
counter
);
}
/* caller must hold counter lock */
static
PDH_STATUS
format_value
(
struct
counter
*
counter
,
DWORD
format
,
union
value
*
raw1
,
union
value
*
raw2
,
PDH_FMT_COUNTERVALUE
*
value
)
{
LONG
factor
;
factor
=
counter
->
scale
?
counter
->
scale
:
counter
->
defaultscale
;
if
(
format
&
PDH_FMT_LONG
)
{
if
(
format
&
PDH_FMT_1000
)
value
->
u
.
longValue
=
raw2
->
longvalue
*
1000
;
else
value
->
u
.
longValue
=
raw2
->
longvalue
*
pow
(
10
,
factor
);
}
else
if
(
format
&
PDH_FMT_LARGE
)
{
if
(
format
&
PDH_FMT_1000
)
value
->
u
.
largeValue
=
raw2
->
largevalue
*
1000
;
else
value
->
u
.
largeValue
=
raw2
->
largevalue
*
pow
(
10
,
factor
);
}
else
if
(
format
&
PDH_FMT_DOUBLE
)
{
if
(
format
&
PDH_FMT_1000
)
value
->
u
.
doubleValue
=
raw2
->
doublevalue
*
1000
;
else
value
->
u
.
doubleValue
=
raw2
->
doublevalue
*
pow
(
10
,
factor
);
}
else
{
WARN
(
"unknown format %x
\n
"
,
format
);
return
PDH_INVALID_ARGUMENT
;
}
return
ERROR_SUCCESS
;
}
/***********************************************************************
* PdhCalculateCounterFromRawValue (PDH.@)
*/
PDH_STATUS
WINAPI
PdhCalculateCounterFromRawValue
(
PDH_HCOUNTER
handle
,
DWORD
format
,
PPDH_RAW_COUNTER
raw1
,
PPDH_RAW_COUNTER
raw2
,
PPDH_FMT_COUNTERVALUE
value
)
{
PDH_STATUS
ret
;
struct
counter
*
counter
=
handle
;
TRACE
(
"%p 0x%08x %p %p %p
\n
"
,
handle
,
format
,
raw1
,
raw2
,
value
);
if
(
!
value
)
return
PDH_INVALID_ARGUMENT
;
EnterCriticalSection
(
&
pdh_handle_cs
);
if
(
!
counter
||
counter
->
magic
!=
PDH_MAGIC_COUNTER
)
{
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
PDH_INVALID_HANDLE
;
}
ret
=
format_value
(
counter
,
format
,
(
union
value
*
)
&
raw1
->
SecondValue
,
(
union
value
*
)
&
raw2
->
SecondValue
,
value
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ret
;
}
/* caller must hold query lock */
static
void
shutdown_query_thread
(
struct
query
*
query
)
{
...
...
@@ -630,7 +685,7 @@ PDH_STATUS WINAPI PdhGetCounterTimeBase( PDH_HCOUNTER handle, LONGLONG *base )
PDH_STATUS
WINAPI
PdhGetFormattedCounterValue
(
PDH_HCOUNTER
handle
,
DWORD
format
,
LPDWORD
type
,
PPDH_FMT_COUNTERVALUE
value
)
{
LONG
factor
;
PDH_STATUS
ret
;
struct
counter
*
counter
=
handle
;
TRACE
(
"%p %x %p %p
\n
"
,
handle
,
format
,
type
,
value
);
...
...
@@ -648,34 +703,14 @@ PDH_STATUS WINAPI PdhGetFormattedCounterValue( PDH_HCOUNTER handle, DWORD format
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
PDH_INVALID_DATA
;
}
factor
=
counter
->
scale
?
counter
->
scale
:
counter
->
defaultscale
;
if
(
format
&
PDH_FMT_LONG
)
{
if
(
format
&
PDH_FMT_1000
)
value
->
u
.
longValue
=
counter
->
two
.
longvalue
*
1000
;
else
value
->
u
.
longValue
=
counter
->
two
.
longvalue
*
pow
(
10
,
factor
);
}
else
if
(
format
&
PDH_FMT_LARGE
)
if
(
!
(
ret
=
format_value
(
counter
,
format
,
&
counter
->
one
,
&
counter
->
two
,
value
)))
{
if
(
format
&
PDH_FMT_1000
)
value
->
u
.
largeValue
=
counter
->
two
.
largevalue
*
1000
;
else
value
->
u
.
largeValue
=
counter
->
two
.
largevalue
*
pow
(
10
,
factor
);
}
else
if
(
format
&
PDH_FMT_DOUBLE
)
{
if
(
format
&
PDH_FMT_1000
)
value
->
u
.
doubleValue
=
counter
->
two
.
doublevalue
*
1000
;
else
value
->
u
.
doubleValue
=
counter
->
two
.
doublevalue
*
pow
(
10
,
factor
);
}
else
{
WARN
(
"unknown format %x
\n
"
,
format
);
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
PDH_INVALID_ARGUMENT
;
}
value
->
CStatus
=
ERROR_SUCCESS
;
if
(
type
)
*
type
=
counter
->
type
;
}
LeaveCriticalSection
(
&
pdh_handle_cs
);
return
ERROR_SUCCESS
;
return
ret
;
}
/***********************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment