Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Protected Asset Support  (Read 4361 times)

0 Members and 1 Guest are viewing this topic.

gamecreator

  • Newbie
  • *
  • Posts: 17
    • View Profile
Protected Asset Support
« on: February 06, 2018, 09:35:54 am »
It is a standard feature in most engines to be able to package your files and have them be protected at least minimally.  I'm under the impression that SFML doesn't do this and I'd ask that it be implemented.

I'm aware that a dedicated person can hack/rip whatever they want but this is coverage for two things:

1.  The majority of the people so that they can't just navigate to the folders of resources and freely take whatever they want.
2.  Many assets you purchase require that you protect them with at least a basic layer of a password protected file or similar.

It also makes your folders cleaner to have a single resource file instead of thousands of them.

Thanks for considering.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Protected Asset Support
« Reply #1 on: February 06, 2018, 10:08:59 am »
SFML is not an engine. We simply provide a higher level API to lower level APIs, as such you can't expect to see engine-level feature provided by SFML.

Resource management is something that can be implemented in a thousand different ways and it highly depends on the developer's use case. Some need speed for loading things, some need more obfuscation, some don't need anything.

SFML provides stream classes which are supported by all the resources, that way anyone can implement their own obfuscation system and simply implement the stream interface to work properly.

As an example you can look at PhysicsFS and FRex's stream implementation. It's really simple to write such "adapters" and it works for anything you decide to go with, but yes, it means you'll have to write some code. Just to repeat, SFML is not an engine and it's not trying to be one. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Protected Asset Support
« Reply #2 on: February 06, 2018, 01:45:37 pm »
Quote
1.  The majority of the people so that they can't just navigate to the folders of resources and freely take whatever they want.
Majority of people just don't care.

Quote
2.  Many assets you purchase require that you protect them with at least a basic layer of a password protected file or similar.
I've never heard of that. Can you link me to some of such asset sales or requirements?

You are conflating two features (security and packing) here. You can encrypt files without packing them and pack them without encrypting them (or do both at once in various ways or neither).

If you want just single file packages then use physfs or sqlite3 directly. They are easy enough to use as is and there probably are C++ libraries for them too. With how SFML's policy on stuff like that is it's really unlikely that it'll ever be integrated in any way.

If you want some actual encryption too then you can try use some encrypted archive format or encrypt and decrypt individual files or pieces of data (from folders, zips, sqlite3 - wherever) yourself with AES or something that but if the key is in exe it'll be really easy to get it out anyway and it's a performance hit compared to just compression and reading data from disk.

Many games actually do use many files organized into folders. Some also use zip (older id tech games, Love2D) or some other special purpose but non-obfuscated format for which tools exists to work with totally freely (like grp, wad, swf, ktex, unr/utx/uax/u**) and it's just an organizational and/or performance thing, not obfuscation or security feature.

Tons of engines and games use packages but the only engine off the top of my head I know of that has actual encryption is Irrlicht (it has AES for zips).
« Last Edit: February 06, 2018, 01:47:17 pm by FRex »
Back to C++ gamedev with SFML in May 2023

gamecreator

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Protected Asset Support
« Reply #3 on: February 06, 2018, 11:36:11 pm »
I use Leadwerks right now where you can publish projects which can automatically zip and password protect your assets, with a password only the engine developer knows.  When an asset is loaded, the engine checks to see if it's in the zip file.  If it is, it loads it from there.  You can also use your own zips with your own passwords or not zip your assets at all.  It's a convenient option.

Thanks for considering.  It's great to have the options mentioned but I think many users would appreciate it being part of SFML, especially if it's as automated as in Leadwerks or Unity.
« Last Edit: February 07, 2018, 12:13:26 am by gamecreator »

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Protected Asset Support
« Reply #4 on: February 07, 2018, 11:34:14 am »
If the exe can decrypt the files then the password must be in there and it'd not be that hard to dig out for a determined person or they can get the data from RAM or GPU itself at runtime, it's also a performance hit unless they have a really optimized implementation of their encryption.

I'm not sure if Unity actually encrypts or only packs the assets and Leadwerks and Unity are fully inclusive engines that are supposed to cover every gamedev need and SFML is just a multimedia library.

Using loadFromMemory and loadFromStream you can use any archive or encryption yourself and it's just as easy and convenient.

I don't think you should worry about encryption and just stick to packing and compression and PhysFS would be the best for that and it's very easy and convenient to use because it's meant for games (it has a virtual filesystem so you can use loose files when making a game and pack it for release and it's easy to release patch archives to override some of the assets). If you want to obfuscate it a bit (without encryption) you can pick one of the more exotic archive formats it supports and change the archive extension when you release the game.

You should check out the links exploiter provided:
« Last Edit: February 07, 2018, 11:56:41 am by FRex »
Back to C++ gamedev with SFML in May 2023

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Protected Asset Support
« Reply #5 on: February 07, 2018, 12:18:50 pm »
Vanilla Unity won't encrypt your stuff or at least it's decryptable standalone (there are tools for this), unless you use some kind of custom formats or loaders.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Protected Asset Support
« Reply #6 on: March 03, 2018, 11:59:54 pm »
Hello

https://www.dropbox.com/sh/8bx9skafhqoxue0/AABOoDpeg3_pU3KxIyzAC4BLa?dl=0

The link brings you an application that packs a folder and all its subfolders with all their files into a file. You have to enter the "root" folder and the target file's full path. If both strings are always the same every time you update your data file, you can create a TXT file which contains both strings in one each lines and browse that file by clicking the "Read from TXT" button, what is easier than typing the strings.

In your game or program, you would have to include the class LoadData that is in the C# file included in the folder. Maybe needs translation to C++ (be careful with data types' sizes).

First you need to instanciate the class passing the data file's full path (or relative). To "open" a file you need to call GetFileContent() function passing the folder full path (from the very very root, i.e. C:\\) and assign it to byte[] array that then you pass to the media (Music, Image, etc) you want to load.

I know it could be improved much. But it works fine. Actually, in my poor Super Mario Game.

Regards
Pablo


 

anything