;;; --------------------------------------------------------------------------
;;; In-Game Reset
;;;
;;; Assumes media patch (uses that free space)
;;; --------------------------------------------------------------------------
%macro igr 7
%ifdef IGR
mov eax,%1
mov ebx,%2
mov ecx,%3
%ifdef IGR_TO_DASHBOARD
%ifdef IGR_FULL_REBOOT
mov edx,%4
%else
mov edx,%5
mov esi,%6
mov ebp,%7
%endif
%endif
call installigr
%endif
%endmacro
%ifdef IGR
%define IGR_SIZE (patchigr.end-patchigr)
CODE_SECTION
installigr:
mov edi,[sign_space]
setcalljmptarget ebx, patchigr, patchigr.var_KeRaiseIrqlToDpcLevel_1, edi
setcalljmptarget ecx, patchigr, patchigr.var_HalReturnToFirmware_1, edi
%ifdef IGR_TO_DASHBOARD
%ifdef IGR_FULL_REBOOT
setcalljmptarget edx, patchigr, patchigr.var_HalWriteSMBusValue_1, edi
%else
mov [patchigr.ldatp+1],edx
setcalljmptarget esi, patchigr, patchigr.var_MmAllocateContiguousMemory_1, edi
setcalljmptarget ebp, patchigr, patchigr.var_MmPersistContiguousMemory_1, edi
%endif
%endif
mov ebx,[memdiff]
lea edx,[edi-80010000h]
mov [eax+ebx],edx
lea eax,[edi+patchigr.getstateret-patchigr]
mov [patchigr.gsradx+4],eax
mov esi,patchigr
mov ecx,IGR_SIZE
add edi,ebx
rep movsb
sub edi,ebx
mov [sign_space],edi
ret
DATA_SECTION
patchigr:
mov eax,[esp]
cmp eax,80000000h
jae .realf
mov edx,[eax]
mov dh,0
cmp edx,0C24008Bh
jne .realf
; cmp byte [eax+4],8Bh
; jne .realf
cmp dword [eax+6],0A3h
jne .realf
sub esp,byte 12
push esi
push edi
lea esi,[esp+12+8]
lea edi,[esp+8]
push byte 6
pop ecx
rep movsd
pop edi
pop esi
.gsradx:mov dword [esp+12],0
.realf:
VJMP KeRaiseIrqlToDpcLevel_1 ; jump to real KeRaiseIrqlToDpcLevel
.getstateret:
test eax,eax
jnz .gsro
%ifdef IGR_MASTER_PORT
mov eax,[esp+4]
mov eax,[eax]
mov eax,[eax]
cmp dword [eax+20],byte IGR_MASTER_PORT
jne .norst
%endif ; IGR_MASTER_PORT
mov eax,[esp+8]
cmp word [eax+4+8],0FFFFh
jne .norst
test byte [eax+4],20h
jnz .checkaltrst
test byte [eax+4],10h
jz .norst
cmp byte [eax+4+6],0
jne short .doboot
.norst:
xor eax,eax
.gsro: ret 8
.checkaltrst:
test byte [eax+4],10h
jnz .bootdash
cmp byte [eax+4+6],0
je .norst
.bootdash:
%ifdef IGR_FULL_REBOOT
%ifdef IGR_TO_DASHBOARD
push byte 0Ch
push byte 0
push byte 1Bh
push byte 20h
VCALL HalWriteSMBusValue_1
%endif ; IGR_TO_DASHBOARD
.doboot:
push byte 1
%else ; !IGR_FULL_REBOOT, do quick reboot
%ifdef IGR_TO_DASHBOARD
.ldatp: mov esi,0 ; LaunchDataPage address
mov edi,1000h
mov ebx,[esi]
test ebx,ebx
jnz .memok
push edi
VCALL MmAllocateContiguousMemory_1
test eax,eax
jz .doboot
mov ebx,eax
mov [esi],eax
.memok:
push byte 1
push edi
push ebx
VCALL MmPersistContiguousMemory_1
mov edi,ebx
xor eax,eax
mov ecx,400h
rep stosd
or dword [ebx],byte -1
%endif ; IGR_TO_DASHBOARD
.doboot:
push byte 2
%endif ; !IGR_FULL_REBOOT
VCALL HalReturnToFirmware_1
.end:
%else ; !IGR
%define IGR_SIZE 0
%endif ; !IGR
Click to expand...