Einzelnen Beitrag anzeigen

NicoDE
(Gast)

n/a Beiträge
 
#1

Testen, ob das Programm in einer VMware VM ausgeführt wird

  Alt 22. Jul 2003, 18:24
Einfacher VMware-Test für i386 (Intel IA32, 80386-kompatibel oder besser)

Hinweis: Es gibt zahlreiche Wege, um eine VMware VM (Virtuelle Maschine) zu entdecken. IsVMwarePresent() basiert auf der Tatsache, dass VMware IN-Anweisungen (an den Port 0x5658 mit dem Wert 0x564D5868 im EAX-Register) abfängt. Dies ist *NICHT* offiziell dokumentiert (von den VMware Tools verwendet, um mittels VM mit dem Host zu kommunizieren).

Da sich dies in zukünftigen Versionen ändern kann, sollte man zusätzliche Tests implementieren (z.B. Hardware-Geräte-IDs, BIOS-Informationen, u.s.w.). Die letzte VMware-Version bietet SMBIOS Informationen an (Du kannst z.B. meine BiosHelp-Unit verwenden, um das ROM-BIOS auszulesen (siehe http://www.bendlins.de/nico/delphi/ ).

Delphi-Quellcode:
////////////////////////////////////////////////////////////////////////////////
//
// Simple VMware check on i386
//
// Note: There are plenty ways to detect VMware. IsVMwarePresent() relies
// on the fact that VMware intercepts IN instructions to port 0x5658 with
// an magic value of 0x564D5868 in EAX. However, this is *NOT* officially
// documented (used by VMware Tools to communicate with the host via VM).
//
// Because this might change in future versions - you should look out for
// additional checks (e.g. hardware device IDs, BIOS informations, etc.).
// Latest VMware version has SMBIOS informations (you may use my BiosHelp
// unit to dump the ROM-BIOS - see [url]http://www.bendlins.de/nico/delphi/[/url] ).
//

function IsVMwarePresent: Boolean; { platform; }
begin
  Result := False;
{$IFDEF CPU386}
  try
    asm
      mov eax, 564D5868h { Magic value 'VMXh' }
      mov dx, 5658h { Port number ('VX') }
      mov ecx, 0000000Ah { Command identifier }
      xor ebx, ebx { Anything but magic }
      in eax, dx { Exception possible }
      cmp ebx, 564D5868h { Set by VMware's VM }
      jne @@exit
      mov Result, True
      @@exit:
    end;
  except
    Result := False;
  end;
{$ENDIF}
end;
[edit=Matze]Code formatiert. Mfg, Matze[/edit]
  Mit Zitat antworten Zitat