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.

518 lines
20 KiB

  1. TITLE KDATA - Kernel data area
  2. win3debdata=1
  3. include gpfix.inc ; include first to define segment order
  4. include kernel.inc
  5. include gpcont.inc ; do we alloc Sherlock data items?
  6. extrn __ahshift:ABS ; Pull in LDBOOT.ASM next from KERNOBJ.LIB
  7. sBegin CODE
  8. externFP Int21Handler
  9. sEnd CODE
  10. public __acrtused
  11. __acrtused = 9697
  12. ;------------------------------------------------------------------------
  13. ; Segment definations to define labels at the segment start. Don't put
  14. ; any code or data here.
  15. ;------------------------------------------------------------------------
  16. sBegin INITCODE
  17. labelB <PUBLIC,initcode>
  18. labelB <PUBLIC,beg_initcode>
  19. sEnd INITCODE
  20. DataBegin INIT
  21. labelB <PUBLIC,initdata>
  22. labelB <PUBLIC,beg_initdata>
  23. DataEnd INIT
  24. ;------------------------------------------------------------------------
  25. ; D A T A S E G M E N T V A R I A B L E S
  26. ;------------------------------------------------------------------------
  27. DataBegin
  28. ; The following items must remain in the same location and order. These
  29. ; items also appear in the initial paragraph of each application's DS.
  30. ORG 0
  31. DW 0
  32. globalW oOldSP,0
  33. globalW hOldSS,5
  34. globalW pLocalHeap,0
  35. globalW pAtomTable,0
  36. globalW pStackTop,<dataOffset gmove_stack_top>
  37. globalW pStackMin,<dataOffset gmove_stack>
  38. globalW pStackBot,<dataOffset gmove_stack>
  39. ;------------------------------------------------------------------------
  40. if KDEBUG
  41. ; If this word gets trashed, then we overflowed our stack
  42. globalW gmove_stack_sig,STACK_SIGNATURE,16
  43. endif
  44. labelB <PUBLIC,lpszFileName> ; Used in FileCDR_notify
  45. gmove_stack_top label byte
  46. EVEN
  47. DW 256 DUP (0) ; gmove requires at least 64 words
  48. globalW gmove_stack,0
  49. globalW prev_gmove_SP,0
  50. globalW prev_gmove_SS,0
  51. globalW ss_sel,0
  52. ;------------------------------------------------------------------
  53. ; The debugger requires that the following items remain in the same
  54. ; relative order.
  55. labelW <PUBLIC,THHOOK> ; So ToolHelp can find this stuff, too.
  56. globalW hGlobalHeap,0 ; Handle to master object
  57. globalW pGlobalHeap,0 ; Current physical address of master object
  58. globalW hExeHead,0 ; Head of module list maintained by Load/Free Module
  59. globalW hExeSweep,0 ; ... 1st module for LRU sweep to examine
  60. globalW topPDB,0 ; DOS PDB on entry
  61. globalW headPDB,0 ; link list of PDBs
  62. globalW topsizePDB,0 ; DOS PDB size upon entry
  63. globalW headTDB,0 ; head of task queue
  64. globalW curTDB,0 ; handle for currently running task
  65. globalW loadTDB,0 ; handle for currently loading task
  66. globalW LockTDB,0 ; handle of super task
  67. globalW SelTableLen,0 ; DONT MOVE THIS
  68. globalD SelTableStart,0 ; DONT MOVE THIS
  69. globalD hBmDPMI,0 ; DPMI handle to BurgerMaster
  70. ;------------------------------------------------------------------------
  71. globalW winVer,400h ; Windows version number for KERNEL.EXE header
  72. globalW fWinx,0 ; Flag from ldboot.asm
  73. globalW f8087,0 ; non zero if 8087 installed
  74. globalW PHTcount,0 ; Count of tasks with a PHT
  75. globalW hGDI,0 ; module handle of GDI
  76. globalW hUser,0 ; module handle of User
  77. globalW hShell,0 ; module handle of Shell
  78. globalW fLMdepth,0 ; # of recursive LoadModules
  79. globalW wDefRIP,0 ; Value to return from RIP in Debug
  80. globalB num_Tasks,0 ; number of tasks (i.e. TDB's) in system
  81. globalB InScheduler,0 ; True if inside scheduler
  82. globalB graphics,1 ; True if user/keyboard/gdi/display loaded
  83. DB 0
  84. globalB fastfp,1 ; True if suppress FWAIT before FOp
  85. ;globalW PID_for_fake,0 ; the PID allocated for the fake task
  86. ;globalW EMS_calc_swap_line,0 ; The calculated swap line
  87. ;globalW EMSCurPID,0 ; The current PID.
  88. globalW MaxCodeSwapArea,0 ; The max paragraphs SetSwapAreaSize can set.
  89. globalW selLowHeap,0 ; selector to Windows Low ( < 640k) heap block
  90. globalW cpLowHeap,0 ; count of paragraphs of Low heap block
  91. globalW selHighHeap,0 ; selector to Windows High ( >640k) heap block
  92. globalW selWoaPdb,0 ; selector to fixed low PDB for WinOldApp
  93. globalW sel_alias_array,0 ; the selector alias array (286 only)
  94. globalW temp_sel,0 ; Single pre-allocated selector
  95. globalD dressed_for_success,0 ; callback into OS/2 mapping layer at app start
  96. globalD InDOS,0 ; -> in dos flags and stuff
  97. globalD pSftLink,0 ; -> end of Sft chain when we started
  98. globalD lpWinSftLink,0 ; -> first node in chain that windows adds
  99. ifdef WOW
  100. globalD pDosWowData,0 ; -> rmode pointer to DosWowData in DOSDATA
  101. globalD pPMDosCDSCNT,0 ; -> DOS CDS Count variable
  102. globalD pPMDosCURDRV,0 ; -> DOS CurDrv variable
  103. globalD pPMDosPDB,0 ; -> pointer to PDB in DOSDATA
  104. globalD pPMDosExterr,0 ; -> pointer to DOS Exterr var (word)
  105. globalD pPMDosExterrLocus, 0 ; -> pointer to DOS ExterrLocus var (byte)
  106. globalD pPMDosExterrActionClass,0 ; -> pointer to DOS ExterrActionClass (word, byte each)
  107. endif
  108. globalD pFileTable,0 ; -> beginning of Sft chain
  109. globalW FileEntrySize,0 ; size of one sft entry
  110. globalD curDTA,0 ; what DOS thinks is the current DTA
  111. globalW cur_dos_PDB,0 ; what DOS thinks is the current PDB
  112. globalW Win_PDB,0 ; what we want the PDB to be
  113. globalW cur_drive_owner,0 ; last TDB to change the disk or directory
  114. globalB fBreak,0 ; state of dos break flag between e&d dos
  115. globalB LastDriveSwapped,0 ; drive letter of last drive where disk swap
  116. globalB DOS_version,0 ; DOS major version number
  117. globalB DOS_revision,0 ; DOS minor version number
  118. globalB fInt21,0 ; Flag indicating INT 21 hooks are installed
  119. globalB fNovell,0 ; Have Novell network
  120. globalB fPadCode,0 ; Pad code segments for 286 chip bug
  121. globalB CurDOSDrive,0FFh ; Current drive according to DOS
  122. globalB DOSDrives,26 ; number of logical drives from DOS
  123. ;----------------------------------------------------------------------
  124. ; PhantArray is a byte array indexed by zero based drive number.
  125. ; A non-zero value indicates the drive is phantom.
  126. globalB PhantArray,0,26
  127. ; Keyboard inquire structure
  128. globalB fFarEast,0 ; non zero means far eastern keyboard
  129. ifdef FE_SB
  130. labelB <PUBLIC,DBCSVectorTable> ;LanguageId, SizeOfDBCSVector, [BeginRange, EndRange] []
  131. dw 411h ;JAPAN
  132. db 4, 81h, 9Fh, 0E0h, 0FCh
  133. dw 412h ;KOREA
  134. db 2, 81h, 0FEh
  135. dw 404h ;TAIWAN
  136. db 2, 81h, 0FEh
  137. dw 804h ;PRC
  138. db 2, 81h, 0FEh
  139. dw 0C04h ;HONGKONG
  140. db 2, 81h, 0FEh
  141. db 0 ;End of table
  142. globalB fDBCSLeadTable,0,256 ; DBCS lead byte index table
  143. endif ;FE_SB
  144. globalB KeyInfo,0,%(SIZE KBINFO)
  145. ; Procedure addresses initialized by InitFwdRef
  146. ALIGN 4
  147. globalD pSysProc,0 ; -> SYSTEM.InquireSystem
  148. globalD pTimerProc,0 ; -> SYSTEM.CreateTimer
  149. globalD pSystemTermProc,0 ; -> SYSTEM.Disable
  150. globalD pKeyProc,0 ; -> KEYBOARD.AnsiToOem
  151. globalD pKeyProc1,0 ; -> KEYBOARD.OemToAnsi
  152. globalD pKeyboardTermProc,0 ; -> KEYBOARD.Disable
  153. globalD pKeyboardSysReq,0 ; -> KEYBOARD.EnableKBSysReq
  154. globalD pDisplayCritSec,0 ; -> DISPLAY.500
  155. globalD pMouseTermProc,0 ; -> MOUSE.Disable
  156. globalD pMBoxProc,0 ; -> USER.MessageBox
  157. globalD pSErrProc,0 ; -> USER.SysErrorBox
  158. globalD pExitProc,0 ; -> USER.ExitWindows
  159. globalD pDisableProc,0 ; -> USER.DisableOEMLayer
  160. globalD pUserInitDone,0 ; -> USER.routine to call when init is done
  161. globalD pPostMessage,0 ; -> USER.PostMessage function
  162. globalD pSignalProc,0 ; -> USER.SignalProc function
  163. globalD pIsUserIdle,0 ; -> USER.IsUserIdle function
  164. globalD pUserGetFocus,0 ; -> USER.GetFocus function
  165. globalD pUserGetWinTask,0 ; -> USER.GetWindowTask function
  166. globalD pUserIsWindow,0 ; -> USER.IsWindow function
  167. globalD pGetFreeSystemResources,0 ; -> USER.GetFreeSystemResources function
  168. globalD plstrcmp,0 ; -> USER.lstrcmp function
  169. globalD lpInt21,0 ; support for NOVELL stealing int 21h
  170. globalD myInt2F,0 ; support for NOVELL swapping with DOS apps
  171. globalD FatalExitProc,0 ; Intercept for FatalExit()
  172. globalD ptrace_dll_entry,0 ; -> ptrace engine DLL entry
  173. globalD ptrace_app_entry,0 ; -> real entry point for app
  174. globalD lpfnToolHelpProc,0 ; TOOLHELP.DLL PTrace function
  175. globalW wExitingTDB,0 ; Flag for DebugWrite--no debug strings at exit
  176. globalD shell_file_proc,0 ; -> shell for file create/del notify
  177. globalW shell_file_TDB,0 ; shell TDB
  178. if SWAPPRO
  179. globalD prevIntF0proc,0 ; -> previous Int F0h handler
  180. globalW hSwapPro,-1 ; file handle for swap profiler
  181. globalB fSwappro,0 ; 0 = no swap info, 1 = swaps, 2 = all
  182. DB 0
  183. endif
  184. globalD gcompact_start,0 ; start to measure swapping
  185. globalD gcompact_timer,0 ; time spent in gcompact to measure swapping
  186. ifdef FE_SB
  187. ifndef KOREA
  188. globalD pJpnSysProc,0 ; -> SYSTEM.JapanInquireSystem
  189. endif
  190. endif
  191. globalW WinFlags,0 ; see kernel.inc for defs of these
  192. globalB Kernel_Flags,0,4 ; see kernel.inc for defs of these
  193. ;
  194. ; WARNING!! Do not disturb the order of the next two variables....
  195. ; See GetLPErrormode in INT24.ASM ARR 7/23/87
  196. ;
  197. globalB Kernel_InDOS,0 ; set when we call the REAL DOS
  198. globalB Kernel_InINT24,0 ; set when Int 24h calls DOS funcs < 13
  199. ; fBooting bits:
  200. ; bit 1 (2h) is reset after kernel is loaded (for fixed blks alloc strategy)
  201. ; fBooting is zeroed as a whole after full booting by bootdone
  202. globalB fBooting,3 ; Set to zero by bootdone
  203. globalB fChkSum,0 ; Flag set if segment checksumming enabled
  204. globalB fCheckFree,1 ; Set to zero by slowboot
  205. globalB cdevat,0 ; Int 24 state
  206. globalB errcap,0 ; Int 24 error capabilities mask
  207. ifndef WOW
  208. ; profile APIs are thunked
  209. globalB fProfileDirty,0 ; Profiles need writing
  210. globalB fProfileMaybeStale,0 ; Profiles MAY need to be reread
  211. globalB fWriteOutProfilesReenter,0 ; Are we currently in WriteOutProfiles?
  212. endif
  213. globalB fPokeAtSegments,1 ; Idle time load of segments
  214. globalB fTaskSwitchCalled, 0 ; Local Reboot only works when task switching
  215. globalD WinAppHooks,0 ; winapps can hook this for std winoldap.
  216. public WOAName
  217. WOAName DB 'WINOLDAP.MOD',0
  218. globalB grab_name,0,128
  219. ALIGN 4
  220. globalD lpWindowsDir,0 ; -> to WFP of where win.ini lives
  221. globalD lpSystemDir,0 ; -> to WFP of where kernel lives
  222. globalW cBytesWinDir,0 ; length of WFP for windows dir
  223. globalW cBytesSysDir,0 ; length of WFP for system dir
  224. ifdef WOW
  225. globalD lpSystemRootDir,0 ; -> value of SystemRoot environment var
  226. globalD lpSystem16Dir,0 ; -> to WFP of \windows\system
  227. globalD lpSystemWx86Dir,0 ; \windows\system32\Wx86
  228. globalW cBytesSystemRootDir,0 ; length of SystemrootEnvironment var
  229. globalW cBytesSys16Dir,0 ; in WOW lpSystemDir points to \windows\system32
  230. globalW cBytesSysWx86Dir,0 ; in WOW Windows\system32\Wx86
  231. public Sys16Suffix
  232. Sys16Suffix DB '\system' ; append to WinDir to get lpSystem16Dir
  233. public cBytesSys16Suffix
  234. cBytesSys16Suffix DW ($ - dataoffset Sys16Suffix)
  235. public SysWx86Suffix
  236. SysWx86Suffix DB '\Sys32x86' ; append to WinDir to get lpSystemWx86Dir
  237. public cBytesSysWx86Suffix
  238. cBytesSysWx86Suffix DW ($ - dataoffset SysWx86Suffix)
  239. endif
  240. globalD lpGPChain,0 ; GP fault hack for WEPs - chain to this addr
  241. if SHERLOCK
  242. globalW gpTrying,0 ; Trying to continue after a GP fault
  243. globalW gpEnable, 1 ; Enable GP continuation
  244. globalW gpInsLen, 0 ; Length of faulting instruction
  245. globalW gpSafe, 0 ; OK to skip current instruction
  246. globalW gpRegs, 0 ; Regs modified by faulting insn
  247. globalW gpStack, 0 ; movement of stack by faulting insn
  248. endif
  249. ifndef WOW
  250. ; The profile APIs are thunked for WOW
  251. globalB WinIniInfo,0,%(size PROINFO)
  252. globalB PrivateProInfo,0,%(size PROINFO)
  253. endif ; ndef WOW
  254. public szUserPro
  255. szUserPro DB 'WIN.INI',0
  256. ifndef WOW
  257. DB 72 dup (0) ; Room for a long path
  258. ;;;globalB fUserPro,0 ; Current Profile is WIN.INI
  259. ;;;globalD lpszUserPro,0
  260. endif
  261. ; ndef WOW
  262. ifdef WOW
  263. globalW hWinnetDriver, 0
  264. endif ;WOW
  265. globalW BufPos,0 ; buffer pointer with OutBuf
  266. globalB OutBuf,0,70 ; 70 character out buffer
  267. EVEN
  268. globalW MyCSAlias,0 ; Kernel's CS/DS Alias
  269. globalW MyCSSeg,0 ; Kernel's CS as a segment
  270. globalW MyDSSeg,0 ; Kernel's DS as a segment
  271. globalW hLoadBlock,0 ; Handle that points to in memory file image
  272. globalW segLoadBlock,0 ; Segment address of file image
  273. globalW wMyOpenFileReent, 0 ; Reentrant flag for MyOpenFile
  274. globalW cpShrink,0
  275. globalW cpShrunk,0 ; Delta from beginning of file to hLoadBlock
  276. globalW PagingFlags,0
  277. globalW ArenaSel,0
  278. globalW FirstFreeSel,0
  279. globalW CountFreeSel,0
  280. globalD FreeArenaList,0
  281. globalD FreeArenaCount,0
  282. globalD HighestArena,0
  283. globalD temp_arena,0
  284. globalD NextCandidate,-1
  285. globalW Win386_Blocks,0
  286. globalW InitialPages,0
  287. globalD lpReboot,0 ; Reboot VxD address
  288. globalW BaseDsc,0
  289. globalW kr1dsc,0
  290. globalW kr2dsc,0
  291. globalW blotdsc,0
  292. globalW DemandLoadSel,0
  293. globalW fhcStealNext,<(MAXFHCACHELEN-1)*size fhCacheStruc+dataOffset fhCache> ; Next fhCache entry to use
  294. globalW fhCacheEnd,<MAXFHCACHELEN*size fhCacheStruc+dataOffset fhCache> ; End of the cache
  295. globalW fhCacheLen,MINFHCACHELEN
  296. globalB fhCache,0,%(MAXFHCACHELEN*size fhCacheStruc)
  297. if KDEBUG
  298. globalB fLoadTrace, 0
  299. globalB fPreloadSeg, 0
  300. globalB fKTraceOut, 0 ; Used by DebugWrite to ignore traces
  301. ; to be sent to PTrace
  302. endif
  303. globalB fDW_Int21h, 0FFh ; FF if okay for DebugWrite to use Int 21h
  304. ALIGN 2
  305. if 0; EarleH
  306. globalW LastCriticalError,-1
  307. endif
  308. globalW LastExtendedError,-1,3 ; Don't move this
  309. globalW Reserved,0,8 ; Don't move this
  310. ifdef WOW
  311. ;------------------------------------------------------------------------
  312. ; W O W G L O B A L D A T A
  313. ;------------------------------------------------------------------------
  314. public achTermsrvWindowsDir ; per user windows directory (for .ini files)
  315. achTermsrvWindowsDir DB MaxFileLen dup (0)
  316. globalW wCurTaskSS,0 ; Currently Running Task SS
  317. globalW wCurTaskBP,0 ; Currently Running Task BP
  318. globalD Dem16to32handle,0 ; -> DOS Emulation 16 to 32 bit handle convertion
  319. globalD FastBop,0 ; eip value for fast bop entry point
  320. globalW FastBopCS,0 ; CS value for fast bop entry point
  321. globalD FastWOW,0 ; eip for fast WOW32 entry point when doing thunk call
  322. globalW FastWOWCS,0 ; CS value for fast wow entry point
  323. globalD FastWOWCbRet,0 ; eip for fast WOW32 entrypoint to return from callback
  324. globalW FastWOWCbRetCS,0; cs for above
  325. globalW WOWFastBopping,0; non-zero if fast call to WOW32 enabled
  326. ; Jmp indirect through here for faster bops
  327. globalB fExitOnLastApp,0 ; Close WOW when the last app exits (not WOWEXEC)
  328. globalB fShutdownTimerStarted,0 ; 1 if the shutdown timer is running (shared WOW)
  329. ;; do not rearrange these or stick anything in the middle!
  330. ;;
  331. ;;
  332. wowtablemodstart label byte
  333. globalW MOD_KERNEL ,0 ; kernel must be first!
  334. globalW MOD_DKERNEL ,0
  335. globalW MOD_USER ,0
  336. globalW MOD_DUSER ,0
  337. globalW MOD_GDI ,0
  338. globalW MOD_DGDI ,0
  339. globalW MOD_KEYBOARD ,0
  340. globalW MOD_SOUND ,0
  341. globalW MOD_SHELL ,0
  342. globalW MOD_WINSOCK ,0
  343. globalW MOD_TOOLHELP ,0
  344. globalW MOD_MMEDIA ,0
  345. globalW MOD_COMMDLG ,0
  346. ifdef FE_SB
  347. globalW MOD_WINNLS ,0
  348. globalW MOD_WIFEMAN ,0
  349. endif ; FE_SB
  350. globalW ModCount ,<($ - dataoffset wowtablemodstart) / 2>
  351. ;;
  352. ;;
  353. ;; do not rearrange these or stick anything in the middle!
  354. globalW DebugWOW,1 ; bit 0 = 1 WOW is being debugged, 0 = WOW is not
  355. globalW TraceOff,0 ; bit 0 = 1 turn off trace interrupts during apis
  356. globalW WOWLastError,0 ; Last error returned by int 21
  357. globalB WOWErrClass, 0
  358. globalB WOWErrAction, 0
  359. globalB WOWErrLocation, 0
  360. endif
  361. globalD Dos_Flag_Addr, 0
  362. DataEnd
  363. ;------------------------------------------------------------------------
  364. ; C O D E S E G M E N T V A R I A B L E S
  365. ;------------------------------------------------------------------------
  366. sBegin CODE
  367. assumes cs,CODE
  368. EVEN
  369. dw 18h dup(0F4CCh) ; Catch them jmps, calls & rets to 0
  370. ; and offset segment for putting in HMA
  371. globalW MyCSDS,0 ; Kernel's DS
  372. globalW gdtdsc,0
  373. ALIGN 4
  374. globalD pYieldProc,0 ; -> USER.UserYield
  375. globalD pStringFunc,0 ; -> USER.StringFunc function
  376. globalD prevInt21proc,0 ; -> previous INT 21h handler
  377. globalD prevInt24proc,0 ; -> previous Int 24h handler
  378. globalD prevInt2Fproc,0 ; -> previous Int 24h handler
  379. globalD prevInt3Fproc,0 ; -> previous Int 3Fh handler
  380. globalD prevInt67proc,0 ; -> previous Int 67h handler
  381. globalD prevInt00proc,0 ; -> previous INT 00h handler !! don't move
  382. ; !! don't move
  383. globalD prevInt02proc,0 ; -> previous INT 02h handler !! don't move
  384. globalD prevInt04proc,0 ; -> previous INT 04h handler !! don't move
  385. globalD prevInt06proc,0 ; -> previous INT 06h handler !! don't move
  386. globalD prevInt07proc,0 ; -> previous INT 07h handler !! don't move
  387. globalD prevInt3Eproc,0 ; -> previous INT 3Eh handler !! don't move
  388. globalD prevInt75proc,0 ; -> previous INT 75h handler !! don't move
  389. globalD prevIntx6proc,0 ; -> previous invalid op-code Fault handler
  390. globalD prevInt0Cproc,0 ; -> previous stack fault handler
  391. globalD prevInt0Dproc,0 ; -> previous GP Fault handler
  392. globalD prevInt0Eproc,0 ; -> previous Page Fault handler
  393. ifdef WOW
  394. globalD prevInt31proc,0 ; used to speed dpmi calls
  395. globalD oldInt00proc,0 ; for debugging traps
  396. globalD prevInt01proc,0 ; for debugging traps
  397. globalD prevInt03proc,0 ; for debugging traps
  398. globalD prevInt10proc,0 ; -> previous INT 10 handler
  399. endif
  400. if 0
  401. PUBLIC DummyKeyboardOEMToAnsi
  402. DummyKeyboardOEMToAnsi proc far
  403. ret ; used for non-graphics version
  404. DummyKeyboardOEMToAnsi endp
  405. endif
  406. sEnd CODE
  407. ;------------------------------------------------------------------------
  408. ; I N I T D A T A S E G M E N T V A R I A B L E S
  409. ;------------------------------------------------------------------------
  410. DataBegin INIT
  411. globalW oNRSeg,0
  412. globalW oMSeg,0
  413. globalD lpBootApp,0 ; Long pointer to app to run after booting
  414. ifndef WOW
  415. ; WOW doesn't muck with WOAName buffer, we leave it as WINOLDAP.MOD
  416. labelB <PUBLIC,woa_286>
  417. db 'WINOLDAP.MOD'
  418. labelB <PUBLIC,woa_386>
  419. db 'WINOA386.MOD'
  420. endif
  421. labelB <PUBLIC,bootExecBlock>
  422. EXECBLOCK <0,0,0,0>
  423. globalW win_show,2
  424. dw 1 ; show open window
  425. DataEnd INIT
  426. end