obhq / obliteration

Experimental free and open-source PlayStation 4 kernel
https://obliteration.net
Apache License 2.0
619 stars 17 forks source link

WinHvPlatform.dll crashes Obliteration when pressing Start on any game. #914

Open VocalFan opened 1 month ago

VocalFan commented 1 month ago

Faulting application name: Obliteration.exe, version: 0.0.1.0, time stamp: 0x66aa766c Faulting module name: WinHvPlatform.dll, version: 10.0.22621.3672, time stamp: 0xb628bb33 Exception code: 0xc0000005 Fault offset: 0x00000000000076d7 Faulting application path: C:\Users\ghost\Downloads\obliteration-win-x64\Obliteration.exe Faulting module path: C:\WINDOWS\SYSTEM32\WinHvPlatform.dll

SuchAFuriousDeath commented 1 month ago

This will be a joy to debug :skull:

VocalFan commented 1 month ago

And I can't help but feel like Ultima removed the log file being in appdata...

VocalFan commented 1 month ago

This will be a joy to debug 💀

(bac.3048): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
WinHvPlatform!WHvApi::Hypercall::SetVpRegisters+0x1df:
00007ffc`12d976d7 410f280402      movaps  xmm0,xmmword ptr [r10+rax] ds:0000007d`18affb38=0000000000000000ffffffff8240c000
ultimaweapon commented 1 month ago

Can you identify which line that cause this error?

VocalFan commented 1 month ago

@ultimaweapon GOTCHA

    fn states(&mut self) -> Result<Self::States<'_>, Self::GetStatesErr> {
        let mut values: [WHV_REGISTER_VALUE; REGISTERS] = unsafe { zeroed() };
        let status = unsafe {
            WHvGetVirtualProcessorRegisters(
                self.part,
                self.index,
                WhpStates::NAMES.as_ptr(),
                REGISTERS as _,
                values.as_mut_ptr(),
            )
        };

Here; WHvGetVirtualProcessorRegisters(

ultimaweapon commented 1 month ago

I have no idea what causing segmentation fault here. We probably need someone with Windows to fix this.

VocalFan commented 1 month ago

Deduction here:

self.part, unless cloned, println!'d, or otherwise affected before being used by WHvGetVirtualProcessorRegisters... Will be free'd before WHvGetVirtualProcessorRegisters can use it, causing a Memory Access Violation.

SuchAFuriousDeath commented 1 month ago

That makes no sense I think

VocalFan commented 1 month ago

That makes no sense I think

It's what happens, however... The value is getting dropped for SOME reason unless I use something to make it active in the function before WHvGetVirtualProcessorRegisters uses it...

SuchAFuriousDeath commented 1 month ago

But that doesn't make sense. You can't 'drop' an int.

VocalFan commented 1 month ago

But that doesn't make sense. You can't 'drop' an int.

And I find it weird that if I do self.part = self.part.clone(), it works.

ultimaweapon commented 1 month ago

That why we need to figure out why it is crashing because your fix does not make sense.

VocalFan commented 1 month ago

That why we need to figure out why it is crashing because your fix does not make sense.

Welllll, have fun with Miri https://github.com/rust-lang/miri

ultimaweapon commented 1 month ago

@VocalFan you can set a breakpoint on that line and view its assembly once the breakpoint are hit to see how it calls the function?

VocalFan commented 1 month ago

@VocalFan you can set a breakpoint on that line and view its assembly once the breakpoint are hit to see how it calls the function?

{part:2517404947584, index:0}

This is for self.part and self.index

VocalFan commented 1 month ago

image

VocalFan commented 1 month ago

image Error point.

VocalFan commented 1 month ago
rip: 0x00007FF76F742C27
rsp: 0x000000FED0DFD690
eax: 0xD0DFD470
ultimaweapon commented 1 month ago

No idea what wrong here since everything looks okay.

VocalFan commented 1 month ago

No idea what wrong here since everything looks okay.

Maybe a bug with windows-sys?

ultimaweapon commented 1 month ago

Everything here looks correctly so no. Seems like I need to set up a Windows machine to figure out.

VocalFan commented 1 month ago

Gonna see if this magically got fixed

VocalFan commented 1 month ago

image I mean, it's new.

VocalFan commented 1 month ago

.next_multiple_of(Ram::VM_PAGE_SIZE) a very temporary thing of this on p_vaddr, and guess what came back?

Stop reason: Exception 0xc0000005 encountered at address 0x7ffc2bef39c6: Access violation reading location 0xffffffffffffffff image

VocalFan commented 1 month ago

But I think that might be a hint, the unaligned address.