Skip to content

Instantly share code, notes, and snippets.

View 0xbadfca11's full-sized avatar
💭
I'm currently depressed.

0xbadfca11

💭
I'm currently depressed.
View GitHub Profile
@0xbadfca11
0xbadfca11 / 00_README.md
Last active January 3, 2025 12:54
Windows ReFS versions
@0xbadfca11
0xbadfca11 / Wrong usage Optimize-VHD.md
Created January 5, 2016 09:38
お前らの Optimize-VHD の使い方は間違っている
  • ゲストでsdelete -z→シャットダウンして→Optimize-VHD -Mode Prezeroed
  • ホストでMount-VHDsdelete -zDismount-VHDOptimize-VHD -Mode Prezeroed

これらは時間と書き込み量を浪費しているだけだから今すぐ止めて
Mount-VHD <VHD> [-NoDriveLetter] -ReadOnly -Passthru | Optimize-VHD [-Mode {Quick|Full}] -Passthru | Dismount-VHD
を使うべき。

なんで?

読み取り専用でマウントしている時に Optimize-VHD をすればディスクイメージ内の NTFS から得られる空き領域情報を利用するから。

@0xbadfca11
0xbadfca11 / What is .PFILE file extension.ja.md
Created February 17, 2017 13:02
What is .PFILE file extension

.PFILE 拡張子とは何か

Microsoft Rights Management Services

あなたが探している情報はこちらではないね?

Windows 10 の EFS

Windows 10 の新機能の一つで FAT16/FAT32/exFAT で EFS(Encrypting File System) が使用可能になりました。 公式にはバージョン 1607 からとありますが実際には FAT16/FAT32 ではバージョン 1507 から exFAT ではバージョン 1511 から使用可能でした。 暗号化されたファイルは Windows 10 以外からはファイル名の末端に .PFILE が付きます。 Windows 10 の EFS 以外でファイル名の末端を .PFILE に変えても Windows 10 で EFS として扱われることはありません。

Windows 10 同士で共有したい

NTFS の EFS の場合と同じ方法で可能です。

@0xbadfca11
0xbadfca11 / Fix-Combined-Character-FileName.ps1
Last active May 6, 2024 09:10 — forked from pekeq/Fix-Combined-Character-FileName.ps1
Windows上で、UNICODEの結合文字が含まれるファイル名を、正規化したファイル名にリネームするスクリプト作った。
<#
.SYNOPSIS
ファイル名、ディレクトリ名のUNICODE結合文字を、普通の1文字に変換する
.DESCRIPTION
ファイル名、ディレクトリ名のUNICODE結合文字になっている部分を、普通の1文字に変換する。
例えば、「か + ゛(濁点記号)」を、「が」に変換する。
Macは、ファイル名をUNICODE結合文字で保存するが、Windowsは、普通の1文字で保存するので、
MacからWindowsに、USBメモリーでファイルをコピーした際など、MacとWindowsのファイル交換時に
@0xbadfca11
0xbadfca11 / .md
Last active June 13, 2017 08:04
Windows exFAT bug

Summary

Windows exFAT driver crashes when making huge file.

Affect

  • Windows XP with KB955704
  • Windows Server 2003 with KB955704
  • Windows Vista
  • Windows Server 2008
  • Windows 7
  • Windows Server 2008 R2
@0xbadfca11
0xbadfca11 / .md
Last active August 22, 2020 09:27
Windows ReFS bug

Summary

Windows ReFS driver crashes when enabling integrity streams of large file.

Affect

  • Windows Server 2012
  • Windows Server 2012 R2
  • Windows Server 2016 (with ReFS 1.2)
  • Windows 10 v1703 (with ReFS 1.2)

Not affect

  • Windows Server 2016 (with ReFS 3.1)
@0xbadfca11
0xbadfca11 / .cpp
Last active June 20, 2022 09:13
_fto132proc bug
#include <fenv.h>
#include <stdint.h>
#include <stdio.h>
extern "C" int64_t fto132proc(/* Passing by ST(0) */);
int main()
{
double f = UINT32_MAX + 0.9;
uint32_t h, l;
#define WIN32_LEAN_AND_MEAN
#define WIL_SUPPRESS_EXCEPTIONS
#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include <wil/resource.h>
int wmain(int, PWSTR argv[])
{
wil::unique_hfile d(CreateFileW(argv[1], FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, nullptr));
@0xbadfca11
0xbadfca11 / .md
Created June 10, 2018 12:19
IsWow64Process2() を使わずにWowA64を検出する

TLDR IsWow64Process2()使え。

WowA64ではIsWow64Process()GetNativeSystemInfo()を使うとx86版Windowsと誤認するようになっている。 バグではなく意図的な仕様と考えられる。(理由考察は省略)

しかしそれらのAPIで得られる値やIsWow64Process2()以外のAPIでも一部の挙動がx86版Windowsと違う。

AMD64 x86 Arm64
IsWow64Process() *Wow64Process TRUE 0 0
@0xbadfca11
0xbadfca11 / 頭の体操.md
Created July 7, 2018 05:51
母音の判定

char a = <...>;
2130466 >> a & 1;
とは

ネタ元

https://twitter.com/kumagi/status/1014953960237436928

必要前提知識

x86のシフト命令は下位5ビットしか見ない

The count operand can be an immediate value or the CL register. The count is masked to 5 bits (or 6 bits if in 64-bit mode and REX.W is used). The count range is limited to 0 to 31 (or 63 if 64-bit mode and REX.W is used).