atl80: Added AtlComModuleRegisterServer implementation (based on AtlModuleRegisterSer...
[wine] / dlls / faultrep / faultrep.c
1 /* Fault report handling
2  *
3  * Copyright 2007 Peter Dons Tychsen
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <stdarg.h>
21
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "winreg.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
28
29 #include "errorrep.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(faultrep);
32
33 static const WCHAR SZ_EXCLUSIONLIST_KEY[] = {
34     'S','o','f','t','w','a','r','e','\\',
35     'M','i','c','r','o','s','o','f','t','\\',
36     'P','C','H','e','a','l','t','h','\\',
37     'E','r','r','o','r','R','e','p','o','r','t','i','n','g','\\',
38     'E','x','c','l','u','s','i','o','n','L','i','s','t', 0};
39
40 /*************************************************************************
41  * AddERExcludedApplicationW  [FAULTREP.@]
42  *
43  * Adds an application to a list of applications for which fault reports
44  * shouldn't be generated
45  *
46  * PARAMS
47  * lpAppFileName  [I] The filename of the application executable
48  *
49  * RETURNS
50  * TRUE on success, FALSE of failure
51  *
52  * NOTES
53  * Wine doesn't use this data but stores it in the registry (in the same place
54  * as Windows would) in case it will be useful in a future version
55  *
56  * According to MSDN this function should succeed even if the user has no write
57  * access to HKLM. This probably means that there is no error checking.
58  */
59 BOOL WINAPI AddERExcludedApplicationW(LPCWSTR lpAppFileName)
60 {
61     WCHAR *bslash;
62     DWORD value = 1;
63     HKEY hkey;
64
65     TRACE("(%s)\n", wine_dbgstr_w(lpAppFileName));
66     bslash = strrchrW(lpAppFileName, '\\');
67     if (bslash != NULL)
68         lpAppFileName = bslash + 1;
69     if (*lpAppFileName == '\0')
70     {
71         SetLastError(ERROR_INVALID_PARAMETER);
72         return FALSE;
73     }
74
75     if (!RegCreateKeyW(HKEY_LOCAL_MACHINE, SZ_EXCLUSIONLIST_KEY, &hkey))
76     {
77         RegSetValueExW(hkey, lpAppFileName, 0, REG_DWORD, (LPBYTE)&value, sizeof(value));
78         RegCloseKey(hkey);
79     }
80
81     return TRUE;
82 }
83
84 /*************************************************************************
85  * AddERExcludedApplicationA  [FAULTREP.@]
86  *
87  * See AddERExcludedApplicationW
88  */
89 BOOL WINAPI AddERExcludedApplicationA(LPCSTR lpAppFileName)
90 {
91     int len = MultiByteToWideChar(CP_ACP, 0, lpAppFileName, -1, NULL, 0);
92     WCHAR *wstr;
93     BOOL ret;
94
95     TRACE("(%s)\n", wine_dbgstr_a(lpAppFileName));
96     if (len == 0)
97         return FALSE;
98     wstr = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
99     MultiByteToWideChar(CP_ACP, 0, lpAppFileName, -1, wstr, len);
100     ret = AddERExcludedApplicationW(wstr);
101     HeapFree(GetProcessHeap(), 0, wstr);
102     return ret;
103 }
104
105 /*************************************************************************
106  * ReportFault  [FAULTREP.@]
107  */
108 EFaultRepRetVal WINAPI ReportFault(LPEXCEPTION_POINTERS pep, DWORD dwOpt)
109 {
110     FIXME("%p 0x%x stub\n", pep, dwOpt);
111     return frrvOk;
112 }
113
114 /***********************************************************************
115  * DllMain.
116  */
117 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
118 {
119     switch(reason)
120     {
121     case DLL_WINE_PREATTACH:
122         return FALSE;
123     case DLL_PROCESS_ATTACH:
124         DisableThreadLibraryCalls(inst);
125         break;
126     case DLL_PROCESS_DETACH:
127         break;
128     }
129     return TRUE;
130 }