How to encrypt how to encrypt the textbook with Renderware

xiaoxiao2021-03-30  220

We currently have this project because some reasons cannot be used with SFS, Single File System, single file system. If you use SFS, you don't need to worry about the resource encrypted. For general users, the resources are put out, such as DFF, ANM, RWS, users don't know how to view these things, but textures, if they are not encrypted, you can see it with ACDSEE, this, some don't want users Things know, for example, the new product to be pushed in a few days, I know what is long in advance.

To decrypt an encrypted overview, the general approach is to read from the disk, in binary, then decrypt, then write the result back, then use rwtextureread, because RENDERWARE recognizes the format of the map file, Read in the future The result is deleted and prevent it from being seen by the user. The entire process requires 2 disk reads, 1 disk write, 1 file delete, slow, the process of Load resources is less than 2 times, the player can't stand it.

I found relevant advice from Renderware Support, and finally decided to use the file system, which is to pick a new memory file system, which is specifically encrypted. The whole process is like this: General EXAMPLE will do something first, that is, call RWImageRegisterImageFormat to register the map of the RW function, for the PNG format, generally RTPngImageRead and RTPngImageWrite. First replace the READ function, change it into your own function, this will enter your own function when using rwtextureread, this time you will pass a filename, add the FileName plus the prefix, this prefix is ​​DeviceName of the new file system, You can call it "MEM:". For example, if you want to read, you want to read "Data / Gui / Aa.png", we now let it become "MEM: /DATA/GUI/AA.PNG", then call RTPngImageRead, pass the new file name to It, this time, the new memory file system works. In this MEM FileSystem, the Open function first reads the map in a binary format. It is said that it has been encrypted, if not, then encrypt, otherwise decrypt in memory, next picture parsing process is Memory Read, because it belongs to this FileSystem's files are RW through the functions in this FileSystem. This is not encrypted by the encrypted map, it will be encrypted during the first time, and will never be encrypted later, and the encrypted map only needs a disk read.

An example of the file system can refer to the Pakfile under Example, and the file system needs the program to provide a lot of functions, and some of the unused functions are best to provide, the function body is empty, such as SYNC, do not let it be null. This is because we use RWA (Renderware Audio) in the project, and some programs of RWA need to call RTFSManagerFiles. This function will sync all functions on all file systems, by calling each FileSystem's SYNC function, if the SYNC function is null, Hang up.

转载请注明原文地址:https://www.9cbs.com/read-130500.html

New Post(0)