WORD _GetWindowWord( PWND pwnd, int index) { if (GETFNID(pwnd) != 0) { if ((index >= 0) && (index < (int)(CBFNID(pwnd->fnid)-sizeof(WND)))) { switch (GETFNID(pwnd)) { case FNID_MDICLIENT: if (index == 0) break; goto DoDefault; case FNID_BUTTON: /* * CorelDraw does a get/set on the first button window word. * Allow it to. */ if (index == 0) { /* * Since we now use a lookaside buffer for the control's * private data, we need to indirect into this structure. */ PBUTN pbutn = ((PBUTNWND)pwnd)->pbutn; if (!pbutn || (LONG)pbutn == (LONG)-1) { return 0; } else { return (WORD)(pbutn->buttonState); } } goto DoDefault; case FNID_DIALOG: if (index == DWL_USER) return LOWORD(((PDIALOG)pwnd)->unused); if (index == DWL_USER+2) return HIWORD(((PDIALOG)pwnd)->unused); goto DoDefault; default: DoDefault: RIPERR3(ERROR_INVALID_INDEX, RIP_WARNING, "GetWindowWord: Trying to read private server data pwnd=(%lX) index=(%ld) fnid=(%lX)", pwnd, index, (DWORD)pwnd->fnid); return 0; break; } } } if (index == GWL_USERDATA) return (WORD)pwnd->dwUserData; if ((index < 0) || (index + (int)sizeof(WORD) > pwnd->cbwndExtra)) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return 0; } else { return *((WORD UNALIGNED *)((BYTE *)(pwnd + 1) + index)); } }
WORD _SetWindowWord( PWND pwnd, int index, WORD value) { WORD wOld; /* * Don't allow setting of words belonging to a system thread if the caller * is not a system thread. Same goes for winlogon. */ if (!FCallerOk(pwnd)) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return 0; } /* * Applications can not set a WORD into a dialog Proc or any of the * non-public reserved bytes in DLGWINDOWEXTRA (usersrv stores pointers * theres) */ if (TestWF(pwnd, WFDIALOGWINDOW)) { if (((index >= DWLP_DLGPROC) && (index < DWLP_MSGRESULT)) || ((index > DWLP_USER+sizeof(LONG_PTR)-sizeof(WORD)) && (index < DLGWINDOWEXTRA))) { RIPERR3(ERROR_INVALID_INDEX, RIP_WARNING, "SetWindowWord: Trying to set WORD of a windowproc pwnd=(%#p) index=(%ld) fnid (%lX)", pwnd, index, (DWORD)pwnd->fnid); return 0; } else { /* * If this is really a dialog and not some other server class * where usersrv has stored some data (Windows Compuserve - * wincim - does this) then store the data now that we have * verified the index limits. */ if (GETFNID(pwnd) == FNID_DIALOG) goto DoSetWord; } } if (index == GWLP_USERDATA) { wOld = (WORD)pwnd->dwUserData; pwnd->dwUserData = MAKELONG(value, HIWORD(pwnd->dwUserData)); return wOld; } // fix for RedShift, they call SetWindowWord // tn play with the low word of the style dword if (index == GWL_STYLE) { wOld = (WORD)pwnd->style; pwnd->style = MAKELONG(value, HIWORD(pwnd->style)); return wOld; } if (GETFNID(pwnd) != 0) { if (index >= 0 && (index < (int)(CBFNID(pwnd->fnid)-sizeof(WND)))) { switch (GETFNID(pwnd)) { case FNID_MDICLIENT: if (index == 0) break; goto DoDefault; case FNID_BUTTON: /* * CorelDraw, Direct Access 1.0 and WordPerfect 6.0 do a * get/set on the first button window word. Allow this * for compatibility. */ if (index == 0) { /* * Since we now use a lookaside buffer for the control's * private data, we need to indirect into this structure. */ PBUTN pbutn = ((PBUTNWND)pwnd)->pbutn; if (!pbutn || (LONG_PTR)pbutn == (LONG_PTR)-1) { return 0; } else { try { wOld = (WORD)ProbeAndReadUlong(&pbutn->buttonState); pbutn->buttonState = value; } except (W32ExceptionHandler(FALSE, RIP_WARNING)) { wOld = 0; } return wOld; } } goto DoDefault; default: DoDefault: RIPERR3(ERROR_INVALID_INDEX, RIP_WARNING, "SetWindowWord: Trying to set private server data pwnd=(%#p) index=(%ld) fnid (%lX)", pwnd, index, (DWORD)pwnd->fnid); return 0; break; } } }