[IDA] Plugin to Convert an entire segment to float? menu

User Tag List

Results 1 to 3 of 3
  1. #1
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [IDA] Plugin to Convert an entire segment to float?

    Apologies in advance if I shoudn't be posting this here (as it's mainly about IDA), but I'm struggling w/how I could efficiently convert ALL values in my _literal4 and _literal8 Mach-O segments to floats.

    Check out this screenshot:


    Basically the top 3 I had to selected the value, go to Edit -> Operand Type -> Number -> Float.

    Obviously I can't do this for every single one as it would take ages. Would anyone be willing to point me in the direction of how I could create a plugin to do this for me? I'm assuming you could just loop through all the literals in a given segment but I'm not experienced w/IDA plugins.

    Would be willing to throw some donation money your way if you could assist. I've always struggled on viewing the OS X binary in IDA as floats are not displayed.

    Thanks in advance!
    https://tanaris4.com

    [IDA] Plugin to Convert an entire segment to float?
  2. #2
    XTZGZoReX's Avatar Active Member
    Reputation
    32
    Join Date
    Apr 2008
    Posts
    173
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dive into IDC. Check the idc sub-directory of your IDA installation.

  3. #3
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Should I go the plugin route? Or is that overkill? I downloaded the SDK + started reading this: http://www.binarypool.com/idapluginwriting/idapw.pdf

    Edit: w00t scripts will work, thanks! I'm working on it now!

    ---------- Post added at 11:46 AM ---------- Previous post was at 10:23 AM ----------

    Figured it out - now does anyone know how to search for floats w/in IDA? (w/o writing a script)

    Here is the auto-conversion script:
    Code:
    #include <idc.idc>
    
    static _ConvertSegmentToFloats(segStart, segEnd, size){
    	
    	auto address, flags, result;
    
    	result = 0;
    	address = segStart;
    
    	while ( address < segEnd ){
    		
    		flags = GetFlags(address);
    
    		// we have valid data here
    		if ( isData(flags) ){
    
    			// float
    			if ( size == 0x4 && !isFloat(flags) ){
    				result = OpFloat(address, 0);
    				Message("\n [%d] Converting location 0x%X to a float", result, address);
    			}
    
    			// double
    			else if ( size == 0x8 && !isDouble(flags) ){
    				result = OpFloat(address, 0);
    				Message("\n [%d] Converting location 0x%X to a double", result, address);
    			}
    		}
    
    		// increase by size!
    		address = address + size;
    	}
    }
    
    static main(){
    
    	auto segPointer;
    	auto segStart, segEnd, segName;
    
    	// Get the pointer to our first segment
    	segPointer = FirstSeg();
    	
    	while (segPointer != BADADDR){
    
    		segName = SegName(segPointer);
    		segStart = SegStart(segPointer);
    		segEnd = SegEnd(segPointer);
    
    		//Message("\n%s from 0x%X to 0x%X", segName, segStart, segEnd );
    
    		// floats
    		if ( segName == "__literal4" ){
    
    			_ConvertSegmentToFloats(segStart, segEnd, 0x4);
    
    		}
    		// doubles
    		else if ( segName == "__literal8" ){
    			_ConvertSegmentToFloats(segStart, segEnd, 0x8);
    		}
    
    		segPointer = NextSeg( segPointer );
    	}
    }
    Last edited by Tanaris4; 09-09-2010 at 09:56 AM.
    https://tanaris4.com

Similar Threads

  1. IDA script / plugin
    By violentmagician in forum WoW Memory Editing
    Replies: 5
    Last Post: 09-19-2012, 06:19 PM
  2. [IDA Plugin] Modded PatchDiff2
    By jjaa in forum WoW Memory Editing
    Replies: 2
    Last Post: 07-24-2011, 04:12 PM
  3. IDA Plugin - Pattern Maker - Source included
    By Tanaris4 in forum WoW Memory Editing
    Replies: 3
    Last Post: 05-05-2011, 08:51 PM
  4. Creating an IDA Plugin to search for floats
    By Tanaris4 in forum WoW Memory Editing
    Replies: 0
    Last Post: 09-09-2010, 11:29 AM
All times are GMT -5. The time now is 04:08 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search