Äèíàìè÷åñêàÿ áèáëèîòåêà
Íàïèñàíèå äèíàìè÷åñêèõ áèáëèîòåê ïîä Win32 òàêæå çíà÷èòåëüíî óïðîñòèëîñü, ïî ñðàâíåíèþ ñ òåì, êàê ýòî äåëàëîñü ïîä Windows 3.x. Èñ÷åçëà íåîáõîäèìîñòü âñòàâëÿòü startup êîä, à èñïîëüçîâàíèå ÷åòûð¸õ ñîáûòèé èíèöèàëèçàöèè/äåèíèöèàëèçàöèè íà óðîâíå ïðîöåññîâ è ïîòîêîâ, êàæåòñÿ ëîãè÷íûì.
Ðàññìîòðèì ïðîñòîé ïðèìåð äèíàìè÷åñêîé áèáëèîòåêè, â êîòîðîé âñåãî îäíà ôóíêöèÿ, ïðåîáðàçîâàíèÿ öåëîãî ÷èñëà â ñòðîêó â øåñòíàäöàòåðè÷íîé ñèñòåìå ñ÷èñëåíèÿ.
Ôàéë mylib.asm
Ideal
P586
Radix 16
Model flat
DLL_PROCESS_ATTACH = 1
extrn GetVersion: proc
DataSeg
hInst dd 0
OSVer dw 0
CodeSeg
proc libEntry stdcall
arg @@hInst :dword, @@rsn :dword, @@rsrv :dword
cmp [@@rsn],DLL_PROCESS_ATTACH
jne @@1
call GetVersion
mov [OSVer],ax
mov eax,[@@hInst]
mov [hInst],eax
@@1: mov eax,1
ret
endP libEntry
public stdcall Hex2Str
proc Hex2Str stdcall
arg @@num :dword, @@str :dword
uses ebx
mov eax,[@@num]
mov ebx,[@@str]
mov ecx,7
@@1: mov edx,eax
shr eax,4
and edx,0F
cmp edx,0A
jae @@2
add edx,'0'
jmp @@3
@@2: add edx,'A' - 0A
@@3: mov [byte ebx + ecx],dl
dec ecx
jns @@1
mov [byte ebx + 8],0
ret
endp Hex2Str
end libEntry
Îñòàëüíûå ôàéëû, êîòîðûå íåîáõîäèìû äëÿ äàííîãî ïðèìåðà, ìîæíî íàéòè â ïðèëîæåíèè 2.