Class TypeLibraryService

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.type.TypeLibraryService

public class TypeLibraryService extends Object
The type library service (TLS) is responsible for managing (loading and unloading) native code type libraries (typelibs). There is one TLS per JEB engines context. It can be retrieved via IEnginesContext.getTypeLibraryService().

This class is thread-safe.

Positive UUIDs (range [0, 0x80000000[) is reserved for internal use. External users may use negative UUIDs.

  • Field Details

    • GROUPID_TYPELIB_UNKNOWN

      public static final int GROUPID_TYPELIB_UNKNOWN
      See Also:
    • GROUPID_TYPELIB_POSIX

      public static final int GROUPID_TYPELIB_POSIX
      See Also:
    • GROUPID_TYPELIB_LINUX

      public static final int GROUPID_TYPELIB_LINUX
      See Also:
    • GROUPID_TYPELIB_LINUX_ANDROID

      public static final int GROUPID_TYPELIB_LINUX_ANDROID
      See Also:
    • GROUPID_TYPELIB_WINDOWS

      public static final int GROUPID_TYPELIB_WINDOWS
      See Also:
    • GROUPID_TYPELIB_WIN32

      public static final int GROUPID_TYPELIB_WIN32
      See Also:
    • GROUPID_TYPELIB_WINDDK

      public static final int GROUPID_TYPELIB_WINDDK
      See Also:
    • GROUPID_TYPELIB_EFI

      public static final int GROUPID_TYPELIB_EFI
      See Also:
    • GROUPID_TYPELIB_TEST

      public static final int GROUPID_TYPELIB_TEST
      reserved for internal use
      See Also:
    • GROUPID_TYPELIB_TEST1

      public static final int GROUPID_TYPELIB_TEST1
      reserved for internal use
      See Also:
    • GROUPID_TYPELIB_TEST2

      public static final int GROUPID_TYPELIB_TEST2
      reserved for internal use
      See Also:
    • GROUPID_TYPELIB_TEST3

      public static final int GROUPID_TYPELIB_TEST3
      reserved for internal use
      See Also:
    • GROUPID_TYPELIB_TEST4

      public static final int GROUPID_TYPELIB_TEST4
      reserved for internal use
      See Also:
    • TYPELIB_FILE_EXTENSION

      public static final String TYPELIB_FILE_EXTENSION
      See Also:
  • Constructor Details

    • TypeLibraryService

      public TypeLibraryService()
      Create a new TLS. At least one folder must be added using addFolder(File, boolean).
    • TypeLibraryService

      public TypeLibraryService(File folder)
      Create a new TLS with an initial folder. The folder will be scanned.
      Parameters:
      folder -
  • Method Details

    • addFolder

      public void addFolder(File folder, boolean doRescan)
      Add a typelib folder to this TLS.
      Parameters:
      folder -
      doRescan - if true, rescan() will be invoked after the folder addition
    • rescan

      public void rescan()
    • rescan

      public void rescan(boolean deleteOldEntries)
      Rescan the type library folders to register/unregister additional/removed typelib binary files.
      Parameters:
      deleteOldEntries -
    • getAvailables

      public List<TypeLibraryEntry> getAvailables()
      Get the list of available type library entries. An available typelib is not necessarily loaded. Refer to TypeLibraryEntry for additional details about the state of a given typelib.
      Returns:
    • getLoadedTypeLibraries

      public List<ITypeLibrary> getLoadedTypeLibraries()
      Get the list of loaded type libraries. More type libraries may be available, eg non-loaded ones.
      Returns:
    • getLoadedTypeLibraryEntries

      public List<TypeLibraryEntry> getLoadedTypeLibraryEntries()
      Get the list of entries that specify a loaded typelib.
      Returns:
    • getNotLoadedTypeLibraryEntries

      public List<TypeLibraryEntry> getNotLoadedTypeLibraryEntries()
      Get the list of entries that specify an unloaded typelib.
      Returns:
    • load

      public boolean load(TypeLibraryEntry entry)
      Load the provided type library into this TLS.
      Parameters:
      entry -
      Returns:
    • loadSingle

      public boolean loadSingle(ProcessorType processorType, int groupId)
      Load the highest priority type library matching the given processor type and group.
      Parameters:
      processorType -
      groupId -
      Returns:
      success indicator
    • load

      public boolean load(ProcessorType processorType, int groupId)
      Load all type libraries matching the given processor and group.
      Parameters:
      processorType -
      groupId -
      Returns:
      success indicator if one or more typelib was loaded
    • load

      public boolean load(ProcessorType processorType, int groupId, int maxCount)
      Load type libraries matching the given processor and group.
      Parameters:
      processorType - mandatory
      groupId - mandatory
      maxCount -
      Returns:
      success indicator if one or more typelib was loaded
    • loadExternal

      public boolean loadExternal(ITypeLibrary typelib)
      Load the provided external (not backed by a file managed by this TLS) typelib object.
      Parameters:
      typelib -
      Returns:
    • unload

      public boolean unload(ITypeLibrary typelib)
      Unload a type library.
      Parameters:
      typelib - a type library
      Returns:
      true if the typelib was previously loaded and is now unloaded; false otherwise
    • unload

      public boolean unload(TypeLibraryEntry e)
      Unload a type library.
      Parameters:
      e - a typelib entry
      Returns:
      true if the typelib was previously loaded and is now unloaded; false otherwise
    • unloadAll

      public int unloadAll()
      Unload all type libraries.
      Returns:
      the number of typelibs that were unloaded
    • findRoutineByName

      public INativeMethodItem findRoutineByName(String name, ProcessorType procType)
      Convenience method.
      Parameters:
      name - routine name
      procType - optional
      Returns:
    • findRoutineByName

      public INativeMethodItem findRoutineByName(String name, ProcessorType procType, int groupId)
      Find a routine by simple name in the currently loaded typelibs. Convenience routine.
      Parameters:
      name - routine name
      procType - optional
      groupId - optional (0 if none/unknown)
      Returns:
    • findTypeBySignature

      public INativeType findTypeBySignature(String signature, ProcessorType procType)
      Find a type by signature in the currently loaded typelibs. Convenience routine.
      Parameters:
      signature -
      procType - optional
      Returns:
    • findTypeBySignature

      public INativeType findTypeBySignature(String signature, ProcessorType procType, int groupId)
      Find a type by signature in the currently loaded typelibs. Convenience routine.
      Parameters:
      signature -
      procType - optional
      groupId - optional (0 if none/unknown)
      Returns:
    • groupIdToName

      public static String groupIdToName(int id)
    • findConstantsByName

      public Set<Object> findConstantsByName(String name, ProcessorType procType, int groupId)
      Find constants by name in the currently loaded typelibs. Convenience routine.
      Parameters:
      name - constant name
      procType - optional
      groupId - optional (0 if none/unknown)
      Returns:
    • findFirstIntegerConstantByName

      public Long findFirstIntegerConstantByName(String name)
      Find the first integer constant by name in the currently loaded typelibs. Convenience routine.
      Parameters:
      name - constant name
      Returns:
      a constant, null if none