mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 17:59:27 +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.
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
{ 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}
|
||||
{$i dynlibs.inc}
|
||||
{$undef readinterface}
|
||||
@ -33,7 +37,10 @@ interface
|
||||
{ ---------------------------------------------------------------------
|
||||
OS - Independent declarations.
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
{$IFNDEF DYNLIBS_SUPPORTS_ORDINAL}
|
||||
type
|
||||
TOrdinalEntry = SizeUInt;
|
||||
{$ENDIF DYNLIBS_SUPPORTS_ORDINAL}
|
||||
|
||||
Function SafeLoadLibrary(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 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 GetLoadErrorStr: string;
|
||||
|
||||
@ -59,9 +66,8 @@ Implementation
|
||||
OS - Independent declarations.
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
{ Note: should define the Word overload and define DYNLIBS_SUPPORTS_ORDINAL if
|
||||
the operating system supports loading functions by a ordinal like e.g.
|
||||
Windows or OS/2 do }
|
||||
{ Note: should define the TOrdinalEntry overload if the operating system
|
||||
supports loading functions by a ordinal like e.g. Windows or OS/2 do }
|
||||
{$i dynlibs.inc}
|
||||
|
||||
{$ifndef FPCRTL_FILESYSTEM_TWO_BYTE_API}
|
||||
@ -147,7 +153,7 @@ end;
|
||||
{$ifndef DYNLIBS_SUPPORTS_ORDINAL}
|
||||
{ OS does not support loading by ordinal (or it's not implemented yet), so by
|
||||
default we simply return Nil }
|
||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : TOrdinalEntry) : Pointer;
|
||||
begin
|
||||
Result := Nil;
|
||||
end;
|
||||
|
@ -20,8 +20,11 @@
|
||||
Interface declarations
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
{$DEFINE DYNLIBS_SUPPORTS_ORDINAL}
|
||||
|
||||
type
|
||||
TLibHandle = longint;
|
||||
TOrdinalEntry = cardinal;
|
||||
|
||||
const
|
||||
NilHandle = 0;
|
||||
@ -66,6 +69,18 @@ begin
|
||||
Result := nil;
|
||||
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;
|
||||
begin
|
||||
DynLibErrPath [0] := #0;
|
||||
|
@ -20,8 +20,11 @@
|
||||
Interface declarations
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
{$define DYNLIBS_SUPPORTS_ORDINAL}
|
||||
|
||||
Type
|
||||
TLibHandle = System.THandle;
|
||||
TOrdinalEntry = word;
|
||||
|
||||
Const
|
||||
NilHandle = 0;
|
||||
@ -48,7 +51,6 @@ begin
|
||||
Result:=Windows.GetProcAddress(Lib,PChar(ProcName));
|
||||
end;
|
||||
|
||||
{$define DYNLIBS_SUPPORTS_ORDINAL}
|
||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
||||
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user