イベントビューアー > アプリケーションとサービスログ > Microsoft > Windows > Hyper-V-****
2016年11月22日火曜日
Hyper-V error 32788
Hyper-V の 仮想マシン起動時のエラー 32788 に苦しめられたけど、イベントログ見れば一瞬で解決できたのでメモ
イベントビューアー > アプリケーションとサービスログ > Microsoft > Windows > Hyper-V-****
今回は、「RemoteFX Manager プロセスを開始できませんでした」とあったから、「RemoteFx 3D ビデオ アダプター」を仮想マシンの設定から削除した。
イベントビューアー > アプリケーションとサービスログ > Microsoft > Windows > Hyper-V-****
2016年8月20日土曜日
Windows 版 iTunes のアップデートが失敗する事について調べた
1. まず 「windows itunes サーバーが見つからない」 で検索
2. https://discussionsjapan.apple.com/thread/10171836?start=0&tstart=0 がヒット
3. インターネットオプション「暗号化されたページをディスクに保存しない」 をオフにすると解決する事を知る
4. PowerShellスクリプトか何かをダブルクリックするだけで設定を切り替えたいから、インターネットオプションの「適用」ボタンを押した時に何が起こっているのかを調べる
5. Sysinternals Process Monitor を起動し、プロセス名でフィルタしてみる
6. 「Path」からそれっぽいのを探すと、「DisableCachingOfSSLPages」が見つかる
7. その行を選択してフィルタに追加する
8. チェックボックスを切り替えて「適用ボタン」を押す、という操作を繰り返す
9. 「DisableCachingOfSSLPages」で合ってた
10. 後はこれの値を更新するスクリプトを書くだけ
2016年2月14日日曜日
Windows Phone IP over USB Transport (IpOverUsbSvc) について
サービス「Windows Phone IP over USB Transport (IpOverUsbSvc)」が無いのに気づいた時点での開発環境
・Windows 7 -> Windows 10 へのアップグレード
・VS2010, VS2013, VS2015 インストール済み
・Windows Phone に関するもの(SDK等)はインストールした記憶無し
調べた結果
・Windows Phone SDK 8.0 をインストールする必要があった
疑問
・Windows 10 Mobile なのになんで Windows Phone SDK 8.0 をわざわざ入れないといけないのか
メモ
・Windows Phone SDK 8.0 のせいで無駄にSSDを4GBも使われた
・Windows Phone SDK 8.0 インストール完了時点で VS2012 が無いから幾つかエラーが表示されていた
・Windows 7 -> Windows 10 へのアップグレード
・VS2010, VS2013, VS2015 インストール済み
・Windows Phone に関するもの(SDK等)はインストールした記憶無し
調べた結果
・Windows Phone SDK 8.0 をインストールする必要があった
疑問
・Windows 10 Mobile なのになんで Windows Phone SDK 8.0 をわざわざ入れないといけないのか
メモ
・Windows Phone SDK 8.0 のせいで無駄にSSDを4GBも使われた
・Windows Phone SDK 8.0 インストール完了時点で VS2012 が無いから幾つかエラーが表示されていた
2015年9月2日水曜日
SQLで画像処理(2値化)
以前やったSQLでの画像処理(2値化)です。
master.dbo.fn_varbintohexsubstring が遅すぎるから、そこだけ c# で対応しました。
処理前
処理後(SSMS -> Excel)
master.dbo.fn_varbintohexsubstring が遅すぎるから、そこだけ c# で対応しました。
処理前
処理後(SSMS -> Excel)
use sample
go
------------------------------------
-- 入力画像データ格納テーブル
------------------------------------
/*
create table image_data(
id int not null identity(1,1) constraint PK_image_data primary key,
name varchar(100),
data varbinary(max)
)
go
*/
-- C:\Windows\Web\Wallpaper\Theme1\smile1.jpg -> D:\dev\data\smile1.bmp
------------------------------------
-- 画像登録
------------------------------------
/*
insert into image_data(name, data)
select
'smile1_24_192_120',
(select * from openrowset(bulk N'D:\dev\data\smile1.bmp', SINGLE_BLOB) as bin)
go
*/
------------------------------------
-- 出力画像データ格納テーブル
------------------------------------
/*
create table result_image(
pos int not null,
row_index int not null,
col_index int not null,
pix int not null,
constraint PK_result_image_rowcol primary key(row_index, col_index)
)
*/
------------------------------------
-- 前処理
------------------------------------
truncate table result_image
go
------------------------------------
-- ビットマップ情報取得
------------------------------------
with
------------------------------------
-- 固定パラメータ
------------------------------------
Param as (
select name, convert(varchar(max), data, 2) as data, data as rawdata from image_data where name = 'smile1_24_192_120'
),
------------------------------------
-- ビットマップファイルヘッダ
------------------------------------
BITMAPFILEHEADER as (
select
convert(char(2), dbo.Collection_Range(p.rawdata, 0, 2)) as bfType,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 2, 4))) as bfSize,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 6, 2))) as bfReserved1,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 8, 2))) as bfReserved2,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 10, 4))) as bfOffBits
from
Param as p
),
------------------------------------
-- ビットマップ情報ヘッダ
------------------------------------
BITMAPINFOHEADER as (
select
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 14, 4))) as biSize,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 18, 4))) as biWidth,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 22, 4))) as biHeight,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 26, 2))) as biPlanes,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 28, 2))) as biBitCount,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 30, 4))) as biCopmression,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 34, 4))) as biSizeImage,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 38, 4))) as biXPixPerMeter,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 42, 4))) as biYPixPerMeter,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 46, 4))) as biClrUsed,
convert(int, dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, 50, 4))) as biCirImportant
from
Param as p
),
------------------------------------
-- ビットマップ情報全体
------------------------------------
BitmapInfo as (
select
bf.*,
bi.*,
(bi.biBitCount/8 * bi.biWidth * bi.biHeight) as PixelCount
from
BITMAPFILEHEADER bf,
BITMAPINFOHEADER bi
),
------------------------------------
-- ピクセル数分のシーケンス生成
------------------------------------
Seq(rowIndex, maxRowCount) as (
select 0, (select PixelCount from BitmapInfo)
union all
select
rowIndex+1, maxRowCount
from
Seq
where
rowIndex < maxRowCount
),
------------------------------------
-- 各ピクセルのRGBを取得
------------------------------------
RawPixels as (
select
s.rowIndex as pos,
round(s.rowIndex / i.biWidth, 0) as row_index,
s.rowIndex % i.biWidth as col_index,
1 as alpha,
dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, i.bfOffBits + (s.rowIndex * 3) + 0, 1)) as red,
dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, i.bfOffBits + (s.rowIndex * 3) + 1, 1)) as green,
dbo.Collection_Reverse(dbo.Collection_Range(p.rawdata, i.bfOffBits + (s.rowIndex * 3) + 2, 1)) as blue,
i.*
from
Param as p,
Seq as s,
BitmapInfo i
where
s.rowIndex < s.maxRowCount / 3
),
------------------------------------
-- 固定パラメータ
------------------------------------
BinarizationParam as (
select 160 as threshold
),
------------------------------------
-- 2値化
------------------------------------
Binarization as (
select
p.pos,
p.row_index,
p.col_index,
(case
when p.red < BinarizationParam.threshold then 0
when p.green < BinarizationParam.threshold then 0
when p.blue < BinarizationParam.threshold then 0
else 1
end) as pix
from
RawPixels as p,
BinarizationParam
)
insert into
result_image
select
*
from
Binarization
option (maxrecursion 0)
------------------------------------
-- 列名一覧作成
------------------------------------
declare @col_list varchar(max) = ''
select
@col_list =
@col_list +
(case when len(@col_list) > 0 then ',' + char(13) else '' end) +
'(case ' +
'when max(case when col_index = ' + cast(col_index as varchar(max)) + ' then pix else 0 end) = 1 then ' +
''''' ' +
'else ' +
'''■'' ' +
'end) as c' + cast(col_index as varchar(max))
from
result_image
group by
col_index
order by
col_index
------------------------------------
-- 出力
------------------------------------
declare @sql varchar(max) =
'select ' + char(13) +
'row_index as r,' + char(13) +
@col_list + char(13) +
'from ' + char(13) +
'result_image ' + char(13) +
'group by row_index ' + char(13) +
'order by row_index desc'
--print @sql
execute sp_sqlexec @sql
go
2014年8月24日日曜日
グレースケールその2
ループもアセンブラで書いた
2014/08/24 18:31 追記
ちょっと短くなった
void apply_grayscale(uint8_t* dstImg, uint8_t* srcImg, int pixelCount)
{
uint16_t tmp1;
int counter;
__asm
{
mov ebx, srcImg
mov ecx, pixelCount
mov counter, 0
loop0:
mov tmp1, 0
mov ah, 77 // 0.298912 * 256
mov al, [ebx+0]
mul ah
mov tmp1, ax
mov ah, 150 // 0.586611 * 256
mov al, [ebx+1]
mul ah
add tmp1, ax
mov ah, 29 // 0.114478 * 256
mov al, [ebx+2]
mul ah
add tmp1, ax
shr tmp1, 8
mov ax, tmp1
push ebx
mov ebx, dstImg
add ebx, counter
mov [ebx+0], al
mov [ebx+1], al
mov [ebx+2], al
pop ebx
add counter, 3
add ebx, 3
sub ecx, 3
jnz loop0
}
}
もうちょい短くなるのかな?2014/08/24 18:31 追記
ちょっと短くなった
void apply_grayscale(uint8_t* dstImg, uint8_t* srcImg, int pixelCount)
{
int counter;
__asm
{
mov ebx, srcImg
mov ecx, pixelCount
mov counter, 0
loop0:
mov dx, 0
mov ax, 77 // 0.298912 * 256
mul [ebx+0]
mov dx, ax
mov ax, 150 // 0.586611 * 256
mul [ebx+1]
add dx, ax
mov ax, 29 // 0.114478 * 256
mul [ebx+2]
add dx, ax
shr dx, 8
push ebx
mov ebx, dstImg
add ebx, counter
mov [ebx+0], dl
mov [ebx+1], dl
mov [ebx+2], dl
pop ebx
add counter, 3
add ebx, 3
sub ecx, 3
jnz loop0
}
}
2014年8月23日土曜日
グレースケール
初めて画像処理をアセンブラで書いてみた
アセンブラでロジックを書くのは初めてかな
アセンブラでロジックを書くのは初めてかな
#include <cstdint>
#include <fstream>
using namespace std;
int main()
{
static const int IMG_HEADER_SIZE = 54;
uint8_t* hdr = new uint8_t[IMG_HEADER_SIZE];
memset(hdr, 0, IMG_HEADER_SIZE);
static const int IMG_DATA_SIZE = 1024*768*3;
uint8_t* img = new uint8_t[IMG_DATA_SIZE];
memset(img, 0, IMG_DATA_SIZE);
ifstream input_file("C:\\Users\\xxxxx\\Desktop\\Desert.bmp", ios::binary);
input_file.read(reinterpret_cast<char*>(hdr), IMG_HEADER_SIZE);
input_file.read(reinterpret_cast<char*>(img), IMG_DATA_SIZE);
for (int i = 0; i < IMG_DATA_SIZE; i+=3)
{
static const int GS_R8_WEIGHT = static_cast<int>(0.298912 * 256);
static const int GS_G8_WEIGHT = static_cast<int>(0.586611 * 256);
static const int GS_B8_WEIGHT = static_cast<int>(0.114478 * 256);
uint8_t r8 = img[i+0];
uint8_t g8 = img[i+1];
uint8_t b8 = img[i+2];
uint16_t tmp1;
uint8_t result;
__asm
{
mov tmp1, 0x00
mov ah, 0
mov al, r8
mul GS_R8_WEIGHT
mov tmp1, ax
mov ah, 0
mov al, g8
mul GS_G8_WEIGHT
add tmp1, ax
mov ah, 0
mov al, b8
mul GS_B8_WEIGHT
add tmp1, ax
shr tmp1, 8
push tmp1
pop result
}
img[i+0] = result;
img[i+1] = result;
img[i+2] = result;
}
ofstream output_file("C:\\Users\\xxxxx\\Desktop\\Desert_grayscale.bmp", ios::binary);
output_file.write(reinterpret_cast<char*>(hdr), IMG_HEADER_SIZE);
output_file.write(reinterpret_cast<char*>(img), IMG_DATA_SIZE);
output_file.close();
delete[] hdr;
delete[] img;
return 0;
}
2013年2月12日火曜日
Windowsの特権を操作
久しぶりに特権関連を書いてみた。
stdafx.h
sample.cpp
stdafx.h
#pragma once #include "targetver.h" #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <tchar.h> #include <string> #include <iostream> #include <boost/format.hpp> #include <boost/scoped_array.hpp> #include <Windows.h> #include <NTSecAPI.h>
sample.cpp
#include "stdafx.h"
#if defined(UNICODE) || defined(_UNICODE)
#define tstring std::wstring
#define tcout std::wcout
#define tformat boost::wformat
#else
#define tstring std::string
#define tcout std::cout
#define tformat boost::format
#endif
class Privilege
{
private:
LUID_AND_ATTRIBUTES luidAndAttrs;
tstring name;
tstring displayName;
public:
static const int PRIV_NAME_MAX_LENGTH = 64;
static const int PRIV_DISPNAME_MAX_LENGTH = 128;
typedef std::vector<boost::shared_ptr<Privilege>> PrivilegeContainer;
Privilege(LUID_AND_ATTRIBUTES luidAndAttrs)
{
this->luidAndAttrs = luidAndAttrs;
}
static PrivilegeContainer GetPrivileges()
{
PrivilegeContainer result;
HANDLE hToken;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
tcout << "OpenProcessToken 失敗" << std::endl;
return result;
}
DWORD length;
GetTokenInformation(hToken, TokenPrivileges, NULL, 0, &length);
boost::scoped_array<TOKEN_PRIVILEGES> privs(new TOKEN_PRIVILEGES[length]);
GetTokenInformation(hToken, TokenPrivileges, privs.get(), length, &length);
for (DWORD i=0; i<privs.get()->PrivilegeCount; i++)
{
auto luidAndAttrs = privs.get()->Privileges[i];
boost::shared_ptr<Privilege> priv(new Privilege(luidAndAttrs));
result.push_back(priv);
}
CloseHandle(hToken);
return result;
}
tstring GetName()
{
if (this->name.empty())
{
DWORD cchName = PRIV_NAME_MAX_LENGTH;
TCHAR name[PRIV_NAME_MAX_LENGTH+1] = {0};
LookupPrivilegeName(NULL, &this->luidAndAttrs.Luid, name, &cchName);
this->name = tstring(name);
}
return this->name;
}
tstring GetDisplayName()
{
if (this->displayName.empty())
{
DWORD cchDispName = PRIV_DISPNAME_MAX_LENGTH;
TCHAR dispname[PRIV_DISPNAME_MAX_LENGTH+1] = {0};
DWORD langID = 0;
LookupPrivilegeDisplayName(NULL, GetName().c_str(), dispname, &cchDispName, &langID);
this->displayName = tstring(dispname);
}
return this->displayName;
}
DWORD GetStatus() const
{
return this->luidAndAttrs.Attributes;
}
tstring GetStatusText() const
{
tstring text;
if (this->luidAndAttrs.Attributes & SE_PRIVILEGE_ENABLED)
{
text.append(_T("有効"));
}
else
{
text.append(_T("無効"));
}
return text;
}
void SetStatus(DWORD status)
{
HANDLE hToken;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
{
tcout << "OpenProcessToken 失敗" << std::endl;
return;
}
TOKEN_PRIVILEGES privs;
privs.PrivilegeCount = 1;
privs.Privileges[0].Attributes = status;
privs.Privileges[0].Luid = this->luidAndAttrs.Luid;
if (!AdjustTokenPrivileges(hToken, FALSE, &privs, 0, NULL, NULL))
{
tcout << "AdjustTokenPrivileges 失敗" << std::endl;
CloseHandle(hToken);
return;
}
this->luidAndAttrs.Attributes = status;
CloseHandle(hToken);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
_tsetlocale(LC_ALL, _T(""));
tcout << _T("----- before -----") << std::endl;
auto privs = Privilege::GetPrivileges();
for each(auto priv in privs)
{
auto ptr = priv.get();
tcout
<< tformat(L"%-4s %-64s %-128s")
% ptr->GetStatusText()
% ptr->GetName()
% ptr->GetDisplayName()
<< std::endl;
}
tcout << _T("----- 特権操作 -----") << std::endl;
auto pred =
[](const boost::shared_ptr<Privilege> &p) {
return (p->GetName() == SE_SHUTDOWN_NAME);
};
auto targetPriv = std::find_if(privs.begin(), privs.end(), pred);
tcout << targetPriv->get()->GetName() << std::endl;
targetPriv->get()->SetStatus(SE_PRIVILEGE_ENABLED);
tcout << _T("----- after -----") << std::endl;
privs = Privilege::GetPrivileges();
for each(auto priv in privs)
{
auto ptr = priv.get();
tcout
<< tformat(L"%-4s %-64s %-128s")
% ptr->GetStatusText()
% ptr->GetName()
% ptr->GetDisplayName()
<< std::endl;
}
return EXIT_SUCCESS;
}
登録:
投稿 (Atom)
SQL で MP4 をパース
SQL でビットマップ画像の2値化は4年位前に挑戦した。 最近、それの Impala 版 を作ったときに閃いた。 「再帰CTEがあるなら、mp4 もいけるんじゃないか」と。 やってみた。 use ragingo drop table video go create...
-
Hyper-V の 仮想マシン起動時のエラー 32788 に苦しめられたけど、イベントログ見れば一瞬で解決できたのでメモ イベントビューアー > アプリケーションとサービスログ > Microsoft > Windows > Hyper-V-**** ...
-
HTML1枚にぎゅっと詰まったシェーダー練習帳 gist https://gist.github.com/ragingo/e9edf399419dd90bd2894de9f48f6710 フラグメントシェーダーが終わったら、 今度は頂点シェーダーをやろう。
-
SQL でビットマップ画像の2値化は4年位前に挑戦した。 最近、それの Impala 版 を作ったときに閃いた。 「再帰CTEがあるなら、mp4 もいけるんじゃないか」と。 やってみた。 use ragingo drop table video go create...


