library simple;
uses
SysUtils,
Classes;
{$R *.res}
procedure SimpleTest;
begin
asm
mov eax, 100
end;
end;
exports SimpleTest;
begin
end.
Конвертирование DLL(Delphi) -> LIB(Assembler)
Вообщем я делаю так:
библиотека simple.dll Delphi
Код:
Конвертирую в lib программой lib.exe вот так lib.exe /def:simple.def /out:simple.lib.
Файл simple.def содержит
Код:
LIBRARY "simple.dll"
DESCRIPTION 'simple.dll'
EXPORTS
SimpleTest@0
DESCRIPTION 'simple.dll'
EXPORTS
SimpleTest@0
Пишу простую прогу на ассемблере test.asm:
Код:
.386
.model flat,stdcall
option casemap:none
include kernel32.inc
includelib lib/kernel32.lib
includelib simple.lib
SimpleTest PROTO
.const
.code
Main PROC
call SimpleTest
invoke ExitProcess, 0
Main ENDP
end Main
.model flat,stdcall
option casemap:none
include kernel32.inc
includelib lib/kernel32.lib
includelib simple.lib
SimpleTest PROTO
.const
.code
Main PROC
call SimpleTest
invoke ExitProcess, 0
Main ENDP
end Main
Компилирую (использую MASM):
"ml.exe" /c /coff test.asm
"link.exe" /SUBSYSTEM:CONSOLE test.obj
Запускаю Test.exe. Пишет "точка входа в процедуру SimpleTest@0 не найдена в библиотеке DLL simple.dll"
В чем ошибка ???
Код:
uses
SysUtils,
Classes;
{$R *.res}
procedure SimpleTest;stdcall;
begin
asm
mov eax, 100
end;
end;
exports SimpleTest;
begin
end.
SysUtils,
Classes;
{$R *.res}
procedure SimpleTest;stdcall;
begin
asm
mov eax, 100
end;
end;
exports SimpleTest;
begin
end.
Код:
LIBRARY "simple.dll"
DESCRIPTION 'simple.dll'
EXPORTS
SimpleTest
DESCRIPTION 'simple.dll'
EXPORTS
SimpleTest
test.obj : error LNK2001: unresolved external symbol _SimpleTest@0
test.exe : fatal error LNK1120: 1 unresolved externals
test.asm
Код:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
includelib .\simple.lib
SimpleTest PROTO c ;)
.const
.code
Main PROC
invoke SimpleTest
invoke ExitProcess, 0
Main ENDP
end Main
.model flat,stdcall
option casemap:none
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
includelib .\simple.lib
SimpleTest PROTO c ;)
.const
.code
Main PROC
invoke SimpleTest
invoke ExitProcess, 0
Main ENDP
end Main
Код:
library simple;
uses
windows,sysutils;
procedure SimpleTest;cdecl;
begin
asm
mov eax,100
end;
end;
exports
SimpleTest;
begin
end.
uses
windows,sysutils;
procedure SimpleTest;cdecl;
begin
asm
mov eax,100
end;
end;
exports
SimpleTest;
begin
end.
Код:
LIBRARY simple.dll
DESCRIPTION simple.dll
EXPORTS SimpleTest
DESCRIPTION simple.dll
EXPORTS SimpleTest
Код:
@echo off
echo Clean dir
del *.obj
del *.exp
del *.lib
echo build..
echo test.asm
ml.exe /nologo /c /coff test.asm
lib.exe /nologo /def:simple.def /out:simple.lib /machine:ix86
link /nologo /SUBSYSTEM:CONSOLE test.obj
echo run test.exe
.\test.exe
echo done
echo Clean dir
del *.obj
del *.exp
del *.lib
echo build..
echo test.asm
ml.exe /nologo /c /coff test.asm
lib.exe /nologo /def:simple.def /out:simple.lib /machine:ix86
link /nologo /SUBSYSTEM:CONSOLE test.obj
echo run test.exe
.\test.exe
echo done
Все работает. Проверено
спасибо...