Skip to content

Commit

Permalink
Avoid pointer truncation in LPARAM/LRESULT on 64 bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
malxau committed Jul 1, 2021
1 parent ae232bc commit 29620be
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion guiwin32/gwcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ static void gwcmd_help_options (GUI_WINDOW *gwp)
** gwcmd -- process a menu command.
*/

LONG gwcmd (GUI_WINDOW *gwp, UINT wParam)
LRESULT gwcmd (GUI_WINDOW *gwp, WPARAM wParam)

{
switch (LOWORD (wParam)) {
Expand Down
52 changes: 26 additions & 26 deletions guiwin32/gwmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int mouse_selection = MOUSE_SEL_NONE;
** gwframe_WM_GETMINMAXINFO
*/

LONG gwframe_WM_GETMINMAXINFO (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_GETMINMAXINFO (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
RECT viewRect;
Expand Down Expand Up @@ -64,7 +64,7 @@ LONG gwframe_WM_GETMINMAXINFO (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwframe_WM_INITMENU
*/

LONG gwframe_WM_INITMENU (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_INITMENU (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
return 1;
Expand All @@ -75,7 +75,7 @@ LONG gwframe_WM_INITMENU (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwframe_WM_MENUSELECT
*/

LONG gwframe_WM_MENUSELECT (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_MENUSELECT (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
char str[80];
Expand All @@ -102,7 +102,7 @@ LONG gwframe_WM_MENUSELECT (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
*/

#if _MSC_VER > 900
LONG gwframe_WM_NOTIFY (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_NOTIFY (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
if (gwp->toolbarHWnd != NULL)
Expand All @@ -117,7 +117,7 @@ LONG gwframe_WM_NOTIFY (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwframe_WM_PAINT
*/

LONG gwframe_WM_PAINT (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_PAINT (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
PAINTSTRUCT ps;
Expand All @@ -133,7 +133,7 @@ LONG gwframe_WM_PAINT (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gframe_WM_SETFOCUS
*/

LONG gwframe_WM_SETFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_SETFOCUS (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
if (gwp->active)
Expand All @@ -147,7 +147,7 @@ LONG gwframe_WM_SETFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gframe_WM_SIZE
*/

LONG gwframe_WM_SIZE (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwframe_WM_SIZE (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
RECT rect;
Expand All @@ -169,7 +169,7 @@ LONG gwframe_WM_SIZE (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_CHAR
*/

LONG gwclient_WM_CHAR (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_CHAR (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
unsigned char chr = (unsigned char)wParam;
Expand All @@ -193,7 +193,7 @@ LONG gwclient_WM_CHAR (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_DROPFILES
*/

LONG gwclient_WM_DROPFILES (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_DROPFILES (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
char cmd[_MAX_PATH + 4];
Expand Down Expand Up @@ -222,7 +222,7 @@ LONG gwclient_WM_DROPFILES (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_ERASEBKGND
*/

LONG gwclient_WM_ERASEBKGND (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_ERASEBKGND (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
RECT rect;
Expand Down Expand Up @@ -259,7 +259,7 @@ LONG gwclient_WM_ERASEBKGND (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_KEYDOWN
*/

LONG gwclient_WM_KEYDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_KEYDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
unsigned char chr[3];
Expand Down Expand Up @@ -391,7 +391,7 @@ LONG gwclient_WM_KEYDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_KEYUP
*/

LONG gwclient_WM_KEYUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_KEYUP (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
if (wParam == VK_SHIFT)
Expand All @@ -410,7 +410,7 @@ LONG gwclient_WM_KEYUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_KILLFOCUS
*/

LONG gwclient_WM_KILLFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_KILLFOCUS (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
HideCaret (gwp->clientHWnd);
Expand All @@ -427,7 +427,7 @@ LONG gwclient_WM_KILLFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_LBUTTONDBLCLK
*/

LONG gwclient_WM_LBUTTONDBLCLK (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_LBUTTONDBLCLK (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
int row = HIWORD (lParam) / gwp->ycsize;
Expand All @@ -447,7 +447,7 @@ LONG gwclient_WM_LBUTTONDBLCLK (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_LBUTTONDOWN
*/

LONG gwclient_WM_LBUTTONDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_LBUTTONDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
mouse_down = 1;
Expand Down Expand Up @@ -475,7 +475,7 @@ LONG gwclient_WM_LBUTTONDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_LBUTTONUP
*/

LONG gwclient_WM_LBUTTONUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_LBUTTONUP (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
mouse_down = 0;
Expand All @@ -497,7 +497,7 @@ LONG gwclient_WM_LBUTTONUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_MOUSEMOVE
*/

LONG gwclient_WM_MOUSEMOVE (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_MOUSEMOVE (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
int row;
Expand Down Expand Up @@ -569,7 +569,7 @@ LONG gwclient_WM_MOUSEMOVE (GUI_WINDOW *gwp, UINT wParam, LONG lParam)

#if defined (WM_MOUSEWHEEL)

LONG gwclient_WM_MOUSEWHEEL (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_MOUSEWHEEL (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
short delta = HIWORD (wParam);
Expand All @@ -591,7 +591,7 @@ LONG gwclient_WM_MOUSEWHEEL (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_PAINT
*/

LONG gwclient_WM_PAINT (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_PAINT (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
PAINTSTRUCT ps;
Expand Down Expand Up @@ -637,7 +637,7 @@ LONG gwclient_WM_PAINT (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_RBUTTONDBLCLK
*/

LONG gwclient_WM_RBUTTONDBLCLK (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_RBUTTONDBLCLK (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
int row = HIWORD (lParam) / gwp->ycsize;
Expand All @@ -657,7 +657,7 @@ LONG gwclient_WM_RBUTTONDBLCLK (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_RBUTTONDOWN
*/

LONG gwclient_WM_RBUTTONDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_RBUTTONDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
WINDOW pwin = winofgw ((GUIWIN *)gwp);
Expand All @@ -683,7 +683,7 @@ LONG gwclient_WM_RBUTTONDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_RBUTTONUP
*/

LONG gwclient_WM_RBUTTONUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_RBUTTONUP (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
WINDOW pwin = winofgw ((GUIWIN *)gwp);
Expand Down Expand Up @@ -712,7 +712,7 @@ LONG gwclient_WM_RBUTTONUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_SETFOCUS
*/

LONG gwclient_WM_SETFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_SETFOCUS (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
dblclick = 0;
Expand Down Expand Up @@ -743,7 +743,7 @@ LONG gwclient_WM_SETFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_SIZE
*/

LONG gwclient_WM_SIZE (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_SIZE (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
int oldrows;
Expand All @@ -770,7 +770,7 @@ LONG gwclient_WM_SIZE (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_SYSKEYDOWN
*/

LONG gwclient_WM_SYSKEYDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_SYSKEYDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
unsigned char chr[3];
Expand Down Expand Up @@ -806,7 +806,7 @@ LONG gwclient_WM_SYSKEYDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
** gwclient_WM_VSCROLL
*/

LONG gwclient_WM_VSCROLL (GUI_WINDOW *gwp, UINT wParam, LONG lParam)
LRESULT gwclient_WM_VSCROLL (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam)

{
long nPos = HIWORD (wParam);
Expand Down
16 changes: 8 additions & 8 deletions guiwin32/winelvis.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ HANDLE ctl3d_handle;
static int init_application (HINSTANCE hInst);
static int init_instance (HINSTANCE hInst);
static void exit_instance (HINSTANCE hInst);
static LONG APIENTRY FrameWndProc (HWND hwnd, UINT msg,
UINT wParam, LONG lParam);
static LONG APIENTRY ClientWndProc (HWND hwnd, UINT msg,
UINT wParam, LONG lParam);
static LRESULT APIENTRY FrameWndProc (HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam);
static LRESULT APIENTRY ClientWndProc (HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam);

/* ---[ WinMain ]------------------------------------------------------ */

Expand Down Expand Up @@ -153,10 +153,10 @@ static void exit_instance (HINSTANCE hInstance)

/* ---[ FrameWndProc ]------------------------------------------------- */

LONG APIENTRY FrameWndProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam)
LRESULT APIENTRY FrameWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

{
LONG rc = 1;
LRESULT rc = 1;

switch (msg) {
case WM_COMMAND:
Expand Down Expand Up @@ -195,10 +195,10 @@ LONG APIENTRY FrameWndProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam)

/* ---[ ClientWndProc ]------------------------------------------------ */

LONG APIENTRY ClientWndProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam)
LRESULT APIENTRY ClientWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

{
LONG rc = 1;
LRESULT rc = 1;

switch (msg) {
case WM_CHAR:
Expand Down
54 changes: 27 additions & 27 deletions guiwin32/winelvis.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extern HICON gwcustomicon;

/* ---[ function prototypes ]------------------------------------------ */

extern LONG gwcmd (GUI_WINDOW *gwp, UINT wParam);
extern LRESULT gwcmd (GUI_WINDOW *gwp, WPARAM wParam);

extern BOOL CALLBACK DlgAbout (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
extern BOOL CALLBACK DlgGoto (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
Expand Down Expand Up @@ -115,32 +115,32 @@ extern void gw_get_default_printer (void);
extern void gw_set_default_printer (char *pDevice, char *pDriver,
char *pOutput);

extern LONG gwframe_WM_GETMINMAXINFO (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwframe_WM_INITMENU (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwframe_WM_MENUSELECT (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwframe_WM_NOTIFY (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwframe_WM_PAINT (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwframe_WM_SIZE (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwframe_WM_SETFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_CHAR (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_DROPFILES (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_ERASEBKGND (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_KEYDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_KEYUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_KILLFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_LBUTTONDBLCLK (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_LBUTTONDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_LBUTTONUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_MOUSEMOVE (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_MOUSEWHEEL (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_PAINT (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_RBUTTONDBLCLK (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_RBUTTONDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_RBUTTONUP (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_SETFOCUS (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_SIZE (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_SYSKEYDOWN (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LONG gwclient_WM_VSCROLL (GUI_WINDOW *gwp, UINT wParam, LONG lParam);
extern LRESULT gwframe_WM_GETMINMAXINFO (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwframe_WM_INITMENU (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwframe_WM_MENUSELECT (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwframe_WM_NOTIFY (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwframe_WM_PAINT (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwframe_WM_SIZE (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwframe_WM_SETFOCUS (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_CHAR (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_DROPFILES (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_ERASEBKGND (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_KEYDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_KEYUP (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_KILLFOCUS (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_LBUTTONDBLCLK (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_LBUTTONDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_LBUTTONUP (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_MOUSEMOVE (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_MOUSEWHEEL (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_PAINT (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_RBUTTONDBLCLK (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_RBUTTONDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_RBUTTONUP (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_SETFOCUS (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_SIZE (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_SYSKEYDOWN (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);
extern LRESULT gwclient_WM_VSCROLL (GUI_WINDOW *gwp, WPARAM wParam, LPARAM lParam);

extern void gw_create_status_bar (GUI_WINDOW *gwp);
extern void gw_destroy_status_bar (GUI_WINDOW *gwp);
Expand Down

0 comments on commit 29620be

Please sign in to comment.