哈哈,又可以捞分了,这段代码我也没试过,别人写的,你试试把<br><br>#include <vcl.h> <br>#include <stdio.h> <br>#include <shellapi.h> <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> ReadProcessMemory(hHeroes3,(void*)(addr),buffer,size,&pppppp) <br>#define POKE(addr,buffer,size)/ <br> WriteProcessMemory(hHeroes3,(void*)(addr),buffer,size,&pppppp) <br>static void ShowHero(hero * h); <br>static void ShowResources(int * r); <br>static 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> my_string(int aa){ <br> sprintf(buffer,"%d",aa); <br> } <br> char buffer[256]; <br>}; <br>//-------------------------------------------------------------------------- <br>- <br>__fastcall TForm1::TForm1(TComponent* Owner) <br> : TForm(Owner) <br>{ <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::FormCreate(TObject *Sender) <br>{ <br> char buf[32]; <br> char *p; <br> OSVERSIONINFO osvi; <br> memset(&osvi,0,sizeof(osvi)); <br> osvi.dwOSVersionInfoSize =sizeof(osvi); <br> GetVersionEx (&osvi); <br> bool bIsWindows95orLater = <br> osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS? <br> true : false; <br> if(bIsWindows95orLater){ <br> BASE_ADDR=0x1366d1b-16; <br> resource_addr=0x136627c; <br> } <br> HWND hHero3=FindWindow(NULL,"Heroes of Might and Magic III: Armageddon's <br> Blade"); <br> if(hHero3){ <br> iTID=GetWindowThreadProcessId(hHero3,&iPID); <br> hHeroes3=OpenProcess(PROCESS_ALL_ACCESS,false,iPID); <br> }else{ <br> MessageBox(Handle,"Heroes III AB is not running,so quit.","mm3",MB_O <br>K); <br> //Application->Terminate(); <br> return; <br> } <br> sprintf(buf,"%08x",hHero3); <br> int i; <br> int start=BASE_ADDR; <br> for(i=0;i<hcount;i++){ <br> RAW_HERO * hh=new RAW_HERO; <br> DWORD pp; <br> ReadProcessMemory(hHeroes3,(void*)start,hh,sizeof(RAW_HERO),&pp); <br> heroes
.set_buffer((void*)hh); <br> start+=sizeof(RAW_HERO); <br> this->ComboBox3->Items->Add(hh->name); <br> }; <br> curr_addr=BASE_ADDR+155*HERO_SIZE; <br> ComboBox3->ItemIndex=0; <br> int r[7]; <br> char rbuf[10240]; <br> PEEK(resource_addr,rbuf,10240); <br> p=rbuf; <br> while( !strncmp(p+48,"Computer",8) ) p+=0x160; <br> resource_addr+=p-rbuf; <br> memcpy(r,p,7*sizeof(int)); <br> //show resources <br> ShowResources(r); <br> #define name_count (150) <br> char * offsets[name_count*4]; <br> PEEK((void*)(0x67a890+4*150),offsets,name_count*4); <br>// FILE * fp=fopen("names.bin","wb"); <br> // fwrite(names,1,10240*2,fp); <br> //fclose(fp); <br> //?????? <br> p=strings; <br> for(i=0;i<name_count;i++) <br> { <br> PEEK((void *)offsets,p,256); <br> unit_names[i =p; <br> this->ListBox1->Items->Add(p); <br> this->ListBox2->Items->Add(p); <br> p+=strlen(p)+1; <br> }; <br> ShowHero(heroes); <br> //magic names <br> int m_count=0,cc=0; <br> int magics[2736]; <br> char *pp; <br> pp=magic_strings; <br> PEEK((void*)(0x66a2dc),(void*)magics,2736*sizeof(char*)); <br> for(i=0;i<2736;i++){ <br> int offset=(int)(magics); <br> char buf[256]; <br> if(offset > 0x1000000){ <br> if( PEEK((void*)offset,buf,256) ){ <br> ListBox4->Items->Add(buf); <br> strcpy(pp,buf); <br> magic_names[m_count++ =pp; <br> for(int kkkk=0;kkkk<strlen(pp);kkkk++) <br> if(pp[kkkk] == '{' || pp[kkkk =='}') <br> pp[kkkk ='/n'; <br> pp+=strlen(pp)+1; <br> cc++; <br> }; <br> } <br> } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void ShowHero(hero * h) <br>{ <br> int index=h-heroes; <br> //PEEK(BASE_ADDR+HERO_SIZE*index,heroes[index].get_buffer(),HERO_SIZE); <br> char * skills=h->skills(); <br> Form1->Edit1->Text=(int)skills[0]; <br> Form1->Edit2->Text=(int)skills[1]; <br> Form1->Edit3->Text=(int)skills[2]; <br> Form1->Edit4->Text=(int)skills[3]; <br> int * units=h->unit_codes(); <br> int * nums=h->unit_counts(); <br>#define code(m,p) / <br> Form1->Button##m->Caption=(units[p == -1 ? / <br> AnsiString("") : AnsiString(unit_names[units[p]])) <br>#define num(m,p) / <br> Form1->Edit##m->Text=(units[p == -1? AnsiString(0) : AnsiString(nums[p]) <br>) <br> code(4,0); <br> code(5,1); <br> code(6,2); <br> code(7,3); <br> code(8,4); <br> code(9,5); <br> code(10,6); <br> num(12,0); <br> num(13,1); <br> num(14,2); <br> num(15,3); <br> num(16,4); <br> num(17,5); <br> num(18,6); <br> Form1->Edit19->Text=*(h->m_spellleft); <br> Form1->Edit20->Text=*(h->m_movement); <br> //display magic information <br> int i; <br> Form1->ListBox3->Clear(); <br> for(i=0;i<hero::magic_count;i++){ <br> if(h->m_magics){ <br> //Form1->ListBox3->Items->Add(magic_names[i*6]); <br> }; <br> } <br>} <br>void __fastcall TForm1::ComboBox3Change(TObject *Sender) <br>{ <br> int index=HeroIndex(); <br> if(index >=0){ <br> hero * h=heroes+index; <br> ShowHero(h); <br> }; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button2Click(TObject *Sender) <br>{ <br> RAW_HERO hh; <br> DWORD pp; <br> curr_addr-=sizeof(RAW_HERO); <br> int start=curr_addr; <br> ReadProcessMemory(hHeroes3,(void*)start,&hh,sizeof(RAW_HERO),&pp); <br> hero h(&hh); <br> ShowHero(&h); <br> this->Label7->Caption=AnsiString(h.name())+my_string(--::count).buffer; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button3Click(TObject *Sender) <br>{ <br> RAW_HERO hh; <br> curr_addr+=sizeof(RAW_HERO); <br> int start=curr_addr; <br> ReadProcessMemory(hHeroes3,(void*)start,&hh,sizeof(RAW_HERO),&pppppp); <br> hero h(&hh); <br> ShowHero(&h); <br> this->Label7->Caption=AnsiString(h.name())+my_string(++::count).buffer; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Label1MouseMove(TObject *Sender, TShiftState Shift, <br> int X, int Y) <br>{ <br> Label1->Font->Color=clBlue; <br> Label1->Font->Style<<fsUnderline; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1:anel1MouseMove(TObject *Sender, TShiftState Shift, <br> int X, int Y) <br>{ <br> Label1->Font->Color=clBlack; <br> Label1->Font->Style >>fsUnderline; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Label1Click(TObject *Sender) <br>{ <br> 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> int i; <br> if( this->PageControl1->ActivePage == this->TabSheet1 ){ <br>//write current hero <br>#ifdef ET <br>#undef ET <br>#endif <br>#define ET(m,n) skills[n =(char)(Form1->Edit##m->Text.ToInt()); <br> int index=HeroIndex(); <br> if(index >=0){ <br> //PEEK(BASE_ADDR+HERO_SIZE*index,heroes[index].get_buffer(),HERO <br>_SIZE); <br> char * skills=heroes[index].skills(); <br> i=0; <br> ET(1,i++); <br> ET(2,i++); <br> ET(3,i++); <br> ET(4,i++); <br> //write units <br> int * units=heroes[index].unit_counts(); <br>#define num(m,p) units[p =Form1->Edit##m->Text.ToInt(); <br> num(12,0); <br> num(13,1); <br> num(14,2); <br> num(15,3); <br> num(16,4); <br> num(17,5); <br> num(18,6); <br> *(heroes[index].m_spellleft)=Form1->Edit19->Text.ToInt();; <br> *(heroes[index].m_movement)=Form1->Edit20->Text.ToInt();; <br> POKE(BASE_ADDR+HERO_SIZE*index,heroes[index].get_buffer(),HERO_S <br>IZE); <br> }; <br> }else if(this->PageControl1->ActivePage == this->TabSheet2){ <br> //write resources <br> int r[7]; <br>#ifdef ET <br>#undef ET <br>#endif <br>#define ET(m,n) r[n =Form1->Edit##m->Text.ToInt() <br> int i=0; <br> ET(5,i++); <br> ET(6,i++); <br> ET(7,i++); <br> ET(8,i++); <br> ET(9,i++); <br> ET(10,i++); <br> ET(11,i++); <br> POKE(resource_addr,&r,7*sizeof(int)); <br> } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void ShowResources(int * r) <br>{ <br>#ifdef ET <br>#undef ET <br>#endif <br>#define ET(m,n)/ <br> Form1->Edit##m->Text=r[n]; <br> PEEK(resource_addr,r,7*sizeof(int)); <br> int i=0; <br> ET(5,i++); <br> ET(6,i++); <br> ET(7,i++); <br> ET(8,i++); <br> ET(9,i++); <br> ET(10,i++); <br> ET(11,i++); <br>} <br>static int HeroIndex() <br>{ <br> int i=Form1->ComboBox3->ItemIndex; <br> if(i<0) return i; <br> AnsiString s=Form1->ComboBox3->Items->Strings; <br> for(i=0;i<hcount;i++){ <br> if( s==heroes.name() ) <br> break; <br> } <br> if( i >= hcount) <br> i=-1; <br> return i; <br>} <br>void __fastcall TForm1::ListBox1Click(TObject *Sender) <br>{ <br> this->Label7->Caption=this->ListBox1->ItemIndex; <br>} <br>static int unit_num; <br>//-------------------------------------------------------------------------- <br>- <br>static void ModifyUnitName(TButton * btn,int n) <br>{ <br> int h=HeroIndex(); <br> if(h<0) return; <br> Form1->ListBox2->Left=btn->Left; <br> Form1->ListBox2->Top=btn->Top; <br> Form1->ListBox2->Visible=true; <br> unit_num=n; <br> int * units=heroes[h].unit_codes(); <br> Form1->ListBox2->ItemIndex=units[n]; <br> Form1->ListBox2->SetFocus(); <br>}; <br>void __fastcall TForm1::Button4Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button4,0); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox2Click(TObject *Sender) <br>{ <br> int i=ListBox2->ItemIndex; <br> if(i>=0){ <br> int h=HeroIndex(); <br> if(h>=0){ <br> int * units=heroes[h].unit_codes(); <br> units[unit_num =i; <br> } <br> ShowHero(heroes+h); <br> } <br> ListBox2->Visible=false; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button5Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button5,1); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button6Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button6,2); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button7Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button7,3); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button8Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button8,4); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button9Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button9,5); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button10Click(TObject *Sender) <br>{ <br> ModifyUnitName(Button10,6); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button13Click(TObject *Sender) <br>{ <br> int i=HeroIndex(); <br> if(i>=0){ <br> memset(heroes.m_magics,1,hero::magic_count); <br> } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox4Click(TObject *Sender) <br>{ <br> Label7->Caption=ListBox4->ItemIndex; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox2KeyDown(TObject *Sender, WORD &Key, <br> TShiftState Shift) <br>{ <br> if(Key==VK_ESCAPE){ <br> ListBox2->Visible=false; <br> } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::FormActivate(TObject *Sender) <br>{ <br> //refresh hero and data <br> ComboBox3Change(this); <br> int r[7]; <br> ShowResources(r); <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox2Exit(TObject *Sender) <br>{ <br> ListBox2->Visible=false; <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::ListBox3Click(TObject *Sender) <br>{ <br> int idx=ListBox3->ItemIndex; <br> if(idx<0) return; <br> int i; <br> AnsiString s=ListBox3->Items->Strings[idx]; <br> char buf [1024]; <br> for(i=0;i<80;i++){ <br> if(s == magic_names[i*6]){ <br> sprintf(buf,"%s /n%s/n %s/n %s/n",magic_names[i*6+1],magic_names <br>[i*6+2], <br> magic_names[i*6+3],magic_names[i*6+4]); <br> Memo1->Text=buf; <br> } <br> } <br>} <br>//-------------------------------------------------------------------------- <br>- <br>void __fastcall TForm1::Button14Click(TObject *Sender) <br>{ <br> int i; <br> FILE * fp=fopen("artifact.txt","w"); <br> char buf[1024]; <br> ListBox1->Clear(); <br> for(i=0;i<256;i++){ <br> DWORD tt=0x678530+(i<<2); <br> PEEK(tt,&tt,sizeof(tt)); <br> PEEK(tt,buf,sizeof(buf)); <br> ListBox1->Items->Add(buf); <br> fprintf(fp,"%s/n",buf); <br> } <br>}