IsProcessInJob 与 GetCurrentProcess 远离 true

发布于 2024-12-01 13:41:04 字数 778 浏览 1 评论 0原文

(Visual Studio 2010 - C++) 您好,

我正在尝试将作业设置为进程,但AssignProcessToJobObject 返回ACCESS_DENIED 并且IsProcessInJob 返回TRUE。

我在调用 CreateProcess (Suspended) 后立即调用 IsProcessInJob 到进程,并尝试使用我的进程调用 IsProcessInJob(主入口点后几行),它返回 true。

void main()
{   
    BOOL bIsInJob;

    IsProcessInJob( GetCurrentProcess(), NULL, &bIsInJob );
    printf( "IsProcessInJob (me): %s\n", bIsInJob ? "true" : "false" ); 
// RET True ! inside and outside IDE
   ...

以前有人看过吗?

感谢您的任何帮助。 资料来源: 当父进程被终止时终止子进程 如何自动销毁 Windows 中的子进程?

(Visual Studio 2010 - C++)
Hello,

I'm trying to set a JOB to a process, but AssignProcessToJobObject returns ACCESS_DENIED and IsProcessInJob returns TRUE.

I call IsProcessInJob to a process immediately after call CreateProcess (Suspended) end tried call IsProcessInJob with my process (a few lines after main entry point) and it returns true.

void main()
{   
    BOOL bIsInJob;

    IsProcessInJob( GetCurrentProcess(), NULL, &bIsInJob );
    printf( "IsProcessInJob (me): %s\n", bIsInJob ? "true" : "false" ); 
// RET True ! inside and outside IDE
   ...

Someone saw it before?

Thanks for any help.
Sources:
Kill child process when parent process is killed
How do I automatically destroy child processes in Windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可是我不能没有你 2024-12-08 13:41:04

我发现了。

由于某种原因,我的进程是 Explorer.exe 的子进程,然后 Explorer 为我的进程设置了一个作业,记事本(我的子进程)继承了该作业。

直到使用 ProcessExplorer 才找到。我在进程列表中看不到我的进程,当我在 Winlogon->Explorer 下面找到时,我明白了。

解决方案:CREATE_BREAKAWAY_FROM_JOB

if (!CreateProcess(L"c:\\windows\\system32\\notepad.exe",  L"", NULL, NULL, FALSE,
        CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &startupInfo, &processInformation))
...

感谢您的评论、耐心和时间。

I found.

For some reason, my process was child of Explorer.exe then Explorer set a job to my process and the notepad (my child) inherits this job.

I could not find until see with ProcessExplorer. I can not saw my process in process list, when i find below Winlogon->Explorer, i understood.

Resolution: CREATE_BREAKAWAY_FROM_JOB

if (!CreateProcess(L"c:\\windows\\system32\\notepad.exe",  L"", NULL, NULL, FALSE,
        CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &startupInfo, &processInformation))
...

Thanks for your comments, patience and time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文