use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class InstructionTest method testCreate.
@Test
public void testCreate() throws CouldntLoadDataException, LoadCancelledException {
final SQLProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
internalModule.load();
final Database database = new Database(new MockDatabase());
final CTagManager mockTagManager = new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "Root", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider);
final TagManager nodeTagManager = new TagManager(mockTagManager);
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, internalModule, nodeTagManager, viewTagManager);
final List<Operand> operands = new ArrayList<Operand>();
final OperandExpression ex2 = OperandExpression.create(module, "eax", ExpressionType.Register);
final OperandExpression ex4 = OperandExpression.create(module, "ebx", ExpressionType.Register);
operands.add(Operand.create(module, ex2));
operands.add(Operand.create(module, ex4));
final Instruction instruction = Instruction.create(module, new Address(0x123), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32");
assertEquals(0x123, instruction.getAddress().toLong());
assertEquals(null, instruction.getComment());
assertArrayEquals(new byte[] { 1, 2, 3 }, instruction.getData());
assertEquals("mov", instruction.getMnemonic());
assertEquals(2, instruction.getOperands().size());
assertEquals("eax", instruction.getOperands().get(0).getRootNode().getChildren().get(0).getValue());
assertEquals("ebx", instruction.getOperands().get(1).getRootNode().getChildren().get(0).getValue());
assertEquals("123 mov eax, ebx", instruction.toString());
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class ModuleFactory method get.
public static Module get() {
final MockSqlProvider provider = new MockSqlProvider();
final Date creationDate = new Date();
final Date modificationDate = new Date();
final CModule internalModule = new CModule(123, "Name", "Comment", creationDate, modificationDate, "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, 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, internalModule, nodeTagManager, viewTagManager);
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class ModuleTest method testConstructor.
@Test
public void testConstructor() {
final MockSqlProvider provider = new MockSqlProvider();
final Date creationDate = new Date();
final Date modificationDate = new Date();
final CModule internalModule = new CModule(123, "Name", "Comment", creationDate, modificationDate, "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, 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());
final Module module = new Module(db, internalModule, nodeTagManager, viewTagManager);
assertEquals("Name", module.getName());
assertEquals("Comment", module.getDescription());
assertNotSame(creationDate, module.getCreationDate());
assertNotSame(modificationDate, module.getModificationDate());
assertTrue(creationDate.equals(module.getCreationDate()));
assertTrue(modificationDate.equals(module.getModificationDate()));
assertEquals(db, module.getDatabase());
assertNotNull(module.getDebugger());
assertEquals(0x555, module.getFilebase().toLong());
assertEquals(0x666, module.getImagebase().toLong());
assertEquals("12345678123456781234567812345678", module.getMD5());
assertEquals("1234567812345678123456781234567812345678", module.getSHA1());
assertEquals("Module 'Name'", module.toString());
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class ModuleTest method setUp.
@Before
public void setUp() throws FileReadException, CouldntLoadDataException, LoadCancelledException {
ConfigManager.instance().read();
final MockSqlProvider provider = new MockSqlProvider();
final Date creationDate = new Date();
final Date modificationDate = new Date();
final CModule internalModule = new CModule(123, "Name", "Comment", creationDate, modificationDate, "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
internalModule.load();
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());
m_module = new Module(db, internalModule, nodeTagManager, viewTagManager);
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class AddressSpaceTest method setUp.
@Before
public void setUp() {
final MockSqlProvider provider = new MockSqlProvider();
creationDate = new Date();
modificationDate = new Date();
final MockDatabase mockDb = new MockDatabase();
database = new Database(mockDb);
internalAddressSpace = new CAddressSpace(1, "Mock Space", "Mock Space Description", creationDate, modificationDate, new LinkedHashMap<INaviModule, IAddress>(), null, provider, new MockProject());
addressSpace = new AddressSpace(database, null, internalAddressSpace);
final Date creationDate = new Date();
final Date modificationDate = new Date();
final CModule internalModule = new CModule(123, "Name", "Comment", creationDate, modificationDate, "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
mockDb.getContent().addModule(internalModule);
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));
module = new Module(database, internalModule, nodeTagManager, viewTagManager);
}
Aggregations