網(wǎng)站首頁 編程語言 正文
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ne-wdm-_fsinfoclass
typedef enum _FSINFOCLASS {
FileFsVolumeInformation = 1,
FileFsLabelInformation,
FileFsSizeInformation,
FileFsDeviceInformation,
FileFsAttributeInformation,
FileFsControlInformation,
FileFsFullSizeInformation,
FileFsObjectIdInformation,
FileFsDriverPathInformation,
FileFsMaximumInformation
} FS_INFORMATION_CLASS, * PFS_INFORMATION_CLASS;
typedef NTSTATUS(*FZwSetVolumeInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS);
typedef NTSTATUS(*FZwQueryVolumeInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS);
int main(int argc, char* argv[])
{
const wchar_t* device = L"\\\\.\\c:";
HANDLE h = CreateFileW(device, 0x40000000, 3, 0, 3, 0x80, 0);
if (h == INVALID_HANDLE_VALUE) return 0;
printf("handle is %d \n", h);
HMODULE m = GetModuleHandleW(L"ntdll.dll");
if (!m) return 0;
printf("module is %p \n", m);
FZwSetVolumeInformationFile _ZwSetVolumeInformationFile = (FZwSetVolumeInformationFile)GetProcAddress(m, "ZwSetVolumeInformationFile");
FZwQueryVolumeInformationFile _ZwQueryVolumeInformationFile = (FZwQueryVolumeInformationFile)GetProcAddress(m, "ZwQueryVolumeInformationFile");
if (!_ZwSetVolumeInformationFile || !_ZwQueryVolumeInformationFile) return 0;
printf("_ZwSetVolumeInformationFile %p \n", _ZwSetVolumeInformationFile);
printf("_ZwQueryVolumeInformationFile %p \n", _ZwQueryVolumeInformationFile);
NTSTATUS s;
const int size = 1024 * 10;
char* buf = new char[size];
memset(buf, 0, size);
IO_STATUS_BLOCK status{ 0 };
typedef struct _FILE_FS_VOLUME_INFORMATION {
LARGE_INTEGER VolumeCreationTime;
ULONG VolumeSerialNumber;
ULONG VolumeLabelLength;
BOOLEAN SupportsObjects;
WCHAR VolumeLabel[1];
} FILE_FS_VOLUME_INFORMATION, * PFILE_FS_VOLUME_INFORMATION;
s = _ZwQueryVolumeInformationFile(h, &status, buf, size, FileFsVolumeInformation);
PFILE_FS_VOLUME_INFORMATION p1 = (PFILE_FS_VOLUME_INFORMATION)buf;
p1->VolumeSerialNumber = 0;
p1->VolumeLabel[0] = L'\0';
s = _ZwSetVolumeInformationFile(h, &status, p1, size, FileFsVolumeInformation);
printf("%p \n", s);
typedef struct _FILE_FS_OBJECTID_INFORMATION {
UCHAR ObjectId[16];
UCHAR ExtendedInfo[48];
} FILE_FS_OBJECTID_INFORMATION, * PFILE_FS_OBJECTID_INFORMATION;
s = _ZwQueryVolumeInformationFile(h, &status, buf, size, FileFsObjectIdInformation);
PFILE_FS_OBJECTID_INFORMATION p2 = (PFILE_FS_OBJECTID_INFORMATION)buf;
p2->ObjectId[0] = 55;
p2->ObjectId[1] = 55;
p2->ObjectId[2] = 55;
p2->ObjectId[3] = 55;
p2->ObjectId[4] = 55;
p2->ObjectId[5] = 55;
p2->ObjectId[6] = 55;
p2->ObjectId[7] = 55;
s = _ZwSetVolumeInformationFile(h, &status, p2, size, FileFsObjectIdInformation);
printf("%p \n", s);
//typedef struct _FILE_FS_DRIVER_PATH_INFORMATION {
// BOOLEAN DriverInPath;
// ULONG DriverNameLength;
// WCHAR DriverName[1];
//} FILE_FS_DRIVER_PATH_INFORMATION, * PFILE_FS_DRIVER_PATH_INFORMATION;
//PFILE_FS_DRIVER_PATH_INFORMATION p3 = (PFILE_FS_DRIVER_PATH_INFORMATION)buf;
//p3->DriverInPath = TRUE;
//p3->DriverNameLength = 0x200;
//wcscpy(p3->DriverName, L"\\\\?\\Volume{c6708e20-53cd-4265-a031-af74f04ca24b}");
//s = _ZwQueryVolumeInformationFile(h, &status, buf, size, FileFsDriverPathInformation);
CloseHandle(h);
system("pause");
return 0;
}
原文鏈接:https://blog.csdn.net/zzy1448331580/article/details/121879219
相關(guān)推薦
- 2022-09-25 python mac版本解釋器安裝
- 2022-07-17 baselines示例程序train_cartpole.py的ImportError_python
- 2022-10-17 Python可視化程序調(diào)用流程解析_python
- 2024-03-15 Redis中RDB和AOF
- 2022-11-18 flutter?showModalBottomSheet常用屬性及說明_Android
- 2022-08-16 QT布局管理詳解QVBoxLayout與QHBoxLayout及QGridLayout的使用_C 語
- 2022-04-30 DataGridView設(shè)置單元格的提示內(nèi)容ToolTip_C#教程
- 2022-06-21 C語言平衡二叉樹真題練習(xí)_C 語言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支