Code:
// Project : Topblast Menu Base v1.1
// Author : Topblast
// Date : 25 August 2010
//
// Credits :
// To : MPGH, Gellins, Han211, Void, mmbob, Microsoft
//
// Tools used:
// Microsoft Visual Studio 2010 ULTIMATE
// DirectX9 SDK Update (summer 2004)
// D3Dfont.cpp / D3dx9.h & d3dx9.lib
//
// This Base can now support 2 different fonts. switch between dont anytime.
#include "Main.h"
#ifdef D3DFont
#include "d3dfont9.cpp"
#endif
FONT pFont=NULL;
D3DSlider *pSlide;
pD3DdeviceX g_pDevice = 0;
oPresent pPresent;
oDrawIndexedPrimitive SDrawIndexedPrimitive;
oBeginScene pBeginScene;
oEndScene pEndScene;
oReset pReset;
void PreReset(pD3DdeviceX pDevice)
{
If pFont Then
pFont = NULL;
_End
If g_pDevice != pDevice Then
g_pDevice = pDevice;
#ifdef D3DFont
#else
Try
If pFont != 0 Then
pFont->Release();
_End
Catch(...) _End
#endif
pFont = NULL;
_End
}
void PostReset(pD3DdeviceX pDevice)
{
#ifdef D3DFont
pFont = new CD3DFont("Arial", 10, D3DFONT_BOLD);
If pFont Then
pFont->InitDeviceObjects(pDevice);
pFont->RestoreDeviceObjects();
_End
#else
D3DXCreateFontA(pDevice, 20, 10, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN, "Arail", &pFont);
#endif
}
HRESULT WINAPI myReset ( pD3DdeviceX pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )
{
PreReset(pDevice);
return pReset(pDevice, pPresentationParameters);
}
HRESULT WINAPI myPresent (pD3DdeviceX pDevice,CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
If pFont==NULL Then
PostReset(pDevice); // Create font
Else
DoMenu(pDevice);
_End
return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
HRESULT WINAPI myEndScene ( pD3DdeviceX pDevice )
{
// RenderFrame();
return pEndScene(pDevice);
}
HRESULT WINAPI myBeginScene ( pD3DdeviceX pDevice ){
// RenderFrame();
return pBeginScene(pDevice);
}
Integer D3D_Hook(void)
{
DWORD *vtbl;
// wait for the d3dx dll
DWORD hD3D=0;
do {
hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
Sleep(10);
} while(!hD3D);
DWORD adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
If adr Then
memcpy(&vtbl,(void *)(adr+2),4);
pReset = (oReset) DetourFunction((PBYTE)vtbl[RESET] , (PBYTE)myReset );
pPresent = (oPresent) DetourFunction((PBYTE)vtbl[PRESENT] , (PBYTE)myPresent );
pBeginScene = (oBeginScene) DetourFunction((PBYTE)vtbl[BEGINSCENE] , (PBYTE)myBeginScene );
pEndScene = (oEndScene) DetourFunction((PBYTE)vtbl[ENDSCENE] , (PBYTE)myEndScene );
_End
return 0;
}
BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
{
DisableThreadLibraryCalls(hDll);
If dwReason == DLL_PROCESS_ATTACH Then
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3D_Hook, NULL, NULL, NULL);
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HACKthread, NULL, NULL, NULL);
_End
return TRUE;
}
D3DMenu *pMenu=NULL;
D3DSlider *pFly=NULL;
Integer CF_Visual;
Integer CH_back;
Integer CF_Memory;
int wallcharms;
int charms;
int wallframe;
int pointmode;
int wallpoint;
int crosshair;
int HackWall=0;
int GhostCharms=0;
int PhantomCharms=0;
int NoFog=0;
int GlassWall=0;
int CrossHair=0;
int WhiteWall=0;
int SeeGhost=0;
int WireFrame=0;
int stw=0;
int chams=0;
int asus=0;
int naked=0;
int swire=0;
int xray=0;
Integer NoReload;
char sFPS[20];
char *opt_Grp[] = { ("+"),("-") };
char *opt_OffOn[] = { ("Off"),("On") };
char *opt_cham[] = { ("Off"),("NX Chams"),("Normal Cham"), ("Color Cham")};//, ("Custom Cham"), ("Front Color")};
char *opt_CRSHAR[] = { ("Off"),("Blue"),("Green"),("Red")};
// --- simple FPS vars and function
int FPScounter = 0;
float FPSfLastTickCount = 0.0f;
float FPSfCurrentTickCount;
void FPScheck(char *str, char *format)
{
FPSfCurrentTickCount = (clock() * 0.001f);
FPScounter++;
if((FPSfCurrentTickCount - FPSfLastTickCount) > 1.0f) {
FPSfLastTickCount = FPSfCurrentTickCount;
sprintf(str,format,FPScounter);
FPScounter = 0;
}
}
void MakeMenu(void){
pMenu->AddText("Framerate", sFPS);
pMenu->AddItem( ("RemoveHackTool") ,&HackToolRemover , opt_OffOn);
pMenu->AddGroup( ("[Visual]") , &CF_Visual, opt_Grp);
if (CF_Visual) {
pMenu->AddItem(("X-Ray") ,&xray , opt_OffOn);
pMenu->AddItem(("Wall-Frame") ,&wallframe , opt_OffOn);
pMenu->AddItem(("Wall-Point") ,&wallpoint , opt_OffOn);
pMenu->AddItem(("Wall-Charms") , &wallcharms , opt_OffOn);
pMenu->AddItem(("Wall-Hack") , &HackWall , opt_OffOn);
pMenu->AddItem(("Full-Bright") , &SeeGhost , opt_OffOn);
pMenu->AddItem(("NM-Chams") ,&charms , opt_OffOn);
pMenu->AddItem(("Ghost-Chams") ,&GhostCharms , opt_OffOn);
pMenu->AddItem(("Phantom-Chams") ,&PhantomCharms , opt_OffOn);
pMenu->AddItem(("No-Fog") ,&NoFog , opt_OffOn);
pMenu->AddItem(("Glass-Wall") ,&GlassWall , opt_OffOn);
pMenu->AddItem(("Wire-Point") ,&pointmode , opt_OffOn);
pMenu->AddItem(("Wire-Frame") , &WireFrame , opt_OffOn);
pMenu->AddItem(("Semi-Wire-Frame") ,&swire , opt_OffOn);
pMenu->AddItem(("Asus-Player") , &asus , opt_OffOn);
pMenu->AddItem(("Naked-Bodys") , &naked , opt_OffOn);
}
pMenu->AddGroup( ("[Memory]") , &CF_Memory, opt_Grp);
if (CF_Memory){
pMenu->AddItem(("NoReload") , &NoReload , opt_OffOn);
}
}
void DoMenu(pD3DdeviceX pDevice)
{
if (pMenu==0) { // first time , create the menu
pMenu = new D3DMenu("MegaR D3D Ru Crossfire",100,150); // title, maxitems,width
pMenu->visible=1; // make it visible
pMenu->col_title=0xffffffff; // change title color to white
} else {
D3DCOLOR xcolor;
switch(Hair){
case 0: xcolor = D3DCOLOR_ARGB( 255, 0, 0, 255 );
break;
case 1: xcolor = D3DCOLOR_ARGB( 255, 0, 0, 255 );
break;
case 2: xcolor = D3DCOLOR_ARGB( 255, 0, 255, 0 );
break;
case 3: xcolor = D3DCOLOR_ARGB( 255, 255, 0, 0 );
break;
}
if( Hair > 0 ){
int size = 20, strong = 2;
D3DVIEWPORT9 viewP;
pDevice->GetViewport( &viewP );
int iCenterX = (viewP.Width / 2) - 1;
int iCenterY = (viewP.Height / 2) -1;
if( iCenterX < 20 && iCenterY < 20 )
{
iCenterX = ( GetSystemMetrics( 0 ) / 2 );
iCenterY = ( GetSystemMetrics( 1 ) / 2 );
}
D3DRECT rec2 = { iCenterX- size, iCenterY, iCenterX+ size, iCenterY+ strong};
D3DRECT rec3 = { iCenterX, iCenterY- size, iCenterX+ strong,iCenterY+ size};
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 0, 0);
pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 0, 0);
}
FPScheck(sFPS,"%d Fps");
If pMenu->noitems==0 Then
MakeMenu();
_End
pMenu->Show(pFont, pDevice);
pMenu->Nav();
}
}
DWORD WINAPI HACKthread( LPVOID param ){
while(True){
#define WeaponMgr 0xABE2AC
#define NoRld 0x2454
DWORD CShell = (DWORD)GetModuleHandleA("CShell.dll");
DWORD pWeaponMgr = *(DWORD*)(CShell + WeaponMgr);
if (NoReload !=0)
if (pWeaponMgr)
{
for(int i=0; i<445; i++)
{
if((*(DWORD*)((*(DWORD*)(CShell+WeaponMgr))+(4*i)) ) != NULL)
*(float*)((*(DWORD*)((*(DWORD*)(CShell+WeaponMgr)) +(4*i))) + NoRld) = 100;
}
}
Sleep(100);
}}
DrawIndexedPrimitive_ pDrawIndexedPrimitive;
LPDIRECT3DTEXTURE9 Red,Yellow,Green,Blue,Purple,Pink,Orange,Black,White;
HRESULT WINAPI nDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
{
IDirect3DVertexBuffer9* pStreamData = NULL;
UINT iOffsetInBytes,iStride;
pDevice->GetStreamSource(0,&pStreamData,&iOffsetInBytes,&iStride);
if ( naked == 1 )
{
if(iStride==44)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
if(iStride==40)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
if(iStride==32)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
}
if (swire ==1)
{
if (iStride==44)
{
pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
}
if (iStride==40)
{
pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
}
if (iStride==32)
{
pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
}
}
if(xray ==1)
{
if(iStride==28)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
}
if ( iStride == 44 &&charms==1)
{
pDevice->SetRenderState(D3DRS_ZENABLE,false);
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
pDevice->SetRenderState(D3DRS_AMBIENT,0x6698FF);
pDevice->SetTexture(0,NULL);
pDevice->SetRenderState(D3DRS_ZENABLE, true);
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
pDevice->SetRenderState(D3DRS_AMBIENT, 0x6698FF);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
if ( iStride == 24 &&wallcharms==1)
{
pDevice->SetRenderState(D3DRS_ZENABLE,false);
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
pDevice->SetRenderState(D3DRS_AMBIENT,0x6698FF);
pDevice->SetTexture(0,NULL);
pDevice->SetRenderState(D3DRS_ZENABLE, true);
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
pDevice->SetRenderState(D3DRS_AMBIENT, 0x6698FF);
}
if ( iStride == 24 &&wallframe==1)
{
pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
}
if ( iStride == 24 &&wallpoint==1)
{
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_POINT);
}
if ( iStride == 44 &&pointmode==1)
{
pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_POINT);
}
if ( iStride == 44 &&HackWall==1)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
if ( iStride == 44 &&NoFog==1)
{
pDevice->SetRenderState(D3DRS_FOGENABLE, false);
}
if ( iStride == 44 &&GhostCharms==1)
{
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);////
pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);////
pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCCOLOR);////
pDevice->SetRenderState(D3DRS_ZENABLE,false);
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);////
pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);////
pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCCOLOR);////
pDevice->SetRenderState(D3DRS_ZENABLE,true);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
if ( iStride == 44 &&PhantomCharms==1)
{
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);
pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCALPHA);
pDevice->SetRenderState(D3DRS_ZENABLE,false);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
if ( iStride == 24 &&GlassWall==1)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
if ( iStride == 44 &&WireFrame==1)
{
pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
}
if ( iStride == 44 &&SeeGhost==1)
{
pDevice->SetRenderState(D3DRS_LIGHTING, false); //d3d lighting off
pDevice->SetRenderState(D3DRS_AMBIENT,D3DCOLOR_ARGB(255,255,255,255)); //
}
if(asus)
{
if(iStride==28)
{
pDevice->SetRenderState( D3DRS_SRCBLEND, 3 );
pDevice->SetRenderState( D3DRS_DESTBLEND, 4 );
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
}
if(iStride==44)
{
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
if(iStride==40)
{
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
if(iStride==32)
{
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
}
return pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
}
HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
{
if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex, NULL)) )
return E_FAIL;
WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)
|(WORD)(((colour32>>20)&0xF)<<8)
|(WORD)(((colour32>>12)&0xF)<<4)
|(WORD)(((colour32>>4)&0xF)<<0);
D3DLOCKED_RECT d3dlr;
(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
WORD *pDst16 = (WORD*)d3dlr.pBits;
for(int xy=0; xy < 8*8; xy++)
*pDst16++ = colour16;
(*ppD3Dtex)->UnlockRect(0);
return S_OK;
}
Code:
#ifndef _MAIN_H
#define _MAIN_H
#define VB_CODE //Topblast VB C++ Code
#ifdef VB_CODE
// Topblast VB Code v1.0 For Topblast Base V1.1
#define Integer int
#define Boolean bool
#define True true
#define False false
#define Then ){
#define If \
if(
#define Try \
try{
#define Catch(a) \
}catch(a){
#define Else }else{
#define Else_If \
}else if(
#define _End }
#endif /* VB CODE*/
////////////////////////
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#pragma warning( disable : 4229 )
#pragma warning( disable : 4099 )
#pragma warning( disable : 4996 )
/////////////////////////
#include <windows.h>
#include <Winuser.h>
#include <stdio.h>
#include <fstream>
#include <stdio.h>
#include <time.h>
//////////////////////////
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
#define RESET 16
#define PRESENT 17
#define BEGINSCENE 41
#define ENDSCENE 42
#define DIP 82
#define pD3DdeviceX LPDIRECT3DDEVICE9
#define pD3DvertexX LPDIRECT3DVERTEXBUFFER9
///////Microsoft Detour v1.5////////
#include "detours.h"
#pragma comment (lib, "detours.lib")
/////////Select You Font//////////
#define D3DFont
//#define D3Dx_Font
#ifdef D3DFont
//D3DFont9
#include "d3dfont9.h"
#define FONT CD3DFont*
#else
//D3DxFont
#define FONT LPD3DXFONT
void DrawString(Integer x, Integer y, DWORD color, const char *fmt, LPD3DXFONT g_pFont, DWORD type = DT_NOCLIP);
#endif /* Select Font */
///////////////////////////
typedef HRESULT (WINAPI* oEndScene)(pD3DdeviceX pDevice);
typedef HRESULT ( WINAPI* oReset )( pD3DdeviceX pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );
typedef HRESULT (WINAPI* oDrawIndexedPrimitive)(pD3DdeviceX pDevice, D3DPRIMITIVETYPE PrimType,Integer BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
typedef HRESULT(WINAPI* DrawIndexedPrimitive_)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount);
typedef HRESULT (WINAPI* oBeginScene) (pD3DdeviceX pDevice);
typedef HRESULT (WINAPI* oPresent ) (pD3DdeviceX pDevice,CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion);
///////////////////////////
#include "D3Dslider.h"
#include "Menu.h"
////////////Main Stuff///////////////
void DrawBoxA(pD3DdeviceX pDevice, Integer x, Integer y, Integer w, Integer h, D3DCOLOR BoxColor, D3DCOLOR BorderColor );
Boolean Ready(WORD type=0x005);
void FillRGB( Integer x, Integer y, Integer w, Integer h, D3DCOLOR color, IDirect3DDevice9* pDevice ) ;
void DrawBorder( Integer x, Integer y, Integer w, Integer h, Integer px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice );
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask);
void DoMenu(pD3DdeviceX pDevice);
DWORD WINAPI HACKthread( LPVOID param );
void __cdecl PushToConsole(char* sVal, float value);
#endif /* Main.h */
Help,plz.