home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_04 / 3n04050b < prev    next >
Text File  |  1992-02-11  |  3KB  |  102 lines

  1. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Begin Listing2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. /*****************************************************/
  3. /* mlefix.c                                          */
  4. /* -- Program to fix the leaky MLE bug.              */
  5. /*****************************************************/
  6.  
  7. #define NOCOMM
  8. #include <windows.h>
  9. #include "win.h"
  10.  
  11. typedef LONG (FAR PASCAL * LPFN_WNDPROC)
  12.     (HWND, WORD, WORD, DWORD);
  13.  
  14. HANDLE          hmemUser;
  15. LPFN_WNDPROC    lpfnMLEFilter;
  16.  
  17. LONG    FAR PASCAL  MLEFilter(WORD, WORD, WORD, DWORD);
  18. LONG    FAR PASCAL  MLEStub(WORD, WORD, WORD, DWORD);
  19. int     FAR PASCAL  LibMain(HANDLE, WORD, WORD, LPSTR);
  20. int     FAR PASCAL  WEP(short);
  21.  
  22. int FAR PASCAL
  23. LibMain(HANDLE hins, WORD ds, WORD cbHeap, LPSTR lsz)
  24. /*****************************************************/
  25. /* -- hins      : This library's instance.           */
  26. /* -- ds        : The library's default data segment */
  27. /* -- cbHeap    : Size of out local heap.            */
  28. /* -- lsz       : Command line invoked with.         */
  29. /*****************************************************/
  30.     {
  31.     WORD        wVersion    = GetVersion();
  32.     WNDCLASS    wcs;
  33.  
  34.     /* Only need to fix this bug for version 3.0. */
  35.     if (LOBYTE(wVersion) != 3 || HIBYTE(wVersion) != 0)
  36.         return FALSE;
  37.  
  38.     /* Get USER's default data segment. */
  39.     if ((hmemUser = LoadLibrary("user.exe")) == 0)
  40.         return FALSE;
  41.  
  42.     /* Superclass the edit class. */
  43.     GetClassInfo(NULL, "edit", &wcs);
  44.     lpfnMLEFilter = (LPFN_WNDPROC)wcs.lpfnWndProc;
  45.     UnregisterClass("edit", NULL);
  46.     wcs.lpfnWndProc = MLEStub;
  47.     RegisterClass(&wcs);
  48.  
  49.     return TRUE;
  50.     }
  51.  
  52. int FAR PASCAL
  53. WEP(short wCode)
  54. /*****************************************************/
  55. /* -- The usual do-nothing stub.                     */
  56. /*****************************************************/
  57.     {
  58.     return FALSE;
  59.     }
  60.  
  61. LONG FAR PASCAL
  62. MLEFilter(WORD hwnd, WORD wm, WORD wParam,
  63.   DWORD lParam)
  64. /*****************************************************/
  65. /* -- Superclasser for MLE's.                        */
  66. /* -- hwnd             : Main window.                */
  67. /* -- wm               : Message type.               */
  68. /* -- wParam, lParam   : Message parameters.         */
  69. /*****************************************************/
  70.     {
  71.     LONG    lVal;
  72.  
  73.     _asm    mov ax,dx;
  74.     lVal = (*lpfnMLEFilter)(hwnd, wm, wParam, lParam);
  75.  
  76.     if (wm == WM_NCCREATE &&
  77.         (GetWindowLong(hwnd, GWL_STYLE) &
  78.             (WS_VSCROLL | WS_HSCROLL)))
  79.         {
  80.         WORD    dsUser  = HIWORD(GlobalLock(hmemUser));
  81.         WORD    dsLocal;
  82.  
  83.         _asm    mov dsLocal, ds;    /* Save ds. */
  84.         _asm    mov ds, dsUser;     /* Get USER ds. */
  85.  
  86.         /* Free dangling USER heap memory. */
  87.         if (((WND *)hwnd)->unknown4 != 0)
  88.         {
  89.             LocalFree(((WND *)hwnd)->unknown4);
  90.             ((WND *)hwnd)->unknown4 = 0;
  91.         }
  92.  
  93.         _asm    mov ds, dsLocal;    /* Restore ds. */
  94.  
  95.         /* In case of REAL mode. */
  96.         GlobalUnlock(hmemUser);
  97.         }
  98.  
  99.     return lVal;
  100.     }
  101. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=End Listing2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  102.