# Class: com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignatureDBManager

Manage a set of [INativeSignaturePackage](INativeSignaturePackage), such that a native item \(routine, basic block, instruction or data\) can be matched against the [INativeSignature](INativeSignature) contained in these packages. The manager is a singleton handling all analysis. 

 Conflicts resolution, i.e. when several signature match, and processing of signatures' attributes are the client's responsibility.

## Static Field: SIGLIB_EXTENSION
Type: `java.lang.String`

Constant value: `.siglib`
Description: Extension of native signature package files.

## Static Field: SIGLIB_USER_PACKAGE_FOLDER
Type: `java.lang.String`

Constant value: `custom`
Description: Default folder name for user\-created signature packages.

## Method: activateAutoSigningMode
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`

Description: Activate automatic native signature creation for an analyzer.
parameter: gca: analyzer for which auto signing should be activated

## Method: addFolder
- parameter: `folder`, type: `java.io.File`
- parameter: `doRescan`, type: `boolean`

Description: Add a new folder to search for native signature packages.
parameter: folder: folder to add
parameter: doRescan: if true all registered folders are scanned for signature packages after the            addition

## Method: createUserPackage
- parameter: `procType`, type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorType`
- parameter: `packageName`, type: `java.lang.String`
- parameter: `packageDescription`, type: `java.lang.String`
- parameter: `packageAuthor`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry`

Description: Create new signature package in user folder \(see [#getUserCreatedPackageFolder()](#getUserCreatedPackageFolder()). If there is already a package with same name, it will fail.
parameter: procType: target processor type
parameter: packageName: package name
parameter: packageDescription: package description
parameter: packageAuthor: package author
return: the entry representing the new package, null if the creation failed

## Method: deactivateAutoSigningMode
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`

Description: Deactivate automatic native signature creation for an analyzer.
parameter: gca: analyzer for which auto signing should be deactivated

## Method: getAvailablePackages
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry>`

Description: Provides the list of available signature packages entries. The corresponding packages are not necessarily loaded.
return: available package entries

## Method: getLoadedPackages
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry>`

Description: Provides the list of signature packages entries for which the corresponding signatures are loaded in memory.
return: loaded package entries

## Method: getNumberLoadedSigs
- return type: `int`

Description: Count loaded signatures across registered analyzers.
return: number of loaded signatures

## Method: getSignatureGenerator
- return type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignatureGenerator`

Description: Get the signature generator used by this manager.
return: signature generator

## Method: getUserCreatedPackageFolder
- return type: `java.io.File`

Description: Get the path for the user\-created signature package folder, if any, whose name is set to [#SIGLIB_USER_PACKAGE_FOLDER](#SIGLIB_USER_PACKAGE_FOLDER).
return: user\-created package folder, possibly null

## Method: getUserCreatedPackages
- parameter: `procType`, type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorType`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry>`

Description: Provides the list of active signature packages entries that were created by a user with a given processor type.
parameter: procType: target processor type
return: list of packages, never null

## Method: getUserCreatedPackages
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry>`

Description: Provides the list of active signature packages entries that were created by a user.
return: list of packages, never null

## Method: getUserSelectedPackage
- parameter: `analyzer`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry`

Description: Get the user\-selected signature package for an analyzer.
parameter: analyzer: analyzer to query
return: selected package entry, possibly null

## Method: isActive
- return type: `boolean`

Description: Determine whether native signature matching is enabled.
return: true if matching is enabled

## Method: isAutoSigningModeActivated
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`
- return type: `boolean`

Description: Determine whether automatic native signature creation is active for an analyzer.
parameter: gca: analyzer to query
return: true if auto signing is active

## Method: loadDefaultPackages
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`

Description: Loads in memory the available packages suitable for the given analysis. The determination of the suitable packages is based on: 
 
- the processor type of the analysis 
- the detected compiler, if any 

 Note that only PNF Software packages are loaded by this method. User provided packages have to be manually loaded.
parameter: gca: analyzer for which packages should be loaded

## Method: loadPackage
- parameter: `entry`, type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry`
- parameter: `doMatching`, type: `boolean`
- return type: `boolean`

Description: Loads a specific package entry for all analyzers known to the manager. 

 Note: analyzer have to be for the same architecture as the package for the loading to happen.
parameter: entry: package entry to load
parameter: doMatching: if true, after the package has been loaded, analyzers will re\-match all            routines
return: true if the package was loaded for at least one analysis, false otherwise

## Method: loadPackage
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `entry`, type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry`
- return type: `boolean`

Description: Loads a specific package for the given analysis.
parameter: gca: analyzer for which to load the package
parameter: entry: package entry to load
return: true if the package was loaded

## Method: match
- parameter: `_gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<? extends com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `routines`, type: `java.util.Collection<com.pnfsoftware.jeb.core.units.code.asm.items.INativeMethodDataItem>`
- parameter: `uniqueMatchOnly`, type: `boolean`
- parameter: `maximumConfidenceLevel`, type: `boolean`
- parameter: `includeAlreadyMatched`, type: `boolean`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignatureMatchResult>`

Description: Match a list of native routines against the currently loaded signatures packages for this analysis. For each routine the algorithm searches for signatures whose **all** [INativeFeature](INativeFeature) match the routine. 

 The result can be incomplete: if a unique match was asked we stop the search as soon as we found two matches and report an incomplete result, see [NativeSignatureMatchResult#isComplete()](NativeSignatureMatchResult#isComplete()).
parameter: _gca: analyzer owning the routines
parameter: routines: routines to match
parameter: uniqueMatchOnly: if true the complete results are the ones for which there is only one            matching signature
parameter: maximumConfidenceLevel: if true the matching signatures \-\- if any \-\- will all be of the            maximum possible level of confidence. For example, if two matching signatures have            [ConfidenceLevel#MEDIUM](ConfidenceLevel#MEDIUM) and one has [ConfidenceLevel#LOW](ConfidenceLevel#LOW), only the            first two will be kept in the results. Otherwise, all matching signatures are            kept.
parameter: includeAlreadyMatched: if true routines already matched will be re\-matched, otherwise            they will be ignored
return: list of results, empty if none

## Method: onEvent
- parameter: `e`, type: `com.pnfsoftware.jeb.util.events.IEvent`

Description: Handle project save events by flushing pending user\-created package updates.
parameter: e: event to handle

## Method: registerAnalyzer
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`

Description: Register an analyzer to be handled by this manager.
parameter: gca: analyzer to register

## Method: removeAllFolders

Description: Empties the list of scanned folders

## Method: removeAllPackages

Description: Empties the list of available packages.

## Method: removeFolder
- parameter: `folder`, type: `java.io.File`
- parameter: `doRescan`, type: `boolean`

Description: Remove a folder from the list of folders to search for native signature packages.
parameter: folder: folder to remove
parameter: doRescan: if true all registered folders are scanned for signature packages after the            removal

## Method: rescan

Description: Rescan registered folders to register/unregister native signature packages. Such package names end with [NativeSignatureDBManager#SIGLIB_EXTENSION](NativeSignatureDBManager#SIGLIB_EXTENSION).

## Method: rescan
- parameter: `deleteOldEntries`, type: `boolean`

Description: Rescan registered folders to register/unregister native signature packages.
parameter: deleteOldEntries: true to remove entries for packages that were not found again

## Method: setActive
- parameter: `isActive`, type: `boolean`

Description: Enable or disable native signature matching.
parameter: isActive: true to enable matching

## Method: setUserSelectedPackage
- parameter: `analyzer`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`
- parameter: `userSelectedPackage`, type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignaturePackageEntry`

Description: Set the user\-selected signature package for an analyzer.
parameter: analyzer: analyzer to update
parameter: userSelectedPackage: selected package entry

## Method: unregisterAnalyzer
- parameter: `gca`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeAnalyzer<com.pnfsoftware.jeb.core.units.code.IInstruction>`

Description: Unregister an analyzer handled by this manager. 

 Note that this method unloads from memory the signatures packages used by the given analysis. Only the signatures storage specific to this analysis will be removed, i.e. if another analysis uses the same package it will stay loaded.
parameter: gca: analyzer to unregister

## Method: updateOnDiskPackages
- parameter: `updateExistingSignatures`, type: `boolean`

Description: Write new signatures into the on disk packages. These signatures are initially stored in memory into the corresponding entry \(see [NativeSignaturePackageEntry#addSignatureToWrite(INativeSignature)](NativeSignaturePackageEntry#addSignatureToWrite(INativeSignature))\). This allows to delay the actual write on disk of the new signatures. 

 Note: only user\-created signature packages can be written into through this method.
parameter: updateExistingSignatures: if true, matching existing signatures are replaced

## Static Method: getInstance
- parameter: `enginesContext`, type: `com.pnfsoftware.jeb.core.IEnginesContext`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.sig.NativeSignatureDBManager`

Description: Get the singleton native signature database manager.
parameter: enginesContext: engines context used by the manager
return: singleton manager

