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
0d516c53
Commit
0d516c53
authored
Jul 09, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Jul 10, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdh: Implement and test PdhSetCounterScaleFactor and PdhGetFormattedCounterValue.
parent
5dfc2ead
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
2 deletions
+148
-2
pdh.spec
dlls/pdh/pdh.spec
+2
-2
pdh_main.c
dlls/pdh/pdh_main.c
+60
-0
pdh.c
dlls/pdh/tests/pdh.c
+86
-0
No files found.
dlls/pdh/pdh.spec
View file @
0d516c53
...
...
@@ -57,7 +57,7 @@
@ stub PdhGetDllVersion
@ stub PdhGetFormattedCounterArrayA
@ stub PdhGetFormattedCounterArrayW
@ st
ub PdhGetFormattedCounterValue
@ st
dcall PdhGetFormattedCounterValue(ptr long ptr ptr)
@ stub PdhGetLogFileSize
@ stub PdhGetLogFileTypeA
@ stub PdhGetLogFileTypeW
...
...
@@ -123,7 +123,7 @@
@ stdcall PdhRemoveCounter(ptr)
@ stub PdhSelectDataSourceA
@ stub PdhSelectDataSourceW
@ st
ub PdhSetCounterScaleFactor
@ st
dcall PdhSetCounterScaleFactor(ptr long)
@ stub PdhSetDefaultRealTimeDataSource
@ stub PdhSetLogSetRunID
@ stub PdhSetQueryTimeRange
...
...
dlls/pdh/pdh_main.c
View file @
0d516c53
...
...
@@ -19,6 +19,7 @@
*/
#include <stdarg.h>
#include <math.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
...
...
@@ -283,6 +284,49 @@ PDH_STATUS WINAPI PdhCollectQueryData( PDH_HQUERY handle )
}
/***********************************************************************
* PdhGetFormattedCounterValue (PDH.@)
*/
PDH_STATUS
WINAPI
PdhGetFormattedCounterValue
(
PDH_HCOUNTER
handle
,
DWORD
format
,
LPDWORD
type
,
PPDH_FMT_COUNTERVALUE
value
)
{
LONG
factor
;
struct
counter
*
counter
=
handle
;
TRACE
(
"%p %x %p %p
\n
"
,
handle
,
format
,
type
,
value
);
if
(
!
value
)
return
PDH_INVALID_ARGUMENT
;
if
(
!
counter
)
return
PDH_INVALID_HANDLE
;
if
(
counter
->
status
)
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
(
format
&
PDH_FMT_1000
)
value
->
u
.
longValue
=
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
.
longValue
=
counter
->
two
.
doublevalue
*
1000
;
else
value
->
u
.
doubleValue
=
counter
->
two
.
doublevalue
*
pow
(
10
,
factor
);
}
else
{
WARN
(
"unknown format %x
\n
"
,
format
);
return
PDH_INVALID_ARGUMENT
;
}
value
->
CStatus
=
ERROR_SUCCESS
;
if
(
type
)
*
type
=
counter
->
type
;
return
ERROR_SUCCESS
;
}
/***********************************************************************
* PdhOpenQueryA (PDH.@)
*/
PDH_STATUS
WINAPI
PdhOpenQueryA
(
LPCSTR
source
,
DWORD_PTR
userdata
,
PDH_HQUERY
*
query
)
...
...
@@ -344,3 +388,19 @@ PDH_STATUS WINAPI PdhRemoveCounter( PDH_HCOUNTER handle )
return
ERROR_SUCCESS
;
}
/***********************************************************************
* PdhSetCounterScaleFactor (PDH.@)
*/
PDH_STATUS
WINAPI
PdhSetCounterScaleFactor
(
PDH_HCOUNTER
handle
,
LONG
factor
)
{
struct
counter
*
counter
=
handle
;
TRACE
(
"%p
\n
"
,
handle
);
if
(
!
counter
)
return
PDH_INVALID_HANDLE
;
if
(
factor
<
PDH_MIN_SCALE
||
factor
>
PDH_MAX_SCALE
)
return
PDH_INVALID_ARGUMENT
;
counter
->
scale
=
factor
;
return
ERROR_SUCCESS
;
}
dlls/pdh/tests/pdh.c
View file @
0d516c53
...
...
@@ -95,8 +95,94 @@ static void test_add_remove_counter( void )
ok
(
ret
==
ERROR_SUCCESS
,
"PdhCloseQuery failed 0x%08x
\n
"
,
ret
);
}
static
void
test_PdhGetFormattedCounterValue
(
void
)
{
PDH_STATUS
ret
;
PDH_HQUERY
query
;
PDH_HCOUNTER
counter
;
PDH_FMT_COUNTERVALUE
value
;
ret
=
PdhOpenQueryA
(
NULL
,
0
,
&
query
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhOpenQueryA failed 0x%08x
\n
"
,
ret
);
ret
=
PdhAddCounterA
(
query
,
"
\\
System
\\
System Up Time"
,
0
,
&
counter
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhAddCounterA failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
NULL
,
PDH_FMT_LARGE
,
NULL
,
NULL
);
ok
(
ret
==
PDH_INVALID_ARGUMENT
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
NULL
,
PDH_FMT_LARGE
,
NULL
,
&
value
);
ok
(
ret
==
PDH_INVALID_HANDLE
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
,
NULL
,
NULL
);
ok
(
ret
==
PDH_INVALID_ARGUMENT
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
,
NULL
,
&
value
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhCollectQueryData
(
query
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhCollectQueryData failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
,
NULL
,
&
value
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
|
PDH_FMT_NOSCALE
,
NULL
,
&
value
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
|
PDH_FMT_NOCAP100
,
NULL
,
&
value
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
|
PDH_FMT_1000
,
NULL
,
&
value
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
counter
,
2
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhGetFormattedCounterValue
(
counter
,
PDH_FMT_LARGE
,
NULL
,
&
value
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhGetFormattedCounterValue failed 0x%08x
\n
"
,
ret
);
ret
=
PdhCloseQuery
(
query
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhCloseQuery failed 0x%08x
\n
"
,
ret
);
}
static
void
test_PdhSetCounterScaleFactor
(
void
)
{
PDH_STATUS
ret
;
PDH_HQUERY
query
;
PDH_HCOUNTER
counter
;
ret
=
PdhOpenQueryA
(
NULL
,
0
,
&
query
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhOpenQueryA failed 0x%08x
\n
"
,
ret
);
ret
=
PdhAddCounterA
(
query
,
"
\\
System
\\
System Up Time"
,
0
,
&
counter
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhAddCounterA failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
NULL
,
8
);
ok
(
ret
==
PDH_INVALID_HANDLE
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
NULL
,
1
);
ok
(
ret
==
PDH_INVALID_HANDLE
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
counter
,
8
);
ok
(
ret
==
PDH_INVALID_ARGUMENT
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
counter
,
-
8
);
ok
(
ret
==
PDH_INVALID_ARGUMENT
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
counter
,
7
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhSetCounterScaleFactor
(
counter
,
0
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhSetCounterScaleFactor failed 0x%08x
\n
"
,
ret
);
ret
=
PdhCloseQuery
(
query
);
ok
(
ret
==
ERROR_SUCCESS
,
"PdhCloseQuery failed 0x%08x
\n
"
,
ret
);
}
START_TEST
(
pdh
)
{
test_open_close_query
();
test_add_remove_counter
();
test_PdhGetFormattedCounterValue
();
test_PdhSetCounterScaleFactor
();
}
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