有没有办法在磁盘上查找文件的确切位置(adress)?
我正在开发一个使用C ++的软件,用于Windows/Linux。
我想在运行时创建一个文件(TXT,JSON,许可证,您将其命名),然后将其保存在某个地方。在C ++中,是否有可能在磁盘上获得该文件的确切位置,以便我重新启动应用程序并阅读该地址(或其他),我将能够访问其数据?
这样做的目的是,如果有人将软件复制到另一个OS或创建OS的图像并试图运行该软件,则地址将不再有效,并且会失败。这是试图添加另一层(在许可管理之上)以防止软件副本。
I'm developing a software using C++ for Windows/Linux.
I want to create a file (txt, json, license, you name it) at runtime, and save it somewhere. Is it possible in C++ to get the exact position of that file on disk, so that if I restart the app and read that address (or other), I'll be able to access its data?
The purpose of this would be that if someone copied the software to another OS, or created an image of the OS, and tried to run it, the address would not be valid anymore and it would fail. This is an attempt to add another layer (on top of license management) to protect against software copy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
磁盘的图像通过字节复制字节,这意味着磁盘上的所有地址(位置)保持完全相同。因此,您的副本保护实际上无法正常工作 - 您仍然可以在保留特殊复制保护文件的同时轻松克隆磁盘。此外,文件甚至可能在磁盘上没有定义的位置:可以将其分为许多片段并散布在整个磁盘上。您找不到不存在的地址。文件系统也可以随时随地移动文件,因此即使在同一系统上,地址也不保持相同。 (这就是碎片策略的作用。例如,Windows按照固定的时间表将文件移动,以使文件系统更快。)
Tl; Dr this无法正常工作。
An image of a disk copies it byte by byte, meaning that all addresses (locations) on disk stay exactly the same. So your copy protection won't actually work - you can still easily clone the disk while preserving your special copy protection file. Additionally, a file may not even have a defined location on disk: It may be split up into many fragments and scattered across the entire disk. You can't find an address that doesn't exist. The filesystem may also just move the file around whenever it feels like it so the address doesn't stay the same even on the same system. (This is what defragmentation does. Windows, for example, moves files around like that on a fixed schedule to make the filesystem faster.)
TL;DR this is not going to work.