Raised This Month: $51 Target: $400
 12% 

[TUT] Most Efficient Function Hooking Method


Post New Thread Reply   
 
Thread Tools Display Modes
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 02-05-2013 , 21:51   Re: [TUT] Most Efficient Function Hooking Method
Reply With Quote #21

I found in engine_i686.so string timed out.
[img]http://img7.**************/img7/3739/addressn.png[/img]
I calculated that offset that i need to patch is:

8BC9C + 1 = 8BC9D

What should i do next?
What is GETREALADDR?

Is there any other way to do this on linux?

Last edited by OvidiuS; 02-05-2013 at 21:53.
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Bos93
Veteran Member
Join Date: Jul 2010
Old 02-17-2013 , 07:29   Re: [TUT] Most Efficient Function Hooking Method
Reply With Quote #22

OvidiuS,

PHP Code:
#include <stdint.h> 
PHP Code:
#ifdef __linux__
    #ifdef __amd64__ // Lin64
        #define GAMEDLL_NAME "cs_amd64.so"
    #else // Lin32
        #define GAMEDLL_NAME "cs_i386.so"
    #endif
#else // Windows
    #define GAMEDLL_NAME "mp.dll"
#endif

// Define memory address type
#ifdef __amd64__
    
typedef uint64_t maddress;
#else
    
typedef uint32_t maddress;
#endif

maddress gameDllAddress;


#define GETREALADDR( Address ) (gameDllAddress + Address) 

Meta_Attach:

PHP Code:
    #ifdef __linux__
        
if (!UTIL_GetLinuxMemoryMap(&mapsFile, &errNum)) 
        {
            
print_srvconsole("Error reading memory maps file. Natives not available. (file \"%s\") (error \"%s\")"mapsFilestrerror(errNum));
            return(
FALSE);
        }
    
#else
        
gameDllAddress = (maddress)LoadLibrary(GAMEDLL_NAME);
        if (!
gameDllAddress
        {
            
print_srvconsole("Error getting handle to game DLL. Natives not available. (file \"%s\")"GAMEDLL_NAME);
            return(
FALSE);
        }
    
#endif 

_____________________________________________ _____________________________________________ ______________________________________

PHP Code:
#ifdef __linux__
    /* Function to read from memory map file to get server binary addresses.
       Returns true if file read successfully.
       Why must Linux be so difficult? Bah! This whole function was quite a pain to write. */
    
bool UTIL_GetLinuxMemoryMap (char **fileint *err) {
        
// Open and read maps file
        
char *mapsfile = new char[MAX_PATH];
        
FILE *fp;
    
        
sprintf(mapsfile"/proc/%d/maps"getpid());
        
fp fopen(mapsfile"r");
        *
file mapsfile;
    
        if (!
fp) {
            
err = &errno;
            
fclose(fp);
            return 
false;
        }

        
char buffer[256], perm[5], dev[6], mapname[PATH_MAX];
        
unsigned long beginendinodeoffset;
        
char serverBinCount 0;

        while (!
feof(fp)) {
            if (
serverBinCount == 1) {
                
gameDllAddress begin;
            } else if (
serverBinCount == 2) {
                
dataSectionStart begin;
                
dataSectionOffset offset;
                break;
            }
        
            if (
fgets(buffersizeof(buffer), fp) == NULL) break;

            
mapname[0] = '\0';
            
sscanf(buffer"%lx-%lx %4s %lx %5s %ld %s", &begin, &endperm, &offsetdev, &inodemapname);

            
chartoken strtok(mapname"/");
            while (
token != NULL) {
                if (
strcmp(tokenGAMEDLL_NAME) == 0) {
                    
serverBinCount++;
                    break;
                }
                
token strtok(NULL"/");
            }
        }

        if (
serverBinCount == 0) {
            
err = &errno;
            
fclose(fp);
            return 
false;
        }

        
fclose(fp);

        return 
true;
    }
#endif 
__________________

Last edited by Bos93; 02-17-2013 at 07:30.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Bos93
Veteran Member
Join Date: Jul 2010
Old 11-10-2013 , 08:00   Re: [TUT] Most Efficient Function Hooking Method
Reply With Quote #23

How to called original function? How to block the round end?
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode