[vlc-commits] winvlc: include address space layout in crash reports

Rafaël Carré git at videolan.org
Tue Nov 15 02:23:19 CET 2011


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Mon Nov 14 20:22:21 2011 -0500| [98f09b5dd844b2126723d6cf0b6f0918444fad1f] | committer: Rafaël Carré

winvlc: include address space layout in crash reports

Will help to 'undo' ASLR and make those reports useful

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=98f09b5dd844b2126723d6cf0b6f0918444fad1f
---

 bin/Makefile.am |    2 +-
 bin/winvlc.c    |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 86d7f65..832d482 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -45,7 +45,7 @@ vlc_static_LDADD = $(vlc_LDADD)
 vlc_static_LDFLAGS = $(vlc_LDFLAGS)
 
 if HAVE_WIN32
-vlc_LDADD += -lwininet vlc_win32_rc.$(OBJEXT)
+vlc_LDADD += -lpsapi -lwininet vlc_win32_rc.$(OBJEXT)
 vlc_DEPENDENCIES = vlc_win32_rc.$(OBJEXT)
 else
 vlc_LDADD += $(LIBDL)
diff --git a/bin/winvlc.c b/bin/winvlc.c
index b3ef798..1f60123 100644
--- a/bin/winvlc.c
+++ b/bin/winvlc.c
@@ -38,6 +38,8 @@
 # endif
 # include <shlobj.h>
 # include <wininet.h>
+# define PSAPI_VERSION 1
+# include <psapi.h>
 # define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
 static void check_crashdump(void);
 LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo);
@@ -343,6 +345,23 @@ LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo)
                         pContext->Ebp,pContext->Eip,pContext->Esp );
 #endif
 
+        HANDLE hpid = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+                                        FALSE, GetCurrentProcessId());
+        if (hpid) {
+            HMODULE mods[1024];
+            DWORD size;
+            if (EnumProcessModules(hpid, mods, sizeof(mods), &size)) {
+                fwprintf( fd, L"\n\n[modules]\n" );
+                for (unsigned int i = 0; i < size / sizeof(HMODULE); i++) {
+                    wchar_t module[ 256 ];
+                    GetModuleFileName(mods[i], module, 256);
+                    fwprintf( fd, L"%p|%s\n", mods[i], module);
+                }
+            }
+            CloseHandle(hpid);
+        }
+
+
         fwprintf( fd, L"\n[stacktrace]\n#EIP|base|module\n" );
 
 #ifdef WIN64



More information about the vlc-commits mailing list