faultrep[2/2]: implement AddERExcludedApplication[AW] (resend)

Mikolaj Zalewski mikolajz at google.com
Fri Aug 31 20:13:43 CDT 2007


I've just noticed in the MSDN that this function should succeed even
if the user have no write access to HKLM. This probably means that
there should be no error checking in registry access. This simplifies
the code.
-------------- next part --------------
From 41047b431a172290479176b2ca6c9189c6e5e8cf Mon Sep 17 00:00:00 2001
From: Mikolaj Zalewski <mikolaj at zalewski.pl>
Date: Fri, 31 Aug 2007 18:10:13 -0700
Subject: [PATCH] faultrep: implement AddERExcludedApplication[AW]
---
 dlls/faultrep/Makefile.in   |    2 +
 dlls/faultrep/faultrep.c    |   80 +++++++++++++++++++++++++++++++++++++++++++
 dlls/faultrep/faultrep.spec |    4 +-
 3 files changed, 83 insertions(+), 3 deletions(-)

diff --git a/dlls/faultrep/Makefile.in b/dlls/faultrep/Makefile.in
index e6e04a2..f521178 100644
--- a/dlls/faultrep/Makefile.in
+++ b/dlls/faultrep/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = faultrep.dll
-IMPORTS   = kernel32
+IMPORTS   = advapi32 kernel32
 
 C_SRCS = faultrep.c
 
diff --git a/dlls/faultrep/faultrep.c b/dlls/faultrep/faultrep.c
index 7771191..19220de 100644
--- a/dlls/faultrep/faultrep.c
+++ b/dlls/faultrep/faultrep.c
@@ -21,10 +21,90 @@ #include <stdarg.h>
 
 #include "windef.h"
 #include "winbase.h"
+#include "winnls.h"
+#include "winreg.h"
 #include "wine/debug.h"
+#include "wine/unicode.h"
+
+#include "errorrep.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(faultrep);
 
+static const WCHAR SZ_EXCLUSIONLIST_KEY[] = {
+    'S','o','f','t','w','a','r','e','\\',
+    'M','i','c','r','o','s','o','f','t','\\',
+    'P','C','H','e','a','l','t','h','\\',
+    'E','r','r','o','r','R','e','p','o','r','t','i','n','g','\\',
+    'E','x','c','l','u','s','i','o','n','L','i','s','t', 0};
+
+/*************************************************************************
+ * AddERExcludedApplicationW  [FAULTREP.@]
+ *
+ * Adds an application to a list of applications for which fault reports
+ * shouldn't be genereated
+ *
+ * PARAMS
+ * lpAppFileName  [I] The filename of the application executable
+ *
+ * RETURNS
+ * TRUE on success, FALSE of failure
+ *
+ * NOTES
+ * Wine doesn't use this data but stores it in the registry (in the same place
+ * as Windows would) in case it will be useful in a future version
+ *
+ * According to MSDN this function should succeed even if the user have no write
+ * access to HKLM. This probably means that there is no error checking.
+ */
+BOOL WINAPI AddERExcludedApplicationW(LPWSTR lpAppFileName)
+{
+    WCHAR *bslash;
+    LONG ret;
+    DWORD value = 1;
+    HKEY hkey;
+
+    TRACE("(%s)\n", wine_dbgstr_w(lpAppFileName));
+    bslash = strrchrW(lpAppFileName, '\\');
+    if (bslash != NULL)
+        lpAppFileName = bslash + 1;
+    if (*lpAppFileName == '\0')
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    hkey = NULL;
+    RegCreateKeyW(HKEY_LOCAL_MACHINE, SZ_EXCLUSIONLIST_KEY, &hkey);
+    if (hkey != NULL)
+    {
+        RegSetValueExW(hkey, lpAppFileName, 0, REG_DWORD, (LPBYTE)&value, sizeof(value));
+        RegCloseKey(hkey);
+    }
+
+    return (ret ? FALSE : TRUE);
+}
+
+/*************************************************************************
+ * AddERExcludedApplicationA  [FAULTREP.@]
+ *
+ * See AddERExcludedApplicationW
+ */
+BOOL WINAPI AddERExcludedApplicationA(LPSTR lpAppFileName)
+{
+    int len = MultiByteToWideChar(CP_ACP, 0, lpAppFileName, -1, NULL, 0);
+    WCHAR *wstr;
+    BOOL ret;
+
+    TRACE("(%s)\n", wine_dbgstr_a(lpAppFileName));
+    if (len == 0)
+        return FALSE;
+    wstr = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
+    MultiByteToWideChar(CP_ACP, 0, lpAppFileName, -1, wstr, sizeof(WCHAR)*len);
+    ret = AddERExcludedApplicationW(wstr);
+    HeapFree(GetProcessHeap(), 0, wstr);
+    return ret;
+}
+
 /***********************************************************************
  * DllMain.
  */
diff --git a/dlls/faultrep/faultrep.spec b/dlls/faultrep/faultrep.spec
index 3cc9934..77a2827 100644
--- a/dlls/faultrep/faultrep.spec
+++ b/dlls/faultrep/faultrep.spec
@@ -1,5 +1,5 @@
-@ stub AddERExcludedApplicationA
-@ stub AddERExcludedApplicationW
+@ stdcall AddERExcludedApplicationA(str)
+@ stdcall AddERExcludedApplicationW(wstr)
 @ stub CreateMinidumpA
 @ stub CreateMinidumpW
 @ stub ReportEREvent
-- 
1.4.1


More information about the wine-patches mailing list