Subversion Repositories Kolibri OS

Rev

Rev 1145 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
836 diamond 1
 
2
3
 
4
DLL_EXIT  equ -1
5
REQ_DLL_VER equ 3
6
7
 
8
        db      'MENUET01'
9
        dd      1
10
        dd      start
11
        dd      i_end
12
        dd      mem
13
        dd      mem
14
        dd      0
15
        dd      0
16
17
 
18
        stdcall load_dll_and_import, dllname, imports
19
        test    eax, eax
20
        jz      exit
21
22
 
23
        cmp     word [dll_ver], REQ_DLL_VER
24
        jb      exit
25
        cmp     word [dll_ver+2], REQ_DLL_VER
26
        ja      exit
27
        push    DLL_ENTRY
28
        call    [dll_start]
29
30
 
31
32
 
33
        push    -1
34
        push    -1
35
        push    -1
36
        push    -1
37
        call    [con_init]
38
39
 
40
; for (;;)
41
; {
42
;   con_write_asciiz("Enter string (empty for exit): ");
43
;   con_gets(s,256);
44
;   if (s[0] == '\n') break;
45
;   con_write_asciiz("You entered: ");
46
;   con_write_asciiz(s);
47
; }
48
mainloop:
49
        push    str1
50
        call    [con_write_asciiz]
51
        push    256
52
        push    s
53
        call    [con_gets]
54
        cmp     [s], 10
55
        jz      done
56
        push    str2
57
        call    [con_write_asciiz]
58
        push    s
59
        call    [con_write_asciiz]
60
        jmp     mainloop
61
done:
62
        push    1
63
        call    [con_exit]
64
exit:
65
        or      eax, -1
66
        int     0x40
67
68
 
69
        pushad
70
; load DLL
71
        push    68
72
        pop     eax
73
        push    19
74
        pop     ebx
75
        mov     ecx, [_dllname]
76
        int     0x40
77
        test    eax, eax
78
        jz      import_fail
79
80
 
81
        mov     edi, eax
82
        mov     esi, [_imports]
83
import_loop:
84
        lodsd
85
        test    eax, eax
86
        jz      import_done
87
        mov     edx, edi
88
import_find:
89
        mov     ebx, [edx]
90
        test    ebx, ebx
91
        jz      import_not_found
92
        push    eax
93
@@:
94
        mov     cl, [eax]
95
        cmp     cl, [ebx]
96
        jnz     import_find_next
97
        test    cl, cl
98
        jz      import_found
99
        inc     eax
100
        inc     ebx
101
        jmp     @b
102
import_find_next:
103
        pop     eax
104
        add     edx, 8
105
        jmp     import_find
106
import_found:
107
        pop     eax
108
        mov     eax, [edx+4]
109
        mov     [esi-4], eax
110
        jmp     import_loop
111
import_not_found:
112
import_fail:
113
        popad
114
        xor     eax, eax
115
        ret
116
import_done:
117
        popad
118
        xor     eax, eax
119
        inc     eax
120
        ret
121
endp
122
123
 
124
125
 
126
dll_start          dd szStart
127
dll_ver            dd szVersion
128
con_init           dd szcon_init
129
con_write_asciiz   dd szcon_write_asciiz
130
con_exit           dd szcon_exit
131
con_gets           dd szcon_gets
132
                   dd 0
133
134
 
135
szVersion          db 'version',0
136
szcon_init         db 'con_init',0
137
szcon_write_asciiz db 'con_write_asciiz',0
138
szcon_exit         db 'con_exit',0
139
szcon_gets         db 'con_gets',0
140
141
 
142
143
 
144
str1               db 'Enter string (empty for exit): ',0
145
str2               db 'You entered: ',0
146
147
 
148
149
 
150
151
 
152
rb 2048 ; stack
153
mem:
154