Monday, August 17, 2015

mmap equivalent in Windows or How To Map Physical Memory to Userspace.

Windows unfortunately has no equivalent of mmap that can access physical memory e.g by mapping /dev/mem to some userspace address, however this can be achieved by a simple(not really) kernel-mode driver that I've personally used in Windows 7 x64, though there should be no reason why it wouldn't work in Windows 8/8.1/10

I found it in this article on CodeProject.

Now, even if you compile the driver, on x64 Windows systems the driver needs to be signed, this for development purposes can be disabled, follow the article on MSDN on how to do that.

But beware, fiddling with physical memory can lead to some very dangerous results if you aren't careful, e.g permanent hardware failure or data loss.

Tuesday, August 4, 2015

The scary Virtual Machine

Sorry for the cheesy thread title, but I had no idea what to put there.

But anyway, I recently came across more virtual machines, and honestly, when you get to the jist of it, they aren't all that difficult to understand nor implement.

For instance, this guy here wrote his own C compiler for the C89 standard, and made it work for his own custom virtual CPU, for which he wrote several "emulators"(emulator;virtual machine it's all the same in this context) in C, Java and finally, Javascript. This actually gave me an idea to implement some VMs in Javascript as well, I mean you can run the thing in your browser.

Now, Virtual Machines like VirtualBox, VMWare and QEMU are different, they try to emulate a whole computer with the peripherals and also takes advantage of a CPU's special virtualization options for HW virtualization, they are indeed harder to write and understand and I myself couldn't even begin to comprehend VirtualBox's code.

But we aren't interested in those(or at least I am not) right now, we just want to emulate a CPU, or even create our own, the sky is the limit.