From 9c5a81471e50199e67a5f2301f8499b1aa4f783b Mon Sep 17 00:00:00 2001 From: ugetab Date: Sun, 7 Feb 2010 22:19:38 +0000 Subject: [PATCH] Added window bounds checking to all WM_MOVE entries due to a bug report and example fceux.cfg file from Gil_ at the nesdev IRC. Win32 only. --- changelog.txt | 1 + src/drivers/win/cdlogger.cpp | 9 +++++++++ src/drivers/win/cheat.cpp | 18 ++++++++++++++++++ src/drivers/win/config.cpp | 23 +++++++++++++++++++++++ src/drivers/win/debugger.cpp | 9 +++++++++ src/drivers/win/log.cpp | 10 ++++++++++ src/drivers/win/memview.cpp | 20 ++++++++++++++++++++ src/drivers/win/memwatch.cpp | 10 ++++++++++ src/drivers/win/monitor.cpp | 10 ++++++++++ src/drivers/win/ntview.cpp | 10 ++++++++++ src/drivers/win/ppuview.cpp | 10 ++++++++++ src/drivers/win/ramwatch.cpp | 10 ++++++++++ src/drivers/win/replay.cpp | 9 +++++++++ src/drivers/win/tasedit.cpp | 10 ++++++++++ src/drivers/win/texthook.cpp | 10 ++++++++++ src/drivers/win/tracer.cpp | 10 ++++++++++ src/drivers/win/window.cpp | 10 ++++++++++ 17 files changed, 189 insertions(+) diff --git a/changelog.txt b/changelog.txt index 261630b3..a65e25c1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +02-feb-2010 - ugetab - Win32 - Added window positions bounds checks. Accounts for -32000 positions & less out-of-range too 08-jan-2010 - rheiny - Win32 - Trace Logger - Trace logger now logs the values of the stack pointer register 31-dec-2009 - prg318 - added gtk gui 08-dec-2009 - Zeromus - Fix Name Table Viewer - Fix for use with New PPU diff --git a/src/drivers/win/cdlogger.cpp b/src/drivers/win/cdlogger.cpp index 24916fa8..7b4d86e8 100644 --- a/src/drivers/win/cdlogger.cpp +++ b/src/drivers/win/cdlogger.cpp @@ -97,6 +97,15 @@ BOOL CALLBACK CDLoggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara GetWindowRect(hwndDlg,&wrect); CDLogger_wndx = wrect.left; CDLogger_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + CDLogger_wndx = 0; + } + if (CDLogger_wndy < -18) { + CDLogger_wndy = -18; + } + #endif break; }; case WM_INITDIALOG: diff --git a/src/drivers/win/cheat.cpp b/src/drivers/win/cheat.cpp index 1eb605bd..05391712 100644 --- a/src/drivers/win/cheat.cpp +++ b/src/drivers/win/cheat.cpp @@ -244,6 +244,15 @@ BOOL CALLBACK CheatConsoleCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l GetWindowRect(hwndDlg,&wrect); ChtPosX = wrect.left; ChtPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + ChtPosX = 0; + } + if (ChtPosY < -18) { + ChtPosY = -18; + } + #endif break; case WM_VSCROLL: @@ -623,6 +632,15 @@ BOOL CALLBACK GGConvCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowRect(hwndDlg,&wrect); GGConv_wndx = wrect.left; GGConv_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + GGConv_wndx = 0; + } + if (GGConv_wndy < -18) { + GGConv_wndy = -18; + } + #endif break; }; case WM_INITDIALOG: diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 213078ca..05217f10 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -317,6 +317,29 @@ void SaveConfig(const char *filename) } //----------------------------------- + //ugetab: window positions could use some bounds checking. + // MemView_wndx and MemView_wndy verified to sometimes end up -32000 + //CDLogger_wndx + //CDLogger_wndy + //GGConv_wndx + //GGConv_wndy + //MainWindow_wndx + //MainWindow_wndy + //MemFind_wndx + //MemFind_wndy + //MemView_wndx + //MemView_wndy + //MemWatch_wndx + //MemWatch_wndy + //Monitor_wndx + //Monitor_wndy + //TasEdit_wndx + //TasEdit_wndy + //Tracer_wndx + //Tracer_wndy + + //----------------------------------- + SaveFCEUConfig(filename,fceuconfig); } diff --git a/src/drivers/win/debugger.cpp b/src/drivers/win/debugger.cpp index e4b71ee7..31c1acda 100644 --- a/src/drivers/win/debugger.cpp +++ b/src/drivers/win/debugger.cpp @@ -1083,6 +1083,15 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara GetWindowRect(hwndDlg,&wrect); DbgPosX = wrect.left; DbgPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + DbgPosX = 59 - DbgSizeX; + } + if (DbgPosY < -18) { + DbgPosY = -18; + } + #endif break; //adelikat: Buttons that don't need a rom loaded to do something, such as autoload diff --git a/src/drivers/win/log.cpp b/src/drivers/win/log.cpp index e6915df7..b0c95711 100644 --- a/src/drivers/win/log.cpp +++ b/src/drivers/win/log.cpp @@ -86,6 +86,16 @@ BOOL CALLBACK LogCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowRect(hwndDlg,&wrect); //Remember X,Y coordinates MLogPosX = wrect.left; MLogPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + MLogPosX = 0; + } + if (MLogPosY < -18) { + MLogPosY = -18; + } + #endif + break; case WM_COMMAND: if(HIWORD(wParam)==BN_CLICKED) diff --git a/src/drivers/win/memview.cpp b/src/drivers/win/memview.cpp index cd66a6f2..50d28dd5 100644 --- a/src/drivers/win/memview.cpp +++ b/src/drivers/win/memview.cpp @@ -1596,6 +1596,16 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa GetWindowRect(hwnd,&wrect); MemView_wndx = wrect.left; MemView_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + MemView_wndx = 59 - MemViewSizeX; + } + if (MemView_wndy < -18) { + MemView_wndy = -18; + } + #endif + return 0; } @@ -1694,6 +1704,16 @@ BOOL CALLBACK MemFindCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam GetWindowRect(hwndDlg,&wrect); MemFind_wndx = wrect.left; MemFind_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + MemFind_wndx = 0; + } + if (MemFind_wndy < -18) { + MemFind_wndy = -18; + } + #endif + break; } case WM_RBUTTONDBLCLK: diff --git a/src/drivers/win/memwatch.cpp b/src/drivers/win/memwatch.cpp index 714ed325..2cfe1706 100644 --- a/src/drivers/win/memwatch.cpp +++ b/src/drivers/win/memwatch.cpp @@ -724,6 +724,16 @@ static BOOL CALLBACK MemWatchCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA GetWindowRect(hwndDlg,&wrect); MemWatch_wndx = wrect.left; MemWatch_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + MemWatch_wndx = 0; + } + if (MemWatch_wndy < -18) { + MemWatch_wndy = -18; + } + #endif + break; }; diff --git a/src/drivers/win/monitor.cpp b/src/drivers/win/monitor.cpp index 370c34fe..f3b0f604 100644 --- a/src/drivers/win/monitor.cpp +++ b/src/drivers/win/monitor.cpp @@ -227,6 +227,16 @@ BOOL CALLBACK MonitorCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam GetWindowRect(hwndDlg,&wrect); Monitor_wndx = wrect.left; Monitor_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + Monitor_wndx = 0; + } + if (Monitor_wndy < -18) { + Monitor_wndy = -18; + } + #endif + break; }; diff --git a/src/drivers/win/ntview.cpp b/src/drivers/win/ntview.cpp index 4c568f46..ea3fec57 100644 --- a/src/drivers/win/ntview.cpp +++ b/src/drivers/win/ntview.cpp @@ -424,6 +424,16 @@ BOOL CALLBACK NTViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowRect(hwndDlg,&wrect); NTViewPosX = wrect.left; NTViewPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + NTViewPosX = 0; + } + if (NTViewPosY < -18) { + NTViewPosY = -18; + } + #endif + break; case WM_RBUTTONDBLCLK: case WM_RBUTTONDOWN: diff --git a/src/drivers/win/ppuview.cpp b/src/drivers/win/ppuview.cpp index 4f79ab7f..a0e6131d 100644 --- a/src/drivers/win/ppuview.cpp +++ b/src/drivers/win/ppuview.cpp @@ -270,6 +270,16 @@ BOOL CALLBACK PPUViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam GetWindowRect(hwndDlg,&wrect); PPUViewPosX = wrect.left; PPUViewPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + PPUViewPosX = 0; + } + if (PPUViewPosY < -18) { + PPUViewPosY = -18; + } + #endif + break; case WM_RBUTTONDBLCLK: case WM_RBUTTONDOWN: diff --git a/src/drivers/win/ramwatch.cpp b/src/drivers/win/ramwatch.cpp index f4e8a354..6ad9c4aa 100644 --- a/src/drivers/win/ramwatch.cpp +++ b/src/drivers/win/ramwatch.cpp @@ -830,6 +830,16 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam GetWindowRect(hDlg,&wrect); ramw_x = wrect.left; ramw_y = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + ramw_x = 0; + } + if (ramw_y < -18) { + ramw_y = -18; + } + #endif + //regSetDwordValue(RAMWX, ramw_x); TODO //regSetDwordValue(RAMWY, ramw_y); TODO } break; diff --git a/src/drivers/win/replay.cpp b/src/drivers/win/replay.cpp index d2d5c054..1a54754f 100644 --- a/src/drivers/win/replay.cpp +++ b/src/drivers/win/replay.cpp @@ -401,6 +401,15 @@ BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L GetWindowRect(hwndDlg,&wrect); MetaPosX = wrect.left; MetaPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + MetaPosX = 0; + } + if (MetaPosY < -18) { + MetaPosY = -18; + } + #endif break; case WM_COMMAND: diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index bc1cefc3..a8d8a5d8 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -1021,6 +1021,16 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar GetWindowRect(hwndDlg,&wrect); TasEdit_wndx = wrect.left; TasEdit_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + TasEdit_wndx = 0; + } + if (TasEdit_wndy < -18) { + TasEdit_wndy = -18; + } + #endif + break; } diff --git a/src/drivers/win/texthook.cpp b/src/drivers/win/texthook.cpp index 91ce78fd..a10bba35 100644 --- a/src/drivers/win/texthook.cpp +++ b/src/drivers/win/texthook.cpp @@ -875,6 +875,16 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa GetWindowRect(hwndDlg,&wrect); TextHookerPosX = wrect.left; TextHookerPosY = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + TextHookerPosX = 0; + } + if (TextHookerPosY < -18) { + TextHookerPosY = -18; + } + #endif + break; case WM_RBUTTONDBLCLK: sprintf(str,"aaaa"); diff --git a/src/drivers/win/tracer.cpp b/src/drivers/win/tracer.cpp index 55effe44..373653b2 100644 --- a/src/drivers/win/tracer.cpp +++ b/src/drivers/win/tracer.cpp @@ -90,6 +90,16 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) GetWindowRect(hwndDlg,&wrect); Tracer_wndx = wrect.left; Tracer_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + Tracer_wndx = 0; + } + if (Tracer_wndy < -18) { + Tracer_wndy = -18; + } + #endif + break; }; case WM_INITDIALOG: diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 48864f8b..5b95a86c 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -1196,6 +1196,16 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) GetWindowRect(hWnd,&wrect); MainWindow_wndx = wrect.left; MainWindow_wndy = wrect.top; + + #ifdef WIN32 + if (wrect.right < 59) { + MainWindow_wndx = 0; + } + if (MainWindow_wndy < -18) { + MainWindow_wndy = -18; + } + #endif + } case WM_MOUSEMOVE: