mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 13:49:30 +02:00
+ added the changes from Pavel Ozerski after several modifications
to be able to create DLLs
This commit is contained in:
parent
2fcbb9a87d
commit
8a0fb3c67e
@ -72,6 +72,7 @@ include $(CFG)/makefile.cfg
|
|||||||
|
|
||||||
# Define Win32 Units
|
# Define Win32 Units
|
||||||
SYSTEMPPU=syswin32$(PPUEXT)
|
SYSTEMPPU=syswin32$(PPUEXT)
|
||||||
|
LOADERS=wprt0 wdllprt0
|
||||||
OBJECTS=strings dos \
|
OBJECTS=strings dos \
|
||||||
windows objects \
|
windows objects \
|
||||||
cpu mmx getopts heaptrc objpas sysutils
|
cpu mmx getopts heaptrc objpas sysutils
|
||||||
@ -137,6 +138,12 @@ clean :
|
|||||||
# Base Units (System, strings, os-dependent-base-unit)
|
# Base Units (System, strings, os-dependent-base-unit)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
wprt0$(OEXT) : wprt0.as
|
||||||
|
$(AS) -o wprt0$(OEXT) wprt0.as
|
||||||
|
|
||||||
|
wdllprt0$(OEXT) : wdllprt0.as
|
||||||
|
$(AS) -o wdllprt0$(OEXT) wdllprt0.as
|
||||||
|
|
||||||
$(SYSTEMPPU) : syswin32.pp win32.inc $(SYSDEPS)
|
$(SYSTEMPPU) : syswin32.pp win32.inc $(SYSDEPS)
|
||||||
$(COMPILER) -Us -Sg syswin32.pp $(REDIR)
|
$(COMPILER) -Us -Sg syswin32.pp $(REDIR)
|
||||||
|
|
||||||
@ -386,7 +393,11 @@ include $(CFG)/makefile.def
|
|||||||
|
|
||||||
#
|
#
|
||||||
# $Log$
|
# $Log$
|
||||||
# Revision 1.12 1998-11-24 19:52:10 jonas
|
# Revision 1.13 1998-11-30 09:16:57 pierre
|
||||||
|
# + added the changes from Pavel Ozerski after several modifications
|
||||||
|
# to be able to create DLLs
|
||||||
|
#
|
||||||
|
# Revision 1.12 1998/11/24 19:52:10 jonas
|
||||||
# + added warning about TABs
|
# + added warning about TABs
|
||||||
#
|
#
|
||||||
# Revision 1.11 1998/11/18 09:28:07 pierre
|
# Revision 1.11 1998/11/18 09:28:07 pierre
|
||||||
|
@ -65,9 +65,13 @@ var
|
|||||||
{ Win32 Info }
|
{ Win32 Info }
|
||||||
startupinfo : tstartupinfo;
|
startupinfo : tstartupinfo;
|
||||||
hprevinst,
|
hprevinst,
|
||||||
|
HInstance,
|
||||||
MainInstance,
|
MainInstance,
|
||||||
cmdshow : longint;
|
cmdshow : longint;
|
||||||
IsLibrary,IsMultiThreaded,IsConsole : boolean;
|
IsLibrary,IsMultiThreaded,IsConsole : boolean;
|
||||||
|
{* Changes made by Ozerski 26.10.1998}
|
||||||
|
DLLreason,DLLparam:longint;
|
||||||
|
{* End Changes}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -623,12 +627,14 @@ procedure getdir(drivenr:byte;var dir:shortstring);
|
|||||||
|
|
||||||
var
|
var
|
||||||
ModuleName : array[0..255] of char;
|
ModuleName : array[0..255] of char;
|
||||||
|
|
||||||
function GetCommandFile:pchar;
|
function GetCommandFile:pchar;
|
||||||
begin
|
begin
|
||||||
GetModuleFileName(0,@ModuleName,255);
|
GetModuleFileName(0,@ModuleName,255);
|
||||||
GetCommandFile:=@ModuleName;
|
GetCommandFile:=@ModuleName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{* End changes}
|
||||||
|
|
||||||
procedure setup_arguments;
|
procedure setup_arguments;
|
||||||
var
|
var
|
||||||
@ -684,6 +690,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$ifndef FPC_WIN32_DLL_SUPPORT}
|
||||||
{$ASMMODE DIRECT}
|
{$ASMMODE DIRECT}
|
||||||
var
|
var
|
||||||
fpucw : word;
|
fpucw : word;
|
||||||
@ -705,6 +712,8 @@ begin
|
|||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$else FPC_WIN32_DLL_SUPPORT}
|
||||||
|
|
||||||
{$ifdef dummy}
|
{$ifdef dummy}
|
||||||
Function SetUpStack : longint;
|
Function SetUpStack : longint;
|
||||||
{ This routine does the following : }
|
{ This routine does the following : }
|
||||||
@ -724,14 +733,40 @@ end;
|
|||||||
{$endif}
|
{$endif}
|
||||||
{$ASMMODE ATT}
|
{$ASMMODE ATT}
|
||||||
|
|
||||||
|
procedure Exe_entry;[public, alias : 'FPC_EXE_Entry'];
|
||||||
|
begin
|
||||||
|
IsLibrary:=false;
|
||||||
|
asm
|
||||||
|
call PASCALMAIN
|
||||||
|
end;
|
||||||
|
{ if we pass here there was no error ! }
|
||||||
|
ExitProcess(0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Dll_entry;[public, alias : 'FPC_DLL_Entry'];
|
||||||
|
begin
|
||||||
|
IsLibrary:=true;
|
||||||
|
case DLLreason of
|
||||||
|
1,2 : asm
|
||||||
|
call PASCALMAIN
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
asm
|
||||||
|
call FPC_DO_EXIT
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$endif def FPC_WIN32_DLL_SUPPORT}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ get some helpful informations }
|
{ get some helpful informations }
|
||||||
GetStartupInfo(@startupinfo);
|
GetStartupInfo(@startupinfo);
|
||||||
{ some misc Win32 stuff }
|
{ some misc Win32 stuff }
|
||||||
hprevinst:=0;
|
hprevinst:=0;
|
||||||
MainInstance:=getmodulehandle(GetCommandFile);
|
if not IsLibrary then
|
||||||
IsLibrary:=MainInstance=0;
|
HInstance:=getmodulehandle(GetCommandFile);
|
||||||
IsConsole:=true;
|
MainInstance:=HInstance;
|
||||||
|
{ No idea how to know this issue !! }
|
||||||
IsMultithreaded:=false;
|
IsMultithreaded:=false;
|
||||||
cmdshow:=startupinfo.wshowwindow;
|
cmdshow:=startupinfo.wshowwindow;
|
||||||
{ to test stack depth }
|
{ to test stack depth }
|
||||||
@ -757,7 +792,11 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.24 1998-11-16 15:48:54 peter
|
Revision 1.25 1998-11-30 09:16:58 pierre
|
||||||
|
+ added the changes from Pavel Ozerski after several modifications
|
||||||
|
to be able to create DLLs
|
||||||
|
|
||||||
|
Revision 1.24 1998/11/16 15:48:54 peter
|
||||||
* fixed longbool returns for api calls
|
* fixed longbool returns for api calls
|
||||||
|
|
||||||
Revision 1.23 1998/11/16 14:14:58 pierre
|
Revision 1.23 1998/11/16 14:14:58 pierre
|
||||||
|
31
rtl/win32/wdllprt0.as
Normal file
31
rtl/win32/wdllprt0.as
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//DLL Startup code for WIN32 port of FPK-Pascal 0.9.98
|
||||||
|
//Written by P.Ozerski
|
||||||
|
//16.10.1998
|
||||||
|
.text
|
||||||
|
.globl _mainCRTStartup
|
||||||
|
_mainCRTStartup:
|
||||||
|
movl $1,U_SYSWIN32_ISCONSOLE
|
||||||
|
jmp .LDLL_Entry
|
||||||
|
.globl _WinMainCRTStartup
|
||||||
|
_WinMainCRTStartup:
|
||||||
|
movl $0,U_SYSWIN32_ISCONSOLE
|
||||||
|
.LDLL_Entry:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %ebx
|
||||||
|
pushl %esi
|
||||||
|
pushl %edi
|
||||||
|
movl 8(%ebp),%edi
|
||||||
|
movl %edi,U_SYSWIN32_HINSTANCE
|
||||||
|
movl 12(%ebp),%edi
|
||||||
|
movl %edi,U_SYSWIN32_DLLREASON
|
||||||
|
movl 16(%ebp),%edi
|
||||||
|
movl %edi,U_SYSWIN32_DLLPARAM
|
||||||
|
call FPC_DLL_Entry
|
||||||
|
popl %edi
|
||||||
|
popl %esi
|
||||||
|
popl %ebx
|
||||||
|
popl %ebp
|
||||||
|
ret $12
|
||||||
|
|
||||||
|
|
14
rtl/win32/wprt0.as
Normal file
14
rtl/win32/wprt0.as
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//Startup code for WIN32 port of FPK-Pascal 0.9.98
|
||||||
|
//Written by P.Ozerski
|
||||||
|
//1998
|
||||||
|
// modified by Pierre Muller
|
||||||
|
.text
|
||||||
|
.GLOBL _mainCRTStartup
|
||||||
|
_mainCRTStartup:
|
||||||
|
movl $1,U_SYSWIN32_ISCONSOLE
|
||||||
|
jmp FPC_EXE_Entry
|
||||||
|
.GLOBL _WinMainCRTStartup
|
||||||
|
_WinMainCRTStartup:
|
||||||
|
movl $0,U_SYSWIN32_ISCONSOLE
|
||||||
|
jmp FPC_EXE_Entry
|
||||||
|
|
Loading…
Reference in New Issue
Block a user