Notices
ECU Flash

IDA Pro Code Change Help?

Thread Tools
 
Search this Thread
 
Old Aug 27, 2010, 09:04 AM
  #1  
Evolved Member
Thread Starter
iTrader: (8)
 
03whitegsr's Avatar
 
Join Date: Nov 2006
Location: Utah
Posts: 4,001
Received 14 Likes on 12 Posts
IDA Pro Code Change Help?

I am trying to make some changes to 96531706 in IDA Pro. I'm using the HEX Dump section to make changes and after I make a change, it seems like it carries over instructions from the previous set of instructions in the disassemble window?

Here are two screen shots.
Left is the normal 96531706 code and the right side is the code changes I'm trying to make. Right now, I'm just NOP'ing things out to hold places, but the NOPs have that extra garbage with it on the right?




Any help?
Attached Thumbnails IDA Pro Code Change Help?-ida-error-2.png  
Old Aug 27, 2010, 09:36 AM
  #2  
Evolved Member
iTrader: (2)
 
l2r99gst's Avatar
 
Join Date: Mar 2004
Location: CA
Posts: 3,499
Likes: 0
Received 4 Likes on 4 Posts
I can't offer any help, but I never knew you could edit the hex in IDA Pro. I have IDA Pro and used it a few times to port some patches that mrfred made to other ROMs. But, I always just used IDAPro to 'look' at the code and then used ECUFlash to make the actual changes.

It would definitely be a lot easier with a hex editor, but I just wasn't aware (or never looked into it enough) that IDA could do it. I always thought that it should, but in the hex window, it was always read-only for me, and I never looked into any setting to change that.
Old Aug 27, 2010, 09:56 AM
  #3  
EvoM Guru
iTrader: (50)
 
mrfred's Avatar
 
Join Date: Mar 2006
Location: Tri-Cities, WA // Portland, OR
Posts: 9,675
Received 128 Likes on 96 Posts
I've never tried to mod the code using IDA.
Old Aug 27, 2010, 10:20 AM
  #4  
Evolved Member
Thread Starter
iTrader: (8)
 
03whitegsr's Avatar
 
Join Date: Nov 2006
Location: Utah
Posts: 4,001
Received 14 Likes on 12 Posts
I just click on the Hex of interest, F2 to edit, F2 to commit changes and then in the dissassembly, hit C on each line I changed to update the code.

MrFred, what do you use for code change?

Once you are in .i64 or .idb in IDA Pro, I'm assuming there is no easy way to go back into .bin format?
Old Aug 27, 2010, 03:17 PM
  #5  
Evolved Member
iTrader: (2)
 
logic's Avatar
 
Join Date: Apr 2003
Location: Berkeley, CA
Posts: 1,022
Likes: 0
Received 6 Likes on 5 Posts
You might want to take a peek at chapter 14 of the IDA Pro Book; specifically, The Infamous Patch Program Menu (you can register for a free trial; or, just buy the book, as it's pretty good). That might get you a little bit closer to what it is you're trying to accomplish.

Originally Posted by The IDA Pro Book
14 - PATCHING BINARIES AND OTHER IDA LIMITATIONS

One of the most frequently asked questions by new or prospective IDA users is, "How can I use IDA to patch binaries?" The simple answer is, "You can't." IDA's intended purpose is to assist you in understanding the behavior of a binary by offering you the best disassembly possible. IDA is not designed to make it easy for you to modify the binaries you are examining. Not wanting to take no for an answer, die-hard patchers often follow up with questions such as, "What about the Edit -> Patch Programs menu?" and "What is the purpose of "File -> Produce File -> Create EXE File?" In this chapter we discuss the apparent anomalies and see if we can't coax IDA into helping us, at least a little bit, in developing patches for binary program files.
Personally, I just use a hex editor ("xvi32" or the hex editor plugin for "Notepad++" on Windows, "hexedit" on Linux) for small changes. For bigger changes, I use binutils/GAS to go from assembly to binary, and EcuFlash to help with cut-and-paste from time to time.
Old Aug 27, 2010, 03:33 PM
  #6  
Evolving Member
 
Ceddy's Avatar
 
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes on 0 Posts
I use IDA to "code edit" for my H8 stuff, mostly because there isn't a easy to use assembler available.


First, hexedit the new instructions in.

Second, you need to select the changed area, and Undefine it. Then hit the C key to change it back to code. Or P key if doing a whole sub.

Third you need to dump your changes. The changes you made have no effect on the original .rom file. I made script to do this.



You will need to change script for SH-2s, in present form it reads 0x10000 - 0x2FFFF from IDA and dumps it to a file.

hex_dump.idc
Code:
#include <idc.idc>
#include <memcpy.idc>

#define ROM_START 0x10000
#define ROM_END 0x30000

static main() {


auto pFile;
auto a;
auto i;

pFile = fopen ("hex_dump.hex", "wb");

for (i = ROM_START; i < ROM_END; i = i + 1) 
	{
		a = Byte(i);
		fputc (a ,pFile);
	}

fclose(pFile);

}
Old Aug 27, 2010, 04:26 PM
  #7  
EvoM Guru
iTrader: (50)
 
mrfred's Avatar
 
Join Date: Mar 2006
Location: Tri-Cities, WA // Portland, OR
Posts: 9,675
Received 128 Likes on 96 Posts
I do everything in an Excel spreadsheet and when cut paste hex in ECUFlash. I think I've given you one or two of my Excel spreadsheets.
Old Aug 27, 2010, 10:38 PM
  #8  
Evolving Member
iTrader: (7)
 
evoredy's Avatar
 
Join Date: Apr 2008
Location: San Jose, CA
Posts: 341
Received 3 Likes on 2 Posts
I just use IDA to mark my locations and then dump undefined and look for my markers. Then I manually insert/edit stuff in defined form replacing code in between the markers--and then re-assemble with kpit-cummins assembler.

There's a little more to it like aligning code sometimes but thats just a result of my method. I'm sure there's a switch somewhere that could be used to fix that lol.

Then I verify meticulously with IDA again/maybe do hex compare/verification too. Kind of cumbersome, but that's how I do things.

I like Ceddy's method better. Never tried it that way yet.

Good Luck Man.

EDIT: the extra garbage is IDA tracking code that is linked to the area's you are NOPing (lol NOPing). basically you have [a lot] more work to do :/.

Last edited by evoredy; Aug 27, 2010 at 10:47 PM.
Old Aug 28, 2010, 12:51 AM
  #9  
Evolved Member
Thread Starter
iTrader: (8)
 
03whitegsr's Avatar
 
Join Date: Nov 2006
Location: Utah
Posts: 4,001
Received 14 Likes on 12 Posts
Thanks guys
Think I got it figured out with your help. Probably not the most efficient way, but it seems to work reliably.
Old Yesterday, 02:46 PM
  #10  
Newbie
 
Aloosh1983's Avatar
 
Join Date: May 2023
Location: Jordan
Posts: 31
Received 0 Likes on 0 Posts
Originally Posted by 03whitegsr
I am trying to make some changes to 96531706 in IDA Pro. I'm using the HEX Dump section to make changes and after I make a change, it seems like it carries over instructions from the previous set of instructions in the disassemble window?

Here are two screen shots.
Left is the normal 96531706 code and the right side is the code changes I'm trying to make. Right now, I'm just NOP'ing things out to hold places, but the NOPs have that extra garbage with it on the right?




Any help?
Hello bro , can you give the script that you are used
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
dparrish
ECU Flash
25
Yesterday 03:18 PM
tephra
ECU Flash
225
Apr 5, 2021 06:30 AM
newbevouser
ECU Flash
16
Dec 30, 2016 08:38 AM
mrfred
ECU Flash
316
Apr 24, 2016 10:24 AM



Quick Reply: IDA Pro Code Change Help?



All times are GMT -7. The time now is 09:37 PM.