blob: a052d60829525a8080b51b2e24953eff3e6802d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
PAGE ,132
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; LIBENTRY.ASM
;
; Windows dynamic link library entry routine
;
; This module generates a code segment called INIT_TEXT.
; It initializes the local heap if one exists and then calls
; the C routine LibMain() which should have the form:
; BOOL FAR PASCAL LibMain(HANDLE hInstance,
; WORD wDataSeg,
; WORD cbHeap,
; LPSTR lpszCmdLine);
;
; The result of the call to LibMain is returned to Windows.
; The C routine should return TRUE if it completes initialization
; successfully, FALSE if some error occurs.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
extrn LibMain:far ; the C routine to be called
extrn LocalInit:far ; Windows heap init routine
extrn __acrtused:abs ; ensures that Win DLL startup code is linked
public LibEntry ; entry point for the DLL
INIT_TEXT segment byte public 'CODE'
assume cs:INIT_TEXT
LibEntry proc far
push di ; handle of the module instance
push ds ; library data segment
push cx ; heap size
push es ; command line segment
push si ; command line offset
; if we have some heap then initialize it
jcxz callc ; jump if no heap specified
; call the Windows function LocalInit() to set up the heap
; LocalInit((LPSTR)start, WORD cbHeap);
push ds ; Heap segment
xor ax,ax
push ax ; Heap start offset in segment
push cx ; Heap end offset in segment
call LocalInit ; try to initialize it
or ax,ax ; did it do it ok ?
jz nocall ; quit if it failed
; invoke the C routine to do any special initialization
callc:
call LibMain ; invoke the 'C' routine (result in AX)
jmp short exit ; LibMain is responsible for stack clean up
nocall: ; clean up passed params
pop si ; if LocalInit fails.
pop es
pop cx
pop ds
pop di
exit:
ret ; return the result
LibEntry endp
INIT_TEXT ends
end LibEntry
|