ufrisk / MemProcFS

MemProcFS
GNU Affero General Public License v3.0
3k stars 371 forks source link

Vmm qemu error #228

Closed FruitBoi closed 11 months ago

FruitBoi commented 12 months ago

Hi!

I am trying to use the qemu device with MemProcFS's vmm library in C Sharp. I have verified that the memprocfs binary can successfully read my VM.

I have extracted the files from the github linux releases into the working directory of my .NET project.

initializing vmm: vmm = new Vmm("", "-v", "-printf", "-device", "qemu://shm=qemu-win10.mem,qmp=/tmp/qmp-win7.sock");

and this is the output

DEVICE OPEN: file DEVICE: ERROR: Failed opening file: 'qemu://shm=qemu-win10.mem,qmp=/tmp/qmp-win7.sock'. MemProcFS: Failed to connect to memory acquisition device. Unhandled exception. System.Exception: VMM INIT FAILED.

leechcore_device_qemu.so is present in the directory

Additionally, I have ensured my .NET project is compiling as x64.

I'm not sure what's going on here.

ufrisk commented 11 months ago

it's not picking up on the qemu driver. It tries to open the whole thing as a file.

questions:

I do a trick with dladdr to locate the full path to the so file and then dynamically load it, it may be that it's broken when running it inside C# on Linux. If that's the case I'd have to look into this. But let's check the above first.

FruitBoi commented 11 months ago

Thanks for the quick response.

I was able to hack it into working by copying the QEMU driver c file into the main leechcore project, adding it to the built in drivers and compiling that into leechcore.so, but that's not a very clean fix.

I am on linux, specifically Ubuntu 23.04 with a patched 6.2.0 kernel.

leechcore_device_qemu.so is directly alongside leechcore.so

All of the files including both leechcore.so and leechcore_device_qemu.so all are executable

One thing to note though; I did have to modify vmm.cs to point to the vmm.so and leechcore.so instead of .dll in my CSharp project.

ufrisk commented 11 months ago

I'm guessing here, but I'd probably have to change the way I lookup the current directly with dladdr. I'll put it up as a bug here. It may be a week or two before I have time to look into it unfortunately :\

I should look into vmmsharp as well.

ufrisk commented 11 months ago

Can you please check if this issue have now been resolved if you download the most recent binary package from the releases section.

It seems like there was a build-issue with the Makefile making it not load when loaded through dotnet, but it worked when loading it normally for some reasons. No clue why, but nevertheless it should now hopefully be resolved.

Also I've "fixed" vmmsharp by removing the .dll extension so it should now work on both so/dll files.

ufrisk commented 11 months ago

Since I haven't heard anything back I'm assuming the issue is resolved and that it should now work fine. Thank you for reporting this issue and best wishes with your project.