gpt4 book ai didi

c - 调试中断 Win32 Api 函数

转载 作者:太空狗 更新时间:2023-10-29 16:52:17 24 4
gpt4 key购买 nike

我想中断 SetTimer 函数,以便查看哪些组件将哪些计时器注册为哪些值。这可能吗?

最佳答案

是的,你可以做到这一点。首先确保你有 public symbols调试器的设置。

SetTimer住在 user32 中,但这正是它导出的内容。最简单的方法是使用命令行调试器 NTSD .我们需要它的真实姓名,因此在 user32 中查找匹配的符号:

0:000> x user32!*timer*
759992b9 USER32!NtUserValidateTimerCallback = <no type information>
759977d5 USER32!NtUserSetTimer = <no type information>
759e4f13 USER32!NtUserSetSystemTimer = <no type information>
759993bf USER32!NtUserKillTimer = <no type information>

啊哈!它的调试符号是 NtUserSetTimer:

0:000> bp user32!NtUserSetTimer

在 Visual Studio 中,您可以通过编写一个简单的临时程序然后设置断点并右键单击并选择“转到反汇编”来找出 SetTimer 所在的位置:

int _tmain(int argc, _TCHAR* argv[]) {
SetTimer(NULL, 0, 0, NULL);
004113BE mov esi,esp
004113C0 push 0
004113C2 push 0
004113C4 push 0
004113C6 push 0
004113C8 call dword ptr [__imp__SetTimer@16 (418338h)]

如果我们进入那个调用,那么我们会到达这里:

_NtUserSetTimer@16:
759977D5 mov eax,123Dh
759977DA mov edx,7FFE0300h
759977DF call dword ptr [edx]
759977E1 ret 10h

因此要在 Visual Studio 中设置断点,您必须使用 context operator在断点。从菜单中选择:Debug -> New Breakpoint -> Break at Function,然后输入:

{,,user32.dll}_NtUserSetTimer@16

关于c - 调试中断 Win32 Api 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3080624/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com