2
0

dynlibh.inc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2015 by the Free Pascal development team
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$ifdef FPC_SYSTEM_HAS_SYSDLH}
  11. {$i sysdlh.inc}
  12. {$else FPC_SYSTEM_HAS_SYSDLH}
  13. { These are fallback declarations }
  14. type
  15. TLibHandle = THandle;
  16. HINST = TLibHandle;
  17. const
  18. NilHandle = TLibHandle(0);
  19. {$endif FPC_SYSTEM_HAS_SYSDLH}
  20. { ---------------------------------------------------------------------
  21. OS - Independent declarations.
  22. ---------------------------------------------------------------------}
  23. type
  24. {$if not declared(TOrdinalEntry)}
  25. TOrdinalEntry = SizeUInt;
  26. {$endif not declared(TOrdinalEntry)}
  27. TLoadLibraryUHandler = function(const Name: UnicodeString): TLibHandle;
  28. TLoadLibraryAHandler = function(const Name: RawByteString): TLibHandle;
  29. TGetProcAddressHandler = function(Lib: TLibHandle; const ProcName: AnsiString): {$ifdef cpui8086}FarPointer{$else}Pointer{$endif};
  30. TGetProcAddressOrdinalHandler = function(Lib: TLibHandle; Ordinal: TOrdinalEntry): {$ifdef cpui8086}FarPointer{$else}Pointer{$endif};
  31. TUnloadLibraryHandler = function(Lib: TLibHandle): Boolean;
  32. TGetLoadErrorStrHandler = function: AnsiString;
  33. TDynLibsManager = record
  34. LoadLibraryU: TLoadLibraryUHandler;
  35. LoadLibraryA: TLoadLibraryAHandler;
  36. GetProcAddress: TGetProcAddressHandler;
  37. GetProcAddressOrdinal: TGetProcAddressOrdinalHandler;
  38. UnloadLibrary: TUnloadLibraryHandler;
  39. GetLoadErrorStr: TGetLoadErrorStrHandler;
  40. end;
  41. Function SafeLoadLibrary(const Name : RawByteString) : TLibHandle;
  42. Function LoadLibrary(const Name : RawByteString) : TLibHandle;
  43. Function SafeLoadLibrary(const Name : UnicodeString) : TLibHandle;
  44. Function LoadLibrary(const Name : UnicodeString) : TLibHandle;
  45. Function GetProcedureAddress(Lib : TlibHandle; const ProcName : AnsiString) : {$ifdef cpui8086}FarPointer{$else}Pointer{$endif};
  46. Function GetProcedureAddress(Lib : TLibHandle; Ordinal: TOrdinalEntry) : {$ifdef cpui8086}FarPointer{$else}Pointer{$endif};
  47. Function UnloadLibrary(Lib : TLibHandle) : Boolean;
  48. Function GetLoadErrorStr: AnsiString;
  49. // Kylix/Delphi compability
  50. Function FreeLibrary(Lib : TLibHandle) : Boolean; inline;
  51. Function GetProcAddress(Lib : TlibHandle; const ProcName : AnsiString) : {$ifdef cpui8086}FarPointer{$else}Pointer{$endif}; inline;
  52. Procedure GetDynLibsManager (Out Manager : TDynLibsManager);
  53. Procedure SetDynLibsManager (Const New : TDynLibsManager);
  54. Procedure SetDynLibsManager (Const New : TDynLibsManager; out Old: TDynLibsManager);
  55. // Delphi compatibility, needs to be expanded when packages arrive.
  56. Type
  57. TEnumModuleFuncLW = function (HInstance: THandle; Data: Pointer): Boolean;
  58. procedure EnumModules(Func: TEnumModuleFuncLW; Data: Pointer);