Go Back   UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats > Anti-Cheat Software & Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/

Welcome to the UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats.
You have to register before you can post and see and access any of the advanced forum features, please click the register link to proceed to the registration form. To start viewing threads or posts, select a forum that you want to visit from the selection below.
Direct3D
hacking programming reversing
You are Unregistered, please register to gain Full access.    
Reply
 
Thread Tools

MidFunction Hook (XP)
Old 08-31-2010, 03:38 AM   #1
UnKnoWnCheaTeR

disavow's Avatar

Join Date: Jul 2009
Posts: 1,068
Reputation: 49844
Rep Power: 551
disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
Points: 31,279, Level: 26
Points: 31,279, Level: 26 Points: 31,279, Level: 26 Points: 31,279, Level: 26
Activity: 13.8%
Activity: 13.8% Activity: 13.8% Activity: 13.8%
Last Achievements
MidFunction Hook (XP)

Thanks to learn_more for sending me xp version to hook.

Win7 + Vista: http://www.uc-forum.com/forum/d3d-pr...tion-hook.html

Defines
Code:
DWORD * VTable;
DWORD dwEndscene_hook, dwEndscene_ret;
BYTE EndSceneOpCodes[6];
Endscene
This time device is already been loaded and checked for null device
Code:
__declspec(naked) void MyEndscene( )
{
    __asm 
    {
         //most registers have already been preserved
         pushaf; //we are in the middle of a conditional jmp
         mov dword ptr ss:[ebp-1C], edi;
         mov dword ptr ss:[ebp-18], ebx; //replace patched code
         mov m_pD3Ddev, esi; //Get the device (loaded previously)
    }


    __asm 
    {
        popaf; //je is set
        jmp dwEndscene_ret;//jump back to normal endscene
    }

}
My offset init function using vtable pattern that Gordon' posted
Code:
void Dx9Hook( LPCSTR D3D9 )
{
    DWORD hD3D = NULL;
    while (!hD3D) hD3D = (DWORD)GetModuleHandle(D3D9);
    DWORD PPPDevice = FindPattern(hD3D, 0x128000,  (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86",  "xx????xx????xx");
    memcpy( &VTable, (void *)(PPPDevice + 2), 4);

    dwEndscene_hook = VTable[42] + 0x36; //mid function
    dwEndscene_ret = dwEndscene_hook + 0x6; //return address
}
Usuage @ Mainthread
Code:
Dx9Hook("d3d9.dll");

Memcpy((void *)Endscene_opcodes, (void *)"\x89\x7D\xE4\x89\x5D\xE8", 6);
        
while( 1 )
{
    Sleep( 1000 );

    if(memcmp((void *)Endscene_opcodes, (void *)dwEndscene_hook, 6) == 0 )
        Detour(dwEndscene_hook, MyEndscene);
 
}
Note: untested and uncompiled... all based on theory and coded quickly to help xp people find there way.

Edit: miscalculated distance, fixed now.
__________________

Shad0w_'s Alter Ego

Last edited by disavow; 08-31-2010 at 03:51 AM.
disavow is online now

Reply With Quote


Old 08-31-2010, 04:30 AM   #2
Level 3

Gellin's Avatar

Join Date: Nov 2007
Location: msdn
Posts: 528
Reputation: 22916
Rep Power: 291
Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!Gellin has reputation that takes up 2GB of server space!
Points: 16,705, Level: 17
Points: 16,705, Level: 17 Points: 16,705, Level: 17 Points: 16,705, Level: 17
Activity: 1.1%
Activity: 1.1% Activity: 1.1% Activity: 1.1%
Last Achievements
I think the proper way to preserve the flags/registers what ever YOU call them would be.

Code:
_declspec(naked) void MyEndscene( )
{
    __asm 
    {
         mov dword ptr ss:[ebp-1C], edi;
         mov dword ptr ss:[ebp-18], ebx; 
         mov m_pD3Ddev, esi; 
         pushaf; 
    }


    __asm 
    {
        popaf; //je is set
        jmp dwEndscene_ret;//jump back to normal endscene
    }

}
Personally i would use pushad/popad as well
__________________
Gellin is offline

Reply With Quote

Old 08-31-2010, 05:11 AM   #3
UnKnoWnCheaTeR

disavow's Avatar

Threadstarter
Join Date: Jul 2009
Posts: 1,068
Reputation: 49844
Rep Power: 551
disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
Points: 31,279, Level: 26
Points: 31,279, Level: 26 Points: 31,279, Level: 26 Points: 31,279, Level: 26
Activity: 13.8%
Activity: 13.8% Activity: 13.8% Activity: 13.8%
Last Achievements
Quote:
Originally Posted by Gellin View Post
I think the proper way to preserve the flags/registers what ever YOU call them would be.

Code:
_declspec(naked) void MyEndscene( )
{
    __asm 
    {
         mov dword ptr ss:[ebp-1C], edi;
         mov dword ptr ss:[ebp-18], ebx; 
         mov m_pD3Ddev, esi; 
         pushaf; 
    }


    __asm 
    {
        popaf; //je is set
        jmp dwEndscene_ret;//jump back to normal endscene
    }

}
Personally i would use pushad/popad as well

I'm preserving the flags before this:
mov dword ptr ss:[ebp-1C], edi;
because a flags have been set by the cmp op before it, not that it matters.
As I said all the registers have already been preserved and doing so again would probably crash it...
They wouldn't need to be preserved anyways, since they get reset after this hook.
__________________

Shad0w_'s Alter Ego
disavow is online now

Reply With Quote

Old 08-31-2010, 12:20 PM   #4
h4x0!2

thelick's Avatar

Join Date: Jul 2010
Posts: 95
Reputation: 1050
Rep Power: 31
thelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of rep
Points: 1,473, Level: 3
Points: 1,473, Level: 3 Points: 1,473, Level: 3 Points: 1,473, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Nice work Shad0w..And if you want hook vista/w7 and xp both?
thelick is offline

Reply With Quote

Old 08-31-2010, 12:32 PM   #5
Moderator

Little's Avatar

Join Date: Nov 2009
Posts: 253
Reputation: 5217
Rep Power: 85
Little DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATS
Points: 3,764, Level: 6
Points: 3,764, Level: 6 Points: 3,764, Level: 6 Points: 3,764, Level: 6
Activity: 56.3%
Activity: 56.3% Activity: 56.3% Activity: 56.3%
Last Achievements
Quote:
Originally Posted by thelick View Post
Nice work Shad0w..And if you want hook vista/w7 and xp both?
you have a few options, you could do a OS check, and hook accordingly
Little is online now

Reply With Quote

Old 08-31-2010, 12:41 PM   #6
h4x0!2

thelick's Avatar

Join Date: Jul 2010
Posts: 95
Reputation: 1050
Rep Power: 31
thelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of rep
Points: 1,473, Level: 3
Points: 1,473, Level: 3 Points: 1,473, Level: 3 Points: 1,473, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by Little View Post
you have a few options, you could do a OS check, and hook accordingly
Right thx little,similar of what i'm doing with the OS check for the addies of op7
thelick is offline

Reply With Quote

Old 08-31-2010, 02:55 PM   #7
Donator

ZeaS's Avatar

Join Date: May 2008
Location: Germany
Posts: 251
Reputation: 18729
Rep Power: 239
ZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UCZeaS Will always be a legend at UC
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (12)
Awarded to members who have donated 10 times or more. Gratuity (1)
Points: 13,610, Level: 15
Points: 13,610, Level: 15 Points: 13,610, Level: 15 Points: 13,610, Level: 15
Activity: 19.5%
Activity: 19.5% Activity: 19.5% Activity: 19.5%
Last Achievements
Quote:
Originally Posted by thelick View Post
Right thx little,similar of what i'm doing with the OS check for the addies of op7
or you could create a "emtpy" function, getting the current bytes and writing them into it so you would not need 2 caves and you will not need a os check : )
__________________

ZeaS is online now

Reply With Quote

Old 08-31-2010, 05:49 PM   #8
h4x0!2

thelick's Avatar

Join Date: Jul 2010
Posts: 95
Reputation: 1050
Rep Power: 31
thelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of rep
Points: 1,473, Level: 3
Points: 1,473, Level: 3 Points: 1,473, Level: 3 Points: 1,473, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by ZeaS View Post
or you could create a "emtpy" function, getting the current bytes and writing them into it so you would not need 2 caves and you will not need a os check : )
Thanks ZeaS
thelick is offline

Reply With Quote

Old 09-01-2010, 02:19 PM   #9
It's Ram Hot

Quicktime's Avatar

Join Date: May 2007
Location: England
Posts: 1,125
Reputation: 18500
Rep Power: 265
Quicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UC
Points: 20,273, Level: 19
Points: 20,273, Level: 19 Points: 20,273, Level: 19 Points: 20,273, Level: 19
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by Shad0w_ View Post
...
Hey,

I've seen this approach work with punkbuster in the past, I am not sure if it was JoshRose or R4z8r who spoke to me about it, they may have also released source-code somewhere on this forum...

Punkbuster would only scan the first 5-10 bytes of directx functions, so you can hook deeper within the function or hook subfunctions, etc. I am not sure if this is still the case however.

Regards,

- Quicktime
Quicktime is offline

Reply With Quote

Old 09-01-2010, 02:26 PM   #10
h4x0!2

thelick's Avatar

Join Date: Jul 2010
Posts: 95
Reputation: 1050
Rep Power: 31
thelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of rep
Points: 1,473, Level: 3
Points: 1,473, Level: 3 Points: 1,473, Level: 3 Points: 1,473, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by Quicktime View Post
Hey,

I've seen this approach work with punkbuster in the past, I am not sure if it was JoshRose or R4z8r who spoke to me about it, they may have also released source-code somewhere on this forum...

Punkbuster would only scan the first 5-10 bytes of directx functions, so you can hook deeper within the function or hook subfunctions, etc. I am not sure if this is still the case however.

Regards,

- Quicktime
Almost sure we are talking about hackshield
thelick is offline

Reply With Quote

Old 09-01-2010, 02:48 PM   #11
UnKnoWnCheaTeR

disavow's Avatar

Threadstarter
Join Date: Jul 2009
Posts: 1,068
Reputation: 49844
Rep Power: 551
disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
Points: 31,279, Level: 26
Points: 31,279, Level: 26 Points: 31,279, Level: 26 Points: 31,279, Level: 26
Activity: 13.8%
Activity: 13.8% Activity: 13.8% Activity: 13.8%
Last Achievements
As far as i'm aware it still works with punkbuster also.
Prehaps all anti detections tools except the latest version of gameguard.
SubFunctions work but that can go into a different sort of territory.

Once you go through there actual function calls and conditional jumps, there is much more that can be modified within the function without triggering a scan.
Once people learn a basic midfunction technique like this I guess they can be more creative and look into these options.
__________________

Shad0w_'s Alter Ego

Last edited by disavow; 09-01-2010 at 03:17 PM.
disavow is online now

Reply With Quote

Old 09-01-2010, 03:09 PM   #12
It's Ram Hot

Quicktime's Avatar

Join Date: May 2007
Location: England
Posts: 1,125
Reputation: 18500
Rep Power: 265
Quicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UCQuicktime Will always be a legend at UC
Points: 20,273, Level: 19
Points: 20,273, Level: 19 Points: 20,273, Level: 19 Points: 20,273, Level: 19
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by thelick View Post
Almost sure we are talking about hackshield
Yes I know this thread is directed at Hackshield... I was just pointing out that the code may have additional uses...

Quote:
Originally Posted by Shad0w_ View Post
...
Thanks for pointing this out!

Cheers,

- Quicktime
Quicktime is offline

Reply With Quote

Old 11-18-2011, 05:37 AM   #13
n00bie

z4y4's Avatar

Join Date: Jun 2011
Posts: 1
Reputation: 10
Rep Power: 8
z4y4 has made posts that are generally average in quality
Points: 353, Level: 1
Points: 353, Level: 1 Points: 353, Level: 1 Points: 353, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
help..
how to insert the midfunction hook into my base..??
My base hook
Quote:
Code:
 typedef HRESULT    ( WINAPI* oEndScene )( LPDIRECT3DDEVICE9 pDevice );
oEndScene pEndScene;

HRESULT APIENTRY myEndScene( LPDIRECT3DDEVICE9 pDevice )
{
        PostReset(pDevice);
        Menu.ShowMenu(pDevice);
        PreReset(pDevice);
    return pEndScene( pDevice );
}
PVOID D3Ddiscover(void *tbl, int size)
{
    HWND                  hWnd;
    void                  *pInterface=0 ;
    D3DPRESENT_PARAMETERS d3dpp;

    if ((hWnd=CreateWindowEx(NULL,WC_DIALOG,"",WS_OVERLAPPED,0,0,50,50,NULL,NULL,NULL,NULL))==NULL) return 0;
    ShowWindow(hWnd, SW_HIDE);

    LPDIRECT3D9            pD3D;
    LPDIRECT3DDEVICE9    pD3Ddev;
    if ((pD3D = Direct3DCreate9(D3D_SDK_VERSION))!=NULL)

    {
        ZeroMemory(&d3dpp, sizeof(d3dpp));
        d3dpp.Windowed         = TRUE;
        d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
        d3dpp.hDeviceWindow    = hWnd;
        d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
        d3dpp.BackBufferWidth  = d3dpp.BackBufferHeight = 600;
        pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pD3Ddev);
        if (pD3Ddev)  {
            pInterface = (PDWORD)*(DWORD *)pD3Ddev;
            memcpy(tbl,(void *)pInterface,size);
            pD3Ddev->Release();
        }
        pD3D->Release();
    }
    DestroyWindow(hWnd);
    return pInterface;
}
int D3D(void)
{
    HINSTANCE    hD3D;
    DWORD        vTable[2520/24];
    hD3D=0;
    do {
        hD3D = GetModuleHandle("d3d9.dll");
        if (!hD3D) Sleep(553000);
    } while(!hD3D);


    if (D3Ddiscover((void *)&vTable[0],23520/56)==0) return 0;
    {
       
        while(1)
        {
        if(memcmp((void*)vTable[7134/87],(void*)(PBYTE)"\x8B\xFF",128/64)== 0)
        {
            pDrawIndexedPrimitive    = (oDrawIndexedPrimitive)    DetourCreate((PBYTE)vTable[7134/87], (PBYTE)myDrawIndexedPrimitive, 245/49);
            pEndScene = (oEndScene) DetourCreate((PBYTE) vTable[1554/37], (PBYTE)myEndScene,245/49);
        }
    Sleep(55300);
    }
    return -1;
    }   

}
char* cBase::GetFile(char *file)
{
    static char path[320];
    for(int i= 0;i<strlen(path);i++)
        path[i]=0;
    strcpy(path, Base.dllpath);
    strcat(path, file);
    return path;
}
BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved)
{
    DisableThreadLibraryCalls(hDll);
    if (dwReason == DLL_PROCESS_ATTACH)
    /*CheckValidHardwareID();*/
    {
        MessageBox (0,"====================================================================\n\n                                    =||>>>>zkyE D3D Menu<<<<||=\n\n====================================================================\n\nFITUR        :\n\n     >  WH CHAMS\n\n     >  HEAD CHAMS\n\n     >  WEAPON CHAMS\n\n     >  WH BENING\n\n     >  WH Glass (WH Biasa)\n\n     >  Phantom\n\n     >  Wireframe\n\n     >  Anti VoteKick   F1 = On / F2 = Off\n\n     >  Crosshair \n\n\n\nCreator :                                                          |== zAyA rAztA ==|\n\n====================================================================","                                   ==|| ™ zkyE (zaya@N3) zAyA rAztA ™ ||==", MB_OK);
       
        CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3D, NULL, NULL, NULL);

    }   
    return TRUE;
}

Last edited by z4y4; 11-18-2011 at 11:39 AM.
z4y4 is offline

Reply With Quote

Old 02-04-2012, 08:44 AM   #14
n00bie

TheGoogle's Avatar

Join Date: May 2011
Posts: 10
Reputation: 10
Rep Power: 10
TheGoogle has made posts that are generally average in quality
Points: 631, Level: 1
Points: 631, Level: 1 Points: 631, Level: 1 Points: 631, Level: 1
Activity: 3.5%
Activity: 3.5% Activity: 3.5% Activity: 3.5%
Last Achievements
error

1>.\Direct3D.cpp(55) : error C2041: illegal digit 'C' for base '10'

mov dword ptr ss:[ebp-1C], edi; // c can not be used
__________________
Super Jenius Search Engine
TheGoogle is online now

Reply With Quote

Old 02-08-2012, 08:21 AM   #15
n00bie

TheGoogle's Avatar

Join Date: May 2011
Posts: 10
Reputation: 10
Rep Power: 10
TheGoogle has made posts that are generally average in quality
Points: 631, Level: 1
Points: 631, Level: 1 Points: 631, Level: 1 Points: 631, Level: 1
Activity: 3.5%
Activity: 3.5% Activity: 3.5% Activity: 3.5%
Last Achievements
dwEndscene_hook = vtable [42] + 0x36; / / mid function

How do you get 0x36; please let me know
__________________
Super Jenius Search Engine
TheGoogle is online now

Reply With Quote

Old 02-08-2012, 08:23 AM   #16
Moderator

Little's Avatar

Join Date: Nov 2009
Posts: 253
Reputation: 5217
Rep Power: 85
Little DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATSLittle DEFINES UNKNOWNCHEATS
Points: 3,764, Level: 6
Points: 3,764, Level: 6 Points: 3,764, Level: 6 Points: 3,764, Level: 6
Activity: 56.3%
Activity: 56.3% Activity: 56.3% Activity: 56.3%
Last Achievements
he's hooking 0x36 bytes into the function... take a look at the function in d3d9.dll
Little is online now

Reply With Quote
Reply  

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit



Tags
hook, midfunction
Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +1. The time now is 07:48 AM.