进程 ID 和进程句柄有什么区别 [英] What's the differences between a Process ID and a Process handle

查看:94
本文介绍了进程 ID 和进程句柄有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进程 ID 是唯一标识进程的数字.进程句柄也是唯一标识进程内核对象的编号.

A process ID is a number that uniquely identifies a process. A process handle is also a number that uniquely identifys a process kernal object.

为什么我们同时需要它们,因为它们中的任何一个都可以识别一个进程.

Why do we need them both since either of them can identify a process.

我认为答案可能在于进程和进程内核对象之间的映射关系.是否可以将多个进程内核对象映射到单个进程?每个进程内核对象都有自己的进程句柄.这样每个进程内核对象都可以代表不同的访问模式或类似的东西.

I think the answer may lie in the mapping relationship betweeen a process and a process kernel object. Is it true that more than one process kernel objects can be mapped to a single process? And each process kernel object has its own process handle. So that each of the process kernel object could represent different access mode or things like that.

这个问题是我在使用 MiniDumpWriteDump() 函数,声明如下:

This question came to me when I am using the MiniDumpWriteDump() function, which is declared like this:

BOOL WINAPI MiniDumpWriteDump(
  __in  HANDLE hProcess,
  __in  DWORD ProcessId,
  __in  HANDLE hFile,
  __in  MINIDUMP_TYPE DumpType,
  __in  PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
  __in  PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
  __in  PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);

所以它的参数包括进程ID和进程句柄.我只是不知道为什么有必要同时拥有它们.

So it's parameters include both process id and process handle. I just don't know why it's necessary to have them both.

非常感谢您的见解.

推荐答案

Process Handle is

Process Handle is

  1. 任意
  2. 获取它的过程的内部.私有且不能在线程/进程之间共享
  3. 它也带有安全访问权限

虽然进程 ID 是

  1. 独一无二
  2. 通用、公共,因此可以在线程/进程之间共享

这篇关于进程 ID 和进程句柄有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆