public class

TypeLibraryService

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

Class Overview

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 getTypeLibraryService().

This class is thread-safe.

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

Summary

Constants
int GROUPID_TYPELIB_EFI
int GROUPID_TYPELIB_LINUX
int GROUPID_TYPELIB_LINUX_ANDROID
int GROUPID_TYPELIB_POSIX
int GROUPID_TYPELIB_TEST reserved for internal use
int GROUPID_TYPELIB_TEST1 reserved for internal use
int GROUPID_TYPELIB_TEST2 reserved for internal use
int GROUPID_TYPELIB_TEST3 reserved for internal use
int GROUPID_TYPELIB_TEST4 reserved for internal use
int GROUPID_TYPELIB_UNKNOWN
int GROUPID_TYPELIB_WIN32
int GROUPID_TYPELIB_WINDDK
int GROUPID_TYPELIB_WINDOWS
String TYPELIB_FILE_EXTENSION
Public Constructors
TypeLibraryService()
Create a new TLS.
TypeLibraryService(File folder)
Create a new TLS with an initial folder.
Public Methods
synchronized void addFolder(File folder, boolean doRescan)
Add a typelib folder to this TLS.
synchronized Set<Object> findConstantsByName(String name, ProcessorType procType, int groupId)
Find constants by name in the currently loaded typelibs.
synchronized Long findFirstIntegerConstantByName(String name)
Find the first integer constant by name in the currently loaded typelibs.
synchronized INativeMethodItem findRoutineByName(String name, ProcessorType procType, int groupId)
Find a routine by simple name in the currently loaded typelibs.
synchronized INativeMethodItem findRoutineByName(String name, ProcessorType procType)
Convenience method.
synchronized INativeType findTypeBySignature(String signature, ProcessorType procType, int groupId)
Find a type by signature in the currently loaded typelibs.
synchronized INativeType findTypeBySignature(String signature, ProcessorType procType)
Find a type by signature in the currently loaded typelibs.
synchronized List<TypeLibraryEntry> getAvailables()
Get the list of available type library entries.
synchronized List<ITypeLibrary> getLoadedTypeLibraries()
Get the list of loaded type libraries.
synchronized List<TypeLibraryEntry> getLoadedTypeLibraryEntries()
Get the list of entries that specify a loaded typelib.
synchronized List<TypeLibraryEntry> getNotLoadedTypeLibraryEntries()
Get the list of entries that specify an unloaded typelib.
static String groupIdToName(int id)
synchronized boolean load(ProcessorType processorType, int groupId, int maxCount)
Load type libraries matching the given processor and group.
synchronized boolean load(ProcessorType processorType, int groupId)
Load all type libraries matching the given processor and group.
synchronized boolean load(TypeLibraryEntry entry)
Load the provided type library into this TLS.
synchronized boolean loadExternal(ITypeLibrary typelib)
Load the provided external (not backed by a file managed by this TLS) typelib object.
synchronized boolean loadSingle(ProcessorType processorType, int groupId)
Load the highest priority type library matching the given processor type and group.
synchronized void rescan(boolean deleteOldEntries)
Rescan the type library folders to register/unregister additional/removed typelib binary files.
synchronized void rescan()
synchronized boolean unload(ITypeLibrary typelib)
Unload a type library.
synchronized boolean unload(TypeLibraryEntry e)
Unload a type library.
synchronized int unloadAll()
Unload all type libraries.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int GROUPID_TYPELIB_EFI

Constant Value: 30 (0x0000001e)

public static final int GROUPID_TYPELIB_LINUX

Constant Value: 2 (0x00000002)

public static final int GROUPID_TYPELIB_LINUX_ANDROID

Constant Value: 3 (0x00000003)

public static final int GROUPID_TYPELIB_POSIX

Constant Value: 1 (0x00000001)

public static final int GROUPID_TYPELIB_TEST

reserved for internal use

Constant Value: 100 (0x00000064)

public static final int GROUPID_TYPELIB_TEST1

reserved for internal use

Constant Value: 101 (0x00000065)

public static final int GROUPID_TYPELIB_TEST2

reserved for internal use

Constant Value: 102 (0x00000066)

public static final int GROUPID_TYPELIB_TEST3

reserved for internal use

Constant Value: 103 (0x00000067)

public static final int GROUPID_TYPELIB_TEST4

reserved for internal use

Constant Value: 104 (0x00000068)

public static final int GROUPID_TYPELIB_UNKNOWN

Constant Value: 0 (0x00000000)

public static final int GROUPID_TYPELIB_WIN32

Constant Value: 10 (0x0000000a)

public static final int GROUPID_TYPELIB_WINDDK

Constant Value: 20 (0x00000014)

public static final int GROUPID_TYPELIB_WINDOWS

Constant Value: 9 (0x00000009)

public static final String TYPELIB_FILE_EXTENSION

Constant Value: ".typelib"

Public Constructors

public TypeLibraryService ()

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

public TypeLibraryService (File folder)

Create a new TLS with an initial folder. The folder will be scanned.

Public Methods

public synchronized void addFolder (File folder, boolean doRescan)

Add a typelib folder to this TLS.

Parameters
doRescan if true, rescan() will be invoked after the folder addition

public synchronized 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)

public synchronized 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

public synchronized 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)

public synchronized INativeMethodItem findRoutineByName (String name, ProcessorType procType)

Convenience method.

Parameters
name routine name
procType optional

public synchronized INativeType findTypeBySignature (String signature, ProcessorType procType, int groupId)

Find a type by signature in the currently loaded typelibs. Convenience routine.

Parameters
procType optional
groupId optional (0 if none/unknown)

public synchronized INativeType findTypeBySignature (String signature, ProcessorType procType)

Find a type by signature in the currently loaded typelibs. Convenience routine.

Parameters
procType optional

public synchronized 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.

public synchronized List<ITypeLibrary> getLoadedTypeLibraries ()

Get the list of loaded type libraries. More type libraries may be available, eg non-loaded ones.

public synchronized List<TypeLibraryEntry> getLoadedTypeLibraryEntries ()

Get the list of entries that specify a loaded typelib.

public synchronized List<TypeLibraryEntry> getNotLoadedTypeLibraryEntries ()

Get the list of entries that specify an unloaded typelib.

public static String groupIdToName (int id)

public synchronized boolean load (ProcessorType processorType, int groupId, int maxCount)

Load type libraries matching the given processor and group.

Parameters
processorType mandatory
groupId mandatory
Returns
  • success indicator if one or more typelib was loaded

public synchronized boolean load (ProcessorType processorType, int groupId)

Load all type libraries matching the given processor and group.

Returns
  • success indicator if one or more typelib was loaded

public synchronized boolean load (TypeLibraryEntry entry)

Load the provided type library into this TLS.

public synchronized boolean loadExternal (ITypeLibrary typelib)

Load the provided external (not backed by a file managed by this TLS) typelib object.

public synchronized boolean loadSingle (ProcessorType processorType, int groupId)

Load the highest priority type library matching the given processor type and group.

Returns
  • success indicator

public synchronized void rescan (boolean deleteOldEntries)

Rescan the type library folders to register/unregister additional/removed typelib binary files.

public synchronized void rescan ()

public synchronized 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

public synchronized 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

public synchronized int unloadAll ()

Unload all type libraries.

Returns
  • the number of typelibs that were unloaded