unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > C and C++

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2007, 12:13 PM
Neo_Reloaded Neo_Reloaded is offline
Tutorial Admin
 
Join Date: Dec 2006
Posts: 259
Default Universal Crosshair

By Crazylord

If you don't like it then i atleast hope you learned something

Code:
/*
	Universal Crosshair
	Author:   CrazyLord
*/

#include <windows.h>
#include <vector>

#define SLEEPTIME 20
#define CROSSHAIR_SIZE 5

int systemInfo[2] = { 0, 0 };
int centerInfo[2] = { 0, 0 };
COLORREF cColorCrosshair = RGB(255, 0, 0);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	HDC twHdc;
	POINT cursorInfo;
	char tInitPath[MAX_PATH];
	char GName[32];

	if (!GetModuleFileName(NULL, tInitPath, MAX_PATH)) {
		MessageBox(NULL, "Unable to read file", NULL, NULL);
		ExitProcess(0);
	}

	// Receiving file path (Credits to OGC Team)
	GetModuleFileName(NULL, tInitPath, MAX_PATH);
	char* pos = tInitPath + strlen(tInitPath);
	while(pos >= tInitPath && *pos != '\\') --pos;
	pos[1]=0;

	// Add the ini file location to the path
	strcat(tInitPath, "settings.ini");

	// Receiving ini variable
	GetPrivateProfileString("Game", "Name", NULL, GName, sizeof(GName), tInitPath);

	while(true) {
		HWND twHandle = FindWindow(NULL, GName);
		if (twHandle != NULL && GetForegroundWindow() == twHdc) {
			// Hooking information
			static bool bInfo = false;
			if (!bInfo) {
				char temp[MAX_PATH];
				sprintf(temp, "%s succesfully hooked, reading ini (%s)", GName, tInitPath);
				MessageBox(NULL, temp, "Notice", NULL);

				// Receiving resolution info
				systemInfo[0] = GetSystemMetrics(SM_CXSCREEN);
				systemInfo[1] = GetSystemMetrics(SM_CYSCREEN);

				centerInfo[0] = systemInfo[0] * 0.5f;
				centerInfo[1] = systemInfo[1] * 0.5f;

				// Getting handle for pixel adjustment
				twHdc = GetDC(twHandle);

				// Make sure radius is set
				if (radius <= 0)
					radius = centerInfo[1];

				bInfo = true;
			}

			// Get current cursor position
			GetCursorPos(&cursorInfo);

			// Crosshair drawing code
			for (int x=centerInfo[0]-CROSSHAIR_SIZE;x<centerInfo[0]+CROSSHAIR_SIZE;x++)
				SetPixel(twHdc, x, centerInfo[1], cColorCrosshair);
			for (int y=centerInfo[1]-CROSSHAIR_SIZE;y<centerInfo[1]+CROSSHAIR_SIZE;y++)
				SetPixel(twHdc, centerInfo[0], y, cColorCrosshair);

			caActive = true;
		}
		else if (caActive == true) {
			ExitProcess(0);
		}
		Sleep(SLEEPTIME);
	}

	return 0;
}
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
crosshair, universal

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 04:31 PM.