Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
阅读:3487回复:30

驱动程序中如何得到线程/进程的拥有者?

楼主#
更多 发布于:2002-06-17 15:50
我想在驱动程序中得到线程或进程的拥有者(owner),即用户名,怎么实现?
比如说,在一个文件系统驱动程序中,我想判断来自LAN内正在试图访问本机的远端用户名,能做到吗?如何做?
谢谢!

最新喜欢:

hunterforpighunter...
Tom_lyd
soliseaman
驱动牛犊
驱动牛犊
  • 注册日期2002-07-02
  • 最后登录2018-05-29
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望10点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2002-08-25 18:00
收获不小,有没有相关的代码贴一点?
谢谢大侠们 :)
dotdraw
驱动牛犊
驱动牛犊
  • 注册日期2002-08-09
  • 最后登录2008-03-30
  • 粉丝0
  • 关注0
  • 积分114分
  • 威望12点
  • 贡献值0点
  • 好评度11点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-08-21 23:42
我想是的!
devil_jie
驱动牛犊
驱动牛犊
  • 注册日期2002-08-07
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-08-21 23:37
在www.sysinternals.com下可以下载tokenmon源程序,它可以得到当前活动进程(线程)的拥有者如用户名和登录ID(logonid),有了
登录ID就可以得到相应的主机名。 在WIN2000下我的办法是配置安全审核策略,远程用户登录到本机时系统会产生相应的日志文件。调用API函数可以打开日志文件取出登录ID所对应的主机名。但这种办法我感觉不好,各位大哥可否有更好的方法通过登录ID(logonid)找到对应的主机名。

[编辑 -  8/21/02 by  devil_jie]

[编辑 -  8/21/02 by  devil_jie]
guard2002
驱动中牛
驱动中牛
  • 注册日期2002-05-21
  • 最后登录2017-03-07
  • 粉丝0
  • 关注0
  • 积分46分
  • 威望65点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
  • 社区居民
地下室#
发布于:2002-06-24 15:20
good
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-06-19 10:55
     Thanks, I have seen the service, and I have had a mind of the service.
     I will try what you told me, and if any problems later, please don\'t hesitata to tell me. thanks for a second time.
Tom_lyd
zdhe
驱动太牛
驱动太牛
  • 注册日期2001-12-26
  • 最后登录2018-06-02
  • 粉丝0
  • 关注0
  • 积分72362分
  • 威望362260点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
6楼#
发布于:2002-06-19 10:36

1. What\'s a user mode service? Can I consider it as a user mode application ? Is it application ?


can not explain in several words.
you need see msdn -> platfrom sdk -> base services->service.

full documented.


2. Did you try like this in the past ? if so, can you tell me some technologies on it ?




i only does some. not all of your request.
I detect ontime access is from net or just from local account. i need not know accurate user name.

get username from sid, it should not be difficult in ring3.

in read/write phase, because sometimes IRP is not dealing in original context, so , there is no meaning for Dealing in read/write phase . in Create phase , IRP_MJ_CREATE, system always make sure it\'s in original context, then you can get username. cache it(just use filemon hash is ok), use in read/write phase.
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2002-06-19 08:26
this is from OCR. use this should work. good luck.

only thing maybe need care.
you should deal this in create phase. not read/write phase. if you want to use it in read/write, cache create phase user info youself.

 


Thans for your answer at first, I have some questions on it.
1. What\'s a user mode service? Can I consider it as a user mode application ? Is it application ?
2. Did you try like this in the past ? if so, can you tell me some technologies on it ?

thanks.
Tom_lyd
zdhe
驱动太牛
驱动太牛
  • 注册日期2001-12-26
  • 最后登录2018-06-02
  • 粉丝0
  • 关注0
  • 积分72362分
  • 威望362260点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
8楼#
发布于:2002-06-18 22:14
this is from OCR. use this should work. good luck.

only thing maybe need care.
you should deal this in create phase. not read/write phase. if you want to use it in read/write, cache create phase user info youself.

Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2002-06-18 14:42
 Q35 How do I retrieve the \"user name\" for the user performing a given operation?
  User names, per se, are not a concept of the core OS. Rather, users are tracked internally as \"security identifiers\" or SIDs. It is possible to extract the SID of the current thread. If a \"user name\" is needed, a user mode service can be used to convert from the SID to the corresponding text user name. This is done using the Win32 function LookupAccountSid, which is documented in the Platform SDK. The SID of the calling thread can be extracted from its token. This is done by first attempting to open the thread token (ZwOpenThreadTokenEx or NtOpenThreadToken or NtOpenThreadTokenEx). If this fails because the thread has no token, the filter should open the process token (ZwOpenProcessTokenEx or NtOpenProcessToken or NtOpenProcessTokenEx). In either case, the filter will have a handle for a token. The SID can be retrieved from the given token using NtQueryInformationToken or ZwQueryInformationToken. The filter should specify TokenUser as the TOKEN_INFORMATION_CLASS value. The call will return a buffer that contains the TOKEN_USER structure. This structure contains the SID of the token. Note, however, that obtaining the SID of the current caller is often not precisely what a filter is trying to accomplish. Instead, often the filter wishes to know the SID of the requesting thread. For local calls, this will typically be the same. For remote calls, however, the CIFS server routinely utilizes impersonation during IRP_MJ_CREATE and for some IRP_MJ_SET_INFORMATION operations. Otherwise, the CIFS server uses the local system\'s credentials. To handle this case, a filter must store away the credential information of the original caller. In the case of IRP_MJ_CREATE the original caller\'s token is specified as part of the IO_SECURITY_CONTEXT parameter. The ACCESS_STATE structure in turn contains the SECURITY_SUBJECT_CONTEXT and the filter can retrieve a pointer to the token using SeQuerySubjectContextToken. The SID can then be retrieved from the token using SeQueryInformationToken.
Tom_lyd
arthurtu
驱动巨牛
驱动巨牛
  • 注册日期2001-11-08
  • 最后登录2020-12-19
  • 粉丝0
  • 关注0
  • 积分26分
  • 威望161点
  • 贡献值0点
  • 好评度35点
  • 原创分0分
  • 专家分0分
  • 社区居民
10楼#
发布于:2002-06-18 09:22
还是在ring3得到?
zhangyl
驱动牛犊
驱动牛犊
  • 注册日期2001-07-18
  • 最后登录2009-03-05
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
11楼#
发布于:2002-06-18 09:15
你可以将线程句柄传给Ring3,Ring3里面自然有很多办法可以得到owner
签名是什么?
arthurtu
驱动巨牛
驱动巨牛
  • 注册日期2001-11-08
  • 最后登录2020-12-19
  • 粉丝0
  • 关注0
  • 积分26分
  • 威望161点
  • 贡献值0点
  • 好评度35点
  • 原创分0分
  • 专家分0分
  • 社区居民
12楼#
发布于:2002-06-18 09:08
和得到线程的拥有者有什么关系?
zhangyl
驱动牛犊
驱动牛犊
  • 注册日期2001-07-18
  • 最后登录2009-03-05
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
13楼#
发布于:2002-06-18 08:56
zdhe说得对,这只能是异步的,不是同步的,基本结构如下(9x):
Ring3:
     创建一个Event,并得到该Event的Ring0句柄,通过DeviceIO,将该句柄传入Ring0,Ring3创建一个Thread,该Thread等待这个Event,当这个Event signaled以后,Ring3处理。

Ring0:
     当需要调用Ring3时,设置那个Event为signaled,然后等待Ring3结束。


这里还涉及到数据传送问题,如果有问题,再和我联系
签名是什么?
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
14楼#
发布于:2002-06-18 08:25
以上各位兄弟发表了不少高见,但我还对怎样在内核态得到线程/进程的拥者还是没有思路。
Tom_lyd
zdhe
驱动太牛
驱动太牛
  • 注册日期2001-12-26
  • 最后登录2018-06-02
  • 粉丝0
  • 关注0
  • 积分72362分
  • 威望362260点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
15楼#
发布于:2002-06-17 21:42
use apc you can call ring3 from ring0.

any way, it\'a asyn, not syn call.
magicx
驱动老牛
驱动老牛
  • 注册日期2002-02-22
  • 最后登录2014-08-18
  • 粉丝1
  • 关注0
  • 积分-14分
  • 威望13点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
16楼#
发布于:2002-06-17 20:38

什么地干活?。。。。。。。。。。。



[color=red]大头鬼! :P[/color]
pjf
pjf
驱动中牛
驱动中牛
  • 注册日期2001-07-08
  • 最后登录2006-10-23
  • 粉丝0
  • 关注0
  • 积分42分
  • 威望4点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
17楼#
发布于:2002-06-17 17:51
NT一样有让你在Ring0 call Ring3的服务,只是2000似乎不再支持。
其实所谓的Ring0 Call Ring3只是造一个系统服务返回的假象,运行Ring3代码后再用门机制恢复到安全状态。有点像V86监控机与V86程序相互切换的原理。
VanCheer
驱动老牛
驱动老牛
  • 注册日期2002-02-21
  • 最后登录2003-08-28
  • 粉丝0
  • 关注0
  • 积分-20分
  • 威望-10点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
18楼#
发布于:2002-06-17 17:12
我没有研究过
估计可以从0->3

那你还说我说的不行的干活,5555555555 :(
如果用任务门可以的话,那用IDT和GDT当然也可以。
[img]http://www.driverdevelop.com/forum/upload/VanCheer/2003-03-21_mon.gif[/img][img]http://www.driverdevelop.com/forum/upload/VanCheer/2002-12-07_smallbaby.jpg[/img]
eqinzm
驱动牛犊
驱动牛犊
  • 注册日期2001-10-18
  • 最后登录2018-05-29
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望20点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
  • 社区居民
19楼#
发布于:2002-06-17 17:11
我没有研究过
估计可以从0->3
Hi
上一页
游客

返回顶部