debug_dlg.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. /////////////////////////////////////////////////////////////////////////EA-V1
  19. // $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/debug_dlg/debug_dlg.cpp $
  20. // $Author: mhoffe $
  21. // $Revision: #1 $
  22. // $DateTime: 2003/07/03 11:55:26 $
  23. //
  24. // ©2003 Electronic Arts
  25. //
  26. // Debug exception dialog test program
  27. //////////////////////////////////////////////////////////////////////////////
  28. #define STRICT
  29. #define WIN32_LEAN_AND_MEAN
  30. #include <windows.h>
  31. #include <commctrl.h>
  32. #include <stdio.h>
  33. // Pardon my coding here but this is for testing only...
  34. #pragma comment (lib,"comctl32")
  35. BOOL CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  36. {
  37. switch(uMsg)
  38. {
  39. case WM_INITDIALOG:
  40. {
  41. SendDlgItemMessage(hWnd,100,WM_SETTEXT,0,(LPARAM)"EXCEPTION_TYPE");
  42. SendDlgItemMessage(hWnd,101,WM_SETTEXT,0,(LPARAM)"Explains exception type further here...\n"
  43. "123456789012345678901234567890123456789012345678901234567890");
  44. SendDlgItemMessage(hWnd,102,WM_SETTEXT,0,(LPARAM)"Module/File/Line, Address");
  45. SendDlgItemMessage(hWnd,103,WM_SETTEXT,0,(LPARAM)"File version, build type");
  46. HWND list;
  47. list=GetDlgItem(hWnd,104);
  48. LVCOLUMN c;
  49. c.mask=LVCF_TEXT|LVCF_WIDTH;
  50. c.pszText="";
  51. c.cx=0;
  52. ListView_InsertColumn(list,0,&c);
  53. c.mask=LVCF_TEXT|LVCF_WIDTH|LVCF_FMT;
  54. c.pszText="Address";
  55. c.cx=60;
  56. c.fmt=LVCFMT_RIGHT;
  57. ListView_InsertColumn(list,1,&c);
  58. c.mask=LVCF_TEXT|LVCF_WIDTH;
  59. c.pszText="Module";
  60. c.cx=120;
  61. ListView_InsertColumn(list,2,&c);
  62. c.pszText="Symbol";
  63. c.cx=300;
  64. ListView_InsertColumn(list,3,&c);
  65. c.pszText="File";
  66. c.cx=130;
  67. ListView_InsertColumn(list,4,&c);
  68. c.pszText="Line";
  69. c.cx=80;
  70. ListView_InsertColumn(list,5,&c);
  71. LVITEM item;
  72. item.iItem=0;
  73. item.iSubItem=0;
  74. item.mask=0;
  75. item.iItem=ListView_InsertItem(list,&item);
  76. item.mask=LVIF_TEXT;
  77. item.iSubItem++;
  78. item.pszText="01234567";
  79. ListView_SetItem(list,&item);
  80. item.iSubItem++;
  81. item.pszText="MSVCRTD.dll+0xad38";
  82. ListView_SetItem(list,&item);
  83. item.iSubItem++;
  84. item.pszText="mainCRTStartupSuperLongSymbolOYeahThisIsCool+0xd23e0";
  85. ListView_SetItem(list,&item);
  86. item.iSubItem++;
  87. item.pszText="reallyreallyverylongfilename.cpp";
  88. ListView_SetItem(list,&item);
  89. item.iSubItem++;
  90. item.pszText="5748+0xad38";
  91. ListView_SetItem(list,&item);
  92. for (int k=1;k<30;k++)
  93. {
  94. item.iItem=k;
  95. item.iSubItem=0;
  96. item.iItem=ListView_InsertItem(list,&item);
  97. item.mask=LVIF_TEXT;
  98. item.iSubItem++;
  99. item.pszText="88888888";
  100. ListView_SetItem(list,&item);
  101. item.iSubItem++;
  102. item.pszText="MSVCRTD.dll+0xad38";
  103. ListView_SetItem(list,&item);
  104. item.iSubItem++;
  105. item.pszText="Debug::DebugException::Symbol+0xd23e0";
  106. ListView_SetItem(list,&item);
  107. item.iSubItem++;
  108. item.pszText="regularfilename.cpp";
  109. ListView_SetItem(list,&item);
  110. item.iSubItem++;
  111. item.pszText="5748+0x38";
  112. ListView_SetItem(list,&item);
  113. }
  114. HFONT hf;
  115. hf=CreateFont(13,0,0,0,FW_NORMAL,
  116. FALSE,FALSE,FALSE,ANSI_CHARSET,
  117. OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
  118. DEFAULT_QUALITY,FIXED_PITCH|FF_MODERN,NULL);
  119. SendDlgItemMessage(hWnd,105,WM_SETFONT,(WPARAM)hf,MAKELPARAM(TRUE,0));
  120. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EAX:0x00000666 EBX:0x7ffdf000 ECX:0x00000000");
  121. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EDX:0x00422208 ESI:0x02100210 EDI:0x0012fec4");
  122. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EIP:0x0040103d ESP:0x0012fe78 EBP:0x0012fec4");
  123. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"Flags:%00000000000000010000001000000110");
  124. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"CS:0x001b DS:0x0023 SS:0x0023");
  125. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ES:0x0023 FS:0x0038 GS:0x0000");
  126. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"");
  127. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"CW:%0000001001111111");
  128. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"SW:%0000000000000000");
  129. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"TW:%1111111111111111");
  130. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ErrOfs: 0x00000000 ErrSel: 0x03020000");
  131. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"DataOfs: 0x00000000 DataSel: 0xffff0000");
  132. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"Cr0NpxState: 0x00000000");
  133. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(0) 10020203100210021002 -1.#IND00");
  134. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(1) 01031002010320020103 -1.#IND00");
  135. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(2) 10021002100210021002 -1.#IND00");
  136. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(3) 02031002020320020203 -1.#IND00");
  137. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(4) 10021002100210021002 -1.#IND00");
  138. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(5) 12031002100210021002 -1.#IND00");
  139. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(6) 14021402100212031002 -1.#IND00");
  140. SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"ST(7) 12031002100210021002 -1.#IND00");
  141. }
  142. return TRUE;
  143. case WM_COMMAND:
  144. switch(LOWORD(wParam))
  145. {
  146. case IDOK:
  147. EndDialog(hWnd,IDOK);
  148. break;
  149. }
  150. return FALSE;
  151. default:
  152. return FALSE;
  153. }
  154. }
  155. int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int)
  156. {
  157. // show dialog box first
  158. InitCommonControls();
  159. DialogBox(hInst,MAKEINTRESOURCE(100),NULL,DialogProc);
  160. // write out resource data (if possible)
  161. FILE *f=fopen("..\\rc_exception.inl","wt");
  162. if (f)
  163. {
  164. fprintf(f,"static unsigned char rcException[]={ // program generated, do not edit\n");
  165. HRSRC h=FindResource(hInst,MAKEINTRESOURCE(100),RT_DIALOG);
  166. DWORD size=SizeofResource(hInst,h);
  167. unsigned char *data=(unsigned char *)LockResource(LoadResource(hInst,h));
  168. for (unsigned k=0;k<size;k+=8)
  169. {
  170. for (unsigned i=0;i<8;i++)
  171. fprintf(f,"0x%02x,",k+i<size?data[k+i]:0);
  172. fprintf(f,"\n");
  173. }
  174. fprintf(f,"0 };\n");
  175. fclose(f);
  176. }
  177. return 0;
  178. }