Skip to content

Commit

Permalink
display memory free for DBVM in the about screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cheat-engine committed Feb 21, 2018
1 parent ca07221 commit 2350d9f
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cheat Engine/bin/celua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ properties

OnClose: function(sender) - The function to call when the form gets closed
OnDropFiles: function(sender, {filenames}) - Called when files are dragged on top of the form. Filenames is an arraytable with the files
FormState: FormState string ReadOnly - The current state of the form. Possible values: fsCreating, fsVisible, fsShowing, fsModal, fsCreatedMDIChild, fsBorderStyleChanged, fsFormStyleChanged, fsFirstShow, fsDisableAutoSize


methods
Expand Down
3 changes: 3 additions & 0 deletions Cheat Engine/bin/defines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ VK_LMENU = 164
VK_RSHIFT = 161
VK_RCONTROL = 163
VK_RMENU = 165
VK_OEM1=0xBA
VK_OEM2=0xBF
VK_OEM3=0xc0


--shellExecute show defines:
Expand Down
6 changes: 5 additions & 1 deletion Cheat Engine/dbk32/DBK32functions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@ function internal_LaunchDBVM(parameters: pointer): BOOL; stdcall;

temp: widestring;

proc, sys: DWORD_PTR;
proc, sys, thread: DWORD_PTR;

cpuid: integer;
fc: dword;
Expand All @@ -2669,6 +2669,7 @@ function internal_LaunchDBVM(parameters: pointer): BOOL; stdcall;

GetProcessAffinityMask(GetCurrentProcess, proc, sys);
SetProcessAffinityMask(GetCurrentProcess, 1 shl cpuid);
SetThreadAffinityMask(GetCurrentThread, 1 shl cpuid);
sleep(10);
end
else
Expand Down Expand Up @@ -2704,7 +2705,10 @@ function internal_LaunchDBVM(parameters: pointer): BOOL; stdcall;
configure_vmx(vmx_password1, vmx_password2);

if parameters<>nil then
begin
SetProcessAffinityMask(GetCurrentProcess, proc);
SetThreadAffinityMask(GetCurrentThread, proc);
end;

end else result:=false;
end;
Expand Down
91 changes: 90 additions & 1 deletion Cheat Engine/dbk32/vmxfunctions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface

VMCALL_ULTIMAP_DEBUGINFO = 36;
VMCALL_TESTPSOD = 37;
VMCALL_GETMEM = 38;

type
TOriginalState=packed record
Expand Down Expand Up @@ -87,6 +88,8 @@ function dbvm_ultimap_debuginfo(debuginfo: PULTIMAPDEBUGINFO): DWORD;

procedure dbvm_switchToKernelMode(cs: word; rip: pointer; parameters: pointer);

function dbvm_getMemory(var pages: QWORD): QWORD;


procedure dbvm_enterkernelmode(originalstate: POriginalState);
procedure dbvm_returntousermode(originalstate: POriginalState);
Expand Down Expand Up @@ -126,6 +129,7 @@ implementation
rsSmallError = 'error';

var vmcall :function(vmcallinfo:pointer; level1pass: dword): PtrUInt; stdcall;
var vmcall2 :function(vmcallinfo:pointer; level1pass: dword; secondaryOut: PQWORD): PtrUInt; stdcall;

function vmcallUnSupported(vmcallinfo:pointer; level1pass: dword): PtrUInt; stdcall;
begin
Expand Down Expand Up @@ -182,6 +186,72 @@ function vmcallSupported_amd(vmcallinfo:pointer; level1pass: dword): PtrUInt; st
result:=r;
end;

function vmcallSupported2_amd(vmcallinfo:pointer; level1pass: dword; output2: pptruint): PtrUInt; stdcall;
var
{$ifdef cpu64}
originalrdx: ptruint;
{$endif}
r,r2: ptruint;
begin
asm
{$ifdef cpu64}
mov originalrdx,rdx
mov rax,vmcallinfo
mov edx,level1pass
vmmcall

mov r2,rdx

mov rdx,originalrdx
mov r,rax
{$else}
mov eax,vmcallinfo
mov edx,level1pass
vmmcall //should raise an UD if the cpu does not support it (or the password is wrong)
mov r,eax
mov r2,edx
{$endif}
end;

result:=r;
if output2<>nil then
output2^:=r2;
end;


function vmcallSupported2_intel(vmcallinfo:pointer; level1pass: dword; output2: pptruint): PtrUInt; stdcall;
var
{$ifdef cpu64}
originalrdx: ptruint;
{$endif}
r: ptruint;
r2: ptruint;
begin
asm
{$ifdef cpu64}
mov originalrdx,rdx
mov rax,vmcallinfo
mov edx,level1pass
vmcall

mov r2,rdx

mov rdx,originalrdx
mov r,rax
{$else}
mov eax,vmcallinfo
mov edx,level1pass
vmcall //should raise an UD if the cpu does not support it (or the password is wrong)
mov r,eax
mov r2,edx
{$endif}
end;

result:=r;
if output2<>nil then
output2^:=r2;
end;

function vmcallSupported_intel(vmcallinfo:pointer; level1pass: dword): PtrUInt; stdcall;
var
{$ifdef cpu64}
Expand Down Expand Up @@ -501,6 +571,19 @@ procedure dbvm_writeMSR(msr: dword; value: qword);
vmcall(@vmcallinfo,vmx_password1);
end;

function dbvm_getMemory(var pages: QWORD): QWORD;
var vmcallinfo: packed record
structsize: dword;
level2pass: dword;
command: dword;
end;
begin
vmcallinfo.structsize:=sizeof(vmcallinfo);
vmcallinfo.level2pass:=vmx_password2;
vmcallinfo.command:=VMCALL_GETMEM;
result:=vmcall2(@vmcallinfo,vmx_password1, @pages);
end;

function dbvm_getRealCR0: QWORD;
var vmcallinfo: packed record
structsize: dword;
Expand Down Expand Up @@ -1109,9 +1192,15 @@ initialization
if isDBVMCapable then
begin
if isamd then
vmcall:=vmcallSupported_amd
begin
vmcall:=vmcallSupported_amd;
vmcall2:=vmcallSupported2_amd
end
else
begin
vmcall:=vmcallSupported_intel;
vmcall2:=vmcallSupported2_intel;
end;

end;
{$endif}
Expand Down
6 changes: 5 additions & 1 deletion Cheat Engine/docs/todo.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generate pointermap may show that it will genertae billions os useless results
generate pointermap may show that it will genertae billions of useless results (it shouldn't)
after the pointermap generation is done and being written to disk, the progressbar shows a small percentage. Change it to some text saying saving
creating a new tab with a groupscan setup looks bad

Expand All @@ -11,6 +11,8 @@ structure dissect:
for .net games let stucture dissect see those structures aS WELL
AND LUA

triggering hotkeys (no matter what they do) while in settings breaks CE completely
add AVX support

mono dissect: order methods by alphabet

Expand All @@ -23,6 +25,8 @@ graphical memory view:
change format makes it black sometimes(loses position ?)
sometimes the x position is not 0, but can't be changed back

memview debugging: add a toolbar for single step/step over so you can debug by clicking icons


find higher resolution icons

Expand Down
6 changes: 3 additions & 3 deletions Cheat Engine/plugin/cepluginsdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ typedef int (__stdcall *CEP_PLUGINTYPE2)(LPDEBUG_EVENT DebugEvent);
typedef void (__stdcall *CEP_PLUGINTYPE3)(ULONG processid, ULONG peprocess, BOOL Created);
typedef void (__stdcall *CEP_PLUGINTYPE4)(int reserved);
typedef void (__stdcall *CEP_PLUGINTYPE5)(void);
typedef BOOL (__stdcall *CEP_PLUGINTYPE6ONPOPUP)(ULONG selectedAddress, char **addressofname, BOOL *show);
typedef BOOL (__stdcall *CEP_PLUGINTYPE6)(ULONG *selectedAddress);
typedef void (__stdcall *CEP_PLUGINTYPE7)(ULONG address, char **addressStringPointer, char **bytestringpointer, char **opcodestringpointer, char **specialstringpointer, ULONG *textcolor);
typedef BOOL (__stdcall *CEP_PLUGINTYPE6ONPOPUP)(UINT_PTR selectedAddress, char **addressofname, BOOL *show);
typedef BOOL (__stdcall *CEP_PLUGINTYPE6)(UINT_PTR *selectedAddress);
typedef void (__stdcall *CEP_PLUGINTYPE7)(UINT_PTR address, char **addressStringPointer, char **bytestringpointer, char **opcodestringpointer, char **specialstringpointer, ULONG *textcolor);
typedef void (__stdcall *CEP_PLUGINTYPE8)(char **line, AutoAssemblerPhase phase, int id);


Expand Down

0 comments on commit 2350d9f

Please sign in to comment.