小编Joh*_*ith的帖子

Windows 7 x86 使用 sysenter 执行直接系统调用

我正在尝试编写一些程序来直接调用系统调用而不通过 ntdll.dll

我的代码(Visual Studio 语法...):

#include <windows.h>

int main()
{
   _asm{
        push arg1
        push arg2
        push arg3
        mov eax,syscall_id
        mov edx,esp
        _emit 0xf
        _emit 0x34 //sysenter opcodes...
       }
Run Code Online (Sandbox Code Playgroud)

当程序尝试执行 sysenter 指令时,程序会因访问冲突而崩溃:

CALL DWORD PTR DS:[EAX+EDX*4] // Access Violation when reading [00000128]

EAX == 0x00000000
EDX == 0x0000004D
Run Code Online (Sandbox Code Playgroud)

我试图在所需的系统调用中使用内核调试器放置一个硬件断点,但执行流程没有到达那里......

我猜这个问题与堆栈顺序/深度有关。

非常感谢!

解决了:

我想问题是我试图在不加载 user32 和 gdi32 dll 的情况下执行 win32k 系统调用。

刚刚添加:

LoadLibraryW(L"user32.dll");
LoadLibraryW(L"gdi32.dll");
Run Code Online (Sandbox Code Playgroud)

问题解决了..

如果有人更清楚为什么不加载这些 dll 会发生这种情况,我会很高兴知道:)

windows kernel system-calls sysenter

4
推荐指数
1
解决办法
2739
查看次数

标签 统计

kernel ×1

sysenter ×1

system-calls ×1

windows ×1