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.

54 lines
1.4 KiB

  1. externFP GetSelectorBase ; in KERNEL
  2. sBegin Data
  3. externD flatBase
  4. externW flatSel
  5. sEnd
  6. ;--------------------------------------------------------------------------;
  7. ;
  8. ; MapFlat - convert a 16:16 pointer into a 0:32 pointer
  9. ;
  10. ; note this macro assumes the memory will *not* move
  11. ; while being accessed. If this is not true call GlobalFix
  12. ; on the memory
  13. ;
  14. ; INPUT:
  15. ; ptr16 16:16 pointer to map flat.
  16. ; ptr32 put flat pointer here.
  17. ;
  18. ; OUTPUT:
  19. ; eax flat pointer (or pointer stored)
  20. ;
  21. ;--------------------------------------------------------------------------;
  22. assumes ds,Data
  23. assumes es,nothing
  24. MapFlat macro ptr16, ptr32
  25. ; is this call safe from a 32-bit seg?
  26. push word ptr ptr16[2]
  27. db 66h,9Ah ; call <far ptr GetSelectorBase>
  28. dw OFFSET GetSelectorBase
  29. dw SEG GetSelectorBase
  30. ror eax,16 ; xchg HIWORD(eax) and LOWORD(eax)
  31. shrd eax,edx,16 ; move LOWORD(edx) to HIWORD(eax)
  32. movzx edx,word ptr ptr16[0] ; add pointer offset
  33. add eax,edx
  34. sub eax,[flatBase] ; make relative to base offset
  35. ifb <ptr32>
  36. mov ptr16,eax
  37. else
  38. mov ptr32,eax
  39. endif
  40. endm
  41. FlatDS macro
  42. mov ds,[flatSel]
  43. mov es,[flatSel]
  44. endm