# thread.token 库模块帮助文档

## thread 成员列表 <a id="thread" href="#thread">&#x23;</a>

### thread.token() <a id="thread.token" href="#thread.token">&#x23;</a>
[返回对象:processTokenObject](#processTokenObject)

### thread.token(threadHandle,access,gc) <a id="thread.token" href="#thread.token">&#x23;</a>
获取线程令牌，返回 process.token 对象。  
@threadHandle 参数指定线程句柄，省略取当前线程句柄，  
access指定访问权限,省略时默认值为 _TOKEN_QUERY  
@gc 指定返回对象在回收时默认自动调用close函数，省略时默认为 true

## thread.token 成员列表 <a id="thread.token" href="#thread.token">&#x23;</a>

获取线程令牌

获取线程令牌，返回 process.token 对象。  
未切换认线程令牌的默认状态回 null

### thread.token.impersonate(process,proc,...) <a id="thread.token.impersonate" href="#thread.token.impersonate">&#x23;</a>

```aardio
thread.token.impersonate(process,proc,...impersonate("winlogon.exe",function(...){
	/*模拟目标进程安全上下文。  
@process 参数指定进程对象、句柄、或已执行文件名，  
指定系统进程 winlogon.exe 可获取 SYSTEM 身份，进程需要管理权限。  
@proc 参数指定设置模拟令牌期间执行的回调函数。  
其他调用参数传递给被调用的回调函数。  
此函数返回回调函数的第一个返回值。  
如果要模拟 trustedInstaller 服务权限请改用 thread.trustedInstaller（需导入库）。*/
})
```

