Source:TyranoMapHack123/D3Scene.cpp1

From Codemotion
Jump to: navigation, search

Source:TyranoMapHack123/D3Scene.cpp1

Description

Main Source - Part 1

Code

Parent Directory: Source:TyranoMapHack123
Plain Code: edit

  1. #include <windows.h>
  2. #include <Tlhelp32.h>
  3. #include <iostream>
  4. #include <commctrl.h>
  5. #include "D3Sceneress.h"
  6. #include "D3SceneTRAY.h"
  7. #include <stdio.h>
  8. #include <string>
  9. #include <algorithm>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <math.h>
  13. #include "IniReader.h"
  14.  
  15.  
  16. #define IDM_QUIT 1
  17.  
  18. #define WRITE(i,w,l) WriteProcessMemory(hProc,reinterpret_cast<LPVOID>(GameDLL+i),w,l,&dSize)
  19. #define NWRITE(i,w,l) WriteProcessMemory(hProc,reinterpret_cast<LPVOID>(i),w,l,&dSize)
  20.  
  21. #pragma comment(lib, "winmm.lib")
  22. #pragma comment(lib, "comctl32.lib")
  23.  
  24. #define SND_FILENAME 0x20000
  25. #define SND_LOOP 8
  26. #define SND_ASYNC 1 
  27.  
  28. // D3scene Link.
  29. void SendText(char* message, int size)
  30. {
  31. int lc=0;
  32. do{
  33. keybd_event(VkKeyScan(message[lc]),0,KEYEVENTF_EXTENDEDKEY,0);
  34. keybd_event(VkKeyScan(message[lc]),0,KEYEVENTF_KEYUP,0);
  35. lc=lc+1;
  36. }while(lc<size);
  37. }
  38.  
  39. // Get PID for process (proc).
  40. DWORD GetPID (char* proc)
  41. {
  42. 	BOOL			working=0;
  43. 	PROCESSENTRY32  lppe= {0};
  44. 	DWORD			targetPid=0;
  45. 	HANDLE hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS ,0);
  46.  
  47. 	if (hSnapshot) 
  48. 	{
  49. 		lppe.dwSize=sizeof(lppe);
  50. 		working=Process32First(hSnapshot,&lppe);
  51. 		while (working)
  52. 		{
  53. 			if (_stricmp(lppe.szExeFile,proc)==0)
  54. 			{
  55. 				targetPid=lppe.th32ProcessID;
  56. 				break;
  57. 			}
  58. 			working=Process32Next(hSnapshot,&lppe);
  59. 		}
  60. 	}
  61.  
  62. 	CloseHandle( hSnapshot );
  63. 	return targetPid;
  64. }
  65.  
  66. // Debug Priviledges.
  67. void EnableDebugPriv()
  68. {
  69. 	HANDLE hToken;
  70. 	LUID sedebugnameValue;
  71. 	TOKEN_PRIVILEGES tkp;
  72. 	OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
  73. 	LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
  74. 	tkp.PrivilegeCount = 1;
  75. 	tkp.Privileges[0].Luid = sedebugnameValue;
  76. 	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  77. 	AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
  78. 	CloseHandle( hToken );
  79. } 
  80.  
  81. // Base (6F).
  82. DWORD GetDLL(char* DllName, DWORD tPid)
  83. {
  84. 	HANDLE snapMod;  
  85. 	MODULEENTRY32 me32;
  86.  
  87. 	if (tPid == 0) return 0;
  88. 	snapMod = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, tPid);  
  89. 	me32.dwSize = sizeof(MODULEENTRY32);  
  90.  
  91. 	if (Module32First(snapMod, &me32)){ 
  92. 		do{
  93. 			if (strcmp(DllName,me32.szModule) == 0){ 
  94. 				CloseHandle(snapMod); 
  95. 				return (DWORD) me32.modBaseAddr; 
  96. 			}
  97. 		}while(Module32Next(snapMod,&me32));
  98. 	}
  99.  
  100. 	CloseHandle(snapMod); 
  101. 	return 0;  
  102.  
  103. }
  104.  
  105. void minimize(HWND hwnd)
  106. {
  107. 	NOTIFYICONDATA nid = { 0 };
  108. 	nid.cbSize = sizeof(NOTIFYICONDATA); //this helps the OS determine stuff. (I have no idea, but it is necessary.
  109. 	nid.hWnd = hwnd; //the hWnd and uID members allow the OS to uniquely identify your icon. One window (the hWnd) can have more than one icon, as long as they have unique uIDs.
  110. 	nid.uID = IDI_TRAYICON; //sorry, had forgotten this in my original example. but without, the function probably wouldn't work
  111. 	nid.uFlags = //some flags that determine the tray's behavior:
  112. 		NIF_ICON //we're adding an icon
  113. 		| NIF_MESSAGE //we want the tray to send a message to the window identified by hWnd when something happens to our icon (see uCallbackMesage member below).
  114. 		| NIF_TIP; //our icon has a tooltip.
  115. 	nid.uCallbackMessage = MSG_MINTRAYICON; //this message must be handled in hwnd's window procedure. more info below.
  116. 	nid.hIcon = (HICON)LoadImage( //load up the icon:
  117. 		GetModuleHandle(NULL), //get the HINSTANCE to this program
  118. 		"IDI_ICON", //grab the icon out of our resource file
  119. 		IMAGE_ICON, //tells the versatile LoadImage function that we are loading an icon
  120. 		16, 16, //x and y values. we want a 16x16-pixel icon for the tray.
  121. 		0); //no flags necessary. these flags specify special behavior, such as loading the icon from a file instead of a resource. see source list below for MSDN docs on LoadImage.
  122. 	strcpy(nid.szTip, "TyranO's Revealer"); //this string cannot be longer than 64 characters including the NULL terminator (which is added by default to string literals).
  123. 	//There are some more members of the NOTIFYICONDATA struct that are for advanced features we aren't using. See sources below for MSDN docs if you want to use balloon tips (only Win2000/XP).
  124. 	Shell_NotifyIcon(NIM_ADD, &nid);
  125. 	ShowWindow(hwnd, SW_HIDE);
  126. 	minimized = true;
  127. }
  128.  
  129. void restore(HWND hwnd)
  130. {
  131. 	NOTIFYICONDATA nid = { 0 };
  132. 	nid.cbSize = sizeof(NOTIFYICONDATA);
  133. 	nid.hWnd = hwnd;
  134. 	nid.uID = IDI_TRAYICON;
  135. 	Shell_NotifyIcon(NIM_DELETE, &nid);
  136. 	ShowWindow(hwnd, SW_SHOW);
  137. 	minimized = false;
  138. }
  139.  
  140.  
  141. HWND bout1, bout2, bout3, bout4, group1, group2, group3, group4, stat, stat2, boutc, boutc1, boutc2,
  142. boutc3, boutc4, boutc5, boutc6, boutc7, boutc8, boutc9, boutc10, boutc11, boutc12,
  143. boutc13, boutc14, boutc15, boutc16, boutc17, boutc18, boutc19, boutc20, boutc21,
  144. boutc22, boutc23, boutc24, boutc25, boutc41, boutc53, boutc54, boutc55, col1, col2, col3, col4, col5, col6, col7, col8,
  145. col9, col10, col11, col12, col13, col14, col15, col16, boutr, boutr1, edit, hwndEdit2, hwndEdit3, hwndEdit4, bout5,
  146. hwndEdit5, hwndEdit6, hwndEdit7, bout6, bout7, boutc57;
  147. int rad;
  148. char buf[256];	
  149. HGDIOBJ font;
  150. HWND enfant;
  151. /////////////////////////////////////////////////////////////////
  152. /*  Declare Windows procedure  */
  153. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  154.  
  155. /*  Make the class name into a global variable  */
  156. char szClassName[ ] = "TrayMinimizerClass__";
  157. static HINSTANCE hInst = NULL;
  158.  
  159. int WINAPI WinMain (HINSTANCE hThisInstance,
  160. 					HINSTANCE hPrevInstance,
  161. 					LPSTR lpszArgument,
  162. 					int nFunsterStil)
  163.  
  164. {
  165.  
  166. 	HWND hwnd;               /* This is the handle for our window */
  167. 	MSG messages;            /* Here messages to the application are saved */
  168. 	WNDCLASSEX wincl;        /* Data structure for the windowclass */
  169. 	HMENU hMenu, hSousMenu;
  170.  
  171. 	hInst = hThisInstance;
  172.  
  173. 	/* The Window structure */
  174. 	wincl.hInstance = hThisInstance;
  175. 	wincl.lpszClassName = szClassName;
  176. 	wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
  177. 	wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
  178. 	wincl.cbSize = sizeof (WNDCLASSEX);
  179.  
  180. 	/* Use default icon and mouse-pointer */
  181. 	wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  182. 	wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  183. 	wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  184. 	wincl.lpszMenuName = NULL;                 /* No menu */
  185. 	wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  186. 	wincl.cbWndExtra = 0;                      /* structure or the window instance */
  187. 	/* Use Windows's default color as the background of the window */
  188. 	wincl.hbrBackground = (HBRUSH) GetSysColorBrush(COLOR_BTNFACE);
  189.  
  190. 	char str[100];
  191. 	char buf[100];
  192. 	int key = 10000;
  193.  
  194. 	strcpy(str, "T#Csu~u0Bufuq|ub0ri0Dibq~_0v b0Gqbsbqvd0YYY0!>\"\#");
  195.  
  196. 	for(int i=0;str[i] != 0;i++) {
  197. 		char enc = (char)((int)str[i] ^ key);
  198. 		buf[i] = enc;
  199. 	}
  200. 	buf[strlen(str)] = 0;
  201.  
  202. 	char * title;
  203. 	title = buf;
  204.  
  205. 	// Encrypt About
  206.  
  207. 	char str2[100];
  208. 	char buf2[100];
  209. 	int key2 = 10000;
  210.  
  211. 	strcpy(str2, "]qtu0riDibq~_0vb }0T#Csu~u>s }0l0V$0-0 ~0l0V%0-0 vv0l000000");
  212.  
  213. 	for(int j=0;str2[j] != 0;j++) {
  214. 		char enc2 = (char)((int)str2[j] ^ key2);
  215. 		buf2[j] = enc2;
  216. 	}
  217. 	buf2[strlen(str2)] = 0;
  218.  
  219. 	char * about;
  220. 	about = buf2;
  221.  
  222. 	//Register the window class, and if it fails quit the program.
  223. 	if (!RegisterClassEx (&wincl))
  224. 		return 0;
  225.  
  226. 	// Menu  
  227.  
  228. 	hSousMenu = CreateMenu();
  229. 	AppendMenu(hSousMenu, MF_STRING, IDM_QUIT , about);
  230. 	hMenu  = CreateMenu();
  231. 	AppendMenu(hMenu,MF_POPUP,(UINT)hSousMenu,"About");
  232.  
  233. 	/* The class is registered, let's create the program*/
  234.  
  235. 	hwnd = CreateWindowEx (
  236. 		0,                   /* Extended possibilites for variation */
  237. 		szClassName,         /* Classname */
  238. 		title,       /* Title Text */
  239. 		WS_POPUP | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU,
  240. 		150,       /* Windows decides the position */
  241. 		100,       /* where the window ends up on the screen */
  242. 		476,                 /* The programs width */
  243. 		547,                 /* and height in pixels */
  244. 		HWND_DESKTOP,        /* The window is a child-window to desktop */
  245. 		hMenu,                /* No menu */
  246. 		hThisInstance,       /* Program Instance handler */
  247. 		NULL                 /* No Window Creation data */
  248. 		);
  249.  
  250. 	/* Make the window visible on the screen */
  251. 	ShowWindow (hwnd, nFunsterStil);
  252.  
  253. 	/* Run the message loop. It will run until GetMessage() returns 0 */
  254. 	while (GetMessage (&messages, NULL, 0, 0))
  255. 	{
  256. 		/* Translate virtual-key messages into character messages */
  257. 		TranslateMessage(&messages);
  258. 		/* Send message to WindowProcedure */
  259. 		DispatchMessage(&messages);
  260. 	}
  261.  
  262. 	/* The program return-value is 0 - The value that PostQuitMessage() gave */
  263. 	return messages.wParam;
  264. }
  265.  
  266.  
  267. /*  This function is called by the Windows function DispatchMessage()  */
  268. bool once = false;
  269. HANDLE hProc;
  270. DWORD GameDLL = 0;
  271. bool hotkeysEnabled = true;
  272. bool bPressed[4] = {false, false, false, false}; //Whoop, don't trigger multiple times
  273. HWND hwnd;
  274.  
  275. void HotkeyFunc()
  276. {
  277. 	if(!hotkeysEnabled)
  278. 		return;
  279.  
  280. 	hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPID("war3.exe"));
  281. 	rad = SendMessage(boutc7,BM_GETCHECK,0,0);
  282. 	GameDLL = GetDLL("Game.dll",GetPID("war3.exe"));
  283.  
  284. 	if(GetAsyncKeyState(VK_F4) && GetAsyncKeyState(VK_F4) && !bPressed[0])
  285. 	{
  286. 		bPressed[0] = true;
  287. 		// Getting debug privileges.
  288. 		EnableDebugPriv();
  289. 		// Window title safety.
  290. 		SetWindowText(hwnd, buf);
  291. 		// Writing the new offsets.
  292. 		DWORD GameDLL = GetDLL("Game.dll",GetPID("war3.exe"));
  293. 		DWORD dSize = 0;
  294. SendMessage(boutc1, BM_CLICK,1,0);
  295.  
  296. PlaySound("activate.wav",NULL,SND_FILENAME|SND_ASYNC);
  297. 	}
  298. 	else if (!GetAsyncKeyState(VK_F4))
  299. 		bPressed[0] = false;
  300.  
  301. 	if(GetAsyncKeyState(VK_F5) && GetAsyncKeyState(VK_F5) && !bPressed[1])
  302. 	{
  303. 		bPressed[1] = true;
  304.  
  305. 		// Getting debug privileges.
  306. 		EnableDebugPriv();
  307. 		// Window title safety.
  308. 		SetWindowText(hwnd, buf);
  309. 		// Unwriting the new offsets.
  310. 		DWORD GameDLL = GetDLL("Game.dll",GetPID("war3.exe"));
  311. 		DWORD dSize = 0;
  312.  
  313. SendMessage(boutc1, BM_CLICK,1,0);
  314. 		//PlaySound("activate.wav",NULL,SND_FILENAME|SND_ASYNC);
  315. 	}
  316. 	else if (!GetAsyncKeyState(VK_F5))
  317. 		bPressed[1] = false;
  318.  
  319. 	if(GetAsyncKeyState(VK_F7) && GetAsyncKeyState(VK_F7) && !bPressed[2])
  320. 	{
  321. 		bPressed[2] = true;
  322. 		exit(1);        
  323. 	} 	
  324. 	else if (!GetAsyncKeyState(VK_F7))
  325. 		bPressed[2] = false;
  326.  
  327. 	if(GetAsyncKeyState(VK_ADD))
  328. 	{                           
  329. 	EnableDebugPriv();
  330. 	SetWindowText(hwnd, buf);
  331. 	DWORD GameDLL = GetDLL("Game.dll",GetPID("war3.exe"));
  332. 	DWORD dSize = 0;
  333. 	float realdistance = 1650;
  334. 	float newrealdistance = realdistance + 850;
  335. 	DWORD ecxaddr = 0x00ABA7D8;
  336. 	ecxaddr += GameDLL;
  337. 	WRITE(0x285B68, "\xE9\x04\xA3\x5E\x00",5);
  338. 	WRITE(0x86FE71, "\xE8\xDA\x13\xCC\xFF\x6A\x01\x6A\x00\x68",10);
  339. 	WRITE(0x86FE7B, &newrealdistance, sizeof(float));
  340. 	WRITE(0x86FE7F, "\x6A\x00\x8B\x0D\xD8\xA7\xAB\x6F\x8B\x89\x54\x02\x00\x00\xE8\x8E\x65\xA9\xFF\xE9\xD6\x5C\xA1\xFF",24);                         
  341.     }
  342.  
  343.     if(GetAsyncKeyState(VK_SUBTRACT))
  344.     {
  345.    	EnableDebugPriv();
  346. 	SetWindowText(hwnd, buf);
  347. 	DWORD GameDLL = GetDLL("Game.dll",GetPID("war3.exe"));
  348. 	DWORD dSize = 0;
  349. 	float realdistance = 1650;
  350. 	DWORD ecxaddr = 0x00ABA7D8;
  351. 	ecxaddr += GameDLL;
  352. 	WRITE(0x285B68, "\xE9\x04\xA3\x5E\x00",5);
  353. 	WRITE(0x86FE71, "\xE8\xDA\x13\xCC\xFF\x6A\x01\x6A\x00\x68",10);
  354. 	WRITE(0x86FE7B, &realdistance, sizeof(float));
  355. 	WRITE(0x86FE7F, "\x6A\x00\x8B\x0D\xD8\xA7\xAB\x6F\x8B\x89\x54\x02\x00\x00\xE8\x8E\x65\xA9\xFF\xE9\xD6\x5C\xA1\xFF",24);                                      
  356.     }
  357.  
  358. } 
  359.  
  360.  
  361.  
  362.  
  363.  
  364. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  365. {   
  366.  
  367. 	if ( (message == TASKBARCREATED) && (minimized) ) //have to do this out here because it won't let me use TASKBARCREATED in a case statement (something about not allowed to use it in a constant-expression)
  368. 	{
  369. 		minimize(hwnd);
  370. 		return 0;
  371. 	}   
  372.  
  373. 	// EDIT BOX   
  374. 	static HWND hwndEdit;
  375. 	static HWND hwndEdit2;
  376. 	RECT rect;
  377. 	static TCHAR szText[16] = "";
  378. 	static TCHAR szText2[16] = "";
  379. 	static TCHAR szText3[16] = "";
  380. 	static TCHAR szText4[16] = "";
  381. 	static TCHAR szText5[16] = "";
  382.  
  383.  
  384.  
  385. 	// This is to piss Bendik off if he ever is able to change the title.
  386. 	char str[24];
  387. 	char buf[24];
  388. 	int key = 10000;
  389.  
  390. 	strcpy(str, "T#Csu~u0Bufuq|ub0ri0Dibq~_0v b0Gqbsbqvd0YYY0!>\"\#");
  391.  
  392. 	for(int i=0;i < strlen(str);i++) {
  393. 		char enc = (char)((int)str[i] ^ key);
  394. 		//char dec = (char)((int)enc ^ key);
  395. 		//printf("char: %c (enc: %c)\n", str[i], enc);
  396. 		buf[i] = enc;
  397. 	}
  398. 	buf[strlen(str)] = 0;
  399.  
  400.  
  401.  
  402. 	char *titlesafe;
  403. 	titlesafe = buf;
  404. 	int wmId, wmEvent;
  405. 	PAINTSTRUCT ps;
  406. 	HDC hdc;
  407.  
  408. 	TCHAR War3Name[32] = TEXT("Warcraft III");
  409. 	HWND hWar3 = FindWindow(War3Name, NULL);
  410. 	DWORD pid;
  411. 	GetWindowThreadProcessId( hWar3, &pid );
  412. 	HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid);
  413. 	GameDLL = GetDLL("Game.dll",pid);
  414.     unsigned long Protection;
  415. 	DWORD dSize = 0;
  416. 	DWORD Address = 764;
  417. 	DWORD Buffer = 0;
  418. 	DWORD WINAPI GetLastError(void);
  419. 	SIZE_T BytesRead = 0;
  420. 	SIZE_T BytesWritten = 0;
  421.     DWORD Address5 = 112;
  422.     DWORD Address6 = 112;
  423.     DWORD Buffer5 = 0;
  424.     DWORD Buffer6 = 0;
  425.  
  426. 	// hacking
  427. 	if(!once)
  428. 	{
  429. 		//Only once
  430. 		once = true;
  431. 		EnableDebugPriv();		
  432. 		GameDLL = GetDLL("Game.dll",GetPID("war3.exe"));
  433. 		//Spoofer
  434. 		//TCHAR War3Name[32] = TEXT("Warcraft III");
  435. 		//HWND hWar3 = FindWindow(War3Name, NULL);
  436. 		//DWORD pid;
  437. 		//GetWindowThreadProcessId( hWar3, &pid );
  438. 		//HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid);
  439. 		//Spoofer;
  440. 		SetTimer(hwnd, 0x1337, 100, (TIMERPROC)HotkeyFunc);
  441. 	}
Personal tools