 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
skinhat@gmail.com Guest
|
Posted: Sat Jan 29, 2005 8:29 am Post subject: Hiding files |
|
|
I have a game written in Delphi (with GLScene) that uses hundreds of
textures, models, maps which I dont want people to have access to when
they install my game. Is it possible to create something like an
encrypted disk (eg like www.dekart.com) that I could put all my
textures etc onto and only my application can access it? I could then
include the crypted disk in the install (if its a single file like
Dekart). I would prefer not to have to change my code to decrypt
crypted files and also would prefer to not write code that would
encrypt hundreds of files every time I want to create an install.
|
|
| Back to top |
|
 |
e.a Guest
|
Posted: Sat Jan 29, 2005 12:36 pm Post subject: Re: Hiding files |
|
|
[email]skinhat (AT) gmail (DOT) com[/email] wrote:
| Quote: |
uses hundreds of
textures, models, maps which I dont want people to have access to when
they install my game.
|
I don't know game programming technics enough, so I have to ask that are
those textures and pictures on the disk in some common graphic formats
like, BMP, JPG, PNG etc.?
| Quote: | Is it possible to create something like an
encrypted disk (eg like www.dekart.com) that I could put all my
textures etc onto and only my application can access it? I could then
include the crypted disk in the install (if its a single file like
Dekart).
|
With my current knowledge, instead of starting to consider any extra
RAM-DISK style solution, I would start thinking how I could just crypt
those texture files, so they would not be easy to open with common
graphic tools.
| Quote: | I would prefer not to have to change my code to decrypt
crypted files
|
Why not? Do you think it would add too much complexity to your current
work, or are you afraid that decrypting would take too many
milliseconds, or what is the problem?
When some common procedure will read the encrypted texture from the disk
with TStreams, do the de-crypting, and pass the pointer to the texture
to tour app. I do not see that it should add very much complexity to the
whole application after all.
| Quote: | and also would prefer to not write code that would
encrypt hundreds of files every time I want to create an install.
|
I do not see why exactly you see some difficulty in here. A Computer
program will easily crypt 500 textures and files, 200 MB size or so, and
burn them to your distribution CD while you drink a cup of coffee.
But after all, I am not a game programmer, and I do not know the
problems on that area.
e.a.
|
|
| Back to top |
|
 |
Tom de Neef Guest
|
Posted: Sat Jan 29, 2005 1:57 pm Post subject: Re: Hiding files |
|
|
<skinhat (AT) gmail (DOT) com> schreef in bericht
news:1106987365.883857.79590 (AT) c13g2000cwb (DOT) googlegroups.com...
| Quote: | I have a game written in Delphi (with GLScene) that uses hundreds of
textures, models, maps which I dont want people to have access to when
they install my game. Is it possible to create something like an
encrypted disk (eg like www.dekart.com) that I could put all my
textures etc onto and only my application can access it? I could then
include the crypted disk in the install (if its a single file like
Dekart). I would prefer not to have to change my code to decrypt
crypted files and also would prefer to not write code that would
encrypt hundreds of files every time I want to create an install.
|
When you use a Tstream to read from file, you can easily introduce a
descendant to decrypt on-the fly, such as here:
function TxorEncryption.Read(var Buffer; Count: Longint): Longint;
type
TBytes = array[0..MaxInt - 1] of Byte;
var
k : integer;
b : byte;
begin
result:= inherited read(Buffer,count);
for k:=0 to result-1 do
begin b:=Tbytes(Buffer)[k];
b:=SHUFFLE(b,key,false);
Tbytes(Buffer)[k]:=b
end;
end;
The complexity is in creating your encrypted files. That requires an extra
step in the development of your application. I have solved that by
introducing a separate source directory - which will not be distributed. On
application start, encrypted file dates are compared with source file dates
(if present) and if the source is newer, a new encrypted file is made with
the write counterpart of teh above:
function TxorEncryption.Write(const Buffer; Count: Longint): Longint;
type
TBytes = array[0..MaxInt - 1] of Byte;
var
k : integer;
b : byte;
begin
result:=0;
for k:=0 to count-1 do
begin b:=Tbytes(Buffer)[k];
b:=SHUFFLE(b,key,true);
result:=result+ inherited write(b,1)
end
end;
So, it is pretty automatic and the user never sees any of it since the step
is bypassed when the source dir is not present. I use two levels of
encryption: DES for really sensitive data and rotating XOR for other data.
The XOR decryption is very fast, but when you start using DES on large
files, you will notice the clock ticking.
Tom
|
|
| Back to top |
|
 |
Jamie Guest
|
Posted: Sat Jan 29, 2005 7:54 pm Post subject: Re: Hiding files |
|
|
[email]skinhat (AT) gmail (DOT) com[/email] wrote:
| Quote: | I have a game written in Delphi (with GLScene) that uses hundreds of
textures, models, maps which I dont want people to have access to when
they install my game. Is it possible to create something like an
encrypted disk (eg like www.dekart.com) that I could put all my
textures etc onto and only my application can access it? I could then
include the crypted disk in the install (if its a single file like
Dekart). I would prefer not to have to change my code to decrypt
crypted files and also would prefer to not write code that would
encrypt hundreds of files every time I want to create an install.
create a Db file with an entry header. |
you will need to create a util to do this.
at the start of the games init, read the
portion of the file you want.
|
|
| Back to top |
|
 |
skinhat@gmail.com Guest
|
Posted: Sat Jan 29, 2005 10:17 pm Post subject: Re: Hiding files |
|
|
| Quote: | uses hundreds of
textures, models, maps which I dont want people to have access to
when
they install my game.
|
I don't know game programming technics enough, so I have to ask that
are
those textures and pictures on the disk in some common graphic
formats
like, BMP, JPG, PNG etc.?
Skinhat>yes
| Quote: | I would prefer not to have to change my code to decrypt
crypted files
|
Why not? Do you think it would add too much complexity to your
current
work, or are you afraid that decrypting would take too many
milliseconds, or what is the problem?
skinhat>Its mainly that I use an opensource library (glscene) and it
has routines like TActor.loadfromfile TGlFreeform.loadfromfile. Every
time I check in the latest code from sourcesafe I'd have to be sure
that my file decryption changes remain in the source code.
When some common procedure will read the encrypted texture from the
disk
with TStreams, do the de-crypting, and pass the pointer to the
texture
to tour app. I do not see that it should add very much complexity to
the
whole application after all.
|
|
| Back to top |
|
 |
skinhat@gmail.com Guest
|
Posted: Sat Jan 29, 2005 10:20 pm Post subject: Re: Hiding files |
|
|
I use an opensource library (glscene) to load things likes actors,
models etc. It has routines like TActor.loadfromfile
TFreeform.loadfromfile. Would it be possible to use your method without
changing the original source code of the open source library? Otherwise
every time I check in the latest code from source safe (from Glscene)
I'd have to remember to make sure my decryption changes remain in the
source.
|
|
| Back to top |
|
 |
Tom de Neef Guest
|
Posted: Sat Jan 29, 2005 11:14 pm Post subject: Re: Hiding files |
|
|
<skinhat (AT) gmail (DOT) com> schreef in bericht
news:1107037243.063243.26780 (AT) z14g2000cwz (DOT) googlegroups.com...
| Quote: | I use an opensource library (glscene) to load things likes actors,
models etc. It has routines like TActor.loadfromfile
TFreeform.loadfromfile. Would it be possible to use your method without
changing the original source code of the open source library? Otherwise
every time I check in the latest code from source safe (from Glscene)
I'd have to remember to make sure my decryption changes remain in the
source.
|
You define
TencryptedActors = class(Tactors)
procedure LoadFromEncryptedFile(filename : string);
procedure SaveToEncryptedFile(filename : string);
end;
So you don't change your open source opjects.
In the new read and write procedures it would be best if you could
read/write the whole datablock of your object. But if the object contains
other objects, that's not possible. Then you will have to handle every
element of the object by itself. Maybe others have a better idea.
Tom
|
|
| Back to top |
|
 |
e.a Guest
|
Posted: Sun Jan 30, 2005 12:39 pm Post subject: Re: Hiding files |
|
|
Tom de Neef wrote:
| Quote: |
TencryptedActors = class(Tactors)
procedure LoadFromEncryptedFile(filename : string);
procedure SaveToEncryptedFile(filename : string);
end;
Maybe others have a better idea.
|
No, that is just the standard Delphi and VCL way to handle this kind of
things.
The application code that goes to the game itself, to the players,
probably will not even need the SaveToEncryptedFile procedure. I
understood that players only read the textures, never write them back.
| Quote: | But if the object contains other objects, that's not possible.
|
I understood that only those simple texture pictures (maybe JPG ??) will
be loaded to the game.
If the original questioner is not able to write the changes
TencryptedActors class, maybe he/she should post the core part about the
Tactors.LoadFrom file part here. Then maybe Tom or someone else is able
to add the few lines of code that it actually needs more.
a.e
|
|
| Back to top |
|
 |
Michael Brown Guest
|
Posted: Sun Jan 30, 2005 1:47 pm Post subject: Re: Hiding files |
|
|
Tom de Neef wrote:
[...]
| Quote: | I use two
levels of encryption: DES for really sensitive data and rotating XOR
for other data. The XOR decryption is very fast, but when you start
using DES on large files, you will notice the clock ticking.
|
That's when you bring out the Big Stick that is asynchronous I/O I've got
a (not-quite-finished ) TStream descendant that does I/O completion-port
based reading and writing, and I can strap up to 16-round AES onto it before
CPU usage (Duron 1600) hits 100%. Up until this point, there is no
measurable performance loss (always 14.5 MBytes/sec for the particular
~150MB file I use for tests, which is the same as if I used a TFileStream)
when operating off a (defragged) disk, though obviously it's slower when the
file is sitting in the cache. Once I get my hands on a *good* AES
implementation (such as porting Brian Gladman's ~17cycles/byte code to
Delphi) it should give a bit more headroom, especially on SMP/SMT machines
where the load can be effectively split.
Of course, using completion ports to do this is probably in the realm of
severe overkill. You could do things much more simply (and possibly more
efficiently) using one thread to do blocked reading an another thread per
CPU to do decryption/encryption. But I was curious about completion ports,
and async I/O with multiple threads is *so* much fun to play with ;)
--
Michael Brown
www.emboss.co.nz : OOS/RSI software and more
Add michael@ to emboss.co.nz ---+--- My inbox is always open
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|