rtl.inc
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 3k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. externFP   GetProcAddress
  2.         externFP   LoadLibrary
  3.         externFP   GetModuleHandle
  4.         externFP   FatalAppExit
  5. ifndef CodeSeg
  6.         CodeSeg equ <Code>
  7. endif
  8. ;------------------------------------------------------------------------------
  9. ;
  10. ; MACRO RTL_PROC
  11. ;
  12. ; USAGE:
  13. ;   RTL_PROC ProcName, ModuleName, Ordinal, loadds?
  14. ;
  15. ;   ProcName    - api name to stub
  16. ;   ModuleName  - module to run-time-link to.
  17. ;   Ordinal     - export ordinal
  18. ;   loadds?     - should we loadds
  19. ;
  20. ; EXAMPLE:
  21. ;
  22. ;   RTL_PROC    ShellAbout, SHELL, 1
  23. ;
  24. ;------------------------------------------------------------------------------
  25. RTL_PROC macro ProcName, ModuleName, Ordinal, LoadProc, loadds?
  26. sBegin Data
  27. ;;public ModuleName&ProcName&
  28. ModuleName&ProcName& label dword
  29.         dw offset Load&ModuleName&ProcName&
  30.         dw seg    Load&ModuleName&ProcName&
  31. ifdef DEBUG
  32.         db  "&ProcName&", 0
  33. endif
  34. sEnd    Data
  35. sBegin CodeSeg
  36.         assumes cs,CodeSeg
  37.         assumes ds,nothing
  38.         assumes es,nothing
  39. public &ProcName&
  40. &ProcName& proc far
  41.         call    LoadProc
  42. ifnb <loadds?>
  43. mov bx,DataBASE
  44.         mov     es,bx
  45.         assumes es,Data
  46. else
  47.         assumes ds,Data
  48. endif
  49.         jmp     dword ptr [ModuleName&ProcName&]
  50. &ProcName& endp
  51. ;;public Load&ModuleName&ProcName&
  52. Load&ModuleName&ProcName& proc near
  53. ifdef DEBUG
  54.         mov     cx,Ordinal
  55.         lea     bx,ModuleName&ProcName&+4
  56.         call    rtl_debug
  57. endif
  58. ifnb <loadds?>
  59.         Save    <es>
  60. endif
  61.         cCall   GetProcAddress,<ax,0,Ordinal>
  62.         mov     word ptr [ModuleName&ProcName&][0],ax
  63.         mov     word ptr [ModuleName&ProcName&][2],dx
  64.         jmp     short &ProcName&
  65. Load&ModuleName&ProcName& endp
  66. sEnd    CodeSeg
  67.         endm
  68. sBegin CodeSeg
  69.         assumes cs,CodeSeg
  70. assumes ds,nothing
  71. assumes es,nothing
  72. ;---------------------------------------------------------------------------;
  73. ;       cx --> Ordinal
  74. ;       es:bx --> szProc
  75. ;---------------------------------------------------------------------------;
  76. ifdef DEBUG
  77. externFP   OutputDebugString
  78. externFP   _wsprintf
  79. format_string:
  80.         db      "SHELL: RTL: %ls@%d",13,10,0
  81. rtl_debug proc near
  82.         push    ds
  83.         push    es
  84. pusha
  85. sub sp,128
  86. mov si,sp
  87.         push    cx                      ; %d
  88.         push    es                      ; %ls
  89.         push    bx
  90.         lea     ax,format_string        ; format string
  91. push cs
  92.         push    ax
  93.         push    ss                      ; buffer
  94. push si
  95. call _wsprintf
  96.         add     sp,7*2                  ; clear 9 words
  97.         cCall   OutputDebugString,<ss,si>
  98.         add     sp,128
  99.         popa
  100.         pop     es
  101.         pop     ds
  102.         ret
  103. rtl_debug endp
  104. endif
  105. sEnd CodeSeg