diff --git a/reactos/dll/win32/pdh/CMakeLists.txt b/reactos/dll/win32/pdh/CMakeLists.txt index 9d456268d69..c33bfc17769 100644 --- a/reactos/dll/win32/pdh/CMakeLists.txt +++ b/reactos/dll/win32/pdh/CMakeLists.txt @@ -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) diff --git a/reactos/dll/win32/pdh/pdh_main.c b/reactos/dll/win32/pdh/pdh_main.c index 9843480cacf..65b40f2ed79 100644 --- a/reactos/dll/win32/pdh/pdh_main.c +++ b/reactos/dll/win32/pdh/pdh_main.c @@ -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 ); } /*********************************************************************** diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 9923bcb86cf..5a639da5e94 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -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