use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class ModuleFactory method get.
public static Module get(final INaviModule module) {
final MockSqlProvider provider = new MockSqlProvider();
final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
final Database db = new Database(new MockDatabase());
return new Module(db, module, nodeTagManager, viewTagManager);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class ModuleFactory method get.
public static Module get(final INaviModule module, final SQLProvider provider) {
final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
final Database db = new Database(new MockDatabase());
return new Module(db, module, nodeTagManager, viewTagManager);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLViewLoader method checkArguments.
/**
* Checks arguments for validity.
*
* @param provider The provider argument to check.
* @param view The view argument to check.
* @param modules The modules argument to check.
* @param nodeTagManager The node tag manager argument to check.
*/
private static void checkArguments(final AbstractSQLProvider provider, final INaviView view, final List<INaviModule> modules, final CTagManager nodeTagManager) {
Preconditions.checkNotNull(provider, "IE00619: Provider argument can not be null");
Preconditions.checkNotNull(view, "IE00620: View argument can not be null");
Preconditions.checkArgument(view.inSameDatabase(provider), "IE00621: View is not part of this database");
Preconditions.checkNotNull(modules, "IE00622: Modules argument can not be null");
for (final INaviModule module : modules) {
Preconditions.checkNotNull(module, "IE00623: Modules list contains a null element");
Preconditions.checkArgument(module.inSameDatabase(provider), "IE00624: Module is not part of this database");
}
Preconditions.checkNotNull(nodeTagManager, "IE00625: Node tag manager argument can not be null");
Preconditions.checkArgument(nodeTagManager.inSameDatabase(provider), "IE00626: Node tag manager is not part of this database");
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processNodeLocalNodeCommentNotification.
/**
* Parses the {@link PGNotification} notifications from the PostgreSQL database back end for local
* code node comments by using a regular expression. If the regular expression matches the
* supplied {@link PGNotification} notification, it is determined if the code node in the
* notification is currently loaded, and if a {@link CommentNotificationContainer} with the
* gathered data from the notification is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processNodeLocalNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = NODE_LOCAL_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer moduleId = Integer.parseInt(matcher.group(3));
final Integer nodeId = Integer.parseInt(matcher.group(4));
final Integer commentId = matcher.group(6).equals("null") ? null : Integer.parseInt(matcher.group(6));
final INaviModule module = provider.findModule(moduleId);
if (!module.isLoaded()) {
return null;
}
final INaviCodeNode codeNode = (INaviCodeNode) NodeCache.get(provider).getNodeById(nodeId);
if (codeNode == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new CodeNodeCommentNotificationContainer(codeNode, operation, CommentScope.LOCAL, commentId);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviModule in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processFunctionCommentNotification.
/**
* Parses the notifications from the database back end for function comments by using a regular
* expression. If the regular expression matches the supplied {@link PGNotification} notification,
* a {@link CommentNotificationContainer} is build with the data from the notification.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processFunctionCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = FUNCTION_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer notificationModuleId = Integer.parseInt(matcher.group(3));
final IAddress notificationFunctionAddress = new CAddress(new BigInteger(matcher.group(4)));
final Integer commentId = matcher.group(5).equals("null") ? null : Integer.parseInt(matcher.group(5));
final INaviModule module = provider.findModule(notificationModuleId);
if ((module == null) || !module.isLoaded()) {
return null;
}
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(notificationFunctionAddress);
if (function == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new FunctionCommentNotificationContainer(function, operation, commentId);
}
Aggregations