|

楼主 |
发表于 2016-9-19 15:06:08
|
显示全部楼层
我留一下作弊器的源码  - #include <windows.h>
- #include <math.h>
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glaux.h>
- #include <GL/glext.h>
-
- #pragma comment (lib, "opengl32.lib")
-
- //=====================================================================================
-
- typedef struct _ENTITIES{
- FLOAT Origin[3];
- BYTE Visible;
- BYTE Valid;
- POINT ESP;
- POINT Head;
- FLOAT BoxHeight;
- }ENTITIES,*PENTITIES;
-
- void (APIENTRY* oglBegin)( GLenum mode );
- void (APIENTRY* owglSwapBuffers)( HDC hDC );
- void (APIENTRY* oglPopMatrix)( void );
- void (APIENTRY* oglPushMatrix)( void );
- void (APIENTRY* oglVertex3f)( GLfloat x, GLfloat y, GLfloat z );
- void (APIENTRY* oglTranslatef)( GLfloat x, GLfloat y, GLfloat z );
- void (APIENTRY* oglViewport)( GLint x, GLint y, GLsizei width, GLsizei height );
-
- extern "C" GLint __stdcall ogluProject(GLdouble objX, GLdouble objY, GLdouble objZ,
- const GLdouble *model, const GLdouble *proj, const GLint *view,
- GLdouble* winX, GLdouble* winY, GLdouble* winZ);
-
- HMODULE GL32DLL = NULL;
-
- FLOAT fCamera[3];
- FLOAT fLastPosition[3];
- FLOAT fHighestVertex[3];
- FLOAT fLowestVertex[3];
- FLOAT fCenterVertex[3];
-
- INT Viewport[4];
- INT MatrixDepth = 0;
- INT VertexCount3f = 0;
- INT MaxEnts = 0;
- double The_Double =
- 0.5000000000000000;
-
- BOOL Found_An_Entity = FALSE;
- bool Aimthrough = false;
-
- ENTITIES Ents[33] = { NULL };
-
- //=====================================================================================
- // MoonBase Chaser343
- float WINAPI GetDistance( float * LocationA, float * LocationB )
- {
- float DistanceX = LocationA[0] - LocationB[0];
- float DistanceY = LocationA[1] - LocationB[1];
- float DistanceZ = LocationA[2] - LocationB[2];
-
- return (float)sqrt( ( DistanceX * DistanceX ) + ( DistanceY * DistanceY ) + ( DistanceZ * DistanceZ ) );
- }
-
- //=====================================================================================
-
- void APIENTRY nglBegin( GLenum mode )
- {
- if( ( mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN )
- && Found_An_Entity == FALSE )
- {
- glDepthRange( 0.0f, 0.5f );
- Found_An_Entity = TRUE;
- }
-
- if( ( mode == GL_POLYGON || mode == GL_TRIANGLES
- || mode == GL_QUADS || mode == GL_QUAD_STRIP )
- && Found_An_Entity == TRUE )
- {
- glDepthRange( 0.0f, 1.0f );
- Found_An_Entity = FALSE;
- }
-
- oglBegin( mode );
- }
-
- //=====================================================================================
-
- void APIENTRY nwglSwapBuffers( HDC hDC )
- {
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
-
- glOrtho( 0, Viewport[2], Viewport[3], 0, 0, 1 );
- glDisable( GL_DEPTH_TEST );
- glMatrixMode ( GL_MODELVIEW );
-
- glPushMatrix( );
- glLoadIdentity();
- glDisable( GL_TEXTURE_2D );
- glTranslatef( 0.375f, 0.375f, 0.0f );
-
- glEnable( GL_BLEND );
- glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-
- for( int i = 0; i < MaxEnts; i++ )
- {
- float x = (float)Ents[i].ESP.x;
- float y = (float)Ents[i].ESP.y;
- float w = 1;
- float h = Ents[i].BoxHeight;
- UCHAR r,g,b,a;
-
- if( Ents[i].Visible == 0x1 )
- {
- r = 20;g = 255;b = 20;a = 200;
- }
- else
- {
- r = 255;g = 255;b = 20;a = 200;
- }
-
- glColor4ub( r, g, b, a );
- glBegin( GL_QUADS );
-
- glVertex2f( x - h - w, y - h - w );
- glVertex2f( x + h + w, y - h - w );
- glVertex2f( x + h + w, y - h );
- glVertex2f( x - h - w, y - h );
-
- glVertex2f( x - h - w, y + h - w );
- glVertex2f( x + h + w, y + h - w );
- glVertex2f( x + h + w, y + h );
- glVertex2f( x - h - w, y + h );
-
- glVertex2f( x - h - w, y - h );
- glVertex2f( x - h, y - h );
- glVertex2f( x - h, y + h );
- glVertex2f( x - h - w, y + h );
-
- glVertex2f( x + h, y - h );
- glVertex2f( x + h + w, y - h );
- glVertex2f( x + h + w, y + h );
- glVertex2f( x + h, y + h );
-
- glEnd( );
- }
-
- float fClosestPos = 999999.0f;
- DWORD TargetX = 0;
- DWORD TargetY = 0;
-
- for( int i = 0; i < MaxEnts; i++ )
- {
- float fTemp[3];
- float ScrCenter[3];
-
- ScrCenter[0] = float(Viewport[2] / 2);
- ScrCenter[1] = float(Viewport[3] / 2);
- ScrCenter[2] = 0.0f;
-
- fTemp[0] = (float)Ents[i].Head.x;
- fTemp[1] = (float)Ents[i].Head.y;
- fTemp[2] = 0.0f;
-
- float nDist = GetDistance( fTemp, ScrCenter );
-
- if( Aimthrough || ( !Aimthrough && Ents[i].Visible == 0x1 ) )
- if( nDist < fClosestPos )
- {
- fClosestPos = nDist;
- TargetX = Ents[i].Head.x;
- TargetY = Ents[i].Head.y;
- }
- }
-
- if( GetAsyncKeyState( VK_XBUTTON2 ) < 0 )
- {
- if( TargetX && TargetY )
- {
- POINT Target;
- DWORD ScrX = Viewport[2] / 2;
- DWORD ScrY = Viewport[3] / 2;
-
- if(TargetX > (ScrX)){
- Target.x = TargetX - (ScrX);
- Target.x /= 4;
- Target.x = +Target.x;
- }
-
- if(TargetX < (ScrX)){
- Target.x = (ScrX) - TargetX;
- Target.x /= 4;
- Target.x = -Target.x;
- }
-
- if(TargetX == (ScrX)){
- Target.x = 0;
- }
-
- if(TargetY > (ScrY)){
- Target.y = TargetY - (ScrY);
- Target.y /= 4;
- Target.y = +Target.y;
- }
-
- if(TargetY < (ScrY)){
- Target.y = (ScrY) - TargetY;
- Target.y /= 4;
- Target.y = -Target.y;
- }
-
- if(TargetY == (ScrY)){
- Target.y = 0;
- }
-
- mouse_event( MOUSEEVENTF_MOVE,
- Target.x, Target.y, NULL, NULL );
- }
- }
-
- glDisable( GL_BLEND );
-
- glPopMatrix( );
- glEnable( GL_TEXTURE_2D );
-
- MaxEnts = 0;
-
- owglSwapBuffers( hDC );
- }
-
- //=====================================================================================
-
- void APIENTRY nglPopMatrix( void )
- {
- oglPopMatrix( );
- MatrixDepth--;
-
- if( VertexCount3f > 550 && GetDistance( fHighestVertex, fCamera ) > 50.0f
- && ( fHighestVertex[2] - fLowestVertex[2] ) > 30.0f )
- {
- double ModelView[16];
- double ProjView[16];
- double View2D[3];
- double Depthcheck[3];
- GLfloat x = 0.0f, y = 0.0f, pix;
- FLOAT fVertexH[3];
- FLOAT fVertexL[3];
- FLOAT BoxH[2];
- FLOAT BoxL[2];
- FLOAT Head[2];
-
- fCenterVertex[0] /= VertexCount3f;
- fCenterVertex[1] /= VertexCount3f;
- fCenterVertex[2] /= VertexCount3f;
-
- fVertexH[0] = fHighestVertex[0];
- fVertexH[1] = fHighestVertex[1];
- fVertexH[2] = fHighestVertex[2];
- fVertexH[2] += 10.0f;
-
- fVertexL[0] = fHighestVertex[0];
- fVertexL[1] = fHighestVertex[1];
- fVertexL[2] = fHighestVertex[2];
- fVertexL[2] -= 10.0f;
-
- Ents[MaxEnts].Visible = 0x0;
-
- glGetDoublev( GL_MODELVIEW_MATRIX, ModelView );
- glGetDoublev( GL_PROJECTION_MATRIX, ProjView ) ;
-
- if( ogluProject( fHighestVertex[0], fHighestVertex[1], fHighestVertex[2] - 4, ModelView, ProjView,
- Viewport, &View2D[0], &View2D[1], &View2D[2] ) == GL_TRUE )
- {
- Head[0] = (float)View2D[0];
- Head[1] = (int)Viewport[3]-(float)View2D[1];
-
- if( ogluProject( fVertexH[0], fVertexH[1], fVertexH[2], ModelView, ProjView,
- Viewport, &View2D[0], &View2D[1], &View2D[2] ) == GL_TRUE )
- {
- BoxH[0] = (float)View2D[0];
- BoxH[1] = (int)Viewport[3]-(float)View2D[1];
-
- if( ogluProject( fVertexL[0], fVertexL[1], fVertexL[2], ModelView, ProjView,
- Viewport, &View2D[0], &View2D[1], &View2D[2] ) == GL_TRUE )
- {
- BoxL[0] = (float)View2D[0];
- BoxL[1] = (int)Viewport[3]-(float)View2D[1];
-
- if( ogluProject( fCenterVertex[0], fCenterVertex[1], fCenterVertex[2], ModelView, ProjView,
- Viewport, &View2D[0], &View2D[1], &View2D[2] ) == GL_TRUE )
- {
- x = (float)View2D[0];
- y = (int)Viewport[3]-(float)View2D[1];
-
- if( ogluProject( fHighestVertex[0], fHighestVertex[1], fHighestVertex[2] + 1, ModelView, ProjView,
- Viewport, &Depthcheck[0], &Depthcheck[1], &Depthcheck[2] ) == GL_TRUE )
- {
- glReadPixels( (int)Depthcheck[0], (int)Depthcheck[1], 1, 1,
- GL_DEPTH_COMPONENT, GL_FLOAT, &pix );
-
- if( pix >= Depthcheck[2] )
- Ents[MaxEnts].Visible = 0x1;
-
- Ents[MaxEnts].Origin[0] = fCenterVertex[0];
- Ents[MaxEnts].Origin[1] = fCenterVertex[1];
- Ents[MaxEnts].Origin[2] = fCenterVertex[2];
-
- Ents[MaxEnts].ESP.x = (LONG)x;
- Ents[MaxEnts].ESP.y = (LONG)y;
-
- Ents[MaxEnts].Head.x = (LONG)Head[0];
- Ents[MaxEnts].Head.y = (LONG)Head[1];
-
- float BoxHeight = BoxL[1] - BoxH[1];
-
- BoxHeight = BoxHeight / 2;
-
- if( BoxHeight < 7 )
- Ents[MaxEnts].BoxHeight = 6;
- else
- Ents[MaxEnts].BoxHeight = BoxHeight;
-
- MaxEnts++;
- }
- }
- }
- }
- }
- }
- fCenterVertex[0] = 0.0f;
- fCenterVertex[1] = 0.0f;
- fCenterVertex[2] = 0.0f;
- }
-
- //=====================================================================================
-
- void APIENTRY nglVertex3f( GLfloat x, GLfloat y, GLfloat z )
- {
- oglVertex3f( x, y, z );
-
- VertexCount3f++;
-
- fLastPosition[0] = x;
- fLastPosition[1] = y;
- fLastPosition[2] = z;
-
- fCenterVertex[0] += x;
- fCenterVertex[1] += y;
- fCenterVertex[2] += z;
-
- if( z > fHighestVertex[2] || VertexCount3f == 1 )
- {
- fHighestVertex[0] = fLastPosition[0];
- fHighestVertex[1] = fLastPosition[1];
- fHighestVertex[2] = fLastPosition[2];
- }
-
- if(z < fLowestVertex[2] || VertexCount3f == 1)
- {
- fLowestVertex[0] = fLastPosition[0];
- fLowestVertex[1] = fLastPosition[1];
- fLowestVertex[2] = fLastPosition[2];
- }
- }
-
- //=====================================================================================
-
- void APIENTRY nglPushMatrix( void )
- {
- oglPushMatrix( );
- MatrixDepth++;
- VertexCount3f = 0;
- }
-
- //=====================================================================================
-
- void APIENTRY nglTranslatef( GLfloat x, GLfloat y, GLfloat z )
- {
- if( x != 0.0f && y != 0.0f && z != 0.0f )
- {
- fCamera[0] = -x;
- fCamera[1] = -y;
- fCamera[2] = -z;
- }
- oglTranslatef( x, y, z );
- }
-
- //=====================================================================================
-
- void APIENTRY nglViewport( GLint x, GLint y, GLsizei width, GLsizei height )
- {
- Viewport[0] = x;
- Viewport[1] = y;
- Viewport[2] = width;
- Viewport[3] = height;
-
- if( GetAsyncKeyState( VK_NUMPAD1 ) &1 )
- Aimthrough = !Aimthrough;
-
- oglViewport( x, y, width, height );
- }
-
- //=====================================================================================
-
- extern "C" __declspec( naked )
- GLint __stdcall ogluProject(GLdouble objX, GLdouble objY, GLdouble objZ,
- const GLdouble *model, const GLdouble *proj, const GLint *view,
- GLdouble* winX, GLdouble* winY, GLdouble* winZ)
- {
- __asm
- {
- MOV EDI,EDI
- PUSH EBP
- MOV EBP,ESP
- PUSH ECX
- SUB ESP,0x40
- FLD QWORD PTR SS:[EBP+0x8]
- LEA EAX,DWORD PTR SS:[EBP-0x40]
- FSTP QWORD PTR SS:[EBP-0x20]
- PUSH EAX // /Arg3
- FLD QWORD PTR SS:[EBP+0x10] // |
- LEA EAX,DWORD PTR SS:[EBP-0x20] // |
- FSTP QWORD PTR SS:[EBP-0x18] // |
- PUSH EAX // |Arg2
- FLD QWORD PTR SS:[EBP+0x18] // |
- PUSH DWORD PTR SS:[EBP+0x20] // |Arg1
- FSTP QWORD PTR SS:[EBP-0x10] // |
- FLD1 // |
- FSTP QWORD PTR SS:[EBP-0x8] // |
- CALL PartB // \glu32.
- LEA EAX,DWORD PTR SS:[EBP-0x20]
- PUSH EAX // /Arg3
- LEA EAX,DWORD PTR SS:[EBP-0x40] // |
- PUSH EAX // |Arg2
- PUSH DWORD PTR SS:[EBP+0x24] // |Arg1
- CALL PartB // \glu32.
- FLDZ
- FLD QWORD PTR SS:[EBP-0x8]
- FUCOM ST(0x1)
- FSTSW AX
- FSTP ST(0x1)
- TEST AH,0x44
- JPE jmp1
- FSTP ST
- XOR EAX,EAX
- JMP jmp2
- jmp1: FLD QWORD PTR SS:[EBP-0x20]
- MOV EAX,DWORD PTR SS:[EBP+0x28]
- FDIV ST,ST(0x1)
- FLD QWORD PTR SS:[EBP-0x18]
- FDIV ST,ST(0x2)
- FLD QWORD PTR SS:[EBP-0x10]
- FDIVRP ST(0x3),ST
- FLD QWORD PTR DS:[The_Double]
- FMUL ST(0x2),ST
- FADD ST(0x2),ST
- FMUL ST(0x1),ST
- FADD ST(0x1),ST
- FMUL ST(0x3),ST
- FADDP ST(0x3),ST
- FILD DWORD PTR DS:[EAX+0x8]
- FMULP ST(0x2),ST
- FILD DWORD PTR DS:[EAX]
- FADDP ST(0x2),ST
- FIMUL DWORD PTR DS:[EAX+0xC]
- FIADD DWORD PTR DS:[EAX+0x4]
- MOV EAX,DWORD PTR SS:[EBP+0x2C]
- FXCH ST(0x1)
- FSTP QWORD PTR DS:[EAX]
- MOV EAX,DWORD PTR SS:[EBP+0x30]
- FSTP QWORD PTR DS:[EAX]
- MOV EAX,DWORD PTR SS:[EBP+0x34]
- FSTP QWORD PTR DS:[EAX]
- XOR EAX,EAX
- INC EAX
- jmp2: LEAVE
- RETN 0x30
-
- PartB:
- MOV EDI,EDI
- PUSH EBP
- MOV EBP,ESP
- MOV EAX,DWORD PTR SS:[EBP+0x8]
- MOV ECX,DWORD PTR SS:[EBP+0xC]
- XOR EDX,EDX
- ADD EAX,0x40
- PUSH ESI
- jmpa: FLD QWORD PTR DS:[EAX-0x40]
- MOV ESI,DWORD PTR SS:[EBP+0x10]
- FMUL QWORD PTR DS:[ECX]
- FLD QWORD PTR DS:[EAX-0x20]
- FMUL QWORD PTR DS:[ECX+0x8]
- FADDP ST(0x1),ST
- FLD QWORD PTR DS:[EAX]
- ADD EAX,0x8
- FMUL QWORD PTR DS:[ECX+0x10]
- FADDP ST(0x1),ST
- FLD QWORD PTR DS:[EAX+0x18]
- FMUL QWORD PTR DS:[ECX+0x18]
- FADDP ST(0x1),ST
- FSTP QWORD PTR DS:[ESI+EDX*0x8]
- INC EDX
- CMP EDX,0x4
- JL jmpa
- POP ESI
- POP EBP
- RETN 0x0C
- }
- }
-
- //=====================================================================================
-
- void * __stdcall DetourFunc( 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] = 0xE9;
- *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
-
- src[0] = 0xE9;
- *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
-
- VirtualProtect(src, len, dwback, &dwback);
-
- return (jmp-len);
- }
-
- VOID __stdcall THREAD( VOID )
- {
- while( GL32DLL == NULL )
- {
- GL32DLL = GetModuleHandleA( "opengl32.dll" );
- Sleep( 100 );
- }
-
- *(PDWORD)&oglBegin =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "glBegin" ), (PBYTE)nglBegin, 6 );
-
- *(PDWORD)&owglSwapBuffers =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "wglSwapBuffers" ), (PBYTE)nwglSwapBuffers, 5 );
-
- *(PDWORD)&oglPopMatrix =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "glPopMatrix" ), (PBYTE)nglPopMatrix, 6 );
-
- *(PDWORD)&oglPushMatrix =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "glPushMatrix" ), (PBYTE)nglPushMatrix, 6 );
-
- *(PDWORD)&oglVertex3f =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "glVertex3f" ), (PBYTE)nglVertex3f, 6 );
-
- *(PDWORD)&oglTranslatef =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "glTranslatef" ), (PBYTE)nglTranslatef, 6 );
-
- *(PDWORD)&oglViewport =(DWORD)
- DetourFunc( (PBYTE)GetProcAddress
- ( GL32DLL, "glViewport" ), (PBYTE)nglViewport, 7 );
- }
-
- //=====================================================================================
-
- BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved )
- {
- if( dwReason == DLL_PROCESS_ATTACH )
- {
- DisableThreadLibraryCalls( hModule );
- CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)
- THREAD, NULL, NULL, NULL );
- }
-
- return TRUE;
- }
-
- //=====================================================================================
复制代码 |
|