Changeset 309

Show
Ignore:
Timestamp:
01/15/10 14:01:12 (8 weeks ago)
Author:
dark_byte
Message:

bugfixes for the heaplist and memory dissect

Location:
Cheat Engine
Files:
22 modified

Legend:

Unmodified
Added
Removed
  • Cheat Engine/CEFuncProc.pas

    r307 r309  
    200200function freetypetostring(freetype: dword):string; 
    201201function isAddress(address: dword):boolean; 
     202function isExecutableAddress(address: dword):boolean; 
    202203 
    203204{$ifndef standalonetrainer} 
     
    31923193end; 
    31933194 
     3195function isExecutableAddress(address: dword):boolean; 
     3196var mbi: TMemoryBasicInformation; 
     3197begin 
     3198  result:=false; 
     3199  if VirtualQueryEx(processhandle, pointer(address), mbi, sizeof(mbi))>0 then 
     3200    result:=(mbi.State=MEM_COMMIT) and (((mbi.Protect and PAGE_EXECUTE)=PAGE_EXECUTE) or ((mbi.Protect and PAGE_EXECUTE_READ)=PAGE_EXECUTE_READ) or ((mbi.Protect and PAGE_EXECUTE_READWRITE)=PAGE_EXECUTE_READWRITE) or ((mbi.Protect and PAGE_EXECUTE_WRITECOPY)=PAGE_EXECUTE_WRITECOPY) ); 
     3201end; 
     3202 
     3203 
     3204 
    31943205 
    31953206 
  • Cheat Engine/DBKKernel/DBKFunc.h

    r225 r309  
    8484typedef struct tagDebugReg7 
    8585{ 
    86         unsigned L0                     :1; //  
    87         unsigned G0                     :1; //  
    88         unsigned L1                     :1; //  
    89         unsigned G1                     :1; //  
    90         unsigned L2                     :1; //  
    91         unsigned G2                     :1; //  
    92         unsigned L3                     :1; //  
    93         unsigned G3                     :1; //  
    94         unsigned GL                     :1; //  
    95         unsigned GE                     :1; //  
    96         unsigned undefined1     :3; // 001  
    97         unsigned GD                     :1; //  
     86        unsigned L0                     :1; //                  0 
     87        unsigned G0                     :1; //                  1 
     88        unsigned L1                     :1; //                  2 
     89        unsigned G1                     :1; //                  3 
     90        unsigned L2                     :1; //                  4 
     91        unsigned G2                     :1; //                  5 
     92        unsigned L3                     :1; //                  6 
     93        unsigned G3                     :1; //                  7 
     94        unsigned GL                     :1; //                  8 
     95        unsigned GE                     :1; //                  9 
     96        unsigned undefined1     :3; // 001              10 
     97        unsigned GD                     :1; //                  11 
    9898        unsigned undefined2     :2; // 00  
    9999        unsigned RW0            :2; 
  • Cheat Engine/DBKKernel/amd64/debuggera.asm

    r294 r309  
    4545interrupt1_asmentry: 
    4646                ;save stack position 
     47                sub esp,4096 
     48 
    4749                cld                      
    4850                push 0 ;push an errorcode on the stack so the stackindex enum type can stay the same relative to interrupts that do have an errorcode (int 14) 
  • Cheat Engine/DBKKernel/debugger.c

    r298 r309  
    159159void debugger_touchDebugRegister(void) 
    160160{ 
     161        DbgPrint("Touching debug register. inepilogue=\n", DebuggerState.FakedDebugRegisterState[cpunr()].inEpilogue); 
     162 
     163         
    161164        debugger_dr0_setValue(debugger_dr0_getValue()); 
     165         
    162166} 
    163167 
     
    223227 
    224228                DbgPrint("Int 1 is hooked,%ssetting GD\n",(state ? "":"un")); 
     229                DbgPrint("oldEpilogueState=%d\n",oldEpilogueState); 
    225230                //debugger_setInitialFakeState(); 
    226231 
     
    228233                DebuggerState.globalDebug=state; 
    229234                debugger_dr7_setGD(state); 
    230                 //DebuggerState.FakedDebugRegisterState[cpunr()].inEpilogue=oldEpilogueState; 
    231  
     235                 
     236                DebuggerState.FakedDebugRegisterState[cpunr()].inEpilogue=oldEpilogueState; 
    232237                 
    233238 
    234239                DebuggerState.FakedDebugRegisterState[cpunr()].DR7=0x400; 
    235240                debugger_dr7_setValueDword(0x400);               
     241 
    236242        } 
    237243 
     
    511517                while (r != STATUS_SUCCESS) 
    512518                { 
    513                         r=KeWaitForSingleObject(&debugger_event_CanBreak,UserRequest, KernelMode, TRUE, NULL); 
     519                        r=KeWaitForSingleObject(&debugger_event_CanBreak,Executive, KernelMode, FALSE, NULL); 
    514520                        //check r and handle specific events 
     521 
     522                        DbgPrint("Woke up. r=%x\n",r); 
    515523                                 
    516524                } 
     
    543551 
    544552                        //LARGE_INTEGER wt; 
    545                         NTSTATUS s; 
     553                        NTSTATUS s=STATUS_UNSUCCESSFUL; 
    546554                         
    547555                        //wt.QuadPart=-10000000LL;  
     
    550558                        DbgPrint("Waiting...\n"); 
    551559 
    552                         s=KeWaitForSingleObject(&debugger_event_WaitForContinue, UserRequest, KernelMode, TRUE, NULL); 
    553  
    554                         DbgPrint("KeWaitForSingleObject=%x\n",s);                
     560 
     561                        while (s != STATUS_SUCCESS) 
     562                        { 
     563                                s=KeWaitForSingleObject(&debugger_event_WaitForContinue, Executive, KernelMode, FALSE, NULL); 
     564                                DbgPrint("KeWaitForSingleObject=%x\n",s);                
     565                        } 
     566 
     567                         
    555568 
    556569                        if (s==STATUS_SUCCESS) 
     
    569582                } 
    570583 
     584 
     585 
    571586                //i'm done, let other threads catch it 
    572587                KeSetEvent(&debugger_event_CanBreak, 0, FALSE); 
     
    596611        DebugReg7 _dr7=*(DebugReg7 *)&currentdebugregs[5]; 
    597612 
     613        DbgPrint("interrupt1_handler\n"); 
    598614         
    599615        //check if this break should be handled or not 
     
    830846        if (DebuggerState.isDebugging) 
    831847        { 
     848                DbgPrint("DebuggerState.isDebugging\n"); 
    832849                //check if this should break 
    833850                if (CurrentProcessID==(HANDLE)(UINT_PTR)DebuggerState.debuggedProcessID) 
     
    835852                        UINT_PTR originaldebugregs[6]; 
    836853                        UINT64 oldDR7=getDR7(); 
     854 
     855                        DbgPrint("CurrentProcessID==(HANDLE)(UINT_PTR)DebuggerState.debuggedProcessID\n"); 
    837856 
    838857                        if (DebuggerState.globalDebug) 
     
    855874                                ((PEFLAGS)&stackpointer[si_eflags])->RF=1; 
    856875                                ((PEFLAGS)&stackpointer[si_eflags])->TF=1; //keep going until IF=1 
     876                                DbgPrint("IF==0\n"); 
    857877                                return 1; //don't handle it but also don't tell windows 
    858878                        } 
     
    879899                        } 
    880900 
     901 
     902                        //save the current stack 
     903                        /* 
     904                        { 
     905                                int *p; 
     906                                p=ExAllocatePool(NonPagedPool,4096*2); 
     907 
     908                                        RtlZeroMemory(p,4096*2); 
     909                                        DbgPrint("p=%p\n",p); 
     910 
     911                                        RtlCopyMemory((PVOID)((UINT_PTR)p+4096), (PVOID)getRSP(), (UINT_PTR)(&stackpointer[si_ss])-(UINT_PTR)getRSP());  
     912 
     913                                        __asm 
     914                                        { 
     915                                                mov eax,p                                                        
     916                                                add eax,4096 
     917                                                 
     918                                                sub ebp,esp 
     919                                                add ebp,eax 
     920 
     921                                                 
     922                                                mov esp,eax 
     923                                 
     924                                        } 
     925 
     926                                        return 1; 
     927         
     928 
     929                        } 
     930                        */ 
     931 
     932 
     933 
    881934                        //start the windows taskswitching mode 
     935 
    882936                        enableInterrupts(); 
    883937                        { 
    884938                                int rs=1; 
    885                                 //DbgPrint("calling breakpointHandler_kernel\n"); 
     939                                DbgPrint("calling breakpointHandler_kernel\n"); 
    886940                                 
    887941                                rs=breakpointHandler_kernel(stackpointer, currentdebugregs);     
    888                                 //DbgPrint("After handler dr6=%x and before handling it was %x\n",debugger_dr6_getValue(), DebuggerState.FakedDebugRegisterState[cpunr()].DR6);  
     942                                DbgPrint("After handler\n"); 
    889943 
    890944                                //DbgPrint("rs=%d\n",rs); 
     
    906960                                else 
    907961                                { 
     962                                         
    908963                                        if (getDR7() != oldDR7) 
    909964                                        { 
     
    919974                                        debugger_dr3_setValue(currentdebugregs[3]); 
    920975                                        debugger_dr6_setValue(currentdebugregs[4]); 
    921                                         debugger_dr7_setValue(*(DebugReg7 *)&currentdebugregs[5]);                                       
     976 
     977                                        if ((currentdebugregs[5] >> 11) & 1) 
     978                                        { 
     979                                                DbgPrint("WTF? GD is 1 in currentdebugregs[5]\n"); 
     980                                        } 
     981                                        else 
     982                                                debugger_dr7_setValue(*(DebugReg7 *)&currentdebugregs[5]);       
     983                                                 
    922984                                } 
    923985                                 
     
    9651027        int i; 
    9661028 
    967         DbgPrint("interrupt1_centry:%d\n",cpunr()); 
     1029        DbgPrint("interrupt1_centry cpunr=%d esp=%x\n",cpunr(), getRSP()); 
    9681030 
    9691031        before=getRSP(); 
     1032 
     1033        for (i=-12; i<7; i++) 
     1034        {        
     1035                DbgPrint("stackpointer %d=%x\n",i, stackpointer[i]); 
     1036        } 
    9701037 
    9711038         
     
    9761043        //DbgPrint("current csr=%x\n", _mm_getcsr()); 
    9771044 
    978         //DbgPrint("stackpointer RAX=%llx\n",stackpointer[si_eax]); 
    979         //DbgPrint("stackpointer RBX=%llx\n",stackpointer[si_ebx]); 
    980         //DbgPrint("stackpointer RCX=%llx\n",stackpointer[si_ecx]); 
    981         //DbgPrint("stackpointer RDX=%llx\n",stackpointer[si_edx]); 
    982         //DbgPrint("stackpointer cs:rip=%llx:%llx\n",stackpointer[si_cs], stackpointer[si_eip]); 
    983         //DbgPrint("stackpointer ss:rsp=%llx:%llx\n",stackpointer[si_ss], stackpointer[si_esp]); 
     1045 
    9841046 
    9851047#endif 
     
    12121274                //not global debug, just clear all flags and be done with it 
    12131275                debugger_dr6_setValue(0xffff0ff0); 
    1214                  
    1215         } 
    1216  
     1276                __nop(); 
     1277                 
     1278        } 
     1279 
     1280        __nop(); 
     1281        __nop(); 
     1282        disableInterrupts(); 
     1283        disableInterrupts(); 
     1284         
     1285        __asm 
     1286        { 
     1287                cli 
     1288        } 
    12171289 
    12181290        if (handled == 2) 
    12191291        { 
     1292                __nop(); 
     1293                //DbgPrint("handled==2\n");              
    12201294                handled = 1; //epilogue = 1 Dr handler 
     1295                __nop(); 
    12211296        } 
    12221297        else 
    12231298        {                
     1299                __nop(); 
    12241300                //not handled by the epilogue set DR0, so the actual epilogue 
    1225                 DebuggerState.FakedDebugRegisterState[cpunr()].inEpilogue=0; 
    1226                 debugger_dr7_setGD(DebuggerState.globalDebug);           
    1227         } 
    1228  
    1229         after=getRSP(); 
    1230  
    1231         DbgPrint("before=%llx after=%llx\n",before,after); 
     1301                //DbgPrint("handled==1\n"); 
     1302                 
     1303                if (DebuggerState.globalDebug) 
     1304                { 
     1305                        DebuggerState.FakedDebugRegisterState[cpunr()].inEpilogue=0; 
     1306                        debugger_dr7_setGD(DebuggerState.globalDebug); //set it back to 1                
     1307                        __nop(); 
     1308                        __nop(); 
     1309                } 
     1310                __nop(); 
     1311                __nop(); 
     1312        } 
     1313 
     1314        __nop(); 
     1315        __nop(); 
     1316 
     1317        //after=getRSP(); 
     1318 
     1319        //DbgPrint("before=%llx after=%llx\n",before,after); 
    12321320 
    12331321        return handled; 
     
    12391327{ 
    12401328        __asm{ 
     1329                //change the start of the stack so that instructions like setthreadcontext do not affect the stack it when it's frozen and waiting for input 
     1330                //meaning the setting of debug registers will have to be done with the changestate call 
     1331 
     1332                //sub esp,4096 
     1333                //push [esp+4096+0+16] //optional ss 
     1334                //push [esp+4096+4+12] //optional esp 
     1335                //push [esp+4096+8+8] //eflags 
     1336                //push [esp+4096+12+4] //cs 
     1337                //push [esp+4096+16+0] //eip 
     1338                 
     1339                 
     1340                 
     1341                 
     1342 
     1343 
     1344 
    12411345                //save stack position 
    12421346                push 0 //push an errorcode on the stack so the stackindex can stay the same 
     
    12461350                //save state 
    12471351                pushad 
    1248                 push ds 
    1249                 push es 
    1250                 push fs 
    1251                 push gs 
    1252  
     1352                xor eax,eax 
     1353                mov ax,ds 
     1354                push eax 
     1355 
     1356                mov ax,es 
     1357                push eax 
     1358 
     1359                mov ax,fs 
     1360                push eax 
     1361 
     1362                mov ax,gs 
     1363                push eax 
     1364                 
    12531365                mov ax,0x23 //0x10 should work too, but even windows itself is using 0x23 
    12541366                mov ds,ax 
  • Cheat Engine/DBKKernel/vmxoffload.c

    r297 r309  
    203203                        NTSTATUS OpenedFile; 
    204204 
    205                         vmmPA=MmGetPhysicalAddress(vmm).QuadPart; 
     205                        vmmPA=(UINT_PTR)MmGetPhysicalAddress(vmm).QuadPart; 
    206206                        DbgPrint("Allocated memory at virtual address %p (physical address %llx)\n",vmm,MmGetPhysicalAddress(vmm)); 
    207207                        RtlZeroMemory(vmm,4*1024*1024); //initialize 
     
    743743                        xchg bx,bx 
    744744                         
     745                        mov ebx,vmmPA 
     746                        __emit 0x8b 
     747                        __emit 0xeb //mov ebp,ebx 
     748                         
     749 
    745750                        lea ebx,NewGDTDescriptor 
    746751                        mov ecx,pagedirptrbasePA 
     
    748753                        mov esi,enterVMM2PA 
    749754                        mov edi,originalstatePA 
    750                         mov ebp,vmmPA 
     755                         
    751756                        call [enterVMM2] 
    752757                         
  • Cheat Engine/KernelDebugger.pas

    r305 r309  
    3939 
    4040    function getDebugReason: integer; 
     41 
    4142 
    4243  public 
     
    379380    Debuggerthread.threadlistCS.Enter; 
    380381    try 
    381       if not setthreadcontext(threadhandle, generaldebugregistercontext) then 
    382         OutputDebugString(format('Failed setting debug registers on thread %x with error %d',[threadhandle, GetLastError])); 
     382      if debuggerthread.stepping then 
     383      begin 
     384        OutputDebugString('debuggerthread.stepping is TRUE'); 
     385        debuggerthread.currentdebuggerstate.dr0:=generaldebugregistercontext.Dr0; 
     386        debuggerthread.currentdebuggerstate.dr1:=generaldebugregistercontext.Dr1; 
     387        debuggerthread.currentdebuggerstate.dr2:=generaldebugregistercontext.Dr2; 
     388        debuggerthread.currentdebuggerstate.dr3:=generaldebugregistercontext.Dr3; 
     389        debuggerthread.currentdebuggerstate.dr6:=generaldebugregistercontext.Dr6; 
     390        debuggerthread.currentdebuggerstate.dr7:=generaldebugregistercontext.Dr7; 
     391      end 
     392      else 
     393      begin 
     394        OutputDebugString('debuggerthread.stepping is FALSE');       
     395        if not setthreadcontext(threadhandle, generaldebugregistercontext) then 
     396          OutputDebugString(format('Failed setting debug registers on thread %x with error %d',[threadhandle, GetLastError])); 
     397      end; 
    383398    finally 
    384399      Debuggerthread.threadlistCS.Leave; 
     
    559574    stacktrace1.Enabled:=true; 
    560575    Executetillreturn1.Enabled:=true; 
    561     caption:='Memory Viewer - Currently debugging thread'; 
     576    if stepping then 
     577      caption:='Memory Viewer - Currently debugging thread' 
     578    else 
     579      caption:='Memory Viewer - Running...'; 
    562580 
    563581    if frmstacktrace<>nil then 
     
    810828  end; 
    811829end; 
    812  
    813830 
    814831function TKDebuggerThread.getDebugReason: integer; 
     
    927944    co_stepover: 
    928945    begin 
    929       OutputDebugString('step over'); 
     946      OutputDebugString('step over. Stepping='+booltostr(stepping,true)); 
    930947      currentdebuggerstate.eflags:=eflags_setRF(currentdebuggerstate.eflags,1); //skip current instruction bp 
    931948      currentdebuggerstate.eflags:=eflags_setTF(currentdebuggerstate.eflags,0); 
     
    944961      currentdebuggerstate.eflags:=eflags_setRF(currentdebuggerstate.eflags,1); //skip current instruction bp 
    945962      currentdebuggerstate.eflags:=eflags_setTF(currentdebuggerstate.eflags,0); 
     963      OutputDebugString('Setting breakpoint to '+inttohex(runtilladdress,8)); 
    946964      KDebugger.SetBreakpoint(runtilladdress, bt_OnInstruction, 1, bo_Break, nil, currentdebuggerstate.threadid, true); 
    947965      stepping:=false; 
     
    10961114                //delete if it belongs to this thread and it's a one time only break 
    10971115                if owner.breakpoint[breakreason].BreakOnce then 
     1116                begin 
     1117                  stepping:=true; 
    10981118                  KDebugger.DisableBreakpoint(breakreason); 
     1119                end; 
    10991120              end 
    11001121              else 
  • Cheat Engine/MainUnit.dfm

    r307 r309  
    14601460      Height = 13 
    14611461      Caption = 'Launch DBVM' 
     1462      Visible = False 
    14621463      OnClick = Label59Click 
    14631464    end 
  • Cheat Engine/MainUnit.pas

    r307 r309  
    1073210732procedure TMainForm.Label59Click(Sender: TObject); 
    1073310733var 
    10734   f: TfrmFloatingPointPanel; 
    10735 begin 
    10736   ZeroMemory(@c,sizeof(c)); 
    10737   c.ContextFlags:=CONTEXT_FLOATING_POINT or CONTEXT_EXTENDED_REGISTERS; 
    10738   if GetThreadContext(getcurrentthread, c) then 
    10739   begin 
    10740     f:=TfrmFloatingPointPanel.create(self); 
    10741     f.SetContextPointer(@c); 
    10742     memorybrowser.memoryaddress:=dword(@c); 
    10743     f.show; 
    10744  
    10745     showmessage(inttohex(dword(@c)+sizeof(c),8)) 
    10746     
    10747   end else showmessage('fuck'); 
     10734  i,j: integer; 
     10735  temp: thandle; 
     10736  found: boolean; 
     10737  c: Tcontext; 
     10738begin 
     10739    found:=false; 
     10740    for i:=0 to length(frmprocesswatcher.processes)-1 do 
     10741    begin 
     10742      if frmprocesswatcher.processes[i].processid=processid then 
     10743      begin 
     10744        //open the threads 
     10745        for j:=0 to length(frmprocesswatcher.processes[i].threadlist)-1 do 
     10746        begin 
     10747 
     10748          temp:=Openthread(STANDARD_RIGHTS_REQUIRED or $3ff,true,frmprocesswatcher.processes[i].threadlist[j].threadid); 
     10749          if temp<>0 then 
     10750          begin 
     10751            c.ContextFlags:=CONTEXT_DEBUG_REGISTERS; 
     10752            GetThreadContext(temp,c); 
     10753 
     10754            c.ContextFlags:=CONTEXT_DEBUG_REGISTERS; 
     10755            c.Dr0:=$12345678; 
     10756            SetThreadContext(temp,c); 
     10757 
     10758//            setlength(threadlist,length(threadlist)+1); 
     10759//            threadlist[length(threadlist)-1]:=temp; 
     10760          end; 
     10761        end; 
     10762 
     10763        found:=true; 
     10764        showmessage('found'); 
     10765        break; 
     10766 
     10767      end; 
     10768    end; 
     10769 
     10770    if not found then showmessage('error'); 
    1074810771end; 
    1074910772 
  • Cheat Engine/MemoryBrowserFormUnit.dfm

    r306 r309  
    7777        OnResize = ScrollBox1Resize 
    7878        object EAXLabel: TLabel 
    79           Left = 10 
     79          Left = 8 
    8080          Top = 19 
    8181          Width = 96 
     
    9393        object EBXlabel: TLabel 
    9494          Tag = 1 
    95           Left = 10 
    96           Top = 32 
     95          Left = 8 
     96          Top = 35 
    9797          Width = 96 
    9898          Height = 13 
     
    109109        object ECXlabel: TLabel 
    110110          Tag = 2 
    111           Left = 10 
    112           Top = 45 
     111          Left = 8 
     112          Top = 51 
    113113          Width = 96 
    114114          Height = 13 
     
    125125        object EDXlabel: TLabel 
    126126          Tag = 3 
    127           Left = 10 
    128           Top = 58 
     127          Left = 8 
     128          Top = 67 
    129129          Width = 96 
    130130          Height = 13 
     
    141141        object ESIlabel: TLabel 
    142142          Tag = 4 
    143           Left = 10 
    144           Top = 70 
     143          Left = 8 
     144          Top = 83 
    145145          Width = 96 
    146146          Height = 13 
     
    157157        object EDIlabel: TLabel 
    158158          Tag = 5 
    159           Left = 10 
    160           Top = 83 
     159          Left = 8 
     160          Top = 99 
    161161          Width = 96 
    162162          Height = 13 
     
    173173        object EBPlabel: TLabel 
    174174          Tag = 6 
    175           Left = 10 
    176           Top = 96 
     175          Left = 8 
     176          Top = 115 
    177177          Width = 96 
    178           Height = 13 
     178          Height = 14 
    179179          Cursor = crHandPoint 
    180180          Caption = 'EBP 00000000' 
     
    189189        object ESPlabel: TLabel 
    190190          Tag = 7 
    191           Left = 10 
    192           Top = 109 
     191          Left = 8 
     192          Top = 131 
    193193          Width = 96 
    194           Height = 13 
     194          Height = 14 
    195195          Cursor = crHandPoint 
    196196          Caption = 'ESP 00000000' 
     
    205205        object EIPlabel: TLabel 
    206206          Tag = 8 
    207           Left = 10 
    208           Top = 121 
     207          Left = 8 
     208          Top = 147 
    209209          Width = 96 
    210           Height = 13 
     210          Height = 15 
    211211          Cursor = crHandPoint 
    212212          Caption = 'EIP 00000000' 
     
    221221        object CSLabel: TLabel 
    222222          Tag = 9 
    223           Left = 10 
    224           Top = 153 
     223          Left = 8 
     224          Top = 184 
    225225          Width = 56 
    226226          Height = 13 
     
    237237        object DSLabel: TLabel 
    238238          Tag = 11 
    239           Left = 10 
    240           Top = 176 
     239          Left = 8 
     240          Top = 216 
    241241          Width = 56 
    242242          Height = 13 
     
    253253        object SSlabel: TLabel 
    254254          Tag = 10 
    255           Left = 10 
    256           Top = 164 
     255          Left = 8 
     256          Top = 200 
    257257          Width = 56 
    258258          Height = 13 
     
    269269        object ESlabel: TLabel 
    270270          Tag = 12 
    271           Left = 10 
    272           Top = 188 
     271          Left = 8 
     272          Top = 232 
    273273          Width = 56 
    274274          Height = 13 
     
    285285        object FSlabel: TLabel 
    286286          Tag = 13 
    287           Left = 10 
    288           Top = 199 
     287          Left = 8 
     288          Top = 248 
    289289          Width = 56 
    290290          Height = 13 
     
    301301        object GSlabel: TLabel 
    302302          Tag = 14 
    303           Left = 10 
    304           Top = 211 
     303          Left = 8 
     304          Top = 264 
    305305          Width = 56 
    306306          Height = 13 
     
    317317        object cflabel: TLabel 
    318318          Tag = 20 
    319           Left = 143 
    320           Top = 20 
     319          Left = 136 
     320          Top = 24 
    321321          Width = 32 
    322322          Height = 13 
     
    332332        object pflabel: TLabel 
    333333          Tag = 21 
    334           Left = 143 
    335           Top = 31 
     334          Left = 136 
     335          Top = 40 
    336336          Width = 32 
    337337          Height = 13 
     
    347347        object aflabel: TLabel 
    348348          Tag = 22 
    349           Left = 143 
    350           Top = 43 
     349          Left = 136 
     350          Top = 56 
    351351          Width = 32 
    352352          Height = 13 
     
    362362        object zflabel: TLabel 
    363363          Tag = 23 
    364           Left = 143 
    365           Top = 55 
     364          Left = 136 
     365          Top = 72 
    366366          Width = 32 
    367367          Height = 13 
     
    377377        object sflabel: TLabel 
    378378          Tag = 24 
    379           Left = 143 
    380           Top = 66 
     379          Left = 136 
     380          Top = 88 
    381381          Width = 32 
    382382          Height = 13 
     
    392392        object oflabel: TLabel 
    393393          Tag = 26 
    394           Left = 143 
    395           Top = 90 
     394          Left = 136 
     395          Top = 120 
    396396          Width = 32 
    397397          Height = 13 
     
    420420        end 
    421421        object Label15: TLabel 
    422           Left = 143 
     422          Left = 139 
    423423          Top = 0 
    424424          Width = 34 
     
    427427        end 
    428428        object Shape2: TShape 
    429           Left = 142 
     429          Left = 138 
    430430          Top = 16 
    431431          Width = 35 
     
    435435        object Label16: TLabel 
    436436          Left = 7 
    437           Top = 134 
     437          Top = 162 
    438438          Width = 115 
    439439          Height = 16 
     
    442442        object Shape3: TShape 
    443443          Left = 7 
    444           Top = 150 
     444          Top = 178 
    445445          Width = 111 
    446446          Height = 3 
     
    449449        object dflabel: TLabel 
    450450          Tag = 25 
    451           Left = 143 
    452           Top = 78 
     451          Left = 136 
     452          Top = 104 
    453453          Width = 32 
    454454          Height = 13 
     
    463463        end 
    464464        object sbShowFloats: TSpeedButton 
    465           Left = 157 
    466           Top = 135 
     465          Left = 153 
     466          Top = 159 
    467467          Width = 21 
    468468          Height = 31 
     
    635635        ViewStyle = vsReport 
    636636        OnData = lvStacktraceDataData 
     637        OnDblClick = lvStacktraceDataDblClick 
    637638      end 
    638639    end 
  • Cheat Engine/MemoryBrowserFormUnit.pas

    r308 r309  
    313313    procedure Executetillreturn1Click(Sender: TObject); 
    314314    procedure lvStacktraceDataData(Sender: TObject; Item: TListItem); 
     315    procedure lvStacktraceDataDblClick(Sender: TObject); 
    315316  private 
    316317    { Private declarations } 
     
    18411842    debuggerthread.continuehow:=wdco_run;   //note: I could also have the debuggerthread suspend itself, and resume it here 
    18421843    debuggerthread.continueprocess:=true; 
    1843     caption:='Memory Viewer - Running'; 
    1844   end; 
     1844  end; 
     1845  caption:='Memory Viewer - Running';   
    18451846  {$endif} 
    18461847end; 
     
    18581859    debuggerthread.continuehow:=wdco_stepinto; //single step 
    18591860    debuggerthread.continueprocess:=true; 
    1860     caption:='Memory Viewer - Running'; 
    1861   end; 
    1862  
     1861  end; 
     1862 
     1863  caption:='Memory Viewer - Running'; 
    18631864  {$endif} 
    18641865end; 
     
    18701871    int3: byte; 
    18711872    original,a,written:dword; 
    1872  
    1873 begin 
    1874   {$ifndef net} 
     1873begin 
    18751874  int3:=$cc; 
    18761875  //place a invisble for the user breakpoint on the following upcode 
     
    19371936 
    19381937    debuggerthread.continueprocess:=true; 
    1939     caption:='Memory Viewer - Running'; 
    1940   end; 
    1941   {$endif} 
     1938 
     1939  end; 
     1940  caption:='Memory Viewer - Running'; 
    19421941end; 
    19431942 
     
    19551954  if kdebugger.isactive then 
    19561955  begin 
    1957     kdebugger.continue(co_runtill); 
     1956    kdebugger.continue(co_runtill, disassemblerview.SelectedAddress); 
    19581957  end 
    19591958  else 
     
    19991998 
    20001999    debuggerthread.continueprocess:=true; 
    2001     caption:='Memory Viewer - Running'; 
    2002   end; 
     2000 
     2001  end; 
     2002  caption:='Memory Viewer - Running'; 
    20032003 
    20042004  {$endif} 
     
    39983998          c:=lvstacktracedata.Columns.Add; 
    39993999          c.Caption:='Return Address'; 
    4000           c.Width:=120; 
     4000          c.Width:=lvstacktracedata.Canvas.TextWidth('DDDDDDDD'); 
     4001          c.AutoSize:=true; 
     4002 
    40014003 
    40024004          c:=lvstacktracedata.Columns.Add; 
     
    41584160 
    41594161function TMemoryBrowser.GetReturnaddress: dword; 
    4160 var haserror: boolean; 
     4162var 
     4163  haserror: boolean; 
     4164  stack: array [0..1023] of dword; 
     4165  x: dword; 
     4166  i: integer; 
    41614167begin 
    41624168  result:=0; 
     
    41724178  end; 
    41734179 
     4180  if result=0 then 
     4181  begin 
     4182 
     4183    //go through the stack and find a entry that falls in executable memory 
     4184    ReadProcessMemory(processhandle, pointer(lastdebugcontext.Esp), @stack[0], 4096, x); 
     4185    for i:=0 to (x div 4) do 
     4186    begin 
     4187      if symhandler.inModule(stack[i]) and isExecutableAddress(stack[i]) then 
     4188      begin 
     4189        result:=stack[i]; //best guess, it's an address specifier, it falls inside a module, and it's executable 
     4190        exit; 
     4191      end; 
     4192    end; 
     4193  end; 
    41744194end; 
    41754195 
     
    42444264end; 
    42454265 
     4266procedure TMemoryBrowser.lvStacktraceDataDblClick(Sender: TObject); 
     4267var 
     4268  hasError: boolean; 
     4269  x: dword; 
     4270 
     4271  column : integer; 
     4272  cursorpos: tpoint; 
     4273  tvrect: trect; 
     4274  i: integer; 
     4275 
     4276  currentleft: integer; 
     4277  s: string; 
     4278begin 
     4279  if stacktrace2.checked then 
     4280  begin 
     4281    //go to the selected address 
     4282    x:=symhandler.getAddressFromName(lvStacktraceData.Selected.Caption,false,haserror); 
     4283    if not haserror then 
     4284      disassemblerview.SelectedAddress:=x; 
     4285  end 
     4286  else 
     4287  begin 
     4288    //depending on what column is selected go to the disassembler/hexview part 
     4289    cursorpos:=mouse.CursorPos; 
     4290    GetWindowRect(lvStacktraceData.Handle, tvrect); 
     4291 
     4292    //get the relative position 
     4293    cursorpos.X:=cursorpos.X-tvrect.Left; 
     4294    cursorpos.Y:=cursorpos.Y-tvrect.Top; 
     4295 
     4296    column:=0; 
     4297 
     4298    currentleft:=0; 
     4299    for i:=0 to lvStacktraceData.Columns.count-1 do 
     4300    begin 
     4301      if (cursorpos.X>currentleft) and (cursorpos.X<(currentleft+lvStacktraceData.Columns[i].width)) then 
     4302      begin 
     4303        column:=i; 
     4304        break; 
     4305      end; 
     4306      inc(currentleft, lvStacktraceData.Columns[i].width); 
     4307    end; 
     4308 
     4309    if column=0 then 
     4310      s:=lvStacktraceData.Selected.Caption 
     4311    else 
     4312      s:=lvStacktraceData.Selected.SubItems[column-1]; 
     4313 
     4314    x:=symhandler.getAddressFromName(lvStacktraceData.Selected.Caption,false,haserror); 
     4315    if not haserror then 
     4316    begin 
     4317      if isExecutableAddress(x) then 
     4318        disassemblerview.SelectedAddress:=x 
     4319      else 
     4320      begin 
     4321        memoryaddress:=x; 
     4322        RefreshMB; 
     4323      end; 
     4324    end; 
     4325 
     4326  end; 
     4327end; 
     4328 
    42464329end. 
  • Cheat Engine/Release/Cheat Engine.iss

    r308 r309  
    33 
    44[Setup] 
    5 AppName=Cheat Engine 5.6 BETA 4 
    6 AppVerName=Cheat Engine 5.6 BETA 4 
     5AppName=Cheat Engine 5.6 BETA 5 
     6AppVerName=Cheat Engine 5.6 BETA 5 
    77AppPublisher=Dark Byte 
    88AppPublisherURL=http://www.cheatengine.org/ 
    99AppSupportURL=http://www.cheatengine.org/ 
    1010AppUpdatesURL=http://www.cheatengine.org/ 
    11 DefaultDirName={pf}\Cheat Engine Beta4 
    12 DefaultGroupName=Cheat Engine 5.6 BETA 4 
     11DefaultDirName={pf}\Cheat Engine Beta5 
     12DefaultGroupName=Cheat Engine 5.6 BETA 5 
    1313AllowNoIcons=yes 
    1414LicenseFile=..\Release\License.txt 
    1515InfoAfterFile=..\Release\readme.txt 
    16 OutputBaseFilename=CheatEngine56Beta4 
     16OutputBaseFilename=CheatEngine56Beta5 
    1717PrivilegesRequired=admin 
    1818ChangesAssociations=yes 
     
    248248 
    249249[Run] 
    250 Filename: "{app}\Cheat Engine.exe"; Description: "Launch Cheat Engine 5.6"; Flags: nowait postinstall skipifsilent runascurrentuser 
     250Filename: "{app}\Cheat Engine.exe"; Description: "Launch Cheat Engine 5.6 Beta 5"; Flags: nowait postinstall skipifsilent runascurrentuser 
  • Cheat Engine/Structuresfrm.pas

    r308 r309  
    11811181      Memorybrowsethisaddress1.Visible:=false; 
    11821182 
    1183       if (s.basestructure<0) then 
     1183      if (s<>nil) and (s.basestructure<0) then 
    11841184      begin 
    11851185        Addelement1.Visible:=false; 
  • Cheat Engine/SynEdit/Source/SynHighlighterAA.pas

    r121 r309  
    139139    function Func59: TtkTokenKind; //readmem     
    140140    function Func68: TtkTokenKind; //include 
     141    function Func82: TtkTokenKind; //assert 
    141142    function Func92: TtkTokenKind; //globalalloc 
    142143    function Func101: TtkTokenKind; //fullaccess/loadbinary 
     
    226227  end; 
    227228 
     229procedure aa_AddExtraCommand(command:pchar); 
     230procedure aa_RemoveExtraCommand(command:pchar); 
     231function isExtraCommand(token:string): boolean; 
     232 
     233 
    228234implementation 
    229235 
     
    238244  Identifiers: array[#0..#255] of ByteBool; 
    239245  mHashTable: array[#0..#255] of Integer; 
     246 
     247  extraCommands: Tstringlist; 
     248 
     249procedure aa_AddExtraCommand(command:pchar); 
     250begin 
     251  if extraCommands=nil then 
     252  begin 
     253    extraCommands:=tstringlist.create; 
     254    extraCommands.Duplicates:=dupIgnore; 
     255    extracommands.CaseSensitive:=false; 
     256  end; 
     257 
     258  extraCommands.Add(command); 
     259end; 
     260 
     261procedure aa_RemoveExtraCommand(command:pchar); 
     262begin 
     263  if extracommands<>nil then 
     264  begin 
     265    extracommands.Delete(extracommands.IndexOf(command)); 
     266    if extracommands.Count=0 then 
     267      freeandnil(extracommands); 
     268  end; 
     269end; 
     270 
     271function isExtraCommand(token: string): boolean; 
     272begin 
     273  result:=false; 
     274  if extracommands<>nil then 
     275    result:=extracommands.IndexOf(token)<>-1; 
     276end; 
     277 
    240278 
    241279procedure MakeIdentTable; 
     
    293331  fIdentFuncTable[59] := Func59; 
    294332  fIdentFuncTable[68] := Func68; 
     333  fIdentFuncTable[82] := Func82;   
    295334  fIdentFuncTable[92] := Func92; 
    296335  fIdentFuncTable[101] := Func101; 
     
    500539end; 
    501540 
     541function TSynAASyn.Func82: TtkTokenKind; //include 
     542begin 
     543  if KeyComp('assert') then Result := tkKey else 
     544    Result := tkIdentifier; 
     545end; 
     546 
    502547function TSynAASyn.Func92: TtkTokenKind; //globalalloc 
    503548begin 
     
    548593  for i:=1 to length(s) do 
    549594  begin 
    550     if (s[i]=' ') or (s[i]=#9) or (s[i]=',') or (s[i]=#10) or (s[i]=#13) then 
     595    if (s[i]='(') or (s[i]=' ') or (s[i]=#9) or (s[i]=',') or (s[i]=#10) or (s[i]=#13) then 
    551596    begin 
    552597      result:=copy(s,1,i-1); 
     
    566611 
    567612     
    568   if (result=tkIdentifier) and (GetOpcodesIndex(getfirsttoken(maybe))<>-1) then 
    569     result:=tkKey; 
     613  if (result=tkIdentifier) then 
     614  begin 
     615    if GetOpcodesIndex(getfirsttoken(maybe))<>-1 then 
     616      result:=tkKey 
     617    else 
     618    if isExtraCommand(getfirsttoken(maybe)) then 
     619      result:=tkKey; 
     620  end; 
     621 
     622 
    570623end; 
    571624 
  • Cheat Engine/cheatengine.dof

    r307 r309  
    189189MinorVer=6 
    190190Release=0 
    191 Build=48 
     191Build=53 
    192192Debug=0 
    193193PreRelease=1 
     
    200200CompanyName= 
    201201FileDescription=Cheat Engine 5.6 
    202 FileVersion=5.6.0.48 
     202FileVersion=5.6.0.53 
    203203InternalName=CheatEngine 
    204204LegalCopyright=none 
  • Cheat Engine/dbk32/debug.pas

    r294 r309  
    115115//just make sure to disable the breakpoint before removing the handler 
    116116begin 
     117  OutputDebugString('DBKDebug_TouchDebugRegister'); 
    117118  foreachcpu(internal_touchdebugregister,nil); 
    118119end; 
  • Cheat Engine/frmHeapsUnit.pas

    r281 r309  
    126126procedure TfrmHeaps.FormCreate(Sender: TObject); 
    127127begin 
    128   frmMemoryAllocHandler:=TfrmMemoryAllocHandler.Create(self); //just not show 
     128  if frmMemoryAllocHandler=nil then 
     129    frmMemoryAllocHandler:=TfrmMemoryAllocHandler.Create(self); //just not show 
     130 
    129131  frmMemoryAllocHandler.WaitForInitializationToFinish; 
    130132 
  • Cheat Engine/frmMemoryAllocHandlerUnit.pas

    r285 r309  
    566566var injectionscript: TStringlist; 
    567567var x,y,z: THandle; 
     568mi: tmoduleinfo; 
    568569begin 
    569570  memrecCS:=TCriticalSection.Create; 
     
    572573  try 
    573574    //inject allochook.dll 
    574     injectdll(CheatEngineDir+'allochook.dll'); 
    575     symhandler.reinitialize; 
     575    if not symhandler.getmodulebyname('allochook.dll',mi) then 
     576    begin 
     577      injectdll(CheatEngineDir+'allochook.dll'); 
     578      symhandler.reinitialize; 
     579    end; 
     580       
     581 
    576582 
    577583 
  • Cheat Engine/plugin.pas

    r305 r309  
    117117  disassembleEx     : pointer; 
    118118  loadModule        : pointer; 
     119  aa_AddExtraCommand: pointer; 
     120  aa_RemoveExtraCommand: pointer; 
    119121end; 
    120122type PExportedFunctions3 = ^TExportedFunctions3; 
     
    495497implementation 
    496498 
    497 uses mainunit,memorybrowserformunit,formsettingsunit, pluginexports; 
     499uses mainunit,memorybrowserformunit,formsettingsunit, pluginexports, SynHighlighterAA; 
    498500 
    499501function TPluginHandler.GetDLLFilePath(pluginid: integer):string; 
     
    13271329  exportedfunctions.disassembleEx:=@ce_disassemble; 
    13281330  exportedfunctions.loadModule:=@ce_loadModule; 
     1331 
     1332  exportedfunctions.aa_AddExtraCommand:=@aa_AddExtraCommand; 
     1333  exportedfunctions.aa_RemoveExtraCommand:=@aa_RemoveExtraCommand; 
     1334 
    13291335end; 
    13301336 
  • Cheat Engine/plugin/cepluginsdk.h

    r307 r309  
    148148typedef BOOL (__stdcall *CEP_LOADMODULE)(char *modulepath, char *exportlist, int *maxsize); 
    149149typedef BOOL (__stdcall *CEP_DISASSEMBLEEX)(ULONG address, char *output, int maxsize); 
     150typedef VOID (__stdcall *CEP_AA_ADDCOMMAND)(void); 
     151typedef VOID (__stdcall *CEP_AA_DELCOMMAND)(void); 
    150152 
    151153typedef struct _ExportedFunctions 
     
    255257  CEP_DISASSEMBLEEX disassembleEx; 
    256258  CEP_LOADMODULE loadModule; 
     259  CEP_AA_ADDCOMMAND aa_AddExtraCommand; 
     260  CEP_AA_DELCOMMAND aa_RemoveExtraCommand; 
    257261 
    258262 
  • Cheat Engine/plugin/cepluginsdk.pas

    r307 r309  
    125125type TloadModule=function(modulepath: pchar; exportlist: pchar; maxsize: pinteger): BOOL; stdcall; 
    126126type TDisassembleEx=function(address: pdword; output: pchar; maxsize: integer): BOOL; stdcall; 
     127type Taa_AddExtraCommand=procedure(command:pchar); 
     128type Taa_RemoveExtraCommand=procedure(command:pchar); 
    127129 
    128130type TPluginVersion =record 
     
    237239  disassembleEx     : TDisassembleEx; 
    238240  loadModule        : TloadModule; 
     241 
     242  aa_AddExtraCommand: Taa_AddExtraCommand; 
     243  aa_RemoveExtraCommand:Taa_RemoveExtraCommand; 
     244 
    239245end; 
    240246 
  • Cheat Engine/pluginexports.pas

    r303 r309  
    3737 
    3838function ce_loadModule(modulepath: pchar; exportlist: pchar; maxsize: pinteger): BOOL; stdcall; 
     39 
    3940 
    4041