Win32 相当于 getgid

Win32 equivalent of getgid

我正在尝试将一些 C Linux 代码转换为 Win32 C++。我有 getgid 功能。如何将此 Linux C 函数转换为 Win32?

这是 getgid 的文档:http://man7.org/linux/man-pages/man2/getgid.2.html

这里是使用上下文:

struct SEC_CONTEXT* scx;
scx->gid = getgid();

其中 SEC_CONTEXT 定义为:

struct SEC_CONTEXT {
ntfs_volume* vol;
gid_t gid; /* gid of user requesting (not the mounter) */
pid_t tid; /* thread id of thread requesting */
};

此外,这个对象,scx,在ntfs_mapping函数内部使用,等等......和git_t 是一个简单的 unsigned int.

Windows 没有 POSIX 进程组的概念。使该代码可移植需要了解组 ID 的用途。

不过,作为灵感,下面是 GnuWin 的实现方式:

/* Get the real group ID of the calling process.  */
gid_t
__getgid ()
{
  return 0;
}

getpgid 获得了一个更有用的值,因为默认情况下,windows 按父 PID 对进程进行分组;所以组 ID 等于进程 ID 值。