|
|
@ -129,22 +129,19 @@ static uint32 CalcCRC(byte *data, uint size, uint32 crc) {
|
|
|
|
|
|
|
|
|
|
|
|
static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
|
|
|
static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
HANDLE file;
|
|
|
|
memset(dfi, 0, sizeof(dfi));
|
|
|
|
memset(dfi, 0, sizeof(dfi));
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
|
|
|
HANDLE file;
|
|
|
|
if (file != INVALID_HANDLE_VALUE) {
|
|
|
|
byte buffer[1024];
|
|
|
|
byte buffer[1024];
|
|
|
|
DWORD numread;
|
|
|
|
DWORD numread;
|
|
|
|
uint32 filesize = 0;
|
|
|
|
uint32 filesize = 0;
|
|
|
|
FILETIME write_time;
|
|
|
|
FILETIME write_time;
|
|
|
|
uint32 crc = (uint32)-1;
|
|
|
|
uint32 crc = (uint32)-1;
|
|
|
|
|
|
|
|
|
|
|
|
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
|
|
|
|
OPEN_EXISTING, 0, 0);
|
|
|
|
|
|
|
|
if (file != INVALID_HANDLE_VALUE) {
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
|
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 ||
|
|
|
|
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0)
|
|
|
|
numread == 0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
filesize += numread;
|
|
|
|
filesize += numread;
|
|
|
|
crc = CalcCRC(buffer, numread, crc);
|
|
|
|
crc = CalcCRC(buffer, numread, crc);
|
|
|
@ -157,7 +154,6 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CloseHandle(file);
|
|
|
|
CloseHandle(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -185,23 +181,22 @@ static char *PrintModuleInfo(char *output, HMODULE mod)
|
|
|
|
|
|
|
|
|
|
|
|
static char *PrintModuleList(char *output)
|
|
|
|
static char *PrintModuleList(char *output)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BOOL (WINAPI *EnumProcessModules)(HANDLE,HMODULE*,DWORD,LPDWORD);
|
|
|
|
BOOL (WINAPI *EnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD);
|
|
|
|
HANDLE proc;
|
|
|
|
|
|
|
|
|
|
|
|
if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) {
|
|
|
|
HMODULE modules[100];
|
|
|
|
HMODULE modules[100];
|
|
|
|
DWORD needed;
|
|
|
|
DWORD needed;
|
|
|
|
BOOL res;
|
|
|
|
BOOL res;
|
|
|
|
int count,i;
|
|
|
|
int count, i;
|
|
|
|
|
|
|
|
|
|
|
|
if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) {
|
|
|
|
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
|
|
|
proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
|
|
|
if (proc != NULL) {
|
|
|
|
if (proc) {
|
|
|
|
|
|
|
|
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
|
|
|
|
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
|
|
|
|
CloseHandle(proc);
|
|
|
|
CloseHandle(proc);
|
|
|
|
if (res) {
|
|
|
|
if (res) {
|
|
|
|
count =
|
|
|
|
count = min(needed / sizeof(HMODULE), lengthof(modules));
|
|
|
|
min(needed / sizeof(HMODULE), lengthof(modules));
|
|
|
|
|
|
|
|
for (i = 0; i != count; i++)
|
|
|
|
for (i = 0; i != count; i++) output = PrintModuleInfo(output, modules[i]);
|
|
|
|
output = PrintModuleInfo(output, modules[i]);
|
|
|
|
|
|
|
|
return output;
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -257,7 +252,6 @@ static const char wininet_files[] =
|
|
|
|
|
|
|
|
|
|
|
|
static WinInetProcs _wininet;
|
|
|
|
static WinInetProcs _wininet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const TCHAR *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const TCHAR *arg)
|
|
|
|
static const TCHAR *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const TCHAR *arg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HINTERNET inet, conn, http;
|
|
|
|
HINTERNET inet, conn, http;
|
|
|
@ -378,17 +372,16 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
|
|
|
|
} return TRUE;
|
|
|
|
} return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (wParam) {
|
|
|
|
switch (wParam) {
|
|
|
|
case 12: // Close
|
|
|
|
case 12: /* Close */
|
|
|
|
ExitProcess(0);
|
|
|
|
ExitProcess(0);
|
|
|
|
case 13: { // Emergency save
|
|
|
|
case 13: /* Emergency save */
|
|
|
|
if (DoEmergencySave(wnd)) {
|
|
|
|
if (DoEmergencySave(wnd)) {
|
|
|
|
MessageBox(wnd, _save_succeeded, _T("Save successful"), MB_ICONINFORMATION);
|
|
|
|
MessageBox(wnd, _save_succeeded, _T("Save successful"), MB_ICONINFORMATION);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
MessageBox(wnd, _T("Save failed"), _T("Save failed"), MB_ICONINFORMATION);
|
|
|
|
MessageBox(wnd, _T("Save failed"), _T("Save failed"), MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 14: { /* Submit crash report */
|
|
|
|
case 14: { // Submit crash report
|
|
|
|
|
|
|
|
const TCHAR *s;
|
|
|
|
const TCHAR *s;
|
|
|
|
|
|
|
|
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
|
@ -411,16 +404,14 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
|
|
|
|
EnableWindow(GetDlgItem(wnd, 14), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(wnd, 14), FALSE);
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
|
|
MessageBox(wnd, _T("Crash report submitted. Thank you."), _T("Crash Report"), MB_ICONINFORMATION);
|
|
|
|
MessageBox(wnd, _T("Crash report submitted. Thank you."), _T("Crash Report"), MB_ICONINFORMATION);
|
|
|
|
break;
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
case 15: /* Expand window to show crash-message */
|
|
|
|
case 15: // Expand
|
|
|
|
|
|
|
|
_expanded ^= 1;
|
|
|
|
_expanded ^= 1;
|
|
|
|
SetWndSize(wnd, _expanded);
|
|
|
|
SetWndSize(wnd, _expanded);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
case WM_CLOSE: ExitProcess(0);
|
|
|
|
ExitProcess(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
return FALSE;
|
|
|
@ -775,12 +766,10 @@ static int ParseCommandLine(char *line, char **argv, int max_argc)
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
// skip whitespace
|
|
|
|
// skip whitespace
|
|
|
|
while (*line == ' ' || *line == '\t')
|
|
|
|
while (*line == ' ' || *line == '\t') line++;
|
|
|
|
line++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// end?
|
|
|
|
// end?
|
|
|
|
if (*line == '\0')
|
|
|
|
if (*line == '\0') break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// special handling when quoted
|
|
|
|
// special handling when quoted
|
|
|
|
if (*line == '"') {
|
|
|
|
if (*line == '"') {
|
|
|
@ -808,7 +797,6 @@ void CreateConsole(void)
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO coninfo;
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO coninfo;
|
|
|
|
|
|
|
|
|
|
|
|
if (_has_console) return;
|
|
|
|
if (_has_console) return;
|
|
|
|
|
|
|
|
|
|
|
|
_has_console = true;
|
|
|
|
_has_console = true;
|
|
|
|
|
|
|
|
|
|
|
|
AllocConsole();
|
|
|
|
AllocConsole();
|
|
|
@ -883,7 +871,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|
|
|
|
|
|
|
|
|
|
|
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
|
|
|
|
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
|
|
|
|
|
|
|
|
|
|
|
|
// setup random seed to something quite random
|
|
|
|
/* setup random seed to something quite random */
|
|
|
|
_random_seeds[1][0] = _random_seeds[0][0] = GetTickCount();
|
|
|
|
_random_seeds[1][0] = _random_seeds[0][0] = GetTickCount();
|
|
|
|
_random_seeds[1][1] = _random_seeds[0][1] = _random_seeds[0][0] * 0x1234567;
|
|
|
|
_random_seeds[1][1] = _random_seeds[0][1] = _random_seeds[0][0] * 0x1234567;
|
|
|
|
SeedMT(_random_seeds[0][0]);
|
|
|
|
SeedMT(_random_seeds[0][0]);
|
|
|
|