From b25f320a4cbf26d2b28d9f74ff7c495516a710d0 Mon Sep 17 00:00:00 2001
From: notaz <notasas@gmail.com>
Date: Sat, 8 Feb 2014 03:18:35 +0200
Subject: [PATCH] plugin: more renaming

---
 plugin/saveasm.cpp | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/plugin/saveasm.cpp b/plugin/saveasm.cpp
index efe8e9d..3622cc8 100644
--- a/plugin/saveasm.cpp
+++ b/plugin/saveasm.cpp
@@ -333,9 +333,26 @@ static void idaapi run(int /*arg*/)
       continue;
     }
 
-    if (is_name_reserved(name)) {
+    // rename vars with '?@' (funcs are ok)
+    int change_qat = 0;
+    ea_flags = get_flags_novalue(ea);
+    if (!isCode(ea_flags) && strpbrk(name, "?@"))
+      change_qat = 1;
+
+    if (change_qat || is_name_reserved(name)) {
       msg("%x: renaming name '%s'\n", ea, name);
       qsnprintf(buf, sizeof(buf), "%s_g", name);
+
+      if (change_qat) {
+        for (p = buf; *p != 0; p++) {
+          if (*p == '?' || *p == '@') {
+            qsnprintf(buf2, sizeof(buf2), "%02x", (unsigned char)*p);
+            memmove(p + 1, p, strlen(p) + 1);
+            memcpy(p, buf2, 2);
+          }
+        }
+      }
+
       set_name(ea, buf);
     }
   }
-- 
2.39.5