Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gmh5225/go-detection-hyper-v
A simple Go program that detects whether the current Windows system is running inside a Hyper-V virtual machine environment(Guest) using CPUID instruction.
https://github.com/gmh5225/go-detection-hyper-v
detection golang hyper-v
Last synced: 18 days ago
JSON representation
A simple Go program that detects whether the current Windows system is running inside a Hyper-V virtual machine environment(Guest) using CPUID instruction.
- Host: GitHub
- URL: https://github.com/gmh5225/go-detection-hyper-v
- Owner: gmh5225
- License: agpl-3.0
- Created: 2024-10-26T23:56:30.000Z (21 days ago)
- Default Branch: main
- Last Pushed: 2024-10-27T07:44:35.000Z (20 days ago)
- Last Synced: 2024-10-28T03:45:29.246Z (19 days ago)
- Topics: detection, golang, hyper-v
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hyper-V Detection Tool
A simple Go program that detects whether the current Windows system is running inside a Hyper-V virtual machine environment(Guest) using CPUID instruction.
## Install
``
go install github.com/gmh5225/[email protected]
``## Uninstall
``
where/which Go-Detection-Hyper-v
``## Clean module cache
``
go clean -modcache
``## How It Works
The program uses the CPUID instruction to:
1. Check for the Hyper-V vendor string ("Microsoft Hv")
2. Verify specific feature flags that indicate a Hyper-V environment## Project Structure
- `main.go` - Main program logic and Hyper-V detection implementation
- `cpuid_amd64.s` - Assembly code for CPUID instruction## Technical Details
The detection is performed by:
1. Using CPUID with leaf `0x40000000` to check for Hyper-V vendor signature
2. Using CPUID with leaf `0x40000003` to verify specific feature flags## Output
The program will output one of two messages:
- "Running in Hyper-V environment(Guest)"
- "Not running in Hyper-V environment(Guest)"## Thanks
- https://x.com/sixtyvividtails/status/1850373100665282775
- https://x.com/sixtyvividtails/status/1850396353765019739