Subversion Repositories Kolibri OS

Rev

Rev 3014 | Rev 6823 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3014 dunkaist 1
;-----------------------------------------------------------------------------
2
proc dll.Load, import_table:dword
3
	mov	esi, [import_table]
4
  .next_lib:
5
	mov	edx, [esi]
6
	or	edx, edx
7
	jz	.exit
8
	push	esi
9
	mov	esi, [esi + 4]
10
	mov	edi, s_libdir.fname
11
    @@:
12
	lodsb
13
	stosb
14
	or	al, al
15
	jnz	@b
16
	mcall	68, 19, s_libdir
17
	or	eax, eax
18
	jz	.fail
19
	stdcall	dll.Link, eax, edx
3038 dunkaist 20
	push	eax
21
	mov	eax, [eax]
22
	cmp	dword[eax], 'lib_'
23
	pop	eax
24
	jnz	@f
3014 dunkaist 25
	stdcall	dll.Init, [eax + 4]
3038 dunkaist 26
    @@:
3014 dunkaist 27
	pop	esi
28
	add	esi, 8
29
	jmp	.next_lib
30
  .exit:
31
	xor	eax, eax
32
	ret
33
  .fail:
34
	add	esp, 4
35
	xor	eax, eax
36
	inc	eax
37
	ret
38
endp
39
;-----------------------------------------------------------------------------
40
proc dll.Link, exp:dword, imp:dword
41
	push	eax
42
	mov	esi, [imp]
43
	test	esi, esi
44
	jz	.done
45
  .next:
46
	lodsd
47
	test	eax, eax
48
	jz	.done
49
	stdcall	dll.GetProcAddress, [exp], eax
50
	or	eax, eax
51
	jz	@f
52
	mov	[esi - 4], eax
53
	jmp	.next
54
    @@:
55
	mov	dword[esp], 0
56
  .done:
57
	pop	eax
58
	ret
59
endp
60
;-----------------------------------------------------------------------------
61
proc dll.Init, dllentry:dword
62
	pushad
63
	mov	eax, mem.Alloc
64
	mov	ebx, mem.Free
65
	mov	ecx, mem.ReAlloc
66
	mov	edx, dll.Load
67
	stdcall	[dllentry]
68
	popad
69
	ret
70
endp
71
;-----------------------------------------------------------------------------
72
proc dll.GetProcAddress, exp:dword, sz_name:dword
73
	mov	edx, [exp]
74
	xor	eax, eax
75
  .next:
76
	or	edx, edx
77
	jz	.end
78
	cmp	dword[edx], 0
79
	jz	.end
80
	stdcall	strcmp, [edx], [sz_name]
81
	test	eax, eax
82
	jz	.ok
83
	add	edx, 8
84
	jmp	.next
85
  .ok:
86
	mov	eax, [edx + 4]
87
  .end:
88
	ret
89
endp
90
;-----------------------------------------------------------------------------
91
proc strcmp, str1:dword, str2:dword
92
	push	esi edi
93
	mov	esi, [str1]
94
	mov	edi, [str2]
95
	xor	eax, eax
96
    @@:
97
	lodsb
98
	scasb
99
	jne	.fail
100
	or	al, al
101
	jnz	@b
102
	jmp	.ok
103
  .fail:
104
	or	eax, -1
105
  .ok:
106
	pop	edi esi
107
	ret
108
endp
109
;-----------------------------------------------------------------------------
2619 mario79 110
s_libdir:
111
  db '/sys/lib/'
3014 dunkaist 112
  .fname rb 32
113
;-----------------------------------------------------------------------------
114
proc mem.Alloc, size
115
	push	ebx ecx
116
	mov	ecx, [size]
117
	mcall	68, 12
118
	pop	ecx ebx
119
	ret
120
endp
121
;-----------------------------------------------------------------------------
122
proc mem.ReAlloc, mptr, size
123
	push	ebx ecx edx
124
	mov	ecx, [size]
125
	or	ecx, ecx
126
	jz	@f
127
    @@:
128
	mov	edx, [mptr]
129
	or	edx, edx
130
	jz	@f
131
    @@:
132
	mcall	68, 20
133
	or	eax, eax
134
	jz	@f
135
    @@:
136
	pop	edx ecx ebx
137
	ret
138
endp
139
;-----------------------------------------------------------------------------
140
proc mem.Free, mptr
141
	push	ebx ecx
142
	mov	ecx,[mptr]
143
	or	ecx,ecx
144
	jz	@f
145
    @@:
146
	mcall	68, 13
147
	pop	ecx ebx
148
	ret
149
endp
150
;-----------------------------------------------------------------------------