本文介绍了有没有一种方法,以假文件的文件SISTEM或者写一个文件,该文件只显示给我的EXE文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我写的,并且使用Adobe的ActiveX控件来显示PDF文件的应用程序。

Ok i wrote and application that use Adobe ActiveX control for displaying PDF files.

的Adobe ActiveX控件加载只能从文件系统的文件。所以我NEAD养活一个文件路径该控件。

Adobe ActiveX control load files only from file system. So i nead to feed a file path to this control.

问题是,我不希望存储在文件系统中的PDF文件。事件暂时的! 我wan't只存储在内存中我的PDF文件,我想使用的Adobe ActiveX控件。

Problem is that i don't want to store PDF files on file system. Event temporary! I wan't to store my PDF files only in memory, and i want to use Adobe ActiveX control.

所以我NEAD:

1)的方式来在文件系统上的假文件。因此,这种控制会认为,有一个文件,但会从内存中加载它

1) A way to fake file on a file system. So this control would "think" that there is a file, but would load it from memory

2)的方式来创建文件系统的文件,这将是看得见只有一个应用程序,所以我的PDF控制可以加载它,其他用户甚至不会看到它。

2) A way to create file on file system that would be "visible" to only one application, so my PDF control could load it, and other users won't even see it..

3)有些东西

PS:我不要求为完成我的家庭作业,我只是问 - 是有办法做到这一点

推荐答案

可以的几乎的做到这一点(意思是:没有你,但你可以做一些接近)。

You can almost do it (means: no you can't, but you can do something that comes close).

创建具有 FILE_ATTRIBUTE_TEMPORARY文件确实的原则创建一个文件,暂时的。但是,只要有足够的缓冲区缓存(通常总​​是这样的,除非你的文​​件是几十到几百兆),系统的不会写入到磁盘的。这不只是发生的事情accidentially,但这种标志的实际指定的行为。

Creating a file with FILE_ATTRIBUTE_TEMPORARY does in principle create a file, temporarily. However, as long as there is sufficient buffer cache (which is normally always the case unless your file is tens to hundreds of megabytes), the system will not write to disk. This is not just something that happens accidentially, but the actual specified behaviour of this flag.

此外,指定 0 的共享模式和 FILE_FLAG_DELETE_ON_CLOSE 将prevent任何其他进程无法打开文件只要你保持开放,即使有人知道它的存在,该文件将消失当您关闭它。即使你的应用程序崩溃,操作系统会清理你身后(DRM是否就是这个道理)。如果您在超级偏执模式,并担心该系统蓝色屏蔽,而你的文件存在,你还可以安排一个悬而未决的举动了。这会,万一系统崩溃,启动过程中删除该文件。

Further, specifying 0 as share mode and FILE_FLAG_DELETE_ON_CLOSE will prevent any other process from opening your file for as long as you keep it open, even if someone knows it's there, and the file will "disappear" when you close it. Even if your application crashes, the OS will clean up behind you (if DRM is the reason). If you're in super paranoia mode and worried about the system bluescreening while your file exists, you can additionally schedule a pending move too. This will, in case of a system crash, remove the file during boot.

最后,鉴于NTFS,您可以创建一个备用流,随机,preferrably唯一的名称(文件或UUID的如SHA1)上的任何文件,甚至目录。目录上的备用流是......一种讨厌的黑客攻击,但完全合法,他们工作得很好,并不会出现在资源管理器中。这不会的真正的使你的文件不可见,但几乎左右(几乎在每一个实际的方面,反正)。如果你是一个好公民,你将要使用的系统临时文件夹这样的事,而不是程序文件夹,或者你不应该写到其他地方。
创建一个备用流死了也很简单,只需使用普通的文件或目录名,并附加一个冒号()和你想要的流的名字。无需额外的API需要。

Lastly, given NTFS, you can create an alternate stream with a random, preferrably unique name (e.g. SHA1 of the document or a UUID) on any file or even directory. Alternate streams on directories are ... a kind of nasty hack, but entirely legal and they work just fine, and don't appear in Explorer. This will not really make your file invisible, but nearly so (in almost every practical aspect, anyway). If you're a good citizen, you will want to use the system temp folder for such a thing, not the program folder or some other place that you shouldn't write to.
Creating an alternate stream is dead easy too, just use the normal file or directory name and append a colon (:) and the name of the stream you want. No extra API needed.

除此之外,它变得有点困难。你当然可以随时创建类似一个虚拟盘(将是艰难的把它藏起来,虽然),或尝试使用的流从内存中的功能之一愚弄应用到从内存缓冲区中的文件的指控阅读......但是这不平凡的东西。

Other than that, it gets kind of hard. You can of course always create something like a ramdisk (would be tough to hide it, though), or try to use one of the stream-from-memory functions to fool an application into reading from a memory buffer on the allegation of a file... but that's not trivial stuff.

这篇关于有没有一种方法,以假文件的文件SISTEM或者写一个文件,该文件只显示给我的EXE文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 01:19