windows - 当 processHandle = -1 时,这个 OpenProcessToken 做了什么?

标签 windows winapi assembly x86

我明白这是做什么的,但是如下所示将 ProcessHandle 设置为 -1 是什么意思?

.text:004011D2 83 EC 20             sub     esp, 20h
.text:004011D5 8D 04 24             lea     eax, [esp+20h+TokenHandle]
.text:004011D8 50                   push    eax          ; TokenHandle
.text:004011D9 6A 28                push    28h          ; DesiredAccess
.text:004011DB 6A FF                push    0FFFFFFFFh   ; ProcessHandle
.text:004011DD E8 96 04 00 00       call    OpenProcessToken

最佳答案

-1 进程句柄是当前进程的句柄。最好调用GetCurrentProcess相反,按照 MSDN 上的建议:

Retrieves a pseudo handle for the current process.
...
A pseudo handle is a special constant, currently (HANDLE)-1, that is interpreted as the current process handle. For compatibility with future operating systems, it is best to call GetCurrentProcess instead of hard-coding this constant value.

关于windows - 当 processHandle = -1 时,这个 OpenProcessToken 做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26772495/

相关文章:

c# - 使用 C# 在 Metro 应用程序中保存用户设置

python - 从 Python 查询 CPU ID?

winapi - CreateFile() 返回 INVALID_HANDLE_VALUE 但 GetLastError() 是 ERROR_SUCCESS

winapi - 捕获隐藏或最小化的窗口

assembly - 默认使用哪个段寄存器?

windows - 如何查看存档的证书? (例如 makecert/certmgr.msc 证书)

c++ - char* 值在分配期间被损坏

c - 使用几个线程使用 WINAPI

delphi - 更改exe中的浮点值

c - 将寄存器值读入 C 变量