diff options
author | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2016-02-19 16:22:20 +0000 |
---|---|---|
committer | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2016-02-19 16:22:20 +0000 |
commit | a96a0b94cd008b3ec0c828a25cf817ff788b1e62 (patch) | |
tree | 43ddfbc26a7f0f169433f65768fcaa166d5dba0a /rtl | |
parent | 7d710dfcd0b5c570b2b27c7da5d3c0f66a47cb85 (diff) | |
download | fpc-a96a0b94cd008b3ec0c828a25cf817ff788b1e62.tar.gz |
Adjust SysInstance so that it is correctly handled with the indirect entry information on Win32
win/sysosh.inc, TEntryInformationOS:
+ new field SysInstance that will hold the address to the main program's SysInstance variable
win32/system.pp:
* rename SysInstance to FPCSysInstance and make it a PLongInt
* OsSetupEntryInformation: setup FPCSysInstance
* adjust initialization of SysInstance to use FPCSysInstance instead
win32/sysinit.inc:
* SysInstance is no longer an external
* initialize the OS.SysInstance field of EntryInformation
win64/system.pp:
* add a FPCSysInstance that's a pointer to SysInstance
win/winres.inc:
* SysInstance is now a pointer and has the same name on both Win32 and Win64
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@33107 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl')
-rw-r--r-- | rtl/win/sysosh.inc | 1 | ||||
-rw-r--r-- | rtl/win/winres.inc | 4 | ||||
-rw-r--r-- | rtl/win32/sysinit.inc | 4 | ||||
-rw-r--r-- | rtl/win32/system.pp | 7 | ||||
-rw-r--r-- | rtl/win64/system.pp | 3 |
5 files changed, 12 insertions, 7 deletions
diff --git a/rtl/win/sysosh.inc b/rtl/win/sysosh.inc index 9cf544101a..59e355d22e 100644 --- a/rtl/win/sysosh.inc +++ b/rtl/win/sysosh.inc @@ -54,6 +54,7 @@ type TEntryInformationOS = record asm_exit : Procedure;stdcall; TlsKeyAddr : PDWord; + SysInstance: PLongInt; end; {$endif Win32} diff --git a/rtl/win/winres.inc b/rtl/win/winres.inc index 5f1fd81409..d7ea747800 100644 --- a/rtl/win/winres.inc +++ b/rtl/win/winres.inc @@ -9,11 +9,11 @@ function SysLockResource(hResData:TFPResourceHGLOBAL):Pointer; stdcall; external function SysFreeResource(hResData:TFPResourceHGLOBAL):Longbool; stdcall; external 'kernel32' name 'FreeResource'; var - SysInstance : PtrUInt;external name {$ifdef win64} 'SysInstance' {$else} '_FPC_SysInstance' {$endif} ; + SysInstance : PPtrUInt;external name '_FPC_SysInstance'; Function IntHINSTANCE : TFPResourceHMODULE; begin - IntHINSTANCE:=sysinstance; + IntHINSTANCE:=sysinstance^; end; Function IntEnumResourceTypes(ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool; diff --git a/rtl/win32/sysinit.inc b/rtl/win32/sysinit.inc index e78fbf35f7..d4b7db6631 100644 --- a/rtl/win32/sysinit.inc +++ b/rtl/win32/sysinit.inc @@ -15,7 +15,7 @@ **********************************************************************} var - SysInstance : Longint;external name '_FPC_SysInstance'; + SysInstance : LongInt; TlsKeyVar: DWord = $ffffffff; InitFinalTable : record end; external name 'INITFINAL'; @@ -67,6 +67,7 @@ OS : ( asm_exit : @asm_exit; TlsKeyAddr : @TlsKeyVar; + SysInstance : @SysInstance; ); ); @@ -81,6 +82,7 @@ EntryInformation.WideInitTables:=@WideInitTables; EntryInformation.OS.asm_exit:=@asm_exit; EntryInformation.OS.TlsKeyAddr:=@TlsKeyVar; + EntryInformation.OS.SysInstance:=@SysInstance; EntryInformation.PascalMain:=@PascalMain;} SysInitEntryInformation.valgrind_used:=valgrind_used; end; diff --git a/rtl/win32/system.pp b/rtl/win32/system.pp index 60b4c1f82a..1bec9136ce 100644 --- a/rtl/win32/system.pp +++ b/rtl/win32/system.pp @@ -111,7 +111,7 @@ Const implementation var - SysInstance : Longint;public name '_FPC_SysInstance'; + FPCSysInstance : PLongint;public name '_FPC_SysInstance'; {$define FPC_SYSTEM_HAS_OSSETUPENTRYINFORMATION} procedure OsSetupEntryInformation(const info: TEntryInformation); forward; @@ -136,6 +136,7 @@ end; procedure OsSetupEntryInformation(const info: TEntryInformation); begin TlsKey := info.OS.TlsKeyAddr; + FPCSysInstance := info.OS.SysInstance; end; {***************************************************************************** @@ -650,9 +651,9 @@ begin GetStartupInfo(@startupinfo); { some misc Win32 stuff } if not IsLibrary then - SysInstance:=getmodulehandle(nil); + FPCSysInstance^:=getmodulehandle(nil); - MainInstance:=SysInstance; + MainInstance:=FPCSysInstance^; { pass dummy value } StackLength := CheckInitialStkLen($1000000); diff --git a/rtl/win64/system.pp b/rtl/win64/system.pp index 2df83b7e21..c004035888 100644 --- a/rtl/win64/system.pp +++ b/rtl/win64/system.pp @@ -106,7 +106,8 @@ implementation {$asmmode att} var - SysInstance : qword;public; + SysInstance : qword; + FPCSysInstance: PQWord = @SysInstance; public name '_FPC_SysInstance'; {$ifdef FPC_USE_WIN64_SEH} function main_wrapper(arg: Pointer; proc: Pointer): ptrint; assembler; nostackframe; |