Class TypeLibraryService
java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.type.TypeLibraryService
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intEFI type library group.static final intLinux type library group.static final intAndroid/Linux type library group.static final intPOSIX type library group.static final intreserved for internal usestatic final intreserved for internal usestatic final intreserved for internal usestatic final intreserved for internal usestatic final intreserved for internal usestatic final intUnknown or unspecified type library group.static final intWin32 type library group.static final intWindows DDK type library group.static final intWindows type library group.static final StringExtension used by binary type library files. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new TLS.TypeLibraryService(File folder) Create a new TLS with an initial folder. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a typelib folder to this TLS.findConstantsByName(String name, ProcessorType procType, int groupId) Find constants by name in the currently loaded typelibs.Find the first integer constant by name in the currently loaded typelibs.findRoutineByName(String name, ProcessorType procType) Convenience method.findRoutineByName(String name, ProcessorType procType, int groupId) Find a routine by simple name in the currently loaded typelibs.findTypeBySignature(String signature, ProcessorType procType) Find a type by signature in the currently loaded typelibs.findTypeBySignature(String signature, ProcessorType procType, int groupId) Find a type by signature in the currently loaded typelibs.Get the list of available type library entries.Get the list of loaded type libraries.Get the list of entries that specify a loaded typelib.Get the list of entries that specify an unloaded typelib.static StringgroupIdToName(int id) Get a display name for a type library group identifier.booleanload(TypeLibraryEntry entry) Load the provided type library into this TLS.booleanload(ProcessorType processorType, int groupId) Load all type libraries matching the given processor and group.booleanload(ProcessorType processorType, int groupId, int maxCount) Load type libraries matching the given processor and group.booleanloadExternal(ITypeLibrary typelib) Load the provided external (not backed by a file managed by this TLS) typelib object.booleanloadSingle(ProcessorType processorType, int groupId) Load the highest priority type library matching the given processor type and group.voidrescan()Rescan the registered type library folders and delete obsolete entries.voidrescan(boolean deleteOldEntries) Rescan the type library folders to register/unregister additional/removed typelib binary files.booleanunload(ITypeLibrary typelib) Unload a type library.booleanUnload a type library.intUnload all type libraries.
-
Field Details
-
GROUPID_TYPELIB_UNKNOWN
public static final int GROUPID_TYPELIB_UNKNOWNUnknown or unspecified type library group.- See Also:
-
GROUPID_TYPELIB_POSIX
public static final int GROUPID_TYPELIB_POSIXPOSIX type library group.- See Also:
-
GROUPID_TYPELIB_LINUX
public static final int GROUPID_TYPELIB_LINUXLinux type library group.- See Also:
-
GROUPID_TYPELIB_LINUX_ANDROID
public static final int GROUPID_TYPELIB_LINUX_ANDROIDAndroid/Linux type library group.- See Also:
-
GROUPID_TYPELIB_WINDOWS
public static final int GROUPID_TYPELIB_WINDOWSWindows type library group.- See Also:
-
GROUPID_TYPELIB_WIN32
public static final int GROUPID_TYPELIB_WIN32Win32 type library group.- See Also:
-
GROUPID_TYPELIB_WINDDK
public static final int GROUPID_TYPELIB_WINDDKWindows DDK type library group.- See Also:
-
GROUPID_TYPELIB_EFI
public static final int GROUPID_TYPELIB_EFIEFI type library group.- See Also:
-
GROUPID_TYPELIB_TEST
public static final int GROUPID_TYPELIB_TESTreserved for internal use- See Also:
-
GROUPID_TYPELIB_TEST1
public static final int GROUPID_TYPELIB_TEST1reserved for internal use- See Also:
-
GROUPID_TYPELIB_TEST2
public static final int GROUPID_TYPELIB_TEST2reserved for internal use- See Also:
-
GROUPID_TYPELIB_TEST3
public static final int GROUPID_TYPELIB_TEST3reserved for internal use- See Also:
-
GROUPID_TYPELIB_TEST4
public static final int GROUPID_TYPELIB_TEST4reserved for internal use- See Also:
-
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 usingaddFolder(File, boolean). -
TypeLibraryService
Create a new TLS with an initial folder. The folder will be scanned.- Parameters:
folder- initial type library folder
-
-
Method Details
-
addFolder
Add a typelib folder to this TLS.- Parameters:
folder- type library folderdoRescan- 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
Get the list of available type library entries. An available typelib is not necessarily loaded. Refer toTypeLibraryEntryfor additional details about the state of a given typelib.- Returns:
- available type library entries
-
getLoadedTypeLibraries
Get the list of loaded type libraries. More type libraries may be available, eg non-loaded ones.- Returns:
- loaded type libraries
-
getLoadedTypeLibraryEntries
Get the list of entries that specify a loaded typelib.- Returns:
- loaded type library entries
-
getNotLoadedTypeLibraryEntries
Get the list of entries that specify an unloaded typelib.- Returns:
- unloaded type library entries
-
load
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
Load the highest priority type library matching the given processor type and group.- Parameters:
processorType- processor type to matchgroupId- type library group identifier to match- Returns:
- success indicator
-
load
Load all type libraries matching the given processor and group.- Parameters:
processorType- processor type to matchgroupId- type library group identifier to match- Returns:
- success indicator if one or more typelib was loaded
-
load
Load type libraries matching the given processor and group.- Parameters:
processorType- mandatorygroupId- mandatorymaxCount- maximum number of matching type libraries to load- Returns:
- success indicator if one or more typelib was loaded
-
loadExternal
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
Unload a type library.- Parameters:
typelib- a type library- Returns:
- true if the typelib was previously loaded and is now unloaded; false otherwise
-
unload
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
Convenience method.- Parameters:
name- routine nameprocType- optional- Returns:
- matching routine, or null if none was found
-
findRoutineByName
Find a routine by simple name in the currently loaded typelibs. Convenience routine.- Parameters:
name- routine nameprocType- optionalgroupId- optional (0 if none/unknown)- Returns:
- matching routine, or null if none was found
-
findTypeBySignature
Find a type by signature in the currently loaded typelibs. Convenience routine.- Parameters:
signature- type signatureprocType- optional- Returns:
- matching type, or null if none was found
-
findTypeBySignature
Find a type by signature in the currently loaded typelibs. Convenience routine.- Parameters:
signature- type signatureprocType- optionalgroupId- optional (0 if none/unknown)- Returns:
- matching type, or null if none was found
-
groupIdToName
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
Find constants by name in the currently loaded typelibs. Convenience routine.- Parameters:
name- constant nameprocType- optionalgroupId- optional (0 if none/unknown)- Returns:
- matching constant values
-
findFirstIntegerConstantByName
Find the first integer constant by name in the currently loaded typelibs. Convenience routine.- Parameters:
name- constant name- Returns:
- a constant, null if none
-