1 ;-----------------------------------------------------------------------------
\r
2 ; load one or more DLL file in COFF format and try to import functions by our list
\r
3 ; if first function in import list begins with 'lib_', call it as DLL initialization
\r
4 ; return eax = 1 as fail, if anyone of .obj file not found in /sys/lib
\r
5 ; return 0 if all fine, but 0 not garantees in succesfull import - see dll.Link comment
\r
6 ; dirties all registers! eax, ebx, ecx, edx, esi, edi
\r
7 proc dll.Load, import_table:dword
\r
8 mov esi, [import_table]
\r
20 mov edi, s_libdir.fname
\r
29 mcall 68, 19, edi ;s_libdir
\r
32 stdcall dll.Link, eax, edx
\r
35 cmp dword[eax], 'lib_'
\r
38 stdcall dll.Init, [eax + 4]
\r
52 ;-----------------------------------------------------------------------------
\r
53 ; scans dll export table for a functions we want to import
\r
54 ; break scan on first unresolved import
\r
56 proc dll.Link, exp:dword, imp:dword
\r
65 stdcall dll.GetProcAddress, [exp], eax
\r
76 ;-----------------------------------------------------------------------------
\r
77 ; calls lib_init with predefined parameters
\r
79 proc dll.Init, dllentry:dword
\r
83 mov ecx, mem.ReAlloc
\r
89 ;-----------------------------------------------------------------------------
\r
90 ; scans export table for a sz_name function
\r
91 ; returns in eax function address or 0 if not found
\r
92 proc dll.GetProcAddress, exp:dword, sz_name:dword
\r
100 stdcall strcmp, [edx], [sz_name]
\r
114 ;-----------------------------------------------------------------------------
\r
116 ; returns eax = 0 if equal, -1 otherwise
\r
117 proc strcmp, str1:dword, str2:dword
\r
135 ;-----------------------------------------------------------------------------
\r
136 if defined dll.Load
\r
141 ;-----------------------------------------------------------------------------
\r
142 proc mem.Alloc, size
\r
149 ;-----------------------------------------------------------------------------
\r
150 proc mem.ReAlloc, mptr, size
\r
158 ;-----------------------------------------------------------------------------
\r
159 proc mem.Free, mptr
\r
166 ;-----------------------------------------------------------------------------
\r