Hans Leidekker : loadperf: Add stub implementations for InstallPerfDllA/W.

Alexandre Julliard julliard at winehq.org
Fri Jan 23 10:06:58 CST 2009


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Jan 23 10:32:20 2009 +0100

loadperf: Add stub implementations for InstallPerfDllA/W.

---

 dlls/loadperf/loadperf.spec   |    4 +-
 dlls/loadperf/loadperf_main.c |   60 +++++++++++++++++++++++++++++++---------
 include/loadperf.h            |    4 +++
 3 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/dlls/loadperf/loadperf.spec b/dlls/loadperf/loadperf.spec
index b46fe29..06e7891 100644
--- a/dlls/loadperf/loadperf.spec
+++ b/dlls/loadperf/loadperf.spec
@@ -1,6 +1,6 @@
 @ stub BackupPerfRegistryToFileW
-@ stub InstallPerfDllA
-@ stub InstallPerfDllW
+@ stdcall InstallPerfDllA(str str ptr)
+@ stdcall InstallPerfDllW(wstr wstr ptr)
 @ stub LoadMofFromInstalledServiceA
 @ stub LoadMofFromInstalledServiceW
 @ stdcall LoadPerfCounterTextStringsA(str long)
diff --git a/dlls/loadperf/loadperf_main.c b/dlls/loadperf/loadperf_main.c
index 89a9c4f..54fe2d6 100644
--- a/dlls/loadperf/loadperf_main.c
+++ b/dlls/loadperf/loadperf_main.c
@@ -50,6 +50,50 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     return TRUE;
 }
 
+static WCHAR *strdupAW(const char *str)
+{
+    WCHAR *ret = NULL;
+    if (str)
+    {
+        INT len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+        if (!(ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) return NULL;
+        MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+    }
+    return ret;
+}
+
+/*************************************************************
+ *     InstallPerfDllA (loadperf.@)
+ */
+DWORD WINAPI InstallPerfDllA(LPCSTR computer, LPCSTR ini, ULONG_PTR flags)
+{
+    DWORD ret;
+    LPWSTR computerW = NULL, iniW = NULL;
+
+    if (computer && !(computerW = strdupAW(computer))) return ERROR_OUTOFMEMORY;
+    if (ini && !(iniW = strdupAW(ini)))
+    {
+        HeapFree(GetProcessHeap(), 0, computerW);
+        return ERROR_OUTOFMEMORY;
+    }
+
+    ret = InstallPerfDllW(computerW, iniW, flags);
+
+    HeapFree(GetProcessHeap(), 0, computerW);
+    HeapFree(GetProcessHeap(), 0, iniW);
+
+    return ret;
+}
+
+/*************************************************************
+ *     InstallPerfDllW (loadperf.@)
+ */
+DWORD WINAPI InstallPerfDllW(LPCWSTR computer, LPCWSTR ini, ULONG_PTR flags)
+{
+    FIXME("(%s, %s, %lx)\n", debugstr_w(computer), debugstr_w(ini), flags);
+    return ERROR_SUCCESS;
+}
+
 /*************************************************************
  *     LoadPerfCounterTextStringsA (loadperf.@)
  *
@@ -61,13 +105,7 @@ DWORD WINAPI LoadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet)
     DWORD ret;
     LPWSTR cmdlineW = NULL;
 
-    if (cmdline)
-    {
-        INT len = MultiByteToWideChar(CP_ACP, 0, cmdline, -1, NULL, 0);
-        cmdlineW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
-        if (!cmdlineW) return ERROR_NOT_ENOUGH_MEMORY;
-        MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlineW, len);
-    }
+    if (cmdline && !(cmdlineW = strdupAW(cmdline))) return ERROR_OUTOFMEMORY;
 
     ret = LoadPerfCounterTextStringsW(cmdlineW, quiet);
 
@@ -102,13 +140,7 @@ DWORD WINAPI UnloadPerfCounterTextStringsA(LPCSTR cmdline, BOOL verbose)
     DWORD ret;
     LPWSTR cmdlineW = NULL;
 
-    if (cmdline)
-    {
-        INT len = MultiByteToWideChar(CP_ACP, 0, cmdline, -1, NULL, 0);
-        cmdlineW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
-        if (!cmdlineW) return ERROR_NOT_ENOUGH_MEMORY;
-        MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlineW, len);
-    }
+    if (cmdline && !(cmdlineW = strdupAW(cmdline))) return ERROR_OUTOFMEMORY;
 
     ret = UnloadPerfCounterTextStringsW(cmdlineW, verbose);
 
diff --git a/include/loadperf.h b/include/loadperf.h
index 45679a2..d11186a 100644
--- a/include/loadperf.h
+++ b/include/loadperf.h
@@ -23,6 +23,10 @@
 extern "C" {
 #endif
 
+DWORD WINAPI InstallPerfDllA(LPCSTR, LPCSTR, ULONG_PTR);
+DWORD WINAPI InstallPerfDllW(LPCWSTR, LPCWSTR, ULONG_PTR);
+#define      InstallPerfDll WINELIB_NAME_AW(InstallPerfDll);
+
 DWORD WINAPI LoadPerfCounterTextStringsA(LPCSTR, BOOL);
 DWORD WINAPI LoadPerfCounterTextStringsW(LPCWSTR, BOOL);
 #define      LoadPerfCounterTextStrings WINELIB_NAME_AW(LoadPerfCounterTextStrings)




More information about the wine-cvs mailing list