Skip to content

Commit

Permalink
Fix crash in exception logging (issue #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerorr committed Aug 15, 2020
1 parent f217eef commit b2e7265
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/ShowData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ COPYRIGHT
Please report bugs to [email protected].
*/

static char const szRCSID[] = "$Id: ShowData.cpp 1881 2020-04-09 20:55:12Z Roger $";
static char const szRCSID[] = "$Id: ShowData.cpp 1915 2020-08-15 14:23:23Z Roger $";

#pragma warning( disable: 4786 ) // identifier was truncated to '255' characters

#include "ShowData.h"
#include "Enumerations.h"

#include <windows.h>
#include <DbgHelp.h>

#include <iomanip>
#include <map>
Expand Down Expand Up @@ -525,7 +526,7 @@ void showFileAttributes( std::ostream & os, ULONG argVal )
}

//////////////////////////////////////////////////////////////////////////
// note: file times are not returned by the commonest Api, NtQueryInformationFile ...
// note: file times are not returned by the commonest Api, NtQueryInformationFile ...
void showPFileBasicInfo( std::ostream & os, HANDLE hProcess, PFILE_BASIC_INFORMATION pFileBasicInfo )
{
showPointer(os, hProcess, (ULONG_PTR)pFileBasicInfo);
Expand Down Expand Up @@ -621,11 +622,19 @@ void showThrowType( std::ostream & os, HANDLE hProcess, ULONG_PTR throwInfo, ULO
memset( type_info + sizeof( PVOID ), 0, sizeof( PVOID ) );

const std::type_info *pType_info = (const std::type_info *)type_info;
const char* pName = pType_info->name();
os << " type: " << pName;
const char *decorated_name = pType_info->raw_name();

// bit of a fudge: msvc allocates type_info name on first use and therefore we must destroy it.
free( const_cast<char*>( pName ) );
char buffer[ 1024 ] = "";
if ((decorated_name[0] == '.') &&
UnDecorateSymbolName( decorated_name + 1, buffer, sizeof( buffer ),
UNDNAME_32_BIT_DECODE | UNDNAME_NO_ARGUMENTS ) )
{
os << " type: " << buffer;
}
else
{
os << " raw type: " << decorated_name;
}
}


Expand Down

0 comments on commit b2e7265

Please sign in to comment.