Creating an IDA Plugin to search for floats menu

User Tag List

Results 1 to 1 of 1
  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)

    Creating an IDA Plugin to search for floats

    So since I've been having issues w/searchign for floats I thought I would create an IDA script to do just that. Simply run the script, it will ask you for an exact float, and it will search for it.

    One issue I'm running into, I'd like for it to be able to search for ranges w/in the vicinity of the number you are searching for. So for example, lets say you are searching for:
    0.01666666666666667

    Well I'd like to automatically "move down" the float until I hit the first non-0 value (which would be 1). Then I'd like to increment + decrement by 1 and search for that range. So the search would be for values in between:
    0.00666666666666667 and 0.02666666666666667
    Sad question I know, and I feel like the solution is simple, but I'm stumped. Anyone have any recommendations on how to go about it (bit shifting/comparison of some type?)

    Thanks!

    Code:
    #include <idc.idc>
    
    static _Search(segStart, segEnd, size, searchValue){
    
    	auto address, flags, result, value;
    
    	Message("\nSearching for %f", searchValue);
    
    	address = segStart;
    
    	while ( address < segEnd ){
    		
    		flags = GetFlags(address);
    
    		// we have valid data here
    		if ( isData(flags) ){
    
    			// if we want to do some searching!
    			if ( size == 0x4 ){
    				value = GetFloat(address);
    			}
    			else if ( size == 0x8 ){
    				value = GetDouble(address);
    			}
    			
    			//19.291105
    			if ( value == searchValue ){
    				Message("\n Value at 0x%X is %f", address, value);
    			}
    		}
    
    		// increase by size!
    		address = address + size;
    	}
    }
    
    static main(){
    
    	auto segPointer, segStart, segEnd, segName, searchValue;
    	searchValue =  AskStr( "0.0" , "Please enter a float/double value to search for");
    
    	// Get the pointer to our first segment
    	segPointer = FirstSeg();
    	
    	while (segPointer != BADADDR){
    
    		segName = SegName(segPointer);
    		segStart = SegStart(segPointer);
    		segEnd = SegEnd(segPointer);
    
    		// floats
    		if ( segName == "__literal4" ){
    			_Search(segStart, segEnd, 0x4, searchValue);
    		}
    		// doubles
    		else if ( segName == "__literal8" ){
    			_Search(segStart, segEnd, 0x8, searchValue);
    		}
    
    		segPointer = NextSeg( segPointer );
    	}
    }
    https://tanaris4.com

    Creating an IDA Plugin to search for floats

Similar Threads

  1. Searching for people interested in creating an MMO (Hobby)
    By crowdedcreation in forum Programming
    Replies: 3
    Last Post: 08-07-2013, 06:17 AM
  2. [IDA] How do I search for a sequence of bytes in code?
    By fvicaria in forum WoW Memory Editing
    Replies: 4
    Last Post: 01-29-2012, 02:38 PM
  3. [IDA] Plugin to Convert an entire segment to float?
    By Tanaris4 in forum WoW Memory Editing
    Replies: 2
    Last Post: 09-09-2010, 10:46 AM
  4. IDA - Searching for floats/doubles
    By Tanaris4 in forum WoW Memory Editing
    Replies: 10
    Last Post: 05-11-2010, 04:03 PM
  5. Searching for Voice Actors/In-Game Actors
    By Örpheus in forum World of Warcraft General
    Replies: 1
    Last Post: 08-01-2006, 10:03 AM
All times are GMT -5. The time now is 03:37 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search