能力值:
( LV2,RANK:10 )
|
-
-
2 楼
typedef struct UnicideString
{
USHORT Length;
USHORT MaxLength;
PWSTR Buffer;
}
lz使用RtlInitUnicodeString把局部变量“haha.exe”初始化到原来的curr->ProcessName里面去了
curr->ProcessName是一个UnicodeString,它其中的Buffer就指向了这个局部变量haha.exe,所以buffer指向了一个内核空间地址
任务管理器是用户层的 当然不能访问内核的地址 所以显示出来是个空的~~~~
lz可以调试一下 复制前curr->ProcessName的Buffer指向的是一个用户空间的地址~~~
所以lz要将“haha.exe”复制到curr->ProcessName
这样就可以了,我已经测试过了
NTSTATUS MyZwQuerySystemInformation(IN ULONG SystemInformationClass,IN PVOID SystemInformation,IN ULONG SystemInformationLength,OUT PULONG ReturnLength)
{
struct _SYSTEM_PROCESSES *curr;
NTSTATUS rc;
UNICODE_STRING process_name,ChangeName;
RtlInitUnicodeString(&process_name, L"smss.exe");
RtlInitUnicodeString(&ChangeName,L"haha.exe");
rc = OldZwQuerySystemInformation( SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
if(NT_SUCCESS(rc))
{
if(SystemInformationClass==5)
{
curr = (struct _SYSTEM_PROCESSES *)SystemInformation;
while(curr)
{
if (RtlEqualUnicodeString(&process_name, &(curr->ProcessName), 1))
{
DbgPrint("B:%wZ\n",&(curr->ProcessName));
RtlCopyUnicodeString(&(curr->ProcessName),&ChangeName);
//curr = (struct _SYSTEM_PROCESSES *)((ULONG)curr + (ULONG)curr->NextEntryDelta);
DbgPrint("A:%wZ\n",&(curr->ProcessName));
break;
} // if (RtlEqualUnicodeString(&process_name, &curr->ProcessName, 1))
if(curr->NextEntryDelta)
{
curr = (struct _SYSTEM_PROCESSES *)((ULONG)curr + (ULONG)curr->NextEntryDelta);
}
else
curr = NULL;
} //while(curr)
} // if(5 == SystemInformationClass)
}// if(NT_SUCCESS(rc))
// KdPrint(("HookZwQuerySystemInformation is Succeessfully. \n"));
return rc;
}
|
能力值:
( LV13,RANK:350 )
|
-
-
3 楼
补充RtlInitUnicodeString和RtlCopyUnicodeString的参考源码:
VOID NTAPI RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,IN PCWSTR SourceString)
{
SIZE_T DestSize;
if(SourceString)
{
DestSize = utf16_wcslen(SourceString) * sizeof(WCHAR);
DestinationString->Length = (USHORT)DestSize;
DestinationString->MaximumLength = (USHORT)DestSize + sizeof(WCHAR);
}
else
{
DestinationString->Length = 0;
DestinationString->MaximumLength = 0;
}
DestinationString->Buffer = (PWCHAR)SourceString;
}
VOID NTAPI RtlCopyUnicodeString( IN OUT PUNICODE_STRING DestinationString, IN PCUNICODE_STRING SourceString)
{
ULONG SourceLength;
if(SourceString == NULL)
{
DestinationString->Length = 0;
}
else
{
SourceLength = min(DestinationString->MaximumLength, SourceString->Length);
DestinationString->Length = (USHORT)SourceLength;
RtlCopyMemory(DestinationString->Buffer,SourceString->Buffer,SourceLength);
if (DestinationString->Length < DestinationString->MaximumLength)
{
DestinationString->Buffer[SourceLength / sizeof(WCHAR)] = UNICODE_NULL;
}
}
}
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
moonife, 你的源码哪里拿的?
我看MSDN上,没看到有说 RtlInitUnicodeString 会指向新分配的缓冲区
|
|
|