mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
b8996c89be
4 changed files with 43 additions and 45 deletions
|
@ -31,7 +31,7 @@ public interface Archive extends DataTypeManagerOwner, Comparable<Archive> {
|
||||||
/**
|
/**
|
||||||
* Gets the name for this data type archive.
|
* Gets the name for this data type archive.
|
||||||
* This is the name to be presented to the user for this archive.
|
* This is the name to be presented to the user for this archive.
|
||||||
* @return the name
|
* @return the name or null if closed
|
||||||
*/
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import generic.theme.GIcon;
|
||||||
import ghidra.framework.model.DomainFile;
|
import ghidra.framework.model.DomainFile;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.program.model.listing.DataTypeArchive;
|
import ghidra.program.model.listing.DataTypeArchive;
|
||||||
|
import ghidra.util.exception.ClosedException;
|
||||||
|
|
||||||
public class ProjectArchive implements DomainFileArchive {
|
public class ProjectArchive implements DomainFileArchive {
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ public class ProjectArchive implements DomainFileArchive {
|
||||||
private DomainFile sourceDomainFile;
|
private DomainFile sourceDomainFile;
|
||||||
private DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
|
private DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
|
||||||
private DataTypeManagerHandler archiveManager;
|
private DataTypeManagerHandler archiveManager;
|
||||||
private DataTypeManager dataTypeManager;
|
private StandAloneDataTypeManager dataTypeManager;
|
||||||
|
|
||||||
ProjectArchive(DataTypeManagerHandler archiveManager, DataTypeArchive dataTypeArchive,
|
ProjectArchive(DataTypeManagerHandler archiveManager, DataTypeArchive dataTypeArchive,
|
||||||
DomainFile sourceDomainFile) {
|
DomainFile sourceDomainFile) {
|
||||||
|
@ -53,6 +54,9 @@ public class ProjectArchive implements DomainFileArchive {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
if (dataTypeManager == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return dataTypeManager.getName();
|
return dataTypeManager.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +78,9 @@ public class ProjectArchive implements DomainFileArchive {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isModifiable() {
|
public boolean isModifiable() {
|
||||||
|
if (dataTypeManager == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
DomainFile df = getDomainObject().getDomainFile();
|
DomainFile df = getDomainObject().getDomainFile();
|
||||||
return df.canSave();
|
return df.canSave();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +97,9 @@ public class ProjectArchive implements DomainFileArchive {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChanged() {
|
public boolean isChanged() {
|
||||||
|
if (dataTypeManager == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
DomainFile df = dataTypeArchive.getDomainFile();
|
DomainFile df = dataTypeArchive.getDomainFile();
|
||||||
long lastModifiedTime = df.getLastModifiedTime();
|
long lastModifiedTime = df.getLastModifiedTime();
|
||||||
return (lastModifiedTime == 0) || dataTypeArchive.isChanged();
|
return (lastModifiedTime == 0) || dataTypeArchive.isChanged();
|
||||||
|
@ -97,26 +107,35 @@ public class ProjectArchive implements DomainFileArchive {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSavable() {
|
public boolean isSavable() {
|
||||||
return !dataTypeArchive.getDomainFile().isReadOnly() && dataTypeArchive.isChangeable();
|
return dataTypeManager != null && !dataTypeArchive.getDomainFile().isReadOnly() &&
|
||||||
|
dataTypeArchive.isChangeable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() throws IOException {
|
public void save() throws IOException {
|
||||||
|
if (dataTypeManager == null) {
|
||||||
|
throw new ClosedException();
|
||||||
|
}
|
||||||
archiveManager.save(getDomainObject());
|
archiveManager.save(getDomainObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if (dataTypeManager != null) {
|
||||||
dataTypeManager.close();
|
dataTypeManager.close();
|
||||||
archiveManager.archiveClosed(this);
|
archiveManager.archiveClosed(this);
|
||||||
dataTypeManager = null;
|
dataTypeManager = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAs(Component component) throws IOException {
|
public void saveAs(Component component) throws IOException {
|
||||||
|
if (dataTypeManager == null) {
|
||||||
|
throw new ClosedException();
|
||||||
|
}
|
||||||
archiveManager.saveAs(dataTypeArchive);
|
archiveManager.saveAs(dataTypeArchive);
|
||||||
sourceDomainFile = dataTypeArchive.getDomainFile(); // update with new domain file
|
sourceDomainFile = dataTypeArchive.getDomainFile(); // update with new domain file
|
||||||
dataTypeArchive.updateID();
|
dataTypeManager.updateID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,7 +26,8 @@ import ghidra.framework.data.OpenMode;
|
||||||
import ghidra.framework.model.DomainFile;
|
import ghidra.framework.model.DomainFile;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.PointerDataType;
|
||||||
|
import ghidra.program.model.data.StandAloneDataTypeManager;
|
||||||
import ghidra.program.model.listing.DataTypeArchive;
|
import ghidra.program.model.listing.DataTypeArchive;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.util.ProgramChangeRecord;
|
import ghidra.program.util.ProgramChangeRecord;
|
||||||
|
@ -255,26 +256,17 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
||||||
return pointerSize > 0 && pointerSize <= PointerDataType.MAX_POINTER_SIZE_BYTES;
|
return pointerSize > 0 && pointerSize <= PointerDataType.MAX_POINTER_SIZE_BYTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ghidra.program.model.listing.Program#getDataTypeManager()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public DataTypeManager getDataTypeManager() {
|
public ProjectDataTypeManager getDataTypeManager() {
|
||||||
return dataTypeManager;
|
return dataTypeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ghidra.program.model.listing.Program#getCreationDate()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Date getCreationDate() {
|
public Date getCreationDate() {
|
||||||
Options pl = getOptions(ARCHIVE_INFO);
|
Options pl = getOptions(ARCHIVE_INFO);
|
||||||
return pl.getDate(DATE_CREATED, new Date(0));
|
return pl.getDate(DATE_CREATED, new Date(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ghidra.program.model.listing.Program#getDefaultPointerSize()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getDefaultPointerSize() {
|
public int getDefaultPointerSize() {
|
||||||
// Not sure what size this should be so use 4 for now.
|
// Not sure what size this should be so use 4 for now.
|
||||||
|
@ -283,9 +275,6 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
||||||
return pl.getInt(DEFAULT_POINTER_SIZE, 4);
|
return pl.getInt(DEFAULT_POINTER_SIZE, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ghidra.program.model.listing.Program#getChanges()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public DataTypeArchiveDBChangeSet getChanges() {
|
public DataTypeArchiveDBChangeSet getChanges() {
|
||||||
return (DataTypeArchiveDBChangeSet) changeSet;
|
return (DataTypeArchiveDBChangeSet) changeSet;
|
||||||
|
@ -581,11 +570,6 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
|
||||||
super.updateMetadata();
|
super.updateMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateID() {
|
|
||||||
dataTypeManager.updateID();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void domainObjectRestored() {
|
protected void domainObjectRestored() {
|
||||||
super.domainObjectRestored();
|
super.domainObjectRestored();
|
||||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.program.model.listing;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import ghidra.program.model.data.DataTypeManagerDomainObject;
|
import ghidra.program.model.data.DataTypeManagerDomainObject;
|
||||||
|
import ghidra.program.model.data.StandAloneDataTypeManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents the main entry point into an object which
|
* This interface represents the main entry point into an object which
|
||||||
|
@ -37,22 +38,18 @@ public interface DataTypeArchive extends DataTypeManagerDomainObject {
|
||||||
public static final Date JANUARY_1_1970 = new Date(0);
|
public static final Date JANUARY_1_1970 = new Date(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this archive has exclusive-write access which may be neccessary for some
|
* {@return the associated standalone data type manager.}
|
||||||
* operations.
|
|
||||||
* @return true if archive has exclusive-write access
|
|
||||||
*/
|
*/
|
||||||
public boolean hasExclusiveAccess();
|
@Override
|
||||||
|
public StandAloneDataTypeManager getDataTypeManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default pointer size as it may be stored within the data type archive.
|
* {@return the default pointer size as it may be stored within the data type archive.}
|
||||||
* @return default pointer size.
|
|
||||||
*/
|
*/
|
||||||
public int getDefaultPointerSize();
|
public int getDefaultPointerSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the creation date of this data type archive.
|
* {@return the creation date of this data type archive or Jan 1, 1970 if unknown.}
|
||||||
* existed, then Jan 1, 1970 is returned.
|
|
||||||
* @return the creation date of this data type archive
|
|
||||||
*/
|
*/
|
||||||
public Date getCreationDate();
|
public Date getCreationDate();
|
||||||
|
|
||||||
|
@ -68,6 +65,4 @@ public interface DataTypeArchive extends DataTypeManagerDomainObject {
|
||||||
*/
|
*/
|
||||||
public void invalidate();
|
public void invalidate();
|
||||||
|
|
||||||
public void updateID();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue