mshtml: Added IHTMLMetaElement stub implementation.
[wine/multimedia.git] / dlls / wer / main.c
blobae9ab26d0e88279d80ef6a61ea7fac47e2496b3d
1 /*
2 * Copyright 2010 Louis Lenders
3 * Copyright 2010 Detlef Riekenberg
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "werapi.h"
28 #include "wine/list.h"
29 #include "wine/unicode.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wer);
34 typedef struct {
35 struct list entry;
36 WER_REPORT_INFORMATION info;
37 WER_REPORT_TYPE reporttype;
38 WCHAR eventtype[1];
39 } report_t;
42 static CRITICAL_SECTION report_table_cs;
43 static CRITICAL_SECTION_DEBUG report_table_cs_debug =
45 0, 0, &report_table_cs,
46 { &report_table_cs_debug.ProcessLocksList, &report_table_cs_debug.ProcessLocksList },
47 0, 0, { (DWORD_PTR)(__FILE__ ": report_table_cs") }
49 static CRITICAL_SECTION report_table_cs = { &report_table_cs_debug, -1, 0, 0, 0, 0 };
51 static struct list report_table = LIST_INIT(report_table);
53 static WCHAR regpath_exclude[] = {'S','o','f','t','w','a','r','e','\\',
54 'M','i','c','r','o','s','o','f','t','\\',
55 'W','i','n','d','o','w','s',' ','E','r','r','o','r',' ','R','e','p','o','r','t','i','n','g','\\',
56 'E','x','c','l','u','d','e','d','A','p','p','l','i','c','a','t','i','o','n','s',0};
58 /***********************************************************************
59 * Memory allocation helper
62 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
64 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
67 static inline BOOL heap_free(void *mem)
69 return HeapFree(GetProcessHeap(), 0, mem);
72 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
74 TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
76 switch (fdwReason)
78 case DLL_WINE_PREATTACH:
79 return FALSE; /* prefer native version */
80 case DLL_PROCESS_ATTACH:
81 DisableThreadLibraryCalls(hinstDLL);
82 break;
83 case DLL_PROCESS_DETACH:
84 break;
87 return TRUE;
90 /***********************************************************************
91 * WerAddExcludedApplication (wer.@)
93 * Add an application to the user specific or the system wide exclusion list
95 * PARAMS
96 * exeName [i] The application name
97 * allUsers [i] for all users (TRUE) or for the current user (FALSE)
99 * RETURNS
100 * Success: S_OK
101 * Failure: A HRESULT error code
104 HRESULT WINAPI WerAddExcludedApplication(PCWSTR exeName, BOOL allUsers)
106 HKEY hkey;
107 DWORD value = 1;
108 LPWSTR bs;
110 TRACE("(%s, %d)\n",debugstr_w(exeName), allUsers);
111 if (!exeName || !exeName[0])
112 return E_INVALIDARG;
114 bs = strrchrW(exeName, '\\');
115 if (bs) {
116 bs++; /* skip the backslash */
117 if (!bs[0]) {
118 return E_INVALIDARG;
120 } else
121 bs = (LPWSTR) exeName;
123 if (!RegCreateKeyW(allUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, regpath_exclude, &hkey)) {
124 RegSetValueExW(hkey, bs, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
125 RegCloseKey(hkey);
126 return S_OK;
128 return E_ACCESSDENIED;
131 /***********************************************************************
132 * WerRemoveExcludedApplication (wer.@)
134 * remove an application from the exclusion list
136 * PARAMS
137 * exeName [i] The application name
138 * allUsers [i] for all users (TRUE) or for the current user (FALSE)
140 * RETURNS
141 * Success: S_OK
142 * Failure: A HRESULT error code
145 HRESULT WINAPI WerRemoveExcludedApplication(PCWSTR exeName, BOOL allUsers)
147 HKEY hkey;
148 LPWSTR bs;
149 LONG lres;
151 TRACE("(%s, %d)\n",debugstr_w(exeName), allUsers);
152 if (!exeName || !exeName[0])
153 return E_INVALIDARG;
155 bs = strrchrW(exeName, '\\');
156 if (bs) {
157 bs++; /* skip the backslash */
158 if (!bs[0]) {
159 return E_INVALIDARG;
161 } else
162 bs = (LPWSTR) exeName;
164 if (!RegCreateKeyW(allUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, regpath_exclude, &hkey)) {
165 lres = RegDeleteValueW(hkey, bs);
166 RegCloseKey(hkey);
167 return lres ? __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND) : S_OK;
169 return E_ACCESSDENIED;
172 /***********************************************************************
173 * WerReportAddDump (wer.@)
175 * Add a dump of dumpType to hReportHandle.
177 * PARAMS
178 * hReportHandle [i] error reporting handle to add the dump
179 * hProcess [i] handle to the regarding process
180 * hThread [o] handle to the regarding thread
181 * dumpType [i] type of the dump
182 * pExceptionParam [o] pointer to a WER_EXCEPTION_INFORMATION
183 * pDumpCustomOptions [o] pointer to a WER_DUMP_CUSTOM_OPTIONS
184 * dwFlags [i] flag to control the heap dump
186 * RETURNS
187 * Success: S_OK
188 * Failure: A HRESULT error code
191 HRESULT WINAPI WerReportAddDump(HREPORT hReportHandle, HANDLE hProcess, HANDLE hThread,
192 WER_DUMP_TYPE dumpType, PWER_EXCEPTION_INFORMATION pExceptionParam,
193 PWER_DUMP_CUSTOM_OPTIONS pDumpCustomOptions, DWORD dwFlags)
195 FIXME("(%p, %p, %p, %d, %p, %p, %u) :stub\n", hReportHandle, hProcess, hThread, dumpType,
196 pExceptionParam, pDumpCustomOptions, dwFlags);
198 return E_NOTIMPL;
201 /***********************************************************************
202 * WerReportCloseHandle (wer.@)
204 * Close an error reporting handle and free associated resources
206 * PARAMS
207 * hreport [i] error reporting handle to close
209 * RETURNS
210 * Success: S_OK
211 * Failure: A HRESULT error code
214 HRESULT WINAPI WerReportCloseHandle(HREPORT hreport)
216 report_t * report = (report_t *) hreport;
217 report_t * cursor;
218 BOOL found = FALSE;
220 TRACE("(%p)\n", hreport);
221 EnterCriticalSection(&report_table_cs);
222 if (report) {
223 LIST_FOR_EACH_ENTRY(cursor, &report_table, report_t, entry)
225 if (cursor == report) {
226 found = TRUE;
227 list_remove(&report->entry);
228 break;
232 LeaveCriticalSection(&report_table_cs);
233 if (!found)
234 return E_INVALIDARG;
236 heap_free(report);
238 return S_OK;
241 /***********************************************************************
242 * WerReportCreate (wer.@)
244 * Create an error report in memory and return a related HANDLE
246 * PARAMS
247 * eventtype [i] a name for the event type
248 * reporttype [i] what type of report should be created
249 * reportinfo [i] NULL or a ptr to a struct with some detailed information
250 * phandle [o] ptr, where the resulting handle should be saved
252 * RETURNS
253 * Success: S_OK
254 * Failure: A HRESULT error code
256 * NOTES
257 * The event type must be registered at microsoft. Predefined types are
258 * "APPCRASH" as the default on Windows, "Crash32" and "Crash64"
261 HRESULT WINAPI WerReportCreate(PCWSTR eventtype, WER_REPORT_TYPE reporttype, PWER_REPORT_INFORMATION reportinfo, HREPORT *phandle)
263 report_t *report;
264 DWORD len;
266 TRACE("(%s, %d, %p, %p)\n", debugstr_w(eventtype), reporttype, reportinfo, phandle);
267 if (reportinfo) {
268 TRACE(".wzFriendlyEventName: %s\n", debugstr_w(reportinfo->wzFriendlyEventName));
269 TRACE(".wzApplicationName: %s\n", debugstr_w(reportinfo->wzApplicationName));
272 if (phandle) *phandle = NULL;
273 if (!eventtype || !eventtype[0] || !phandle) {
274 return E_INVALIDARG;
277 len = lstrlenW(eventtype) + 1;
279 report = heap_alloc_zero(len * sizeof(WCHAR) + sizeof(report_t));
280 if (!report)
281 return __HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
283 lstrcpyW(report->eventtype, eventtype);
284 report->reporttype = reporttype;
286 if (reportinfo) {
287 report->info = *reportinfo;
288 } else {
289 FIXME("build report information from scratch for %p\n", report);
292 EnterCriticalSection(&report_table_cs);
293 list_add_head(&report_table, &report->entry);
294 LeaveCriticalSection(&report_table_cs);
296 *phandle = report;
297 TRACE("=> %p\n", report);
298 return S_OK;
301 /***********************************************************************
302 * WerReportSetParameter (wer.@)
304 * Set one of 10 parameter / value pairs for a report handle
306 * PARAMS
307 * hreport [i] error reporting handle to add the parameter
308 * id [i] parameter to set (WER_P0 up to WER_P9)
309 * name [i] optional name of the parameter
310 * value [i] value of the parameter
312 * RETURNS
313 * Success: S_OK
314 * Failure: A HRESULT error code
317 HRESULT WINAPI WerReportSetParameter(HREPORT hreport, DWORD id, PCWSTR name, PCWSTR value)
319 FIXME("(%p, %d, %s, %s) :stub\n", hreport, id, debugstr_w(name), debugstr_w(value));
321 return E_NOTIMPL;
324 /***********************************************************************
325 * WerReportSubmit (wer.@)
327 * Ask the user for permission and send the error report
328 * then kill or restart the application, when requested
330 * PARAMS
331 * hreport [i] error reporting handle to send
332 * consent [i] current transmit permission
333 * flags [i] flag to select dialog, transmission snd restart options
334 * presult [o] ptr, where the transmission result should be saved
336 * RETURNS
337 * Success: S_OK
338 * Failure: A HRESULT error code
341 HRESULT WINAPI WerReportSubmit(HREPORT hreport, WER_CONSENT consent, DWORD flags, PWER_SUBMIT_RESULT presult)
343 FIXME("(%p, %d, 0x%x, %p) :stub\n", hreport, consent, flags, presult);
345 if(!presult)
346 return E_INVALIDARG;
348 *presult = WerDisabled;
349 return E_NOTIMPL;
352 /***********************************************************************
353 * WerReportSetUIOption (wer.@)
355 HRESULT WINAPI WerReportSetUIOption(HREPORT hreport, WER_REPORT_UI uitype, PCWSTR value)
357 FIXME("(%p, %d, %s) :stub\n", hreport, uitype, debugstr_w(value));
358 return E_NOTIMPL;