Cleaned up the crash reporter, and tested it :)
This commit is contained in:
@@ -1,207 +0,0 @@
|
||||
Serial mouse reset
|
||||
------------------
|
||||
|
||||
1: Set UART to 'break line' state (set bit 6 in the LCR).
|
||||
2: Clear the RTS and DTR (bits 0-1) in the MCR, wait a while.
|
||||
3: Set the RTS and DTR bits again.
|
||||
|
||||
|
||||
Serial mouse detection (identification bytes before optional PnP data)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
In Mouse Systems mode, mouse sends nothing.
|
||||
In Microsoft mode, mouse sends 'M' after dropping and raising RTS.
|
||||
In Logitech mode, mouse sends 'M3' after dropping and raising RTS.
|
||||
In wheel mode, mouse sends 'MZ@',0,0,0 after dropping and raising RTS.
|
||||
|
||||
|
||||
PS/2 pointing device ID (reported after 0F2h command)
|
||||
-----------------------------------------------------
|
||||
|
||||
In standard mode, the device reports 0.
|
||||
In wheel mode, the device reports 3. This mode is enabled by sending a
|
||||
Select Report Rate 200, a Rate 100 and finally a Rate 80 command sequence.
|
||||
In extended mode, the device reports 4. This mode is enabled by sending a
|
||||
Select Report Rate 200, a Rate 200 and finally a Rate 80 command sequence.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Serial Mouse Systems mode: 1200 bps, 8 data bits, 1 stop bit, no parity
|
||||
|
||||
1st byte 2nd byte 3rd byte
|
||||
+---------------+ +---------------+ +---------------+
|
||||
|1|0|0|0|0|L|M|R| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y|
|
||||
+---------------+ +---------------+ +---------------+
|
||||
| | | Xa movement Ya movement
|
||||
| | |
|
||||
| | | 4th byte 5th byte
|
||||
Left Button ------+ | | +---------------+ +---------------+
|
||||
Middle Button --------+ | |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y|
|
||||
Right Button ----------+ +---------------+ +---------------+
|
||||
(0 if pressed) Xb movement Yb movement
|
||||
|
||||
|
||||
Xa/Ya - movement of the mouse since last packet.
|
||||
Xb/Yb - movement of the mouse since Xa/Ya.
|
||||
Movement values are 8-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/upward.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Serial Microsoft mode: 1200 bps, 7 data bits, 1 stop bit, no parity
|
||||
|
||||
1st byte 2nd byte 3rd byte
|
||||
+---------------+ +---------------+ +---------------+
|
||||
|0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y|
|
||||
+---------------+ +---------------+ +---------------+
|
||||
| | \ / \ / \----+----/ \----+----/
|
||||
| | | | | |
|
||||
| | +---|-------------|---------+ |
|
||||
| | +-----+ | | |
|
||||
| | / \ /----+----\ / \ /----+----\
|
||||
| | +---------------+ +---------------+
|
||||
Left Button -+ | | | | | | | | | | | | | | | | | | |
|
||||
Right Button ---+ +---------------+ +---------------+
|
||||
(1 if pressed) X movement Y movement
|
||||
|
||||
|
||||
Movement values are 8-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/downward.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Serial Logitech mode: 1200 bps, 7 data bits, 1 stop bit, no parity
|
||||
|
||||
1st byte 2nd byte 3rd byte
|
||||
+---------------+ +---------------+ +---------------+
|
||||
|0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y|
|
||||
+---------------+ +---------------+ +---------------+
|
||||
| | \ / \ / \----+----/ \----+----/
|
||||
| | | | | |
|
||||
| | +---|-------------|---------+ |
|
||||
| | +-----+ | | |
|
||||
| | / \ /----+----\ / \ /----+----\
|
||||
| | +---------------+ +---------------+
|
||||
Left Button -+ | | | | | | | | | | | | | | | | | | |
|
||||
Right Button ---+ +---------------+ +---------------+
|
||||
(1 if pressed) X movement Y movement
|
||||
|
||||
|
||||
The extra byte (only when middle button is pressed)
|
||||
---------------------------------------------------
|
||||
|
||||
4th byte
|
||||
+---------------+
|
||||
|0|0|M|0|0|0|0|0|
|
||||
+---------------+
|
||||
|
|
||||
Middle Button (1 if pressed)
|
||||
|
||||
|
||||
First three bytes are equal to Mouse mode packet.
|
||||
Movement values are 8-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/downward.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Serial Microsoft wheel mode: 1200 bps, 7 data bits, 1 stop bit, no parity
|
||||
|
||||
1st byte 2nd byte 3rd byte 4th byte
|
||||
+---------------+ +---------------+ +---------------+ +---------------+
|
||||
|0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y| |0|0|0|M|w|w|w|w|
|
||||
+---------------+ +---------------+ +---------------+ +---------------+
|
||||
| | \ / \ / \----+----/ \----+----/ | \--+--/
|
||||
| | | | | | | |
|
||||
| | +---|-------------|---------+ | | |
|
||||
| | +-----+ | | | | Wheel
|
||||
| | / \ /----+----\ / \ /----+----\ | Movement
|
||||
| | +---------------+ +---------------+ |
|
||||
Left Button -+ | | | | | | | | | | | | | | | | | | | |
|
||||
Right Button ---+ +---------------+ +---------------+ Middle Button
|
||||
(1 if pressed) X movement Y movement (1 if pressed)
|
||||
|
||||
|
||||
First three bytes are equal to Mouse mode packet.
|
||||
Movement values are 8-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/downward.
|
||||
Wheel movement is a 4-bit signed twos complement integer.
|
||||
Positive wheel movement value indicates rotation downward.
|
||||
|
||||
|
||||
===========================================================================
|
||||
PS/2 standard mode protocol:
|
||||
|
||||
1st byte 2nd byte 3rd byte
|
||||
+---------------+ +---------------+ +---------------+
|
||||
|?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y|
|
||||
+---------------+ +---------------+ +---------------+
|
||||
| | | | | \------+------/ \------+------/
|
||||
| | | | | | |
|
||||
+-|---|-|-|----------|-----------+ |
|
||||
+---|-|-|--+ | | |
|
||||
| | | | /-----+-------\ | /---+---------\
|
||||
Middle Button ------+ | | +-----------------+ +-----------------+
|
||||
Right Button --------+ | | | | | | | | | | | | | | | | | | | | |
|
||||
Left Button ----------+ +-----------------+ +-----------------+
|
||||
(1 if pressed) X movement Y movement
|
||||
|
||||
|
||||
Two most significant bits in first byte indicate overflow (more than 9 bits
|
||||
of movement) in each direction. Usually ignored.
|
||||
Movement values are 9-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/upward.
|
||||
|
||||
|
||||
===========================================================================
|
||||
PS/2 wheel mode protocol:
|
||||
|
||||
1st byte 2nd byte 3rd byte 4th byte
|
||||
+---------------+ +---------------+ +---------------+ +---------------+
|
||||
|?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| |w|w|w|w|W|W|W|W|
|
||||
+---------------+ +---------------+ +---------------+ +---------------+
|
||||
| | | | | \------+------/ \------+------/ \-------+-----/
|
||||
| | | | | | | |
|
||||
+-|---|-|-|----------|-----------+ | |
|
||||
+---|-|-|--+ | | | |
|
||||
| | | | /-----+-------\ | /---+---------\ |
|
||||
Middle Button ------+ | | +-----------------+ +-----------------+ |
|
||||
Right Button --------+ | | | | | | | | | | | | | | | | | | | | | |
|
||||
Left Button ----------+ +-----------------+ +-----------------+ Wheel
|
||||
(1 if pressed) X movement Y movement Movement
|
||||
|
||||
|
||||
First three bytes are equal to PS/2 standard mode packet.
|
||||
Two most significant bits in first byte indicate overflow (more than 9 bits
|
||||
of movement) in each direction. Usually ignored.
|
||||
Movement values are 9-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/upward.
|
||||
Wheel movement is a 8-bit signed twos complement integer and usually
|
||||
limited by -8..+7 range (4-bit value).
|
||||
Positive wheel movement value indicates rotation downward.
|
||||
|
||||
|
||||
===========================================================================
|
||||
PS/2 extended mode protocol:
|
||||
|
||||
1st byte 2nd byte 3rd byte 4th byte
|
||||
+---------------+ +---------------+ +---------------+ +---------------+
|
||||
|?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| |0|0|B|F|W|W|W|W|
|
||||
+---------------+ +---------------+ +---------------+ +---------------+
|
||||
| | | | | \------+------/ \------+------/ | | \--+--/
|
||||
| | | | | | | | | |
|
||||
+-|---|-|-|----------|-----------+ | | | |
|
||||
+---|-|-|--+ | | | | | Wheel
|
||||
| | | | /-----+-------\ | /---+---------\ | | Movement
|
||||
Middle Button ------+ | | +-----------------+ +-----------------+ | |
|
||||
Right Button --------+ | | | | | | | | | | | | | | | | | | | | | | +- Forward Button
|
||||
Left Button ----------+ +-----------------+ +-----------------+ +--- Back Button
|
||||
(1 if pressed) X movement Y movement (1 if pressed)
|
||||
|
||||
|
||||
First three bytes are equal to PS/2 standard mode packet.
|
||||
Two most significant bits in first byte indicate overflow (more than 9 bits
|
||||
of movement) in each direction. Usually ignored.
|
||||
Movement values are 9-bit signed twos complement integers.
|
||||
Positive movement value indicates motion to the right/upward.
|
||||
Wheel movement is a 4-bit signed twos complement integer.
|
||||
Positive wheel movement value indicates rotation downward.
|
||||
@@ -1,8 +1,23 @@
|
||||
/* Copyright holders: Riley
|
||||
see COPYING for more details
|
||||
|
||||
win_crashdump.c : Windows exception handler to make a crash dump just before a crash happens.
|
||||
*/
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Handle generation of crash-dump reports.
|
||||
*
|
||||
* Version: @(#)win_crashdump.c 1.0.2 2017/11/12
|
||||
*
|
||||
* Authors: Riley
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2016,2017 Riley.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*/
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
@@ -110,41 +125,41 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
return(EXCEPTION_CONTINUE_SEARCH);
|
||||
}
|
||||
|
||||
// Now the file is open, let's write the data we were passed out in a human-readable format.
|
||||
|
||||
// Let's get the name of the module where the exception occured.
|
||||
/*
|
||||
* Write the data we were passed out in a human-readable format.
|
||||
*
|
||||
* Get the name of the module where the exception occurred.
|
||||
*/
|
||||
HMODULE hMods[1024];
|
||||
MODULEINFO modInfo;
|
||||
HMODULE ipModule = 0;
|
||||
DWORD cbNeeded;
|
||||
|
||||
// Try to get a list of all loaded modules.
|
||||
/* Try to get a list of all loaded modules. */
|
||||
if (EnumProcessModules(GetCurrentProcess(),
|
||||
hMods, sizeof(hMods), &cbNeeded)) {
|
||||
// The list was obtained, walk through each of the modules.
|
||||
/* Got it, now walk through all modules.. */
|
||||
for (DWORD i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||
// For each module, get the module information
|
||||
// (base address, size, entry point)
|
||||
/* For each module, get the module information. */
|
||||
GetModuleInformation(GetCurrentProcess(),
|
||||
hMods[i], &modInfo, sizeof(MODULEINFO));
|
||||
// If the exception address is located in the range of
|
||||
// where this module is loaded...
|
||||
/* If the exception address is in the range of this module.. */
|
||||
if ( (ExceptionInfo->ExceptionRecord->ExceptionAddress >= modInfo.lpBaseOfDll) &&
|
||||
(ExceptionInfo->ExceptionRecord->ExceptionAddress < (modInfo.lpBaseOfDll + modInfo.SizeOfImage))) {
|
||||
// ...this is the module we're looking for!
|
||||
/* ...this is the module we're looking for! */
|
||||
ipModule = hMods[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start to put the crash-dump string into the buffer.
|
||||
/* Start to put the crash-dump string into the buffer. */
|
||||
sprintf(ExceptionHandlerBuffer,
|
||||
"%s crashed on %d-%02d-%02d %02d:%02d:%02d.%03d\r\n\r\n"
|
||||
""
|
||||
"#\r\n# %s\r\n#\r\n"
|
||||
"# Crash on %d-%02d-%02d at %02d:%02d:%02d.%03d\r\n#\r\n"
|
||||
"\r\n"
|
||||
"Exception details:\r\n"
|
||||
"Exception NTSTATUS code: 0x%08lx\r\n"
|
||||
"Occured at address: 0x%p",
|
||||
" NTSTATUS code: 0x%08lx\r\n Address: 0x%p",
|
||||
emu_version,
|
||||
SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay,
|
||||
SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond,
|
||||
@@ -152,7 +167,10 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
ExceptionInfo->ExceptionRecord->ExceptionCode,
|
||||
(void *)ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
||||
|
||||
// If we found the module that the exception occured in, get the full path to the module the exception occured at and include it.
|
||||
/*
|
||||
* If we found the correct module, get the full path to
|
||||
* the module the exception occured at and include it.
|
||||
*/
|
||||
BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
if (ipModule != 0) {
|
||||
sprintf(BufPtr," [");
|
||||
@@ -165,14 +183,10 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
}
|
||||
}
|
||||
|
||||
// Continue to create the crash-dump string.
|
||||
sprintf(BufPtr,
|
||||
"\r\n"
|
||||
"Number of parameters: %lu\r\n"
|
||||
"Exception parameters: ",
|
||||
"\r\nNumber of parameters: %lu\r\nException parameters: ",
|
||||
ExceptionInfo->ExceptionRecord->NumberParameters);
|
||||
|
||||
// Add the exception parameters to the crash-dump string.
|
||||
for (int i = 0; i < ExceptionInfo->ExceptionRecord->NumberParameters; i++) {
|
||||
BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)];
|
||||
sprintf(BufPtr,"0x%p ",
|
||||
@@ -183,32 +197,35 @@ LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
PCONTEXT Registers = ExceptionInfo->ContextRecord;
|
||||
|
||||
#if defined(__i386__) && !defined(__x86_64)
|
||||
// This binary is being compiled for x86, include a register dump.
|
||||
/* This binary is being compiled for x86, include a register dump. */
|
||||
sprintf(BufPtr,
|
||||
"\r\n"
|
||||
"Register dump:\r\n"
|
||||
"eax=0x%08lx ebx=0x%08lx ecx=0x%08lx edx=0x%08lx ebp=0x%08lx esp=0x%08lx esi=0x%08lx edi=0x%08lx eip=0x%08lx\r\n"
|
||||
"\r\n",
|
||||
Registers->Eax, Registers->Ebx, Registers->Ecx, Registers->Edx, Registers->Ebp, Registers->Esp, Registers->Esi, Registers->Edi, Registers->Eip);
|
||||
"\r\n\r\nRegister dump:\r\n\r\n"
|
||||
"EIP:0x%08lx\r\n"
|
||||
"EAX:0x%08lx EBX:0x%08lx ECX:0x%08lx EDX:0x%08lx\r\n"
|
||||
"EBP:0x%08lx ESP:0x%08lx ESI:0x%08lx EDI:0x%08lx\r\n\r\n",
|
||||
Registers->Eip,
|
||||
Registers->Eax, Registers->Ebx, Registers->Ecx, Registers->Edx,
|
||||
Registers->Ebp, Registers->Esp, Registers->Esi, Registers->Edi);
|
||||
#else
|
||||
// Register dump is supported by no other architectures right now. MinGW headers seem to lack the x64 CONTEXT structure definition.
|
||||
sprintf(BufPtr,"\r\n");
|
||||
/* Register dump not supported by this architecture. */
|
||||
/* (MinGW headers seem to lack the x64 CONTEXT structure definition) */
|
||||
sprintf(BufPtr, "\r\n");
|
||||
#endif
|
||||
|
||||
// The crash-dump string has been created, write it to disk.
|
||||
/* Write the string to disk. */
|
||||
WriteFile(hDumpFile, ExceptionHandlerBuffer,
|
||||
strlen(ExceptionHandlerBuffer), NULL, NULL);
|
||||
|
||||
// Finally, close the file.
|
||||
/* Close the file. */
|
||||
CloseHandle(hDumpFile);
|
||||
|
||||
// And return, therefore causing the crash,
|
||||
// but only after the crash dump has been created.
|
||||
/* Return, therefore causing the crash. */
|
||||
return(EXCEPTION_CONTINUE_SEARCH);
|
||||
}
|
||||
|
||||
|
||||
void InitCrashDump(void)
|
||||
void
|
||||
InitCrashDump(void)
|
||||
{
|
||||
/*
|
||||
* An exception handler should not allocate memory,
|
||||
|
||||
Reference in New Issue
Block a user