Thread: lag?

Results 1 to 6 of 6

Hybrid View

  1. #1
    cubanelite's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    192.168.1.1
    Posts
    138
    Reputation
    81
    Thanks
    113
    My Mood
    Hungover

    lag?

    Why is this code so laggy?... I get like 10 fps when I play.

    Hook.h:
    Code:
    #include "stdafx.h"
    unsigned int CUBANELITE_POINTER[] = { 0xE9 };
    typedef HRESULT(WINAPI *tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *a);
    tReset oReset;
    
    typedef HRESULT(WINAPI *tPresent)(LPDIRECT3DDEVICE9 pDevice, CONST RECT *a, CONST RECT *b, HWND c, CONST RGNDATA *d);
    tPresent oPresent;
    
    DWORD* FindDevice(VOID)
    {
        DWORD Base = (DWORD)LoadLibraryW(L"d3d9.dll");
        for(DWORD i = 0; i < 0x128000; i++ )
        {
          if ( (*(BYTE *)(Base+i+0x00))==0xC7
            && (*(BYTE *)(Base+i+0x01))==0x06
            && (*(BYTE *)(Base+i+0x06))==0x89
            && (*(BYTE *)(Base+i+0x07))==0x86
            && (*(BYTE *)(Base+i+0x0C))==0x89
            && (*(BYTE *)(Base+i+0x0D))==0x86 )
            return (DWORD *)(Base + i + 2);
        }
        return NULL;
    }
    
    
    void *Salta(BYTE *src,const BYTE *dst,const int len){
    BYTE *jmp = (BYTE*)malloc(len+5);
    DWORD dwback;
    VirtualProtect(src, len, PAGE_READWRITE, &dwback);
    memcpy(jmp, src, len); jmp += len;
    jmp[0] = CUBANELITE_POINTER[0];
    *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
    src[0] = CUBANELITE_POINTER[0];
    *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
    VirtualProtect(src, len, dwback, &dwback);
    return (jmp-len);
    }

    Hack.cpp:
    Code:
    #include "stdafx.h"
    #include "Menu.h"
    #include "Hook.h"
    
    /////////////////////////////////////
    #define DeviceGame 0x009118A0
    #define SuperBullet 0x37428FED
    #define WeaponRange1 0x3742E729
    #define WeaponRange2 0x3742EAA9
    #define NoRecoil1 0x373B1E00
    #define NoRecoil2 0x374E07C9
    #define NoRecoil3 0x373B1E14
    #define NoRecoil4 0x373B1E17
    #define NoRecoil5 0x373B1E20
    #define NameTags1 0x373036C9
    #define NameTags2 0x3730374F
    #define RapidFire 0x3742F1A5
    #define GameStatus 0x37806FC4
    #define NoReload 0x3742E4A4
    #define ADDR_CONSOLEUNWRAPPED 0x486030
    /////////////////////////////////////
    
    int PosX = 30;
    int PosY = 70;
    int Posy = 60;
    
    // Chaves Menu
    char* opt_opçoes[] = { "OFF", "ON" };
    
    //Menu
    char MenuTitle[25] = { ".: KC Alliance V1.1 :." }; //Menu Title.
    char Timestruct[25] = { "hh':'mm':'ss tt" };
    char TimeString[25];
    int  MenuSelection;
    int  Current = true;
    bool Menu = true;
    bool bFont;
    
    BOOL IsGameReadyForHook(VOID)
    {
    	if(GetModuleHandle("d3d9.dll") != NULL 
    	&& GetModuleHandle("ClientFX.fxd") != NULL 
    	&& GetModuleHandle("CShell.dll") != NULL)
    		return TRUE;
    
    	return FALSE;
    }
    
    //Hack Variables
    INT cFPS;
    INT Cross;
    INT hack1;
    INT hack2;
    INT hack3;
    INT hack4;
    INT hack5;
    INT hack6;
    INT hack7;
    INT hack8;
    INT hack9;
    INT hack10;
    INT hack11;
    INT hack12;
    INT hack13;
    INT hack14;
    INT hack15;
    INT hack16;
    INT hack17;
    INT hack18;
    INT MoverMenu;
    
    void Memoria( void* pvAddress, void* pvBuffer, size_t len )
    {
    	if( *(BYTE*)pvAddress == *(BYTE*)pvBuffer )
    		return;
    
    	memcpy( ( void* )pvAddress, ( void* )pvBuffer, len );
    }
    
    bool bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask) 
    { 
        for(;*szMask;++szMask,++pData,++bMask) 
        if(*szMask=='x' && *pData!=*bMask )  
        return false; 
        return (*szMask) == NULL; 
    } 
    
    
    ///////////////////////////// PTC ///////////////////////
    void push(const char* Command)
    {
    	void* Console = (void*)ADDR_CONSOLEUNWRAPPED;
    	if(*(BYTE*)GameStatus == 1) 
    	{
    	_asm
    		{
    			call get_eip
    			push Command
    			add eax, 0xF
    			push eax
    			jmp Console
    			add esp, 0x4
    	}
    	return;
    	_asm
    	{
    get_eip:
    		mov eax, [esp]
    		sub eax, 5
    			ret
    		}
    	}
    }
    ////////////////////////// END OF PTC ///////////////////
    
    HRESULT WINAPI hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *a)
    {
    	Directx_Font->OnLostDevice();
    
    	HRESULT hTorna = oReset(pDevice, a);
    
    	if(SUCCEEDED(hTorna))
    		Directx_Font->OnResetDevice();
    
    	return hTorna;
    }
    
    HRESULT WINAPI hkPresent(LPDIRECT3DDEVICE9 pDevice, const RECT *a, const RECT *b, HWND c, const RGNDATA *d)
    {
    	if(Directx_Font) {
    		Directx_Font->Release();
    		Directx_Font = NULL;
    		bFont = false;
    	}
    
    	if(!bFont) {
    		D3DXCreateFont(pDevice, 14, 0, 400, 1, 0, 1, 0, 4, 0 | (0<<4), "Arial", &Directx_Font);
    		bFont = true;
    	}
    
    	if(GetAsyncKeyState(VK_INSERT)&1) Menu = !Menu;	
    
    	if(Menu && Directx_Font) {
    		pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    		GetTimeFormat(NULL, NULL, NULL, NULL, Timestruct, 15);
    
    		DrawBox(PosX - 10, PosY - 22, 162, 20, TBlack, White, pDevice);//Draw box do titulo.
    		DrawBorder(PosX - 10, PosY - 22, 162, 20, 1, White, pDevice);//Borda da box do titulo.
    		DrawText(pDevice, PosX , PosY - 20, White, MenuTitle);// Titulo do hack. MenuTitle declaração, então deve mudar la em cima.
    		sprintf_s(TimeString, "%s", Timestruct);// Relogio.
    		DrawText(pDevice, PosX + 100, PosY - 20, White, TimeString);// Texto do Relogio.	
    		DrawBox(PosX - 10, PosY, 162, 360, TBlack, White, pDevice);// Draw Box Principal //Cada vez que for adicionar uma nova função aumente o INT h (50) em 20 em 20 por exemplo, 50 + 20 = 70, 70 + 20 = 100, Espero que intenda.
    		DrawBorder(PosX - 10, PosY, 162, 360, 1, White, pDevice); //Borda da box principal.
    		DrawBorder(PosX - 10, Posy + 2 + (MenuSelection * 15), 162, 13, 1, White, pDevice); // Selection
    		Current = 1;
    		if(GetAsyncKeyState(VK_UP)&1) 
    			MenuSelection--;
    
    		if(GetAsyncKeyState(VK_DOWN)&1) 
    			MenuSelection++;
    
    			Additem("Super Bullets" , 1, hack1,      0, opt_opçoes, pDevice);
    			Additem("Weapon Range" , 1, hack2,      0, opt_opçoes, pDevice);
    			Additem("No Recoil" , 1, hack3,      0, opt_opçoes, pDevice);
    			Additem("No Spread" , 1, hack9,      0, opt_opçoes, pDevice);
    			Additem("Far Pickup" , 1, hack14,      0, opt_opçoes, pDevice);
    			Additem("Rapid Fire" , 1, hack15,      0, opt_opçoes, pDevice);
    			Additem("Nx Chams" , 1, hack4,      0, opt_opçoes, pDevice);
    			Additem("No Fog" , 1, hack7,      0, opt_opçoes, pDevice);
    			Additem("Full Bright" , 1, hack8,      0, opt_opçoes, pDevice);
    			Additem("WireFrame People" , 1, hack10,      0, opt_opçoes, pDevice);
    			Additem("Tracers" , 1, hack11,      0, opt_opçoes, pDevice);
    			Additem("Player Glow" , 1, hack12,      0, opt_opçoes, pDevice);
    			Additem("Nametags" , 1, hack13,      0, opt_opçoes, pDevice);
    			Additem("No Smoke" , 1, hack17,      0, opt_opçoes, pDevice);
    			Additem("Super Speed" , 1, hack5,      0, opt_opçoes, pDevice);
    			Additem("Super Jump" , 2, hack6,      0, opt_opçoes, pDevice);
    			Additem("Fly" , 1, hack16,      0, opt_opçoes, pDevice);
    			Additem("Removals" , 1, hack18,      0, opt_opçoes, pDevice);
    			Additem("CrossHair", 13, Cross,		0, opt_opçoes, pDevice);
    			Additem("Show FPS" , 1, cFPS,        0, opt_opçoes, pDevice);
    			Additem("Move Menu", 1, MoverMenu,  0, opt_opçoes, pDevice);
    
    		if(MenuSelection >= Current)
    			MenuSelection = 1;
    
    		else if(MenuSelection < 1)
    			MenuSelection = Current;
    	}
    
    	if(*(BYTE *)GameStatus == 1) { if(Cross == 1){CrossHair(pDevice, Red); }}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 2){CrossHair(pDevice, Green); }}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 3){CrossHair(pDevice, Orange);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 4){CrossHair(pDevice, Blue);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 5){CrossHair(pDevice, Yellow);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 6){CrossHair(pDevice, Black);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 7){CrossHair(pDevice, Grey);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 8){CrossHair(pDevice, Gold);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 9){CrossHair(pDevice, Pink);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 10){CrossHair(pDevice, Purple);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 11){CrossHair(pDevice, White);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 12){CrossHair(pDevice, Cyan);}}
    if(*(BYTE *)GameStatus == 1) { if(Cross == 13){CrossHair(pDevice, Magenta);}}
    
     if((*(BYTE *)GameStatus == 1) &&  hack1){
    		memcpy( (PBYTE)SuperBullet, (PBYTE)"\x90\x90\x90", 3); // this is a memory hack.
        }else{
    		memcpy( (PBYTE)SuperBullet, (PBYTE)"\x0F\x94\xC0", 3); // get the off byted by ollydbging the addie.
    	}
    
    
     if((*(BYTE *)GameStatus == 1) && hack2) {
    	memcpy( (PBYTE)WeaponRange1, (PBYTE)"\xB8\x00\x00\x00\x10\x90", 6 );
        memcpy( (PBYTE)WeaponRange2, (PBYTE)"\xB8\x00\x00\x00\x10\x90", 6 );
            }else{
        memcpy( (PBYTE)WeaponRange1, (PBYTE)"\x8B\x80\xC8\x02\x00\x00", 6 ); 
        memcpy( (PBYTE)WeaponRange2, (PBYTE)"\x8B\x80\xC8\x02\x00\x00", 6 );
     }
    
     if((*(BYTE *)GameStatus == 1) && hack3) {
    	 memcpy( (PBYTE)NoRecoil1, (PBYTE)"\x90\x90\x90", 3);
    	 memcpy( (PBYTE)NoRecoil2, (PBYTE)"\x90\x90\x90", 3);
    	 memcpy( (PBYTE)NoRecoil3, (PBYTE)"\x90\x90\x90", 3);
    	 memcpy( (PBYTE)NoRecoil4, (PBYTE)"\x90\x90\x90", 3);
    	 memcpy( (PBYTE)NoRecoil5, (PBYTE)"\x90\x90\x90", 3);
            }else{
        memcpy( (PBYTE)NoRecoil1, (PBYTE)"\xD8\x66\x58", 3);
    	memcpy( (PBYTE)NoRecoil2, (PBYTE)"\xD9\x46\x54", 3);
    	memcpy( (PBYTE)NoRecoil3, (PBYTE)"\xD9\x5E\x58", 3);
    	memcpy( (PBYTE)NoRecoil4, (PBYTE)"\xD9\x46\x4C", 3);
    	memcpy( (PBYTE)NoRecoil5, (PBYTE)"\xD9\x5E\x4C", 3);
     }
    
     if(hack4) {
    	push("SkelModelStencil -1" );
     }else {
    	push("SkelModelStencil 0" );
     }
    
     if(hack5) {
    push("BaseMoveAccel 2000.000000");
    push("StartAccel 2000.000000");
    push("MaxAccel 2000.000000");
    push("AccelInc 2000.000000");
    push("WalkVel 2000.000000");
    push("FRunVel 2000.000000");
    push("BRunVel 2000.000000");
    push("SRunVel 2000.000000");
    push("JumpVel 2000.000000");
    push("DuckVel 2000.000000");
     }else {
    push("WalkVel 70.000000");
    push("FRunVel 285.000000");
    push("BRunVel 285.000000");
    push("SRunVel 285.000000");
    push("DuckVel 50.000000");
     }
    
     if(hack6 == 1) {
    	 push("JumpVel 430.000000" );
     }else {
    	 push("JumpVel 330.000000" );
     }
    
    if(hack6 == 2) {
    	 push("JumpVel 630.000000" );
     }else {
    	 push("JumpVel 330.000000" );
    }
    
     if(hack7) {
    	 push("FogEnable 0" );
     }else {
    	 push("FogEnable 1" );
     }
    
     if(hack8) {
    	 push("FullBright 1" );
     }else {
    	 push("FullBright 0" );
     }
    
     if(hack9){
    	push("PerturbRotationEffect 0.000000");
        push("PerturbIncreaseSpeed 0.000000");
        push("PerturbWalkPercent 0.000000");
        push("PerturbFiringIncreaseSpeed 0.000000");
        push("PerturbRecoil 0.000000");
        push("FireMovePerturb 0.000000");
        push("ZoomedFireMoveDuckPerturb 0.000000");
        push("ZoomedFireMovePerturb 0.000000");
        push("ZoomedFireDuckPerturb 0.000000");
    }else{
    	push("PerturbRotationEffect 3.000000");
        push("PerturbIncreaseSpeed 3.000000");
        push("PerturbDecreaseSpeed 9.000000");
        push("PerturbWalkPercent 0.500000");
        push("PerturbRecoil 9.000000");
        push("FireMovePerturb 9.000000");
        push("ZoomedFireMoveDuckPerturb 9.000000");
        push("ZoomedFireMovePerturb 9.000000");
        push("ZoomedFireDuckPerturb 9.000000");
    }
    
    if(hack10) {
    	push("WireframeModels 1" );
    }else {
    	push("WireframeModels 0" );
    }
    
    if(hack11) {
    	push("ShowFirePath 1" );;
    }else {
    	push("ShowFirePath 0" );
    }
    
    if(hack12){
        push("ScreenGlowEnable 1");
        } else {
        push("ScreenGlowEnable 0");
        }
    
    if((*(BYTE *)GameStatus == 1) && hack13) {
    	memcpy( (PBYTE)NameTags1, (PBYTE)"\x90\x90", 2);
    	memcpy( (PBYTE)NameTags2, (PBYTE)"\x90\x90", 2);
    }else {
    	memcpy( (PBYTE)NameTags1, (PBYTE)"\x75\x05", 2);
    	memcpy( (PBYTE)NameTags2, (PBYTE)"\x75\x05", 2);
    }
    
    if(hack14) {
    			push("ActivationDistance 99999" );
    		}else {
    			push("ActivationDistance 9" );
    }
    
    if((*(BYTE *)GameStatus == 1) && hack15) {
    		if (GetAsyncKeyState(VK_MBUTTON)<0) {
    			memcpy( (PBYTE)RapidFire, (PBYTE)"\x90\x90", 2);
    		}else{
    			memcpy( (PBYTE)RapidFire, (PBYTE)"\x74\x3E", 2);
    		}
    	}
    
    if(hack16) {
    	if( GetAsyncKeyState( VK_SPACE ) < 0 ) {
    			push( "PlayerGravity 800" );
    		}else{
    			push( "PlayerGravity -800" );
    	}
    }
    
    if(hack17) { // if hack 17 is on
    	push("DrawParticles 0"); //Using the ptc method, push the ptc hack into the game
    }else { // if it's not on
    	push("DrawParticles 1"); //turn it off
    } // close hack
    
    if(cFPS){
        push("ShowFps 1");
        } else {
        push("ShowFps 0");
        }
    
    if (hack18) {
    		           //On
    push ("DynamicLight 0");
    push ("EnableWeatherFX 0 ");
    push ("MuzzleLight 0 ");
    push ("SnowEnable 0 ");
    push ("CamDamage 0 ");
    push ("ModelApplySun 0" );
    push ("ClientFXDetailLevel 0" );
    push ("ModelShadow_Proj_Enable 0" );
    push ("DebrisFXLevel 0 ");
    push ("ScatterEnable 0 ");
    push ("modelshadow_proj_blurenable 0 ");
    push ("DrawAllModelShadows 0 ");
    push ("ModelShadow_Proj_MinColorComponent 0" );
    push ("ModelShadow_Proj_MaxProjDist 0 ");
    	}else { 
    push ("DynamicLight 1");
    push ("EnableWeatherFX 1 ");
    push ("MuzzleLight 1 ");
    push ("SnowEnable 1 ");
    push ("CamDamage 1 ");
    push ("ModelApplySun 1" );
    push ("ClientFXDetailLevel 1" );
    push ("ModelShadow_Proj_Enable 1" );
    push ("DebrisFXLevel 1 ");
    push ("ScatterEnable 1 ");
    push ("modelshadow_proj_blurenable 1 ");
    push ("DrawAllModelShadows 1 ");
    push ("ModelShadow_Proj_MinColorComponent 1" );
    push ("ModelShadow_Proj_MaxProjDist 1 ");
    }
    
    	if(MoverMenu) {
    		POINT MyCursor; 
    		GetCursorPos(&MyCursor);
    		PosX = MyCursor.x; 
    		PosY = MyCursor.y;
    		Posy = MyCursor.y - 10;
    	}
    
    	return oPresent(pDevice, a, b, c, d);
    }
    
    DWORD CALLBACK dwD3D9Thread(LPVOID)
    {
    	while( !IsGameReadyForHook() )
    		Sleep(100);
    	return 0;
    }
    
    DWORD WINAPI Hook(LPVOID lpArgs) // this is your Part of your hook
    {
    	DWORD dwD3D9 = 0;
    	do
    	{
    		dwD3D9 = (DWORD)GetModuleHandleA("d3d9.dll");
    		Sleep(10);
    	} 
    	while(!dwD3D9);
    	DWORD* VtablePtr = FindDevice();
        DWORD* VTable;
        *(DWORD*)&VTable = *(DWORD*)VtablePtr;
    	 if(VtablePtr) 
     { 
     oReset = ( tReset ) Salta(( PBYTE ) VTable[16], ( PBYTE ) &hkReset ,5);
     oPresent = ( tPresent ) Salta(( PBYTE ) VTable[17], ( PBYTE ) &hkPresent ,5);
     }
    	 return 0;
    }
    Sorry for the messy coding. Any help is appreciated though, thanks.
    Last edited by cubanelite; 06-04-2012 at 12:44 AM.
    If you have any questions, PM Me. I always check them.
    PEACE, HOMIES!

  2. #2
    realnigger's Avatar
    Join Date
    Apr 2012
    Gender
    male
    Posts
    17
    Reputation
    9
    Thanks
    1
    your creating font, adding menu items, and pushing console commands every frame
    dont do that

  3. #3
    cubanelite's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    192.168.1.1
    Posts
    138
    Reputation
    81
    Thanks
    113
    My Mood
    Hungover
    Quote Originally Posted by real****** View Post
    your creating font, adding menu items, and pushing console commands every frame
    dont do that
    So you're saying to add a rest right before the reset?...
    Code:
    Sleep(10);
    return oPresent(pDevice, a, b, c, d);
    }
    Right?...
    If you have any questions, PM Me. I always check them.
    PEACE, HOMIES!

  4. #4
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,409
    My Mood
    In Love
    Quote Originally Posted by cubanelite View Post
    So you're saying to add a rest right before the reset?...
    Code:
    Sleep(10);
    return oPresent(pDevice, a, b, c, d);
    }
    Right?...
    that will cause a delay between each frame is displayed causing more lag.
    Make a timer, only delay the PTC calls.
    Or, you can just make sure the PTC is only called when the hack is changed.
    No I do not make game hacks anymore, please stop asking.

  5. The Following User Says Thank You to flameswor10 For This Useful Post:

    cubanelite (06-04-2012)

  6. #5
    pDevice's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Location
    d3d9.h
    Posts
    1,306
    Reputation
    15
    Thanks
    420
    My Mood
    Stressed
    very functions PTC



  7. #6
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,409
    My Mood
    In Love
    /closed cause I'm sure you can fix it from now.
    No I do not make game hacks anymore, please stop asking.

Similar Threads

  1. super msn lag
    By Dave84311 in forum General
    Replies: 31
    Last Post: 02-01-2009, 02:48 AM
  2. Ammm I Have Qusetion about lags :O
    By EdenAsus in forum WarRock - International Hacks
    Replies: 7
    Last Post: 07-17-2007, 07:45 PM
  3. net limited pro (lag tool)
    By josser in forum Soldier Front General
    Replies: 4
    Last Post: 07-10-2007, 05:59 PM
  4. warrock lag
    By ragman1234 in forum WarRock - International Hacks
    Replies: 0
    Last Post: 04-30-2007, 11:59 PM
  5. Video lag
    By 22061988 in forum WarRock - International Hacks
    Replies: 8
    Last Post: 02-10-2007, 08:29 PM