Thread: API Function

Results 1 to 15 of 15
  1. #1
    xPureangel's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    Singapore
    Posts
    27
    Reputation
    10
    Thanks
    234
    My Mood
    Amazed

    API Function

    Releasing a easy mode API function! Thanks if it helps!

     
    Code:
    #include <cstdlib>
    #include <cstring>
    
    #include <winsock2.h>
    #include <Ws2tcpip.h>
    
    #include <windows.h>
    
    class ApiCave
    {
        public:
        void GenerateBytes();
        void RestoreBytes();
        void PlaceJump();
        void GetOriginalFuncAddress(char * moduleName, char * functionName);
        ApiCave(LPVOID DetourFunction, int iSize);
        ~ApiCave();
        private:
        int iInstructionSize;
        BYTE *originalBytes, *hookBytes, *tempBytes;
        DWORD OriginalFunctionAddress, DetourFunctionAddress, oldprotect;
        DWORD myprotect;
    };
    void ApiCave::GenerateBytes()
    {
        tempBytes[0] = 0xE9;
        tempBytes[5] = 0xC3;                                    // 0xE9 = JMP 0x90 = NOP oxC3 = RET
        memcpy(hookBytes, tempBytes, iInstructionSize);                                         // store jmp instruction to JMP
        DWORD JMPSize = ((DWORD)DetourFunctionAddress - (DWORD)OriginalFunctionAddress - 5);    // calculate jump distance
        VirtualProtect((LPVOID)OriginalFunctionAddress, iInstructionSize,                                   // assign read write protection
                       myprotect, &oldprotect);
        memcpy((LPVOID)originalBytes, (LPVOID)OriginalFunctionAddress, iInstructionSize);                                   // make backup
        memcpy(&hookBytes[1], &JMPSize, 4);                                                     // fill the nop's with the jump distance (JMP,distance(4bytes),RET)
        VirtualProtect((LPVOID)OriginalFunctionAddress, iInstructionSize, oldprotect, NULL);
    }
    void ApiCave::RestoreBytes()
    {
        VirtualProtect((LPVOID)OriginalFunctionAddress, iInstructionSize, myprotect, &oldprotect);
        memcpy((LPVOID)OriginalFunctionAddress, originalBytes, iInstructionSize);
        VirtualProtect((LPVOID)OriginalFunctionAddress, iInstructionSize, oldprotect, NULL);
    }
    void ApiCave::PlaceJump()
    {
        VirtualProtect((LPVOID)OriginalFunctionAddress, iInstructionSize, myprotect, &oldprotect);
        memcpy((LPVOID)OriginalFunctionAddress, hookBytes, iInstructionSize);
        VirtualProtect((LPVOID)OriginalFunctionAddress, iInstructionSize, oldprotect, NULL);
    }
    void ApiCave::GetOriginalFuncAddress(char * moduleName, char * functionName)
    {
        OriginalFunctionAddress = (DWORD)GetProcAddress(GetModuleHandle(moduleName), functionName);
    }
    ApiCave::ApiCave(LPVOID DetourFunction, int iSize)
    {
        iInstructionSize = iSize;
        myprotect = PAGE_EXECUTE_READWRITE;
        DetourFunctionAddress = (DWORD)DetourFunction;
        tempBytes = new BYTE[iSize];
        originalBytes = new BYTE[iSize];
        hookBytes = new BYTE[iSize];
    }
    ApiCave::~ApiCave()
    {
        delete[] tempBytes;
        delete[] originalBytes;
        delete[] hookBytes;
    }


     
    Code:
    #include "hook.h"
    
    BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    {
        switch (fdwReason)
        {
            case DLL_PROCESS_ATTACH:
                DoTheHook();
                break;
        }
        return TRUE; 
    }


     
    Code:
    #include "hkClass.h"
    
    int WINAPI MySend(SOCKET, const char *, int, int);  
    int WINAPI MyMessageBoxA(HWND, LPCTSTR, LPCTSTR, UINT);
    
    ApiCave sendCave((LPVOID)MySend, 6);
    ApiCave mbCave((LPVOID)MyMessageBoxA, 6);
    
    int WINAPI MySend (SOCKET s, const char * buf, int len, int flags)
    {
        sendCave.RestoreBytes();
        int retVal = send(s, buf, len, flags);
        sendCave.PlaceJump();
        return retVal;
    }
    
    int WINAPI MyMessageBoxA(HWND hWnd, LPCTSTR text, LPCTSTR title, UINT type)
    {
       mbCave.RestoreBytes();
       int retVal = MessageBoxA(hWnd, text, title, type);
       mbCave.PlaceJump();
       return retVal;
    }
    
    void DoTheHook()
    {
       sendCave.GetOriginalFuncAddress("ws2_32.dll", "send");
       mbCave.GetOriginalFuncAddress("user32.dll", "MessageBoxA");
       
       sendCave.GenerateBytes();
       mbCave.GenerateBytes();
       
       sendCave.PlaceJump();
       mbCave.PlaceJump();
    }


    Credits:Harava



    Like my video and subscribe! haha
    Last edited by xPureangel; 01-27-2014 at 06:55 AM.

  2. The Following User Says Thank You to xPureangel For This Useful Post:

    GameCube64Bit (01-27-2014)

  3. #2
    Mayion's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    Bed
    Posts
    13,504
    Reputation
    4018
    Thanks
    8,372
    My Mood
    Twisted
    Nice montage. ^^
    I do not use any type of messenger outside of MPGH.
    Inactive but you can reach me through VM/PM.










     

    Donator - 30 August 2013
    Battlefield Minion - 26 October 2013

    Blackshot Minion - 14 January 2014/16 September 2014
    Minecraft Minion - 7 February 2014/16 September 2014
    WarRock Minion - 23 February 2014
    League of Legends Minion - 21 March 2014

    Minion+ - 15 May 2014
    Other Semi-Popular First Person Shooter Minion - 8 August 2014
    CrossFire Minion - 23 October 2014
    Programming Section Minion - 13 November 2014
    Marketplace Minion - 7 December 2014

    Official Middleman - 7 December 2014 - 27 June 2015
    Moderator - 29 December 2014
    Project Blackout Minion - 10 January 2015
    News Force Interviewer - January 2015
    Steam Games Minion - 21 March 2015
    Dragon Nest Minion - 31 March 2015
    Publicist - April 2015 - 21 September 2015
    Global Moderator - 25 August 2015
    Super User - 13 August 2016



  4. #3
    COD3RIN's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Posts
    5,309
    Reputation
    468
    Thanks
    28,779
    My Mood
    Angelic
    you need to reversing this code ......and credit by?
    ᚛C☢dℝin3᚜
    Love you.
    ~Kenshit13
    Quote Originally Posted by cheaterman26 View Post
    COD3RIN PUT A BACKDOOR ON HIS OWN CHEAT HE HACK MY COMPUTER AND MY STEAM, DON'T TRUST THIS GUYS !



  5. #4
    xPureangel's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    Singapore
    Posts
    27
    Reputation
    10
    Thanks
    234
    My Mood
    Amazed
    Oh thanks!
    Quote Originally Posted by Mayion View Post
    Nice montage. ^^

  6. #5
    xPureangel's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    Singapore
    Posts
    27
    Reputation
    10
    Thanks
    234
    My Mood
    Amazed
    I'm not suppose to mention his name
    Quote Originally Posted by COD3RIN View Post
    you need to reversing this code ......and credit by?

  7. #6
    COD3RIN's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Posts
    5,309
    Reputation
    468
    Thanks
    28,779
    My Mood
    Angelic
    Quote Originally Posted by xPureangel View Post
    I'm not suppose to mention his name
    and why? ...
    ᚛C☢dℝin3᚜
    Love you.
    ~Kenshit13
    Quote Originally Posted by cheaterman26 View Post
    COD3RIN PUT A BACKDOOR ON HIS OWN CHEAT HE HACK MY COMPUTER AND MY STEAM, DON'T TRUST THIS GUYS !



  8. #7
    xPureangel's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    Singapore
    Posts
    27
    Reputation
    10
    Thanks
    234
    My Mood
    Amazed
    he isn't from the forum :x
    Quote Originally Posted by COD3RIN View Post

    and why? ...

  9. #8
    Mayion's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    Bed
    Posts
    13,504
    Reputation
    4018
    Thanks
    8,372
    My Mood
    Twisted
    Quote Originally Posted by xPureangel View Post
    he isn't from the forum :x
    Credits are required, mention his name.
    I do not use any type of messenger outside of MPGH.
    Inactive but you can reach me through VM/PM.










     

    Donator - 30 August 2013
    Battlefield Minion - 26 October 2013

    Blackshot Minion - 14 January 2014/16 September 2014
    Minecraft Minion - 7 February 2014/16 September 2014
    WarRock Minion - 23 February 2014
    League of Legends Minion - 21 March 2014

    Minion+ - 15 May 2014
    Other Semi-Popular First Person Shooter Minion - 8 August 2014
    CrossFire Minion - 23 October 2014
    Programming Section Minion - 13 November 2014
    Marketplace Minion - 7 December 2014

    Official Middleman - 7 December 2014 - 27 June 2015
    Moderator - 29 December 2014
    Project Blackout Minion - 10 January 2015
    News Force Interviewer - January 2015
    Steam Games Minion - 21 March 2015
    Dragon Nest Minion - 31 March 2015
    Publicist - April 2015 - 21 September 2015
    Global Moderator - 25 August 2015
    Super User - 13 August 2016



  10. #9
    COD3RIN's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Posts
    5,309
    Reputation
    468
    Thanks
    28,779
    My Mood
    Angelic
    Quote Originally Posted by xPureangel View Post
    he isn't from the forum :x
    i already know who belong this code
    ᚛C☢dℝin3᚜
    Love you.
    ~Kenshit13
    Quote Originally Posted by cheaterman26 View Post
    COD3RIN PUT A BACKDOOR ON HIS OWN CHEAT HE HACK MY COMPUTER AND MY STEAM, DON'T TRUST THIS GUYS !



  11. #10
    xPureangel's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    Singapore
    Posts
    27
    Reputation
    10
    Thanks
    234
    My Mood
    Amazed
    done hahaha
    Quote Originally Posted by Mayion View Post


    Credits are required, mention his name.

  12. #11
    MiguelZinho's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Posts
    32
    Reputation
    10
    Thanks
    4
    @xPureangel ->> Releasing a easy mode API function! Thanks if it helps!

    this detour is functional in "BlackShot"?
    Last edited by MiguelZinho; 01-27-2014 at 10:02 AM.

  13. #12
    macallister's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    27
    Reputation
    10
    Thanks
    1
    My Mood
    Relaxed
    what is API

  14. #13
    xPureangel's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    Singapore
    Posts
    27
    Reputation
    10
    Thanks
    234
    My Mood
    Amazed
    Skype, Abnormal KaeMing
    Quote Originally Posted by MiguelZinho View Post
    @xPureangel ->> Releasing a easy mode API function! Thanks if it helps!

    this detour is functional in "BlackShot"?

  15. #14
    bobchao123's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    48
    Reputation
    10
    Thanks
    1
    what does dis do
    ?

  16. #15
    Vinicios-BR's Avatar
    Join Date
    Feb 2014
    Gender
    male
    Posts
    12
    Reputation
    10
    Thanks
    0
    My Mood
    Yeehaw
    i cant understand can you explain it

Similar Threads

  1. Nop Function?
    By Braco22 in forum Combat Arms Coding Help & Discussion
    Replies: 2
    Last Post: 08-27-2011, 02:56 PM
  2. Help me ? add new function
    By tinhozdl in forum Combat Arms Coding Help & Discussion
    Replies: 5
    Last Post: 08-22-2011, 06:56 PM
  3. [Help] how do esp function?
    By dostrix in forum WarRock Hack Source Code
    Replies: 14
    Last Post: 04-02-2011, 01:31 AM
  4. .XOS FUNCTION
    By ricekicks in forum WarRock Discussions
    Replies: 16
    Last Post: 08-14-2010, 10:22 PM
  5. [Discussion] Cf vip is function??
    By alone_ake in forum CrossFire Hacks & Cheats
    Replies: 2
    Last Post: 02-03-2010, 09:40 PM