網站首頁 編程語言 正文
#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
- 上一篇:檢測到調試后執行的代碼
- 下一篇:類實例化 對象的內存模型 及 內存占用分析
相關推薦
- 2022-04-17 python數據庫操作之sqlalchemy逆向工程
- 2022-05-21 python中的變量命名規則詳情_python
- 2022-05-20 springboot-mybatis實現增刪改查
- 2022-04-11 圖文詳解C#中的協變與逆變_C#教程
- 2022-07-27 C語言深入講解指針與結構體的使用_C 語言
- 2022-07-29 python保存字典數據到csv文件的完整代碼_python
- 2022-06-23 Android通過SeekBar調節布局背景顏色_Android
- 2022-07-16 Spring MVC重定向和轉發
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支