c# - !ClrStack shows the Unmanaged Call stack -
i have created console application have called win32 project throws access violation exception. have attached custom filter in setunhandledexceptionfilter
. when use !clrstack
command, shows unmanaged call stack msdn says clrstack provide stack trace of managed code only.
https://msdn.microsoft.com/en-us/library/bb190764(v=vs.110).aspx
please .
program.cs
public void exceptionmethod() { exceptioncreator.createaccessviolationexception(); }
win32 project:
errorreportwritter.h
#pragma once #include "stdafx.h" #include "dbghelp.h" using namespace system; using namespace system::runtime::interopservices; using namespace system::text; public ref class errorreportwritter { public: static void installhandler(); };
errorreportwritter.cpp
long winapi myexceptionfilter(__in struct _exception_pointers *exceptioninfo) { //for test purpose, dump location solution location handle hfile = createfilea("test.dmp", generic_read | generic_write, 0, null, create_always, file_attribute_normal, null); if ((hfile != null) && (hfile != invalid_handle_value)) { // create maxidump minidump_type mdt = (minidump_type)(minidumpwithfullmemory | minidumpwithfullmemoryinfo | minidumpwithhandledata | minidumpwiththreadinfo | minidumpwithunloadedmodules); //minidump_type mdt = minidumpnormal; minidump_exception_information mei; mei.threadid = getcurrentthreadid(); mei.clientpointers = false; mei.exceptionpointers = exceptioninfo; bool rv = minidumpwritedump(getcurrentprocess(), getcurrentprocessid(), hfile, mdt, &mei, 0, 0); //todo: put check failure return value , throw exception in case // close file closehandle(hfile); } //todo: still need decide if search next functionality needed final solution if (oldfilter == null) { return exception_continue_search; } long ret = oldfilter(exceptioninfo); return ret; } void errorreportwritter::installhandler() { //returns address of previous exception filter established function. //a null return value means there no current top-level exception handler. oldfilter = setunhandledexceptionfilter(myexceptionfilter); }
the code have managed c++. (or c++/cli or whatever visual studio version supports).
to create unmanaged win32 project, example in visual studio 2015, got file
-> new project
, select templates
-> visual c++
-> win32 project
.
Comments
Post a Comment