Subversion Repositories Kolibri OS

Rev

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