Marc-Pierre-Barbier / Genshin-Impact-on-linux

this repository only contains a README that describe how to get genshin impact running inside vmware
53 stars 3 forks source link

broken in 1.3: ideas #7

Open ghost opened 3 years ago

ghost commented 3 years ago

I am investigating into it being broken and I think it detects the IO port in VMware. Now, it seems that more things are being detected. I am masking the DMI information, but it fails (and I am on VirtualBox unfortunately). Can somebody try? Also, keep in mind that it might be completely impossible to stop them from detecting the VM (due to some privileged operations taking longer and causing VM exits)

ghost commented 3 years ago

Maybe consider using QEMU? Self-denied; QEMU does not allow for good virtual GPU's and passthrough will make you unable to see your screen if you only have 1 GPU (and I am unable to code C at the moment to fix the first problem)

Try masking the DMI information? -> I am trying to no avail, but I might succeed. However, it is very easy to detect yourself running in a VM, by simply measuring the time of a privileged instruction. To bypass this, we need to freeze time while the privileged instruction is executing (and I am unable to code C, of course)

Any other ideas before I (and lots of people) just go to Bluestacks-on-wine? that is not possible (Wine does not work with it)

ghost commented 3 years ago

QEMU ARM and install Android on it, and install Genshin Impact on it?

Or Anbox?

Marc-Pierre-Barbier commented 3 years ago

I can code in c with no issue but I have no idea how to implement that

Marc-Pierre-Barbier commented 3 years ago

QEMU ARM and install Android on it, and install Genshin Impact on it?

Or Anbox?

Might worth the shot but we will probably lose mouse control for the game

ghost commented 3 years ago

Unfortunately, I am on macOS (Catalina), so I cannot install Anbox. Could you try?

ghost commented 3 years ago

QEMU ARM and install Android on it, and install Genshin Impact on it? Or Anbox?

Might worth the shot but we will probably lose mouse control for the game

Probably. Or we will have to reimplement Bluestacks mouse+keyboard controls.

Marc-Pierre-Barbier commented 3 years ago

QEMU ARM and install Android on it, and install Genshin Impact on it? Or Anbox?

Might worth the shot but we will probably lose mouse control for the game

Probably. Or we will have to reimplement Bluestacks mouse+keyboard controls.

Just check there is no controller support on genshin android. Andbos is based on lxc so no arm support Maybe a m1 macbook or a chrome book coul use it but not amd64 since the game is arm only as I seen

We can still try qemu it does support arm emulation

ghost commented 3 years ago

https://android.stackexchange.com/questions/115320/is-it-possible-to-simulate-touch-without-root

I can code in shell script and reimplement Bluestacks-like mouse+keyboard controls (sshing to the emulated android device and making a fifo to touch the screen). This means QEMU is feasible, but still no virtual GPU

ghost commented 3 years ago

Note: the Android version has no anticheat (!!!), so it cannot detect VMs.

Marc-Pierre-Barbier commented 3 years ago

https://android.stackexchange.com/questions/115320/is-it-possible-to-simulate-touch-without-root

I can code in shell script and reimplement Bluestacks-like mouse+keyboard controls (sshing to the emulated android device and making a fifo to touch the screen). This means QEMU is feasible, but still no virtual GPU

Maybe virtio it does have opengl support it might be worth a try

I can code in c a translation layer for joystick input it easy to do

I will try to get android running in a vm tomorrow

ghost commented 3 years ago

It should be as easy as running $ input tap x y

ghost commented 3 years ago

Assuming the Android image does not have crippled binaries, this is simple ssh -T command.

Marc-Pierre-Barbier commented 3 years ago

ok from what i heard using the android-sdk to get an easy emulation is not possible they deprecated arm some years ago and now it segfault, we can still try libhoudini and qemu

Edit : they added arm emulation to android 10 in the avd i will try it since i have it already installed for android development Edit2: it's trash Edit3: libhoudini don't work with genshin

Marc-Pierre-Barbier commented 3 years ago

ok a new idea it might be super dumb or super smart or both but i discovered that there is a chinese emulator that can run the game and is called memu but it can only run in windows i tried their installer with wine it crash i will do some testing by extract the binaries from windows after installation, but worst case senario we will just be able to launch the game in the windows vm

Marc-Pierre-Barbier commented 3 years ago

i have a second stupid idea nested qemu - vmware vm -> we passthrough to the qemu vm the vmware gpu

this way only the gpu is signed by vmware

ghost commented 3 years ago

I thought memu also failed to run the game.

i have a second stupid idea nested qemu - vmware vm -> we passthrough to the qemu vm the vmware gpu

this way only the gpu is signed by vmware

Performance impact will be too big except if you have a Ryzen 7 2nd gen or something (forgot the model numbers)

ghost commented 3 years ago

this way only the gpu is signed by vmware

I cannot fake GPU BIOS/EFI DMI information for the GPU. This means that VMs (host => vm => genshin) are now impossible, because the information gets regenerated at reboot and deleting keyn in the registry only affects the next boot.

ghost commented 3 years ago

I can code in c a translation layer for joystick input it easy to do

I will be unable to test that unfortunately. I think I might want to make a shell script for that (haha I only know shell and now it is useful for once)

ghost commented 3 years ago

Bluestacks apparently works with 64-bit instance (install with Instance Manager)

Unfortunately, it does not work with macOS, since there is no nested Intel VT-X or AMD [insert name here]

ghost commented 3 years ago

A stupid idea: qemu-arm (not qemu-system-arm) the binary after extracting the .apk. This will most likely fail but let’s try.

ghost commented 3 years ago

apktool will make this easy. Also, reverse-engineering for the purpose of compatibility is legal in France and where I live.

Marc-Pierre-Barbier commented 3 years ago

ok i read a lot online and the thing is that most android emulator don't suport armv8 64bit and genshin does use armv8 64 so it's not an option to emulate it since libhoudini only support armv8 32bit or armv7 64bit, last hope is qemu

ghost commented 3 years ago

What about using the user-mode QEMU? Not qemu-system-arm, just qemu-arm to run the binary

ghost commented 3 years ago

Wait, QEMU TCG on X86-64 should work, because all instructions take some x amount of time to execute. so QEMU must be TCG

Dont’t forget to fake DMI/GPU info/CPU CPUID

ghost commented 3 years ago

android-x86 has a native bridge, sounds like QEMU (usermode)-in-QEMU, might also be worth a try

ghost commented 3 years ago

New problem: we do not have an ARM CPU to grab the CPUID off of

Probably not an issue (no anticheat)

Marc-Pierre-Barbier commented 3 years ago

qemu-aarm will not work because we will miss the all of the android libs, i tried to make a qemu android vm i found how and im not motivated to compile qemu with the android patches just to discover that the performance are garbage

maybe qemu-aarm inside of android x86 ? i may try latter but if i remember correct running android apps require starting an intent and an intent is a java object so i don't know how will qemu-arm behave

ghost commented 3 years ago

android x86 has a compat layer for arm64 apps

in settings

let me try

PseudoDistant commented 3 years ago

~Maybe consider using QEMU?~ Self-denied; QEMU does not allow for good virtual GPU's and passthrough will make you unable to see your screen if you only have 1 GPU (and I am unable to code C at the moment to fix the first problem)

I managed to get single-GPU passthrough working just fine. I can start the VM through the console (Linux no GUI), then when the VM shuts down, I just auto-start SDDM and everything's good :D .

(I don't have Genshin working, but it's something.)

I am running an AMD Radeon RX570, don't know if that helps.

#!/bin/sh
function initvm {

#   |||Stops display manager before unstrapping GPU|||
systemctl stop display-manager.service

#   Unbind the VTConsoles :D .
#echo 0 > /sys/class/vtcon0/bind
#echo 0 > /sys/class/vtcon1/bind

#   Unbind GPU from driver
echo 0000:09:00.0 > /sys/bus/pci/drivers/amdgpu/unbind
echo 0000:09:00.1 > /sys/bus/pci/drivers/snd_hda_intel/unbind

#   Also unbind the EFI-Framebuffer!!!
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind

# Without sleep, Race condition error
sleep 2

#   Unload GPU drivers
modprobe -r amdgpu

#   Unbind GPU
virsh nodedev-detach pci_0000_09_00_0
virsh nodedev-detach pci_0000_09_00_1

#   Load VFIO to strap GPU
modprobe vfio-pci
modprobe vfio
modprobe vfio_iommu_type1

#   Bind GPU to vfio-pci
echo 0000:09:00.0 > /sys/bus/pci/drivers/vfio-pci/bind
echo 0000:09:00.1 > /sys/bus/pci/drivers/vfio-pci/bind
}
function runvm {

#   Load QEMU KVM (Windows 10)
qemu-system-x86_64 --enable-kvm \
-smp cores=8 \
-cpu EPYC-v1,hv_vendor_id=null \
-machine kernel_irqchip=on \
-m 12288 \
-usb \
-device qemu-xhci,id=xhci \
-device usb-host,bus=xhci.0,hostbus=01,hostaddr=2 \
-device usb-tablet,bus=xhci.0 \
-device vfio-pci,host=09:00.0,multifunction=on,x-vga=on \
-device vfio-pci,host=09:00.1,multifunction=on \
-device vfio-pci,host=0a:00.3,multifunction=on \
-display none \
-vga none \
-net nic -net user \
--hda /home/farlandercraft/WinVM/Windows10.img \
--hdb /home/farlandercraft/2Drive/AME/Data.img \
-boot menu=on

# -machine kernel_irqchip=on \
# AMD Radeon VGA compatible controller [1002:67df] pci:v00001002d000067DFsv00001462sd0000341Bbc03sc00i00
# AMD Radeon audio device [1002:aaf0] pci:v00001002d0000AAF0sv00001462sd0000AAF0bc04sc03i00

#-bios /usr/share/edk2-ovmf/x64/OVMF_CODE.fd \
#-m 12288 \
#-device usb-host,bus=xhci.0,hostbus=03,hostaddr=5 \
#--cdrom /home/farlandercraft/2Drive/iso/Win101903.iso \
#-display gtk,gl=on \
}
function normalize {

#   |||Everything here loads after the QEMU KVM stops|||

#   Unbind GPU from vfio-pci
echo 0000:09:00.0 > /sys/bus/pci/drivers/vfio-pci/unbind
echo 0000:09:00.1 > /sys/bus/pci/drivers/vfio-pci/unbind

#   Unload VFIO
modprobe -r vfio-pci
modprobe -r vfio_iommu_type1
modprobe -r vfio

#   Restart Host to GPU connection
virsh nodedev-reattach pci_0000_09_00_0
virsh nodedev-reattach pci_0000_09_00_1

#   Rebind VTConsoles :D !
#echo 1 > /sys/class/vtcon0/bind
#echo 1 > /sys/class/vtcon1/bind

#   Reload GPU drivers
modprobe amdgpu

#   Bind GPU to driver
echo 0000:09:00.0 > /sys/bus/pci/drivers/amdgpu/bind
echo 0000:09:00.1 > /sys/bus/pci/drivers/snd_hda_intel/bind

#   Restart display manager after strapping GPU !!!
#systemctl start display-manager.service

#   Reboot system (useful if necessary)
#reboot
}

initvm
runvm
normalize
exit 0
ghost commented 3 years ago

woah. Mind = blown. I thought GPU passthrough was impossible.... but single-GPU passthrough? Impressive.

PseudoDistant commented 3 years ago

woah. Mind = blown. I thought GPU passthrough was impossible.... but single-GPU passthrough? Impressive.

Thanks :smiling_face_with_three_hearts: .

ghost commented 3 years ago

And this shell script is impressive too. Where did you learn the /sys/class paths?

PseudoDistant commented 3 years ago

And this shell script is impressive too. Where did you learn the /sys/class paths?

Years trapped in the basement :fearful: .

jk I learned that stuff on StackOverflow and the Arch Linux wiki.

ghost commented 3 years ago

I learned the unbind paths with ls -R (exploring)

ghost commented 3 years ago

(turns out I unbound the hard drive)

PseudoDistant commented 3 years ago

(turns out I unbound the hard drive)

lol

ghost commented 3 years ago

by the way, to hide kvm, kvm=off on the qemu command line (it will drop the kvm cpuid bit 31, hypervisor)

Consider also faking the CPUID to your host machine.

edit: also, avoid virtio devices like the plague if you can, they are much faster but easily detected edit: Also, TCG is our only option, because KVM is detectable (and so is hv)

PseudoDistant commented 3 years ago

by the way, to hide kvm, kvm=off on the qemu command line (it will drop the kvm cpuid bit 31, hypervisor)

Consider also faking the CPUID to your host machine.

edit: also, avoid virtio devices like the plague if you can, they are much faster but easily detected edit: Also, TCG is our only option, because KVM is detectable (and so is hv)

nuuuu not KVM ;-; . Why do they block VMs? It's so dumb.

Marc-Pierre-Barbier commented 3 years ago

You can hide kvm just look pcie passthrough guide for nvidia they have to do it to get the driver working.

I already mentioned the pcie passthrough In the original .md but I didn't explain why I didn't do it I have a laptop with fucked up iommu group and no way of dumping my gpu bios making the passthrough method just impossible for some

I can fix the iommu with vfio override but since it's a laptop dgpu i need the bios to get it running

And vfio override is a big security risk and you need to compile a kernel with it built in

And i also mentioned gvt-g Wich allow to split intel hd into vgpu that you can passthrough bit it's bad for performance (i got the genshin logo and then 1-0fps

PseudoDistant commented 3 years ago

You can hide kvm just look pcie passthrough guide for nvidia they have to do it to get the driver working.

I already mentioned the pcie passthrough In the original .md but I didn't explain why I didn't do it I have a laptop with fucked up iommu group and no way of dumping my gpu bios making the passthrough method just impossible for some

I can fix the iommu with vfio override but since it's a laptop dgpu i need the bios to get it running

And vfio override is a big security risk and you need to compile a kernel with it built in

And i also mentioned gvt-g Wich allow to split intel hd into vgpu that you can passthrough bit it's bad for performance (i got the genshin logo and then 1-0fps

I don't know how, or if it works, but perhaps Looking Glass might work to resolve that? I'm aware that it makes setting up GPU passthrough easier, but I don't know exactly what it does lmao . (I usually just configure everything myself.)

Maybe not, again I don't know what it does. Maybe the limitations of your IOMMU groups really are unbreakable :/ .

Marc-Pierre-Barbier commented 3 years ago

You can hide kvm just look pcie passthrough guide for nvidia they have to do it to get the driver working. I already mentioned the pcie passthrough In the original .md but I didn't explain why I didn't do it I have a laptop with fucked up iommu group and no way of dumping my gpu bios making the passthrough method just impossible for some I can fix the iommu with vfio override but since it's a laptop dgpu i need the bios to get it running And vfio override is a big security risk and you need to compile a kernel with it built in And i also mentioned gvt-g Wich allow to split intel hd into vgpu that you can passthrough bit it's bad for performance (i got the genshin logo and then 1-0fps

I don't know how, or if it works, but perhaps Looking Glass might work to resolve that? I'm aware that it makes setting up GPU passthrough easier, but I don't know exactly what it does lmao . (I usually just configure everything myself.)

Maybe not, again I don't know what it does. Maybe the limitations of your IOMMU groups really are unbreakable :/ .

looking glass use shared ram between the host and the vm to send the display, it has no link with fps the only solution would be to exctract my bios and then extract from it the gpu bios and use it to passthrough my gpu to the vm i don't know how to do that

ghost commented 3 years ago

by the way, to hide kvm, kvm=off on the qemu command line (it will drop the kvm cpuid bit 31, hypervisor)

Consider also faking the CPUID to your host machine.

edit: also, avoid virtio devices like the plague if you can, they are much faster but easily detected

edit: Also, TCG is our only option, because KVM is detectable (and so is hv)

nuuuu not KVM ;-; .

Why do they block VMs?

It's so dumb.

Anticheat. If they did not, I would be attaching a debugger to the VM process and hacking the game without it noticing.

It's so dumb.

I understand, it's quite annoying to not be able to play your favorite game on a GPU passthrough you setup yourself :)

ghost commented 3 years ago

https://stackoverflow.com/questions/4386449/send-touch-events-to-a-device-via-adb

Todo: make a shell script to run adb shell swipe x y x y 100 and reimplement Bluestacks-like keymapping.

ghost commented 3 years ago

QEMU ARM and install Android on it, and install Genshin Impact on it? Or Anbox?

Might worth the shot but we will probably lose mouse control for the game

I can transform it into a keyboard-only game with adb shell input swipe x y x y duration, so this is not too bad

Marc-Pierre-Barbier commented 3 years ago

the easyest option would be libhoudini 8_Z wich hasn't bee released nor anounced so ... :(

ghost commented 3 years ago

Hmm... We need a poll. Who prefers mouse control over keyboard? (yes = prefer mouse, no = prefer keyboard/wish it was keyboard)

the easyest option would be libhoudini 8_Z wich hasn't bee released nor anounced so ... :(

Well... yeah. not released nor announced, which means we will absolutely have to QEMU ARM+Android+Genshin (not ideal, we lose some performance)

ghost commented 3 years ago

(I prefer keyboard. Easier on my hands.)

Marc-Pierre-Barbier commented 3 years ago

dude it's more that not ideal i tried to get it running i get segfault from he officials android tools, so we need qemu BUT qemu has to be moded to support android and to do that you need to recompile everything and its a nightmare

ghost commented 3 years ago

i get segfault

?!?!?

ghost commented 3 years ago

we need to recompile everything

I use Gentoo, but you use some other Linux distro (arch?)... Should I just compile it and send you the binary?