以下是部分代码:
RtlInitUnicodeString(&RegString, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\自定义项");
RtlInitUnicodeString(&ValueName, L"自定义键");
//KeStallExecutionProcessor(3000);
//初始化OBJECT_ATTRIBUTE
InitializeObjectAttributes(&objAttrib, &RegString, OBJ_CASE_INSENSITIVE, NULL, NULL);
//打开注册表
status = ZwOpenKey(&hRegister, KEY_READ, &objAttrib);
if (!NT_SUCCESS(status))
{
return ((ZWCREATEFILE)(OldZwCreateFile)) (FileHandle, DesiredAccess,
ObjectAttributes, IoStatusBlock, AllocationSize, FileAttributes,
ShareAccess, CreateDisposition, CreateOptions, EaBuffer, EaLength);
}
//获取注册表键值数据长度并申请内存
……
//获取数据
status = ZwQueryValueKey(hRegister, &ValueName, KeyValuePartialInformation, KeyValue, ValueDataLen, &ValueDataLen);
if (!NT_SUCCESS(status))
{
if (hRegister != NULL)
{
ZwClose(hRegister);
hRegister = NULL;
}
if (KeyValue != NULL)
{
ExFreePool(KeyValue);
KeyValue = NULL;
}
return ((ZWCREATEFILE)(OldZwCreateFile)) (FileHandle, DesiredAccess,
ObjectAttributes, IoStatusBlock, AllocationSize, FileAttributes,
ShareAccess, CreateDisposition, CreateOptions, EaBuffer, EaLength);
}
if (hRegister != NULL)
{
ZwClose(hRegister);
hRegister = NULL;
}
请前辈指点
今天有点晚了,前辈有时间帮忙给看看吧
先谢过了 呵呵
|