From f512f292707ec9172214fadf731ae22d1cd1f66a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Feb 2019 08:50:49 +0100 Subject: [PATCH] - fixed crash log display. This still contained pieces where a multibyte string was passed through SendMessage and WM_SETTEXT. All these have been replaced with SetWindowTextW. This commit also removes the never used crash log upload code and all associated assets because it is extremely unlikely that such a feature will ever be implemented. --- src/win32/boing1.ico | Bin 766 -> 0 bytes src/win32/boing2.ico | Bin 766 -> 0 bytes src/win32/boing3.ico | Bin 766 -> 0 bytes src/win32/boing4.ico | Bin 766 -> 0 bytes src/win32/boing5.ico | Bin 766 -> 0 bytes src/win32/boing6.ico | Bin 766 -> 0 bytes src/win32/boing7.ico | Bin 766 -> 0 bytes src/win32/boing8.ico | Bin 766 -> 0 bytes src/win32/i_crash.cpp | 1079 ++--------------------------------------- src/win32/zdoom.rc | 30 -- 10 files changed, 30 insertions(+), 1079 deletions(-) delete mode 100644 src/win32/boing1.ico delete mode 100644 src/win32/boing2.ico delete mode 100644 src/win32/boing3.ico delete mode 100644 src/win32/boing4.ico delete mode 100644 src/win32/boing5.ico delete mode 100644 src/win32/boing6.ico delete mode 100644 src/win32/boing7.ico delete mode 100644 src/win32/boing8.ico diff --git a/src/win32/boing1.ico b/src/win32/boing1.ico deleted file mode 100644 index ba19283332f9ba4ecdd1b3dd557fa0edf058b526..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZvaF>-`33`IrAOlB)mr440nu{jz?pmn9IaFi`mQpPixDDTU#ursj{)|aLKjj&nA z9LHDF_=WzknKy&IeJHzCC^F?^(6gsj7*(FBgNH~I&z#n(%IN1j#^ zt8Kj?7ferGVS+mrfj5ql4Gd4U+^1j033d+J!`Lts2`xX-5pUZhcq(kaha@S-0b5yn zBNMUoc^!Vuu0Lk){FMQFxnYZ0k9E^w+%Da*#{oX)bW5x2Z*Yj~8&0^d(%{@p6X`$E CwrOnu diff --git a/src/win32/boing2.ico b/src/win32/boing2.ico deleted file mode 100644 index 083f6b21ca503e6cf88026fc602aceba8bbe5d4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZvaJx;|i5QH}b38e}ZEh)Lh<7hcTT35b`kMc^&l&pkUzFFt}N!VH2GoGDwoR|&t zWqCEVuP3uN<_}^aK8eAe8ENcYn$$f*%$kp_t5yV^MQe>&Oypw`S`l$WsY*Ix-V;vKw}GoZLg09?pv-?#Wnsp7YSaPO6?}ntYp7{fc9slqn3& zqGNet>|m=p78nhf_m#4;Jn$@9lrZq}qXj%~Av zXI&pn_I79X#Q1`*_$xlyJztF4VPa>8GFyLb+Z5qE1hrO1Wum_pp$O+uN}s>1l!)Tr zl@M;xMq&nIP%`1+(MsWSQKAJUQ3k;kCHCEHAq3OVim)dpr2tHY&^z{hPUg_)xX+dv z;0BYHfqhY@u!abqZ@B9+Y4p`(4~tMIK5$S7dNT^3g`G@`LSF%x?!`|Jls z1kC?sr#RYEL=eaxVFV}*tPONA6T2`g7})a!8W;_D+HMhO5QW|A)>@O~D3fyN|D3ft zqn`S8_%u6zm_6&1@P{j2%})5V-JIK{JNDbaKRHv)zS9*AX}zO~_E~eV&YY8}zW|C? BX|(_V diff --git a/src/win32/boing4.ico b/src/win32/boing4.ico deleted file mode 100644 index d8f60c0d6a9e5a99c8a2a991835ac7e7e4dee092..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZvaJ#ND=429{sK;g-qvesj7ksi%Q$f}7~(NQvH^jHB!+3!hKoB)+fnU8#Y`ZXKq z%kpk&w->V$|4(eezOcbw8ENEt6T4L?vewVmRUSsi$vN{^B7!6^s)sZ0hW~OSWU_P+dOq5#V9jh9mZ{kL!1FQq|z60XI?0`HPk=k|11#`?g-knfb#*Pi5D8~i5=>7Uy zQ6EDskM%kHnw@{lKDd<`d%I%UY{Z83FkYA5*mDCva)#XM#w!}q`bHD&v*utMZBC~C E1ODD>$p8QV diff --git a/src/win32/boing5.ico b/src/win32/boing5.ico deleted file mode 100644 index 085a991116a2abef89dff164c0151287493def78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZvaF>b>!3`OatK#|Fvx;A5Pksi%Q@XAS7@li5%^jHE#+4m*cPJl|Lq_6+=Y0)+t z=$Ff@seL_}y)l0f7vhr`?3s}Uw>7ET3GGbvv1!tZptD$(g;_gUAIsE=pleIRf30}Q z@SVwYHp(VGm-G_u8BO5{S0%GHU{G_u3mPR{d^J0FoY2kzPD>xm*qSw~=Hb4Q3?-80 zDI8LEJfB%Ltf|Bp6*KBo-r=IHC>virc1#w%VZ*zIYvLzD=1gTBqb@oQ^25N(prp^^ zfl+cnG2*KS1&E530wp!B1{@X+70{tNPU>a-M)2Og08%`36P3FQunnqL8x;y9#|Km< z?_aBHwuwxc%c=ejzh>7Tvv;zN#LJCX%ud8G9l_tFf9$b=?=`~$CQdgz3-l8`|LGD_k@BzfNg2nl9&VIfVE-r z2p6z5F~P*Z`@pz?IS+-qMsd!A15ieJ(arQlL!;%;wzd9M|F3?EGW)PS=FJT(D|3W7B#wZkO)Z;{e}trV7U93mVe;MicF`dT?)g HPg?&0kos&3 diff --git a/src/win32/boing7.ico b/src/win32/boing7.ico deleted file mode 100644 index a5864b22a8ecb608a4b36194acd159e2249dd60f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZvaF>b^#36dF)enCnsR&@tCZA*LpYSY z;{mu;(-fm3ETmaTIdBw3RJ6q#r{Pn_Ew1FMkpoi`tJ7^bRZlPUbLu8@8Kbs=03CpB z$7)DtN_mt@)fARMY#ONpjIBe6Av_#7iq4m7lN7eyP$j5L3v&ZOjB~1N4bpc%;CUgP zT>JVQe$6gFX75xT@s}&Un)P@$-<{W`H}+`YGpAcyUVlYHTHk1*eNhb_QmaYnKW86p Aw*UYD diff --git a/src/win32/boing8.ico b/src/win32/boing8.ico deleted file mode 100644 index 9fcbc853e97a040a58c6237e4cbc877bc807a089..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmZvaF>=Hp3`ONQGnuVOl{PMOi_Ot|1X?Pt;-hSta?3E233*>)?cJFG0>1Romoa7& zeOX>j?d!?xjr9Xtuup8VXJ#6)TN67@$g}#eb=3}|v)Q(dRi5s{de;u4%cbeR)_W;; zu~K_0rPV=A!X4LeKo*_lDn@N$*PYP(wBwe|5>(>M3~&ov-PHms 1) - { - UserSummary = (char *)HeapAlloc (GetProcessHeap(), 0, textlen); - if (UserSummary != NULL) - { - textlen = (DWORD)SendMessage (edit, WM_GETTEXT, textlen, (LPARAM)UserSummary); - } - } -} //========================================================================== // @@ -1889,46 +1804,49 @@ static INT_PTR CALLBACK OverviewDlgProc (HWND hDlg, UINT message, WPARAM wParam, switch (message) { case WM_INITDIALOG: + { if (pEnableThemeDialogTexture != NULL) { - pEnableThemeDialogTexture (hDlg, ETDT_ENABLETAB); + pEnableThemeDialogTexture(hDlg, ETDT_ENABLETAB); } // Setup the header at the top of the page. - edit = GetDlgItem (hDlg, IDC_CRASHHEADER); - SendMessage (edit, WM_SETTEXT, 0, (LPARAM)GAMENAME" has encountered a problem and needs to close.\n" + edit = GetDlgItem(hDlg, IDC_CRASHHEADER); + SetWindowTextW(edit, WGAMENAME" has encountered a problem and needs to close.\n" "We are sorry for the inconvenience."); - + // Setup a bold version of the standard dialog font and make the header bold. charFormat.cbSize = sizeof(charFormat); - SendMessage (edit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&charFormat); + SendMessageW(edit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&charFormat); charFormat.dwEffects = CFE_BOLD; - SendMessage (edit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&charFormat); + SendMessageW(edit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&charFormat); // Setup the drawing routine for the dying guy's bitmap. - edit = GetDlgItem (hDlg, IDC_DEADGUYVIEWER); - StdStaticProc = (WNDPROC)(LONG_PTR)SetWindowLongPtr (edit, GWLP_WNDPROC, (WLONG_PTR)(LONG_PTR)TransparentStaticProc); + edit = GetDlgItem(hDlg, IDC_DEADGUYVIEWER); + StdStaticProc = (WNDPROC)(LONG_PTR)SetWindowLongPtr(edit, GWLP_WNDPROC, (WLONG_PTR)(LONG_PTR)TransparentStaticProc); // Fill in all the text just below the heading. - edit = GetDlgItem (hDlg, IDC_PLEASETELLUS); - SendMessage (edit, EM_AUTOURLDETECT, TRUE, 0); - SendMessage (edit, WM_SETTEXT, 0, (LPARAM)"Please tell us about this problem.\n" + edit = GetDlgItem(hDlg, IDC_PLEASETELLUS); + SendMessageW(edit, EM_AUTOURLDETECT, TRUE, 0); + SetWindowTextW(edit, L"Please tell us about this problem.\n" "The information will NOT be sent to Microsoft.\n\n" "An error report has been created that you can submit to help improve " GAMENAME ". " "You can either save it to disk and make a report in the bugs forum at " FORUM_URL ", " "or you can send it directly without letting other people know about it."); - SendMessage (edit, EM_SETSEL, 0, 81); - SendMessage (edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&charFormat); - SendMessage (edit, EM_SETEVENTMASK, 0, ENM_LINK); + SendMessageW(edit, EM_SETSEL, 0, 81); + SendMessageW(edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&charFormat); + SendMessageW(edit, EM_SETEVENTMASK, 0, ENM_LINK); // Assign a default invalid file handle to the user's edit control. - edit = GetDlgItem (hDlg, IDC_CRASHINFO); - SetWindowLongPtr (edit, GWLP_USERDATA, (LONG_PTR)INVALID_HANDLE_VALUE); + edit = GetDlgItem(hDlg, IDC_CRASHINFO); + SetWindowLongPtrW(edit, GWLP_USERDATA, (LONG_PTR)INVALID_HANDLE_VALUE); // Fill in the summary text at the bottom of the page. - edit = GetDlgItem (hDlg, IDC_CRASHSUMMARY); - SendMessage (edit, WM_SETTEXT, 0, (LPARAM)CrashSummary); + edit = GetDlgItem(hDlg, IDC_CRASHSUMMARY); + auto wsum = WideString(CrashSummary); + SetWindowTextW(edit, wsum.c_str()); return TRUE; + } case WM_NOTIFY: // When the link in the "please tell us" edit control is clicked, open @@ -1940,17 +1858,12 @@ static INT_PTR CALLBACK OverviewDlgProc (HWND hDlg, UINT message, WPARAM wParam, if (link->msg == WM_LBUTTONDOWN) { ShellExecuteA (NULL, "open", BUGS_FORUM_URL, NULL, NULL, 0); - SetWindowLongPtr (hDlg, DWLP_MSGRESULT, 1); + SetWindowLongPtrW (hDlg, DWLP_MSGRESULT, 1); return TRUE; } } return FALSE; break; - - case WM_DESTROY: - // When this pane is destroyed, extract the user's summary. - AddDescriptionText (GetDlgItem (hDlg, IDC_CRASHINFO)); - break; } return FALSE; } @@ -2067,10 +1980,10 @@ static INT_PTR CALLBACK DetailsDlgProc (HWND hDlg, UINT message, WPARAM wParam, // Set up the file contents display: No undos. The control's // userdata stores the index of the file currently displayed. ctrl = GetDlgItem (hDlg, IDC_CRASHFILECONTENTS); - SendMessage (ctrl, EM_SETUNDOLIMIT, 0, 0); - SetWindowLongPtr (ctrl, GWLP_USERDATA, -1); + SendMessageW (ctrl, EM_SETUNDOLIMIT, 0, 0); + SetWindowLongPtrW (ctrl, GWLP_USERDATA, -1); SetEditControl (ctrl, GetDlgItem(hDlg, IDC_CRASHFILESIZE), 0); - SendMessage (ctrl, LB_SETCURSEL, 0, 0); + SendMessageW (ctrl, LB_SETCURSEL, 0, 0); break; case WM_SHOWWINDOW: @@ -2079,14 +1992,14 @@ static INT_PTR CALLBACK DetailsDlgProc (HWND hDlg, UINT message, WPARAM wParam, if (wParam == TRUE) { ctrl = GetDlgItem (hDlg, IDC_CRASHFILES); - j = (int)SendMessage (ctrl, LB_GETCURSEL, 0, 0); - SendMessage (ctrl, LB_RESETCONTENT, 0, 0); + j = (int)SendMessageW (ctrl, LB_GETCURSEL, 0, 0); + SendMessageW (ctrl, LB_RESETCONTENT, 0, 0); for (i = 0; i < NumFiles; ++i) { SendMessageA (ctrl, LB_ADDSTRING, 0, (LPARAM)TarFiles[i].Filename); } if (j == LB_ERR || j >= i) j = 0; - SendMessage (ctrl, LB_SETCURSEL, j, 0); + SendMessageW (ctrl, LB_SETCURSEL, j, 0); ctrl = GetDlgItem (hDlg, IDC_CRASHFILECONTENTS); if (j > 2) SetWindowLongPtr (ctrl, GWLP_USERDATA, -1); @@ -2301,931 +2214,6 @@ static void SetEditControl (HWND edit, HWND sizedisplay, int filenum) SendMessage (edit, EM_SETSEL, (WPARAM)-1, 0); } -#if 0 // Server-side support is not done yet - -//========================================================================== -// -// GetHeader -// -// Receives the HTTP header from a socket, up to and including the empty -// line that terminates the header. -// -//========================================================================== - -static char *GetHeader (SOCKET sock) -{ - DWORD spaceHave = 0, spaceAt = 0; - char *space = NULL; - char inchar; - int got; - - for (;;) - { - // Get one character - got = recv (sock, &inchar, 1, 0); - if (got != 1) - { -error: - if (space != NULL) HeapFree (GetProcessHeap(), 0, space); - return NULL; - } - // Append it to the header we have so far - if (space == NULL) - { - spaceHave = 256; - space = (char *)HeapAlloc (GetProcessHeap(), 0, 256); - } - else if (spaceAt == spaceHave-1) - { - spaceHave += 256; - space = (char *)HeapReAlloc (GetProcessHeap(), 0, space, spaceHave); - } - switch (spaceAt) - { - case 0: if (inchar != 'H') goto error; break; - case 1: if (inchar != 'T') goto error; break; - case 2: if (inchar != 'T') goto error; break; - case 3: if (inchar != 'P') goto error; break; - case 4: if (inchar != '/') goto error; break; - } - space[spaceAt++] = inchar; - if (inchar == '\n' && space[spaceAt-2] == '\r' && space[spaceAt-3] == '\n' && space[spaceAt-4] == '\r') - { // The header is complete - break; - } - } - space[spaceAt++] = '\0'; - if (spaceAt < 12) goto error; - return space; -} - -//========================================================================== -// -// UploadFail -// -// Stuffs some text into the status control to indicate what went wrong. -// -//========================================================================== - -static void UploadFail (HWND hDlg, const char *message, int reason) -{ - char buff[512]; - - mysnprintf (buff, countof(buff), "%s: %d", message, reason); - SetWindowText (GetDlgItem (hDlg, IDC_BOINGSTATUS), buff); - - if (reason >= 10000 && reason <= 11999) - { - LPVOID lpMsgBuf; - if (FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, - 0, - NULL)) - { - SetWindowText (GetDlgItem (hDlg, IDC_BOINGEDIT), (LPCSTR)lpMsgBuf); - LocalFree (lpMsgBuf); - } - } -} - -//========================================================================== -// -// GetChunkLen -// -// Returns the chunk length for a HTTP response using the chunked -// transfer-encoding. -// -//========================================================================== - -static int GetChunkLen (SOCKET sock) -{ - char crlf[2] = { '\r', '\n' }; - int len = 0; - int stage = 0; - char inchar; - - while (recv (sock, &inchar, 1, 0) == 1) - { - switch (stage) - { - case 0: // Checking for CRLF from the previous chunk - case 1: - if (inchar == crlf[stage]) { stage++; break; } - else stage = 2; - - case 2: // Reading length - if (inchar == ';') stage = 3; - else if (inchar >= '0' && inchar <= '9') len = (len << 4) | (inchar - '0'); - else if (inchar >= 'A' && inchar <= 'F') len = (len << 4) | ((inchar - 'A') + 10); - else if (inchar >= 'a' && inchar <= 'f') len = (len << 4) | ((inchar - 'a') + 10); - else if (inchar == '\r') stage = 4; - break; - - case 3: // Skipping chunk extension - case 4: - if (inchar == crlf[stage-3]) stage++; - else stage = 3; - if (stage == 5) - { - return len; - } - break; - } - } - return len; -} - -//========================================================================== -// -// TranslateHTML -// -// Converts HTML text into something closer to plain-text and appends it -// to the edit control's contents. -// -//========================================================================== - -struct TranslateHTML -{ - TranslateHTML (char *header, HWND editcontrol) - : edit(editcontrol), state(0), allowspace(false) - { - plaintext = strstr (header, "content-type: text/html") == NULL; - } - void Translate (char *buf); - - HWND edit; - int state; - bool allowspace; - char token[64]; - bool plaintext; -}; - -void TranslateHTML::Translate (char *buf) -{ - char *in, *out; - int tokenp = 0; - bool endrange = false; - bool inhead = false, inscript = false; - - if (plaintext) - { - SendMessage (edit, EM_REPLACESEL, 0, (LPARAM)buf); - return; - } - - for (in = out = buf; *in != 0; in++) - { - char x = *in; - switch (state) - { - case 0: // Not in a token - if (x == '<' || x == '&') - { - state = x == '<' ? 1 : 11; - } - else if (!inhead && !inscript) - { - if (x <= ' ') - { - if (allowspace) - { - allowspace = false; - *out++ = ' '; - } - } - else - { - *out++ = x; - allowspace = true; - } - } - break; - - case 1: // Just got a '<' - state = 2; - tokenp = 0; - if (x == '/') - { - endrange = true; - break; - } - else if (x == '!') - { - state = 20; - break; - } - else - { - endrange = false; - } - - case 2: // Somewhere past '<' - if (x == '>') - { // Token finished -gottoken: - token[tokenp] = 0; - if (!endrange) - { - if (stricmp (token, "head") == 0) - { - inhead = true; - } - else if (stricmp (token, "script") == 0) - { - inscript = true; - } - else if (stricmp (token, "p") == 0 || stricmp (token, "address") == 0) - { - *out++ = '\n'; - *out++ = '\n'; - allowspace = false; - } - else if (stricmp (token, "br") == 0) - { - *out++ = '\n'; - allowspace = false; - } - else if (stricmp (token, "li") == 0) - { - *out++ = '\n'; - *out++ = '*'; - *out++ = ' '; - allowspace = false; - } - else if ((token[0] == 'h' || token[0] == 'H') && token[1] >= '0' && token[1] <= '9' && token[2] == '\0') - { - *out++ = '\n'; - allowspace = false; - } - } - else - { - if (stricmp (token, "head") == 0) - { - inhead = false; - } - else if (stricmp (token, "script") == 0) - { - inscript = false; - } - else if ((token[0] == 'h' || token[0] == 'H') && token[1] >= '0' && token[1] <= '9' && token[2] == '\0') - { - *out++ = '\n'; - *out++ = '\n'; - allowspace = false; - } - else if (stricmp (token, "ul") == 0 || stricmp (token, "ol") == 0) - { - *out++ = '\n'; - allowspace = false; - } - } - state = 0; - } - else if (x == ' ') - { - state = 3; - } - else if (tokenp < 63) - { - token[tokenp++] = x; - } - break; - - case 3: // Past '<' TOKEN ' ' - if (x == '>') - { // Token finished - goto gottoken; - } - break; - - case 11: // Just got a '&' - state = 12; - tokenp = 0; - - case 12: - if (x == ';') - { // Token finished - if (stricmp (token, "lt") == 0) - { - *out++ = '<'; - } - else if (stricmp (token, "gt") == 0) - { - *out++ = '>'; - } - else if (stricmp (token, "amp") == 0) - { - *out++ = '&'; - } - state = 0; - } - else if (tokenp < 63) - { - token[tokenp++] = x; - } - break; - - case 20: // Just got "') - { - state = 0; - } - else - { - state = 22; - } - break; - } - } - if (out != buf) - { - *out++ = '\0'; - SendMessage (edit, EM_REPLACESEL, 0, (LPARAM)buf); - } -} - -//========================================================================== -// -// ReadResponse -// -// Read the HTTP response. If file is not INVALID_HANDLE_VALUE, then the -// response is downloaded to the file. Otherwise, it is passed through -// TranslateHTML and into the upload dialog's edit control. -// -//========================================================================== - -static bool ReadResponse (HWND hDlg, char *header, SOCKET sock, char *buf, int bufsize, HANDLE file) -{ - HWND edit = GetDlgItem (hDlg, IDC_BOINGEDIT); - DWORD wrote; - int len, avail, totalRecv; - int recvBytes = 0; - POINT pt = { 0, 0 }; - - strlwr (header); - - TranslateHTML translator (header, edit); - SendMessage (edit, WM_SETREDRAW, FALSE, 0); - - if (strstr (header, "transfer-encoding: chunked") != NULL) - { // Response body is chunked - for (;;) - { - len = GetChunkLen (sock); - if (len == 0) - { - break; - } - while (len > 0) - { - if (len > bufsize-1) avail = bufsize-1; - else avail = len; - recvBytes = recv (sock, buf, avail, 0); - if (recvBytes == 0 || recvBytes == SOCKET_ERROR) - { - goto done; - } - buf[recvBytes] = '\0'; - if (file != INVALID_HANDLE_VALUE) - { - WriteFile (file, buf, recvBytes, &wrote, NULL); - } - else - { - translator.Translate (buf); - } - len -= recvBytes; - } - } - } - else - { // Response body is uninterrupted - char *lenhead = strstr (header, "content-length: "); - if (lenhead != 0) - { - len = (int)strtoll (lenhead + 16, NULL, 10); - if (file != INVALID_HANDLE_VALUE) - { - ShowWindow (GetDlgItem (hDlg, IDC_BOINGPROGRESS), SW_SHOW); - SendMessage (GetDlgItem (hDlg, IDC_BOINGPROGRESS), PBM_SETRANGE, 0, MAKELPARAM (0, (len + bufsize-2)/(bufsize-1))); - } - } - else - { - len = 0; - } - totalRecv = 0; - for (;;) - { - if (len == 0) avail = bufsize - 1; - else - { - avail = len - totalRecv; - if (avail > bufsize - 1) avail = bufsize - 1; - } - recvBytes = recv (sock, buf, avail, 0); - if (recvBytes == 0 || recvBytes == SOCKET_ERROR) - { - break; - } - totalRecv += recvBytes; - buf[recvBytes] = '\0'; - if (file != INVALID_HANDLE_VALUE) - { - SendMessage (GetDlgItem (hDlg, IDC_BOINGPROGRESS), PBM_SETPOS, totalRecv/(bufsize-1), 0); - WriteFile (file, buf, recvBytes, &wrote, NULL); - } - else - { - translator.Translate (buf); - } - if (len != 0 && totalRecv >= len) - { - break; - } - } - } -done: - SendMessage (edit, EM_SETSCROLLPOS, 0, (LPARAM)&pt); - SendMessage (edit, WM_SETREDRAW, TRUE, 0); - InvalidateRect (edit, NULL, FALSE); - return recvBytes != SOCKET_ERROR; -} - -//========================================================================== -// -// CheckServerResponse -// -// Waits for a response from the server. If it doesn't get a 1xx or 2xx -// response, the response is displayed. The return value is either the -// response code or -1 if a socket error occurred. -// -//========================================================================== - -static int CheckServerResponse (HWND hDlg, SOCKET sock, char *&header, char *buf, int bufsize) -{ - int response; - - header = GetHeader (sock); - if (header == NULL) - { - UploadFail (hDlg, "Error reading server response", WSAGetLastError()); - return -1; - } - response = strtoul (strchr (header, ' '), NULL, 10); - if (response >= 300) - { - char *topline = strstr (header, "\r\n"); - *topline = 0; - SetWindowText (GetDlgItem (hDlg, IDC_BOINGSTATUS), header); - *topline = '\r'; - if (response != 304) - { - ReadResponse (hDlg, header, sock, buf, bufsize, INVALID_HANDLE_VALUE); - } - } - return response; -} - -//========================================================================== -// -// CabinetCallback -// -// Used to extract dbghelp.dll out of the downloaded cabinet. -// -//========================================================================== - -static UINT CALLBACK CabinetCallback (PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2) -{ - if (notification == SPFILENOTIFY_FILEINCABINET) - { - FILE_IN_CABINET_INFO *info = (FILE_IN_CABINET_INFO *)param1; - if (strcmp (info->NameInCabinet, "dbghelp.dll") == 0) - { - strncpy (info->FullTargetName, (char *)context, sizeof(info->FullTargetName)); - info->FullTargetName[sizeof(info->FullTargetName)-1] = '\0'; - info->FullTargetName[strlen(info->FullTargetName)-1] = 'l'; - return FILEOP_DOIT; - } - return FILEOP_SKIP; - } - return NO_ERROR; -} - -struct UploadParmStruct -{ - HWND hDlg; - HANDLE hThread; - HANDLE hFile; - const char *UserSummary; -}; - -//========================================================================== -// -// UploadProc -// -// Drives the error report upload and optionally the dbghelp download, -// using standard HTTP requests. -// -//========================================================================== - -static DWORD WINAPI UploadProc (LPVOID lpParam) -{ - char dbghelpPath[MAX_PATH+12]; - UploadParmStruct *parm = (UploadParmStruct *)lpParam; - char xferbuf[1024]; - WSADATA wsad; - SOCKET sock = INVALID_SOCKET; - addrinfo aiHints = { 0 }; - addrinfo *aiList = NULL; - char *header = NULL; - DWORD fileLen, fileLeft, contentLength; - int bytesSent; - int headerLen; - int err, i; - int retries; - DWORD returnval = TRUE; - HANDLE dbghelp = INVALID_HANDLE_VALUE; - HWND status = GetDlgItem (parm->hDlg, IDC_BOINGSTATUS); - - dbghelpPath[0] = '\0'; - SetWindowText (status, "Looking up " REMOTE_HOST "..."); - - // Startup Winsock. If this doesn't work, then we can't do anything. - err = WSAStartup (0x0101, &wsad); - if (err != 0) - { - UploadFail (parm->hDlg, "Could not initialize Winsock", err); - return FALSE; - } - - try - { - OSVERSIONINFO verinfo = { sizeof(verinfo) }; - GetVersionEx (&verinfo); - if (verinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - { - verinfo.dwBuildNumber &= 0xFFFF; - } - - // Lookup the host we want to talk with. - aiHints.ai_family = AF_INET; - aiHints.ai_socktype = SOCK_STREAM; - aiHints.ai_protocol = IPPROTO_TCP; - - err = getaddrinfo (REMOTE_HOST, REMOTE_PORT, &aiHints, &aiList); - if (err != 0 || aiList == NULL) - { - UploadFail (parm->hDlg, "Could not resolve " REMOTE_HOST, err); - throw 1; - } - - // Create a new socket... - sock = socket (aiList->ai_family, aiList->ai_socktype, aiList->ai_protocol); - if (sock == INVALID_SOCKET) - { - UploadFail (parm->hDlg, "Could not create socket", WSAGetLastError()); - throw 1; - } - - int timeout = TIMEOUT; - setsockopt (sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); - setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); - - // ...and connect it to the remote host. - SetWindowText (status, "Connecting to " REMOTE_HOST "..."); - err = connect (sock, aiList->ai_addr, sizeof(*aiList->ai_addr)); - if (err == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Failed to connect", WSAGetLastError()); - throw 1; - } - - // Now tell the host we want to submit the report. - SetWindowText (status, "Sending HTTP request..."); - fileLen = GetFileSize (parm->hFile, NULL); - contentLength = sizeof(MultipartInfoHeader)-1 + 8+9*7+2 + strlen(verinfo.szCSDVersion) + - (parm->UserSummary ? (sizeof(MultipartUserSummaryHeader)-1 + strlen(UserSummary)) : 0) + - sizeof(MultipartBinaryHeader)-1 + - sizeof(MultipartHeaderGZip)-1 + fileLen + - sizeof(MultipartFooter)-1; - headerLen = mysnprintf (xferbuf, countof(xferbuf), PostHeader, contentLength); - bytesSent = send (sock, xferbuf, headerLen, 0); - if (bytesSent != headerLen) - { - UploadFail (parm->hDlg, "Could not send HTTP request", WSAGetLastError()); - throw 1; - } - - // Wait for a 100 continue response from the host. - err = CheckServerResponse (parm->hDlg, sock, header, xferbuf, sizeof(xferbuf)); - if (err < 0 || err >= 300) - { - throw 1; - } - - // And now that we have it, we can finally send the report. - SetWindowText (status, "Sending report..."); - - // First show the progress bar so the user knows how much of the report has been sent. - ShowWindow (GetDlgItem (parm->hDlg, IDC_BOINGPROGRESS), SW_SHOW); - SendMessage (GetDlgItem (parm->hDlg, IDC_BOINGPROGRESS), PBM_SETRANGE, 0, MAKELPARAM (0, (fileLen + sizeof(xferbuf)-1)/sizeof(xferbuf))); - - // Send the bare-bones info (exception and windows version info) - bytesSent = send (sock, MultipartInfoHeader, sizeof(MultipartInfoHeader)-1, 0); - if (bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError()); - throw 1; - } - headerLen = mysnprintf (xferbuf, countof(xferbuf), "Windows %08lX %p %X %08lX %08lX %08lX %08lX %08lX %s", - CrashPointers.ExceptionRecord->ExceptionCode, - CrashPointers.ExceptionRecord->ExceptionAddress, - !!CrashPointers.ExceptionRecord->ExceptionInformation[0], - CrashPointers.ExceptionRecord->ExceptionInformation[1], - - verinfo.dwMajorVersion, - verinfo.dwMinorVersion, - verinfo.dwBuildNumber, - verinfo.dwPlatformId, - verinfo.szCSDVersion); - bytesSent = send (sock, xferbuf, headerLen, 0); - if (bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError()); - throw 1; - } - - // Send the user summary. - if (parm->UserSummary) - { - bytesSent = send (sock, MultipartUserSummaryHeader, sizeof(MultipartUserSummaryHeader)-1, 0); - if (bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError()); - throw 1; - } - bytesSent = send (sock, parm->UserSummary, (int)strlen(parm->UserSummary), 0); - if (bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError()); - throw 1; - } - } - - // Send the report file. - headerLen = mysnprintf (xferbuf, countof(xferbuf), "%s%s", MultipartBinaryHeader, MultipartHeaderZip); - - bytesSent = send (sock, xferbuf, headerLen, 0); - if (bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError()); - throw 1; - } - - // Send the report itself. - SetFilePointer (parm->hFile, 0, NULL, FILE_BEGIN); - fileLeft = fileLen; - i = 0; - while (fileLeft != 0) - { - DWORD grab = fileLeft > sizeof(xferbuf) ? sizeof(xferbuf) : fileLeft; - DWORD didread; - - ReadFile (parm->hFile, xferbuf, grab, &didread, NULL); - bytesSent = send (sock, xferbuf, didread, 0); - if (bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError()); - throw 1; - } - fileLeft -= grab; - SendMessage (GetDlgItem (parm->hDlg, IDC_BOINGPROGRESS), PBM_SETPOS, ++i, 0); - } - // Send the multipart footer. - bytesSent += send (sock, MultipartFooter, sizeof(MultipartFooter) - 1, 0); - - // And now we're done uploading the report. Yay! - SetWindowText (status, "Report sent"); - - // But we still need a 200 response from the host. Hopefully it gives us one. - HeapFree (GetProcessHeap(), 0, header); - err = CheckServerResponse (parm->hDlg, sock, header, xferbuf, sizeof(xferbuf)); - if (err < 0 || err >= 300) - { - throw 1; - } - - // Fill the edit control with the response body, in case the host wants - // to say, "Thank you for clicking that send button." - ReadResponse (parm->hDlg, header, sock, xferbuf, sizeof(xferbuf), INVALID_HANDLE_VALUE); - - // Close the connection, because we told the host this was a one-shot communication. - closesocket (sock); sock = INVALID_SOCKET; - - // If dbghelp.dll was not available or too old when the report was created, - // ask the user if they want to download it. It's too late to be of any use - // to this report, but it can still be used for future reports. - if (NeedDbgHelp && MessageBox (parm->hDlg, - "Shall I download dbghelp.dll?\n\n" - "This is a Microsoft-supplied DLL that can gather detailed information when a program crashes.\n\n" - "Although it is not essential for "GAMENAME", it will make any future error\n" - "reports more useful, so it is strongly suggested that you answer \"yes.\"\n\n" - "If you answer \"yes,\" dbghelp.dll will be installed in the same directory as "GAMENAME".", - "Download dbghelp.dll?", MB_YESNO|MB_ICONQUESTION) == IDYES) - { - char *bs; - - // Download it to the same directory as zdoom.exe. - GetModuleFileName (NULL, dbghelpPath, MAX_PATH); - dbghelpPath[MAX_PATH] = 0; - bs = strrchr (dbghelpPath, '\\'); - if (bs != NULL) - { - strcpy (bs + 1, "dbghelp.dl_"); - } - else - { - strcpy (dbghelpPath, "dbghelp.dl_"); - } - dbghelp = CreateFile (dbghelpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if (dbghelp != INVALID_HANDLE_VALUE) - { - SetWindowText (status, "Receiving dbghelp..."); - retries = 0; - - // Reopen the socket. We don't need to repeat the lookup, because - // we already know where the host is. - SetWindowText (status, "Reconnecting to " REMOTE_HOST "..."); - sock = socket (aiList->ai_family, aiList->ai_socktype, aiList->ai_protocol); - if (sock == INVALID_SOCKET) - { - UploadFail (parm->hDlg, "Could not create socket", WSAGetLastError()); - throw 1; - } - - // Socket is open. Try reconnecting now. - err = connect (sock, aiList->ai_addr, sizeof(*aiList->ai_addr)); - if (err == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Failed to reconnect", WSAGetLastError()); - throw 2; - } - SetWindowText (status, "Receiving dbghelp..."); - - // And send the request. - bytesSent = send (sock, DbgHelpRequest, sizeof(DbgHelpRequest)-1, 0); - if (bytesSent == 0 || bytesSent == SOCKET_ERROR) - { - UploadFail (parm->hDlg, "Failed trying to request dbghelp", WSAGetLastError()); - throw 2; - } - - // Ignore any information replies from the server. There shouldn't be any, - // but this loop is here just in case. - err = 100; - while (err / 100 == 1) - { - HeapFree (GetProcessHeap(), 0, header); - err = CheckServerResponse (parm->hDlg, sock, header, xferbuf, sizeof(xferbuf)); - } - // Now, if we haven't received a 200 OK response, give up because we - // shouldn't receive anything but that. - if (err != 200) - { - throw 2; - } - // Write the response body to the dbghelp.dl_ file. - if (!ReadResponse (parm->hDlg, header, sock, xferbuf, sizeof(xferbuf), dbghelp)) - { - UploadFail (parm->hDlg, "Could not receive dbghelp", WSAGetLastError()); - throw 2; - } - CloseHandle (dbghelp); dbghelp = INVALID_HANDLE_VALUE; - - // Now use the Setup API to extract dbghelp.dll from the file we just downloaded. - if (!SetupIterateCabinet (dbghelpPath, 0, CabinetCallback, dbghelpPath)) - { - UploadFail (parm->hDlg, "Extraction of dbghelp failed", GetLastError()); - } - - // And now we're done with that. There's nothing more to do here now. - SetWindowText (status, "Dbghelp installed"); - } - } - } - catch (...) - { - returnval = FALSE; - } - - ShowWindow (GetDlgItem (parm->hDlg, IDC_BOINGPROGRESS), SW_HIDE); - KillTimer (parm->hDlg, 1); - EnableWindow (GetDlgItem (parm->hDlg, IDOK), TRUE); - EnableWindow (GetDlgItem (parm->hDlg, IDC_BOINGEDIT), TRUE); - - if (dbghelp != INVALID_HANDLE_VALUE) CloseHandle (dbghelp); - if (dbghelpPath[0] != '\0') DeleteFile (dbghelpPath); - if (header != NULL) HeapFree (GetProcessHeap(), 0, header); - if (sock != INVALID_SOCKET) closesocket (sock); - if (aiList != NULL) freeaddrinfo (aiList); - WSACleanup (); - return returnval; -} - -//========================================================================== -// -// BoingDlgProc -// -// The dialog procedure for the upload status dialog. Aside from spawning -// off a new thread executing UploadProc, it doesn't do a whole lot. -// -//========================================================================== - -static BOOL CALLBACK BoingDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - UploadParmStruct *parms = (UploadParmStruct *)lParam; - HWND ctrl; - WLONG_PTR iconNum; - HANDLE icon; - DWORD threadID; - - switch (message) - { - case WM_INITDIALOG: - SetTimer (hDlg, 1, 100, NULL); - ctrl = GetDlgItem (hDlg, IDC_BOING); - SetWindowLongPtr (ctrl, GWLP_USERDATA, IDI_BOING1); - parms->hDlg = hDlg; - parms->hThread = CreateThread (NULL, 0, UploadProc, parms, 0, &threadID); - return TRUE; - - case WM_TIMER: - if (wParam == 1) - { - ctrl = GetDlgItem (hDlg, IDC_BOING); - iconNum = GetWindowLongPtr (ctrl, GWLP_USERDATA) + 1; - if (iconNum > IDI_BOING8) iconNum = IDI_BOING1; - SetWindowLongPtr (ctrl, GWLP_USERDATA, iconNum); - icon = LoadImage (g_hInst, MAKEINTRESOURCE(iconNum), IMAGE_ICON, 32, 32, LR_SHARED|LR_DEFAULTCOLOR); - SendMessage (ctrl, STM_SETICON, (WPARAM)icon, 0); - InvalidateRect (ctrl, NULL, FALSE); - SetWindowLongPtr (hDlg, DWLP_MSGRESULT, 0); - return TRUE; - } - break; - - case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED) - { - KillTimer (hDlg, 1); - EndDialog (hDlg, LOWORD(wParam)); - } - break; - } - return FALSE; -} - -//========================================================================== -// -// UploadReport -// -// Starts off the upload by showing the upload dialog. -// -//========================================================================== - -static BOOL UploadReport (HANDLE file) -{ - UploadParmStruct uploadParm = { 0, 0, file, UserSummary }; - BOOL res = (BOOL)DialogBoxParam (g_hInst, MAKEINTRESOURCE(IDD_BOING), NULL, (DLGPROC)BoingDlgProc, (LPARAM)&uploadParm); - if (UserSummary != NULL) - { - HeapFree (GetProcessHeap(), 0, UserSummary); - UserSummary = NULL; - } - return res; -} - -#endif // #if 0 - //========================================================================== // // SaveReport @@ -3320,15 +2308,8 @@ void DisplayCrashLog () pEnableThemeDialogTexture = (HRESULT (__stdcall *)(HWND,DWORD))GetProcAddress (uxtheme, "EnableThemeDialogTexture"); } INT_PTR result = DialogBox (g_hInst, MAKEINTRESOURCE(IDD_CRASHDIALOG), NULL, (DLGPROC)CrashDlgProc); - if (result == IDYES) - { -#if 0 // Server-side support is not done yet because I am too lazy. - file = MakeZip (); - UploadReport (file); - CloseHandle (file); -#endif - } - else if (result == IDC_SAVEREPORT) + + if (result == IDC_SAVEREPORT) { file = MakeZip (); SaveReport (file); diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index 74e019de8c..d19f6c40e4 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -100,14 +100,6 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON1 ICON "icon1.ico" -IDI_BOING1 ICON "boing1.ico" -IDI_BOING2 ICON "boing2.ico" -IDI_BOING3 ICON "boing3.ico" -IDI_BOING4 ICON "boing4.ico" -IDI_BOING5 ICON "boing5.ico" -IDI_BOING6 ICON "boing6.ico" -IDI_BOING7 ICON "boing7.ico" -IDI_BOING8 ICON "boing8.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -188,14 +180,6 @@ BEGIN HORZGUIDE, 76 END - IDD_BOING, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 180 - VERTGUIDE, 33 - TOPMARGIN, 7 - END - IDD_ERRORPANE, DIALOG BEGIN LEFTMARGIN, 7 @@ -416,7 +400,6 @@ CAPTION "GZDoom Very Fatal Error" FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN CONTROL "",IDC_CRASHTAB,"SysTabControl32",WS_TABSTOP,4,4,404,280 - PUSHBUTTON "&Send Error Report",IDYES,146,289,91,14,WS_DISABLED PUSHBUTTON "Save Report to Disk...",IDC_SAVEREPORT,242,289,91,14 PUSHBUTTON "&Discard Report",IDNO,338,289,70,14 END @@ -446,19 +429,6 @@ BEGIN CONTROL "",IDC_CRASHFILECONTENTS,"RichEdit20A",ES_MULTILINE | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,83,385,174 END -IDD_BOING DIALOGEX 0, 0, 187, 196 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Upload status" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Close",IDOK,130,175,50,14,WS_DISABLED - ICON IDI_BOING1,IDC_BOING,7,7,21,20 - LTEXT "Static",IDC_BOINGSTATUS,33,12,147,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,166,189,1 - CONTROL "",IDC_BOINGEDIT,"RichEdit20A",ES_MULTILINE | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,34,173,124 - CONTROL "",IDC_BOINGPROGRESS,"msctls_progress32",NOT WS_VISIBLE | WS_BORDER | 0x1,33,22,147,9 -END - IDD_ERRORPANE DIALOGEX 0, 0, 190, 28 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN EXSTYLE WS_EX_CONTROLPARENT