title: How to get the stacktrace of a DLL who crashes?
body: <p>I develop some DLLs for an application and I would like to know if it is possible to get the stacktrace (in a log file) of my DLL when it crashes and then without make any modification in the code of the main application.</p>
  
  <p>Here is a dummy example of a DLL I want to log the stacktrace when it crashes:</p>
  
  <p><strong>HelloDLL.h</strong></p>
  
  <pre><code>#pragma once
  
  //more about this in reference 1
  #ifdef DLLDIR_EX
     #define DLLDIR  __declspec(dllexport)   // export DLL information
  
  #else
     #define DLLDIR  __declspec(dllimport)   // import DLL information
  
  #endif 
  
  class DLLDIR HelloDLL
  {
  public:
      HelloDLL(void);
      ~HelloDLL(void);
  
      void crash();
  
  private:
      void danger();
  };
  </code></pre>
  
  <p><strong>HelloDLL.cpp</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include "HelloDLL.h"
  #include &lt;iostream&gt;
  
  using namespace std; 
  
  HelloDLL::HelloDLL(void)
  {
  }
  
  HelloDLL::~HelloDLL(void)
  {
  }
  
  void HelloDLL::crash()
  {
      danger();
  }
  
  void HelloDLL::danger()
  {
      abort();
  }
  </code></pre>
  
  <p>And the application I cannot change:</p>
  
  <pre><code>#include "stdafx.h"
  #include "HelloDLL.h"
  
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int _tmain(int argc, _TCHAR* argv[])
  {
  
      HelloDLL helloDLL;
      helloDLL.crash();
  
      getchar();
  
      return 0;
  }
  </code></pre>
  
  <p>I used <a href="http://programmingexamples.wikidot.com/blog:1" rel="nofollow noreferrer">this website</a> to create this example.</p>
  
  <p>In other words, how can I get the maximum information from my DLL when it crashes in order to facilitate the debugging process?</p>