我把hookZwClose后得到句柄通过ObReferenceObjectByHandle(FileHandle, 0, *IoFileObjectType, KernelMode, &FileObject, NULL);后FileObject->FileName.Buffer是操作文件的进程名(如\windows\system\notepad.exe),而我想得到的是文件名(如*.txt)。怎么做呢。
PUNICODE_STRING
SfGetFileName(
IN PFILE_OBJECT FileObject,
IN NTSTATUS CreateStatus,
IN OUT PGET_NAME_CONTROL NameControl
)
/*++
Routine Description:
This routine will try and get the name of the given file object. This
is guaranteed to always return a printable string (though it may be NULL).
This will allocate a buffer if it needs to.
Arguments:
FileObject - the file object we want the name for
CreateStatus - status of the create operation
NameControl - control structure used for retrieving the name. It keeps
track if a buffer was allocated or if we are using the internal
buffer.
Return Value:
Pointer to the unicode string with the name
--*/
{
POBJECT_NAME_INFORMATION nameInfo;
NTSTATUS status;
ULONG size;
ULONG bufferSize;
//
// Mark we have not allocated the buffer
//
NameControl->allocatedBuffer = NULL;
//
// Use the small buffer in the structure (that will handle most cases)
// for the name
//
nameInfo = (POBJECT_NAME_INFORMATION)NameControl->smallBuffer;
bufferSize = sizeof(NameControl->smallBuffer);
//
// If the open succeeded, get the name of the file, if it
// failed, get the name of the device.
//
status = ObQueryNameString(
(NT_SUCCESS( CreateStatus ) ?
(PVOID)FileObject :
(PVOID)FileObject->DeviceObject),
nameInfo,
bufferSize,
&size );
//
// See if the buffer was to small
//
if (status == STATUS_BUFFER_OVERFLOW) {
//
// The buffer was too small, allocate one big enough
//
bufferSize = size + sizeof(WCHAR);
NameControl->allocatedBuffer = ExAllocatePoolWithTag(
NonPagedPool,
bufferSize,
SFLT_POOL_TAG );
if (NULL == NameControl->allocatedBuffer) {
//
// Failed allocating a buffer, return an empty string for the name
//
RtlInitEmptyUnicodeString(
(PUNICODE_STRING)&NameControl->smallBuffer,
(PWCHAR)(NameControl->smallBuffer + sizeof(UNICODE_STRING)),
(USHORT)(sizeof(NameControl->smallBuffer) - sizeof(UNICODE_STRING)) );
return (PUNICODE_STRING)&NameControl->smallBuffer;
}
//
// Set the allocated buffer and get the name again
//
nameInfo = (POBJECT_NAME_INFORMATION)NameControl->allocatedBuffer;
status = ObQueryNameString(
FileObject,
nameInfo,
bufferSize,
&size );
}
//
// If we got a name and an error opening the file then we
// just received the device name. Grab the rest of the name
// from the FileObject (note that this can only be done if being called
// from Create). This only happens if we got an error back from the
// create.
//
if (NT_SUCCESS( status ) &&
!NT_SUCCESS( CreateStatus )) {
ULONG newSize;
PCHAR newBuffer;
POBJECT_NAME_INFORMATION newNameInfo;
//
// Calculate the size of the buffer we will need to hold
// the combined names
//
newSize = size + FileObject->FileName.Length;
//
// If there is a related file object add in the length
// of that plus space for a separator
//
if (NULL != FileObject->RelatedFileObject) {
newSize += FileObject->RelatedFileObject->FileName.Length +
sizeof(WCHAR);
}
//
// See if it will fit in the existing buffer
//
if (newSize > bufferSize) {
//
// It does not fit, allocate a bigger buffer
//
newBuffer = ExAllocatePoolWithTag(
NonPagedPool,
newSize,
SFLT_POOL_TAG );
if (NULL == newBuffer) {
//
// Failed allocating a buffer, return an empty string for the name
//
RtlInitEmptyUnicodeString(
(PUNICODE_STRING)&NameControl->smallBuffer,
(PWCHAR)(NameControl->smallBuffer + sizeof(UNICODE_STRING)),
(USHORT)(sizeof(NameControl->smallBuffer) - sizeof(UNICODE_STRING)) );
return (PUNICODE_STRING)&NameControl->smallBuffer;
}
//
// Now initialize the new buffer with the information
// from the old buffer.
//
newNameInfo = (POBJECT_NAME_INFORMATION)newBuffer;
RtlInitEmptyUnicodeString(
&newNameInfo->Name,
(PWCHAR)(newBuffer + sizeof(OBJECT_NAME_INFORMATION)),
(USHORT)(newSize - sizeof(OBJECT_NAME_INFORMATION)) );
RtlCopyUnicodeString( &newNameInfo->Name,
&nameInfo->Name );
//
// Free the old allocated buffer (if there is one)
// and save off the new allocated buffer address. It
// would be very rare that we should have to free the
// old buffer because device names should always fit
// inside it.
//
if (NULL != NameControl->allocatedBuffer) {
ExFreePool( NameControl->allocatedBuffer );
}
//
// Readjust our pointers
//
NameControl->allocatedBuffer = newBuffer;
bufferSize = newSize;
nameInfo = newNameInfo;
} else {
//
// The MaximumLength was set by ObQueryNameString to
// one char larger then the length. Set it to the
// true size of the buffer (so we can append the names)
//
nameInfo->Name.MaximumLength = (USHORT)(bufferSize -
sizeof(OBJECT_NAME_INFORMATION));
}
//
// If there is a related file object, append that name
// first onto the device object along with a separator
// character
//
if (NULL != FileObject->RelatedFileObject) {
RtlAppendUnicodeStringToString(
&nameInfo->Name,
&FileObject->RelatedFileObject->FileName );
RtlAppendUnicodeToString( &nameInfo->Name, L"\\" );
}
//
// Append the name from the file object
//
RtlAppendUnicodeStringToString(
&nameInfo->Name,
&FileObject->FileName );
ASSERT(nameInfo->Name.Length <= nameInfo->Name.MaximumLength);
}
//
// Return the name
//
return &nameInfo->Name;
}
typedef struct _GET_NAME_CONTROL {
PCHAR allocatedBuffer;
CHAR smallBuffer[256];
} GET_NAME_CONTROL, *PGET_NAME_CONTROL;
调用时候
GET_NAME_CONTROL nameControl;
PUNICODE_STRING name = SfGetFileName(FileObject,
STATUS_SUCCESS,
&nameControl );
调用完,在调用这个函数,释放内存
SfGetFileNameCleanup( &nameControl );
VOID
SfGetFileNameCleanup(
IN OUT PGET_NAME_CONTROL NameControl
)
/*++
Routine Description:
This will see if a buffer was allocated and will free it if it was
Arguments:
NameControl - control structure used for retrieving the name. It keeps
track if a buffer was allocated or if we are using the internal
buffer.
Return Value:
None
--*/
{
if (NULL != NameControl->allocatedBuffer) {
ExFreePool( NameControl->allocatedBuffer);
NameControl->allocatedBuffer = NULL;
}
}
看看大概的调用情况 左边是2000有的,右边是xp后走的 ...当 Kernel32.dll 中的 API 通过 Ntdll.dll 时,会完成参数的检查再调用一个中断(int 2Eh 或者 SysEnter 指令),从而实现从 Ring3 进入 Ring0 层 ...
1.SSDT是什么? SSDT全程是System Services Discriptor Table 翻译过来就是系统服务描述符表,那么系统服务描述符是什么呢?根据官方的解释ssdt表就是把ring3的Win32 API和ring0的内核API联系起来。SSDT并不仅仅只...
最近在学HookSSDT和针对Hook的ResumeSSDT,避免自己理解有所偏差,把它们写出来,希望大家不吝赐教。(虽然已经是过时了的技术,但是最起码了解其中的原理,嘿嘿嘿。) 转载注明出处:...
#include "HookSSDT.h" #include <ntimage.h> #define SEC_IMAGE 0x001000000 ULONG32 __NtOpenProcessIndex = 0; PVOID __ServiceTableBase = NULL; ULONG32 __OldNtOpenProcessOffset = 0...
/*++ * @Description * 主逻辑控制函数 * @Param * @Return * @Attention --*/ void Running(); /*++ * @Description * 不接收换行的从标准输入内收到键入,是一个安全函数 * * @Param ...kgets(OUT.
SSDT HOOK中的获取函数服务号:(因为SSDT中的函数在ntdll.dll均为导出函数) R3下:1)LoadLibrary "ntdll.dll" 2)GetProcAddress 得到ntdll.dll导出表中函数地址address 3)FunctionIndex = *( PULONG...
SSDT InlineHook是在SSDT Hook 基础上来进一步Hook的,SSDTHook 是直接将SSDT表中的 Nt*函数替换成Fake函数,而SSDT Inline Hook是将原函数代码的前五个字节改变为 E9 _ _ _ _ ,后面跟的是Offset,也就是我们Fake...
用ZwQuerySystemInformation 功能号为11(SystemModuleInformation) 得到所有系统模块的地址 遍历搜索得到ntos模块的基地址 读Ntos模块到System进程空间中 在ntos中找到函数真正地址 将地址转换为ssdt的索引 //...
背景SSDT 全称为 System Services Descriptor Table,即系统服务描述符表。SSDT 表的作用就是把 ring3 的 WIN32 API 函数和 ring0 的内核 API 函数联系起来。对于ring3下的一些API,最终会对应于 ntdll.dll 里一个 ...
网上很多文章都有关于SSDT的完整的实现,但是没有关于Shadow SSDT的完整实现,目前最好的文章是《shadow ssdt学习笔记 by zhuwg》,我这里的程序也很多参考了他的文章,在这里谢谢了。我这里给出一个hook ...
1.系统服务调度表SSDT及SSSDT Shadow 系统服务:由操作系统提供的一组函数(内核函数),API可以间接或者直接的调用系统服务。操作系统以动态链接库(DLL)的形式提供API。 SSDT:系统服务调度表(System ...
HookSSDT这篇文章主要讲述HookNtOpenProcess函数阻止暴力枚举进程以及学习过程中遇到的相关问题以及解决方法 OpenProcess调用的主要过程: 关键步骤解释及代码片段 完整代码 在HookSSDT的过程中遇到的问题 大家遇到...
1.IAT_HOOK IAT是程序中存储导入函数地址的数据结构,如果HOOK了导入函数地址。就可以在函数调用的时候,将函数流程HOOK到我们指定的流程。但是我个人觉得这种方式最好要结合DLL注入的方式,如果单纯的使用HOOK,...
最近打开一个游戏,发现该游戏不断调用SetCursorPos这个函数,所以想着在内核中...获得鼠标的位置函数GetCursorPos,设置鼠标的位置SetCursorPos 获得暂且不分析,这里只说SetCursorPos,其实这两个也是异曲同工。 S
文章目录Hook框架选择基于微软规范的框架微软规范以外的框架简单介绍一下InfinityHook获取内核中的函数地址内核中导出的函数内核未导出的函数获取 SSDT ShadowSSDT 地址获取系统服务号手动获取获取并判断系统版本...
标 题: 【原创】Hook Shadow SSDT 作 者: sislcb 时 间: 2008-06-02,23:21:04 链 接: http://bbs.pediy.com/showthread.php?t=65931 网上很多文章都有关于SSDT的完整的实现,但是没有关于Shadow SSDT的...
2、系统服务调度表SSDT及SSSDT Shadow 系统服务:由操作系统提供的一组函数(内核函数),API可以间接或者直接的调用系统服务。操作系统以动态链接库(DLL)的形式提供API。 SSDT:系统服务调度表(System ...
网上很多文章都有关于SSDT的完整的实现,但是没有关于Shadow SSDT的完整实现,目前最好的文章是《shadow ssdt学习笔记 by zhuwg》,我这里的程序也很多参考了他的文章,在这里谢谢了。我这里给出一个hook shadow ...
标 题: 【原创】Hook Shadow SSDT 作 者: sislcb 时 间: 2008-06-02,23:21:04 链 接: http://bbs.pediy.com/showthread.php?t=65931 网上很多文章都有关于SSDT的完整的实现,但是没有关于Shadow SSDT的完整...
网络安全中的文件删除与保护一直都是大家谈论的焦点问题,针对如何保护磁盘上属于自己的专有文件,已经存在一些现成技术,比如信息隐藏技术。笔者详细的谈论过有关基于有序规则的信息隐藏与加密技术,利用一些常见...
http://www.vcfans.com/2010/04/hook-shadow-ssdt.html 作 者: sislcb原 文:http://bbs.pediy.com/showthread.php?t=65931 网上很多文章都有关于SSDT的完整的实现,但是没有关于Shadow SSDT的完整实现,目前最好的...
SSDT(System Services Descriptor Table),系统服务描述符表。这个表就是一个把ring3的Win32 API和ring0的... 通过修改此表的函数地址可以对常用windows函数及API进行hook,从而实现对一些关心的系统动作进行过滤
重载内容:两张系统服务调度表 ,传说的SSDT和ShadowSSDT 作用:通过重载内核,可以饶过各大著名驱动保护的HOOK.极少数例外. 重载方式:挂勾系统三环和零环的主要通道KiFastCallEntry,然后改变自己的进程,通过新内核. ...
走进JSP、掌握JSP语法、JSP内置对象、Servlet技术、综合实验(一)——JSP使用Model2实现登录模块、EL表达式语言、JSTL核心标签库、综合实验(二)——结合JSTL与EL技术开发通讯录模块、JSP操作XML、JavaScript脚本语言、综合实验(三)——Ajax实现用户注册模块——可以轻松领会Java Web程序开发的精髓,提高开发技能。 快速提高自己的java web项目开发能力
2020华为软件精英挑战赛初复赛赛题包,不包含民间数据集,民间数据集在博客中给出大佬github地址。
微信小程序源码,包含:图片展示、外卖点餐、小工具类、小游戏类、演绎博览、新闻资讯、医疗保健、艺术生活等源码。
从0开始,Linux云计算系列课程,包含Linux初级运维、运维、初级架构师、云计算运维及开发..... a:0:{}
课程分为:J2SE 基础阶段,中级阶段,阶段; 课间会讲解一些小程序的开发:如:猜拳游戏,模拟银行柜员机程序,退休金结算程序等.
Linux从入门到系列课程,全部重点放在企业应用上面。课程主要针对互联网企业运维,因此不会花多余的时间去阐述无关紧要
每个章节后一个课时下载课件(课时名称样式:“xxxxxx-下载课件“) 本课程是Project的基础课程,主要针对P