Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
debug_dlg.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
20// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/debug_dlg/debug_dlg.cpp $
21// $Author: mhoffe $
22// $Revision: #1 $
23// $DateTime: 2003/07/03 11:55:26 $
24//
25// ©2003 Electronic Arts
26//
27// Debug exception dialog test program
29#define STRICT
30#define WIN32_LEAN_AND_MEAN
31#include <windows.h>
32#include <commctrl.h>
33#include <stdio.h>
34
35// Pardon my coding here but this is for testing only...
36
37#pragma comment (lib,"comctl32")
38
39BOOL CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
40{
41 switch(uMsg)
42 {
43 case WM_INITDIALOG:
44 {
45 SendDlgItemMessage(hWnd,100,WM_SETTEXT,0,(LPARAM)"EXCEPTION_TYPE");
46 SendDlgItemMessage(hWnd,101,WM_SETTEXT,0,(LPARAM)"Explains exception type further here...\n"
47 "123456789012345678901234567890123456789012345678901234567890");
48 SendDlgItemMessage(hWnd,102,WM_SETTEXT,0,(LPARAM)"Module/File/Line, Address");
49 SendDlgItemMessage(hWnd,103,WM_SETTEXT,0,(LPARAM)"File version, build type");
50
51 HWND list;
52 list=GetDlgItem(hWnd,104);
53
54 LVCOLUMN c;
55 c.mask=LVCF_TEXT|LVCF_WIDTH;
56 c.pszText="";
57 c.cx=0;
58 ListView_InsertColumn(list,0,&c);
59
60 c.mask=LVCF_TEXT|LVCF_WIDTH|LVCF_FMT;
61 c.pszText="Address";
62 c.cx=60;
63 c.fmt=LVCFMT_RIGHT;
64 ListView_InsertColumn(list,1,&c);
65
66 c.mask=LVCF_TEXT|LVCF_WIDTH;
67 c.pszText="Module";
68 c.cx=120;
69 ListView_InsertColumn(list,2,&c);
70
71 c.pszText="Symbol";
72 c.cx=300;
73 ListView_InsertColumn(list,3,&c);
74
75 c.pszText="File";
76 c.cx=130;
77 ListView_InsertColumn(list,4,&c);
78
79 c.pszText="Line";
80 c.cx=80;
81 ListView_InsertColumn(list,5,&c);
82
83 LVITEM item;
84 item.iItem=0;
85 item.iSubItem=0;
86 item.mask=0;
87
88 item.iItem=ListView_InsertItem(list,&item);
89 item.mask=LVIF_TEXT;
90
91 item.iSubItem++;
92 item.pszText="01234567";
93 ListView_SetItem(list,&item);
94
95 item.iSubItem++;
96 item.pszText="MSVCRTD.dll+0xad38";
97 ListView_SetItem(list,&item);
98
99 item.iSubItem++;
100 item.pszText="mainCRTStartupSuperLongSymbolOYeahThisIsCool+0xd23e0";
101 ListView_SetItem(list,&item);
102
103 item.iSubItem++;
104 item.pszText="reallyreallyverylongfilename.cpp";
105 ListView_SetItem(list,&item);
106
107 item.iSubItem++;
108 item.pszText="5748+0xad38";
109 ListView_SetItem(list,&item);
110
111 for (int k=1;k<30;k++)
112 {
113 item.iItem=k;
114 item.iSubItem=0;
115 item.iItem=ListView_InsertItem(list,&item);
116 item.mask=LVIF_TEXT;
117
118 item.iSubItem++;
119 item.pszText="88888888";
120 ListView_SetItem(list,&item);
121
122 item.iSubItem++;
123 item.pszText="MSVCRTD.dll+0xad38";
124 ListView_SetItem(list,&item);
125
126 item.iSubItem++;
127 item.pszText="Debug::DebugException::Symbol+0xd23e0";
128 ListView_SetItem(list,&item);
129
130 item.iSubItem++;
131 item.pszText="regularfilename.cpp";
132 ListView_SetItem(list,&item);
133
134 item.iSubItem++;
135 item.pszText="5748+0x38";
136 ListView_SetItem(list,&item);
137 }
138
139 HFONT hf;
140 hf=CreateFont(13,0,0,0,FW_NORMAL,
141 FALSE,FALSE,FALSE,ANSI_CHARSET,
142 OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
143 DEFAULT_QUALITY,FIXED_PITCH|FF_MODERN,NULL);
144 SendDlgItemMessage(hWnd,105,WM_SETFONT,(WPARAM)hf,MAKELPARAM(TRUE,0));
145 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EAX:0x00000666 EBX:0x7ffdf000 ECX:0x00000000");
146 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EDX:0x00422208 ESI:0x02100210 EDI:0x0012fec4");
147 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EIP:0x0040103d ESP:0x0012fe78 EBP:0x0012fec4");
148 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"Flags:%00000000000000010000001000000110");
149 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"CS:0x001b DS:0x0023 SS:0x0023");
150 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ES:0x0023 FS:0x0038 GS:0x0000");
151 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"");
152 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"CW:%0000001001111111");
153 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"SW:%0000000000000000");
154 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"TW:%1111111111111111");
155 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ErrOfs: 0x00000000 ErrSel: 0x03020000");
156 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"DataOfs: 0x00000000 DataSel: 0xffff0000");
157 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"Cr0NpxState: 0x00000000");
158 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(0) 10020203100210021002 -1.#IND00");
159 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(1) 01031002010320020103 -1.#IND00");
160 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(2) 10021002100210021002 -1.#IND00");
161 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(3) 02031002020320020203 -1.#IND00");
162 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(4) 10021002100210021002 -1.#IND00");
163 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(5) 12031002100210021002 -1.#IND00");
164 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(6) 14021402100212031002 -1.#IND00");
165 SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(7) 12031002100210021002 -1.#IND00");
166 }
167 return TRUE;
168 case WM_COMMAND:
169 switch(LOWORD(wParam))
170 {
171 case IDOK:
172 EndDialog(hWnd,IDOK);
173 break;
174 }
175 return FALSE;
176 default:
177 return FALSE;
178 }
179}
180
181int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int)
182{
183 // show dialog box first
184 InitCommonControls();
185 DialogBox(hInst,MAKEINTRESOURCE(100),NULL,DialogProc);
186
187 // write out resource data (if possible)
188 FILE *f=fopen("..\\rc_exception.inl","wt");
189 if (f)
190 {
191 fprintf(f,"static unsigned char rcException[]={ // program generated, do not edit\n");
192
193 HRSRC h=FindResource(hInst,MAKEINTRESOURCE(100),RT_DIALOG);
194 DWORD size=SizeofResource(hInst,h);
195
196 unsigned char *data=(unsigned char *)LockResource(LoadResource(hInst,h));
197 for (unsigned k=0;k<size;k+=8)
198 {
199 for (unsigned i=0;i<8;i++)
200 fprintf(f,"0x%02x,",k+i<size?data[k+i]:0);
201 fprintf(f,"\n");
202 }
203
204 fprintf(f,"0 };\n");
205 fclose(f);
206 }
207
208 return 0;
209}
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
unsigned int UINT
Definition bittype.h:63
unsigned long DWORD
Definition bittype.h:57
#define BOOL
Definition Wnd_File.h:57
int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int)
BOOL CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition debug_dlg.cpp:39
HINSTANCE hInst
Definition test2.cpp:37