|
[求助]关于NtOpenFile和NtCreateFile
[QUOTE=xSpy;1302099]楼主到底是在驱动里转换还是在应用层转换? 之前写的一段,供参考. [/QUOTE] 其实我也不知道我自己写的算是r3 or r0 纯粹是不懂研究研究,多谢知识分享 |
|
[求助]关于NtOpenFile和NtCreateFile
今天早上逆向了WDK里面的FilterGetDosName,发现 GetVolumeNameForVolumeMountPoint 和 GetVolumePathNamesForVolumeName 发现FilterGetDosName通过把NT路径拼接成 \\\\?\\Gobal\\Device\\HarddiskVolume3\\, 传入GetVolumeNameForVolumeMountPoint 获得Guid,得到的Guid再传入GetVolumePathNamesForVolumeName就获得对应的Dos路径。 问题虽然可以这样解决,但是NtCreateFile和NtOpenFile还是打不开分区目录,获取不了句柄! 最后windbg逆向知道NtOpenFile的第二个参数是0x00100080对应FILE_SEQUENTIAL_WRITE_ONCE|FILE_SUPPORTS_REPARSE_POINTS 目录句柄返回成功! |
|
[求助]关于NtOpenFile和NtCreateFile
上面RtlNtPathNameToDosPathName用到的结构体定义 typedef struct _RTL_BUFFER { PWCHAR Buffer; PWCHAR StaticBuffer; SIZE_T Size; SIZE_T StaticSize; SIZE_T ReservedForAllocatedSize; PVOID ReservedForIMalloc; } RTL_BUFFER, *PRTL_BUFFER; typedef struct _RTL_UNICODE_STRING_BUFFER { UNICODE_STRING String; RTL_BUFFER ByteBuffer; WCHAR MinimumStaticBufferForTerminalNul[sizeof(WCHAR)]; } RTL_UNICODE_STRING_BUFFER, *PRTL_UNICODE_STRING_BUFFER; typedef NTSTATUS (NTAPI* _RtlNtPathNameToDosPathName)( __in ULONG Flags, __inout PRTL_UNICODE_STRING_BUFFER Path, __out_opt PULONG Disposition, __inout_opt PWSTR* FilePart ); _RtlNtPathNameToDosPathName RtlNtPathNameToDosPathName; |
|
[求助]关于NtOpenFile和NtCreateFile
再给一段RtlNtPathNameToDosPathName的代码 HMODULE hNTDLL = LoadLibrary(L"ntdll.dll"); if(hNTDLL == NULL) return ; RtlNtPathNameToDosPathName = (_RtlNtPathNameToDosPathName)GetProcAddress(hNTDLL, "RtlNtPathNameToDosPathName"); if(RtlNtPathNameToDosPathName == NULL) return ; //RtlGetProcessHeap = (_RtlGetProcessHeap)GetProcAddress(hNTDLL,"RtlGetProcessHeap"); //if(RtlGetProcessHeap == NULL) return ; PWCHAR puBuffer = (PWCHAR)RtlAllocateHeap(RtlProcessHeap(), HEAP_ZERO_MEMORY, pNameInfo->Name.Length * sizeof(PWCHAR)); PWCHAR _puBuffer = (PWCHAR)RtlAllocateHeap(RtlProcessHeap(), HEAP_ZERO_MEMORY, pNameInfo->Name.Length * sizeof(PWCHAR)); if(puBuffer == NULL || _puBuffer == NULL) return ; //RtlCopyMemory(puBuffer, pNameInfo->Name.Buffer, pNameInfo->Name.Length); //RtlCopyMemory(_puBuffer, pNameInfo->Name.Buffer, pNameInfo->Name.Length); RTL_UNICODE_STRING_BUFFER DosPath; DosPath.String.Buffer = pNameInfo->Name.Buffer; DosPath.String.Length = pNameInfo->Name.Length; DosPath.String.MaximumLength = pNameInfo->Name.MaximumLength; DosPath.ByteBuffer.Buffer = puBuffer; DosPath.ByteBuffer.StaticBuffer = _puBuffer; DosPath.ByteBuffer.Size = MAX_PATH; DosPath.ByteBuffer.StaticSize = MAX_PATH; DosPath.ByteBuffer.ReservedForAllocatedSize = 0; DosPath.ByteBuffer.ReservedForIMalloc = NULL; ULONG Disposition = 0; //(Disposition返回1) Status = RtlNtPathNameToDosPathName(0, &DosPath, &Disposition, NULL); if(NT_SUCCESS(Status)) { wprintf(L"DosPath.String.Buffer = %s\n",DosPath.String.Buffer); wprintf(L"DosPath.ByteBuffer.Buffer = %s\n",DosPath.ByteBuffer.Buffer); wprintf(L"DosPath.ByteBuffer.StaticBuffer = %s\n", DosPath.ByteBuffer.StaticBuffer); } } 真心求各位大神指导。 |
|
[求助]关于NtOpenFile和NtCreateFile
附上自己写的代码 首先是普通文件的dos转nt HANDLE keyhandle =CreateFile(L"C:\\MyServiceLog.txt",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL,NULL); NTSTATUS Status = NtQueryObject((HANDLE)keyhandle,ObjectNameInformation,cInfoBuffer,0,&Size); if(Size > 0) { Status = NtQueryObject((HANDLE)keyhandle,ObjectNameInformation,cInfoBuffer,Size,&Size); if(NT_SUCCESS(Status)) { pNameInfo = (POBJECT_NAME_INFORMATION)cInfoBuffer; wprintf(L"%s\r\n",pNameInfo->Name.Buffer); } } 然后就是想打开打开各分区根目录,用上面的方法获取NT路径 OBJECT_ATTRIBUTES obj; UNICODE_STRING string; IO_STATUS_BLOCK IoStatusBlock; RtlInitUnicodeString(&string, L"\\\\.\\C\\MyService"); //string.Length = wcslen(L"\\\\.\\C:"); //string.MaximumLength = wcslen(L"\\\\.\\C:") + 1; //string.Buffer = (PWCH)malloc(sizeof(WCHAR)*string.Length); InitializeObjectAttributes(&obj,&string, OBJ_CASE_INSENSITIVE + OBJ_KERNEL_HANDLE, NULL, NULL); //NtOpenFile(&keyhandle,DIRECTORY_ALL_ACCESS,&obj,&IoStatusBlock,NULL,NULL); //NtCreateFile(&keyhandle,FILE_TRAVERSE |FILE_LIST_DIRECTORY, &obj, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0,FILE_OPEN_IF, FILE_SYNCHRONOUS_IO_NONALERT,NULL, 0); (以上两函数句柄返回都是0) |
|
[求助]关于NtOpenFile和NtCreateFile
是不是放错板块呢?还是都休息去了? |
|
[分享][分享]1年总结+面经
面试原话: mixerSetControlDetails 这个函数是什么作用? |
|
[分享][分享]1年总结+面经
mixerSetControlDetails 这函数做什么的得清楚,堆栈回溯一下吧。 |
|
[分享][分享]1年总结+面经
直接告诉你就没意思了 |
|
[分享][分享]1年总结+面经
你是xp还是win7?还有跟驱动就证明是错了,我之前也是跟驱动,后来发现自己是错的。用回面试官对我说的话:“你对windows系统还理解不够深。” |
|
[分享][分享]1年总结+面经
通过sndvol找关键api。我没说sndvol就是存储声音的地方 |
|
|
|
[分享][分享]1年总结+面经
我是中山人 |
|
[分享][分享]1年总结+面经
我是半桶水,八两都不足 就是知道自己想要什么而已 |
|
[分享][分享]1年总结+面经
请教不敢当,一起讨论一起进步 |
|
[分享][分享]1年总结+面经
自己心中有方向,就不需要按图发展 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值