Created new plat_tempfile() function so it can be re-used.
This commit is contained in:
@@ -367,6 +367,26 @@ plat_get_exe_name(wchar_t *bufp, int size)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plat_tempfile(wchar_t *bufp, const wchar_t *prefix, const wchar_t *suffix)
|
||||
{
|
||||
SYSTEMTIME SystemTime;
|
||||
char temp[1024];
|
||||
|
||||
if (prefix != NULL)
|
||||
sprintf(temp, "%ls", prefix);
|
||||
else
|
||||
strcpy(temp, EMU_NAME);
|
||||
|
||||
GetSystemTime(&SystemTime);
|
||||
sprintf(&temp[strlen(temp)], "-%d%02d%02d-%02d-%02d-%02d-%03d%ls",
|
||||
SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour,
|
||||
SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds,
|
||||
suffix);
|
||||
mbstowcs(bufp, temp, strlen(temp)+1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
plat_getcwd(wchar_t *bufp, int max)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle generation of crash-dump reports.
|
||||
*
|
||||
* Version: @(#)win_crashdump.c 1.0.6 2018/03/20
|
||||
* Version: @(#)win_crashdump.c 1.0.7 2018/08/31
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Riley (Rai-chan),
|
||||
@@ -53,6 +53,7 @@
|
||||
static PVOID hExceptionHandler;
|
||||
static char *ExceptionHandlerBuffer,
|
||||
*CurrentBufferPointer;
|
||||
static char ExceptionHandlerFileName[1024];
|
||||
|
||||
|
||||
static LONG CALLBACK
|
||||
@@ -63,6 +64,9 @@ MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
char *BufPtr;
|
||||
DWORD i;
|
||||
|
||||
/* Get current system date and time. */
|
||||
GetSystemTime(&SystemTime);
|
||||
|
||||
/*
|
||||
* Win32-specific functions will be used wherever possible,
|
||||
* just in case the C stdlib-equivalents try to allocate
|
||||
@@ -113,20 +117,14 @@ MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
* It should contain the current date and time so as
|
||||
* to be (hopefully!) unique.
|
||||
*/
|
||||
GetSystemTime(&SystemTime);
|
||||
sprintf(CurrentBufferPointer,
|
||||
"%s-%d%02d%02d-%02d-%02d-%02d-%03d.dmp", EMU_NAME,
|
||||
SystemTime.wYear,
|
||||
SystemTime.wMonth,
|
||||
SystemTime.wDay,
|
||||
SystemTime.wHour,
|
||||
SystemTime.wMinute,
|
||||
SystemTime.wSecond,
|
||||
SystemTime.wMilliseconds);
|
||||
plat_tempfile((wchar_t *)ExceptionHandlerBuffer, NULL, DUMP_FILE_EXT);
|
||||
wcstombs(ExceptionHandlerFileName, (wchar_t *)ExceptionHandlerBuffer,
|
||||
sizeof(ExceptionHandlerFileName));
|
||||
|
||||
|
||||
/* Now the filename is in the buffer, the file can be created. */
|
||||
hDumpFile = CreateFile(
|
||||
ExceptionHandlerBuffer, // The filename of the file to open.
|
||||
ExceptionHandlerFileName, // The filename of the file to open.
|
||||
GENERIC_WRITE, // The permissions to request.
|
||||
0, // Make sure other processes can't
|
||||
// touch the crash dump at all
|
||||
|
||||
Reference in New Issue
Block a user