1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

GetModuleBase OSX C++

Discussion in 'Source Code' started by suMan, Aug 31, 2014.

  1. suMan

    suMan New Member

    Joined:
    Jul 23, 2013
    Messages:
    93
    Likes Received:
    0
    hey leute.
    hab dies schon auf unknownchegats gepostet,
    aber dachte mir ich share es auch hier.
    Ne easy methods um module bases zu fetchen ( OSX C++ )
    Beispiel Counter strike source:

    Code:
    function exec ( auf  stack overflow  gefunden):
    
    string exec(char* cmd) {
        FILE* pipe = popen(cmd, "r");
        if (!pipe) return "ERROR";
        char buffer[128];
        std::string result = "";
        while(!feof(pipe)) {
            if(fgets(buffer, 128, pipe) != NULL)
                result += buffer;
        }
        pclose(pipe);
        return result;
    }
    funktionen:
    
    unsigned long GetBaseAdress(string input,char* dylib){
        string data  = input.substr(input.find(dylib), input.length());
        string baseadress = data.substr(data.find_first_of("0x"),data.find_first_of(" ("));
        baseadress = baseadress.substr(0,baseadress.find_first_of(" "));
        return strtoul(baseadress.c_str(),NULL,0);
    }
    
    anwendung:
    
        string data = exec(" symbols hl2_osx -noSymbols -noSources -noDemangling 
        -fullSourcePath -arch i386 -w");
            
        this->uClientBase = GetBaseAdress(data, "/client.dylib");
        this->uEngineBase = GetBaseAdress(data, "/engine.dylib");
        printf("%-10s [0x%.8x]\n","Client.dylib", this->uClientBase);
        printf("%-10s [0x%.8x]\n","Engine.dylib", this->uEngineBase);
    
    
    ich hoffe das hilft jemanden. lg suman

    runtime screenshot:
    [​IMG]