Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.2 KiB

  1. ;\
  2. ; give2gdi.asm
  3. ;
  4. ; Copyright (C) 1991, MicroSoft Corporation
  5. ;
  6. ; Contains code which changes memory metafile ownership to GDI
  7. ;
  8. ; History: sriniK 05/22/1991
  9. ;/
  10. include cmacros.inc
  11. include windows.inc
  12. .286
  13. ;**************************** Data Segment ********************************
  14. sBegin data
  15. assumes ds, data
  16. szGDI db 'GDI', 0
  17. szWEP db 'WEP', 0
  18. sEnd data
  19. ;*************************** Code Segment *********************************
  20. externFP GlobalRealloc
  21. externFP GlobalSize
  22. externFP GetModuleHandle
  23. externFP GetProcAddress
  24. createSeg Give2GDI, Give2GDI, para, public, code
  25. sBegin Give2GDI
  26. assumes cs,Give2GDI
  27. assumes ds,data
  28. assumes es,nothing
  29. ;**************************** Public Functions ****************************
  30. cProc GiveToGDI, <PUBLIC,FAR>
  31. ;
  32. ;
  33. ; HANDLE FAR PASCAL GiveToGDI(HANDLE hMem)
  34. ;
  35. ; Assign ownership of the given global memory block to GDI
  36. ;
  37. ; returns a handle to the memory block if successful, otherwise returns NULL
  38. ;
  39. parmW hMem
  40. localD lpGDIWEP
  41. cBegin
  42. ;*************************************************************
  43. ;** Get address of retf in fixed GDI code segment **
  44. ;*************************************************************
  45. push ds
  46. push dataOFFSET szGDI
  47. cCall GetModuleHandle
  48. push ax
  49. push ds
  50. push dataOFFSET szWEP
  51. cCall GetProcAddress
  52. mov [word ptr lpGDIWEP[0]], ax
  53. mov [word ptr lpGDIWEP[2]], dx
  54. ;*************************************************************
  55. ;** Kludge a call to GlobalReAlloc with GDI as caller **
  56. ;*************************************************************
  57. push 0 ; Params for WEP
  58. push cs ; GDI's WEP returns here
  59. push offset ReturnHere
  60. push hMem ; Params to GlobalReAlloc
  61. push 0
  62. push 0
  63. push [GMEM_MOVEABLE or GMEM_SHARE or GMEM_MODIFY]
  64. push [word ptr lpGDIWEP[2]] ; GlobalReAlloc returns here
  65. push [word ptr lpGDIWEP[0]] ; GlobalReAlloc returns here
  66. push 0 ; Params for WEP
  67. push seg GlobalReAlloc ; GDI's WEP returns here
  68. push offset GlobalReAlloc
  69. jmp lpGDIWEP ; Dive off the end
  70. ReturnHere:
  71. ;*************************************************************
  72. ;** Return handle to reallocated block **
  73. ;*************************************************************
  74. mov ax,hMem
  75. cEnd
  76. ;*************************************************************************
  77. sEnd Give2GDI
  78. end
  79. ;*************************************************************************