Skip to content

Instantly share code, notes, and snippets.

View 0xbadfca11's full-sized avatar
💭
I may be slow to respond.

0xbadfca11

💭
I may be slow to respond.
View GitHub Profile
@0xbadfca11
0xbadfca11 / 0.md
Created March 19, 2024 11:12
Using FileExtd.lib with newer Windows SDK
  1. Add kernel32.lib to Ignore Specific Default Libraries.
    But don't remove kernel32.lib from Additional Dependencies.
  2. Set Additional Dependencies to fileextd.lib;ntdll.lib;%(AdditionalDependencies).
    Order is important. fileextd.lib must come before kernel32.lib.
  3. FileExtd.lib was not created with __declspec(dllimport) in mind. Need to take precautions against the _imp__ symbol.
    Do either.
    • #define WINBASEAPI before #include <windows.h>. Although this is easy, keep in mind that it affects the entire source file.
  • Override __imp__SetFileInformationByHandle@16 using assembly.
@0xbadfca11
0xbadfca11 / 00_README.md
Last active March 6, 2024 12:51
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 / .md
Created December 21, 2018 11:30
Windows ReFS bug

Summary

Windows Server 2016 ReFS driver crashes when trying to mount ReFS 3.4 that disguised ReFS 3.1.

Affect

  • Windows Server 2016
    Tested with KB4483229 applied

Not affect

  • Windows 10 v1809
  • Windows Server 2019

How to crash

  1. Boot from Install media of Windows 10 v1809.
@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;
@0xbadfca11
0xbadfca11 / How to use a USB thumb drive as Hyper-V pass-through disk.en.md
Created August 9, 2016 12:00
How to use a USB stick as Hyper-V pass-through disk

Not goal of this document

  • Pass-through USB device as USB device.

Goal of this document

  • Using USB storage as pass-through disk.

USB-HDD and Windows To Go certified USB stick

This is easy.

Normal USB sticks

#define WIN32_LEAN_AND_MEAN
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <windows.h>
#include <atlbase.h>
#include <winternl.h>
#include <cstdio>
#include <cstdlib>
#pragma comment(lib, "ntdll")
#ifndef FILE_CS_FLAG_CASE_SENSITIVE_DIR
@0xbadfca11
0xbadfca11 / .adoc
Created September 24, 2020 13:10
Don't use GetImageConfigInformation

TL;DR Don’t use GetImageConfigInformation.

GetImageConfigInformation bug

GetImageConfigInformation is hard coded that the Image Config Directory is 64 bytes.
It will not work in most environments.
Don’t use GetImageConfigInformation. This API is waste.

GetImageConfigInformation Implementation

@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)
EXPORTS
WslLaunch