Source code of Windows XP (NT5)
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.

436 lines
11 KiB

  1. ;++
  2. ;
  3. ; WOW v1.0
  4. ;
  5. ; Copyright (c) 1991, Microsoft Corporation
  6. ;
  7. ; USER.ASM
  8. ; Win16 USER thunks
  9. ;
  10. ; History:
  11. ;
  12. ; Created 25-Jan-1991 by Jeff Parsons (jeffpar)
  13. ; Added Win 31 thunks 22nd-March-1992 by Chandan S. Chauhan (ChandanC)
  14. ;
  15. ;--
  16. TITLE USER.ASM
  17. PAGE ,132
  18. ; Some applications require that USER have a heap. This means
  19. ; we must always have: LIBINIT equ 1
  20. LIBINIT equ 1
  21. .286p
  22. .xlist
  23. include wow.inc
  24. include wowusr.inc
  25. include cmacros.inc
  26. NOEXTERNS=1 ; to suppress including most of the stuff in user.inc
  27. include user.inc
  28. .list
  29. __acrtused = 0
  30. public __acrtused ;satisfy external C ref.
  31. ifdef LIBINIT
  32. externFP LocalInit
  33. endif
  34. externFP LW_InitNetInfo
  35. ifndef WOW
  36. externNP LW_DriversInit
  37. endif
  38. externFP GetModuleHandle
  39. externFP SetTaskSignalProc
  40. externFP NewSignalProc
  41. externFP IsWindow
  42. externFP CreateQueue
  43. externFP WOW16Call
  44. externFP TileWindows
  45. externFP CascadeWindows
  46. createSeg _TEXT,CODE,WORD,PUBLIC,CODE
  47. createSeg _DATA,DATA,WORD,PUBLIC,DATA,DGROUP
  48. defgrp DGROUP,DATA
  49. sBegin DATA
  50. DontMove db 2 dup (0) ; <<< WARNING 2 bytes *must* be reserved at the start
  51. ; users DS for compatability >>>>
  52. Reserved db 16 dup (0) ;reserved for Windows
  53. USER_Identifier db 'USER16 Data Segment'
  54. fFirstApp db 1
  55. externD LPCHECKMETAFILE;
  56. ExternW <hInstanceWin>
  57. ExternW <hWinnetDriver>
  58. GlobalW hwndSysModal,0
  59. sEnd DATA
  60. ;
  61. ; GP fault exception handler table definition
  62. ;
  63. sBegin GPFIX0
  64. __GP label word
  65. public __GP
  66. sEnd GPFIX0
  67. sBegin CODE
  68. assumes CS,CODE
  69. assumes DS,DATA
  70. assumes ES,NOTHING
  71. ifdef LIBINIT
  72. externFP LibMain
  73. endif
  74. ifdef WOW
  75. externFP EnableSystemTimers
  76. externFP SetDivZero
  77. endif
  78. cProc USER16,<PUBLIC,FAR,PASCAL,NODATA,NOWIN,ATOMIC>
  79. cBegin <nogen>
  80. ifdef WOW
  81. call EnableSystemTimers
  82. endif
  83. IFDEF LIBINIT
  84. ; push params and call user initialisation code
  85. push di ;hModule
  86. mov hInstanceWin, di
  87. ; if we have a local heap declared then initialize it
  88. jcxz no_heap
  89. push 0 ;segment
  90. push 0 ;start
  91. push cx ;length
  92. call LocalInit
  93. no_heap:
  94. call LibMain ;return exit code from LibMain
  95. ELSE
  96. mov ax,1 ;are we dressed for success or WHAT?!
  97. ENDIF
  98. push ax
  99. cmp hInstanceWin, 0
  100. jne hInstNotNull
  101. mov hInstanceWin, di
  102. hInstNotNull:
  103. ifndef WOW
  104. call LW_DriversInit
  105. endif
  106. pop ax
  107. ret
  108. cEnd <nogen>
  109. cProc InitApp,<PUBLIC,FAR,PASCAL,NODATA,NOWIN,ATOMIC>
  110. parmW hInst ; App's hInstance
  111. cBegin
  112. mov ax,8 ; MAGIC Win3.1 default message queue size
  113. push ax ; NOTE Win3.1 (and User32) read the size
  114. call CreateQueue ; from win.ini, we don't.
  115. cmp ax,0 ; hq
  116. jne IA_HaveQ
  117. mov ax,0 ; return FALSE
  118. jmp IA_Ret
  119. IA_HaveQ:
  120. push ds
  121. mov ax, _DATA ; set USER16's DS
  122. mov ds,ax
  123. assumes ds, DATA
  124. xor dx,dx
  125. push dx
  126. push seg NewSignalProc
  127. push offset NewSignalProc
  128. call SetTaskSignalProc
  129. ;
  130. ; Init WNET apis.
  131. ;
  132. cmp fFirstApp, 1
  133. jne IA_notfirstapp
  134. mov fFirstApp, 0
  135. call LW_InitNetInfo
  136. IA_notfirstapp:
  137. ;
  138. ; Setup Divide By Zero handler
  139. ;
  140. call SetDivZero
  141. mov ax,1
  142. xor dx,dx
  143. pop ds
  144. IA_Ret:
  145. cEnd
  146. assumes DS,NOTHING
  147. cProc WEP,<PUBLIC,FAR,PASCAL,NODATA,NOWIN,ATOMIC>
  148. parmW iExit ;DLL exit code
  149. cBegin
  150. mov ax,1 ;always indicate success
  151. cEnd
  152. ;*--------------------------------------------------------------------------*
  153. ;*
  154. ;* LFillStruct() -
  155. ;*
  156. ;*--------------------------------------------------------------------------*
  157. cProc LFillStruct, <PUBLIC, FAR, NODATA, ATOMIC>,<di>
  158. parmD lpStruct
  159. parmW cb
  160. parmW fillChar
  161. cBegin
  162. les di,lpStruct
  163. mov cx,cb
  164. mov ax,fillChar
  165. cld
  166. rep stosb
  167. cEnd
  168. ;*--------------------------------------------------------------------------*
  169. ;* *
  170. ;* GetSysModalWindow() - *
  171. ;* *
  172. ;*--------------------------------------------------------------------------*
  173. cProc GetSysModalWindow, <PUBLIC, FAR>
  174. cBegin nogen
  175. mov ax,_DATA
  176. nop
  177. mov es,ax
  178. mov ax,es:[hwndSysModal]
  179. or ax,ax
  180. jz GSMW_ItsZero
  181. push es
  182. push ax ; make sure we only return valid
  183. call IsWindow ; windows.
  184. pop es
  185. or ax,ax
  186. jnz GSMW_ItsNotZero
  187. mov es:[hwndSysModal], ax ; zero out hwndSysModal
  188. GSMW_ItsNotZero:
  189. mov ax,es:[hwndSysModal]
  190. GSMW_ItsZero:
  191. retf
  192. cEnd nogen
  193. ;*--------------------------------------------------------------------------*
  194. ;* *
  195. ;* SetSysModalWindow() - *
  196. ;* *
  197. ;*--------------------------------------------------------------------------*
  198. cProc ISetSysModalWindow, <PUBLIC, FAR>
  199. ParmW hwnd
  200. cBegin nogen
  201. mov ax,_DATA
  202. nop
  203. mov es,ax
  204. mov bx,sp
  205. mov ax,ss:[bx+4]
  206. xchg ax,es:[hwndSysModal]
  207. retf 2
  208. cEnd nogen
  209. ;
  210. ; The DWPBits table defines which messages have actual processing for
  211. ; DefWindowProc. We get these bits from user32. User32 assumes the
  212. ; buffer passed in is zero-initialized, hence the DUP(0) below.
  213. ;
  214. DWPBits DB 101 DUP(0) ; Room for bits for msgs 0 - 807 (decimal)
  215. public DWPBits
  216. cbDWPBits DW ($ - codeoffset DWPBits)
  217. public cbDWPBits
  218. MaxDWPMsg DW 0
  219. public MaxDWPMsg
  220. ;*--------------------------------------------------------------------------*
  221. ;*
  222. ;* CheckDefWindowProc()
  223. ;*
  224. ;* Checks to see if the message gets processed by DefWindowProc. If not,
  225. ;* the API returns 0.
  226. ;*
  227. ;*--------------------------------------------------------------------------*
  228. ALIGN 4
  229. cProc CheckDefWindowProc, <PUBLIC, NEAR>
  230. parmW hWnd
  231. parmW wMsg
  232. parmW wParam
  233. parmD lParam
  234. parmD lpReturn ; Callers Return Address
  235. ;parmW wBP ; Thunk saved BP
  236. ;parmW wDS ; Thunk saved DS
  237. cBegin
  238. mov bx,wMsg
  239. cmp bx,cs:MaxDWPMsg
  240. ja @f ; jump if above (return with 0)
  241. mov cx,bx
  242. shr bx,3 ; make byte index into table
  243. mov al,cs:[bx+DWPBits] ; get proper 8-bits
  244. and cx,0007H
  245. shr al,cl ; get proper bit into bit 0 of al
  246. test al,1
  247. jz @f
  248. mov sp,bp ; Do cEnd without Ret count (leave parameters there)
  249. pop bp
  250. ret
  251. @@:
  252. pop bp
  253. xor ax,ax ; return (ULONG)0 to flag no window processing
  254. add sp,2 ; skip thunk IP
  255. xor dx,dx ; return (ULONG)0 to flag no window processing
  256. retf 10 ; 10 bytes to pop
  257. cEnd <nogen>
  258. UserThunk ADJUSTWINDOWRECT
  259. UserThunk ADJUSTWINDOWRECTEX
  260. ; Hack to use original IDs. These functions have local implementations
  261. ; that thunk to Win32 if the locale is other than U.S. English.
  262. FUN_WIN32ANSILOWER equ FUN_ANSILOWER
  263. FUN_WIN32ANSILOWERBUFF equ FUN_ANSILOWERBUFF
  264. FUN_WIN32ANSINEXT equ FUN_ANSINEXT
  265. FUN_WIN32ANSIPREV equ FUN_ANSIPREV
  266. FUN_WIN32ANSIUPPER equ FUN_ANSIUPPER
  267. FUN_WIN32ANSIUPPERBUFF equ FUN_ANSIUPPERBUFF
  268. DUserThunk WIN32ANSILOWER, %(size ANSILOWER16)
  269. DUserThunk WIN32ANSILOWERBUFF, %(size ANSILOWERBUFF16)
  270. DUserThunk WIN32ANSINEXT, %(size ANSINEXT16)
  271. DUserThunk WIN32ANSIPREV, %(size ANSIPREV16)
  272. DUserThunk WIN32ANSIUPPER, %(size ANSIUPPER16)
  273. DUserThunk WIN32ANSIUPPERBUFF, %(size ANSIUPPERBUFF16)
  274. DUserThunk ANYPOPUP,0
  275. UserThunk APPENDMENU
  276. UserThunk ARRANGEICONICWINDOWS
  277. DUserThunk BEGINDEFERWINDOWPOS
  278. UserThunk BEGINPAINT
  279. UserThunk BRINGWINDOWTOTOP
  280. UserThunk BROADCASTMESSAGE
  281. UserThunk BUILDCOMMDCB
  282. ;;; UserThunk BUTTONWNDPROC ;LOCALAPI in wsubcls.c
  283. DUserThunk CALCCHILDSCROLL
  284. UserThunk CALLMSGFILTER
  285. UserThunk CALLWINDOWPROC
  286. UserThunk CARETBLINKPROC
  287. UserThunk CHANGECLIPBOARDCHAIN
  288. UserThunk CHANGEMENU
  289. UserThunk CHECKDLGBUTTON
  290. UserThunk CHECKMENUITEM
  291. UserThunk CHECKRADIOBUTTON
  292. UserThunk CHILDWINDOWFROMPOINT
  293. UserThunk CLEARCOMMBREAK
  294. UserThunk CLIPCURSOR
  295. DUserThunk CLOSECLIPBOARD,0
  296. FUN_WOWCLOSECOMM EQU FUN_CLOSECOMM
  297. DUserThunk WOWCLOSECOMM %(size CLOSECOMM16)
  298. UserThunk CLOSEWINDOW
  299. ;;; UserThunk COMBOBOXCTLWNDPROC ;LOCALAPI in wsubcls.c
  300. UserThunk COMPUPDATERECT
  301. UserThunk COMPUPDATERGN
  302. DUserThunk CONTROLPANELINFO
  303. UserThunk CONTSCROLL
  304. ;;; UserThunk COPYRECT ; LOCALAPI in winrect.asm
  305. DUserThunk COUNTCLIPBOARDFORMATS,0
  306. UserThunk CREATECARET
  307. UserThunk CREATECURSOR
  308. DUserThunk CREATECURSORICONINDIRECT
  309. ; UserThunk CREATEDIALOG ; defined in fastres.c
  310. ; UserThunk CREATEDIALOGINDIRECT
  311. ; UserThunk CREATEDIALOGINDIRECTPARAM
  312. ;FUN_WOWCREATEDIALOGPARAM EQU FUN_CREATEDIALOGPARAM
  313. ; DUserThunk WOWCREATEDIALOGPARAM, %(size CREATEDIALOGPARAM16)
  314. UserThunk CREATEICON
  315. DUserThunk CREATEMENU,0
  316. DUserThunk CREATEPOPUPMENU,0
  317. UserThunk CREATEWINDOW
  318. UserThunk CREATEWINDOWEX
  319. DUserThunk DCHOOK
  320. UserThunk DEFDLGPROC
  321. UserThunk DEFERWINDOWPOS
  322. UserThunk DEFFRAMEPROC
  323. UserThunk DEFMDICHILDPROC
  324. PUserThunk DEFWINDOWPROC,CheckDefWindowProc
  325. .386p
  326. LabelFP <PUBLIC, CascadeChildWindows>
  327. xor edx, edx
  328. pop eax ; save caller's return addr
  329. push edx ; lpRect == NULL
  330. push dx ; chwnd == 0
  331. push edx ; ahwnd == NULL
  332. push eax
  333. jmp CascadeWindows
  334. LabelFP <PUBLIC, TileChildWindows>
  335. xor edx, edx
  336. pop eax ; save caller's return addr
  337. push edx ; lpRect == NULL
  338. push dx ; chwnd == 0
  339. push edx ; ahwnd == NULL
  340. push eax
  341. jmp TileWindows
  342. .286p
  343. ; From Win 3.1 final inentry.asm - mattfe
  344. ;=========================================================================
  345. ; OldExitWindows()
  346. ;
  347. ; This function is at the same ordinal value as the old 2.x ExitWindows. This
  348. ; does nothing more than terminate the app. If it is the only app running the
  349. ; system will go away too.
  350. LabelFP <PUBLIC, OldExitWindows>
  351. mov ax,4c00h
  352. int 21h
  353. retf ; just in case the int21 returns...
  354. sEnd CODE
  355. end USER16