[Tutorial]Creating D3D8 Base | Wallhack

10/15/2012 15:47 Mαrrα#1
INSTALLING VISUAL C++ 2008

LINK : [Only registered and activated users can see links. Click Here To Register...]
HOW-TO : Select Visual C++ 2008 Express Edition under Visual Studios 2008 Express and click Free Download

INSTALLING DIRECT-X SDK


LINK : [Only registered and activated users can see links. Click Here To Register...]
HOW-TO : Click download and install this SDK

ADDING DIRECT-X INCLUDE FILES IN VC++

STEP 1. Install Direct-X SDK
STEP 2. Open VC++
STEP 3. Select Tools -> Option -> Projects and Solutions -> VC++ Directories
STEP 4. In VC ++ Directories, go to the drop-down menu and select Include Files
STEP 5. Add the code below
Code:
C:\Program Files\Microsoft DirectX 9.0 SDK (Summer 2004)\Include
ADDING DIRECT-X LIBRARY FILES IN VC++

STEP 1. Install Direct-X SDK
STEP 2. Open VC++
STEP 3. Select Tools -> Option -> Projects and Solutions -> VC++ Directories
STEP 4. In VC ++ Directories, go to the drop-down menu and select Library Files
STEP 5. Add the code below
Code:
C:\Program Files\Microsoft DirectX 9.0 SDK (Summer 2004)\Lib
Here's a tutorial on how to create a d3d8 / Sudden attack base!

Open up Visual C++ 2008
Create: Project...
Choose Win32 Console Application
If you do not see it, look at Project types and click on Visual C++

Screenshot

[Only registered and activated users can see links. Click Here To Register...]

You should see the picture below be presented on your Visual C++
Press NEXT

Screenshot

[Only registered and activated users can see links. Click Here To Register...]

Do not touch anything else. Application type - Select "DLL"
Press FINISH

Screenshot

[Only registered and activated users can see links. Click Here To Register...]

You should see the screenshot below presented on your Visual C++
Right click and remove dllmain.cpp*
* - Remove because it is already defined in the base source I will give you.

Screenshot

[Only registered and activated users can see links. Click Here To Register...]

Click the green arrow on the top to debug / release. Alternately, you can just build / rebuild (for those who know how to use C++ IDE)

Screenshot

[Only registered and activated users can see links. Click Here To Register...]

Base Source Code

Code:
#include "stdafx.h"
#include <windows.h>

#include <d3d8.h>
#pragma comment(lib, "d3d8.lib")

typedef HRESULT (WINAPI* CreateDevice_Prototype)        (LPDIRECT3D8, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, LPDIRECT3DDEVICE8*);
typedef HRESULT (WINAPI* Reset_Prototype)               (LPDIRECT3DDEVICE8, D3DPRESENT_PARAMETERS*);
typedef HRESULT (WINAPI* EndScene_Prototype)            (LPDIRECT3DDEVICE8);
typedef HRESULT (WINAPI* DrawIndexedPrimitive_Prototype)(LPDIRECT3DDEVICE8, D3DPRIMITIVETYPE, UINT, UINT, UINT, UINT);

CreateDevice_Prototype         CreateDevice_Pointer         = NULL;
Reset_Prototype                Reset_Pointer                = NULL;
EndScene_Prototype             EndScene_Pointer             = NULL;
DrawIndexedPrimitive_Prototype DrawIndexedPrimitive_Pointer = NULL;

HRESULT WINAPI Direct3DCreate8_VMTable    (VOID);
HRESULT WINAPI CreateDevice_Detour        (LPDIRECT3D8, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, LPDIRECT3DDEVICE8*);
HRESULT WINAPI Reset_Detour               (LPDIRECT3DDEVICE8, D3DPRESENT_PARAMETERS*);
HRESULT WINAPI EndScene_Detour            (LPDIRECT3DDEVICE8);
HRESULT WINAPI DrawIndexedPrimitive_Detour(LPDIRECT3DDEVICE8, D3DPRIMITIVETYPE, UINT, UINT, UINT, UINT);

PDWORD Direct3D_VMTable = NULL; 

BOOL WINAPI DllMain(HINSTANCE hinstModule, DWORD dwReason, LPVOID lpvReserved)
{
  if(dwReason == DLL_PROCESS_ATTACH)
  {
    DisableThreadLibraryCalls(hinstModule);

    if(Direct3DCreate8_VMTable() == D3D_OK)
    return TRUE;
  }

  return FALSE;
}

HRESULT WINAPI Direct3DCreate8_VMTable(VOID)
{
  LPDIRECT3D8 Direct3D_Object = Direct3DCreate8(D3D_SDK_VERSION);

  if(Direct3D_Object == NULL)
  return D3DERR_INVALIDCALL;
  
  Direct3D_VMTable = (PDWORD)*(PDWORD)Direct3D_Object;
  Direct3D_Object->Release();

  DWORD dwProtect;

  if(VirtualProtect(&Direct3D_VMTable[15], sizeof(DWORD), PAGE_READWRITE, &dwProtect) != 0)
  {
    *(PDWORD)&CreateDevice_Pointer = Direct3D_VMTable[15];
    *(PDWORD)&Direct3D_VMTable[15] = (DWORD)CreateDevice_Detour;

    if(VirtualProtect(&Direct3D_VMTable[15], sizeof(DWORD), dwProtect, &dwProtect) == 0)
    return D3DERR_INVALIDCALL;
  }
  else
  return D3DERR_INVALIDCALL;

  return D3D_OK;
}

HRESULT WINAPI CreateDevice_Detour(LPDIRECT3D8 Direct3D_Object, UINT Adapter, D3DDEVTYPE DeviceType, HWND FocusWindow, 
					DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* PresentationParameters, 
					LPDIRECT3DDEVICE8* Returned_Device_Interface)
{
  HRESULT Returned_Result = CreateDevice_Pointer(Direct3D_Object, Adapter, DeviceType, FocusWindow, BehaviorFlags, 
	                                          PresentationParameters, Returned_Device_Interface);

  DWORD dwProtect;

  if(VirtualProtect(&Direct3D_VMTable[15], sizeof(DWORD), PAGE_READWRITE, &dwProtect) != 0)
  {
    *(PDWORD)&Direct3D_VMTable[15] = *(PDWORD)&CreateDevice_Pointer;
    CreateDevice_Pointer           = NULL;

    if(VirtualProtect(&Direct3D_VMTable[15], sizeof(DWORD), dwProtect, &dwProtect) == 0)
    return D3DERR_INVALIDCALL;
  }
  else
  return D3DERR_INVALIDCALL;

  if(Returned_Result == D3D_OK)
  {
    Direct3D_VMTable = (PDWORD)*(PDWORD)*Returned_Device_Interface;

    *(PDWORD)&Reset_Pointer                = (DWORD)Direct3D_VMTable[14];
    *(PDWORD)&EndScene_Pointer             = (DWORD)Direct3D_VMTable[35];
    *(PDWORD)&DrawIndexedPrimitive_Pointer = (DWORD)Direct3D_VMTable[71];

    *(PDWORD)&Direct3D_VMTable[14] = (DWORD)Reset_Detour;
    *(PDWORD)&Direct3D_VMTable[35] = (DWORD)EndScene_Detour;
    *(PDWORD)&Direct3D_VMTable[71] = (DWORD)DrawIndexedPrimitive_Detour;
  }
    
  return Returned_Result;
}

HRESULT WINAPI Reset_Detour(LPDIRECT3DDEVICE8 Device_Interface, D3DPRESENT_PARAMETERS* PresentationParameters)
{
  return Reset_Pointer(Device_Interface, PresentationParameters);
}

HRESULT WINAPI EndScene_Detour(LPDIRECT3DDEVICE8 Device_Interface)
{
  return EndScene_Pointer(Device_Interface);
}

HRESULT WINAPI DrawIndexedPrimitive_Detour(LPDIRECT3DDEVICE8 Device_Interface, D3DPRIMITIVETYPE Type, 
                                           UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
{
  LPDIRECT3DVERTEXBUFFER8 Stream_Data;
  UINT Stride = 0;

  if(Device_Interface->GetStreamSource(0, &Stream_Data, &Stride) == D3D_OK)
  Stream_Data->Release();
  //code
  return DrawIndexedPrimitive_Pointer(Device_Interface, Type, MinIndex, NumVertices, StartIndex, PrimitiveCount);
}
How to add WALLHACK
Look at this piece of code right here in the base

Code:
HRESULT WINAPI DrawIndexedPrimitive_Detour(LPDIRECT3DDEVICE8 Device_Interface, D3DPRIMITIVETYPE Type, 
                                           UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
{
  LPDIRECT3DVERTEXBUFFER8 Stream_Data;
  UINT Stride;

  if(Device_Interface->GetStreamSource(0, &Stream_Data, &Stride) == D3D_OK)
  Stream_Data->Release();
  //code
  return DrawIndexedPrimitive_Pointer(Device_Interface, Type, MinIndex, NumVertices, StartIndex, PrimitiveCount);
}
Now, look more closely at the following.
Code:
//code
INFO
Stride 40 and 44 are the body model of Sudden Attack. (One's upper, one's lower)
WALL HACK ---
Add this below the "//code"
Code:
bool wallhack;
if(Stride == 40 && wallhack || Stride == 44 && wallhack)
{
   Device_Interface->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
To make this work, you need to add a hotkey.

Add this below the wallhack code.
Code:
if ((GetAsyncKeyState(VK_NUMPAD1)&1) == 1) //Numpad 1
     wallhack = !wallhack;//Start Wallhack
If you press NUMPAD 1, wallhack will start.


Credits:
Voltage552
Match*Star.
10/17/2012 08:02 takechi1#2
after you have the dll code done how do u inject it?
10/17/2012 14:26 Mαrrα#3
Quote:
Originally Posted by takechi1 View Post
after you have the dll code done how do u inject it?
You will compile it and you can inject it using an injector.
10/22/2012 16:34 jeff14#4
Hi marra, CAn u make wallhack in specialforce dfi and teach me how to compile i know you are a good coder i this section :) Please O.O

because im new to c++ i dont know how to get the code of sf please i need chams source code only...
10/28/2012 04:49 cina08#5
where do i fine the dll hack after i made one???

doesent work :)
10/28/2012 14:39 Mαrrα#6
This tutorial is for people who wanna learn how to make a d3d8 base.
And who has the knowledge who want to create their own.
This doesn't mean that after you compile this is it's already working or detected.

Note: This is a tutorial only and not a working hack.
11/02/2012 18:35 HaloRan#7
Thanks ^_^ this one is what I need xD

Quote:
Originally Posted by Mαrrα View Post
This tutorial is for people who wanna learn how to make a d3d8 base.
And who has the knowledge who want to create their own.
This doesn't mean that after you compile this is it's already working or detected.

Note: This is a tutorial only and not a working hack.
well, you know how to make it working right? I kinda needing some info about this kind of stuff ^_^