mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-22 16:11:44 +02:00
+ Add a new overload to DynLibs to allow loading by Ordinal only. This needs specific operating system support however and will return Nil (using a default implementation) if ordinals are not supported.
+ Implement overload for the three supported Windows targets. git-svn-id: trunk@26457 -
This commit is contained in:
parent
194abaddb4
commit
6273192ce1
@ -41,6 +41,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 UnloadLibrary(Lib : TLibHandle) : Boolean;
|
||||
Function GetLoadErrorStr: string;
|
||||
|
||||
@ -58,6 +59,9 @@ 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 }
|
||||
{$i dynlibs.inc}
|
||||
|
||||
{$ifndef FPCRTL_FILESYSTEM_TWO_BYTE_API}
|
||||
@ -140,6 +144,14 @@ begin
|
||||
end;
|
||||
{$endif not FPCRTL_FILESYSTEM_TWO_BYTE_API}
|
||||
|
||||
{$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;
|
||||
begin
|
||||
Result := Nil;
|
||||
end;
|
||||
{$endif not DYNLIBS_SUPPORTS_ORDINAL}
|
||||
|
||||
Function FreeLibrary(Lib : TLibHandle) : Boolean;
|
||||
|
||||
|
@ -48,6 +48,13 @@ begin
|
||||
Result:=Windows.GetProcAddress(Lib,PChar(ProcName));
|
||||
end;
|
||||
|
||||
{$define DYNLIBS_SUPPORTS_ORDINAL}
|
||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
||||
|
||||
begin
|
||||
Result:=Windows.GetProcAddress(Lib,PChar(Ordinal));
|
||||
end;
|
||||
|
||||
Function UnloadLibrary(Lib : TLibHandle) : Boolean;
|
||||
|
||||
begin
|
||||
|
@ -50,6 +50,12 @@ begin
|
||||
FreeMem(ws);
|
||||
end;
|
||||
|
||||
{$define DYNLIBS_SUPPORTS_ORDINAL}
|
||||
Function GetProcedureAddress(Lib : TLibHandle; Ordinal : Word) : Pointer;
|
||||
begin
|
||||
Result:=Windows.GetProcAddress(Lib, PWideChar(Ordinal));
|
||||
end;
|
||||
|
||||
Function UnloadLibrary(Lib : TLibHandle) : Boolean;
|
||||
begin
|
||||
Result:=Windows.FreeLibrary(Lib);
|
||||
|
Loading…
Reference in New Issue
Block a user