-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2954-Fix-xml-import.patch
97 lines (88 loc) · 4.04 KB
/
2954-Fix-xml-import.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yevhenii Havrylko <[email protected]>
Date: Mon, 19 Apr 2021 01:36:25 +0300
Subject: [PATCH] 2954: Fix xml import
---
.../ghidra/app/util/cparser/C/CParserUtils.java | 17 ++++++++++++++++-
.../ghidra/app/util/xml/FunctionsXmlMgr.java | 11 ++++++++++-
gradle/support/ip.gradle | 1 +
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java
index 7389be2cd8..8d7ff30356 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/C/CParserUtils.java
@@ -36,6 +36,7 @@ import ghidra.util.*;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
+import org.apache.commons.lang3.StringUtils;
public class CParserUtils {
@@ -201,6 +202,18 @@ public class CParserUtils {
return null;
}
+ GenericCallingConvention convention = null;
+
+ for (GenericCallingConvention conv : GenericCallingConvention.values()) {
+ if (conv == GenericCallingConvention.unknown) continue;
+
+ if (StringUtils.endsWith(signatureParts[0], " " + conv)) {
+ convention = conv;
+ signatureParts[0] = StringUtils.removeEnd(signatureParts[0], " " + conv);
+ break;
+ }
+ }
+
String replacedText =
signatureParts[0] + " " + getTempName(signatureParts[1].length()) + signatureParts[2];
@@ -217,7 +230,9 @@ public class CParserUtils {
// put back the old signature name
dt.setName(signatureParts[1]);
- return (FunctionDefinitionDataType) dt;
+ FunctionDefinitionDataType fdt = (FunctionDefinitionDataType) dt;
+ if (convention != null) fdt.setGenericCallingConvention(convention);
+ return fdt;
}
catch (InvalidNameException | DuplicateNameException e) {
// can't happen since we are calling setName() with the value that was
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/FunctionsXmlMgr.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/FunctionsXmlMgr.java
index d64ec1df3d..f4a4eeead1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/FunctionsXmlMgr.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/FunctionsXmlMgr.java
@@ -153,6 +153,11 @@ class FunctionsXmlMgr {
Symbol symbol = func.getSymbol();
Namespace namespace = NamespaceUtils.getFunctionNamespaceAt(program,
namespacePath, entryPoint);
+ if (namespace == null && namespacePath != null) {
+ namespace = NamespaceUtils.createNamespaceHierarchy(
+ namespacePath.getPath(), program.getGlobalNamespace(),
+ program,SourceType.IMPORTED);
+ }
if (namespace == null) {
namespace = program.getGlobalNamespace();
}
@@ -208,7 +213,11 @@ class FunctionsXmlMgr {
}
}
else {
- tryToParseTypeInfoComment(monitor, func, typeInfoComment);
+ tryToParseTypeInfoComment(monitor, func, typeInfoComment);
+
+ if (func.getSignature().getCallingConventionName().equals("__thiscall") && func.getParentNamespace() != null) {
+ NamespaceUtils.convertNamespaceToClass(func.getParentNamespace());
+ }
}
addLocalVars(func, stackVariables, overwriteConflicts);
diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradle
index 1dfe1d8a39..83f119f35a 100644
--- a/gradle/support/ip.gradle
+++ b/gradle/support/ip.gradle
@@ -136,6 +136,7 @@ def Map<String, List<String>> getIpForModule(Project p) {
exclude "**/.vs/**"
exclude "**/*.vcxproj.user"
exclude "**/.vscode/**"
+ exclude "**/*.iml" // Intellij project files
}
tree.each { file ->
String ip = getIp(p.projectDir, file)
--
2.45.1