summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2015-11-22 13:32:12 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2015-11-22 13:32:12 +0000
commite02b34e500cdc49c049e1fef6df155b34910a716 (patch)
tree5f53dfb5905d67cf1712b39373f440d1a59c9615
parentb8e62279253be0ac3e6349ff2d8c52f5c8f79457 (diff)
downloadfpc-e02b34e500cdc49c049e1fef6df155b34910a716.tar.gz
Adjust non-Windows resources to work with indirect main information as well.
rtl/inc/systemh.inc, TEntryInformation: + new cross platform field ResLocation which stores the pointer to the resources rtl/inc/intres.inc: * change the type of ResHeader from PResHdr to PPResHdr (and adjust code that uses it accordingly; Note: the first dereferencing is assumed to be always valid!) * adjust declaration of ResHeader depending on whether indirect main information is used or not rtl/darwin/sysinit.pas & rtl/linux/si_impl.inc: * pass the location of the resources through SysInitEntryInformation rtl/bsd/system.pp & rtl/linux/system.pp: + new public variable FPCResLocation which is setup by SysEntry rtl/win32/sysinit.inc: * initialize ResLocation of SysInitEntryInformation as Nil rtl/win32/system.pp: * initialize ResLocation of EntryInformation as Nil git-svn-id: http://svn.freepascal.org/svn/fpc/branches/svenbarth@32491 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--packages/rtl/bsd/system.pp2
-rw-r--r--packages/rtl/darwin/sysinit.pas2
-rw-r--r--packages/rtl/inc/intres.inc59
-rw-r--r--packages/rtl/inc/systemh.inc1
-rw-r--r--packages/rtl/linux/si_impl.inc2
-rw-r--r--packages/rtl/linux/system.pp2
-rw-r--r--packages/rtl/win32/sysinit.inc1
-rw-r--r--packages/rtl/win32/system.pp1
8 files changed, 46 insertions, 24 deletions
diff --git a/packages/rtl/bsd/system.pp b/packages/rtl/bsd/system.pp
index dc4bba84ee..3af0eb8026 100644
--- a/packages/rtl/bsd/system.pp
+++ b/packages/rtl/bsd/system.pp
@@ -306,6 +306,7 @@ end;
var
FPCResStrInitTables : Pointer;public name '_FPC_ResStrInitTables';
FPCResourceStringTables : Pointer;public name '_FPC_ResourceStringTables';
+ FPCResLocation : Pointer;public name '_FPC_ResLocation';
procedure SysEntry(constref info: TEntryInformation);[public,alias:'FPC_SysEntry'];
begin
@@ -316,6 +317,7 @@ begin
initialstklen := EntryInformation.Platform.stklen;
FPCResStrInitTables := EntryInformation.ResStrInitTables;
FPCResourceStringTables := EntryInformation.ResourceStringTables;
+ FPCResLocation := EntryInformation.ResLocation;
{$ifdef cpui386}
Set8087CW(Default8087CW);
{$endif cpui386}
diff --git a/packages/rtl/darwin/sysinit.pas b/packages/rtl/darwin/sysinit.pas
index 16031ca99e..c377ef0117 100644
--- a/packages/rtl/darwin/sysinit.pas
+++ b/packages/rtl/darwin/sysinit.pas
@@ -32,6 +32,7 @@ var
{$ifdef FPC_HAS_RESSTRINITS}
ResStrInitTables : record end; external name 'FPC_RESSTRINITTABLES';
{$endif}
+ ResLocation: record end; external name 'FPC_RESLOCATION';
ResourceStringTables : record end; external name 'FPC_RESOURCESTRINGTABLES';
StkLen: SizeUInt; external name '__stklen';
@@ -48,6 +49,7 @@ const
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
WideInitTables : @WideInitTables;
{$endif}
+ ResLocation : @ResLocation;
asm_exit : nil;
PascalMain : @PascalMain;
valgrind_used : false;
diff --git a/packages/rtl/inc/intres.inc b/packages/rtl/inc/intres.inc
index e81b2c2dce..6709c678da 100644
--- a/packages/rtl/inc/intres.inc
+++ b/packages/rtl/inc/intres.inc
@@ -28,12 +28,23 @@ type
handles : PPtrUint; //pointer to handles
end;
PResHdr = ^TResHdr;
+ PPResHdr = ^PResHdr;
+
+{$if defined(win32) or (defined(darwin) and not defined(ver2_6))}
+{$define FPC_HAS_INDIRECT_MAIN_INFORMATION}
+{$endif}
var
{$ifdef FPC_HAS_WINLIKERESOURCES}
- ResHeader : PResHdr; external name 'FPC_RESLOCATION';
+{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
+ ResHeader : PPResHdr; external name '_FPC_ResLocation';
+{$else}
+ ResHeaderVar : PResHdr; external name 'FPC_RESLOCATION';
+ ResHeader : PPResHdr = @ResHeaderVar;
+{$endif}
{$else}
- ResHeader : PResHdr= nil;
+ ResHeaderVar : PResHdr = nil;
+ ResHeader : PPResHdr= @ResHeaderVar;
{$endif}
(*****************************************************************************
@@ -139,8 +150,8 @@ function InternalFindResource(ResourceName, ResourceType: PChar):
PResInfoNode;
begin
InternalFindResource:=nil;
- if ResHeader=nil then exit;
- InternalFindResource:=ResHeader^.rootptr;
+ if ResHeader^=nil then exit;
+ InternalFindResource:=ResHeader^^.rootptr;
InternalFindResource:=BinSearchRes(InternalFindResource,ResourceType);
if InternalFindResource<>nil then
@@ -179,9 +190,9 @@ var ptr : PResInfoNode;
tot, i : integer;
begin
IntEnumResourceTypes:=False;
- if ResHeader=nil then exit;
- tot:=ResHeader^.rootptr^.ncounthandle+ResHeader^.rootptr^.idcountsize;
- ptr:=ResHeader^.rootptr^.subptr;
+ if ResHeader^=nil then exit;
+ tot:=ResHeader^^.rootptr^.ncounthandle+ResHeader^^.rootptr^.idcountsize;
+ ptr:=ResHeader^^.rootptr^.subptr;
IntEnumResourceTypes:=true;
i:=0;
while i<tot do
@@ -196,8 +207,8 @@ var ptr : PResInfoNode;
tot, i : integer;
begin
IntEnumResourceNames:=False;
- if ResHeader=nil then exit;
- ptr:=ResHeader^.rootptr;
+ if ResHeader^=nil then exit;
+ ptr:=ResHeader^^.rootptr;
ptr:=BinSearchRes(ptr,ResourceType);
if ptr=nil then exit;
@@ -244,9 +255,9 @@ begin
ptr:=ptr^.subptr;
if ptr^.ncounthandle=0 then
begin
- ResHeader^.handles[ResHeader^.usedhandles]:=PtrUint(ptr);
- inc(ResHeader^.usedhandles);
- ptr^.ncounthandle:=ResHeader^.usedhandles;
+ ResHeader^^.handles[ResHeader^^.usedhandles]:=PtrUint(ptr);
+ inc(ResHeader^^.usedhandles);
+ ptr^.ncounthandle:=ResHeader^^.usedhandles;
end;
IntFindResource:=ptr^.ncounthandle;
end;
@@ -278,9 +289,9 @@ begin
if ptr^.ncounthandle=0 then
begin
- ResHeader^.handles[ResHeader^.usedhandles]:=PtrUint(ptr);
- inc(ResHeader^.usedhandles);
- ptr^.ncounthandle:=ResHeader^.usedhandles;
+ ResHeader^^.handles[ResHeader^^.usedhandles]:=PtrUint(ptr);
+ inc(ResHeader^^.usedhandles);
+ ptr^.ncounthandle:=ResHeader^^.usedhandles;
end;
IntFindResourceEx:=ptr^.ncounthandle;
end;
@@ -288,34 +299,34 @@ end;
Function IntLoadResource(ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): TFPResourceHGLOBAL;
begin
IntLoadResource:=0;
- if ResHeader=nil then exit;
- if (ResHandle<=0) or (ResHandle>ResHeader^.usedhandles) then exit;
- IntLoadResource:=TFPResourceHGLOBAL(PResInfoNode(ResHeader^.handles[ResHandle-1])^.subptr);
+ if ResHeader^=nil then exit;
+ if (ResHandle<=0) or (ResHandle>ResHeader^^.usedhandles) then exit;
+ IntLoadResource:=TFPResourceHGLOBAL(PResInfoNode(ResHeader^^.handles[ResHandle-1])^.subptr);
end;
Function IntSizeofResource(ModuleHandle: TFPResourceHMODULE; ResHandle: TFPResourceHandle): LongWord;
begin
IntSizeofResource:=0;
- if ResHeader=nil then exit;
- if (ResHandle<=0) or (ResHandle>ResHeader^.usedhandles) then exit;
- IntSizeofResource:=PResInfoNode(ResHeader^.handles[ResHandle-1])^.idcountsize;
+ if ResHeader^=nil then exit;
+ if (ResHandle<=0) or (ResHandle>ResHeader^^.usedhandles) then exit;
+ IntSizeofResource:=PResInfoNode(ResHeader^^.handles[ResHandle-1])^.idcountsize;
end;
Function IntLockResource(ResData: TFPResourceHGLOBAL): Pointer;
begin
IntLockResource:=Nil;
- if ResHeader=nil then exit;
+ if ResHeader^=nil then exit;
IntLockResource:=Pointer(ResData);
end;
Function IntUnlockResource(ResData: TFPResourceHGLOBAL): LongBool;
begin
- IntUnlockResource:=(ResHeader<>nil);
+ IntUnlockResource:=(ResHeader^<>nil);
end;
Function IntFreeResource(ResData: TFPResourceHGLOBAL): LongBool;
begin
- IntFreeResource:=(ResHeader<>nil);
+ IntFreeResource:=(ResHeader^<>nil);
end;
const
diff --git a/packages/rtl/inc/systemh.inc b/packages/rtl/inc/systemh.inc
index 04e166b000..e184783431 100644
--- a/packages/rtl/inc/systemh.inc
+++ b/packages/rtl/inc/systemh.inc
@@ -562,6 +562,7 @@ type
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
WideInitTables : Pointer;
{$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
+ ResLocation: Pointer;
asm_exit : Procedure;stdcall;
PascalMain : Procedure;
valgrind_used : boolean;
diff --git a/packages/rtl/linux/si_impl.inc b/packages/rtl/linux/si_impl.inc
index 847f2cf3f6..02fa05100b 100644
--- a/packages/rtl/linux/si_impl.inc
+++ b/packages/rtl/linux/si_impl.inc
@@ -27,6 +27,7 @@ var
ResStrInitTables : record end; external name 'FPC_RESSTRINITTABLES';
{$endif}
ResourceStringTables : record end; external name 'FPC_RESOURCESTRINGTABLES';
+ ResLocation : Pointer; external name 'FPC_RESLOCATION';
const
SysInitEntryInformation : TEntryInformation = (
@@ -41,6 +42,7 @@ const
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
WideInitTables : @WideInitTables;
{$endif}
+ ResLocation : @ResLocation;
asm_exit : nil;
PascalMain : @PascalMain;
valgrind_used : false;
diff --git a/packages/rtl/linux/system.pp b/packages/rtl/linux/system.pp
index 005861e633..86abacfb26 100644
--- a/packages/rtl/linux/system.pp
+++ b/packages/rtl/linux/system.pp
@@ -90,6 +90,7 @@ var
var
FPCResStrInitTables : Pointer;public name '_FPC_ResStrInitTables';
FPCResourceStringTables : Pointer;public name '_FPC_ResourceStringTables';
+ FPCResLocation : Pointer;public name '_FPC_ResLocation';
initialstkptr : Pointer;
procedure SysEntry(constref info: TEntryInformation);[public,alias:'FPC_SysEntry'];
@@ -101,6 +102,7 @@ begin
initialstkptr := EntryInformation.Platform.stkptr;
FPCResStrInitTables := EntryInformation.ResStrInitTables;
FPCResourceStringTables := EntryInformation.ResourceStringTables;
+ FPCResLocation := EntryInformation.ResLocation;
{$ifdef cpui386}
Set8087CW(Default8087CW);
{$endif cpui386}
diff --git a/packages/rtl/win32/sysinit.inc b/packages/rtl/win32/sysinit.inc
index 65d13b03f8..b86d9f11d3 100644
--- a/packages/rtl/win32/sysinit.inc
+++ b/packages/rtl/win32/sysinit.inc
@@ -63,6 +63,7 @@
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
WideInitTables : @WideInitTables;
{$endif}
+ ResLocation : nil;
asm_exit : @asm_exit;
PascalMain : @PascalMain;
valgrind_used : false;
diff --git a/packages/rtl/win32/system.pp b/packages/rtl/win32/system.pp
index 17a594cb25..ede1a41483 100644
--- a/packages/rtl/win32/system.pp
+++ b/packages/rtl/win32/system.pp
@@ -121,6 +121,7 @@ const
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
WideInitTables : nil;
{$endif}
+ ResLocation : nil;
asm_exit : nil;
PascalMain : nil;
valgrind_used : false;