xref: /reactos/dll/win32/loadperf/loadperf_main.c (revision 23373acb)
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 #include "config.h"
22 
23 #include <stdarg.h>
24 
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winnls.h"
29 #include "wine/debug.h"
30 
31 #include "loadperf.h"
32 
33 WINE_DEFAULT_DEBUG_CHANNEL(loadperf);
34 
35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
36 {
37     TRACE("(0x%p, %d, %p)\n",hinstDLL,fdwReason,lpvReserved);
38 
39     switch(fdwReason)
40     {
41     case DLL_WINE_PREATTACH:
42         return FALSE; /* prefer native version */
43     case DLL_PROCESS_ATTACH:
44         DisableThreadLibraryCalls(hinstDLL);
45         break;
46     }
47 
48     return TRUE;
49 }
50 
51 static WCHAR *strdupAW(const char *str)
52 {
53     WCHAR *ret = NULL;
54     if (str)
55     {
56         INT len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
57         if (!(ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) return NULL;
58         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
59     }
60     return ret;
61 }
62 
63 /*************************************************************
64  *     InstallPerfDllA (loadperf.@)
65  */
66 DWORD WINAPI InstallPerfDllA(LPCSTR computer, LPCSTR ini, ULONG_PTR flags)
67 {
68     DWORD ret;
69     LPWSTR computerW = NULL, iniW = NULL;
70 
71     if (computer && !(computerW = strdupAW(computer))) return ERROR_OUTOFMEMORY;
72     if (ini && !(iniW = strdupAW(ini)))
73     {
74         HeapFree(GetProcessHeap(), 0, computerW);
75         return ERROR_OUTOFMEMORY;
76     }
77 
78     ret = InstallPerfDllW(computerW, iniW, flags);
79 
80     HeapFree(GetProcessHeap(), 0, computerW);
81     HeapFree(GetProcessHeap(), 0, iniW);
82 
83     return ret;
84 }
85 
86 /*************************************************************
87  *     InstallPerfDllW (loadperf.@)
88  */
89 DWORD WINAPI InstallPerfDllW(LPCWSTR computer, LPCWSTR ini, ULONG_PTR flags)
90 {
91     FIXME("(%s, %s, %lx)\n", debugstr_w(computer), debugstr_w(ini), flags);
92     return ERROR_SUCCESS;
93 }
94 
95 /*************************************************************
96  *     LoadPerfCounterTextStringsA (loadperf.@)
97  *
98  * NOTES
99  *   See LoadPerfCounterTextStringsW
100  */
101 DWORD WINAPI LoadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet)
102 {
103     DWORD ret;
104     LPWSTR cmdlineW = NULL;
105 
106     if (cmdline && !(cmdlineW = strdupAW(cmdline))) return ERROR_OUTOFMEMORY;
107 
108     ret = LoadPerfCounterTextStringsW(cmdlineW, quiet);
109 
110     HeapFree(GetProcessHeap(), 0, cmdlineW);
111 
112     return ret;
113 }
114 
115 /*************************************************************
116  *     LoadPerfCounterTextStringsW (loadperf.@)
117  *
118  * PARAMS
119  *   cmdline [in] Last argument in command line - ini file to be used
120  *   quiet   [in] FALSE - the function may write to stdout
121  *
122  */
123 DWORD WINAPI LoadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL quiet)
124 {
125     FIXME("(%s, %d): stub\n", debugstr_w(cmdline), quiet);
126 
127     return ERROR_SUCCESS;
128 }
129 
130 /*************************************************************
131  *     UnloadPerfCounterTextStringsA (loadperf.@)
132  *
133  * NOTES
134  *   See UnloadPerfCounterTextStringsW
135  */
136 DWORD WINAPI UnloadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet)
137 {
138     DWORD ret;
139     LPWSTR cmdlineW = NULL;
140 
141     if (cmdline && !(cmdlineW = strdupAW(cmdline))) return ERROR_OUTOFMEMORY;
142 
143     ret = UnloadPerfCounterTextStringsW(cmdlineW, quiet);
144 
145     HeapFree(GetProcessHeap(), 0, cmdlineW);
146 
147     return ret;
148 }
149 
150 /*************************************************************
151  *     UnloadPerfCounterTextStringsW (loadperf.@)
152  *
153  * PARAMS
154  *   cmdline [in] Last argument in command line - application counters to be removed
155  *   quiet   [in] FALSE - the function may write to stdout
156  *
157  */
158 DWORD WINAPI UnloadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL quiet)
159 {
160     FIXME("(%s, %d): stub\n", debugstr_w(cmdline), quiet);
161 
162     return ERROR_SUCCESS;
163 }
164