[PDH]
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 26 Sep 2013 14:04:52 +0000 (14:04 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 26 Sep 2013 14:04:52 +0000 (14:04 +0000)
* Sync with Wine 1.7.1.
CORE-7469

svn path=/trunk/; revision=60360

reactos/dll/win32/pdh/CMakeLists.txt
reactos/dll/win32/pdh/pdh_main.c
reactos/media/doc/README.WINE

index 9d45626..c33bfc1 100644 (file)
@@ -1,11 +1,9 @@
 
-add_definitions(-D__WINESRC__)
-
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
 
+add_definitions(-D__WINESRC__)
 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
-
 spec2def(pdh.dll pdh.spec ADD_IMPORTLIB)
 
 list(APPEND SOURCE
@@ -15,10 +13,6 @@ list(APPEND SOURCE
 
 add_library(pdh SHARED ${SOURCE})
 set_module_type(pdh win32dll)
-
 target_link_libraries(pdh wine)
-
 add_importlibs(pdh msvcrt kernel32 ntdll)
-
-
 add_cd_file(TARGET pdh DESTINATION reactos/system32 FOR all)
index 9843480..65b40f2 100644 (file)
@@ -87,12 +87,17 @@ static inline WCHAR *pdh_strdup_aw( const char *src )
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
     TRACE("(0x%p, %d, %p)\n",hinstDLL,fdwReason,lpvReserved);
-
-    if (fdwReason == DLL_WINE_PREATTACH) return FALSE;    /* prefer native version */
-
-    if (fdwReason == DLL_PROCESS_ATTACH)
+    switch (fdwReason)
     {
-        DisableThreadLibraryCalls( hinstDLL );
+    case DLL_WINE_PREATTACH:
+        return FALSE;    /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls(hinstDLL);
+        break;
+    case DLL_PROCESS_DETACH:
+        if (lpvReserved) break;
+        DeleteCriticalSection(&pdh_handle_cs);
+        break;
     }
 
     return TRUE;
@@ -218,14 +223,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 );
 }
 
 /***********************************************************************
index 9923bcb..5a639da 100644 (file)
@@ -150,7 +150,7 @@ reactos/dll/win32/oledlg          # Synced to Wine-1.7.1
 reactos/dll/win32/olepro32        # Synced to Wine-1.7.1
 reactos/dll/win32/olesvr32        # Synced to Wine-1.5.19
 reactos/dll/win32/olethk32        # Synced to Wine-1.5.19
-reactos/dll/win32/pdh             # Autosync
+reactos/dll/win32/pdh             # Synced to Wine-1.7.1
 reactos/dll/win32/pidgen          # Synced to Wine-1.5.19
 reactos/dll/win32/powrprof        # Forked at Wine-1.0rc5
 reactos/dll/win32/printui         # Synced to Wine-1.5.4