|
RomRaider
Documentation
Community
Developers
|
| Author |
Message |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sat Dec 12, 2009 6:56 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
merchgod wrote: it is just a label to data of an unknown size (to IDA). You can rename it as you please Ah, thanks! I'm amazed at how much different 32bit addressing and architecture is from 16bit... I will get it though! I am determined! Andy
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 2:07 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
Does this look normal to anyone? I am a little confused with the breaking up of the code. When I select graph mode, IDA shows this all as one sub routine, which doesn't seem to be the case... Also, does the bar up top look like I have it opened correctly? Thanks guys! This is an 04 STi ROM Attachment: 32bithelp.JPG Andy
You do not have the required permissions to view the files attached to this post.
|
|
| Top |
|
 |
|
fujiillin
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 2:22 am |
|
 |
| Experienced |
 |
Joined: Wed Feb 13, 2008 3:00 am Posts: 153
|
|
I'm not too familiar with the rom, but it looks like you have most of it. What method did you use?
IDA will display loc_26334 as part of the first subroutine. I opened this rom, and the second subroutine in the picture is not part of nor referenced by the first, and it showed up as a separate subroutine in graph mode.
_________________ 06 Wrx Wagon 2.3 longrod in the works
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 2:27 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
|
Thanks! I was misreading it as far as the second part goes. I am glad to hear that it looks like it's opened up ok though, I was pretty nervous about all the labeling I have done being wrong haha!
I'm still reading the manuals for the processors and I am starting to understand a bit, but I think I am missing a manual or my eyes aren't working as they should. I can't seem to figure out how an address is referenced. For instance if we used turbo dynamics proportional in the 04 STi the table address would be 0x567C4, but it doesn't seem to be called that way in any of the sub routines. In the 16bit ROMs there was always an offset, like 67C4, Z where Z = 5. Is there a similar case here?
Andy
|
|
| Top |
|
 |
|
fujiillin
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 2:53 am |
|
 |
| Experienced |
 |
Joined: Wed Feb 13, 2008 3:00 am Posts: 153
|
Not sure about the 16bit roms, but in 32bit it goes like this: Looking at turbo dynamics proportional, after address 0x1383E, the subroutine loads 0x537B4 into r4 and immediately jumps to sub_208C. Code: ROM:0001383E loc_1383E: ; CODE XREF: sub_136C0+174j ROM:0001383E mov.l @(h'50,pc), r12 ; [00013890] = sub_208C ROM:00013840 mov.l @(h'50,pc), r4 ; [00013894] = dword_537B4 ROM:00013842 jsr @r12 ; sub_208C ROM:00013844 fmov fr14, fr4
Data tables in rom (addresses from the definitions): Code: ROM:000567A0 TurboDynamicsProportional_YAxis:.data.l h'C3160000, h'C2480000, h'C1A00000, h'C1200000 ROM:000567A0 .data.l 0 ROM:000567B4 .data.l h'41200000, h'41A00000, h'42480000, h'43160000 ROM:000567C4 TurboDynamicsProportional:.data.l h'2F003100, h'314031B3, h'3200324D, h'32C03300 ROM:000567C4 .data.l h'3500FFFF
Looking at 0x537B4: Code: ROM:000537B4 dword_537B4: .data.l h'90800, h'567A0, h'567C4, h'3B800000, h'C2480000 ROM:000537B4 ; DATA XREF: sub_136C0:off_13894o
This is the "lookup table" for the TD_proportional table. The first longword and last two longwords contain data about the size of the table, type of data, and conversions. The second long is the TD_prop axis, and the third is the TD_prop data. Sub 208C is passed the LUT in r4, and the current axis value in fr4, and returns the interpolated value to fr0. This sub, as far as i know, is used for all the 2D map pulls, and there is another similar routine used for 3D map pulls. So, to find the lut, go to the search drop down box and select binary pattern, then type the data table address (from the definitions), and a red dot will show on the big bar, clicking it will take you to the LUT. Since most of the LUTs are right next to each other, if you have all the data tables named (I suggest using the XMLtoIDC app to to this automatically, before you crack open the rom), all you need to do is highlight the third longword in the LUTs and the name of the table should show up, then you can name the LUT. There is more information in this forum about the other values in the lut, I don't recall them offhand. Notice how the axis data is stored in longwords, while the data itself is in words, this info would be in the LUT. This is from Freon's SD code, VEdef is 3d, dyndef is 2d: Code: ! ******************** MAPS BELOW ********************
VEdef: ! volumetric efficiency map, manifold pressure col, rpm row .word 13 ! 12 columns .word 18 ! 18 rows .long VEcol .long VErow .long VEdata .long 0x8000000 ! 16bit data .float 4.57763672e-5 ! gradient for 16bit to float conv ! 1.5/32768 (0-1.50 range, 16bit precision) .float 0 ! offset for 16bit to float conv (+ 0)
*****************************************************************
dyndef: ! dynamics table (enrich/impoverish fuel on Delta MAP) .word 7 ! 7 elements .word 0x800 ! 16 bit data .long dyncol .long dyndata .long 0x8000000 ! 16bit data .float 6.1037e-5 ! 2.00/32767 (0-2.00 range, 16bit precision) .float 0 ! + 0 If you aren't familiar with UINT16 or single precision IEEE-754 floating point values, it will help to learn about them.
_________________ 06 Wrx Wagon 2.3 longrod in the works
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 4:20 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
Wow! Thank you so much! That was very informative! Were your examples from an 04 STi? Because my screen looks much different... I was able to follow along with what you were saying in my head but not in the ROM. Code: ROM:0001383E loc_1383E: ; CODE XREF: Turbo_Dynamics+174j ROM:0001383E mov.l @(h'50,pc), r12 ; [00013890] = sub_208C ROM:00013840 mov.l @(h'50,pc), r4 ; [00013894] = unk_537B4 ROM:00013842 jsr @r12 ; sub_208C ROM:00013844 fmov fr14, fr4
Code: ROM:000567A0 .data.b h'C3 ; + ROM:000567A1 .data.b h'16 ROM:000567A2 .data.b 0 ROM:000567A3 .data.b 0 ROM:000567A4 .data.b h'C2 ; - ROM:000567A5 .data.b h'48 ; H ROM:000567A6 .data.b 0 ROM:000567A7 .data.b 0 ROM:000567A8 .data.b h'C1 ; - ROM:000567A9 .data.b h'A0 ; á ROM:000567AA .data.b 0 ROM:000567AB .data.b 0 ROM:000567AC .data.b h'C1 ; - ROM:000567AD .data.b h'20 ROM:000567AE .data.b 0 ROM:000567AF .data.b 0 ROM:000567B0 .data.b 0 ROM:000567B1 .data.b 0 ROM:000567B2 .data.b 0 ROM:000567B3 .data.b 0 ROM:000567B4 .data.b h'41 ; A ROM:000567B5 .data.b h'20 ROM:000567B6 .data.b 0 ROM:000567B7 .data.b 0 ROM:000567B8 .data.b h'41 ; A ROM:000567B9 .data.b h'A0 ; á ROM:000567BA .data.b 0 ROM:000567BB .data.b 0 ROM:000567BC .data.b h'42 ; B ROM:000567BD .data.b h'48 ; H ROM:000567BE .data.b 0 ROM:000567BF .data.b 0 ROM:000567C0 .data.b h'43 ; C ROM:000567C1 .data.b h'16 ROM:000567C2 .data.b 0 ROM:000567C3 .data.b 0 ROM:000567C4 .data.b h'2F ; / ; TD Prop
Code: ROM:000537B4 unk_537B4: .data.b 0 ; DATA XREF: Turbo_Dynamics:off_13894o
Also, I have tried the xmltoidc thing but it prompts me to enter text or something(I can't remember offhand) when I try to load the idc file, any idea what I am supposed to put there? Andy
|
|
| Top |
|
 |
|
fujiillin
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 6:39 am |
|
 |
| Experienced |
 |
Joined: Wed Feb 13, 2008 3:00 am Posts: 153
|
|
My examples were taken from the A2ZJ710J Rom, not sure which you're using, perhaps there is another revision.
For XMLtoIDC, select "IDC file" from IDA's file menu, pick the file, OK. Then it pops up a small window. From there, you go back to File->IDC Command, and enter DefineA2ZJ710J(), or whichever rom you're using.
Also double check that your IDC file properly inherited the map definitions, with some rom revisions there is a problem and you only get logger definitions, ie: A8DH201X vs A8DH200X, in the definitions, there are no table defs for the 201X, just a 'inherits 200X' statement. To correct the issue, I just make IDCs for both roms and copy the map names over. If your IDC shows any map definitions at all, you're good to go.
_________________ 06 Wrx Wagon 2.3 longrod in the works
Last edited by fujiillin on Sun Dec 27, 2009 6:43 am, edited 1 time in total.
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 6:43 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
Ok, I will give that a try, thanks! Did you see the difference in our examples? It seems like your numbers are all put together to for hex numbers, where mine are still in line by line format, do you know what I did wrong?  Thanks so much for all of your help so far! Andy
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 6:47 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
"can't rename byte as 'whatever' because this byte can't have a name(it is a tail byte)" is the only output I get with the xmltoidc program. EDIT: I take that back, it did work! Just not for 3 bytes, oh well. THANK YOU!!! I am using the same ROM as you. Andy
|
|
| Top |
|
 |
|
fujiillin
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 6:50 am |
|
 |
| Experienced |
 |
Joined: Wed Feb 13, 2008 3:00 am Posts: 153
|
|
Yep, it looks like you're using the same rom, but the analysis didn't bunch those data.b bytes into data.l longwords. It's really hit or miss and depends how you open the rom. I used the VBR method on this one, and sometimes I have data tables that are arranged in bytes not words or longwords. I think it may have to do with the order in which you name them. For example, naming the address before opening/analyzing the rom may result in a different data size than naming after analysis.
In any case, the 'D' key changes the data size. Note that you'll need to do this at a longword boundary, ie: in this case, addresses ending in 0, 4, 8, and C.
_________________ 06 Wrx Wagon 2.3 longrod in the works
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 6:55 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
fujiillin wrote: Yep, it looks like you're using the same rom, but the analysis didn't bunch those data.b bytes into data.l longwords. It's really hit or miss and depends how you open the rom. I used the VBR method on this one, and sometimes I have data tables that are arranged in bytes not words or longwords. I think it may have to do with the order in which you name them. For example, naming the address before opening/analyzing the rom may result in a different data size than naming after analysis.
In any case, the 'D' key changes the data size. Note that you'll need to do this at a longword boundary, ie: in this case, addresses ending in 0, 4, 8, and C. Oh man, this program is really confusing me! I appreciate your patience with me! EDIT: I got it! There was some box that needed to be checked about combining data stuff in the final pass. Stupid box. Andy
|
|
| Top |
|
 |
|
elevenpoint7five
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 9:09 am |
|
 |
| Experienced |
Joined: Mon Aug 18, 2008 11:15 pm Posts: 316 Location: Chicago, Illinois
|
Things are coming along pretty decent now! Thanks again for all your help tonight! Could you tell me if this looks right? I have NO idea what it means, line 56768: Code: ROM:00056766 .data.b h'80 ; Ç ROM:00056767 .data.b h'80 ; Ç ROM:00056768 TargetBoostCompensationECT:.sdata "ÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇDz" ROM:00056768 .data.b 0 ROM:0005677B .data.b 0 ROM:0005677C .data.l h'44FA0000, h'453B8000, h'457A0000 ROM:00056788 dword_56788: .data.l h'90909090 ; DATA XREF: ROM:00053794o
I'm not sure what .sdata is and it doesn't look like it belongs there... Andy
|
|
| Top |
|
 |
|
fujiillin
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 5:11 pm |
|
 |
| Experienced |
 |
Joined: Wed Feb 13, 2008 3:00 am Posts: 153
|
I've seen the .sdata thing before and I'm not entirely sure what it is, and usually just change it to hex. I believe either the d or o key will change it. Regarding the VBR, its pretty simple. In all the roms I've looked at, there is a long list of subroutines at the very end of the rom. At the end of the rom is the rom name, preceded by the VBR subroutine. Clicking this location takes you to it, then pressing 'p' marks it as a subroutine. From there, make sure you have 'make final pass' checked in the options, and reanalyze program, it should open up from there. Code: ROM:0007FFE4 .data.l loc_3214 ROM:0007FFE8 .data.l loc_3244 ROM:0007FFEC .data.l loc_3274 ROM:0007FFF0 .datab.l 2, h'FFFFFFFF ROM:0007FFF8 off_7FFF8: .data.l sub_EAD0 ; DATA XREF: ROM:off_5ACo ROM:0007FFFC off_7FFFC: .data.l aA2zj710j ; DATA XREF: ROM:off_5A8o ROM:0007FFFC ; "A2ZJ710J" RAM:FFFF0000 ; ===========================================================================
_________________ 06 Wrx Wagon 2.3 longrod in the works
|
|
| Top |
|
 |
|
Mart
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 5:26 pm |
|
 |
| Experienced |
Joined: Sun Jun 01, 2008 2:14 am Posts: 125 Location: Quebec
|
I think if someone could document one 16-bits and one 32-bits ROM dissassembly with the procedure in IDA (just the basics) , it would jumpstart a lot of people I believe. fujiillin wrote: I've seen the .sdata thing before and I'm not entirely sure what it is, and usually just change it to hex. I believe either the d or o key will change it. Regarding the VBR, its pretty simple. In all the roms I've looked at, there is a long list of subroutines at the very end of the rom. At the end of the rom is the rom name, preceded by the VBR subroutine. Clicking this location takes you to it, then pressing 'p' marks it as a subroutine. From there, make sure you have 'make final pass' checked in the options, and reanalyze program, it should open up from there. Code: ROM:0007FFE4 .data.l loc_3214 ROM:0007FFE8 .data.l loc_3244 ROM:0007FFEC .data.l loc_3274 ROM:0007FFF0 .datab.l 2, h'FFFFFFFF ROM:0007FFF8 off_7FFF8: .data.l sub_EAD0 ; DATA XREF: ROM:off_5ACo ROM:0007FFFC off_7FFFC: .data.l aA2zj710j ; DATA XREF: ROM:off_5A8o ROM:0007FFFC ; "A2ZJ710J" RAM:FFFF0000 ; ===========================================================================
|
|
| Top |
|
 |
|
fujiillin
|
Post subject: Re: 32-bit Disassembly in IDA Posted: Sun Dec 27, 2009 5:46 pm |
|
 |
| Experienced |
 |
Joined: Wed Feb 13, 2008 3:00 am Posts: 153
|
|
I'm getting close to finishing up a couple patches for my rom, then I plan on compiling everything into a PDF including everything from opening a rom in IDA to the basics of pipeline flow and optimization.
_________________ 06 Wrx Wagon 2.3 longrod in the works
|
|
| Top |
|
 |
Who is online |
Users browsing this forum: No registered users and 4 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|