找回密码
 加入
搜索
查看: 2053|回复: 6

如何hook注册表的项值变化?

[复制链接]
发表于 2009-1-6 21:21:17 | 显示全部楼层 |阅读模式
如何hook注册表的项值变化?如变化则重启.
发表于 2009-1-7 00:58:02 | 显示全部楼层
最简单的方法是循环读取注册表。如果不一样,就重启
发表于 2009-1-7 10:24:56 | 显示全部楼层
#include <date.au3>

$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\default")
$colEvents = $objWMIService.ExecNotificationQuery _
    ("SELECT * FROM RegistryKeyChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND " & _
        "KeyPath='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run'")

While 1
        Sleep(250)
    $objLatestEvent = $colEvents.NextEvent
    MsgBox(0,0,"注册表已更改")       
WEnd
 楼主| 发表于 2009-1-9 21:22:59 | 显示全部楼层
感谢小三,有没有api的函数,wmi开机运行太慢了,另外我只监控:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network
config 这个项,要怎么监控?
发表于 2009-1-10 02:12:37 | 显示全部楼层
CreateEventA
RegNotifyChangeKeyValue
WaitForSingleObject
返回WAIT_OBJECT_0为被更改
返回WAIT_ABANDONED为发生错误,可以以此做异常处理。
发表于 2009-8-6 16:15:45 | 显示全部楼层
都是天书,看不懂
发表于 2009-8-6 16:28:14 | 显示全部楼层
#include <WinAPI.au3>
#include <LocalSecurityAuthority.au3>

$hKey = _RegOpenKeyEx($HKEY_LOCAL_MACHINE, "Software\Test", $KEY_NOTIFY)
$hEvent = _RegNotifyChangeKeyValue($hKey, False, 15)
_WinAPI_WaitForSingleObject($hEvent, -1)
Msgbox(0, "", "Machine\Software\Test has changed.")
_RegCloseKey($hKey)

Func _RegNotifyChangeKeyValue($hKey, $fWatchSub = False, $iFilter = 15)
        Local $hEvent, $iResult

        $hEvent = _WinAPI_CreateEvent()
        $iResult = DllCall("Advapi32.dll", "long", "RegNotifyChangeKeyValue", _
                        "hWnd", $hKey, "int", $fWatchSub, "dword", $iFilter, _
                        "hWnd", $hEvent, "int", 1)
        Return SetError($iResult[0], 0, $hEvent)
EndFunc        ;==>_RegNotifyChangeKeyValue
LocalSecurityAuthority.au3 - http://www.autoitx.com/forum.php ... &extra=page%3D1

评分

参与人数 1金钱 +10 贡献 +5 收起 理由
afan + 10 + 5

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 23:33 , Processed in 0.084189 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表