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.

81 lines
2.2 KiB

  1. ;***************************************************************************
  2. ;* KRNLPEEK.ASM
  3. ;*
  4. ;* Assembly code used to peer into the heart of KERNEL and return
  5. ;* information in global variables.
  6. ;*
  7. ;***************************************************************************
  8. INCLUDE TOOLPRIV.INC ;Include the TOOLHELP values
  9. PMODE32 = 0 ;This should work either way
  10. PMODE = 0
  11. INCLUDE WINKERN.INC
  12. INCLUDE WINDOWS.INC
  13. ;** Functions
  14. externFP GlobalMasterHandle
  15. externFP GlobalLock
  16. externFP GetVersion
  17. externFP GetProcAddress
  18. externFP GetModuleHandle
  19. externNP HelperHandleToSel
  20. sBegin DATA
  21. externB _szKernel
  22. sEnd DATA
  23. ;** Functions
  24. sBegin CODE
  25. assumes CS,CODE
  26. ; void KernelType(void)
  27. ;
  28. ; Returns information from KERNEL in global variables
  29. cProc KernelType, <PUBLIC>, <si,di>
  30. cBegin
  31. mov wTHFlags,0 ;Zero flags indicates error
  32. .286
  33. ;** Call the undocumented function GlobalMasterHandle to get
  34. ;* a pointer to the global HeapInfo structure.
  35. ;** This is the means we can use to detect the kernel types.
  36. cCall GlobalMasterHandle
  37. cCall HelperHandleToSel, <dx> ;Convert it to a selector
  38. mov hMaster,ax ;Save the handle
  39. mov wTHFlags,TH_KERNEL_386
  40. KT_BothPModes:
  41. ;** Now get pmode KERNEL information
  42. ; cCall GetVersion ;Which Windows version are we on
  43. mov bx,SEG GlobalLock ;KERNEL code segment selector
  44. ; cmp ax,0004h ;Win 4.0?
  45. ; je KT_Win31
  46. ; mov wTHFlags,0 ;Zero wTHFlags indicates error
  47. ; jmp SHORT KT_End ;Unknown Windows version
  48. KT_Win31:
  49. mov ax,seg _DATA
  50. mov dx,offset _DATA:_szKernel
  51. cCall GetModuleHandle,<ax,dx>
  52. cCall GetProcAddress,<ax,0,332> ; DX:AX -> hGlobalHeap
  53. mov segKernel,dx ;Save for later
  54. mov es,dx ;Point with ES
  55. add ax,4
  56. mov npwExeHead,ax
  57. add ax,10
  58. mov npwTDBHead,ax
  59. add ax,2
  60. mov npwTDBCur,ax
  61. add ax,6
  62. mov npwSelTableLen,ax
  63. add ax,2
  64. mov npdwSelTableStart,ax
  65. .8086
  66. KT_End:
  67. cEnd
  68. sEnd
  69. END