WIP
This commit is contained in:
parent
5ce1a399b1
commit
ebfc4bf4f4
|
@ -10,22 +10,22 @@ struct GHStubException : public std::exception {
|
||||||
void *gh_stub_impl_ptr(void *ptr);
|
void *gh_stub_impl_ptr(void *ptr);
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
T gh_stub_impl_cdecl(void *ptr, Args... args) {
|
T gh_stub_impl_cdecl(void *ptr_, Args... args) {
|
||||||
#if RE_DBG_INJECTED
|
#if RE_DBG_INJECTED
|
||||||
using Callable = __cdecl T (*)(Args...);
|
using Callable = __cdecl T (*)(Args...);
|
||||||
static Callable *ptr = (Callable *)gh_stub_impl_ptr(ptr);
|
static Callable *fn = (Callable *)gh_stub_impl_ptr(ptr_);
|
||||||
return ptr(args...);
|
return fn(args...);
|
||||||
#else
|
#else
|
||||||
throw GHStubException("Function not implemented");
|
throw GHStubException("Function not implemented");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
T gh_stub_impl_stdcall(void *ptr, Args... args) {
|
T gh_stub_impl_stdcall(void *ptr_, Args... args) {
|
||||||
#if RE_DBG_INJECTED
|
#if RE_DBG_INJECTED
|
||||||
using Callable = __stdcall T (*)(Args...);
|
using Callable = __stdcall T (*)(Args...);
|
||||||
static Callable *ptr = (Callable *)gh_stub_impl_ptr(ptr);
|
static Callable *fn = (Callable *)gh_stub_impl_ptr(ptr_);
|
||||||
return ptr(args...);
|
return fn(args...);
|
||||||
#else
|
#else
|
||||||
throw GHStubException("Function not implemented");
|
throw GHStubException("Function not implemented");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1924,4 +1924,6 @@ _strflt
|
||||||
_tiddata
|
_tiddata
|
||||||
_BIN_TYPES_
|
_BIN_TYPES_
|
||||||
tagBIND_FLAGS_
|
tagBIND_FLAGS_
|
||||||
ImageBaseOffset32
|
ImageBaseOffset32
|
||||||
|
wchar_t
|
||||||
|
WCHAR
|
|
@ -82,4 +82,5 @@ winspool.h
|
||||||
winsvc.h
|
winsvc.h
|
||||||
winuser.h
|
winuser.h
|
||||||
winver.h
|
winver.h
|
||||||
wtypes.h
|
wtypes.h
|
||||||
|
dinput.h
|
|
@ -13,6 +13,6 @@ public class DumpTypes extends GhidraScript {
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
TypeDumper dumper = new TypeDumper(this);
|
TypeDumper dumper = new TypeDumper(this);
|
||||||
dumper.run();
|
dumper.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ import ghidra.util.task.TaskMonitor;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -27,10 +27,6 @@ public class DataTypeWriter {
|
||||||
private static String EOL = System.getProperty("line.separator");
|
private static String EOL = System.getProperty("line.separator");
|
||||||
private Set<DataType> resolved;
|
private Set<DataType> resolved;
|
||||||
private Map<String, DataType> resolvedTypeMap;
|
private Map<String, DataType> resolvedTypeMap;
|
||||||
private Set<Composite> deferredCompositeDeclarations;
|
|
||||||
private ArrayDeque<DataType> deferredTypeFIFO;
|
|
||||||
private Set<DataType> deferredTypes;
|
|
||||||
private int writerDepth;
|
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
private DataTypeManager dtm;
|
private DataTypeManager dtm;
|
||||||
private DataOrganization dataOrganization;
|
private DataOrganization dataOrganization;
|
||||||
|
@ -54,10 +50,6 @@ public class DataTypeWriter {
|
||||||
this.blacklistedTypes = new HashSet<>();
|
this.blacklistedTypes = new HashSet<>();
|
||||||
this.resolved = new HashSet();
|
this.resolved = new HashSet();
|
||||||
this.resolvedTypeMap = new HashMap();
|
this.resolvedTypeMap = new HashMap();
|
||||||
this.deferredCompositeDeclarations = new HashSet();
|
|
||||||
this.deferredTypeFIFO = new ArrayDeque();
|
|
||||||
this.deferredTypes = new HashSet();
|
|
||||||
this.writerDepth = 0;
|
|
||||||
this.cppStyleComments = false;
|
this.cppStyleComments = false;
|
||||||
this.dtm = dtm;
|
this.dtm = dtm;
|
||||||
if (dtm != null) {
|
if (dtm != null) {
|
||||||
|
@ -128,254 +120,138 @@ public class DataTypeWriter {
|
||||||
|
|
||||||
public void write(List<DataType> dataTypes, TaskMonitor monitor, boolean throwExceptionOnInvalidType)
|
public void write(List<DataType> dataTypes, TaskMonitor monitor, boolean throwExceptionOnInvalidType)
|
||||||
throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
monitor.initialize((long) dataTypes.size());
|
// Sort types to handle dependencies
|
||||||
|
List<DataType> sortedTypes = sortTypesByDependencies(dataTypes);
|
||||||
|
|
||||||
|
monitor.initialize((long) sortedTypes.size());
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
Iterator var5 = dataTypes.iterator();
|
|
||||||
|
for (DataType dataType : sortedTypes) {
|
||||||
while (var5.hasNext()) {
|
|
||||||
DataType dataType = (DataType) var5.next();
|
|
||||||
monitor.checkCancelled();
|
monitor.checkCancelled();
|
||||||
this.write(dataType, monitor, throwExceptionOnInvalidType);
|
this.writeType(dataType, monitor, throwExceptionOnInvalidType);
|
||||||
++cnt;
|
++cnt;
|
||||||
monitor.setProgress((long) cnt);
|
monitor.setProgress((long) cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deferWrite(DataType dt) {
|
private List<DataType> sortTypesByDependencies(List<DataType> dataTypes) {
|
||||||
if (!this.resolved.contains(dt) && !this.deferredTypes.contains(dt)) {
|
// Simple dependency sorting - write forward declarations for composites first,
|
||||||
this.deferredTypes.add(dt);
|
// then non-composites, then composite bodies
|
||||||
this.deferredTypeFIFO.addLast(dt);
|
List<DataType> forwardDeclarations = new ArrayList<>();
|
||||||
|
List<DataType> nonComposites = new ArrayList<>();
|
||||||
|
List<DataType> composites = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DataType dt : dataTypes) {
|
||||||
|
if (dt instanceof Structure || dt instanceof Union) {
|
||||||
|
composites.add(dt);
|
||||||
|
} else {
|
||||||
|
nonComposites.add(dt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DataType> result = new ArrayList<>();
|
||||||
|
// First add forward declarations for all composites
|
||||||
|
result.addAll(composites);
|
||||||
|
// Then add non-composites
|
||||||
|
result.addAll(nonComposites);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(DataType dt, TaskMonitor monitor) throws IOException, CancelledException {
|
void write(DataType dt, TaskMonitor monitor) throws IOException, CancelledException {
|
||||||
this.doWrite(dt, monitor, true);
|
this.writeType(dt, monitor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(DataType dt, TaskMonitor monitor, boolean throwExceptionOnInvalidType)
|
void write(DataType dt, TaskMonitor monitor, boolean throwExceptionOnInvalidType)
|
||||||
throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
this.doWrite(dt, monitor, throwExceptionOnInvalidType);
|
this.writeType(dt, monitor, throwExceptionOnInvalidType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWrite(DataType dt, TaskMonitor monitor, boolean throwExceptionOnInvalidType)
|
private void writeType(DataType dt, TaskMonitor monitor, boolean throwExceptionOnInvalidType)
|
||||||
throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
if (dt != null) {
|
if (dt == null || blacklistedTypes.contains(dt.getDisplayName())) {
|
||||||
if (blacklistedTypes.contains(dt.getDisplayName()))
|
return;
|
||||||
return;
|
|
||||||
if (!(dt instanceof FunctionDefinition)) {
|
|
||||||
if (dt instanceof FactoryDataType) {
|
|
||||||
IllegalArgumentException iae = new IllegalArgumentException("Factory data types may not be written");
|
|
||||||
if (throwExceptionOnInvalidType) {
|
|
||||||
throw iae;
|
|
||||||
}
|
|
||||||
|
|
||||||
Msg.error(this, "Factory data types may not be written - type: " + dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(dt instanceof Pointer) && !(dt instanceof Array) && !(dt instanceof BitFieldDataType)) {
|
|
||||||
dt = dt.clone(this.dtm);
|
|
||||||
if (!this.resolved.contains(dt)) {
|
|
||||||
this.resolved.add(dt);
|
|
||||||
DataType resolvedType = (DataType) this.resolvedTypeMap.get(dt.getName());
|
|
||||||
if (resolvedType != null) {
|
|
||||||
if (!resolvedType.isEquivalent(dt)) {
|
|
||||||
if (dt instanceof TypeDef) {
|
|
||||||
DataType baseType = ((TypeDef) dt).getBaseDataType();
|
|
||||||
if ((resolvedType instanceof Composite || resolvedType instanceof Enum)
|
|
||||||
&& baseType.isEquivalent(resolvedType)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.writer.write(EOL);
|
|
||||||
Writer var10000 = this.writer;
|
|
||||||
String var10002 = dt.getPathName();
|
|
||||||
var10000.write(this
|
|
||||||
.comment("WARNING! conflicting data type names: " + var10002 + " - " + resolvedType.getPathName()));
|
|
||||||
this.writer.write(EOL);
|
|
||||||
this.writer.write(EOL);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.resolvedTypeMap.put(dt.getName(), dt);
|
|
||||||
++this.writerDepth;
|
|
||||||
if (dt.equals(DataType.DEFAULT)) {
|
|
||||||
this.writer.write("typedef unsigned char " + DataType.DEFAULT.getName() + ";");
|
|
||||||
this.writer.write(EOL);
|
|
||||||
this.writer.write(EOL);
|
|
||||||
} else if (dt instanceof Dynamic) {
|
|
||||||
this.writeDynamicBuiltIn((Dynamic) dt, monitor);
|
|
||||||
} else if (dt instanceof Structure) {
|
|
||||||
Structure struct = (Structure) dt;
|
|
||||||
this.writeCompositePreDeclaration(struct, monitor);
|
|
||||||
this.deferredCompositeDeclarations.add(struct);
|
|
||||||
} else if (dt instanceof Union) {
|
|
||||||
Union union = (Union) dt;
|
|
||||||
this.writeCompositePreDeclaration(union, monitor);
|
|
||||||
this.deferredCompositeDeclarations.add(union);
|
|
||||||
} else if (dt instanceof Enum) {
|
|
||||||
this.writeEnum((Enum) dt, monitor);
|
|
||||||
} else if (dt instanceof TypeDef) {
|
|
||||||
this.writeTypeDef((TypeDef) dt, monitor);
|
|
||||||
} else if (dt instanceof BuiltInDataType) {
|
|
||||||
this.writeBuiltIn((BuiltInDataType) dt, monitor);
|
|
||||||
} else if (!(dt instanceof BitFieldDataType)) {
|
|
||||||
this.writer.write(EOL);
|
|
||||||
this.writer.write(EOL);
|
|
||||||
this.writer.write(this.comment("Unable to write datatype. Type unrecognized: " + dt.getClass()));
|
|
||||||
this.writer.write(EOL);
|
|
||||||
this.writer.write(EOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.writerDepth == 1) {
|
|
||||||
this.writeDeferredDeclarations(monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
--this.writerDepth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.write(this.getBaseDataType(dt), monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeDeferredDeclarations(TaskMonitor monitor) throws IOException, CancelledException {
|
|
||||||
while (!this.deferredTypes.isEmpty()) {
|
|
||||||
DataType dt = (DataType) this.deferredTypeFIFO.removeFirst();
|
|
||||||
this.deferredTypes.remove(dt);
|
|
||||||
this.write(dt, monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.writeDeferredCompositeDeclarations(monitor);
|
if (dt instanceof FunctionDefinition) {
|
||||||
this.deferredCompositeDeclarations.clear();
|
return; // Skip function definitions
|
||||||
}
|
|
||||||
|
|
||||||
private DataType getBaseArrayTypedefType(DataType dt) {
|
|
||||||
while (true) {
|
|
||||||
if (dt != null) {
|
|
||||||
if (dt instanceof TypeDef) {
|
|
||||||
dt = ((TypeDef) dt).getBaseDataType();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dt instanceof Array) {
|
|
||||||
dt = ((Array) dt).getDataType();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean containsComposite(Composite container, Composite contained) {
|
|
||||||
DataTypeComponent[] var3 = container.getDefinedComponents();
|
|
||||||
int var4 = var3.length;
|
|
||||||
|
|
||||||
for (int var5 = 0; var5 < var4; ++var5) {
|
|
||||||
DataTypeComponent component = var3[var5];
|
|
||||||
DataType dt = this.getBaseArrayTypedefType(component.getDataType());
|
|
||||||
if (dt instanceof Composite && dt.getName().equals(contained.getName()) && dt.isEquivalent(contained)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (dt instanceof FactoryDataType) {
|
||||||
}
|
IllegalArgumentException iae = new IllegalArgumentException("Factory data types may not be written");
|
||||||
|
if (throwExceptionOnInvalidType) {
|
||||||
private void writeDeferredCompositeDeclarations(TaskMonitor monitor) throws IOException, CancelledException {
|
throw iae;
|
||||||
int cnt = this.deferredCompositeDeclarations.size();
|
|
||||||
if (cnt != 0) {
|
|
||||||
LinkedList<Composite> list = new LinkedList(this.deferredCompositeDeclarations);
|
|
||||||
if (list.size() > 1) {
|
|
||||||
int sortChange = 1;
|
|
||||||
|
|
||||||
while (sortChange != 0) {
|
|
||||||
sortChange = 0;
|
|
||||||
|
|
||||||
for (int i = cnt - 1; i > 0; --i) {
|
|
||||||
if (this.resortComposites(list, i)) {
|
|
||||||
++sortChange;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Msg.error(this, "Factory data types may not be written - type: " + dt);
|
||||||
Iterator var6 = list.iterator();
|
return;
|
||||||
|
|
||||||
while (var6.hasNext()) {
|
|
||||||
Composite composite = (Composite) var6.next();
|
|
||||||
this.writeCompositeBody(composite, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean resortComposites(List<Composite> list, int index) {
|
// Handle pointer/array types by just getting their base type for dependency checking
|
||||||
int listSize = list.size();
|
if (dt instanceof Pointer || dt instanceof Array || dt instanceof BitFieldDataType) {
|
||||||
if (listSize <= 0) {
|
// Don't auto-discover dependencies, just write the type as-is
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
Composite composite = (Composite) list.get(index);
|
dt = dt.clone(this.dtm);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < index; ++i) {
|
if (this.resolved.contains(dt)) {
|
||||||
Composite other = (Composite) list.get(i);
|
return; // Already written
|
||||||
if (this.containsComposite(other, composite)) {
|
}
|
||||||
list.remove(index);
|
|
||||||
list.add(i, composite);
|
this.resolved.add(dt);
|
||||||
composite = null;
|
DataType resolvedType = this.resolvedTypeMap.get(dt.getName());
|
||||||
return true;
|
if (resolvedType != null && !resolvedType.isEquivalent(dt)) {
|
||||||
}
|
// Handle name conflicts
|
||||||
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(this.comment("WARNING! conflicting data type names: " + dt.getPathName() + " - " + resolvedType.getPathName()));
|
||||||
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(EOL);
|
||||||
|
} else {
|
||||||
|
this.resolvedTypeMap.put(dt.getName(), dt);
|
||||||
|
|
||||||
|
if (dt.equals(DataType.DEFAULT)) {
|
||||||
|
this.writer.write("typedef unsigned char " + DataType.DEFAULT.getName() + ";");
|
||||||
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(EOL);
|
||||||
|
} else if (dt instanceof Dynamic) {
|
||||||
|
this.writeDynamicBuiltIn((Dynamic) dt, monitor);
|
||||||
|
} else if (dt instanceof Structure) {
|
||||||
|
this.writeStructure((Structure) dt, monitor);
|
||||||
|
} else if (dt instanceof Union) {
|
||||||
|
this.writeUnion((Union) dt, monitor);
|
||||||
|
} else if (dt instanceof Enum) {
|
||||||
|
this.writeEnum((Enum) dt, monitor);
|
||||||
|
} else if (dt instanceof TypeDef) {
|
||||||
|
this.writeTypeDef((TypeDef) dt, monitor);
|
||||||
|
} else if (dt instanceof BuiltInDataType) {
|
||||||
|
this.writeBuiltIn((BuiltInDataType) dt, monitor);
|
||||||
|
} else if (!(dt instanceof BitFieldDataType)) {
|
||||||
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(this.comment("Unable to write datatype. Type unrecognized: " + dt.getClass()));
|
||||||
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDynamicComponentString(Dynamic dynamicType, String fieldName, int length) {
|
private void writeStructure(Structure struct, TaskMonitor monitor) throws IOException, CancelledException {
|
||||||
if (dynamicType.canSpecifyLength()) {
|
// Write forward declaration first
|
||||||
DataType replacementBaseType = dynamicType.getReplacementBaseType();
|
this.writer.write("typedef struct " + struct.getDisplayName() + " " + struct.getDisplayName() + ", *P" + struct.getDisplayName() + ";");
|
||||||
if (replacementBaseType != null) {
|
this.writer.write(EOL);
|
||||||
replacementBaseType = replacementBaseType.clone(this.dtm);
|
this.writer.write(EOL);
|
||||||
int elementLen = replacementBaseType.getLength();
|
|
||||||
if (elementLen > 0) {
|
// Then write the body
|
||||||
int elementCnt = (length + elementLen - 1) / elementLen;
|
this.writeCompositeBody(struct, monitor);
|
||||||
return replacementBaseType.getDisplayName() + " " + fieldName + "[" + elementCnt + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
String var10001 = dynamicType.getClass().getSimpleName();
|
|
||||||
Msg.error(this,
|
|
||||||
var10001 + " returned bad replacementBaseType: " + replacementBaseType.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCompositePreDeclaration(Composite composite, TaskMonitor monitor)
|
private void writeUnion(Union union, TaskMonitor monitor) throws IOException, CancelledException {
|
||||||
throws IOException, CancelledException {
|
// Write forward declaration first
|
||||||
String compositeType = composite instanceof Structure ? "struct" : "union";
|
this.writer.write("typedef union " + union.getDisplayName() + " " + union.getDisplayName() + ", *P" + union.getDisplayName() + ";");
|
||||||
this.writer.write("typedef " + compositeType + " " + composite.getDisplayName() + " " + composite.getDisplayName()
|
|
||||||
+ ", *P" + composite.getDisplayName() + ";");
|
|
||||||
this.writer.write(EOL);
|
this.writer.write(EOL);
|
||||||
this.writer.write(EOL);
|
this.writer.write(EOL);
|
||||||
DataTypeComponent[] var4 = composite.getComponents();
|
|
||||||
int var5 = var4.length;
|
// Then write the body
|
||||||
|
this.writeCompositeBody(union, monitor);
|
||||||
for (int var6 = 0; var6 < var5; ++var6) {
|
|
||||||
DataTypeComponent component = var4[var6];
|
|
||||||
if (monitor.isCancelled()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataType componentType = component.getDataType();
|
|
||||||
this.deferWrite(componentType);
|
|
||||||
this.getTypeDeclaration((String) null, componentType, component.getLength(), true, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCompositeBody(Composite composite, TaskMonitor monitor) throws IOException, CancelledException {
|
private void writeCompositeBody(Composite composite, TaskMonitor monitor) throws IOException, CancelledException {
|
||||||
|
@ -436,13 +312,12 @@ public class DataTypeWriter {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String componentString = null;
|
String componentString = null;
|
||||||
if (dataType instanceof Dynamic) {
|
if (dataType instanceof Dynamic) {
|
||||||
componentString = this.getDynamicComponentString((Dynamic) dataType, name, instanceLength);
|
// Simplified dynamic handling - just use the display name
|
||||||
if (componentString != null) {
|
componentString = dataType.getDisplayName();
|
||||||
sb.append(componentString);
|
if (name.length() != 0) {
|
||||||
} else {
|
componentString = componentString + " " + name;
|
||||||
sb.append(this.comment("ignoring dynamic datatype inside composite: " + dataType.getDisplayName()));
|
|
||||||
sb.append(EOL);
|
|
||||||
}
|
}
|
||||||
|
sb.append(componentString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (componentString == null) {
|
if (componentString == null) {
|
||||||
|
@ -588,15 +463,13 @@ public class DataTypeWriter {
|
||||||
|
|
||||||
this.resolvedTypeMap.remove(typedefName);
|
this.resolvedTypeMap.remove(typedefName);
|
||||||
} finally {
|
} finally {
|
||||||
this.write(dataType, monitor);
|
// Removed auto-discovery - don't write the dataType automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseType instanceof Array && this.getBaseArrayTypedefType(baseType) instanceof Composite) {
|
// Removed deferred writing call - we only write what's explicitly passed
|
||||||
this.writeDeferredDeclarations(monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
String typedefString = this.getTypeDeclaration(typedefName, dataType, -1, true, monitor);
|
String typedefString = this.getTypeDeclaration(typedefName, dataType, -1, true, monitor);
|
||||||
this.writer.write("typedef " + typedefString + ";");
|
this.writer.write("typedef " + typedefString + ";");
|
||||||
|
@ -651,11 +524,11 @@ public class DataTypeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDynamicBuiltIn(Dynamic dt, TaskMonitor monitor) throws IOException, CancelledException {
|
private void writeDynamicBuiltIn(Dynamic dt, TaskMonitor monitor) throws IOException, CancelledException {
|
||||||
DataType baseDt = dt.getReplacementBaseType();
|
// Simplified - don't auto-discover replacement types
|
||||||
if (baseDt != null) {
|
// Just write a comment about the dynamic type
|
||||||
this.write(baseDt, monitor);
|
this.writer.write(this.comment("Dynamic type: " + dt.getDisplayName()));
|
||||||
}
|
this.writer.write(EOL);
|
||||||
|
this.writer.write(EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeBuiltIn(BuiltInDataType dt, TaskMonitor monitor) throws IOException {
|
private void writeBuiltIn(BuiltInDataType dt, TaskMonitor monitor) throws IOException {
|
||||||
|
|
|
@ -76,14 +76,14 @@ public class TypeDumper {
|
||||||
DataType dt = it.next();
|
DataType dt = it.next();
|
||||||
if (typeBlacklist.contains(dt.getDisplayName()))
|
if (typeBlacklist.contains(dt.getDisplayName()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CategoryPath catPath = dt.getCategoryPath();
|
CategoryPath catPath = dt.getCategoryPath();
|
||||||
if (catPath.getPathElements().length > 0 && categoryPathBlacklist.contains(catPath.getPathElements()[0]))
|
if (catPath.getPathElements().length > 0 && categoryPathBlacklist.contains(catPath.getPathElements()[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// script.println("Type: " + dt.getDisplayName() + " - CatPath: " + dt.getCategoryPath());
|
|
||||||
|
|
||||||
// if (dt.getName().equals("ImageBaseOffset32"))
|
// if (dt.getName().equals("ImageBaseOffset32"))
|
||||||
// throw new Exception("Found: " + dt.getDisplayName() + " - " + catPath.getPathElements()[0] + " - " + dt.getClass().getSimpleName());
|
// throw new Exception("Found: " + dt.getDisplayName() + " - " +
|
||||||
|
// catPath.getPathElements()[0] + " - " + dt.getClass().getSimpleName());
|
||||||
|
|
||||||
if (dt instanceof Structure || dt instanceof TypeDef || dt instanceof EnumDataType) {
|
if (dt instanceof Structure || dt instanceof TypeDef || dt instanceof EnumDataType) {
|
||||||
// script.println("Adding: " + dt.getDisplayName() + " - " +
|
// script.println("Adding: " + dt.getDisplayName() + " - " +
|
||||||
|
@ -92,6 +92,12 @@ public class TypeDumper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String s = "";
|
||||||
|
for (DataType dataType : filteredTypes) {
|
||||||
|
s += dataType.getDisplayName() + ", ";
|
||||||
|
}
|
||||||
|
script.println(s);
|
||||||
|
|
||||||
try (PrintWriter writer = new PrintWriter(new File(RemanConfig.INSTANCE.outputDir, "gh_types.h"),
|
try (PrintWriter writer = new PrintWriter(new File(RemanConfig.INSTANCE.outputDir, "gh_types.h"),
|
||||||
"UTF-8")) {
|
"UTF-8")) {
|
||||||
Utils.headerGuardPre(writer, "STRUCTS");
|
Utils.headerGuardPre(writer, "STRUCTS");
|
||||||
|
|
Loading…
Reference in New Issue