1 /* 2 * Implementation of loadperf.dll 3 * 4 * Copyright 2009 Andrey Turkin 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 22 #include <stdarg.h> 23 24 #include "windef.h" 25 #include "winbase.h" 26 #include "winerror.h" 27 #include "winnls.h" 28 #include "wine/debug.h" 29 30 #include "loadperf.h" 31 32 WINE_DEFAULT_DEBUG_CHANNEL(loadperf); 33 34 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 35 { 36 TRACE("(0x%p, %d, %p)\n",hinstDLL,fdwReason,lpvReserved); 37 38 switch(fdwReason) 39 { 40 case DLL_WINE_PREATTACH: 41 return FALSE; /* prefer native version */ 42 case DLL_PROCESS_ATTACH: 43 DisableThreadLibraryCalls(hinstDLL); 44 break; 45 } 46 47 return TRUE; 48 } 49 50 static WCHAR *strdupAW(const char *str) 51 { 52 WCHAR *ret = NULL; 53 if (str) 54 { 55 INT len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); 56 if (!(ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) return NULL; 57 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); 58 } 59 return ret; 60 } 61 62 /************************************************************* 63 * InstallPerfDllA (loadperf.@) 64 */ 65 DWORD WINAPI InstallPerfDllA(LPCSTR computer, LPCSTR ini, ULONG_PTR flags) 66 { 67 DWORD ret; 68 LPWSTR computerW = NULL, iniW = NULL; 69 70 if (computer && !(computerW = strdupAW(computer))) return ERROR_OUTOFMEMORY; 71 if (ini && !(iniW = strdupAW(ini))) 72 { 73 HeapFree(GetProcessHeap(), 0, computerW); 74 return ERROR_OUTOFMEMORY; 75 } 76 77 ret = InstallPerfDllW(computerW, iniW, flags); 78 79 HeapFree(GetProcessHeap(), 0, computerW); 80 HeapFree(GetProcessHeap(), 0, iniW); 81 82 return ret; 83 } 84 85 /************************************************************* 86 * InstallPerfDllW (loadperf.@) 87 */ 88 DWORD WINAPI InstallPerfDllW(LPCWSTR computer, LPCWSTR ini, ULONG_PTR flags) 89 { 90 FIXME("(%s, %s, %lx)\n", debugstr_w(computer), debugstr_w(ini), flags); 91 return ERROR_SUCCESS; 92 } 93 94 /************************************************************* 95 * LoadPerfCounterTextStringsA (loadperf.@) 96 * 97 * NOTES 98 * See LoadPerfCounterTextStringsW 99 */ 100 DWORD WINAPI LoadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet) 101 { 102 DWORD ret; 103 LPWSTR cmdlineW = NULL; 104 105 if (cmdline && !(cmdlineW = strdupAW(cmdline))) return ERROR_OUTOFMEMORY; 106 107 ret = LoadPerfCounterTextStringsW(cmdlineW, quiet); 108 109 HeapFree(GetProcessHeap(), 0, cmdlineW); 110 111 return ret; 112 } 113 114 /************************************************************* 115 * LoadPerfCounterTextStringsW (loadperf.@) 116 * 117 * PARAMS 118 * cmdline [in] Last argument in command line - ini file to be used 119 * quiet [in] FALSE - the function may write to stdout 120 * 121 */ 122 DWORD WINAPI LoadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL quiet) 123 { 124 FIXME("(%s, %d): stub\n", debugstr_w(cmdline), quiet); 125 126 return ERROR_SUCCESS; 127 } 128 129 /************************************************************* 130 * UnloadPerfCounterTextStringsA (loadperf.@) 131 * 132 * NOTES 133 * See UnloadPerfCounterTextStringsW 134 */ 135 DWORD WINAPI UnloadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet) 136 { 137 DWORD ret; 138 LPWSTR cmdlineW = NULL; 139 140 if (cmdline && !(cmdlineW = strdupAW(cmdline))) return ERROR_OUTOFMEMORY; 141 142 ret = UnloadPerfCounterTextStringsW(cmdlineW, quiet); 143 144 HeapFree(GetProcessHeap(), 0, cmdlineW); 145 146 return ret; 147 } 148 149 /************************************************************* 150 * UnloadPerfCounterTextStringsW (loadperf.@) 151 * 152 * PARAMS 153 * cmdline [in] Last argument in command line - application counters to be removed 154 * quiet [in] FALSE - the function may write to stdout 155 * 156 */ 157 DWORD WINAPI UnloadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL quiet) 158 { 159 FIXME("(%s, %d): stub\n", debugstr_w(cmdline), quiet); 160 161 return ERROR_SUCCESS; 162 } 163