小明思考

高性能服务器端计算
posts - 70, comments - 428, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

为英雄无敌3写个游戏修改器

Posted on 2005-12-19 11:37 小明 阅读(16990) 评论(7)  编辑 收藏 引用 所属分类: Win32Game Development
我是比较铁杆的英雄无敌3的fans,在网上看到这样的文章:http://game.china.com/zh_cn/play/10002765/20021113/11362720.html

就是让我方英雄学会所有技能,真的蛮爽的
学会28项技能修改法
heroes3.jpg

  首先,把你的英雄的士兵调到前面几格来,接着用FPE来搜索。例如你的士兵数:第一格3,第二格14,第三格4,那么就用 3,0,14,0,4,0 来搜索,就可以找到地址。显示为:
  士兵种类- FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
   FF FF FF FF FF FF FF FF FF FF FF FF 03 00 00 00-士兵数量
   0E 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00
   00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08
   09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
   25 26 27 28 01 02 03 04 05 06 07 08 00 00 00 00
   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   04 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF
   FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
   FF或00作为一格,每4格是代表一种属性,物品, 状态等等。前面28格是士兵的种类,接下来28格是士兵的数量。例如: 英雄可带7种士兵,你要每种都是天使,那么把
   03 00 00 00 前面的FF FF FF FF 改为0D 00 00 00。 如果你要数量100, 那么把
   03 00 00 00 改为64 00 00 00。 士兵的种类是这样分的:00 00 00 00 是枪兵,
   01 00 00 00 是 进化一级的枪兵,02 00 00 00 是弓箭手,03 00 00 00 是神箭手。
   如此类推。
  
   从03那一格开始数,28格后就是英雄的技能等级,接着的28格是英雄的技能,
   也就是从01到28代表的是英雄的技能等级,技能等级最多只能是3。
   01 箭术等级 02 寻路术等级 03 后勤学等级
   04 侦察术等级 05 外交术等级 06 航海术等级
   07 领导术等级 08 智慧术等级 09 神秘术等级
   10 幸运术等级 11 弹道术等级 12 鹰眼术等级
   13 招魂术等级 14 理财术等级 15 火系魔法等级
   16 气系魔法等级 17 水系魔法等级 18 土系魔法等级
   19 学术等级 20 战术等级 21 炮术等级
   22 学习能力等级 23 进攻术等级 24 防御术等级

但是每次使用FPE真的很麻烦,我又是很懒的人。FPE可以做到的事情,我也可以做到。
其实游戏修改不过是使用ReadProcessMemoryWriteProcessMemory

花了半天不断的试验,终于写出一个可以用于英雄无敌3.1版的修改器,没有写界面(I'm lazy-:)),运行之后就是让我方英雄学会所有技能。

#include <windows.h>
#include 
<tlhelp32.h>
#include 
<cstdio>

const char MODULE_NAME[] = "Heroes3.exe";

void printError( TCHAR* msg )
{
    DWORD eNum;
    TCHAR sysMsg[
256];
    TCHAR
* p;
    
    eNum 
= GetLastError( );
    FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM 
| FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL, eNum,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
// Default language
        sysMsg, 256, NULL );
    
    
// Trim the end of the line and terminate it with a null
    p = sysMsg;
    
while( ( *> 31 ) || ( *== 9 ) )
        
++p;
    
do { *p-- = 0; } while( ( p >= sysMsg ) &&
        ( ( 
*== '.' ) || ( *< 33 ) ) );
    
    
// Display the message
    printf( "WARNING: %s failed with error %d (%s)\n", msg, eNum, sysMsg );
}


DWORD findProcessId(
const char *module)
{
    DWORD result 
= -1;
    HANDLE hProcessSnap;
    
    
// Take a snapshot of all processes in the system.
    hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
    
if( hProcessSnap == INVALID_HANDLE_VALUE )
    {
        printError( 
"CreateToolhelp32Snapshot (of processes)" );
        
return result;
    }
    
    PROCESSENTRY32 pe32;
    
// Set the size of the structure before using it.
    pe32.dwSize = sizeof( PROCESSENTRY32 );
    
    
// Retrieve information about the first process,
    
// and exit if unsuccessful
    if!Process32First( hProcessSnap, &pe32 ) )
    {
        printError( 
"Process32First" );  // Show cause of failure
        CloseHandle( hProcessSnap );     // Must clean up the snapshot object!
        return result;
    }
    
    
// Now walk the snapshot of processes, and
    
// display information about each process in turn
    do
    {
        
if(stricmp(pe32.szExeFile,module)==0)
        {
            printf( 
"find process:  %s\n", module );
            result 
= pe32.th32ProcessID;
            
break;
        }
        
    } 
while( Process32Next( hProcessSnap, &pe32 ) );
    
    CloseHandle( hProcessSnap );
    
return result;
}

int main(int argc,char *argv[])
{
    DWORD h3pid 
= -1;
    
    h3pid 
=  findProcessId(MODULE_NAME);
    
if(h3pid == -1)
    {
        printf(
"can't find %s in memory,please make sure the program started!\n",MODULE_NAME);
        
return 1;
    }

    HANDLE h3 
= OpenProcess( PROCESS_ALL_ACCESS, FALSE, h3pid );
    
if( h3 == NULL )
    {
      printError( 
"OpenProcess" );
      
return 1;
    }

    unsigned 
long sideOffset=0x824994;
    unsigned 
char side = 0xff;
    
if(!ReadProcessMemory(h3,(LPCVOID)sideOffset,&side,1,0)) //查找我方的颜色
    {
        printError( 
"ReadProcessMemory" );
        
return 1;
    }

    
if(side!=0xff)
    {
        printf(
"find current side:%d\n",(int)side);
    }
    
else
    {
        printf(
"can't find current side\n");
        side 
= 0;
    }

    unsigned 
long heroBaseAddress = 0x15216ab;  //hero name start
    unsigned char name[20]={0};
    unsigned 
long temp = heroBaseAddress-1;

    
char b[28]; //28种技能
    
int size = sizeof(b);
    memset(b,
3,size);
    b[
12]=0;//不学招魂术

    
for(int i=0;i<=155;++i) //一共156个Hero
    {
        
if(!ReadProcessMemory(h3,(LPCVOID)temp,name,sizeof(name),0))
        {
            printError( 
"ReadProcessMemory" );
            
return 1;
        }
        
if(name[0]==side)
        {
            printf(
"find:%s\t",name+1);
            
if(!WriteProcessMemory(h3,(LPVOID)(temp+0xA7),b,size,0))
            {
                printError( 
"WriteProcessMemory" );
                
return 1;
            }
            
else
            {
                printf(
"update skill sucess!\n");
            }
        }
        temp 
+= 0x492;
    }

    CloseHandle(h3);
    
return 0;
}


附加:
让我方英雄所有英雄学会除了招魂术的以外的27种技能的小程序

以前英雄世界也有一个这样的程序,但是版本太老,不能用了。

使用版本:中文版3.1,其他版本没有测试

使用方法:进入游戏后,运行程序

Download: http://www.cppblog.com/Files/sandy/h3c.zip

Feedback

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2005-12-19 15:10 by 小软
玩游戏你也作弊,我就从没看你写的工具有界面的:(

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2005-12-28 14:41 by Flyingis
有意思

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2006-11-01 13:12 by zlot
难道说......

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2006-12-10 22:53 by maber

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2007-03-04 20:57 by pdd
我也编写了一个,但是时灵时不灵,似乎地址是变动的。QQ:21384483

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2007-08-30 10:42 by 浪子高达
re: 为英雄无敌3写个游戏修改器 回复 更多评论
2007-03-04 20:57 by pdd
我也编写了一个,但是时灵时不灵,似乎地址是变动的。QQ:21384483

变动是因为英雄变了!

QQ:527301899

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2007-08-30 10:43 by 浪子高达
那个,如果有界面的话就好了~大哥...

# re: 为英雄无敌3写个游戏修改器  回复  更多评论   

2009-04-10 20:32 by MIG39CN
你好
哥们 我下了你的那个小程序
怎么没发现有什么变化啊?

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理