实例介绍
【实例截图】

【核心代码】魔兽全图的源码,小地图可见,自己测试能用,不能过检测,但是可以自己参考开发,用外挂的方式可以过检测.
#include "War3Class.h" VOID War3::EnableDebugPriv() { HANDLE hToken; LUID sedebugnameValue; TOKEN_PRIVILEGES tkp; OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken); LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue); tkp.PrivilegeCount = 1; tkp.Privileges[0].Luid = sedebugnameValue; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, false, &tkp, sizeof tkp, NULL, NULL); CloseHandle(hToken); } War3::War3() { VerSion=0; GameAddr=0,GameSize=0; StormAddr=0,StormSize=0; Hwnd_War3=0; Tid_War3=0; Handle_War3=0; Pid_War3=0; GameStateAddr=0; HeroNumAddr=0; PingMapAddr=0; LocalPlayerAddr=0; } BOOL War3::InitVariables() { EnableDebugPriv(); Hwnd_War3 = FindWindowA("Warcraft III",NULL); if (Hwnd_War3==NULL) { ::MessageBox(NULL,L"获取魔兽窗口句柄失败",L"ERROR",0); return FALSE; } Tid_War3=GetWindowThreadProcessId(Hwnd_War3, &Pid_War3); Handle_War3=OpenProcess(PROCESS_ALL_ACCESS, false,Pid_War3); if(Handle_War3==NULL) { ::MessageBox(NULL,L"打开魔兽进程失败",L"ERROR",0); return FALSE; } if(!ListProcessModules()) { ::MessageBox(NULL,L"枚举魔兽模块失败",L"ERROR",0); return FALSE; }; if(!GetVersionAndInit(GameAddr)) { ::MessageBox(NULL,L"获取魔兽版本错误",L"ERROR",0); }; return TRUE; } BOOL War3::ListProcessModules() { HANDLE hModuleSnap = INVALID_HANDLE_VALUE; MODULEENTRY32 me32; hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, Pid_War3 ); if( hModuleSnap == INVALID_HANDLE_VALUE ) { return FALSE; } me32.dwSize = sizeof( MODULEENTRY32 ); if( !Module32First( hModuleSnap, &me32 ) ) { CloseHandle( hModuleSnap ); return FALSE; } do { if(lstrcmpi(me32.szModule,L"game.dll")==0) { GameSize=me32.modBaseSize; GameAddr=(DWORD)me32.modBaseAddr; }; if(lstrcmpi(me32.szModule,L"storm.dll")==0) { StormSize=me32.modBaseSize; StormAddr=(DWORD)me32.modBaseAddr; } } while( Module32Next( hModuleSnap, &me32 ) ); CloseHandle( hModuleSnap ); if((GameAddr!=NULL)&&(StormAddr!=NULL)) return TRUE; return FALSE; } BOOL War3::GetVersionAndInit(DWORD GameAddr) { DWORD veraddr; veraddr = GameAddr 0x636F5D; unsigned char p124b[] ={0x80, 0xBE, 0xA8, 0x01}; unsigned char p124e[] = {0x8B, 0x50, 0x3C, 0x3B}; unsigned char p125b[] = {0x10, 0x75, 0x72, 0xC7}; unsigned char p126[] = { 0xb6, 0x89,0x7c, 0x73}; if (0 == memcmp(p124b, (unsigned char*)veraddr, sizeof(p124b))) { Addr2Handle1=GameAddr 0x3A8AE0; Addr2Handle2=GameAddr 0x4317F0; PingMapAddr=GameAddr 0x3b50d0; UnitAddIndicatorAddr=GameAddr 0x3c7650; GetUnitNameAddr=GameAddr 0x3c63d0; CreateTextTagAddr=GameAddr 0x3bd000; DisplayGameTextAddr=GameAddr 0x3CC380; GetPlayerHandleAddr=GameAddr 0x3BC5B0; MakeStringAddr=GameAddr 0x012040; SetTextTagPosUnitAddr=GameAddr 0x3cc310; SetTextTagTextAddr=GameAddr 0x3bd050; Char2IndexAddr=GameAddr 0x3a0030; GetHandleTableAddr=GameAddr 0x44bd90; IndexTojStringAddr=GameAddr 0x45a100; PingMiniMapAddr=GameAddr 0x3b50d0; VerSion=V124b; GameStateAddr=GameAddr 0xACC570; HeroNumAddr=GameAddr 0xACA954; LocalPlayerAddr=GameAddr 0XACD44C; } else if (0 == memcmp(p124e, (unsigned char*)veraddr, sizeof(p124e))) { VerSion=V124e; GameStateAddr=GameAddr 0xACC570; HeroNumAddr=GameAddr 0xACA954; LocalPlayerAddr=GameAddr 0XACD44C; Addr2Handle1=GameAddr 0x3a8ba0; Addr2Handle2=GameAddr 0x4317C0; PingMapAddr=GameAddr 0x3b5190; UnitAddIndicatorAddr=GameAddr 0x3c7710; GetUnitNameAddr=GameAddr 0x3c6490;; CreateTextTagAddr=GameAddr 0x3bd0c0;; DisplayGameTextAddr=GameAddr 0x3CC440 ; GetPlayerHandleAddr=GameAddr 0x3BC670; MakeStringAddr=GameAddr 0x012040; SetTextTagPosUnitAddr=GameAddr 0x3cc3D0; SetTextTagTextAddr=GameAddr 0x3bd110; Char2IndexAddr=GameAddr 0x3A0130; GetHandleTableAddr= GameAddr 0x44BDF0; IndexTojStringAddr= GameAddr 0x45A170; PingMiniMapAddr=GameAddr 0x3b5190; } else { VerSion=0; } if(VerSion==0) { return FALSE; } return TRUE; } ///////////////////////////////////////////////////////////////// VOID War3::DisplayGameTextFunc( wchar_t pszContent[], float offxpercent, float offypercent ) { char *pszHello; int iTextLen = WideCharToMultiByte(CP_UTF8, 0, pszContent, -1, NULL, 0, NULL, NULL); pszHello = new char[iTextLen 1]; memset(pszHello, 0x00, sizeof(char)*(iTextLen 1)); WideCharToMultiByte(CP_UTF8, 0, pszContent, -1, pszHello, iTextLen, NULL, NULL); static float rx; static float ry; rx = offxpercent; ry = offypercent; int wcstr = MakeString(pszHello); DWORD hplayer = GetPlayerHandleFunc(GetLocalPlayerFunc()); DWORD tempcall=DisplayGameTextAddr; __asm { pushad PUSH wcstr; LEA EBX, ry; PUSH EBX; LEA EBX, rx; PUSH EBX; PUSH hplayer; CALL tempcall; ADD ESP, 16; popad } } ////////////////////////////////////////////////////////////////////////// DWORD War3::GetLocalPlayerFunc() { WORD rt; DWORD temp=LocalPlayerAddr; __asm { MOV EBX, temp; MOV EAX, DWORD PTR DS:[EBX]; TEST EAX, EAX; JE err; MOV EAX, DWORD PTR DS:[EAX 0x28]; MOV rt, AX; } return (DWORD)rt; err: return 0xF; } //////////////////////////////////////////////////// UINT War3::GetPlayerHandleFunc(int indexPlayer) { UINT hPlayer; if (indexPlayer < 0) indexPlayer = GetLocalPlayerFunc(); if (indexPlayer > 12) indexPlayer = 12; DWORD tempcall=GetPlayerHandleAddr; __asm { pushad; push indexPlayer; call tempcall; mov hPlayer,eax; pop eax; popad; } return hPlayer; } /////////////////////////////////////////////////////////// UINT __cdecl War3::MakeString(char* psz) { static DWORD _datas[3]; static DWORD* pjstr = &_datas[0]; UINT jstr; DWORD tempcall; tempcall=MakeStringAddr; __asm { mov ecx, pjstr; push psz; call tempcall; mov jstr, eax; pop eax; } return jstr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DWORD War3::GetHeroAddrPFunc() { DWORD HeroAddrPoint=0; memcpy(&HeroAddrPoint,(LPCVOID)(StormAddr HeroAddrPointOffsetStorm),4); if(*(DWORD*)(HeroAddrPoint 0x88)!=0x18) return 0; HeroAddrPoint=HeroAddrPoint 0x98; //特别注意,这里返回值可能为0; return HeroAddrPoint; } VOID War3::UnitAddIndicator(DWORD hUnit,int r,int g,int b,int alpha) { DWORD tempcall=(DWORD)UnitAddIndicatorAddr; __asm { pushad push alpha push b push g push r push hUnit call tempcall add esp,0x14 popad } }; DWORD War3::AddrToHandle(DWORD Addr) { DWORD m=LocalPlayerAddr,call1=Addr2Handle1,call2=Addr2Handle2,hand; _asm { pushad mov esi,Addr mov ecx,m mov ecx,[ecx] call call1 push 0 push esi mov ecx,eax call call2 mov hand,eax popad } return hand; }; //// VOID War3::SetTextTagPosUnit(DWORD text, DWORD hunit,float height) { static float rheight; rheight = height; DWORD tempcall=SetTextTagPosUnitAddr; __asm { mov eax,eax pushad lea ebx, rheight push ebx push hunit push text call tempcall add esp, 12 popad; } } DWORD War3::CreateTextTagFunc() { DWORD rt; DWORD tempcall=(DWORD)CreateTextTagAddr; __asm { mov ebx,ebx pushad call tempcall mov rt,eax popad } return rt; }; VOID War3::SetTextTagText(DWORD htt,DWORD jstr,float height) { DWORD tempcall=SetTextTagTextAddr; float *tempush=&height; __asm { mov ecx,ecx pushad push tempush push jstr push htt call tempcall add esp,0xc popad } }; DWORD War3::GetUnitNameFunc(DWORD hunit) { DWORD tempcall=GetUnitNameAddr,rt; __asm { pushad push hunit call tempcall mov rt,eax add esp,4 popad } return rt; } LONG War3::Char2Index(LPSTR pStr) { char * temp = pStr; DWORD tempcall=Char2IndexAddr,rt; DWORD inf; memcpy(&inf,(LPVOID)LocalPlayerAddr,4); _asm { mov edx,edx mov ecx,inf; push temp; call tempcall; mov rt,eax; } return rt; } HANDLE War3::GetHandleTable() { HANDLE rt; DWORD tempcall=GetHandleTableAddr,inf=LocalPlayerAddr; memcpy(&inf,(LPVOID)inf,4); _asm { mov esp,esp mov ecx, inf; mov ecx, [ecx 8] call tempcall; mov rt,eax; } return rt; } LONG War3::IndexTojString(DWORD Index) { HANDLE ht = GetHandleTable(); DWORD tempcall=IndexTojStringAddr; LONG rt = 0; if(ht == 0 || Index== 0) return rt; _asm { mov al,al push Index; mov ecx,ht; call tempcall; mov rt,eax; } return rt; } CHAR * War3::jStringToChar(LONG jStr) { int val1; int result; val1 = *(DWORD *)(jStr 8); if ( val1 ) result = *(DWORD *)(val1 28); else result = 0; return (char*)result; } HWND War3::GetHwndWar3() { return Hwnd_War3; }; DWORD War3::GetHeroNumAddr() { return HeroNumAddr; }; DWORD War3::GetGameStateAddr() { return GameStateAddr; }; VOID War3::PingMiniMap(float x,float y) { float *px=&x; float *py=&y; float PingTime=0.5; float *ptime=&PingTime; DWORD tempcall=(DWORD)PingMiniMapAddr; _asm { push ptime mov eax,eax push py push px mov eax,eax call tempcall add esp,0xc } } DWORD War3::GetVerSion() { return VerSion; };
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论