运行句柄已打开的文件(C++ winapi)

发布于 2024-12-12 09:28:55 字数 271 浏览 6 评论 0原文

我在我的 C++ 应用程序中包含了一个 exe 文件作为资源,我需要运行它,但我需要限制它的访问权限,以便用户无法复制它。 我需要保持它的句柄打开,以便外部程序无法访问它,并且因为我使用 FILE_FLAG_DELETE_ON_CLOSE 作为标志,所以如果我的应用程序被终止,它将删除。

但正因为如此,我无法使用 CreateProcess() 或 WinExec() 运行它。 我知道这听起来很奇怪,但我有充分的理由。我需要这些来保护游戏的可执行文件免受 dll 注入作弊的影响,但我没有该 exe 的代码。

I included a exe file as a resource in my c++ application and i need to run it, but i need to restrict it's access alot so the user can't copy it.
I need to keep it's handle opened so external programs can't access it, and because i used FILE_FLAG_DELETE_ON_CLOSE as a flag, so it will delete if my application gets killed.

But because of that i can't run it with CreateProcess() or WinExec().
I know it sounds weird, but i have a good reason.I need those to protect the executable of a game from a dll-injection cheat, and i don't have the code of that exe.

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

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

发布评论

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

评论(1

铜锣湾横着走 2024-12-19 09:28:55

由于您无法锁定整个文件,因此可以使用 LockFile 锁定很小的一部分。您需要找到 Windows 不使用的字节范围。您可以通过向 EXE 添加虚拟资源来实现此目的。 (这不需要源代码)。

Since you can't lock the entire file, lock a very small part with LockFile. You'll need to find a byte range that Windows doesn't use. You might achieve this by adding a dummy resource to the EXE. (This does not require source code).

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