WPFで!! - Crystal Dew Blog

Download Report

Transcript WPFで!! - Crystal Dew Blog

CLR/H ひよひよ
VirtualChecker WPF
[1/14]
Virtual Windows XP とは?
Windows XP SP3 + 仮想PC環境
実機
仮想PC
同じアプリでも得られる
情報に違いが……
仮想PCにインストールした
アプリを直接起動可能!!
実機
VirtualChecker WPF
仮想PC
[2/14]
Virtual Windows XP が動かない!?
あっ、あれ?
VirtualChecker WPF
[3/14]
Virtual Windows XP の動作には…
AMD-V™ または Intel® VT
(BIOS で有効に設定) が搭載
された、ハードウェア仮想化
に対応したプロセッサーが必
要です。
VirtualChecker WPF
[4/14]
VirtualChecker の出番ですよ!!
VirtualChecker
仮想化支援機能の状態確認
OpenLibSys.org
http://openlibsys.org/index-ja.html
VirtualChecker WPF
[5/14]
『無効』⇒『有効』
BIOSセットアップ画面から
仮想化支援機能を有効にします。
※設定変更後は一度電源を切りましょう。
Panasonic CF-Y8 (Yシリーズ最終モデル)
VirtualChecker WPF
[6/14]
作ってみたいと思いませんか?
自分でも作ってみたい
と思いませんか?
WPFで!!
VirtualChecker WPF
[7/14]
必要な機能は3つだけ!!
1. Intel VT/AMD-V に対応しているか判定
2. Intel VT/AMD-V が有効か判定
3. 結果を表示
1. CPUID命令を使用して判定
でもどうやって?
2. RDMSR命令を使用して判定
でもどうやって?
3. WPFで表示
VirtualChecker WPF
[8/14]
汎用ハードウェアアクセスライブラリ
http://openlibsys.org/
修正 BSD ライセンス
VirtualChecker WPF
[9/14]
VirtualChecker WPF の構成
VirtualChecker WPF
[10/14]
1. Intel VT/AMD-V 対応?
Intel VT の場合
private bool IsIntelVtSupported()
{ // Feature Flag ECX の bit5 が 1 なら Intel VT 対応
uint eax = 0, ebx = 0, ecx = 0, edx = 0;
if (ols.CpuidPx(0x1, ref eax, ref ebx, ref ecx, ref edx, (UIntPtr)1) != 0
&& (ecx & (1 << 5)) != 0)
{
return true;
}
else
{
return false;
}
}
AMD-V の場合
省略
VirtualChecker WPF
[11/14]
2. Intel VT/AMD-V 有効?
Intel VT の場合
private bool IsIntelVtEnabled()
{ // Feature Control MSR EAX の bit1/bit2 が 1 なら Intel VT 有効
uint eax = 0, edx = 0;
if (ols.RdmsrPx(0x3A, ref eax, ref edx, (UIntPtr)1) != 0
&& ((eax & (1 << 1)) != 0 || (eax & (1 << 2)) != 0))
{
return true;
}
else
{
return false;
}
}
AMD-V の場合
省略
VirtualChecker WPF
[12/14]
3. 結果の表示
if (IsIntelVtSupported())
{
if (IsIntelVtEnabled())
{
str = "Intel VT 有効";
}
else
{
str = "Intel VT 無効";
}
}
完成!?
VirtualChecker WPF
else if (IsAmdvSupported())
{
if (IsAmdvEnabled())
{
str = "AMD-V 有効";
}
else
{
str = "AMD-V 無効";
}
}
else
{
str = "Intel VT/AMD-V 未対応";
}
label1.Content = str;
[13/14]
まとめ
XAML
<Window x:Class="VirtualCheckerWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="VirtualChecker WPF" Height="110" Width="600" ResizeMode="NoResize">
<Grid FlowDirection="LeftToRight">
<Label Name="label1" FontSize="48" Height="70" Width="578" HorizontalContentAlignment="Center" />
</Grid>
</Window>
XP Mode が使えるかどうかわからない!!
というお悩みもこれで解決です。
VirtualChecker WPF
[14/14]