Rev 5940 | Rev 8227 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5940 | Rev 6823 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;----------------------------------------------------------------------------- |
1 | ;----------------------------------------------------------------------------- |
- | 2 | ; load one or more DLL file in COFF format and try to import functions by our list |
|
- | 3 | ; if first function in import list begins with 'lib_', call it as DLL initialization |
|
- | 4 | ; return eax = 1 as fail, if anyone of .obj file not found in /sys/lib |
|
- | 5 | ; return 0 if all fine, but 0 not garantees in succesfull import - see dll.Link comment |
|
- | 6 | ; dirties all registers! eax, ebx, ecx, edx, esi, edi |
|
2 | proc dll.Load, import_table:dword |
7 | proc dll.Load, import_table:dword |
3 | mov esi, [import_table] |
8 | mov esi, [import_table] |
4 | .next_lib: |
9 | .next_lib: |
5 | mov edx, [esi] |
10 | mov edx, [esi] |
6 | or edx, edx |
11 | or edx, edx |
Line 35... | Line 40... | ||
35 | xor eax, eax |
40 | xor eax, eax |
36 | inc eax |
41 | inc eax |
37 | ret |
42 | ret |
38 | endp |
43 | endp |
39 | ;----------------------------------------------------------------------------- |
44 | ;----------------------------------------------------------------------------- |
- | 45 | ; scans dll export table for a functions we want to import |
|
- | 46 | ; break scan on first unresolved import |
|
- | 47 | ; no return value |
|
40 | proc dll.Link, exp:dword, imp:dword |
48 | proc dll.Link, exp:dword, imp:dword |
41 | push eax |
49 | push eax |
42 | mov esi, [imp] |
50 | mov esi, [imp] |
43 | test esi, esi |
51 | test esi, esi |
44 | jz .done |
52 | jz .done |
Line 56... | Line 64... | ||
56 | .done: |
64 | .done: |
57 | pop eax |
65 | pop eax |
58 | ret |
66 | ret |
59 | endp |
67 | endp |
60 | ;----------------------------------------------------------------------------- |
68 | ;----------------------------------------------------------------------------- |
- | 69 | ; calls lib_init with predefined parameters |
|
- | 70 | ; no return value |
|
61 | proc dll.Init, dllentry:dword |
71 | proc dll.Init, dllentry:dword |
62 | pushad |
72 | pushad |
63 | mov eax, mem.Alloc |
73 | mov eax, mem.Alloc |
64 | mov ebx, mem.Free |
74 | mov ebx, mem.Free |
65 | mov ecx, mem.ReAlloc |
75 | mov ecx, mem.ReAlloc |
Line 67... | Line 77... | ||
67 | stdcall [dllentry] |
77 | stdcall [dllentry] |
68 | popad |
78 | popad |
69 | ret |
79 | ret |
70 | endp |
80 | endp |
71 | ;----------------------------------------------------------------------------- |
81 | ;----------------------------------------------------------------------------- |
- | 82 | ; scans export table for a sz_name function |
|
- | 83 | ; returns in eax function address or 0 if not found |
|
72 | proc dll.GetProcAddress, exp:dword, sz_name:dword |
84 | proc dll.GetProcAddress, exp:dword, sz_name:dword |
73 | mov edx, [exp] |
85 | mov edx, [exp] |
74 | xor eax, eax |
86 | xor eax, eax |
75 | .next: |
87 | .next: |
76 | or edx, edx |
88 | or edx, edx |
Line 83... | Line 95... | ||
83 | add edx, 8 |
95 | add edx, 8 |
84 | jmp .next |
96 | jmp .next |
85 | .ok: |
97 | .ok: |
86 | mov eax, [edx + 4] |
98 | mov eax, [edx + 4] |
87 | .end: |
99 | .end: |
- | 100 | cmp eax, -1 |
|
- | 101 | jnz @f |
|
- | 102 | xor eax, eax |
|
- | 103 | @@: |
|
88 | ret |
104 | ret |
89 | endp |
105 | endp |
90 | ;----------------------------------------------------------------------------- |
106 | ;----------------------------------------------------------------------------- |
- | 107 | ; compares strings |
|
- | 108 | ; returns eax = 0 if equal, -1 otherwise |
|
91 | proc strcmp, str1:dword, str2:dword |
109 | proc strcmp, str1:dword, str2:dword |
92 | push esi edi |
110 | push esi edi |
93 | mov esi, [str1] |
111 | mov esi, [str1] |
94 | mov edi, [str2] |
112 | mov edi, [str2] |
95 | xor eax, eax |
113 | xor eax, eax |