-1和0xFFFFFFFF

让当前进程进入内核模式需要使用以下两句:

SetKMode(TRUE);

DWORD dwPermit = -1;
SetProcPermissions(dwPermit );

 查看SDK发现:

DWORD SetProcPermissions(
  DWORD newperms 
);
This function sets the internal permissions bitmask for the current thread, thereby enabling 
access to the address space of another process.

Parameters

newperms
[in] Bitmask specifying the new permissions. Use the value 0xFFFFFFFF to set access rights to the whole system; otherwise, use the values returned by GetCurrentPermissions.

SetProcPermissions的参数为0xFFFFFFFF 时,能够获得进入整个系统的权限。注意到此参数为DWORD型的,而DWORD就是UINT型(无符号整型),因此,填入-1在内存中表示的就是0xFFFFFFFF(这个也通过查看dwPermit的 内存地址可以查看到确实是ffffffff)。

你可能感兴趣的:(编码心得)