怎样写一个游戏修改器,300分,要详细可用代码、例程!(300分)

  • 主题发起人 主题发起人 lml
  • 开始时间 开始时间
L

lml

Unregistered / Unconfirmed
GUEST, unregistred user!
特别是怎样确定目标地址的?<br>最好用starcraft为例。
 
我也想知道哦。如有比较好的答案,我再出300。
 
no one know?<br>600分也没人要?
 
给你一个思路:<br>先查找读取指定进程(process)的内存数据<br>比如 水晶 原来为1054,那么就把找到的<br>所有值为1054的地址存到一个数组(或TList)<br>里面,然后改变 水晶 的值为1062,接着<br>在刚才找到的那些地址里面再找,以缩小范围<br>如此循环,到唯一地址为止,就是要找的地址<br>修改它的值就可以了<br><br>可以用到以下函数:<br>ReadProcessMemory用于读取进程(process)的内存数据<br>WriteProcessMemory用于写进程的内存数据<br>VirtualProtect用于修改进程的内存数据存取保护的区域.(详见Win32的帮助文件)<br><br>因为我也没做过,所以只能说这么多了
 
哈哈,又可以捞分了,这段代码我也没试过,别人写的,你试试把<br><br>#include &lt;vcl.h&gt; <br>#include &lt;stdio.h&gt; <br>#include &lt;shellapi.h&gt; <br>using namespace std; <br>#pragma hdrstop <br>#include "about.h" <br>#include "mm3.h" <br>#include "heroes3.h" <br>//-------------------------------------------------------------------------- <br>- <br>#pragma package(smart_init) <br>#pragma resource "*.dfm" <br>TForm1 *Form1; <br>static DWORD iPID,iTID; <br>static HANDLE hHeroes3; <br>static hero heroes[1000]; <br>static int BASE_ADDR=0x132ffc0+sizeof(RAW_HERO)-16;//133595c;//0x1359fd2;//0 <br>x134d633; <br>static int curr_addr; <br>static int count; <br>static int resource_addr=0x132f99c; <br>static DWORD pppppp; <br>#define PEEK(addr,buffer,size)/ <br>&nbsp; &nbsp; ReadProcessMemory(hHeroes3,(void*)(addr),buffer,size,&amp;pppppp) <br>#define POKE(addr,buffer,size)/ <br>&nbsp; &nbsp; WriteProcessMemory(hHeroes3,(void*)(addr),buffer,size,&amp;pppppp) <br>static void ShowHero(hero * h); <br>static void ShowResources(int * r); <br>static &nbsp;int HeroIndex(); <br>static int hcount=156; <br>static char strings[20480]; <br>static char * unit_names[300]; <br>static char magic_strings[20480]; <br>static char magic_legend_strings[20480]; <br>static char * magic_names[300]; <br>static char * magic_legends[300]; <br>class my_string <br>{ <br>public: <br>&nbsp; &nbsp; my_string(int aa){ <br>&nbsp; &nbsp; &nbsp; &nbsp; sprintf(buffer,"%d",aa); <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; char buffer[256]; <br>}; <br>//-------------------------------------------------------------------------- <br>- <br>__fastcall TForm1::TForm1(TComponent* Owner) <br>&nbsp; &nbsp; : TForm(Owner) <br>{ <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::FormCreate(TObject *Sender) <br>{ <br>&nbsp; &nbsp; char buf[32]; <br>&nbsp; &nbsp; char *p; <br>&nbsp; &nbsp; OSVERSIONINFO osvi; <br>&nbsp; &nbsp; memset(&amp;osvi,0,sizeof(osvi)); <br>&nbsp; &nbsp; osvi.dwOSVersionInfoSize =sizeof(osvi); <br>&nbsp; &nbsp; GetVersionEx (&amp;osvi); <br>&nbsp; &nbsp; bool bIsWindows95orLater = <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS? <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;true : false; <br>&nbsp; &nbsp; if(bIsWindows95orLater){ <br>&nbsp; &nbsp; &nbsp; &nbsp; BASE_ADDR=0x1366d1b-16; <br>&nbsp; &nbsp; &nbsp; &nbsp; resource_addr=0x136627c; <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; HWND hHero3=FindWindow(NULL,"Heroes of Might and Magic III: Armageddon's <br>&nbsp;Blade"); <br>&nbsp; &nbsp; if(hHero3){ <br>&nbsp; &nbsp; &nbsp; &nbsp; iTID=GetWindowThreadProcessId(hHero3,&amp;iPID); <br>&nbsp; &nbsp; &nbsp; &nbsp; hHeroes3=OpenProcess(PROCESS_ALL_ACCESS,false,iPID); <br>&nbsp; &nbsp; }else{ <br>&nbsp; &nbsp; &nbsp; &nbsp; MessageBox(Handle,"Heroes III AB is not running,so quit.","mm3",MB_O <br>K); <br>&nbsp; &nbsp; &nbsp; &nbsp; //Application-&gt;Terminate(); <br>&nbsp; &nbsp; &nbsp; &nbsp; return; <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; sprintf(buf,"%08x",hHero3); <br>&nbsp; &nbsp; int i; <br>&nbsp; &nbsp; int start=BASE_ADDR; <br>&nbsp; &nbsp; for(i=0;i&lt;hcount;i++){ <br>&nbsp; &nbsp; &nbsp; &nbsp; RAW_HERO * hh=new RAW_HERO; <br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD pp; <br>&nbsp; &nbsp; &nbsp; &nbsp; ReadProcessMemory(hHeroes3,(void*)start,hh,sizeof(RAW_HERO),&amp;pp); <br>&nbsp; &nbsp; &nbsp; &nbsp; heroes.set_buffer((void*)hh); <br>&nbsp; &nbsp; &nbsp; &nbsp; start+=sizeof(RAW_HERO); <br>&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;ComboBox3-&gt;Items-&gt;Add(hh-&gt;name); <br>&nbsp; &nbsp; }; <br>&nbsp; &nbsp; curr_addr=BASE_ADDR+155*HERO_SIZE; <br>&nbsp; &nbsp; ComboBox3-&gt;ItemIndex=0; <br>&nbsp; &nbsp; int r[7]; <br>&nbsp; &nbsp; char rbuf[10240]; <br>&nbsp; &nbsp; PEEK(resource_addr,rbuf,10240); <br>&nbsp; &nbsp; p=rbuf; <br>&nbsp; &nbsp; while( !strncmp(p+48,"Computer",8) ) p+=0x160; <br>&nbsp; &nbsp; resource_addr+=p-rbuf; <br>&nbsp; &nbsp; memcpy(r,p,7*sizeof(int)); <br>&nbsp; &nbsp; //show resources <br>&nbsp; &nbsp; ShowResources(r); <br>&nbsp; &nbsp; #define name_count &nbsp;(150) <br>&nbsp; &nbsp; char * offsets[name_count*4]; <br>&nbsp; &nbsp; PEEK((void*)(0x67a890+4*150),offsets,name_count*4); <br>// &nbsp; &nbsp;FILE * fp=fopen("names.bin","wb"); <br>&nbsp; // &nbsp;fwrite(names,1,10240*2,fp); <br>&nbsp; &nbsp; //fclose(fp); <br>&nbsp; &nbsp; //?????? <br>&nbsp; &nbsp; p=strings; <br>&nbsp; &nbsp; for(i=0;i&lt;name_count;i++) <br>&nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; PEEK((void *)offsets,p,256); <br>&nbsp; &nbsp; &nbsp; &nbsp; unit_names[i =p; <br>&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;ListBox1-&gt;Items-&gt;Add(p); <br>&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;ListBox2-&gt;Items-&gt;Add(p); <br>&nbsp; &nbsp; &nbsp; &nbsp; p+=strlen(p)+1; <br>&nbsp; &nbsp; }; <br>&nbsp; &nbsp; ShowHero(heroes); <br>&nbsp; &nbsp; //magic names <br>&nbsp; &nbsp; int m_count=0,cc=0; <br>&nbsp; &nbsp; int magics[2736]; <br>&nbsp; &nbsp; char *pp; <br>&nbsp; &nbsp; pp=magic_strings; <br>&nbsp; &nbsp; PEEK((void*)(0x66a2dc),(void*)magics,2736*sizeof(char*)); <br>&nbsp; &nbsp; for(i=0;i&lt;2736;i++){ <br>&nbsp; &nbsp; &nbsp; &nbsp; int offset=(int)(magics); <br>&nbsp; &nbsp; &nbsp; &nbsp; char buf[256]; <br>&nbsp; &nbsp; &nbsp; &nbsp; if(offset &gt; 0x1000000){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( PEEK((void*)offset,buf,256) ){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ListBox4-&gt;Items-&gt;Add(buf); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(pp,buf); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; magic_names[m_count++ =pp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int kkkk=0;kkkk&lt;strlen(pp);kkkk++) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(pp[kkkk] == '{' || pp[kkkk =='}') <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pp[kkkk ='/n'; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pp+=strlen(pp)+1; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cc++; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void ShowHero(hero * h) <br>{ <br>&nbsp; &nbsp; int index=h-heroes; <br>&nbsp; &nbsp; //PEEK(BASE_ADDR+HERO_SIZE*index,heroes[index].get_buffer(),HERO_SIZE); <br>&nbsp; &nbsp; char * skills=h-&gt;skills(); <br>&nbsp; &nbsp; Form1-&gt;Edit1-&gt;Text=(int)skills[0]; <br>&nbsp; &nbsp; Form1-&gt;Edit2-&gt;Text=(int)skills[1]; <br>&nbsp; &nbsp; Form1-&gt;Edit3-&gt;Text=(int)skills[2]; <br>&nbsp; &nbsp; Form1-&gt;Edit4-&gt;Text=(int)skills[3]; <br>&nbsp; &nbsp; int * units=h-&gt;unit_codes(); <br>&nbsp; &nbsp; int * nums=h-&gt;unit_counts(); <br>#define code(m,p) / <br>&nbsp; &nbsp; Form1-&gt;Button##m-&gt;Caption=(units[p == -1 ? / <br>&nbsp; &nbsp; &nbsp; &nbsp; AnsiString("") : AnsiString(unit_names[units[p]])) <br>#define num(m,p) &nbsp;/ <br>&nbsp; &nbsp; Form1-&gt;Edit##m-&gt;Text=(units[p == -1? AnsiString(0) : AnsiString(nums[p]) <br>) <br>&nbsp; &nbsp; code(4,0); <br>&nbsp; &nbsp; code(5,1); <br>&nbsp; &nbsp; code(6,2); <br>&nbsp; &nbsp; code(7,3); <br>&nbsp; &nbsp; code(8,4); <br>&nbsp; &nbsp; code(9,5); <br>&nbsp; &nbsp; code(10,6); <br>&nbsp; &nbsp; num(12,0); <br>&nbsp; &nbsp; num(13,1); <br>&nbsp; &nbsp; num(14,2); <br>&nbsp; &nbsp; num(15,3); <br>&nbsp; &nbsp; num(16,4); <br>&nbsp; &nbsp; num(17,5); <br>&nbsp; &nbsp; num(18,6); <br>&nbsp; &nbsp; Form1-&gt;Edit19-&gt;Text=*(h-&gt;m_spellleft); <br>&nbsp; &nbsp; Form1-&gt;Edit20-&gt;Text=*(h-&gt;m_movement); <br>&nbsp; &nbsp; //display magic information <br>&nbsp; &nbsp; int i; <br>&nbsp; &nbsp; Form1-&gt;ListBox3-&gt;Clear(); <br>&nbsp; &nbsp; for(i=0;i&lt;hero::magic_count;i++){ <br>&nbsp; &nbsp; &nbsp; &nbsp; if(h-&gt;m_magics){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Form1-&gt;ListBox3-&gt;Items-&gt;Add(magic_names[i*6]); <br>&nbsp; &nbsp; &nbsp; &nbsp; }; <br>&nbsp; &nbsp; } <br>} <br>void __fastcall TForm1::ComboBox3Change(TObject *Sender) <br>{ <br>&nbsp; &nbsp; int index=HeroIndex(); <br>&nbsp; &nbsp; if(index &gt;=0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; hero * h=heroes+index; <br>&nbsp; &nbsp; &nbsp; &nbsp; ShowHero(h); <br>&nbsp; &nbsp; }; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button2Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; RAW_HERO hh; <br>&nbsp; &nbsp; DWORD pp; <br>&nbsp; &nbsp; curr_addr-=sizeof(RAW_HERO); <br>&nbsp; &nbsp; int start=curr_addr; <br>&nbsp; &nbsp; ReadProcessMemory(hHeroes3,(void*)start,&amp;hh,sizeof(RAW_HERO),&amp;pp); <br>&nbsp; &nbsp; hero h(&amp;hh); <br>&nbsp; &nbsp; ShowHero(&amp;h); <br>&nbsp; &nbsp; this-&gt;Label7-&gt;Caption=AnsiString(h.name())+my_string(--::count).buffer; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button3Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; RAW_HERO hh; <br>&nbsp; &nbsp; curr_addr+=sizeof(RAW_HERO); <br>&nbsp; &nbsp; int start=curr_addr; <br>&nbsp; &nbsp; ReadProcessMemory(hHeroes3,(void*)start,&amp;hh,sizeof(RAW_HERO),&amp;pppppp); <br>&nbsp; &nbsp; hero h(&amp;hh); <br>&nbsp; &nbsp; ShowHero(&amp;h); <br>&nbsp; &nbsp; this-&gt;Label7-&gt;Caption=AnsiString(h.name())+my_string(++::count).buffer; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Label1MouseMove(TObject *Sender, TShiftState Shift, <br>&nbsp; &nbsp; &nbsp; int X, int Y) <br>{ <br>&nbsp; &nbsp; Label1-&gt;Font-&gt;Color=clBlue; <br>&nbsp; &nbsp; Label1-&gt;Font-&gt;Style&lt;&lt;fsUnderline; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Panel1MouseMove(TObject *Sender, TShiftState Shift, <br>&nbsp; &nbsp; &nbsp; int X, int Y) <br>{ <br>&nbsp; &nbsp; Label1-&gt;Font-&gt;Color=clBlack; <br>&nbsp; &nbsp; Label1-&gt;Font-&gt;Style &gt;&gt;fsUnderline; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Label1Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ShellExecute(Handle, "open", "mailto:jhunter@263.net", NULL, NULL, SW_SH <br>OWNORMAL); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button1Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; int i; <br>&nbsp; &nbsp; if( this-&gt;PageControl1-&gt;ActivePage == this-&gt;TabSheet1 ){ <br>//write current hero <br>#ifdef ET <br>#undef ET <br>#endif <br>#define ET(m,n) skills[n =(char)(Form1-&gt;Edit##m-&gt;Text.ToInt()); <br>&nbsp; &nbsp; &nbsp; &nbsp; int index=HeroIndex(); <br>&nbsp; &nbsp; &nbsp; &nbsp; if(index &gt;=0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PEEK(BASE_ADDR+HERO_SIZE*index,heroes[index].get_buffer(),HERO <br>_SIZE); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char * skills=heroes[index].skills(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ET(1,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ET(2,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ET(3,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ET(4,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //write units <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int * units=heroes[index].unit_counts(); <br>#define num(m,p) units[p =Form1-&gt;Edit##m-&gt;Text.ToInt(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(12,0); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(13,1); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(14,2); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(15,3); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(16,4); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(17,5); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num(18,6); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *(heroes[index].m_spellleft)=Form1-&gt;Edit19-&gt;Text.ToInt();; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *(heroes[index].m_movement)=Form1-&gt;Edit20-&gt;Text.ToInt();; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; POKE(BASE_ADDR+HERO_SIZE*index,heroes[index].get_buffer(),HERO_S <br>IZE); <br>&nbsp; &nbsp; &nbsp; &nbsp; }; <br>&nbsp; &nbsp; }else if(this-&gt;PageControl1-&gt;ActivePage == this-&gt;TabSheet2){ <br>&nbsp; &nbsp; &nbsp; &nbsp; //write resources <br>&nbsp; &nbsp; &nbsp; &nbsp; int r[7]; <br>#ifdef ET <br>#undef ET <br>#endif <br>#define ET(m,n) r[n =Form1-&gt;Edit##m-&gt;Text.ToInt() <br>&nbsp; &nbsp; &nbsp; &nbsp; int i=0; <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(5,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(6,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(7,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(8,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(9,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(10,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; ET(11,i++); <br>&nbsp; &nbsp; &nbsp; &nbsp; POKE(resource_addr,&amp;r,7*sizeof(int)); <br>&nbsp; &nbsp; } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void ShowResources(int * r) <br>{ <br>#ifdef ET <br>#undef ET <br>#endif <br>#define ET(m,n)/ <br>&nbsp; &nbsp; Form1-&gt;Edit##m-&gt;Text=r[n]; <br>&nbsp; &nbsp; PEEK(resource_addr,r,7*sizeof(int)); <br>&nbsp; &nbsp; int i=0; <br>&nbsp; &nbsp; ET(5,i++); <br>&nbsp; &nbsp; ET(6,i++); <br>&nbsp; &nbsp; ET(7,i++); <br>&nbsp; &nbsp; ET(8,i++); <br>&nbsp; &nbsp; ET(9,i++); <br>&nbsp; &nbsp; ET(10,i++); <br>&nbsp; &nbsp; ET(11,i++); <br>} <br>static &nbsp;int HeroIndex() <br>{ <br>&nbsp; &nbsp; int i=Form1-&gt;ComboBox3-&gt;ItemIndex; <br>&nbsp; &nbsp; if(i&lt;0) return i; <br>&nbsp; &nbsp; AnsiString s=Form1-&gt;ComboBox3-&gt;Items-&gt;Strings; <br>&nbsp; &nbsp; for(i=0;i&lt;hcount;i++){ <br>&nbsp; &nbsp; &nbsp; &nbsp; if( s==heroes.name() ) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; if( i &gt;= hcount) <br>&nbsp; &nbsp; &nbsp; &nbsp; i=-1; <br>&nbsp; &nbsp; return i; <br>} <br>void __fastcall TForm1::ListBox1Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; this-&gt;Label7-&gt;Caption=this-&gt;ListBox1-&gt;ItemIndex; <br>} <br>static int unit_num; <br>//-------------------------------------------------------------------------- <br>- <br>static void ModifyUnitName(TButton * btn,int n) <br>{ <br>&nbsp; &nbsp; int h=HeroIndex(); <br>&nbsp; &nbsp; if(h&lt;0) return; <br>&nbsp; &nbsp; Form1-&gt;ListBox2-&gt;Left=btn-&gt;Left; <br>&nbsp; &nbsp; Form1-&gt;ListBox2-&gt;Top=btn-&gt;Top; <br>&nbsp; &nbsp; Form1-&gt;ListBox2-&gt;Visible=true; <br>&nbsp; &nbsp; unit_num=n; <br>&nbsp; &nbsp; int * units=heroes[h].unit_codes(); <br>&nbsp; &nbsp; Form1-&gt;ListBox2-&gt;ItemIndex=units[n]; <br>&nbsp; &nbsp; Form1-&gt;ListBox2-&gt;SetFocus(); <br>}; <br>void __fastcall TForm1::Button4Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button4,0); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox2Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; int i=ListBox2-&gt;ItemIndex; <br>&nbsp; &nbsp; if(i&gt;=0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; int h=HeroIndex(); <br>&nbsp; &nbsp; &nbsp; &nbsp; if(h&gt;=0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int * units=heroes[h].unit_codes(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; units[unit_num =i; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; ShowHero(heroes+h); <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; ListBox2-&gt;Visible=false; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button5Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button5,1); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button6Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button6,2); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button7Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button7,3); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button8Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button8,4); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button9Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button9,5); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button10Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ModifyUnitName(Button10,6); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button13Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; int i=HeroIndex(); <br>&nbsp; &nbsp; if(i&gt;=0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; memset(heroes.m_magics,1,hero::magic_count); <br>&nbsp; &nbsp; } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox4Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; Label7-&gt;Caption=ListBox4-&gt;ItemIndex; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox2KeyDown(TObject *Sender, WORD &amp;Key, <br>&nbsp; &nbsp; &nbsp; TShiftState Shift) <br>{ <br>&nbsp; &nbsp; if(Key==VK_ESCAPE){ <br>&nbsp; &nbsp; &nbsp; &nbsp; ListBox2-&gt;Visible=false; <br>&nbsp; &nbsp; } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::FormActivate(TObject *Sender) <br>{ <br>&nbsp; &nbsp; //refresh hero and data <br>&nbsp; &nbsp; ComboBox3Change(this); <br>&nbsp; &nbsp; int r[7]; <br>&nbsp; &nbsp; ShowResources(r); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox2Exit(TObject *Sender) <br>{ <br>&nbsp; &nbsp; ListBox2-&gt;Visible=false; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox3Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; int idx=ListBox3-&gt;ItemIndex; <br>&nbsp; &nbsp; if(idx&lt;0) &nbsp; return; <br>&nbsp; &nbsp; int i; <br>&nbsp; &nbsp; AnsiString s=ListBox3-&gt;Items-&gt;Strings[idx]; <br>&nbsp; &nbsp; char buf [1024]; <br>&nbsp; &nbsp; for(i=0;i&lt;80;i++){ <br>&nbsp; &nbsp; &nbsp; &nbsp; if(s == magic_names[i*6]){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sprintf(buf,"%s /n%s/n %s/n %s/n",magic_names[i*6+1],magic_names <br>[i*6+2], <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; magic_names[i*6+3],magic_names[i*6+4]); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Memo1-&gt;Text=buf; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button14Click(TObject *Sender) <br>{ <br>&nbsp; &nbsp; int i; <br>&nbsp; &nbsp; FILE * fp=fopen("artifact.txt","w"); <br>&nbsp; &nbsp; char buf[1024]; <br>&nbsp; &nbsp; ListBox1-&gt;Clear(); <br>&nbsp; &nbsp; for(i=0;i&lt;256;i++){ <br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD tt=0x678530+(i&lt;&lt;2); <br>&nbsp; &nbsp; &nbsp; &nbsp; PEEK(tt,&amp;tt,sizeof(tt)); <br>&nbsp; &nbsp; &nbsp; &nbsp; PEEK(tt,buf,sizeof(buf)); <br>&nbsp; &nbsp; &nbsp; &nbsp; ListBox1-&gt;Items-&gt;Add(buf); <br>&nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp,"%s/n",buf); <br>&nbsp; &nbsp; } <br>}
 
老大,不是那么简单的....<br>windows对内存的管理和dos下不同<br>而且估计需要VXD才能解决
 
我的主页上有我写的一个工具,你看一看,如果还过得去的话我可以把关于内存部分的源代码给你。<br>http://zhangyi1980.home.chinaren.com/MyPrograms/index.html<br>文件工具 Ver0.39
 
跨越内存禁区修改游戏数据(2001年第2期) <br>http://www.csdn.net/magazine/source/2/Hero.doc<br><br>unit uheromate;//本单元与uheromate窗体相对应<br>interface<br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, Menus, ComCtrls, Grids, ExtCtrls,ShellApi;<br>type<br>&nbsp; TModifyThread = class(TThread) &nbsp;//新建线程类,用于修改英雄属性页的设置<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; protected<br>&nbsp; &nbsp; procedure Execute; override;<br>&nbsp; end;<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Label1: TLabel;<br>&nbsp; &nbsp; PageControl1: TPageControl;<br>&nbsp; &nbsp; TabSheet1: TTabSheet;<br>&nbsp; &nbsp; Label3: TLabel;<br>&nbsp; &nbsp; Edit1: TEdit;<br>&nbsp; &nbsp; UpDown1: TUpDown;<br>&nbsp; &nbsp; Edit2: TEdit;<br>&nbsp; &nbsp; UpDown2: TUpDown;<br>&nbsp; &nbsp; Edit3: TEdit;<br>&nbsp; &nbsp; UpDown3: TUpDown;<br>&nbsp; &nbsp; Edit4: TEdit;<br>&nbsp; &nbsp; UpDown4: TUpDown;<br>&nbsp; &nbsp; CheckBox1: TCheckBox; &nbsp;//英雄技能页—是否增加所有第二技能<br>&nbsp; &nbsp; CheckBox2: TCheckBox; &nbsp;//英雄技能页—是否修改四项第一技能<br>&nbsp; &nbsp; TabSheet2: TTabSheet;<br>&nbsp; &nbsp; TabSheet3: TTabSheet;<br>&nbsp; &nbsp; TabSheet4: TTabSheet;<br>&nbsp; &nbsp; ComboBox1: TComboBox; &nbsp;//英雄技能页—下拉框,用于选择英雄<br>&nbsp; &nbsp; Label2: TLabel;<br>&nbsp; &nbsp; B_skill: TButton; &nbsp;//英雄技能页—变更英雄属性按钮<br>&nbsp; &nbsp; B_nolimit: TButton; //机动力页—使英雄机动力无限按钮<br>&nbsp; &nbsp; B_allday: TButton;// 机动力页—锁定英雄机动力按钮<br>&nbsp; &nbsp; Timer1: TTimer;<br>&nbsp; &nbsp; ListBox1: TListBox;<br>&nbsp; &nbsp; B_okToAddArtifact: TButton; //宝物页—根据列表框中宝物修改游戏内存<br>&nbsp; &nbsp; B_add: TButton;//宝物页—增加宝物到列表框按钮<br>&nbsp; &nbsp; Label4: TLabel;<br>&nbsp; &nbsp; ComboBox2: TComboBox; //宝物页—宝物列表框<br>&nbsp; &nbsp; B_return: TButton; //返回游戏按钮<br>&nbsp; &nbsp; B_Remove: TButton; //宝物页—从列表框中减少宝物<br>&nbsp; &nbsp; procedure B_skillClick(Sender: TObject);<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure ComboBox1Change(Sender: TObject);<br>&nbsp; &nbsp; procedure CheckBox2Click(Sender: TObject);<br>&nbsp; &nbsp; procedure B_nolimitClick(Sender: TObject);<br>&nbsp; &nbsp; procedure B_alldayClick(Sender: TObject);<br>&nbsp; &nbsp; procedure Timer1Timer(Sender: TObject);<br>&nbsp; &nbsp; procedure B_okToAddArtifactClick(Sender: TObject);<br>&nbsp; &nbsp; procedure B_addClick(Sender: TObject);<br>&nbsp; &nbsp; procedure B_returnClick(Sender: TObject);<br>&nbsp; &nbsp; procedure B_RemoveClick(Sender: TObject);<br>&nbsp; &nbsp; procedure FormDestroy(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; heroname:pchar; &nbsp;//当前修改的英雄名<br>&nbsp; heroBaseAdd,heroAdd:integer; &nbsp;//第一个英雄的地址和当前英雄的序号<br>&nbsp; heros:array[0..180] of pchar; &nbsp;//英雄名序列<br>&nbsp; isdebug:integer; //是否已用OpenProcess函数打开游戏进程<br><br>&nbsp; winhwnd:hwnd; &nbsp;//游戏窗口句柄<br>&nbsp; pId,threadId:Integer; //拥有游戏主窗口的进程和线程ID<br>&nbsp; hProcess: THandle; &nbsp;//用OpenProcess函数游戏进程的句柄<br><br>&nbsp; str1:string='锁定机动力';<br>&nbsp; str2:string='取消锁定';<br><br>implementation<br>{$R *.DFM}<br><br>procedure TForm1.B_skillClick(Sender: TObject);//修改英雄属性页设置<br>var<br>&nbsp; &nbsp;threadNew:TModifyThread;<br>begin<br>&nbsp;threadNew:=TModifyThread.Create(false);<br>&nbsp;threadNew.Execute;<br>&nbsp;if not SetForegroundWindow(winhWnd) then<br>&nbsp; &nbsp;showmessage(inttostr(getlasterror));<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>isdebug:=0;<br>heroBaseAdd:=$015c7f63; &nbsp;//&lt;--光盘版$015d7f63;//硬盘版 $015c7f63;<br><br>heros[0]:='Orrin'; heros[1]:='Valeska'; heros[2]:='Edric'; heros[3]:='Sylvia';<br>heros[4]:='Lord Haart(1)';heros[5]:='Sorsha'; heros[6]:='Christian'; heros[7]:='Tyris';<br>heros[8]:='Rion'; heros[9]:='Adela'; heros[10]:='Cuthbert'; &nbsp;heros[11]:='Adelaide';<br>heros[12]:='Ingham'; &nbsp; heros[13]:='Sanya'; heros[14]:='Loynis'; heros[15]:='Caitlin';<br>heros[16]:='Mephala'; heros[17]:='Ufretin'; heros[18]:='Jenova'; heros[19]:='Ryland';<br>heros[20]:='Thorgrim'; heros[21]:='Ivor'; heros[22]:='Clancy'; heros[23]:='Kyrre';<br>heros[24]:='Coronius'; heros[25]:='Uland'; heros[26]:='Elleshar'; heros[27]:='Gem';<br>heros[28]:='Malcom'; heros[29]:='Melodia'; heros[30]:='Alagar'; heros[31]:='Aeris';<br>heros[32]:='Piquedram'; heros[33]:='Thane'; heros[34]:='Josephine'; heros[35]:='Neela';<br>heros[36]:='Torosar'; heros[37]:='Fafner'; heros[38]:='Rissa'; heros[39]:='Iona';<br>heros[40]:='Astral'; heros[41]:='Halon'; heros[42]:='Serena'; heros[43]:='Daremyth';<br>heros[44]:='Theodorus'; heros[45]:='Solmyr'; heros[46]:='Cyra'; heros[47]:='Aine';<br>heros[48]:='Fiona'; heros[49]:='Rashka'; heros[50]:='Marius'; heros[51]:='Ignatius';<br>heros[52]:='Octavia'; heros[53]:='Calh'; heros[54]:='Pyre'; heros[55]:='Nymus';<br>heros[56]:='Ayden'; heros[57]:='Xyron'; heros[58]:='Axsis'; heros[59]:='Olema';<br>heros[60]:='Calid'; heros[61]:='Ash'; heros[62]:='Zydar'; heros[63]:='Xarfax';<br>heros[64]:='Straker'; heros[65]:='Vokial'; heros[66]:='Moandor'; heros[67]:='Charna';<br>heros[68]:='TamikaIsra'; heros[69]:='Isra'; heros[70]:='Clavius'; heros[71]:='Galthran';<br>heros[72]:='Septienna'; heros[73]:='Aislinn'; heros[74]:='Sandro'; heros[75]:='Nimbus';<br>heros[76]:='Thant'; heros[77]:='Xsi'; heros[78]:='Vidomina'; heros[79]:='Nagash';<br>heros[80]:='Lorelei'; heros[81]:='Arlach'; heros[82]:='Dace'; heros[83]:='Ajit';<br>heros[84]:='Damacon'; heros[85]:='Gunnar'; heros[86]:='Synca'; heros[87]:='Shakti';<br>heros[88]:='Alamar'; heros[89]:='Jaegar'; heros[90]:='Malekith'; heros[91]:='Jeddite';<br>heros[92]:='Geon'; heros[93]:='Deemer'; heros[94]:='Sephinroth'; heros[95]:='Darkstorn';<br>heros[96]:='Yog'; heros[97]:='Gurnisson'; heros[98]:='Jabarkas'; heros[99]:='Shiva';<br>heros[100]:='Gretchin'; heros[101]:='Krellion'; heros[102]:='Crag Hack';heros[103]:='Tyraxor';<br>heros[104]:='Gird'; heros[105]:='Vey'; heros[106]:='Dessa'; heros[107]:='Terek';<br>heros[108]:='Zubin'; heros[109]:='Gundula'; heros[110]:='Oris'; heros[111]:='Saurug';<br>heros[112]:='Bron'; heros[113]:='Drakon'; heros[114]:='Wystan'; heros[115]:='Tazar';<br>heros[116]:='Alkin'; heros[117]:='Korbac'; heros[118]:='Gerwulf'; heros[119]:='Broghild';<br>heros[120]:='Mirlanda'; heros[121]:='Rosic'; heros[122]:='Voy'; heros[123]:='Verdish';<br>heros[124]:='Merist'; heros[125]:='Styg'; heros[126]:='Andra'; heros[127]:='Tiva';<br>heros[128]:='Pasis'; heros[129]:='Thunar'; heros[130]:='Ignissa'; heros[131]:='Lacus';<br>heros[132]:='Monere'; heros[133]:='Erdamon'; heros[134]:='Fiur'; heros[135]:='Kalt';<br>heros[136]:='Luna'; heros[137]:='Brissa'; heros[138]:='Ciele'; heros[139]:='Labetha';<br>heros[140]:='Inteus'; heros[141]:='Aenain'; heros[142]:='Gelare'; heros[143]:='Grindan';<br>heros[144]:='Sir Mullich';heros[145]:='Adrienne';heros[146]:='Catherine'; heros[147]:='Dracon';<br>heros[148]:='Gelu'; heros[149]:='Kilgor'; heros[150]:='Lord Haart';heros[151]:='Mutare';<br>heros[152]:='Roland'; heros[153]:='Mutare Drake';heros[154]:='Boragus';heros[155]:='Xeron';<br>end;<br><br>procedure TForm1.ComboBox1Change(Sender: TObject); &nbsp;//取得当前英雄的内存地址<br>var<br>&nbsp; &nbsp;OrrinBuffer:array[0..4] of byte;<br>&nbsp; &nbsp;i:integer;<br>&nbsp; &nbsp;lpNumberOfBytesWritten: DWORD;<br>begin<br>&nbsp; &nbsp;ListBox1.Items.Clear;<br>if isdebug=0 then &nbsp;//未执行OpenProcess<br>begin<br>&nbsp; &nbsp;winhwnd:=FindWindow(NIL,'Heroes of Might and Magic III: Armageddon''s Blade');<br>&nbsp; &nbsp;if winhwnd=0 then winhwnd:=FindWindow(NIL,'Heroes of Might and Magic III');<br>&nbsp; &nbsp; &nbsp; &nbsp;if winhwnd=0 then &nbsp;showmessage('Heroes III is not running');<br>&nbsp; &nbsp;threadId:=GetWindowThreadProcessId(winhwnd,@pId) ;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if threadId=0 then &nbsp; &nbsp;showmessage('not find id');<br>&nbsp; &nbsp;hProcess:=OpenProcess(PROCESS_ALL_ACCESS,true, pId);<br>&nbsp; &nbsp;isdebug:=1;<br>&nbsp; &nbsp;//查找英雄数据区基地址heroBaseAdd<br>&nbsp; &nbsp;for i:=5 to 20 do //in least add 600000<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ReadProcessMemory(hProcess,ptr(heroBaseAdd), @OrrinBuffer,5, lpNumberOfBytesWritten);<br>&nbsp; &nbsp; &nbsp; &nbsp;//英雄数据区基地址处的值应是第一个英雄的名字:”Orrin”<br>&nbsp; &nbsp; &nbsp; &nbsp;if (OrrinBuffer[0]=79) and (OrrinBuffer[1]=114)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and (OrrinBuffer[2]=114) &nbsp;and (OrrinBuffer[3]=105)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and (OrrinBuffer[4]=110) &nbsp;then &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp;if (i mod 2)=1 then //<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heroBaseAdd:=heroBaseAdd+$10000 // &lt;--光盘版比硬盘版多$10000<br>&nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heroBaseAdd:=$015c7f63+$100000*(i div 2) +$30000; //硬盘版<br>&nbsp; &nbsp;end;<br>end;<br>//得到欲修改的英雄的序号<br>&nbsp; &nbsp;heroname:=Pchar(combobox1.text);<br>&nbsp; &nbsp;for i :=0 &nbsp;to 165 do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if strcomp(heros,heroname)=0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heroadd:=i;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;end;<br>end;<br><br>procedure TModifyThread.Execute; //修改英雄属性页的设置<br>var<br>&nbsp; &nbsp;lpBuffer: array[0..56] of byte;<br>&nbsp; &nbsp;four: array[0..3] of byte;<br>&nbsp; &nbsp;lpNumberOfBytesWritten: DWORD;<br>&nbsp; &nbsp;i:integer;<br>begin<br>&nbsp; for i := 0 to 27 do<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; lpBuffer:=3;<br>&nbsp; end;<br>&nbsp; for i := 28 to 35 do<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; lpBuffer:=i-27;<br>&nbsp; end;<br>&nbsp; lpBuffer[56]:=27; &nbsp;//总共有27项魔法<br>&nbsp; lpBuffer[12]:=0; &nbsp; //不设置招魂术<br><br>&nbsp; four[0]:=Form1.UpDown1.Position;<br>&nbsp; four[1]:=Form1.UpDown2.Position;<br>&nbsp; four[2]:=Form1.UpDown3.Position;<br>&nbsp; four[3]:=Form1.UpDown4.Position;<br>&nbsp; if Form1.CheckBox1.Checked=true then //增加第二技能<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if not WriteProcessMemory(hProcess,ptr(heroBaseAdd+heroadd*$492+$A6), @lpBuffer,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 57, lpNumberOfBytesWritten) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('Write mem Error');<br>&nbsp; &nbsp; end;<br>&nbsp; if Form1.CheckBox2.Checked=true then //设置第一技能<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if not WriteProcessMemory(hProcess,ptr(heroBaseAdd+heroadd*$492+$453), @four,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4, lpNumberOfBytesWritten) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('Write mem Error');<br>&nbsp; &nbsp; end;<br>end;<br><br>procedure TForm1.CheckBox2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp; edit1.Enabled:=not(edit1.Enabled);<br>&nbsp; &nbsp; &nbsp; edit2.Enabled:=not(edit2.Enabled);<br>&nbsp; &nbsp; &nbsp; edit3.Enabled:=not(edit3.Enabled);<br>&nbsp; &nbsp; &nbsp; edit4.Enabled:=not(edit4.Enabled);<br>&nbsp; &nbsp; &nbsp; updown1.Enabled:=not(updown1.Enabled);<br>&nbsp; &nbsp; &nbsp; updown2.Enabled:=not(updown2.Enabled);<br>&nbsp; &nbsp; &nbsp; updown3.Enabled:=not(updown3.Enabled);<br>&nbsp; &nbsp; &nbsp; updown4.Enabled:=not(updown4.Enabled);<br>end;<br><br>procedure TForm1.B_nolimitClick(Sender: TObject); &nbsp;//无限机动力<br>var<br>&nbsp; &nbsp;newdistance: array[0..1] of byte;<br>&nbsp; &nbsp;lpNumberOfBytesWritten: DWORD;<br>begin<br>&nbsp; &nbsp;newdistance[0]:=$99;<br>&nbsp; &nbsp;newdistance[1]:=$99;<br>&nbsp; &nbsp;if not WriteProcessMemory(hProcess,ptr(heroBaseAdd+heroadd*$492+$2A), @newdistance,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2, lpNumberOfBytesWritten) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror)+'Write mem Error');<br>&nbsp; &nbsp;if not SetForegroundWindow(winhWnd) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror));<br>end;<br><br>procedure TForm1.B_alldayClick(Sender: TObject); //锁定机动力<br>begin<br>&nbsp; &nbsp;if &nbsp;B_allday.Caption=str1 then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; B_allday.Caption:=str2;<br>&nbsp; &nbsp; &nbsp; &nbsp; Timer1.Enabled:=true;<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; B_allday.Caption:=str1;<br>&nbsp; &nbsp; &nbsp; &nbsp; Timer1.Enabled:=False;<br>&nbsp; &nbsp; &nbsp; end;<br>end;<br>procedure TForm1.Timer1Timer(Sender: TObject); &nbsp;//锁定机动力<br>var<br>&nbsp; &nbsp;olddistance: array[0..1] of byte;<br>&nbsp; &nbsp;newdistance: array[0..1] of byte;<br>&nbsp; &nbsp;lpNumberOfBytesWritten: DWORD;<br>begin<br>&nbsp; &nbsp;if not ReadProcessMemory(hProcess,ptr(heroBaseAdd+heroadd*$492+$26), @olddistance,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2, lpNumberOfBytesWritten) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror)+'Read mem Error');<br>&nbsp; &nbsp;newdistance[0]:=olddistance[0];<br>&nbsp; &nbsp;newdistance[1]:=olddistance[1];<br>&nbsp; &nbsp;if not WriteProcessMemory(hProcess,ptr(heroBaseAdd+heroadd*$492+$2A), @newdistance,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2, lpNumberOfBytesWritten) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror)+'Write mem Error');<br>&nbsp; if not SetForegroundWindow(winhWnd) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror));<br>end;<br>procedure TForm1.B_okToAddArtifactClick(Sender: TObject); //增加宝物<br>var<br>&nbsp; &nbsp;i:integer;<br>&nbsp; &nbsp;Artifact:array[0..7] of byte;<br>&nbsp; &nbsp;lpNumberOfBytesWritten: DWORD;<br>begin<br>&nbsp; &nbsp;Artifact[1]:=0; &nbsp; Artifact[2]:=0; &nbsp; Artifact[3]:=0;<br>&nbsp; &nbsp;Artifact[4]:=$FF; Artifact[5]:=$FF; Artifact[6]:=$FF; Artifact[7]:=$FF;<br><br>for i:=0 to Form1.ListBox1.Items.Count-1 do<br>begin<br>&nbsp; Artifact[0]:=ComboBox2.Items.IndexOf(listbox1.Items.Strings)+2;<br>&nbsp; if Artifact[0]&lt;&gt;2 then<br>&nbsp; &nbsp; &nbsp; &nbsp; Artifact[0]:=Artifact[0]+4;<br>&nbsp; if not WriteProcessMemory(hProcess,ptr(heroBaseAdd+heroadd*$492+$1B1+8*i), @Artifact,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8, lpNumberOfBytesWritten) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror)+'Write mem Error');<br>end;<br>&nbsp; if not SetForegroundWindow(winhWnd) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage(inttostr(getlasterror));<br>end;<br><br>procedure TForm1.B_addClick(Sender: TObject);<br>begin<br>&nbsp; &nbsp;ListBox1.Items.Add(ComboBox2.Text);<br>end;<br><br>procedure TForm1.B_returnClick(Sender: TObject);<br>begin<br>&nbsp; &nbsp;showwindow(winhwnd,SW_MAXIMIZE);<br>end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>procedure TForm1.B_RemoveClick(Sender: TObject);<br>begin<br>&nbsp; &nbsp;ListBox1.Items.Delete(ListBox1.ItemIndex);<br>&nbsp; &nbsp;ListBox1.ItemIndex:=0;<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> if hProcess &lt;&gt;0 then &nbsp; closehandle(hProcess); //关闭句柄<br>end;<br>end.<br>
 
&nbsp; &nbsp;其实我已经找到答案了,而且是针对starcraft,但无法给自己加分,可惜了,300分哦!<br>我找内存的方法是通过softice+fpe2000,至于操作内存的方法和大家差不多。<br>&nbsp; &nbsp; 凡是提到GetWindowThreadProcessId、OpenProcess、Read(Write)ProcessMemory的朋友<br>们加较多的分,没有意见吧?
 
一点补充:这个问题的关键在于StarCraft的内存地址的确定,大家都没有提到这一点,其实、<br>sc的两种资源的内存地址是变化的,所以只能用softice反汇编之来确定其地址。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部