Hans Leidekker : pdh: Accept the local machine name in counter paths.

Alexandre Julliard julliard at winehq.org
Fri Dec 21 11:05:21 CST 2012


Module: wine
Branch: master
Commit: 4933dc78c6aeef024c6f240945968d05a51d4670
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4933dc78c6aeef024c6f240945968d05a51d4670

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Dec 21 13:56:23 2012 +0100

pdh: Accept the local machine name in counter paths.

---

 dlls/pdh/pdh_main.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/dlls/pdh/pdh_main.c b/dlls/pdh/pdh_main.c
index 69f0d71..f1a34e7 100644
--- a/dlls/pdh/pdh_main.c
+++ b/dlls/pdh/pdh_main.c
@@ -220,14 +220,27 @@ static const struct source counter_sources[] =
     { 674,  path_uptime,            collect_uptime,             TYPE_UPTIME,            -3,     1000 }
 };
 
+static BOOL is_local_machine( const WCHAR *name, DWORD len )
+{
+    WCHAR buf[MAX_COMPUTERNAME_LENGTH + 1];
+    DWORD buflen = sizeof(buf) / sizeof(buf[0]);
+
+    if (!GetComputerNameW( buf, &buflen )) return FALSE;
+    return len == buflen && !memicmpW( name, buf, buflen );
+}
+
 static BOOL pdh_match_path( LPCWSTR fullpath, LPCWSTR path )
 {
     const WCHAR *p;
 
-    if (strchrW( path, '\\')) p = fullpath;
+    if (path[0] == '\\' && path[1] == '\\' && (p = strchrW( path + 2, '\\' )) &&
+        is_local_machine( path + 2, p - path - 2 ))
+    {
+        path += p - path;
+    }
+    if (strchrW( path, '\\' )) p = fullpath;
     else p = strrchrW( fullpath, '\\' ) + 1;
-    if (strcmpW( p, path )) return FALSE;
-    return TRUE;
+    return !strcmpW( p, path );
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list