Issue pulling the offset from a pattern menu

Shout-Out

User Tag List

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

    Issue pulling the offset from a pattern

    So I finally have my code correctly finding a given pattern w/a mask from memory. See here:
    tanaris4 private pastebin - collaborative debugging tool

    My issue is I'm not able to pull the actual offset out, I thought it was as simple as returning it similar to what has been posted elsewhere in the forums. I know for a fact I'm screwing up some fundamental C programming crap here, but I'm lost as to figuring it out.

    Anyone have any ideas?
    Code:
    return (unsigned long)(dw_Address+i);
    in theory should be the offset, but it's not. What am I missing here?

    Thanks so much!

    Edit: I think it's obvious, but dw_Address is the raw Bytes in memory (I pull the data from memory + malloc ReturnedBuffer)

    Issue pulling the offset from a pattern
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shouldn't you be returning startAddress+i?

  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)
    Originally Posted by Apoc View Post
    Shouldn't you be returning startAddress+i?
    That is just a "helper", as the dw_address doesn't start at 0, it starts at like 0x1000 (just based on how I'm reading the memory from wow).

    But yes the actual start of what I'm scanning for is at startAddress+i (including the xxx before the ???).

    so in the above instance startAddress+i is 0x1F3927, which is:


    And i need it to return 0xB9BEE0 vs. where the code was found

    Full source here (although I think you only need the above):http://code.google.com/p/pocketgnome...c=svn116&r=116

    Thanks again, really appreciate it, SOOO close to getting this functional :-)
    Last edited by Tanaris4; 09-22-2009 at 03:08 PM.

  4. #4
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    BOOL bDataCompare(const unsigned char* pData, const unsigned char* bMask, const char* szMask)
    {
            for(;*szMask;++szMask,++pData,++bMask){
                    if(*szMask=='x' && *pData!=*bMask ){
                            return false;
                    }
            }
            return /*(*szMask) == 0;*/ true;
    }

  5. #5
    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)
    Originally Posted by Apoc View Post
    Code:
    BOOL bDataCompare(const unsigned char* pData, const unsigned char* bMask, const char* szMask)
    {
            for(;*szMask;++szMask,++pData,++bMask){
                    if(*szMask=='x' && *pData!=*bMask ){
                            return false;
                    }
            }
            return /*(*szMask) == 0;*/ true;
    }
    That function is actually working correctly, so no change is needed there. I'm able to find the exact address of where my pattern with mask STARTS, just not able to find out where the offset is within that - does that make sense?

    Edit: More clarification: (dw_Address+i) is actually the start of the pattern, so it's \x8B\x75\x10 etc... (it's the raw bytes)
    Last edited by Tanaris4; 09-22-2009 at 03:23 PM.

  6. #6
    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)
    Modifying findPattern to: tanaris4 private pastebin - collaborative debugging tool

    Will actually print out the offset for me (backwards) - Obviously I can reverse the loop to store it correctly, but I still feel like i'm missing something simple here

  7. #7
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Tanaris4 View Post
    Modifying findPattern to: tanaris4 private pastebin - collaborative debugging tool

    Will actually print out the offset for me (backwards) - Obviously I can reverse the loop to store it correctly, but I still feel like i'm missing something simple here
    Aren't the addresses in memory simply stored as little-endian (or something)?
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  8. #8
    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)
    OK figured it out, but this has to be HORRIBLY inefficient:

    Code:
    unsigned long dwFindPattern( unsigned char *bMask,char * szMask, Byte*dw_Address, unsigned long dw_Len, unsigned long startAddressOffset )
    {
    	unsigned long i;
    	for(i=0; i < dw_Len; i++)
    		if( bDataCompare( (unsigned char*)( dw_Address+i ),bMask,szMask) ){
    			PGLog(@"Found signature at 0x%X ", i + startAddressOffset);
    			
    			const unsigned char* pData = (unsigned char*)( dw_Address+i );
    			unsigned long j = 0;
    			for ( ;*szMask;++szMask,++pData){
    				if ( j && *szMask == 'x' ){
    					break;
    				}
    				if ( *szMask == '?' ){
    					j++;
    				}
    			}
    				
    			unsigned long offset = 0, k;
    			for (k=0;j>0;j--,k++){
    				--pData;
    				offset <<= 8;  
    				offset ^= (long)*pData & 0xFF;   
    			}
    			
    			PGLog(@"Offset: 0x%X", offset);
    			
    			return offset;
    		}
    	return 0;
    }

Similar Threads

  1. [Guide]All the videos from Joana guide
    By mitzaem in forum World of Warcraft Guides
    Replies: 3
    Last Post: 01-22-2008, 06:22 PM
  2. Quickest way ever to the barrens from UD starting area
    By Blewitt101 in forum World of Warcraft Exploits
    Replies: 9
    Last Post: 01-15-2008, 08:35 AM
  3. Help plz about Mysql.exe on the repack from ac-web
    By aznboy in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 11-06-2007, 10:39 PM
  4. All the spells from the PTR
    By Fishy80 in forum World of Warcraft Model Editing
    Replies: 0
    Last Post: 04-20-2007, 02:32 PM
  5. Any1 have the guide from www.ultimatewowguide.com
    By oooscorpion in forum World of Warcraft General
    Replies: 0
    Last Post: 03-24-2007, 03:37 PM
All times are GMT -5. The time now is 09:55 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