1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// ASSERT_DIALOG.CPP
//
// Handle Remote Assert().
//=====================================================================================//
#include "vxconsole.h"
AssertAction_t g_AssertAction = ASSERT_ACTION_BREAK;
static const char * g_AssertInfo = "Assert Info Not Available.";
bool g_AssertDialogActive = false;
//-----------------------------------------------------------------------------
// AssertDialogProc
//
//-----------------------------------------------------------------------------
int CALLBACK AssertDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg )
{
case WM_INITDIALOG:
{
SetWindowText( hDlg, "Xbox 360 Assert!" );
SetDlgItemText( hDlg, IDC_FILENAME_CONTROL, g_AssertInfo );
// Center the dialog.
RECT rcDlg, rcDesktop;
GetWindowRect( hDlg, &rcDlg );
GetWindowRect( GetDesktopWindow(), &rcDesktop );
SetWindowPos(
hDlg,
HWND_TOP,
((rcDesktop.right-rcDesktop.left) - (rcDlg.right-rcDlg.left)) / 2,
((rcDesktop.bottom-rcDesktop.top) - (rcDlg.bottom-rcDlg.top)) / 2,
0,
0,
SWP_NOSIZE );
}
return true;
case WM_COMMAND:
{
switch( LOWORD( wParam ) )
{
// Ignore Asserts in this file from now on.
case IDC_IGNORE_FILE:
{
g_AssertAction = ASSERT_ACTION_IGNORE_FILE;
EndDialog( hDlg, 0 );
return true;
}
// Ignore this Assert once.
case IDC_IGNORE_THIS:
{
g_AssertAction = ASSERT_ACTION_IGNORE_THIS;
EndDialog( hDlg, 0 );
return true;
}
// Always ignore this Assert.
case IDC_IGNORE_ALWAYS:
{
g_AssertAction = ASSERT_ACTION_IGNORE_ALWAYS;
EndDialog( hDlg, 0 );
return true;
}
// Ignore all Asserts from now on.
case IDC_IGNORE_ALL:
{
g_AssertAction = ASSERT_ACTION_IGNORE_ALL;
EndDialog( hDlg, 0 );
return true;
}
case IDC_BREAK:
{
g_AssertAction = ASSERT_ACTION_BREAK;
EndDialog( hDlg, 0 );
return true;
}
}
case WM_KEYDOWN:
{
// Escape?
if ( wParam == 2 )
{
// Ignore this Assert.
g_AssertAction = ASSERT_ACTION_IGNORE_THIS;
EndDialog( hDlg, 0 );
return true;
}
}
}
return true;
}
return FALSE;
}
//-----------------------------------------------------------------------------
// rc_Assert
//
// Sent from application on hitting an Assert
//-----------------------------------------------------------------------------
int rc_Assert( char* commandPtr )
{
char* cmdToken;
int retAddr;
int errCode = -1;
// Flash the taskbar icon (otherwise users may not realise the app has stalled on an Assert, esp. during loading)
FLASHWINFO flashWInfo = { sizeof(FLASHWINFO), g_hDlgMain, FLASHW_ALL|FLASHW_TIMERNOFG, 0, 1000 };
FlashWindowEx( &flashWInfo );
// get retAddr
cmdToken = GetToken( &commandPtr );
if ( !cmdToken[0] )
goto cleanUp;
if (1 != sscanf( cmdToken, "%x", &retAddr ))
goto cleanUp;
// skip whitespace
while ( commandPtr[0] == ' ' )
{
commandPtr++;
}
// Display file/line/expression info from the message in the Assert dialog
// (convert '\t' to '\n'; way simpler than tokenizing a general assert expression)
g_AssertInfo = commandPtr;
char *tab = commandPtr;
while( ( tab = strchr( tab, '\t' ) ) != NULL )
{
tab[0] = '\n';
}
// Open the Assert dialog, to determine the desired action
g_AssertAction = ASSERT_ACTION_BREAK;
g_AssertDialogActive = true;
DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_ASSERT_DIALOG ), g_hDlgMain, ( DLGPROC )AssertDialogProc );
g_AssertDialogActive = false;
// Write the (endian-converted) result directly back into the application's memory:
int xboxRetVal = BigDWord( g_AssertAction );
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
// success
errCode = 0;
cleanUp:
return errCode;
}
|