wined3d: Pass a wined3d_device_context to wined3d_cs_emit_set_index_buffer().
[wine.git] / dlls / wer / main.c
blobe54e6d6e0c94002607c2381cb5a986272ae838a2
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 <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winreg.h"
25 #include "werapi.h"
26 #include "wine/heap.h"
27 #include "wine/list.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wer);
32 typedef struct {
33 struct list entry;
34 WER_REPORT_INFORMATION info;
35 WER_REPORT_TYPE reporttype;
36 WCHAR eventtype[1];
37 } report_t;
40 static CRITICAL_SECTION report_table_cs;
41 static CRITICAL_SECTION_DEBUG report_table_cs_debug =
43 0, 0, &report_table_cs,
44 { &report_table_cs_debug.ProcessLocksList, &report_table_cs_debug.ProcessLocksList },
45 0, 0, { (DWORD_PTR)(__FILE__ ": report_table_cs") }
47 static CRITICAL_SECTION report_table_cs = { &report_table_cs_debug, -1, 0, 0, 0, 0 };
49 static struct list report_table = LIST_INIT(report_table);
51 static const WCHAR regpath_exclude[] = L"Software\\Microsoft\\Windows Error Reporting\\ExcludedApplications";
53 /***********************************************************************
54 * WerAddExcludedApplication (wer.@)
56 * Add an application to the user specific or the system wide exclusion list
58 * PARAMS
59 * exeName [i] The application name
60 * allUsers [i] for all users (TRUE) or for the current user (FALSE)
62 * RETURNS
63 * Success: S_OK
64 * Failure: A HRESULT error code
67 HRESULT WINAPI WerAddExcludedApplication(PCWSTR exeName, BOOL allUsers)
69 HKEY hkey;
70 DWORD value = 1;
71 LPWSTR bs;
73 TRACE("(%s, %d)\n",debugstr_w(exeName), allUsers);
74 if (!exeName || !exeName[0])
75 return E_INVALIDARG;
77 bs = wcsrchr(exeName, '\\');
78 if (bs) {
79 bs++; /* skip the backslash */
80 if (!bs[0]) {
81 return E_INVALIDARG;
83 } else
84 bs = (LPWSTR) exeName;
86 if (!RegCreateKeyW(allUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, regpath_exclude, &hkey)) {
87 RegSetValueExW(hkey, bs, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
88 RegCloseKey(hkey);
89 return S_OK;
91 return E_ACCESSDENIED;
94 /***********************************************************************
95 * WerRemoveExcludedApplication (wer.@)
97 * remove an application from the exclusion list
99 * PARAMS
100 * exeName [i] The application name
101 * allUsers [i] for all users (TRUE) or for the current user (FALSE)
103 * RETURNS
104 * Success: S_OK
105 * Failure: A HRESULT error code
108 HRESULT WINAPI WerRemoveExcludedApplication(PCWSTR exeName, BOOL allUsers)
110 HKEY hkey;
111 LPWSTR bs;
112 LONG lres;
114 TRACE("(%s, %d)\n",debugstr_w(exeName), allUsers);
115 if (!exeName || !exeName[0])
116 return E_INVALIDARG;
118 bs = wcsrchr(exeName, '\\');
119 if (bs) {
120 bs++; /* skip the backslash */
121 if (!bs[0]) {
122 return E_INVALIDARG;
124 } else
125 bs = (LPWSTR) exeName;
127 if (!RegCreateKeyW(allUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, regpath_exclude, &hkey)) {
128 lres = RegDeleteValueW(hkey, bs);
129 RegCloseKey(hkey);
130 return lres ? __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND) : S_OK;
132 return E_ACCESSDENIED;
135 /***********************************************************************
136 * WerReportAddDump (wer.@)
138 * Add a dump of dumpType to hReportHandle.
140 * PARAMS
141 * hReportHandle [i] error reporting handle to add the dump
142 * hProcess [i] handle to the regarding process
143 * hThread [o] handle to the regarding thread
144 * dumpType [i] type of the dump
145 * pExceptionParam [o] pointer to a WER_EXCEPTION_INFORMATION
146 * pDumpCustomOptions [o] pointer to a WER_DUMP_CUSTOM_OPTIONS
147 * dwFlags [i] flag to control the heap dump
149 * RETURNS
150 * Success: S_OK
151 * Failure: A HRESULT error code
154 HRESULT WINAPI WerReportAddDump(HREPORT hReportHandle, HANDLE hProcess, HANDLE hThread,
155 WER_DUMP_TYPE dumpType, PWER_EXCEPTION_INFORMATION pExceptionParam,
156 PWER_DUMP_CUSTOM_OPTIONS pDumpCustomOptions, DWORD dwFlags)
158 FIXME("(%p, %p, %p, %d, %p, %p, %u) :stub\n", hReportHandle, hProcess, hThread, dumpType,
159 pExceptionParam, pDumpCustomOptions, dwFlags);
161 return E_NOTIMPL;
164 /***********************************************************************
165 * WerReportAddFile (wer.@)
167 * Add a file to an error report handle.
169 * PARAMS
170 * hreport [i] error reporting handle to add the file
171 * path [i] path to the file to add
172 * type [i] type of the file to add
173 * flags [i] flags for the file
175 * RETURNS
176 * Success: S_OK
177 * Failure: A HRESULT error code
180 HRESULT WINAPI WerReportAddFile(HREPORT hreport, PCWSTR path, WER_FILE_TYPE type, DWORD flags)
182 FIXME("(%p, %s, %d, 0x%x) :stub\n", hreport, debugstr_w(path), type, flags);
184 return S_OK;
187 /***********************************************************************
188 * WerReportCloseHandle (wer.@)
190 * Close an error reporting handle and free associated resources
192 * PARAMS
193 * hreport [i] error reporting handle to close
195 * RETURNS
196 * Success: S_OK
197 * Failure: A HRESULT error code
200 HRESULT WINAPI WerReportCloseHandle(HREPORT hreport)
202 report_t * report = (report_t *) hreport;
203 report_t * cursor;
204 BOOL found = FALSE;
206 TRACE("(%p)\n", hreport);
207 EnterCriticalSection(&report_table_cs);
208 if (report) {
209 LIST_FOR_EACH_ENTRY(cursor, &report_table, report_t, entry)
211 if (cursor == report) {
212 found = TRUE;
213 list_remove(&report->entry);
214 break;
218 LeaveCriticalSection(&report_table_cs);
219 if (!found)
220 return E_INVALIDARG;
222 heap_free(report);
224 return S_OK;
227 /***********************************************************************
228 * WerReportCreate (wer.@)
230 * Create an error report in memory and return a related HANDLE
232 * PARAMS
233 * eventtype [i] a name for the event type
234 * reporttype [i] what type of report should be created
235 * reportinfo [i] NULL or a ptr to a struct with some detailed information
236 * phandle [o] ptr, where the resulting handle should be saved
238 * RETURNS
239 * Success: S_OK
240 * Failure: A HRESULT error code
242 * NOTES
243 * The event type must be registered at microsoft. Predefined types are
244 * "APPCRASH" as the default on Windows, "Crash32" and "Crash64"
247 HRESULT WINAPI WerReportCreate(PCWSTR eventtype, WER_REPORT_TYPE reporttype, PWER_REPORT_INFORMATION reportinfo, HREPORT *phandle)
249 report_t *report;
251 TRACE("(%s, %d, %p, %p)\n", debugstr_w(eventtype), reporttype, reportinfo, phandle);
252 if (reportinfo) {
253 TRACE(".wzFriendlyEventName: %s\n", debugstr_w(reportinfo->wzFriendlyEventName));
254 TRACE(".wzApplicationName: %s\n", debugstr_w(reportinfo->wzApplicationName));
257 if (phandle) *phandle = NULL;
258 if (!eventtype || !eventtype[0] || !phandle || (reporttype >= WerReportInvalid)) {
259 return E_INVALIDARG;
262 report = heap_alloc_zero(FIELD_OFFSET(report_t, eventtype[lstrlenW(eventtype) + 1]));
263 if (!report)
264 return __HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
266 lstrcpyW(report->eventtype, eventtype);
267 report->reporttype = reporttype;
269 if (reportinfo) {
270 report->info = *reportinfo;
271 } else {
272 FIXME("build report information from scratch for %p\n", report);
275 EnterCriticalSection(&report_table_cs);
276 list_add_head(&report_table, &report->entry);
277 LeaveCriticalSection(&report_table_cs);
279 *phandle = report;
280 TRACE("=> %p\n", report);
281 return S_OK;
284 /***********************************************************************
285 * WerReportSetParameter (wer.@)
287 * Set one of 10 parameter / value pairs for a report handle
289 * PARAMS
290 * hreport [i] error reporting handle to add the parameter
291 * id [i] parameter to set (WER_P0 up to WER_P9)
292 * name [i] optional name of the parameter
293 * value [i] value of the parameter
295 * RETURNS
296 * Success: S_OK
297 * Failure: A HRESULT error code
300 HRESULT WINAPI WerReportSetParameter(HREPORT hreport, DWORD id, PCWSTR name, PCWSTR value)
302 FIXME("(%p, %d, %s, %s) :stub\n", hreport, id, debugstr_w(name), debugstr_w(value));
304 return S_OK;
307 /***********************************************************************
308 * WerReportSubmit (wer.@)
310 * Ask the user for permission and send the error report
311 * then kill or restart the application, when requested
313 * PARAMS
314 * hreport [i] error reporting handle to send
315 * consent [i] current transmit permission
316 * flags [i] flag to select dialog, transmission snd restart options
317 * presult [o] ptr, where the transmission result should be saved
319 * RETURNS
320 * Success: S_OK
321 * Failure: A HRESULT error code
324 HRESULT WINAPI WerReportSubmit(HREPORT hreport, WER_CONSENT consent, DWORD flags, PWER_SUBMIT_RESULT presult)
326 FIXME("(%p, %d, 0x%x, %p) :stub\n", hreport, consent, flags, presult);
328 if(!presult)
329 return E_INVALIDARG;
331 *presult = WerDisabled;
332 return S_OK;
335 /***********************************************************************
336 * WerReportSetUIOption (wer.@)
338 HRESULT WINAPI WerReportSetUIOption(HREPORT hreport, WER_REPORT_UI uitype, PCWSTR value)
340 FIXME("(%p, %d, %s) :stub\n", hreport, uitype, debugstr_w(value));
341 return E_NOTIMPL;