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
      Unknown or unspecified type library group.
      See Also:
    • GROUPID_TYPELIB_POSIX

      public static final int GROUPID_TYPELIB_POSIX
      POSIX type library group.
      See Also:
    • GROUPID_TYPELIB_LINUX

      public static final int GROUPID_TYPELIB_LINUX
      Linux type library group.
      See Also:
    • GROUPID_TYPELIB_LINUX_ANDROID

      public static final int GROUPID_TYPELIB_LINUX_ANDROID
      Android/Linux type library group.
      See Also:
    • GROUPID_TYPELIB_WINDOWS

      public static final int GROUPID_TYPELIB_WINDOWS
      Windows type library group.
      See Also:
    • GROUPID_TYPELIB_WIN32

      public static final int GROUPID_TYPELIB_WIN32
      Win32 type library group.
      See Also:
    • GROUPID_TYPELIB_WINDDK

      public static final int GROUPID_TYPELIB_WINDDK
      Windows DDK type library group.
      See Also:
    • GROUPID_TYPELIB_EFI

      public static final int GROUPID_TYPELIB_EFI
      EFI type library group.
      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
      Extension used by binary type library files.
      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 - initial type library folder
  • Method Details

    • addFolder

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

      public void rescan()
      Rescan the registered type library folders and delete obsolete entries.
    • rescan

      public void rescan(boolean deleteOldEntries)
      Rescan the type library folders to register/unregister additional/removed typelib binary files.
      Parameters:
      deleteOldEntries - true to delete stale or superseded type library files
    • 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:
      available type library entries
    • getLoadedTypeLibraries

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

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

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

      public boolean load(TypeLibraryEntry entry)
      Load the provided type library into this TLS.
      Parameters:
      entry - type library entry to load
      Returns:
      true if the entry is loaded after this call
    • loadSingle

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

      public boolean load(ProcessorType processorType, int groupId)
      Load all type libraries matching the given processor and group.
      Parameters:
      processorType - processor type to match
      groupId - type library group identifier to match
      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 - maximum number of matching type libraries to load
      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 - external type library object
      Returns:
      true if the external type library was registered
    • 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:
      matching routine, or null if none was found
    • 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:
      matching routine, or null if none was found
    • findTypeBySignature

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

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

      public static String groupIdToName(int id)
      Get a display name for a type library group identifier.
      Parameters:
      id - type library group identifier
      Returns:
      the display name, or the decimal identifier if the group is unknown
    • 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:
      matching constant values
    • 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