projects
/
grml-scripts.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4c24f02
)
made vmware-detect.c compile on all archs, implemented check for amd64
author
Michael Gebetsroither
<michael.geb@gmx.at>
Sun, 24 Dec 2006 11:37:36 +0000
(12:37 +0100)
committer
Michael Gebetsroither
<michael.geb@gmx.at>
Sun, 24 Dec 2006 11:37:36 +0000
(12:37 +0100)
compile/vmware-detect.c
patch
|
blob
|
history
diff --git
a/compile/vmware-detect.c
b/compile/vmware-detect.c
index
d242a38
..
f3875a7
100644
(file)
--- a/
compile/vmware-detect.c
+++ b/
compile/vmware-detect.c
@@
-1,13
+1,24
@@
-#include <stdio.h>
+#if defined (__i386__)
+int checkVmware()
+{
+ unsigned char idtr[6];
+ asm("sidt %0" : "=m" (idtr));
+ return (0xff==idtr[5]) ? 0 : 1;
+}
+#elif defined (__x86_64__)
+// only guessed, possible need to check against 0xffff?
+int checkVmware()
+{
+ unsigned char idtr[10];
+ asm("sidt %0" : "=m" (idtr));
+ return (0xff==idtr[9]) ? 0 : 1;
+}
+#else
+// vmware runs only on the archs above
+int checkVmware() { return 1; }
+#endif
+
int main() {
int main() {
- unsigned char idtr[6];
- asm("sidt %0" : "=m" (idtr));
- if(0xff==idtr[5])
- {
- return 0;
- }
- else
- {
- return 1;
- }
+ // returns 0 if running inside vmware, 1 otherwise
+ return checkVmware();
}
}