unit1.pas.svn-base

来自「这是一段游戏修改工具的源代码.ring3功能由dephi开发,驱动是C开发.希望」· SVN-BASE 代码 · 共 2,369 行 · 第 1/5 页

SVN-BASE
2,369
字号
      VirtualProtectEx(processhandle,  pointer(memrec[i].Address),1,PAGE_EXECUTE_READWRITE,original);      if memrec[i].VarType=0 then //byte      begin        writeprocessmemory(processhandle,pointer(memrec[i].Address),addr(newvalue1),1,write);        memrec[i].FrozenValue:=newvalue1;      end;      if memrec[i].VarType=1 then //word      begin        writeprocessmemory(processhandle,pointer(memrec[i].Address),addr(newvalue2),2,write);        memrec[i].FrozenValue:=newvalue2;      end;      if memrec[i].VarType=2 then //dword      begin        writeprocessmemory(processhandle,pointer(memrec[i].Address),addr(newvalue3),4,write);        memrec[i].FrozenValue:=newvalue3;      end;      if memrec[i].VarType=3 then //single      begin        writeprocessmemory(processhandle,pointer(memrec[i].Address),addr(newvalue4),4,write);        memrec[i].FrozenFValue:=newvalue4      end;      if memrec[i].VarType=4 then //double      begin        writeprocessmemory(processhandle,pointer(memrec[i].Address),addr(newvalue5),8,write);        memrec[i].FrozenFValue:=newvalue5      end;      if memrec[i].VarType=5 then //binary      begin        if settings.BinariesAsDecimal then          newvaluest:=inttobin(abs(newvalue6));        bl:=1+((length(newvaluest)-1) div 8);        setlength(newbytes,bl);        ReadProcessMemory(processhandle,pointer(memrec[i].Address),@newbytes[0],bl,write);        if settings.BinariesAsDecimal then          newvaluest:=inttobin(abs(newvalue6));        j:=0;        k:=memrec[i].bit;        for l:=length(newvaluest) downto 1 do        begin          case newvaluest[l] of           '0' : setbit(k,newbytes[j],0);           '1' : setbit(k,newbytes[j],1);           '*','?': ;           else raise exception.Create(newvaluest+' is not a valid binary notation!');          end;          inc(k);          if k>=8 then          begin            inc(j);            k:=0;          end;        end;        writeprocessmemory(processhandle,pointer(memrec[i].Address),@newbytes[0],bl,write);        memrec[i].frozenstring:=newvaluest;        setlength(newbytes,0);      end;      if memrec[i].VarType=6 then //Int64      begin        writeprocessmemory(processhandle,pointer(memrec[i].Address),addr(newvalue6),8,write);        memrec[i].FrozenValue:=newvalue6;      end;      //set old security back      VirtualProtectEx(processhandle,  pointer(memrec[i].Address),1,original,write);    end;  end;  updatelist(recordnr,recordnr);end;procedure TForm1.UpdateList(start: word;stop:word);var i,j,k: Integer;    read1: byte;    read2: word;    read3: dword;    read4: single;    read5: double;    read6: Int64;    read7: pchar;    read8: array of byte;    read9: pbyte;    count: dword;    rec: Integer;    v,temp,temp2: string;    nrofbytes: integer;    counter: integer;begin  updatelistcs.Enter;  try    count:=0;    counter:=0;    for rec:=start to stop do    begin      if rec>(numberofrecords-1) then      begin        output[0]:=8;        sendbuf(1);        exit;      end;      if counter>1024 then      begin        sendbuf(counter);        counter:=0;      end;      output[0]:=SC_ValueUpdated;      pword(@output[1])^:=rec; //recnr      if not memrec[rec].frozen then      begin        case memrec[rec].vartype of        0: begin //byte             readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read1),1,count);             if count>0 then             begin               if settings.ShowAsSigned then                 v:=IntToStr(ShortInt(read1))               else                 v:=IntToStr(read1);             end else v:='??'           end;      1: begin //word           readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read2),2,count);           if count=0 then v:='??' else           begin             if settings.ShowAsSigned then               v:=IntToStr(SmallInt(read2))             else               v:=IntToStr(read2);           end;         end;      2: begin //dword           readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read3),4,count);           if count=0 then v:='??' else           begin             if settings.ShowAsSigned then               v:=IntToStr(Longint(read3))             else               v:=IntToStr(read3);           end;         end;      3: begin //float           readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read4),4,count);           if count=0 then             v:='??'           else             v:=FloatToStr(read4);         end;      4: begin  //double           readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read5),8,count);           if count=0 then             v:='??'           else             v:=FloatToStr(read5);         end;      5: begin //binary           //read the bytes           nrofbytes:=1+((memrec[rec].Bit+memrec[rec].bitlength) div 8);           setlength(read8,nrofbytes);           readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read8[0]),nrofbytes,count);           if count=0 then v:='??' else           begin             //convert what i need to a string of bits             temp:='';             j:=memrec[rec].Bit;             read9:=@read8[0];             for k:=1 to memrec[rec].bitlength do             begin               temp:=temp+IntToStr(getbit(j,read9^));               inc(j);               if j>=8 then               begin                 j:=0;                 inc(read9);               end;             end;             temp2:='';             for k:=length(temp) downto 1 do               temp2:=temp2+temp[k];             if settings.BinariesAsDecimal then             begin               try                 v:=IntToStr(bintoint(temp2));               except                 v:='Too long';               end;             end else v:=temp2;             //and convert them to a decimal value           end;         end;      6: begin //Int64           readprocessmemory(processhandle,pointer(memrec[rec].address),addr(read6),8,count);           if count=0 then v:='??' else           begin             v:=IntToStr(read6);           end;         end;      7: begin  //text           getmem(read7,memrec[rec].Bit+1);           readprocessmemory(processhandle,pointer(memrec[rec].Address),read7,memrec[rec].Bit,count);           if count<memrec[rec].Bit then v:='??' else           begin             read7[memrec[rec].Bit]:=chr(0);             v:=read7;           end;           freemem(read7);         end;      8: begin //array of byte           setlength(read8,memrec[rec].Bit);           readprocessmemory(processhandle,pointer(memrec[rec].Address),read8,memrec[rec].Bit,count);           if count<memrec[rec].Bit then v:='??' else           begin             temp:='';             for j:=0 to memrec[rec].Bit-1 do               temp:=temp+IntToHex(read8[j],2)+' ';             v:=temp;           end;           setlength(read8,0);         end;      end;    end    else    begin      if settings.ShowAsSigned then      begin        if memrec[rec].VarType=0 then v:=IntToStr(ShortInt(memrec[rec].frozenvalue)) else        if memrec[rec].VarType=1 then v:=IntToStr(SmallInt(memrec[rec].frozenvalue)) else        if memrec[rec].VarType=2 then v:=IntToStr(LongInt(memrec[rec].frozenvalue));      end else      begin        if memrec[rec].VarType=0 then v:=IntToStr(byte(memrec[rec].frozenvalue)) else        if memrec[rec].VarType=1 then v:=IntToStr(word(memrec[rec].frozenvalue)) else        if memrec[rec].VarType=2 then v:=IntToStr(dword(memrec[rec].frozenvalue));      end;      if memrec[rec].VarType=3 then  //signle      begin        read4:=memrec[rec].FrozenFvalue;        v:=FloatToStr(read4);      end;      if memrec[rec].VarType=4 then  //double      begin        read5:=memrec[rec].FrozenFvalue;        v:=FloatToStr(read5);      end;      if memrec[rec].Vartype=5 then //binary      begin        //turn arround        temp2:=memrec[rec].frozenstring;        temp:='';        for j:=length(temp2) downto 1 do          temp:=temp+temp2[j];        if settings.BinariesAsDecimal then          v:=IntToStr(bintoint(temp))        else          v:=temp;      end;      if memrec[rec].VarType=6 then  //int64      begin        v:=IntToStr((memrec[rec].frozenvalue));      end;      if memrec[rec].VarType=7 then //text      begin        v:=memrec[rec].Frozenstring;      end;      if memrec[rec].VarType=8 then //array of byte      begin        temp:='';        for j:=0 to length(memrec[i].frozenBytes)-1 do          temp:=temp+IntToHex(memrec[i].frozenBytes[j],2)+' ';        v:=temp;      end;    end;    output[3]:=length(v);    copymemory(@output[4],@v[1],output[3]);    sendbuf(4+output[3]);  end;  output[0]:=SC_VALUELISTDONE;  sendbuf(1);  finally    updatelistcs.Leave;  end;end;procedure TForm1.UpdateList;begin  UpdateList(0,numberofrecords-1);end;procedure TForm1.FormCreate(Sender: TObject);var pid: dword;    ownprocesshandle: THandle;    tokenhandle: thandle;    tp:TTokenPrivileges;    prev: TTokenPrivileges;    ReturnLength: Dword;begin  //create the filemapping for hypermode scanning  HyperscanFileMapping:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,sizeof(tscansettings),'CEHYPERSCANSETTINGS');  if HyperscanFileMapping=0 then  begin    FreeLibrary(CEHOOKDLL);    exit;  end;  HyperscanView:=MapViewOfFile(HyperscanFileMapping,FILE_MAP_ALL_ACCESS,0,0,0);  if hyperscanview=nil then  begin    closehandle(HyperscanFileMapping);    FreeLibrary(CEHOOKDLL);  end;  try  zeromemory(hyperscanview,sizeof(tscansettings));  hyperscanview.mainformHandle:=handle;  hyperscanview.applicantionhandle:=application.Handle;  hyperscanview.CheatEngineDir:=CheatEngineDir;  hyperscanview.CEProcessID:=GetCurrentProcessId;  hyperscanview.CEMainThreadID:=getcurrentthreadid;  except  end;    pid:=GetCurrentProcessID;  ownprocesshandle:=OpenProcess(PROCESS_ALL_ACCESS,true,pid);  tokenhandle:=0;  if ownprocesshandle<>0 then  begin    if OpenProcessToken(ownprocesshandle,TOKEN_QUERY or TOKEN_ADJUST_PRIVILEGES	,tokenhandle) then    begin      if lookupPrivilegeValue(nil, 'SeDebugPrivilege' ,tp.Privileges[0].Luid) then      begin        tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;        tp.PrivilegeCount := 1; // One privilege to set        AdjustTokenPrivileges(tokenhandle,false,tp,sizeof(tp),@prev,returnlength);      end;    end;  end;  Set8087CW($133f);  //bye,bye fp exceptions  cefuncproc.buffersize:=512*1024;  progressbar1:=TProgressbar.Create(nil);  progressbar1.Visible:=true;  progressbar1.Parent:=form1;  progressbar1.Left:=500;  progressbar1.SendToBack;  senddata:=true;  logon:=false;  lag:=500;  GetCEdir;  Scan_MEM_PRIVATE:=true;  Scan_MEM_IMAGE:=true;  Scan_MEM_MAPPED:=false;  UpdatelistCS:=TCriticalSection.Create;end;procedure TForm1.ServerSocket1ClientError(Sender: TObject;  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;  var ErrorCode: Integer);begin  senddata:=true;  ErrorCode:=0;  setlength(memrec,0);  numberofrecords:=0;  online:=false;end;procedure TForm1.Button1Click(Sender: TObject);begin  if button1.caption='Start Server' then  begin  try    closeD:=false;    idtcpserver1.DefaultPort:=StrToInt(PortValue.Text);    idtcpserver1.Active:=true;    online:=true;    statusBar1.Panels[0].Text:='Online';    log.Lines.Add('Server started on port:'+PortValue.text);    Button1.caption:='Stop Server';  except    on EConvertError do      showmessage(PortValue.text+' is not an valid value');  end;  end else  begin    idtcpserver1.Active:=false;    closeD:=true;    online:=false;    log.Lines.Add('Server Stopped');    Button1.caption:='Start Server';    statusBar1.Panels[0].Text:='Offline';  end;end;procedure TForm1.ReceiveBuf(var Buf; Count: Integer;socket:TCustomWinSocket);//this function keeps on going till the ammount of bytes requiested is readvar bp: ^byte;    left: integer;    read: integer;    timeout: integer;begin  left:=count;  timeout:=0;  bp:=@buf;  while left>0 do  begin    read:=socket.ReceiveBuf(bp^,left);    if read>0 then    begin      inc(bp,read);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?