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.

139 lines
3.7 KiB

  1. ;\
  2. ; ole.asm
  3. ;
  4. ; Copyright (C) 1991, MicroSoft Corporation
  5. ;
  6. ; Contains pointer vaildation routine
  7. ;
  8. ; History: sriniK 02/01/1991 original
  9. ; srinik 02/21/1991 added GetGDIds, IsMetaDC
  10. ;/
  11. .286p
  12. .MODEL SMALL
  13. .CODE
  14. ;**************************** _CheckPointer ****************************
  15. ;
  16. ; WORD CheckPointer (lp, access)
  17. ;
  18. ; Args:
  19. ; lp pointer to be verified
  20. ; access 0 test the pointer for read access
  21. ; 1 test the pointer for write access
  22. ; returns:
  23. ; FALSE invalid pointer
  24. ; TRUE valid pointer
  25. ;
  26. ;
  27. ;
  28. public _CheckPointer
  29. _CheckPointer proc
  30. push bp
  31. mov bp, sp
  32. xor ax, ax
  33. and word ptr [bp+8], -1
  34. jnz check_write_access
  35. verr word ptr [bp+6] ; check selector for read access
  36. jnz error
  37. jmp short check_offset
  38. check_write_access:
  39. verw word ptr [bp+6] ; check selector for write access
  40. jnz error
  41. check_offset:
  42. lsl bx, word ptr [bp+6] ; segment limit gets copied into BX
  43. jnz error
  44. cmp [bp+4], bx
  45. ja error
  46. or ax, -1
  47. error:
  48. pop bp
  49. ret
  50. _CheckPointer endp
  51. ;**************************** _GetGdiDS ****************************
  52. ;
  53. ; WORD GetGDIds (lpGdiFunc)
  54. ;
  55. ; Args:
  56. ; lpGdiFunc long pointer to one of the GDI functions, with selector
  57. ; part being aliased to a data selector
  58. ; returns:
  59. ; GDI DS value
  60. ;
  61. public _GetGDIds
  62. _GetGDIds proc
  63. push bp
  64. mov bp, sp
  65. mov ax, word ptr [bp+6] ; data selector
  66. push ds
  67. mov ds, ax
  68. mov bx, word ptr [bp+4]
  69. mov ax, word ptr ds:[bx+1]
  70. pop ds
  71. pop bp
  72. ret
  73. _GetGDIds endp
  74. ;**************************** _IsMetaDC ****************************
  75. ;
  76. ; WORD IsMetaDC (hdc, wGDIds)
  77. ;
  78. ; Args:
  79. ; hdc handle device context
  80. ; wGDIds GDI's data segment selector
  81. ;
  82. ; returns:
  83. ; TRUE if hdc is metafile dc
  84. ; FALSE otherwise
  85. ;
  86. ; ilObjHead struc
  87. ; dw ? ; pointer to next obj in chain
  88. ; ilObjType dw ? ; defines type of object
  89. ; ilObjCount dd ? ; the count of the object
  90. ; ilObjMetaList dw ? ; handle to the list of metafile
  91. ; ilObjHead ends
  92. ;
  93. public _IsMetaDC
  94. OBJ_METAFILE equ 10
  95. _IsMetaDC proc
  96. push bp
  97. mov bp, sp
  98. mov ax, [bp+6] ; data selector
  99. push ds
  100. mov ds, ax
  101. mov di, [bp+4] ; hdc
  102. mov di, [di]
  103. cmp word ptr [di+2], OBJ_METAFILE
  104. jz metafile
  105. xor ax, ax
  106. metafile:
  107. pop ds
  108. pop bp
  109. ret
  110. _IsMetaDC endp
  111. end