如何在Windows上自动监控和限制进程资源

发布于 2024-08-19 04:19:06 字数 226 浏览 4 评论 0原文

在 Linux 上,通常我使用 ptrace 函数来跟踪所有系统调用,并在进程尝试对我的计算机执行任何有害操作时终止该进程,例如 system("shutdown -s -t 00 ”) 左右。

我有办法在 Windows 上执行此操作吗?

编辑:我想编写沙箱程序来限制其子进程的时间和内存使用量,该程序可以在 Windows 和 Linux 上运行,但现在它只能通过 ptrace 在 Linux 上运行

On Linux, normally I use ptrace function to trace all syscall, and kill the process if the it tries to do anything harmful to my machine, such as system("shutdown -s -t 00") or so.

Is there a way for me to do this on Windows?

EDIT: I want to write Sandbox program to limit time and memory usage of its child that can work on both Windows and Linux, and now it can only run on Linux via ptrace

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

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

发布评论

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

评论(3

幸福%小乖 2024-08-26 04:19:06

如果您将流程附加到 作业对象 ,可以限制进程的CPU时间和内存。这不会让您阻止 if 执行恶意操作,但它会让您实现您的要求。

If you attach your process to a Job object, you can limit the CPU time and memory of the process. That won't allow you to prevent if from performing malicious actions but it will allow you to achieve what you asked.

ι不睡觉的鱼゛ 2024-08-26 04:19:06

要在沙箱中运行应用程序,您可以使用 CreateRestrictedToken此处< /a> 有关您可以启用/禁用的权限的一些信息),请调用 ImpersonateLoggedOnUser 使用新令牌,使用 CreateProcess 启动新进程并使用 恢复到自己。我不确定在所有情况下您是否可以直接使用 CreateProcessAsUser,尝试一下。

To run an application in a sandbox you could create a new restricted access token with CreateRestrictedToken (here's some info about the privileges you can enable/disable), call ImpersonateLoggedOnUser with the new token, start the new process with CreateProcess and revert to your old token with RevertToSelf. I'm not sure if in all contexes you can instead directly use CreateProcessAsUser, give it a try.

靖瑶 2024-08-26 04:19:06

可能为时已晚,刚刚看到您的帖子,我自己也在寻找相同的功能。

我发现CPU限制1.1

你可以在这里下载它的源代码 http://www.killprog.com/etce .html

我使用得很成功,希望对你有帮助

May be too late, just came across your post looking for the same functionality myself.

I found CPU limit 1.1

You can download it here with source code http://www.killprog.com/etce.html

I'm using it very successfully, hope it helps you

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