[Answered]How to detect Virtual Box (OS Level)
[Answered]How to detect Virtual Box (OS Level)
Okay, so today I was working on BGA a bit.
Once I completed my BGA driver I noticed something interesting. VirtualBox and Bochs use 0xE0000000 LFB address and Qemu uses 0xFD000008 LFB address. Now, I found out how to detect Bochs, if Bochs isn't detected then I set LFB to Qemu's LFB. Now how do I detect Virtual Box?
Once I completed my BGA driver I noticed something interesting. VirtualBox and Bochs use 0xE0000000 LFB address and Qemu uses 0xFD000008 LFB address. Now, I found out how to detect Bochs, if Bochs isn't detected then I set LFB to Qemu's LFB. Now how do I detect Virtual Box?
Last edited by Octacone on Sat Aug 13, 2016 2:12 pm, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: How to detect Virtual Box (OS Level)
Check the ACPI tables or the AHCI device names.octacone wrote:Okay, so today I was working on BGA a bit.
Once I completed my BGA driver I noticed something interesting. VirtualBox and Bochs use 0xE0000000 LFB address and Qemu uses 0xFD000008 LFB address. Now, I found out how to detect Bochs, if Bochs isn't detected then I set LFB to Qemu's LFB. Now how do I detect Virtual Box?
Im pretty sure there is an easier way, but thats the two I noticed during developing my os
Anyways, why do you hardcode this?
Re: How to detect Virtual Box (OS Level)
That is not going to work atm (I don't have ACPI or ACHI).Ch4ozz wrote:Check the ACPI tables or the AHCI device names.octacone wrote:Okay, so today I was working on BGA a bit.
Once I completed my BGA driver I noticed something interesting. VirtualBox and Bochs use 0xE0000000 LFB address and Qemu uses 0xFD000008 LFB address. Now, I found out how to detect Bochs, if Bochs isn't detected then I set LFB to Qemu's LFB. Now how do I detect Virtual Box?
Im pretty sure there is an easier way, but thats the two I noticed during developing my os
?? Detection or LFB?Ch4ozz wrote:Anyways, why do you hardcode this?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: How to detect Virtual Box (OS Level)
VirtualBox has a "VirtualBox Guest Service" device on the PCI bus, with Vendor ID 0x80EE and Device ID 0xCAFE.
If this exists, you can assume you're running under VirtualBox. Not sure what difference it makes, though.
If this exists, you can assume you're running under VirtualBox. Not sure what difference it makes, though.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Re: How to detect Virtual Box (OS Level)
Very interesting. Can I use ports to detect this or I need to write PCI scanner? Thanks for the hint!SpyderTL wrote:VirtualBox has a "VirtualBox Guest Service" device on the PCI bus, with Vendor ID 0x80EE and Device ID 0xCAFE.
If this exists, you can assume you're running under VirtualBox. Not sure what difference it makes, though.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- sleephacker
- Member
- Posts: 97
- Joined: Thu Aug 06, 2015 6:41 am
- Location: Netherlands
Re: How to detect Virtual Box (OS Level)
You don't need to detect if you're running on bochs/QEMU/virtualbox, I've never used BGA but according to the wiki you can obtain the LFB address through PCI, which is probably more reliable than using hardcoded values.
EDIT: you would need to write a PCI scanner for both options.
EDIT: you would need to write a PCI scanner for both options.
Re: How to detect Virtual Box (OS Level)
Yeah, I should probably detect LFB rather than defining it. Thanks!!! Going to do it that way.sleephacker wrote:You don't need to detect if you're running on bochs/QEMU/virtualbox, I've never used BGA but according to the wiki you can obtain the LFB address through PCI, which is probably more reliable than using hardcoded values.
EDIT: you would need to write a PCI scanner for both options.
Also: why does paging mess up my LBF, when I enable paging I can't plot pixels.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: How to detect Virtual Box (OS Level)
You could see if the whole hardware device environment is the same that VirtualBox has (the same device IDs....).
You could search for VirtualBox BIOS signatures, strings that mention it, BIOS splash bitmaps that correspond to VirtualBox.
You could see if there are VirtualBox-style folder shares.
You could inspect for anything that has to do with VirtualBox in memory.
You could search for VirtualBox BIOS signatures, strings that mention it, BIOS splash bitmaps that correspond to VirtualBox.
You could see if there are VirtualBox-style folder shares.
You could inspect for anything that has to do with VirtualBox in memory.
Last edited by ~ on Fri Aug 12, 2016 10:31 am, edited 1 time in total.
YouTube:
http://youtube.com/@AltComp126
My x86 OS/software:
https://sourceforge.net/projects/api-simple-completa/
Donate to get more food/programming resources/computers:
https://www.paypal.com/donate/?hosted_b ... QS2YTW3V64
http://youtube.com/@AltComp126
My x86 OS/software:
https://sourceforge.net/projects/api-simple-completa/
Donate to get more food/programming resources/computers:
https://www.paypal.com/donate/?hosted_b ... QS2YTW3V64
Re: How to detect Virtual Box (OS Level)
Wow, didn't know that there were so many ways. I think that the best way of detecting Virtual Box is by searching for device IDs. +1~ wrote:You could see if the whole hardware device environment is the same that VirtualBox has (the same device IDs....).
You could search for VirtualBox BIOS signatures, strings that mention it, BIOS splash bitmaps that correspond to VirtualBox.
You could see if there are VirtualBox-style folder shares.
You should inspect for anything that has to do with VirtualBox in memory.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: How to detect Virtual Box (OS Level)
How to do this? I want to check Vendor ID/Device ID. So I need a function that sees if a device exists? So what buses/slots I should be looking at? I don't want to write an entire PCI system just to check if a device exists. There must be a way to check if a device with give ID exists. Right?SpyderTL wrote:VirtualBox has a "VirtualBox Guest Service" device on the PCI bus, with Vendor ID 0x80EE and Device ID 0xCAFE.
If this exists, you can assume you're running under VirtualBox. Not sure what difference it makes, though.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- Kazinsal
- Member
- Posts: 559
- Joined: Wed Jul 13, 2011 7:38 pm
- Libera.chat IRC: Kazinsal
- Location: Vancouver
- Contact:
Re: How to detect Virtual Box (OS Level)
You have to write a whole PCI bus enumerator in order to reliably find devices.
Considering you'd have to do that anyways in order to write drivers for just about anything, you might as well do it now.
Considering you'd have to do that anyways in order to write drivers for just about anything, you might as well do it now.
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: How to detect Virtual Box (OS Level)
Detecting VirtualBox just to use BGA isn't worth it.
There is no real proof that a new VirtualBox version won't have the framebuffer at 0xE0000000. Instead, you should read the framebuffer from BAR0 of the PCI BGA device (device 0x1234:0x1111), and if it doesn't exist, only then should you use 0xE0000000. QEMU has a PCI BGA, and, as you have pointed out, uses the framebuffer at 0xFD000000.
EDIT: A PCI enumerator is very simple, actually. Once you have a routine to read and write registers to the PCI configuration space, most of it is done with common sense.
There is no real proof that a new VirtualBox version won't have the framebuffer at 0xE0000000. Instead, you should read the framebuffer from BAR0 of the PCI BGA device (device 0x1234:0x1111), and if it doesn't exist, only then should you use 0xE0000000. QEMU has a PCI BGA, and, as you have pointed out, uses the framebuffer at 0xFD000000.
EDIT: A PCI enumerator is very simple, actually. Once you have a routine to read and write registers to the PCI configuration space, most of it is done with common sense.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: How to detect Virtual Box (OS Level)
I have a function that detects both Bochs and VirtualBox and if they don't get detected system makes an assumption that the emulator equals to Qemu. Atm I can read from 32Bit PCI, is that useful? It has (bus, device, function, offset).omarrx024 wrote:Detecting VirtualBox just to use BGA isn't worth it.
There is no real proof that a new VirtualBox version won't have the framebuffer at 0xE0000000. Instead, you should read the framebuffer from BAR0 of the PCI BGA device (device 0x1234:0x1111), and if it doesn't exist, only then should you use 0xE0000000. QEMU has a PCI BGA, and, as you have pointed out, uses the framebuffer at 0xFD000000.
EDIT: A PCI enumerator is very simple, actually. Once you have a routine to read and write registers to the PCI configuration space, most of it is done with common sense.
I just need if(CheckVendor("0xCAFE") == true)
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: How to detect Virtual Box (OS Level)
What do I need to input in:
uint32_t Read32BitPCI(uint8_t bus, uint8_t device, uint8_t function, uint32_t offset)
Can I see if my vendor id device exists using that?
Another IDEA
I can skip Virtual Box detection if I find a way to detect Qemu <------
uint32_t Read32BitPCI(uint8_t bus, uint8_t device, uint8_t function, uint32_t offset)
Can I see if my vendor id device exists using that?
Another IDEA
I can skip Virtual Box detection if I find a way to detect Qemu <------
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: How to detect Virtual Box (OS Level)
This turned into my worst nightmare.
Is there a simple way to detect Qemu? I bet that somebody know the answer.
Is there a simple way to detect Qemu? I bet that somebody know the answer.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader