运行句柄已打开的文件(C++ winapi)
我在我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您无法锁定整个文件,因此可以使用
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).