Changeset 5242


Ignore:
Timestamp:
Feb 22, 2001, 11:37:31 AM (24 years ago)
Author:
sandervl
Message:

window & class user word access fixes

Location:
trunk/src/user32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/user32/win32class.cpp

    r5084 r5242  
    1 /* $Id: win32class.cpp,v 1.22 2001-02-10 10:35:31 sandervl Exp $ */
     1/* $Id: win32class.cpp,v 1.23 2001-02-22 10:37:30 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    104104  dprintf(("USER32:  wndclass->hIconSm %X\n", wndclass->hIconSm));
    105105
    106   nrExtraClassWords     = wndclass->cbClsExtra;
    107   nrExtraWindowWords    = wndclass->cbWndExtra;
     106  nrExtraClassBytes     = wndclass->cbClsExtra;
     107  nrExtraWindowBytes    = wndclass->cbWndExtra;
    108108  backgroundBrush       = wndclass->hbrBackground;
    109109  hCursor               = wndclass->hCursor;
     
    123123
    124124  //User data class words/longs
    125   if(nrExtraClassWords) {
    126         userClassLong = (ULONG *)_smalloc(nrExtraClassWords);
    127         if(userClassLong == NULL) {
    128                 dprintf(("Win32Class ctr: userClassLong == NULL!"));
     125  if(nrExtraClassBytes) {
     126        userClassBytes = (char *)_smalloc(nrExtraClassBytes);
     127        if(userClassBytes == NULL) {
     128                dprintf(("Win32Class ctr: userClassBytes == NULL!"));
    129129                exit(1);
    130130        }
    131         memset(userClassLong, 0, nrExtraClassWords);
    132   }
    133   else  userClassLong = NULL;
     131        memset(userClassBytes, 0, nrExtraClassBytes);
     132  }
     133  else  userClassBytes = NULL;
    134134
    135135  cWindows = 0;
     
    151151  WINPROC_FreeProc(windowProc, WIN_PROC_CLASS);
    152152
    153   if(userClassLong)     free(userClassLong);
     153  if(userClassBytes)    free(userClassBytes);
    154154  if(classNameA)        free(classNameA);
    155155  if(classNameW)        free(classNameW);
     
    251251
    252252  if(HIWORD(id)) {
    253         lpszClassName = UnicodeToAsciiString((LPWSTR)id);
    254   }
    255   else  lpszClassName = (LPSTR)id;
     253    lpszClassName = UnicodeToAsciiString((LPWSTR)id);
     254  }
     255  else  lpszClassName = (LPSTR)id;
    256256
    257257  winclass = FindClass(hInstance, lpszClassName);
     
    278278BOOL Win32WndClass::getClassInfo(WNDCLASSEXA *wndclass)
    279279{
    280   wndclass->cbClsExtra    = nrExtraClassWords;
    281   wndclass->cbWndExtra    = nrExtraWindowWords;
     280  wndclass->cbClsExtra    = nrExtraClassBytes;
     281  wndclass->cbWndExtra    = nrExtraWindowBytes;
    282282  wndclass->hbrBackground = backgroundBrush;
    283283  wndclass->hCursor       = hCursor;
     
    295295BOOL Win32WndClass::getClassInfo(WNDCLASSEXW *wndclass)
    296296{
    297   wndclass->cbClsExtra    = nrExtraClassWords;
    298   wndclass->cbWndExtra    = nrExtraWindowWords;
     297  wndclass->cbClsExtra    = nrExtraClassBytes;
     298  wndclass->cbWndExtra    = nrExtraWindowBytes;
    299299  wndclass->hbrBackground = backgroundBrush;
    300300  wndclass->hCursor       = hCursor;
     
    376376  switch(index) {
    377377        case GCL_CBCLSEXTRA:
    378                 return nrExtraClassWords;
     378                return nrExtraClassBytes;
    379379        case GCL_CBWNDEXTRA:
    380                 return nrExtraWindowWords;
     380                return nrExtraWindowBytes;
    381381        case GCL_HBRBACKGROUND:
    382382                return backgroundBrush;
     
    399399                return 0;
    400400        default:
    401                 if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) {
    402                         return userClassLong[index];
    403                 }
     401                if(index >= 0 && index + sizeof(ULONG) <= nrExtraClassBytes) {
     402                        //Note: NT4, SP6 does not set the last error to 0
     403                        SetLastError(ERROR_SUCCESS);
     404                        return *(ULONG *)(userClassBytes + index);
     405                }
     406                if(classNameA) {
     407                     dprintf2(("WARNING: getClassLong %s: %d -> wrong INDEX", classNameA, index));
     408                }
     409                else dprintf2(("WARNING: getClassLong %d: %d -> wrong INDEX", classAtom, index));
    404410                SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
    405411                return 0;
     
    414420                return (WORD)classAtom;
    415421        default:
    416                 if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) {
    417                         return ((WORD *)userClassLong)[index];
    418                 }
     422                if(index >= 0 && index + sizeof(WORD) <= nrExtraClassBytes) {
     423                        //Note: NT4, SP6 does not set the last error to 0
     424                        SetLastError(ERROR_SUCCESS);
     425                        return *(WORD *)(userClassBytes + index);
     426                }
     427                if(classNameA) {
     428                     dprintf2(("WARNING: getClassWord %s: %d -> wrong INDEX", classNameA, index));
     429                }
     430                else dprintf2(("WARNING: getClassWord %d: %d -> wrong INDEX", classAtom, index));
    419431                SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
    420432                return 0;
     
    430442  switch(index) {
    431443        case GCL_CBCLSEXTRA: //TODO (doesn't affect allocated classes, so what does it do?)
    432                 rc = nrExtraClassWords;
    433 //              nrExtraClassWords = lNewVal;
     444                rc = nrExtraClassBytes;
     445//              nrExtraClassBytes = lNewVal;
    434446                break;
    435447        case GCL_CBWNDEXTRA:
    436                 rc = nrExtraWindowWords;
    437                 nrExtraWindowWords = lNewVal;
     448                rc = nrExtraWindowBytes;
     449                nrExtraWindowBytes = lNewVal;
    438450                break;
    439451        case GCL_HBRBACKGROUND:
     
    466478                break;
    467479        case GCL_WNDPROC:
    468                 //Note: Type of SetWindowLong determines new window proc type
     480                //Note: Type of SetWindowLong determines new window proc type
    469481                //      UNLESS the new window proc has already been registered
    470482                //      (use the old type in that case)
    471483                //      (VERIFIED in NT 4, SP6)
    472                 //TODO: Is that also true for GCL_WNDPROC???????????????
     484                //TODO: Is that also true for GCL_WNDPROC???????????????
    473485                rc = (LONG)WINPROC_GetProc(windowProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A );
    474486                WINPROC_SetProc((HWINDOWPROC *)&windowProc, (WNDPROC)lNewVal, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_CLASS );
     
    478490                return 0;
    479491        default:
    480                 if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) {
    481                         rc = userClassLong[index];
    482                         userClassLong[index] = lNewVal;
     492                if(index >= 0 && index + sizeof(ULONG) <= nrExtraClassBytes) {
     493                        rc = *(ULONG *)(userClassBytes + index);
     494                        *(ULONG *)(userClassBytes + index) = lNewVal;
    483495                        break;
    484496                }
    485497                SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
    486                 if(classNameA) {
    487                       dprintf2(("WARNING: Win32WndClass::setClassLongA %s: %d %x -> wrong INDEX", classNameA, index, lNewVal));
    488                 }
    489                 else dprintf2(("WARNING: Win32WndClass::setClassLongA %d: %d %x -> wrong INDEX", classAtom, index, lNewVal));
     498                if(classNameA) {
     499                     dprintf2(("WARNING: Win32WndClass::setClassLongA %s: %d %x -> wrong INDEX", classNameA, index, lNewVal));
     500                }
     501                else dprintf2(("WARNING: Win32WndClass::setClassLongA %d: %d %x -> wrong INDEX", classAtom, index, lNewVal));
    490502                return 0;
    491503  }
     
    509521                return(rc);
    510522        default:
    511                 if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) {
    512                         rc = ((WORD *)userClassLong)[index];
    513                         ((WORD *)userClassLong)[index] = wNewVal;
     523                if(index >= 0 && index + sizeof(WORD) <= nrExtraClassBytes) {
     524                        rc = *(WORD *)(userClassBytes + index);
     525                        *(WORD *)(userClassBytes + index) = wNewVal;
     526                        //Note: NT4, SP6 does not set the last error to 0
     527                        SetLastError(ERROR_SUCCESS);
    514528                        return(rc);
    515529                }
    516530                SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
     531                if(classNameA) {
     532                     dprintf2(("WARNING: setClassWord %s: %d %x -> wrong INDEX", classNameA, index, wNewVal));
     533                }
     534                else dprintf2(("WARNING: setClassWord %d: %d %x -> wrong INDEX", classAtom, index, wNewVal));
    517535                return 0;
    518536  }
  • TabularUnified trunk/src/user32/win32class.h

    r5056 r5242  
    1 /* $Id: win32class.h,v 1.13 2001-02-02 19:04:02 sandervl Exp $ */
     1/* $Id: win32class.h,v 1.14 2001-02-22 10:37:30 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    4242       WNDPROC  getWindowProc()         { return windowProc; };
    4343         LPSTR  getMenuNameA()          { return menuNameA; };
    44          DWORD  getExtraWndWords()      { return nrExtraWindowWords; };
     44         DWORD  getExtraWndBytes()      { return nrExtraWindowBytes; };
    4545
    4646         HICON  getIcon()               { return hIcon; };
     
    7777 //Standard class words/longs
    7878 ULONG          windowStyle;            //GCL_STYLE     * must be offset 14h *
    79  ULONG          nrExtraClassWords;      //GCL_CBCLSEXTRA
    80  ULONG          nrExtraWindowWords;     //GCL_CBWNDEXTRA
     79 ULONG          nrExtraClassBytes;      //GCL_CBCLSEXTRA
     80 ULONG          nrExtraWindowBytes;     //GCL_CBWNDEXTRA
    8181 HBRUSH         backgroundBrush;        //GCL_HBRBACKGROUND
    8282 HCURSOR        hCursor;                //GCL_HCURSOR
     
    9393 HDC            hdcClass;
    9494
    95  //User data class words/longs
    96  ULONG         *userClassLong;
     95 //User data class bytse
     96 char          *userClassBytes;
    9797 ULONG          processId;
    9898
  • TabularUnified trunk/src/user32/win32wbase.cpp

    r5237 r5242  
    1 /* $Id: win32wbase.cpp,v 1.241 2001-02-21 21:30:43 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.242 2001-02-22 10:37:31 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    110110  wndNameLength    = 0;
    111111
    112   userWindowLong   = NULL;;
    113   nrUserWindowLong = 0;
     112  userWindowBytes  = NULL;;
     113  nrUserWindowBytes= 0;
    114114
    115115  magic            = WIN32PM_MAGIC;
     
    214214        HwFreeWindowHandle(Win32Hwnd);
    215215
    216     if(userWindowLong)
    217         free(userWindowLong);
     216    if(userWindowBytes)
     217        free(userWindowBytes);
    218218
    219219    if(windowNameA) {
     
    393393
    394394    //Allocate window words
    395     nrUserWindowLong = windowClass->getExtraWndWords();
    396     if(nrUserWindowLong) {
    397         userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
    398         memset(userWindowLong, 0, nrUserWindowLong);
     395    nrUserWindowBytes = windowClass->getExtraWndBytes();
     396    if(nrUserWindowBytes) {
     397        userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
     398        memset(userWindowBytes, 0, nrUserWindowBytes);
    399399    }
    400400
     
    34243424
    34253425        default:
    3426                 if(index >= 0 && index/4 < nrUserWindowLong)
     3426                if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
    34273427                {
    3428                     oldval = userWindowLong[index/4];
    3429                     userWindowLong[index/4] = value;
     3428                    oldval = *(ULONG *)(userWindowBytes + index);
     3429                    *(ULONG *)(userWindowBytes + index) = value;
    34303430                    break;
    34313431                }
     
    34683468        break;
    34693469    default:
    3470         if(index >= 0 && index/4 < nrUserWindowLong)
    3471         {
    3472             value = userWindowLong[index/4];
     3470        if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
     3471        {
     3472            value = *(ULONG *)(userWindowBytes + index);
    34733473            break;
    34743474        }
     3475        dprintf(("WARNING: GetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
    34753476        SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
    34763477        return 0;
    34773478    }
    3478     dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
     3479    dprintf2(("GetWindowLong%c %x %d %x", getWindowHandle(), (fUnicode) ? 'W' : 'A', index, value));
    34793480    //Note: NT4, SP6 does not set the last error to 0
    34803481    SetLastError(ERROR_SUCCESS);
     
    34873488 WORD oldval;
    34883489
    3489     if(index >= 0 && index/4 < nrUserWindowLong)
    3490     {
    3491         oldval = ((WORD *)userWindowLong)[index/2];
    3492         ((WORD *)userWindowLong)[index/2] = value;
     3490    if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
     3491    {
     3492        oldval = *(WORD *)(userWindowBytes + index);
     3493        *(WORD *)(userWindowBytes + index) = value;
     3494        //Note: NT4, SP6 does not set the last error to 0
     3495        dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
     3496        SetLastError(ERROR_SUCCESS);
     3497        return oldval;
     3498    }
     3499    dprintf(("WARNING: SetWindowWord %x %d %x returned %x INVALID index!", getWindowHandle(), index, value));
     3500    SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
     3501    return 0;
     3502}
     3503//******************************************************************************
     3504//******************************************************************************
     3505WORD Win32BaseWindow::GetWindowWord(int index)
     3506{
     3507    if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
     3508    {
    34933509        //Note: NT4, SP6 does not set the last error to 0
    34943510        SetLastError(ERROR_SUCCESS);
    3495         return oldval;
    3496     }
    3497     SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
    3498     return 0;
    3499 }
    3500 //******************************************************************************
    3501 //******************************************************************************
    3502 WORD Win32BaseWindow::GetWindowWord(int index)
    3503 {
    3504     if(index >= 0 && index/4 < nrUserWindowLong)
    3505     {
    3506         //Note: NT4, SP6 does not set the last error to 0
    3507         SetLastError(ERROR_SUCCESS);
    3508         return ((WORD *)userWindowLong)[index/2];
    3509     }
     3511        dprintf2(("GetWindowWord %x %d %x", getWindowHandle(), index, *(WORD *)(userWindowBytes + index)));
     3512        return *(WORD *)(userWindowBytes + index);
     3513    }
     3514    dprintf(("WARNING: GetWindowWord %x %d returned %x INVALID index!", getWindowHandle(), index));
    35103515    SetLastError(ERROR_INVALID_INDEX);  //verified in NT4, SP6
    35113516    return 0;
  • TabularUnified trunk/src/user32/win32wbase.h

    r5237 r5242  
    1 /* $Id: win32wbase.h,v 1.109 2001-02-21 21:30:44 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.110 2001-02-22 10:37:31 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    387387        ULONG   wndNameLength; //including 0 terminator
    388388
    389         ULONG  *userWindowLong;
    390         ULONG   nrUserWindowLong;
     389        char   *userWindowBytes;
     390        ULONG   nrUserWindowBytes;
    391391
    392392        RECT    rectWindow; //relative to parent
  • TabularUnified trunk/src/user32/windowclass.cpp

    r5056 r5242  
    1 /* $Id: windowclass.cpp,v 1.15 2001-02-02 19:04:03 sandervl Exp $ */
     1/* $Id: windowclass.cpp,v 1.16 2001-02-22 10:37:31 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Code for OS/2
     
    363363 Win32BaseWindow *wnd;
    364364
    365     dprintf(("USER32: SetClassLongA %x %d %x", hwnd, nIndex, lNewVal));
    366     wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    367     if(!wnd) {
    368         dprintf(("SetClassLongA wnd == NULL"));
     365    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     366    if(!wnd) {
     367        dprintf(("SetClassLongA %x %d %x wnd == NULL", hwnd, nIndex, lNewVal));
    369368        return(0);
    370369    }
     
    377376 Win32BaseWindow *wnd;
    378377
    379     dprintf(("USER32: SetClassLongW\n"));
    380     wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    381     if(!wnd) {
    382         dprintf(("SetClassLongW wnd == NULL"));
     378    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     379    if(!wnd) {
     380        dprintf(("SetClassLongW %x %d %x wnd == NULL", hwnd, nIndex, lNewVal));
    383381        return(0);
    384382    }
     
    391389 Win32BaseWindow *wnd;
    392390
    393     dprintf(("USER32: SetClassWordA\n"));
    394     wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    395     if(!wnd) {
    396         dprintf(("SetClassWordA wnd == NULL"));
     391    dprintf(("USER32: SetClassWord %x %d %x", hwnd, nIndex, (ULONG)wNewVal));
     392    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     393    if(!wnd) {
     394        dprintf(("SetClassWordA %x %d %x wnd == NULL", hwnd, nIndex, wNewVal));
    397395        return(0);
    398396    }
     
    404402{
    405403 Win32BaseWindow *wnd;
    406 
    407     dprintf(("USER32: GetClassWordA\n"));
    408     wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    409     if(!wnd) {
    410         dprintf(("GetClassWordA wnd == NULL"));
    411         return(0);
    412     }
    413     return (wnd->getClass())->getClassWord(nIndex);
     404 WORD             ret;
     405
     406    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     407    if(!wnd) {
     408        dprintf(("GetClassWordA %x %d wnd == NULL", hwnd, nIndex));
     409        return(0);
     410    }
     411    ret = (wnd->getClass())->getClassWord(nIndex);
     412    dprintf(("USER32: GetClassWord %x %d returned %x", hwnd, nIndex, (ULONG)ret));
     413    return ret;
    414414}
    415415//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.