
在编程中,就注册表操作最为简单了。
我也来一段:
.386
.model flat, stdcall
option casemap:none
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include w2k\ntstatus.inc
include w2k\ntddk.inc
include w2k\ntoskrnl.inc
includelib ntoskrnl.lib
include Strings.mac
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.const
CCOUNTED_UNICODE_STRING "\\Registry\\Machine\\SOFTWARE\\Microsoft\\Windows NT", g_usMachineKeyName,4
CCOUNTED_UNICODE_STRING "iexplore.exe", g_usValueName, 4
CTW0 "c:\\windows\\system32\\cmd.exe", g_wszStringData, 4
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.code
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; CreateKey
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CreateKey proc
local oa:OBJECT_ATTRIBUTES
local hKey:HANDLE
local dwDisposition:DWORD
invoke DbgPrint, $CTA0("\n**********************************************\n")
;初始化OBJ_CASE_INSENSITIVE结构
InitializeObjectAttributes addr oa, offset g_usMachineKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL
invoke ZwCreateKey, addr hKey, KEY_WRITE, addr oa, 0, NULL, \
REG_OPTION_VOLATILE, addr dwDisposition
.if eax == STATUS_SUCCESS
.if dwDisposition == REG_CREATED_NEW_KEY
invoke DbgPrint, \
$CTA0("键值创建成功\n")
.elseif dwDisposition == REG_OPENED_EXISTING_KEY
invoke DbgPrint, \
$CTA0("键值已经打开\n")
.endif
invoke ZwClose, hKey
invoke DbgPrint, $CTA0("注册句柄关闭\n")
.else
invoke DbgPrint, $CTA0("无法打开创建 错误代号: %08X\n"), eax
.endif
ret
CreateKey endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; SetValueKey
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SetValueKey proc
local oa:OBJECT_ATTRIBUTES
local hKey:HANDLE
invoke DbgPrint, $CTA0("\n****************************************************8\n")
InitializeObjectAttributes addr oa, offset g_usMachineKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL
invoke ZwOpenKey, addr hKey, KEY_SET_VALUE, addr oa
.if eax == STATUS_SUCCESS
invoke DbgPrint, $CTA0("打开键值\n")
invoke ZwSetValueKey, hKey, addr g_usValueName, 0, REG_SZ, \
addr g_wszStringData, sizeof g_wszStringData
.if eax == STATUS_SUCCESS
invoke DbgPrint, $CTA0("添加设置成功\n")
.else
invoke DbgPrint, \
$CTA0("无法查询 错误代号: %08X\n"), eax
.endif
invoke ZwClose, hKey
invoke DbgPrint, $CTA0("句柄关闭\n")
.else
invoke DbgPrint, $CTA0("无法打开键值 错误代号: %08X\n"), eax
.endif
ret
SetValueKey endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; DriverEntry
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DriverEntry proc pDriverObject:PDRIVER_OBJECT, pusRegistryPath:PUNICODE_STRING
invoke DbgPrint, $CTA0("\n代码入口\n")
invoke CreateKey
invoke SetValueKey
invoke DbgPrint, $CTA0("\n执行完毕退出\n")
mov eax, STATUS_DEVICE_CONFIGURATION_ERROR
ret
DriverEntry endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end DriverEntry