PDA

View Full Version : Tutorial: Simple Wallhack



Neg6
24th February 2005, 03:37
Well, there are probably a lot of people like me who are trying to get started, but just can't find a good tutorial.

Well, to start off your going to need to have an OpenGL wrapper. This basically is like a middle man, best illustrated below:

Game - > Calls OpenGL Function -> Calls OpenGL Wrapper -> Calls OpenGL itself

The wrapper allows you to make additions to the function called, such as Disabling blending in a wallhack.

So, onto making the wallhack.

First of all, your going to want to scroll down to the glBegin function. This function is called A LOT. This is what is called before drawing walls, models, guns etc. So, what your going to want to do here is check to see what is being drawn. The paramater sent into glBegin is "mode". This will tell you what is being drawn. Players in COUNTER-STRIKE 1.6 are drawn using the mode GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN and GL_QUADS. What this means is that if we want to make the walls See-Through, we have to check to make sure this is not being drawn. This code is fairly simple and can be done as follows:



if(!(mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN)))


So, this means that if Counter-Strike is drawing a wall, do the following.

For a simple wallhack, you can just disable DEPTH_TEST. What this means is that it no longer checks to see if the wall is in front of the player. This can be done as follows:



glDisable(GL_DEPTH_TEST);


Now we are disabling the depth testing and you can see through walls :D

For some people, you may have to Enable depth testing if its not a wall, which is done as follows:



else
glEnable(GL_DEPTH_TEST);


Now after doing these, you let your wrapper call the real glBegin and your wallhack is done!

Finished code:



if(!(mode==GL_TRIANGLE_STRIP||mode==GL_TRIANGLE_FA N))
glDisable(GL_DEPTH_TEST);
else
glEnable(GL_DEPTH_TEST);

//glBegin true method

Intended for use on:
www.mpcforum.com www.ccoders.cproj.com

doslucky
2nd March 2005, 10:06
Kinda troubling me :(

Here is what I did:


void sys_glBegin (GLenum mode)
{
(*orig_glBegin) (mode);

if ((mode == GL_TRIANGLES || mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN || mode == GL_QUADS))
{
glDisable(GL_DEPTH_TEST);
}
else
{
glEnable(GL_DEPTH_TEST);
}
}


Compiled with 0 errors / 0 warnings, put hte opengl32.dll in my steamapps/email/counter-strike folder, but the wallhack doesnt work.

Did I type something wrong, or did I put hte code in the wrong area of the opengl.cpp?

[EDIT] Fixed it, (*orig_glBegin) (mode); has to go below the if statement.
but I've got another problem: The skybox is also drawn half-way. So when I stare at a wall, it goes half way up then it shows the skybox in front instead of behind.

Couch
2nd March 2005, 16:23
Kinda troubling me :(

Here is what I did:


void sys_glBegin (GLenum mode)
{
(*orig_glBegin) (mode);

if ((mode == GL_TRIANGLES || mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN || mode == GL_QUADS))
{
glDisable(GL_DEPTH_TEST);
}
else
{
glEnable(GL_DEPTH_TEST);
}
}


Compiled with 0 errors / 0 warnings, put hte opengl32.dll in my steamapps/email/counter-strike folder, but the wallhack doesnt work.

Did I type something wrong, or did I put hte code in the wrong area of the opengl.cpp?

[EDIT] Fixed it, (*orig_glBegin) (mode); has to go below the if statement.
but I've got another problem: The skybox is also drawn half-way. So when I stare at a wall, it goes half way up then it shows the skybox in front instead of behind.

You know why that didn't work right? It's because you're calling the original glBegin mode.. so it's going to draw it over the world, so you'd have no wallhack. You have the code to do so but the OpenGL is drawing the world again over it.

doslucky
3rd March 2005, 01:04
Yeah I figured that much but the skybox draws over sometimes

Couch
3rd March 2005, 02:45
Take GL_QUADS out of there, GL_QUADS would be things like boxes etc.. so the skybox = a giant box, it's going to show that through.

doslucky
3rd March 2005, 04:23
I tried that, then my menu dissapeared when I launched counter-strike. And, corect me if im wrong, the skybox is made the same way any wall is made, you place a brush, and texturize it, but with the skybox you must also hollow it out. Thanks though

xqz
3rd March 2005, 13:45
Make a toggle for your hack then so it isnt on allways (in your case , in the menu aswell).

Make a global boolean and call it whatever you like. Then check for those modes in glBegin and if that boolean you made is true...

in SwapBuffers , you check if a key is being pressed once with the following code...


if(GetAsyncKeyState(virtual_keycode)&1==1) {
boolname=!boolname };


Where virtual_keycode is any valid keycode for any key on your keyboard such as VK_F1/VK_F12 , VK_NUMPAD0/VK_NUMPAD9 , VK_ADD etc. Boolname is the name of the global bool you made...

If you want to use the cheat then , press the key you selected once to start it and press it again to toggle it off.

Neg6
4th March 2005, 04:08
And make sure the cheat starts as false then.