2010-08-27 12:46:09 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Louis Lenders
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2010-11-01 09:22:03 +01:00
|
|
|
#include "werapi.h"
|
2010-11-01 23:08:45 +01:00
|
|
|
#include "wine/list.h"
|
2010-08-27 12:46:09 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wer);
|
|
|
|
|
2010-11-01 23:08:45 +01:00
|
|
|
typedef struct {
|
|
|
|
struct list entry;
|
|
|
|
WER_REPORT_INFORMATION info;
|
|
|
|
WER_REPORT_TYPE reporttype;
|
|
|
|
WCHAR eventtype[1];
|
|
|
|
} report_t;
|
|
|
|
|
|
|
|
|
|
|
|
static CRITICAL_SECTION report_table_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG report_table_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &report_table_cs,
|
|
|
|
{ &report_table_cs_debug.ProcessLocksList, &report_table_cs_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": report_table_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION report_table_cs = { &report_table_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
static struct list report_table = LIST_INIT(report_table);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Memory alloccation helper
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
|
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL heap_free(void *mem)
|
|
|
|
{
|
|
|
|
return HeapFree(GetProcessHeap(), 0, mem);
|
|
|
|
}
|
|
|
|
|
2010-10-20 00:22:51 +02:00
|
|
|
HRESULT WINAPI WerAddExcludedApplication(PCWSTR exeName, BOOL allUsers)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %d) stub\n",debugstr_w(exeName), allUsers);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-08-27 12:46:09 +02:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-10-26 11:37:16 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WerRemoveExcludedApplication (wer.@)
|
|
|
|
*
|
|
|
|
* remove an application from the exclusion list
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* exeName [i] The application name
|
|
|
|
* allUsers [i] for all users (TRUE) or for the current user (FALSE)
|
|
|
|
*
|
|
|
|
* RESULTS
|
|
|
|
* SUCCESS S_OK
|
|
|
|
* FAILURE A HRESULT error code
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI WerRemoveExcludedApplication(PCWSTR exeName, BOOL allUsers)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %d) :stub\n",debugstr_w(exeName), allUsers);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2010-11-01 09:22:03 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WerReportCloseHandle (wer.@)
|
|
|
|
*
|
|
|
|
* Close an error reporting handle and free associated resources
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hreport [i] error reporting handle to close
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: A HRESULT error code
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI WerReportCloseHandle(HREPORT hreport)
|
|
|
|
{
|
2010-11-01 23:08:45 +01:00
|
|
|
report_t * report = (report_t *) hreport;
|
|
|
|
report_t * cursor;
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", hreport);
|
|
|
|
EnterCriticalSection(&report_table_cs);
|
|
|
|
if (report) {
|
|
|
|
LIST_FOR_EACH_ENTRY(cursor, &report_table, report_t, entry)
|
|
|
|
{
|
|
|
|
if (cursor == report) {
|
|
|
|
found = TRUE;
|
|
|
|
list_remove(&report->entry);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&report_table_cs);
|
|
|
|
if (!found)
|
|
|
|
return E_INVALIDARG;
|
2010-11-01 09:22:03 +01:00
|
|
|
|
2010-11-01 23:08:45 +01:00
|
|
|
heap_free(report);
|
|
|
|
|
|
|
|
return S_OK;
|
2010-11-01 09:22:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WerReportCreate (wer.@)
|
|
|
|
*
|
|
|
|
* Create an error report in memory and return a related HANDLE
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* eventtype [i] a name for the event type
|
|
|
|
* reporttype [i] what type of report should be created
|
|
|
|
* reportinfo [i] NULL or a ptr to a struct with some detailed information
|
|
|
|
* phandle [o] ptr, where the resulting handle should be saved
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: A HRESULT error code
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The event type must be registered at microsoft. Predefined types are
|
|
|
|
* "APPCRASH" as the default on Windows, "Crash32" and "Crash64"
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI WerReportCreate(PCWSTR eventtype, WER_REPORT_TYPE reporttype, PWER_REPORT_INFORMATION reportinfo, HREPORT *phandle)
|
|
|
|
{
|
2010-11-01 23:08:45 +01:00
|
|
|
report_t *report;
|
|
|
|
DWORD len;
|
2010-11-01 09:22:03 +01:00
|
|
|
|
2010-11-01 23:08:45 +01:00
|
|
|
TRACE("(%s, %d, %p, %p)\n", debugstr_w(eventtype), reporttype, reportinfo, phandle);
|
2010-11-01 09:22:03 +01:00
|
|
|
if (reportinfo) {
|
|
|
|
TRACE(".wzFriendlyEventName: %s\n", debugstr_w(reportinfo->wzFriendlyEventName));
|
|
|
|
TRACE(".wzApplicationName: %s\n", debugstr_w(reportinfo->wzApplicationName));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (phandle) *phandle = NULL;
|
|
|
|
if (!eventtype || !eventtype[0] || !phandle) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2010-11-01 23:08:45 +01:00
|
|
|
len = lstrlenW(eventtype) + 1;
|
|
|
|
|
|
|
|
report = heap_alloc_zero(len * sizeof(WCHAR) + sizeof(report_t));
|
|
|
|
if (!report)
|
|
|
|
return __HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
|
|
|
|
|
|
|
|
lstrcpyW(report->eventtype, eventtype);
|
|
|
|
report->reporttype = reporttype;
|
|
|
|
|
|
|
|
if (reportinfo) {
|
|
|
|
report->info = *reportinfo;
|
|
|
|
} else {
|
|
|
|
FIXME("build report information from scratch for %p\n", report);
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&report_table_cs);
|
|
|
|
list_add_head(&report_table, &report->entry);
|
|
|
|
LeaveCriticalSection(&report_table_cs);
|
|
|
|
|
|
|
|
*phandle = report;
|
|
|
|
TRACE("=> %p\n", report);
|
|
|
|
return S_OK;
|
2010-11-01 09:22:03 +01:00
|
|
|
}
|
2010-11-01 09:22:05 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WerReportSetParameter (wer.@)
|
|
|
|
*
|
|
|
|
* Set one of 10 parameter / value pairs for a report handle
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hreport [i] error reporting handle to add the parameter
|
|
|
|
* id [i] parameter to set (WER_P0 upto WER_P9)
|
|
|
|
* name [i] optional name of the parameter
|
|
|
|
* value [i] value of the parameter
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: A HRESULT error code
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI WerReportSetParameter(HREPORT hreport, DWORD id, PCWSTR name, PCWSTR value)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %s, %s) :stub\n", hreport, id, debugstr_w(name), debugstr_w(value));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|