From a40af5b2e7f3beef0ac8a784532c6523d13d3023 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 14 Feb 2006 06:21:46 +0000 Subject: [PATCH] support optionally gzipped .vdi files --- .../src/archutils/Win32/CrashHandlerChild.cpp | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/stepmania/src/archutils/Win32/CrashHandlerChild.cpp b/stepmania/src/archutils/Win32/CrashHandlerChild.cpp index bec96de68b..892d3971e4 100644 --- a/stepmania/src/archutils/Win32/CrashHandlerChild.cpp +++ b/stepmania/src/archutils/Win32/CrashHandlerChild.cpp @@ -20,6 +20,7 @@ #include "RageUtil.h" #include "XmlFile.h" #include "LocalizedString.h" +#include "RageFileDriverDeflate.h" #if defined(_MSC_VER) #pragma comment(lib, "archutils/Win32/ddk/dbghelp.lib") @@ -35,7 +36,7 @@ namespace VDDebugInfo { Context() { pRVAHeap=NULL; } bool Loaded() const { return pRVAHeap != NULL; } - void *pRawBlock; + RString sRawBlock; int nBuildNumber; @@ -60,9 +61,24 @@ namespace VDDebugInfo strcat( buf, ".vdi" ); } - bool VDDebugInfoInitFromMemory( Context *pctx, const void *src_ ) + bool VDDebugInfoInitFromMemory( Context *pctx ) { - const unsigned char *src = (const unsigned char *)src_; + if( pctx->sRawBlock[0] == '\x1f' && + pctx->sRawBlock[1] == '\x8b' ) + { + RString sBufOut; + RString sError; + if( !GunzipString(pctx->sRawBlock, sBufOut, sError) ) + { + pctx->sError = werr_ssprintf( GetLastError(), "VDI error: %s", sError.c_str() ); + return false; + } + + pctx->sRawBlock = sBufOut; + } + + + const unsigned char *src = (const unsigned char *) pctx->sRawBlock.data(); pctx->pRVAHeap = NULL; @@ -89,11 +105,8 @@ namespace VDDebugInfo void VDDebugInfoDeinit( Context *pctx ) { - if( pctx->pRawBlock ) - { - VirtualFree(pctx->pRawBlock, 0, MEM_RELEASE); - pctx->pRawBlock = NULL; - } + if( !pctx->sRawBlock.empty() ) + pctx->sRawBlock = RString(); } bool VDDebugInfoInitFromFile( Context *pctx ) @@ -101,7 +114,7 @@ namespace VDDebugInfo if( pctx->Loaded() ) return true; - pctx->pRawBlock = NULL; + pctx->sRawBlock = RString(); pctx->pRVAHeap = NULL; GetVDIPath( pctx->sFilename, ARRAYSIZE(pctx->sFilename) ); pctx->sError = RString(); @@ -118,22 +131,20 @@ namespace VDDebugInfo if( dwFileSize == INVALID_FILE_SIZE ) break; - pctx->pRawBlock = VirtualAlloc( NULL, dwFileSize, MEM_COMMIT, PAGE_READWRITE ); - if( !pctx->pRawBlock ) + char *pBuf = pctx->sRawBlock.GetBuffer( dwFileSize ); + if( pBuf == NULL ) break; DWORD dwActual; - if( !ReadFile(h, pctx->pRawBlock, dwFileSize, &dwActual, NULL) || dwActual != dwFileSize ) + int iRet = ReadFile(h, pBuf, dwFileSize, &dwActual, NULL); + CloseHandle(h); + pctx->sRawBlock.ReleaseBuffer( dwActual ); + + if( !iRet || dwActual != dwFileSize ) break; - CloseHandle(h); - - if( VDDebugInfoInitFromMemory(pctx, pctx->pRawBlock) ) - { + if( VDDebugInfoInitFromMemory(pctx) ) return true; - } - - VirtualFree( pctx->pRawBlock, 0, MEM_RELEASE ); } while(0); VDDebugInfoDeinit(pctx);