Java Code Examples for ghidra.program.model.listing.Data#setByteArray()

The following examples show how to use ghidra.program.model.listing.Data#setByteArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testClearAllInstanceSettings() throws Exception {
	listing.createData(addr(10), new ByteDataType(), 1);
	Data data = listing.getDataAt(addr(10));

	data.setString("color", "red");
	data.setLong("someLongValue", 10);
	data.setByteArray("bytes", new byte[] { 0, 1, 2 });
	data.setString("endian", "big Endian");

	data.clearAllSettings();
	assertNull(data.getString("color"));
	assertNull(data.getLong("someLongValue"));
	assertNull(data.getByteArray("bytes"));
	assertNull(data.getString("endian"));
}
 
Example 2
Source File: SettingsTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetInstanceNames() throws Exception {
	listing.createData(addr(10), new ByteDataType(), 1);
	Data data = listing.getDataAt(addr(10));
	data.setString("color", "red");
	data.setLong("someLongValue", 10);
	data.setByteArray("bytes", new byte[] { 0, 1, 2 });
	data.setString("endian", "big Endian");

	String[] names = data.getNames();
	assertEquals(4, names.length);
}
 
Example 3
Source File: SettingsTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testClearInstanceSettings() throws Exception {
	listing.createData(addr(10), new ByteDataType(), 1);
	Data data = listing.getDataAt(addr(10));

	data.setString("color", "red");
	data.setLong("someLongValue", 10);
	data.setByteArray("bytes", new byte[] { 0, 1, 2 });

	data.clearSetting("color");
	assertNull(data.getString("color"));
}
 
Example 4
Source File: SettingsTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsEmptyInstanceSettings() throws Exception {
	listing.createData(addr(10), new ByteDataType(), 1);
	Data data = listing.getDataAt(addr(10));

	data.setString("color", "red");
	data.setLong("someLongValue", 10);
	data.setByteArray("bytes", new byte[] { 0, 1, 2 });
	data.setString("endian", "big Endian");

	assertTrue(!data.isEmpty());
	data.clearAllSettings();

	assertTrue(data.isEmpty());
}