Changeset 501
- Timestamp:
- 09/08/08 07:21:06 (5 years ago)
- Location:
- branches/cail-digicdv/hv30_analysis/scripts
- Files:
-
- 3 added
- 6 edited
-
_init_sections.idc (modified) (3 diffs)
-
_todo.idc (modified) (1 diff)
-
dump-xrefs.idc (modified) (15 diffs)
-
scan-fuctions.idc (modified) (3 diffs)
-
scan-func_tables.idc (modified) (2 diffs)
-
scan-lib.idc (modified) (2 diffs)
-
scan-unicode-pascal.idc (added)
-
search-language-resources.idc (added)
-
search-range.idc (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/cail-digicdv/hv30_analysis/scripts/_init_sections.idc
r492 r501 8 8 static main() 9 9 { 10 memcpy(0x40294, 0x4073FB8, 0x1248); 11 /* 10 12 createSegments(); 11 13 … … 15 17 16 18 makeNames1(); 19 //*/ 17 20 } 18 21 … … 59 62 // small RAM segment 60 63 memcpy(0x419C8, 0x002DB0E4, 0xE4); 64 65 // init_copy_4073FB8_40294_size1248 66 memcpy(0x40294, 0x4073FB8, 0x1248); 67 61 68 } 62 69 -
branches/cail-digicdv/hv30_analysis/scripts/_todo.idc
r492 r501 2 2 3 3 taskCreate_sys xrefs ? 4 5 search copy loops ??? 6 7 8 init_main_data_copy_ntsc refs?? 9 10 11 17 12 81 13 14 15 16 Order: 17 18 19 _init_sections.idc 20 _initial_names.idc 21 22 shell_register.idc 23 24 scan-func_tables.idc 25 // scan-refs.idc 26 // scan-strings.idc 27 search-language-resources.idc 28 29 // call it multiple times 30 scan-fuctions.idc -
branches/cail-digicdv/hv30_analysis/scripts/dump-xrefs.idc
r492 r501 3 3 4 4 #define TRACE 0 5 6 // directory prefix 5 7 #define FPREFIX "graphs/" 6 8 7 #define SHOW_UNK_DATA 0 9 // enable unk_ references 10 #define SHOW_UNK_DATA 1 11 12 // enable showing disassembly line 13 #define SHOW_DATA_DISASM 0 14 15 // Number of nodes limitation 16 #define NODES_LIMIT 0 17 18 static is_direction_down() 19 { 20 auto dir; 21 22 if (GetArrayId("downIdArray") == -1) return 0; 23 else return 1; 24 } 25 26 #define ZERO_DEPTH 1000 27 8 28 9 29 // Touchgraph todo: … … 17 37 */ 18 38 19 static searchTask(start, arr, calleeHash, edgeHash, depth )39 static searchTask(start, arr, calleeHash, edgeHash, depth, recurse) 20 40 { 21 41 auto x,y, fname, fend; … … 23 43 auto type; 24 44 auto name; 25 45 26 46 x = GetFunctionAttr(start, FUNCATTR_START); 27 47 if (x == -1) x = start; 28 48 29 49 fend = GetFunctionAttr(start, FUNCATTR_END); 50 if (fend == -1) fend = start+4; 30 51 31 52 fname = Name(x); //TODO - no-function code refs will be ignored! … … 39 60 } 40 61 41 if (TRACE) Message( "*** " +atoa(start) + " " + atoa(fend) + " - "+ fname + "\n");62 if (TRACE) Message(atoa(start) + " " + atoa(fend) + " - "+ fname + "\n"); 42 63 43 64 SetHashLong(arr, fname, x); 44 if (depth == 1000) SetHashLong(calleeHash, fname, depth); 65 if (depth == ZERO_DEPTH) SetHashLong(calleeHash, fname, depth); 66 67 if (recurse == 0) return; 45 68 46 69 refCount = 1; 47 48 if (depth >= 1000) { 49 for(; x < fend; x = x+2) 70 71 for(; x < fend; x = x+2) 72 { 73 74 if (is_direction_down() == 1) 50 75 { 51 52 76 for( y=Rfirst0(x); y != BADADDR; y=Rnext0(x,y) ) 53 77 { … … 69 93 SetHashLong(edgeHash, fname+"---"+name, 1); 70 94 71 searchTask(y, arr, calleeHash, edgeHash, depth+1 );95 searchTask(y, arr, calleeHash, edgeHash, depth+1, TRUE); 72 96 refCount = refCount + 1; 73 97 } 98 } 99 100 // if (is_direction_down() == 1) 101 { 74 102 for(y = Dfirst(x); y != BADADDR; y=Dnext(x,y) ) 75 103 { … … 87 115 SetHashLong(edgeHash, fname+"---"+name, 1); 88 116 89 searchTask(y, arr, calleeHash, edgeHash, depth+1); 117 searchTask(y, arr, calleeHash, edgeHash, depth+1, (is_direction_down() == 1) ); 118 90 119 refCount = refCount + 1; 91 120 } 92 121 } 93 122 } 94 /* 95 if ( depth <= 1000)123 124 if (is_direction_down() == 0) 96 125 { 97 126 x = GetFunctionAttr(start, FUNCATTR_START); 127 if (x == -1) x = start; 98 128 99 129 if (TRACE) Message("* UP " + atoa(start) + " " + atoa(fend) + " - "+ fname + "\n"); … … 114 144 SetHashLong(calleeHash, name, depth-1); 115 145 SetHashLong(edgeHash, name+"---"+fname, 1); 116 searchTask(y, arr, calleeHash, edgeHash, depth-1 );146 searchTask(y, arr, calleeHash, edgeHash, depth-1, TRUE); 117 147 refCount = refCount + 1; 118 148 } … … 121 151 type = XrefType(); 122 152 name = GetFunctionName(y); 123 name = Name(y);124 if (name == 0) {153 if (name == 0) name = Name(y); 154 if (name == 0) { 125 155 continue; 126 156 name = atoa(y) + " " + GetDisasm(y); … … 128 158 SetHashLong(calleeHash, name, depth-1); 129 159 SetHashLong(edgeHash, name+"---"+fname, 1); 130 searchTask(y, arr, calleeHash, edgeHash, depth-1 );160 searchTask(y, arr, calleeHash, edgeHash, depth-1, TRUE); 131 161 refCount = refCount + 1; 132 162 } 133 163 } 134 */ 164 135 165 } 136 166 … … 142 172 auto length, color, fsize, shape, x, y, label, hint, visible; 143 173 auto flags, type, depth; 144 145 fname = GetFunctionName(a); 146 147 ea = GetFunctionAttr(a, FUNCATTR_START); 148 149 DeleteArray( GetArrayId("visitedHash") ); 150 DeleteArray( GetArrayId("calleeHash") ); 151 DeleteArray( GetArrayId("edgeHash") ); 152 153 visitedHash = CreateArray("visitedHash"); 154 calleeHash = CreateArray("calleeHash"); 155 edgeHash = CreateArray("edgeHash"); 156 157 searchTask(ea, visitedHash, calleeHash, edgeHash, 1000); 158 159 f = fopen(FPREFIX + "xrefs-"+fname+".vna", "w"); 174 auto node_addr; 175 auto nodes_num; 176 177 ea = GetFunctionAttr(a, FUNCATTR_START); 178 if (ea == -1) ea = a; 179 180 if (is_direction_down() == 1) 181 fname = "xrefs-" + Name(ea); 182 else 183 fname = "uprefs-" + Name(ea); 184 185 DeleteArray( GetArrayId("visitedHash") ); 186 DeleteArray( GetArrayId("calleeHash") ); 187 DeleteArray( GetArrayId("edgeHash") ); 188 189 visitedHash = CreateArray("visitedHash"); 190 calleeHash = CreateArray("calleeHash"); 191 edgeHash = CreateArray("edgeHash"); 192 193 searchTask(ea, visitedHash, calleeHash, edgeHash, ZERO_DEPTH, TRUE); 194 195 196 f = fopen(FPREFIX + fname+".vna", "w"); 160 197 161 198 fprintf(f, "*Node data\n"); … … 223 260 224 261 225 f = fopen(FPREFIX + "xrefs-"+fname+".xml", "w");262 f = fopen(FPREFIX + fname+".xml", "w"); 226 263 227 264 fprintf(f, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); 228 265 fprintf(f, "<TOUCHGRAPH_LB version='1.20'><NODESET>\n"); 229 266 267 nodes_num = 0; 230 268 for (t = GetFirstHashKey(calleeHash); t != 0; t = GetNextHashKey(calleeHash, t)) 231 269 { … … 233 271 shape = 2; 234 272 label = t; 235 hint = form("0x%x %s", GetHashLong(visitedHash, t), ""); 273 node_addr = GetHashLong(visitedHash, t); 274 hint = form("<b>0x%x</b> %s", node_addr, ""); 236 275 visible = "true"; 237 depth = GetHashLong(calleeHash, t)-1000; 238 239 //if (depth == 0) visible = "true"; 240 241 if (isCode(GetFlags(GetHashLong(visitedHash, t)))) 242 { 243 fsize = 20 - depth*2; 244 if (fsize < 10) fsize = 10; 276 depth = GetHashLong(calleeHash, t) - ZERO_DEPTH; 277 278 nodes_num = nodes_num+1; 279 //if (NODES_LIMIT != 0 && nodes_num > NODES_LIMIT) break; 280 281 if (isCode(GetFlags(node_addr))) 282 { 283 if (is_direction_down()) 284 fsize = 20 - depth*2; 285 else 286 fsize = 20 + depth*2; 287 288 if (fsize < 9) fsize = 9; 245 289 if (fsize > 22) fsize = 22; 246 if (!hasUserName(GetFlags(GetHashLong(visitedHash, t)))){ 290 if (!hasUserName(GetFlags(node_addr))) 291 { 247 292 color = 0xEE2020; 248 293 } 249 294 }else 250 if (isASCII(GetFlags( GetHashLong(visitedHash, t))))295 if (isASCII(GetFlags(node_addr))) 251 296 { 252 297 color = 0x6060C0; 253 298 fsize = 10; 254 299 shape = 1; 255 label = getString(GetHashLong(visitedHash, t)); 256 label = replace(label, "&", "@"); 257 label = replace(label, "'", "'"); 258 label = replace(label, "<", "<"); 259 label = replace(label, ">", ">"); 300 label = GetString(node_addr, -1, GetStringType(node_addr)); 260 301 label = replace(label, "\n", ""); 261 302 label = replace(label, "\r", ""); 262 depth = - 1;303 depth = -ZERO_DEPTH; 263 304 }else 264 305 //if (isData(GetFlags(GetHashLong(visitedHash, t)))) … … 267 308 fsize = 10; 268 309 shape = 1; 269 if (!hasUserName(GetFlags(GetHashLong(visitedHash, t)))){ 310 //if (!hasUserName(GetFlags(node_addr))) { 311 if (-1 != strstr(t, "unk_")) { 270 312 color = 0x70A070; 271 } 272 label = label + ": " + GetDisasm(GetHashLong(visitedHash, t)); 273 depth = -1; 274 if (SHOW_UNK_DATA == 0) continue; 275 } 276 x = 10; 313 if (SHOW_UNK_DATA == 0) continue; 314 } 315 if (SHOW_DATA_DISASM) { 316 label = label + ": " + GetDisasm(node_addr); 317 } 318 depth = -ZERO_DEPTH; 319 } 320 hint = label + ": " + GetDisasm(node_addr) + "<br><br>" + hint; 321 322 x = 0; 277 323 y = 10; 324 if (depth == 0) 325 { 326 x = 100; 327 y = 100; 328 } 278 329 279 330 fprintf(f, "<NODE nodeID='AutoID %s'>\n", t); 280 331 fprintf(f, " <NODE_LOCATION x='%d' y='%d' visible='%s'/>\n", x, y, visible); 281 fprintf(f, " <NODE_LABEL label='%s' shape='%d' backColor='%x' textColor='FFFFFF' fontSize='%d'/>\n", label, shape, color, fsize);282 if (depth != - 1){332 fprintf(f, " <NODE_LABEL label='%s' shape='%d' backColor='%x' textColor='FFFFFF' fontSize='%d'/>\n", xml_escape(label), shape, color, fsize); 333 if (depth != -ZERO_DEPTH){ 283 334 fprintf(f, " <NODE_BEHAVIOUR logic='com.touchgraph.graphlayout.mods.ApproachYbyWeight' weight='%d'/>\n", depth); 284 335 } 285 fprintf(f, " <NODE_HINT hint='%s' width='200' height='-1' isHTML='true'/>\n", hint);336 fprintf(f, " <NODE_HINT hint='%s' width='200' height='-1' isHTML='true'/>\n", xml_escape(hint)); 286 337 fprintf(f, "</NODE>\n"); 287 338 } … … 312 363 length = 30; 313 364 color = 0xC0E0C0; 314 if (SHOW_UNK_DATA == 0) continue;315 365 } 316 366 //length = length * 10; … … 325 375 fclose(f); 326 376 377 return fname; 378 379 } 380 381 static xml_escape(label) 382 { 383 label = replace(label, "&", "@"); 384 label = replace(label, "'", "'"); 385 label = replace(label, "<", "<"); 386 label = replace(label, ">", ">"); 387 388 return label; 327 389 } 328 390 329 391 static main() 330 392 { 331 332 ResolveTask(ScreenEA()); 333 334 Message("Done\n"); 393 auto fname; 394 395 auto answer; 396 397 DeleteArray( GetArrayId("downIdArray") ); 398 answer = AskYN(-1, "YES - xrefs down from\nNO - xrefs up to\n"); 399 if (answer == -1) 400 return; 401 if (answer == 1) 402 CreateArray("downIdArray"); 403 404 fname = ResolveTask(ScreenEA()); 405 406 Message("Done: %s\n", fname); 335 407 } -
branches/cail-digicdv/hv30_analysis/scripts/scan-fuctions.idc
r477 r501 13 13 static main() 14 14 { 15 auto sb, se, a, c, w, d ;15 auto sb, se, a, c, w, d, y; 16 16 auto lr, push; 17 17 … … 31 31 lr = 1; 32 32 33 if ( d == 0x9F8C ) 34 lr = 1; 35 33 36 if (d == 0x1781) 37 lr = 1; 38 if (d == 0x1708) 34 39 lr = 1; 35 40 … … 39 44 */ 40 45 41 // Message("code:%x, %x\n", (d&0xFF00) == 0x4f00, (d&0x00FF > 0x80));42 // Message("lr:%x, push:%x\n",lr, push);43 44 46 if (!lr && !push) continue; 45 47 46 if (lr && isUnknown(GetFlags(a))) 47 MakeCode(a); 48 if (!isUnknown(GetFlags(a))) continue; 48 49 49 //MakeFunction(a, BADADDR); 50 if (RfirstB0(a) == BADADDR && DfirstB(a) == BADADDR) continue; 51 52 for(y = DfirstB(a); y != BADADDR; y=DnextB(a,y) ) 53 { 54 Message("%08x: %s\n", y, GetDisasm(y)); 55 } 56 57 // Message("lr:%x, push:%x\n",lr, push); 58 59 MakeFunction(a, BADADDR); 60 61 // 50 62 /* else if (isUnknown(GetFlags(a))) 51 63 { -
branches/cail-digicdv/hv30_analysis/scripts/scan-func_tables.idc
r477 r501 18 18 static isIn(addr) 19 19 { 20 return addr > CODE_START && addr < CODE_END;20 return (addr > CODE_START && addr < CODE_END) || addr == 0; 21 21 } 22 23 22 24 23 25 static main() 24 26 { 25 auto sb, se, a, c, w, d; 26 sb = CODE_START; 27 se = CODE_END; 27 28 search_table(CODE_START, CODE_END); 29 30 // search_table(0x40294, 0x40294 + 0x1248); 31 32 } 33 34 35 static search_table(sb, se) 36 { 37 auto a, c, w, d; 28 38 29 39 c = 0; … … 32 42 if ( isIn(Dword(a+0)) 33 43 && isIn(Dword(a+4)) 34 && isIn(Dword(a+8)) 44 // && isIn(Dword(a+8)) 45 && isUnknown(GetFlags(a+0)) 35 46 ) 36 47 { 37 Message(" Table: %x\n", a);48 Message("%x : item\n", a); 38 49 //MakeUnknown(a, 4, DOUNK_EXPAND); 39 c = c+ 3;50 c = c+1; 40 51 41 52 MakeDword(a+0); 42 53 MakeDword(a+4); 43 54 MakeDword(a+8); 44 a = a + 8;55 //a = a + 4; 45 56 } 46 57 -
branches/cail-digicdv/hv30_analysis/scripts/scan-lib.idc
r477 r501 4 4 #define ROM_END (0xBFA00000+0x800000) 5 5 6 #define TRUE 1 7 #define FALSE 0 6 8 7 9 static getString(addr) … … 26 28 27 29 30 static GetStringPascal(addr) 31 { 32 auto origa, stringRead, length; 33 34 stringRead = ""; 35 length = Word(addr); 36 addr = addr+2; 37 38 if (length < 2) return 0; 39 if (length > 50) return 0; 40 41 for(; length > 0; length = length-1) 42 { 43 auto c; 44 c = Word(addr); 45 if (c < 0x2D || c > 0x7F) c = '_'; 46 47 stringRead = form("%s%c", stringRead, c); 48 addr = addr + 2; 49 } 50 51 return stringRead; 52 } 28 53 29 54
Note: See TracChangeset
for help on using the changeset viewer.