ReactOS  0.4.15-dev-309-g7c8d563
loadperf_main.c
Go to the documentation of this file.
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 
33 
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;
58  }
59  return ret;
60 }
61 
62 /*************************************************************
63  * InstallPerfDllA (loadperf.@)
64  */
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  */
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  */
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  */
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  */
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  */
158 {
159  FIXME("(%s, %d): stub\n", debugstr_w(cmdline), quiet);
160 
161  return ERROR_SUCCESS;
162 }
DWORD WINAPI UnloadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet)
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DWORD WINAPI UnloadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL quiet)
DWORD WINAPI LoadPerfCounterTextStringsA(LPCSTR cmdline, BOOL quiet)
#define CP_ACP
Definition: compat.h:99
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
TCHAR * cmdline
Definition: stretchblt.cpp:32
int32_t INT
Definition: typedefs.h:57
static IN DWORD IN LPVOID lpvReserved
uint32_t ULONG_PTR
Definition: typedefs.h:64
DWORD WINAPI InstallPerfDllW(LPCWSTR computer, LPCWSTR ini, ULONG_PTR flags)
Definition: loadperf_main.c:88
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
TConfig ini
Definition: tnconfig.cpp:45
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI LoadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL quiet)
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
static WCHAR * strdupAW(const char *str)
Definition: loadperf_main.c:50
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: loadperf_main.c:34
WINE_DEFAULT_DEBUG_CHANNEL(loadperf)
DWORD WINAPI InstallPerfDllA(LPCSTR computer, LPCSTR ini, ULONG_PTR flags)
Definition: loadperf_main.c:65
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13