source: trunk/src/win32k/dev32/devfirst.asm

Last change on this file was 6280, checked in by bird, 24 years ago

Kill API coding.

File size: 10.5 KB
RevLine 
[6280]1; $Id: devfirst.asm,v 1.9 2001-07-10 05:19:34 bird Exp $
[847]2;
3; DevFirst - entrypoint and segment definitions
4;
5; Copyright (c) 1999 knut st. osmundsen
6;
[1467]7; Project Odin Software License can be found in LICENSE.TXT
[847]8;
9 .386p
10
11;
12; Include files
13;
14 include devsegdf.inc
[1467]15 include sas.inc
[847]16
17;
18; Exported symbols
19;
20 public CODE16START
[4164]21 public CODE16_INITSTART
[847]22 public DATA16START
23 public DATA16START
24 public DATA16_BSSSTART
25 public DATA16_CONSTSTART
[4164]26 public DATA16_INITSTART
[847]27 public CODE16START
28 public CODE32START
29 public DATA32START
30 public BSS32START
31 public CONST32_ROSTART
[2898]32 public _VFTSTART
33 public EH_DATASTART
[847]34
[2898]35
[847]36 public _strategyAsm0
37 public _strategyAsm1
[2898]38 public _CallGetKernelInfo32
[2799]39 public _CallElfIOCtl
40 public _CallWin32kIOCtl
[6218]41 public _CallWin32kOpen
42 public _CallWin32kClose
[847]43 public _SSToDS_16a
[1467]44 public GetOS2KrnlMTE
[5220]45 public x86DisableWriteProtect
46 public x86RestoreWriteProtect
[847]47
48
49;
50; Externs
51;
[1467]52 extrn _TKSSBase16:dword
[2898]53 extrn GETKERNELINFO32:FAR
[2799]54 extrn ELFIOCTL:FAR
55 extrn WIN32KIOCTL:FAR
[6218]56 extrn WIN32KOPEN:FAR
57 extrn WIN32KCLOSE:FAR
[1467]58 .286p
[6280]59 extrn h_POST_SIGNAL:FAR
[847]60 extrn _strategy:near
61
62
63CODE16 segment
64 ASSUME CS:CODE16, DS:DATA16, ES:NOTHING, SS:NOTHING
65
66CODE16START label byte
67
[1467]68 .286p
[847]69;$win32ki entry point
70_strategyAsm0:
[4164]71; int 3
[847]72 push 0
73 jmp _strategyAsm
74
75;$win32k entry point
76_strategyAsm1:
[4164]77; int 3
[847]78 push 1
79 jmp _strategyAsm
80
[1467]81;;
82; Stub which pushes parameters onto the stack and call the 16-bit C strategy routine.
83; @returns returns the return value of strategy(...)
84; @author knut st. osmundsen
[847]85_strategyAsm proc far
86 push es
87 push bx
88 push ds
89 pop es
90 call _strategy
91 pop bx
92 pop es
93 mov word ptr es:[bx+3], ax
94 add sp, 2
95 retf
96_strategyAsm endp
97
98
[1467]99 .386p
100;;
101; Thunk procedure for R0Init32.
[2898]102; @cproto USHORT NEAR CallGetKernelInfo32(ULONG addressKrnlInfoBuf);
103; @returns Same as GetKernelInfo32.
104; @param addressKrnlInfoBuf 32-bit pointer to request data on stack.
[1467]105; @status completely implemented.
106; @author knut st. osmundsen
[2898]107_CallGetKernelInfo32 PROC NEAR
[1467]108 ASSUME CS:CODE16
109 push ds
110 push word ptr [esp+6] ; push high word.
111 push word ptr [esp+6] ; push low word.
[2898]112 call far ptr FLAT:GETKERNELINFO32
[1467]113 pop ds
[4164]114 ret
[2898]115_CallGetKernelInfo32 ENDP
[1467]116
117
[2799]118
119
[1467]120;;
[2799]121; Thunk procedure for .
122; @cproto USHORT NEAR CallElfIOCtl(void);
123; @returns Same as ElfIOCtl
124; @param address of IOCtl request packet (32-bit pointer).
125; @status completely implemented.
126; @author knut st. osmundsen
127_CallElfIOCtl PROC NEAR
128 ASSUME CS:CODE16
129 push ds
130 push word ptr [esp+6] ; push high word.
131 push word ptr [esp+6] ; push low word.
132 call far ptr FLAT:ELFIOCTL
133 pop ds
134 retn
135_CallElfIOCtl ENDP
136
137;;
138; Thunk procedure for .
139; @cproto USHORT NEAR CallWin32kIOCtl(void);
140; @returns Same as Win32kIOCtl
141; @param address of IOCtl request packet (32-bit pointer).
142; @status completely implemented.
143; @author knut st. osmundsen
144_CallWin32kIOCtl PROC NEAR
145 ASSUME CS:CODE16
146 push ds
147 push word ptr [esp+6] ; push high word.
148 push word ptr [esp+6] ; push low word.
149 call far ptr FLAT:WIN32KIOCTL
150 pop ds
151 retn
152_CallWin32kIOCtl ENDP
153
154
[6218]155;;
156; Thunk procedure for .
157; @cproto USHORT NEAR CallWin32kOpen(LIN);
158; @returns Same as Win32kOpen
159; @param address of Open request packet (32-bit pointer).
160; @status completely implemented.
161; @author knut st. osmundsen
162_CallWin32kOpen PROC NEAR
163 ASSUME CS:CODE16
164 push ds
165 push word ptr [esp+6] ; push high word.
166 push word ptr [esp+6] ; push low word.
167 call far ptr FLAT:WIN32KOPEN
168 pop ds
169 retn
170_CallWin32kOpen ENDP
[2799]171
[6218]172
[2799]173;;
[6218]174; Thunk procedure for strategy close.
175; @cproto USHORT NEAR CallWin32kClose(LIN);
176; @returns Same as Win32kIOCtl
177; @param address of Open request packet (32-bit pointer).
178; @status completely implemented.
179; @author knut st. osmundsen
180_CallWin32kClose PROC NEAR
181 ASSUME CS:CODE16
182 push ds
183 push word ptr [esp+6] ; push high word.
184 push word ptr [esp+6] ; push low word.
185 call far ptr FLAT:WIN32KCLOSE
186 pop ds
187 retn
188_CallWin32kClose ENDP
189
190
191
192;;
[1467]193; SSToDS - stack pointer to Flat pointer.
194; @cproto extern LIN SSToDS_16a(void NEAR *pStackVar);
195; @returns ax:dx makes up a 32-bit flat pointer to stack.
196; @param pStackVar Stack pointer which is to be made a flat pointer.
197; @equiv SSToDS in 32-bit code.
198; @sketch Get Flat CS
199; Get TKSSBase address. (FLAT)
200; return *TKSSBase + pStackVar.
201; @status completely implemented.
202; @author knut st. osmundsen
203; @remark es is cs, not ds!
[4164]204_SSToDS_16a proc NEAR
[847]205 assume CS:CODE16, DS:DATA16, ES:NOTHING
[1467]206 mov edx, ds:_TKSSBase16 ; get pointer held by _TKSSBase16 (pointer to stack base)
207 call far ptr FLAT:far_getCS ; get flat selector.
[847]208 push es
[1467]209 mov es, ax
210 assume es:FLAT
211 mov eax, es:[edx] ; get pointer to stack base
212 pop es
213 movzx edx, word ptr ss:[esp + 2] ; 16-bit stack pointer (parameter)
214 add eax, edx ; 32-bit stack pointer in eax
[847]215 mov edx, eax
[1467]216 shr edx, 16 ; dx high 16-bit of 32-bit stack pointer.
[4164]217 retn
[847]218_SSToDS_16a endp
219
220CODE16 ends
221
[1467]222
223;
224; all segments have a <segmentname>START label at the start of the segment.
225;
226
[847]227CODE32 segment
228CODE32START label byte
[1467]229
230;;
231; Gets the current cs.
232; @cproto none.
233; @returns CS
234; @author knut st. osmundsen
235; @remark internal method. called from 16-bit code...
236far_getCS proc far
237 ASSUME DS:nothing, ES:nothing
238 mov ax, cs
239 retf
240far_getCS endp
241
242
243
244;;
245; Gets the a 32-bit flat pointer to the OS/2 Kernel MTE.
246; @cproto extern PMTE _System GetOS2KrnlMTE(void);
247; @returns Pointer to kernel MTE.
248; @status completely implemented.
249; @author knut st. osmundsen
250GetOS2KrnlMTE PROC NEAR
251 push es
252
253 mov ax, SAS_selector ;70h - Read-only SAS selector.
254 mov es, ax
255 xor ebx, ebx
256 assume ebx: PTR SAS
257 mov bx, es:[ebx].SAS_vm_data ;SAS_vm_data (0ch)
258 assume ebx: PTR SAS_vm_section
259 mov eax, es:[ebx].SAS_vm_krnl_mte ;SAS_vm_krnl_mte (0ch)
260
[847]261 pop es
[1467]262 ret
263GetOS2KrnlMTE ENDP
[847]264
[5220]265
266;;
267; Disables the ring-0 write protection.
268; It's used to help us write to readonly code segments and objects.
269; @cproto extern ULONG _Optlink x86DisableWriteProtect(void);
270; @return Previous write protection flag setting.
271; @uses eax, edx
272; @status completely implemented.
273; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
274; @remark Used by importTabInit.
275x86DisableWriteProtect proc near
276 cli
277 mov edx, cr0 ; Get current cr0
278 test edx, 000010000h ; Test for the WriteProtect flag (bit 16)
279 setnz al
280 movzx eax, al ; Old flag setting in eax (return value)
281 and edx, 0fffeffffh ; Clear the 16th (WP) bit.
282 mov cr0, edx ;
283 sti
284 ret ; return eax holds previous WP value.
285x86DisableWriteProtect endp
286
287
288;;
289; Restore the WP flag of CR0 to it's previous state.
290; The call is intent only to be called with the result from x86DisableWriteProtect,
291; and will hence only enable the WP flag.
292; @cproto extern ULONG _Optlink x86RestoreWriteProtect(ULONG flWP);
293; @return Previous write protection flag setting.
294; @param eax - flWP Boolean value. (1 = WP was set, 0 WP was clear)
295; @uses eax
296; @status completely implemented.
297; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
298; @remark Used by importTabInit.
299x86RestoreWriteProtect proc near
300 test eax, eax ; Check if the flag was previously clear
301 jnz x86RWP_set ; If set Then Set it back.
302 jmp x86RWP_end ; If clear Then nothing to do.
303x86RWP_set:
304 cli
305 mov eax, cr0 ; Get current cr0.
306 or eax, 000010000h ; The the 16-bit (WP) bit.
307 mov cr0, eax ; Update cr0.
308 sti
309
310x86RWP_end:
311 ret
312x86RestoreWriteProtect endp
313
314
[6280]315;;
316; Post signal to one or more processes.
317; @cproto extern ULONG POST_SIGNAL32(USHORT usSignal, USHORT usAction, USHORT usSignalArg, USHORT usPIDSGR);
318; @returns NO_ERROR on success.
319; On error ERROR_NOT_DESCENDANT, ERROR_SIGNAL_REFUSED,
320; ERROR_INVALID_PROCID, ERROR_ZOMBIE_PROCESS, ERROR_SIGNAL_PENDING. (it seems)
321; @param ax Signal number.
322; @param dx Action.
323; 0 - the process and all children.
324; 1 - only the process
325; 2 - the process and all it's decendants.
326; 3 - all processes in that screen group.
327; @param cx Signal argument.
328; @param [ebp+14h] Process Id or Screen Group Id.
329; @uses eax, edx, ecx
330; @status completely implemented.
331; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
332; @remark Used by importTabInit.
333POST_SIGNAL32 proc near
334 push ebp
335 mov ebp, esp
336 push ebx
337
338 movzx eax, ax ; signal
339 movzx ebx, dx ; action
340 movzx ecx, cx ; argument
341 movzx edx, word ptr [ebp+14h] ; pid
342
343 jmp far ptr CODE16:Thunk16_POST_SIGNAL32
344Thunk32_POST_SIGNAL32::
345 jc cps_error ; jump on error
346 xor eax, eax ; just to make sure it's all empty.
347 jmp cps_end
348
349cps_error:
350 movzx eax, ax ; make sure upper part is empty as well.
351
352cps_end:
353 pop ebx
354 leave
355 ret
356POST_SIGNAL32 endp
[847]357CODE32 ends
358
[6280]359CODE16 segment
360Thunk16_POST_SIGNAL32::
361 call far ptr h_POST_SIGNAL
362 jmp far ptr FLAT:Thunk32_POST_SIGNAL32
363CODE16 ends
364
365
366
367
[4164]368CODE16_INIT segment
369CODE16_INITSTART label byte
370CODE16_INIT ends
[847]371
372DATA16 segment
373DATA16START label byte
374DATA16 ends
375
376DATA16_BSS segment
377DATA16_BSSSTART label byte
378DATA16_BSS ends
379
380DATA16_CONST segment
381DATA16_CONSTSTART label byte
382DATA16_CONST ends
383
[4164]384DATA16_INIT segment
385DATA16_INITSTART label byte
386DATA16_INIT ends
387
[847]388DATA32 segment
389DATA32START label byte
390DATA32 ends
391
392BSS32 segment
393BSS32START label byte
394BSS32 ends
395
396CONST32_RO segment
397CONST32_ROSTART label byte
398CONST32_RO ends
[2836]399
400_VFT segment
401_VFTSTART LABEL BYTE
402_VFT ends
403
404EH_DATA segment
405EH_DATASTART LABEL BYTE
406EH_DATA ends
407
[847]408END
409
Note: See TracBrowser for help on using the repository browser.