Announcement

Collapse
No announcement yet.

Detect MS Virtual PC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Detect MS Virtual PC

    Hi,
    I am running PB3.5 under MS-DOS 6.22 under Virtual PC 2004 SP1.

    I would like to have my PB programs determine if they are running under VPC.

    VPC has a static hardware setup.

    The BIOS is an AMI BIOS.

    The Chipset is an Intel 440BX.

    The sound card is a Creative Labs Sound Blaster 16 ISA Plug and Play.

    The network adapter is a DEC 21140A 10/100.

    The video card is a S3 Trio 32/64 PCI with 8 MB Video RAM.

    The motherboard manufacturer is Microsoft Corporation.

    Is there a way to determine these items from PowerBASIC? I think the easiest method would be to determine if the motherboard manufacturer is Microsoft Corporation, but I'm not sure how to go about this.

    Many thanks,

    Joe

  • #2
    I don't know ASM so I don't know if this is of any help, but it might get you a start: http://www.codeproject.com/KB/system...=2518831&fr=26

    Comment


    • #3
      I don't use any such products so this is a pure guess....

      Perhaps when running on a 'virtual' system there is an environment variable you can check for either existence or value?
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Let me be the one to ask: Why would it make any difference to your program?

        Isn't the whole idea of the "virtual machine" to let you do precisely nothing different than were you running on a "real machine?"

        Enquiring Minds Want to Know.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Originally posted by Joe Caverly View Post
          Is there a way to determine these items from PowerBASIC? I think the easiest method would be to determine if the motherboard manufacturer is Microsoft Corporation, but I'm not sure how to go about this.
          You can get that kind of info via WMI. You can check for samples of querying it from PowerBASIC both here and on Jose's forum.
          Virtual PC Guy's Weblog have a sample VBScript that can be used as a guide (but you probably have already seen that article).

          Bye!
          -- The universe tends toward maximum irony. Don't push it.

          File Extension Seeker - Metasearch engine for file extensions / file types
          Online TrID file identifier | TrIDLib - Identify thousands of file formats

          Comment


          • #6
            Thanks, yes I am aware of these. However, these won't work from pure DOS, but only from Windows.

            Regards,

            Joe

            Comment


            • #7
              Whops! Sorry I overlooked the DOS requirements!
              -- The universe tends toward maximum irony. Don't push it.

              File Extension Seeker - Metasearch engine for file extensions / file types
              Online TrID file identifier | TrIDLib - Identify thousands of file formats

              Comment


              • #8
                When I run a PB 3.5 & PV/Vision application in a window in Windows XP, and I have APP.GRAPHICSMODE = 1 and APP.GRAPHICSMOUSE = 1, I get some garbage characters on the screen, specifically, the mouse pointer, and I cannot use the mouse correctly. I get a mouse cursor, which moves with the mouse, but does not work when clicking on an object.

                If I run the application full screen in XP, it works fine.

                If I have APP.GRAPHICSMODE = 0 and APP.GRAPHICSMOUSE = 0, it works fine in XP whether full screen or not.

                When running from MS-DOS 6.22 in Microsoft Virtual PC, it works regardless, as VPC isolates MS-DOS 6.22 from even seeing Windows. As far as it is concerned, Windows does not exist.

                I realize that the problem is due to the font remapping, which is a problem for an XP window.

                Thus, I want to programitcally determine where the program is running from, so as to determine whether I can run in graphics mode or not. The only other option is to enlist a switch for the executable, and let the user decide.

                Thanks,

                Joe

                Comment


                • #9
                  Originally posted by Michael Mattias View Post
                  Let me be the one to ask: Why would it make any difference to your program?

                  Isn't the whole idea of the "virtual machine" to let you do precisely nothing different than were you running on a "real machine?"

                  Enquiring Minds Want to Know.
                  Well, actually there are differences. A TS session could be terminated by the user, for example (as opposed to user logs off a TS). You might want to react on this.

                  Other plausible reasons include licensing, user validation (against some kind of directory, be that LDAP or AD or whatever), which is different when an application runs within a TS session, AFAIK.

                  OT: my FF spell checker highlights the word "Enquiring" and suggests "Inquiring" instead. Is that a AE/BE thingy or is that just a type by you, Michael?

                  Comment


                  • #10
                    OT: my FF spell checker highlights the word "Enquiring" and suggests "Inquiring" instead. Is that a AE/BE thingy or is that just a type by you, Michael?
                    It's a BE/AE thingy.
                    Since Michael doesn't live all that far from the border, some of his language characteristics may have been subverted by infiltrators from Canada, where some of us use either spelling.
                    Seriously though, I always thought, without checking the dictionaries on it, that the Canadian use of Enquire as opposed to Inquire was a result of the French influence here in Canada. But apparently it is a British thing.(or thingy)
                    Last edited by Rodney Hicks; 31 Jul 2008, 05:54 AM. Reason: phrase adjustment
                    Rod
                    In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                    Comment


                    • #11
                      To enquire is to ask a question.
                      To inquire is to investigate.

                      I could enquire about John's cat: "How's John's cat doing?"

                      I could inquire into John's cat: John hasn't seen the cat for a week. The neighbour saw the cat on the roof on Tuesday. The police found the cat's collar in the back lane. What do you know about the cat's disappearence? Were you in the area that week? How do you explain your fingerprint on the collar? Did you see anyone else with the cat .. etc. .

                      British Paul

                      Comment


                      • #12
                        Enquire, Inquire.... so colour me contrarian.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Joe,
                          See this thread - http://www.powerbasic.com/support/pb...ad.php?t=24024
                          I demonstrate two examples... one which detects VMWare explicitly, and one which detects (in theory) any virtual machine - VMWare and VirtualPC are definitely detected. It's more of a "generic" detection if you will.

                          Yes you can easily detect if you're running under MS VirtualPC - it's pretty much the same as checking if you're running under VMWare (both have a "backdoor port"), but unfortunately nobody has written any VirtualPC-specific code for PB yet.
                          -

                          Comment


                          • #14
                            Hi Joe

                            Here is a method that is fairly simple, but requires that the Virtual Machine additions have been installed (I think).

                            Check for the existence of the environment variable DOSVMADD13.

                            To see what I am talking about, at the DOS prompt in the Virtual Machine, type SET then enter and a list of all of the environment variables will follow.

                            Alternatively, find the VESA graphics call that returns the name of the video card, MSVPC's emulate a Trident S3 card as yo know
                            .
                            This test won't be conclusive however because there are still machines out there that use S3 cards, but since all MSVPC's use it, most of the time it will be right.

                            If you need code for this, let me know and I'll rustle it up for you.

                            Best Regards
                            Gary Barnes
                            The Control Key

                            If you are not part of the solution
                            then you are either a gas, solid, plasma or some other form of matter.

                            Comment


                            • #15
                              Hi Gary,
                              I had thought about that, but maybe some people do not have the VM Additions installed, as I do. Does DOSVMADD13 exist even if the VM Additions are not installed?

                              To detect this, I just do a PRINT ENVIRON$("DOSVMADD13"), which returns INSTALLED. I looked in the VPC Help file, but could find no reference if it did or did not have this environment variable if installed or not under MS-DOS.

                              If it did, that would solve my problem.

                              Thanks,

                              Joe

                              Comment


                              • #16
                                Hi Wayne,
                                Thanks for the link, but the code is for windows, not for DOS. As I only have PB 3.5 for DOS, it won't compile.

                                When I run the following in PB 3.5 DOS;

                                result% = 0
                                try_again:
                                ! db &h0F,&h31 ; rdtsc
                                ! mov ebx, eax
                                ! db &h0F,&h31 ; rdtsc
                                ! sub eax, ebx
                                ! push eax
                                ! cmp eax, 1
                                ! jz try_again
                                ! pop eax
                                ! cmp eax, &h0200
                                ! jb no_vm
                                ! mov eax, 1
                                ! jmp finish
                                no_vm:
                                ! mov eax, 0
                                finish:
                                ! mov result%, eax

                                I get an Error 497: Assembler syntax error. I realize that db has to be used, as PB3.5 only supports the 8086 processor, but how do I get it to work with this code?

                                Thanks,

                                Joe
                                Last edited by Joe Caverly; 2 Aug 2008, 04:06 AM.

                                Comment


                                • #17
                                  A TS session could be terminated by the user, for example (as opposed to user logs off a TS). You might want to react on this
                                  OK, I'll buy that.

                                  But can you detect this in a PB/DOS-compiled program?

                                  MCM
                                  Michael Mattias
                                  Tal Systems (retired)
                                  Port Washington WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    I have found a DOS utility called SMBIOSD, which gives me the following;

                                    ÍÍ> Type 1: System Information
                                    Struc length is 25 bytes.
                                    Struc handle is 0001h.
                                    Manufacturer: Microsoft Corporation
                                    Product Name: Virtual Machine
                                    Version: 5.0
                                    Serial Number: <Omitted in this message>
                                    Universal Unique ID #: 00020003000400050006000700080009
                                    Wake-Up Type: Power Switch

                                    Redirecting the output of SMBIOSD to a file, I can then read this info from the file, to determine if my program is running in MS Virtual PC.

                                    This is not the 100% PowerBASIC 3.5 solution I had been looking for, but I guess that even PB35 has its limits.

                                    The SMBIOSD utility can be found at http://www.sudleyplace.com/download.htm

                                    Joe

                                    Comment


                                    • #19
                                      Sorry Joe, my mistake. The code is for 32-bit compilers (PBCC/PBWIN), not 16-bit PBDOS. It may be possible to convert the code to 16-bit using just AX instead of EAX (for example) registers, but I doubt it as the RDTSC instruction is at the heart of this particular trick.

                                      Perhaps your 16-bit DOS executable could drop-and-execute a 32-bit executable to do the work on its behalf?
                                      -

                                      Comment


                                      • #20
                                        Perhaps your 16-bit DOS executable could drop-and-execute a 32-bit executable to do the work on its behalf
                                        I know a 16-bit PB/DOS program can SHELL a 32-bit PB/Win-or-CC program.
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X