Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/cheat-engine/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrinzPlayer committed Mar 27, 2016
2 parents 48292a4 + ca761e8 commit 7ead0c6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DBKKernel/IOPLDispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ NTSTATUS DispatchIoctl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
if (PsLookupProcessByProcessId((PVOID)(UINT_PTR)(processid),&selectedprocess)==STATUS_SUCCESS)
{

DbgPrint("Calling ObOpenObjectByPointer\n");
//DbgPrint("Calling ObOpenObjectByPointer\n");
ntStatus=ObOpenObjectByPointer (
selectedprocess,
0,
Expand All @@ -268,7 +268,7 @@ NTSTATUS DispatchIoctl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
KernelMode, //UserMode,
&ProcessHandle);

DbgPrint("ntStatus=%x",ntStatus);
//DbgPrint("ntStatus=%x",ntStatus);
}
}
__except(1)
Expand Down
4 changes: 2 additions & 2 deletions DBKKernel/ces.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ goto error
if "%AMD64%"=="1" goto x86success

copy .\obj%BUILD_ALT_DIR%\i386\dbk.sys "..\Cheat Engine\bin\dbk32.sys"
signtool sign /ac "..\cheat engine\release\sig\GlobalSign Root CA.crt" /n "Cheat Engine" /t http://timestamp.globalsign.com/scripts/timstamp.dll "..\Cheat Engine\bin\dbk32.sys"
signtool sign /a /ac "..\cheat engine\release\sig\GlobalSign Root CA.crt" /n "Cheat Engine" /t http://timestamp.globalsign.com/scripts/timstamp.dll "..\Cheat Engine\bin\dbk32.sys"
goto successend

:x86success:
copy .\obj%BUILD_ALT_DIR%\amd64\dbk.sys "..\Cheat Engine\bin\dbk64.sys"
signtool sign /ac "..\cheat engine\release\sig\GlobalSign Root CA.crt" /n "Cheat Engine" /t http://timestamp.globalsign.com/scripts/timstamp.dll "..\Cheat Engine\bin\dbk64.sys"
signtool sign /a /ac "..\cheat engine\release\sig\GlobalSign Root CA.crt" /n "Cheat Engine" /t http://timestamp.globalsign.com/scripts/timstamp.dll "..\Cheat Engine\bin\dbk64.sys"

siggen\siggen.exe "..\Cheat Engine\bin\cheatengine-i386.exe"
siggen\siggen.exe "..\Cheat Engine\bin\cheatengine-x86_64.exe"
Expand Down
24 changes: 19 additions & 5 deletions DBKKernel/ultimap.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ Called from usermode to wait for data

}

void ultimap_cleanstate()
{
APIC_BASE->LVT_Performance_Monitor.a = APIC_BASE->LVT_Performance_Monitor.a & 0xff;
APIC_BASE->EOI.a = 0;
}

int perfmon_interrupt_centry(void)
{
KIRQL old;
Expand All @@ -214,11 +220,7 @@ int perfmon_interrupt_centry(void)


if (causedbyme)
{
//undo the system flags that got set by this interrupt
APIC_BASE->LVT_Performance_Monitor.a=APIC_BASE->LVT_Performance_Monitor.a & 0xff;
APIC_BASE->EOI.a=0;
}
ultimap_cleanstate();

blocksize=DS_AREA[cpunr()]->BTS_IndexBaseAddress-DS_AREA[cpunr()]->BTS_BufferBaseAddress;

Expand Down Expand Up @@ -513,11 +515,13 @@ Call this for each processor
DbgPrint("APIC_BASE->LVT_Performance_Monitor.a=%x\n", APIC_BASE->LVT_Performance_Monitor.a);


/*
if (inthook_HookInterrupt((unsigned char)perfmonIVT, getCS(), (ULONG_PTR)perfmon_interrupt, &perfmonJumpBackLocation))
DbgPrint("Interrupt hooked\n");
else
DbgPrint("Failed to hook interrupt\n");
*/

}

Expand All @@ -533,6 +537,14 @@ Call this for each processor
}


void perfmon_hook(__in struct _KINTERRUPT *Interrupt, __in PVOID ServiceContext)
{
perfmon_interrupt_centry();
ultimap_cleanstate();
}

void *pperfmon_hook = perfmon_hook;

NTSTATUS ultimap(UINT64 cr3, UINT64 dbgctl_msr, int DS_AREA_SIZE, BOOL savetofile, WCHAR *filename, int handlerCount)
{
struct
Expand Down Expand Up @@ -604,6 +616,8 @@ NTSTATUS ultimap(UINT64 cr3, UINT64 dbgctl_msr, int DS_AREA_SIZE, BOOL savetofil
params.dbgctl_msr=dbgctl_msr;
params.DS_AREA_SIZE=DS_AREA_SIZE;

HalSetSystemInformation(HalProfileSourceInterruptHandler, sizeof(PVOID*), &pperfmon_hook); //hook the perfmon interrupt

forEachCpu(ultimap_setup_dpc, &params, NULL, NULL);
return STATUS_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion DBKKernel/vmxoffload.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void vmxoffload(PCWSTR dbvmimgpath)

if (statusblock.Status==STATUS_SUCCESS)
{
DWORD vmmsize=fsi.EndOfFile.LowPart-(startsector*512);
DWORD vmmsize = fsi.EndOfFile.LowPart;// -(startsector * 512);

//now read the vmdisk into the allocated memory
DbgPrint("The startsector=%d (that's offset %d)\n",startsector,startsector*512);
Expand Down

0 comments on commit 7ead0c6

Please sign in to comment.