mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:09:20 +02:00
* GetProcAddr added for OS/2, type of argument for ordinal target specific now
git-svn-id: trunk@26521 -
This commit is contained in:
parent
b91509159a
commit
1a430d8110
@ -26,6 +26,10 @@ interface
|
|||||||
Read OS-dependent interface declarations.
|
Read OS-dependent interface declarations.
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
|
{ Note: should define the TOrdinalEntry type and define
|
||||||
|
DYNLIBS_SUPPORTS_ORDINAL if the operating system supports loading
|
||||||
|
functions by a ordinal like e.g. Windows or OS/2 do }
|
||||||
|
|
||||||
{$define readinterface}
|
{$define readinterface}
|
||||||
{$i dynlibs.inc}
|
{$i dynlibs.inc}
|
||||||
{$undef readinterface}
|
{$undef readinterface}
|
||||||
@ -33,7 +37,10 @@ interface
|
|||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
OS - Independent declarations.
|
OS - Independent declarations.
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
{$IFNDEF DYNLIBS_SUPPORTS_ORDINAL}
|
||||||
|
type
|
||||||
|
TOrdinalEntry = SizeUInt;
|
||||||
|
{$ENDIF DYNLIBS_SUPPORTS_ORDINAL}
|
||||||
|
|
||||||
Function SafeLoadLibrary(const Name : RawByteString) : TLibHandle;
|
Function SafeLoadLibrary(const Name : RawByteString) : TLibHandle;
|
||||||
Function LoadLibrary(const Name : RawByteString) : TLibHandle;
|
Function LoadLibrary(const Name : RawByteString) : TLibHandle;
|
||||||
@ -41,7 +48,7 @@ Function SafeLoadLibrary(const Name : UnicodeString) : TLibHandle;
|
|||||||
Function LoadLibrary(const Name : UnicodeString) : TLibHandle;
|
Function LoadLibrary(const Name : UnicodeString) : TLibHandle;
|
||||||
|
|
||||||
Function GetProcedureAddress(Lib : TlibHandle; const ProcName : AnsiString) : Pointer;
|
Function GetProcedureAddress(Lib : TlibHandle; const ProcName : AnsiString) : Pointer;
|
||||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal: Word) : Pointer;
|
Function GetProcedureAddress(Lib : TLibHandle; Ordinal: TOrdinalEntry) : Pointer;
|
||||||
Function UnloadLibrary(Lib : TLibHandle) : Boolean;
|
Function UnloadLibrary(Lib : TLibHandle) : Boolean;
|
||||||
Function GetLoadErrorStr: string;
|
Function GetLoadErrorStr: string;
|
||||||
|
|
||||||
@ -59,9 +66,8 @@ Implementation
|
|||||||
OS - Independent declarations.
|
OS - Independent declarations.
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
{ Note: should define the Word overload and define DYNLIBS_SUPPORTS_ORDINAL if
|
{ Note: should define the TOrdinalEntry overload if the operating system
|
||||||
the operating system supports loading functions by a ordinal like e.g.
|
supports loading functions by a ordinal like e.g. Windows or OS/2 do }
|
||||||
Windows or OS/2 do }
|
|
||||||
{$i dynlibs.inc}
|
{$i dynlibs.inc}
|
||||||
|
|
||||||
{$ifndef FPCRTL_FILESYSTEM_TWO_BYTE_API}
|
{$ifndef FPCRTL_FILESYSTEM_TWO_BYTE_API}
|
||||||
@ -147,7 +153,7 @@ end;
|
|||||||
{$ifndef DYNLIBS_SUPPORTS_ORDINAL}
|
{$ifndef DYNLIBS_SUPPORTS_ORDINAL}
|
||||||
{ OS does not support loading by ordinal (or it's not implemented yet), so by
|
{ OS does not support loading by ordinal (or it's not implemented yet), so by
|
||||||
default we simply return Nil }
|
default we simply return Nil }
|
||||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : TOrdinalEntry) : Pointer;
|
||||||
begin
|
begin
|
||||||
Result := Nil;
|
Result := Nil;
|
||||||
end;
|
end;
|
||||||
|
@ -20,8 +20,11 @@
|
|||||||
Interface declarations
|
Interface declarations
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
|
{$DEFINE DYNLIBS_SUPPORTS_ORDINAL}
|
||||||
|
|
||||||
type
|
type
|
||||||
TLibHandle = longint;
|
TLibHandle = longint;
|
||||||
|
TOrdinalEntry = cardinal;
|
||||||
|
|
||||||
const
|
const
|
||||||
NilHandle = 0;
|
NilHandle = 0;
|
||||||
@ -66,6 +69,18 @@ begin
|
|||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetProcedureAddress (Lib: TLibHandle; Ordinal: TOrdinalEntry): pointer;
|
||||||
|
var
|
||||||
|
P: pointer;
|
||||||
|
begin
|
||||||
|
DynLibErrPath [0] := #0;
|
||||||
|
DynLibErrNo := DosQueryProcAddr (Lib, Ordinal, nil, P);
|
||||||
|
if DynLibErrNo = 0 then
|
||||||
|
Result := P
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function UnloadLibrary (Lib: TLibHandle): boolean;
|
function UnloadLibrary (Lib: TLibHandle): boolean;
|
||||||
begin
|
begin
|
||||||
DynLibErrPath [0] := #0;
|
DynLibErrPath [0] := #0;
|
||||||
|
@ -20,8 +20,11 @@
|
|||||||
Interface declarations
|
Interface declarations
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
|
{$define DYNLIBS_SUPPORTS_ORDINAL}
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TLibHandle = System.THandle;
|
TLibHandle = System.THandle;
|
||||||
|
TOrdinalEntry = word;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
NilHandle = 0;
|
NilHandle = 0;
|
||||||
@ -48,7 +51,6 @@ begin
|
|||||||
Result:=Windows.GetProcAddress(Lib,PChar(ProcName));
|
Result:=Windows.GetProcAddress(Lib,PChar(ProcName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$define DYNLIBS_SUPPORTS_ORDINAL}
|
|
||||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user