Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,182 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 4 of 8 1 2 3 4 5 6 7 8
Re: Your own RESOURCE file without A6PRO edition [Re: Matt_Coles] #55055
11/05/05 02:52
11/05/05 02:52
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline
Senior Developer
Josh_Arldt  Offline
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
Thanks Lion_TS. You are a very helpfull person.
I look foward to more of your contributions.

Re: Your own RESOURCE file without A6PRO edition [Re: Josh_Arldt] #55056
11/06/05 20:12
11/06/05 20:12
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline
Serious User
JetpackMonkey  Offline
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
Hi There

Looks like this is a really powerful tool, but I do not really grasp what at a Resource file is. Anyone care to explain?

Would this make a game smaller (like that comment about a 200 MB game smaller like 70 MB?)

How is this different from file packers? Etc!

Thanks

Re: Your own RESOURCE file without A6PRO edition [Re: JetpackMonkey] #55057
11/06/05 21:02
11/06/05 21:02
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline
Senior Member
Sinthoras  Offline
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
Here, it is only a normal .zip file, packed with a normal zip program, and also unpackable by one (if you know the password )
The file size is decreasing by the way of packing the data. Maybe there is a special way that you have to use for this "plugin", but it is definately zipped..

The "resource files" of the pro edition are a bit different from that, because they can include all your data without setting any password or using a zip program.
But apart from that, the implementation of Lion_ts's system is that easy that you can say it is the same as in the pro edition, maybe even better than that because you can set your own password and also view your data at any time without any problems.
If i understood it right, the system just unpacks the data and stores the content in the engines virtual data space, so that it is usable.

In this way, thank you a lot, Lion!
Sinthoras

Re: Your own RESOURCE file without A6PRO edition [Re: Sinthoras] #55058
11/06/05 22:42
11/06/05 22:42
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
One question: when the password is set within the wdl files someone could search for it and unpack by hand the archive -- a bit unsecure, isnt it?

Re: Your own RESOURCE file without A6PRO edition [Re: HeelX] #55059
11/07/05 02:30
11/07/05 02:30
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
yeah, to be a bit secure we have to save coded password not in wdl. In dll itself, for example, in registry, in data file, in special disk place,... And you can store in wdl not a real password, but some way coded/scrambled/mangled one.
To provide more security you can download sources and zlib to write your own compressed format (like in a6pro, it use zlib too).

Re: Your own RESOURCE file without A6PRO edition [Re: Lion_Ts] #55060
11/07/05 20:48
11/07/05 20:48
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline
Senior Member
Sinthoras  Offline
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
sent you a PM, Lion

Re: Your own RESOURCE file without A6PRO edition [Re: Sinthoras] #55061
11/10/05 16:08
11/10/05 16:08
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline
Senior Member
Sinthoras  Offline
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
Okay, after some tests i have finished a version with password, given as parameter in c-script and then crypted to get the REAL password for the zip file.
You can get the crypted version when you call the function "encrypt(string)" in c-script. That will create a "password.txt" file, where you can see the encrypted password to copy it in your zip program.
This function is only provided in the "debug version" of the dll, if you release your game you only copy the "release version", without this encryption function.

here is the code for your dll
Code:

...
#define DLL_USE // always define before including adll.h
#include "adll.h"
#include "unzip.h"
#include "iowin32.h"

const char *zipfilename="resource.zip";

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
engine_bind();
return TRUE;
}

#define is_debug_version

int cryption_formula(int value, int value2)
{
return((value*5 + 1)%4);
}

var dll_encrypt(STRING* password)
{
int istrlen, counter=0;

istrlen = int(_FLOAT(str_len(_CHR(password))));

while(counter < istrlen)
{
password->chars[counter] += cryption_formula(counter, password->chars[counter]);
counter ++;
}
return(_VAR(1));
}

#ifdef is_debug_version
DLLFUNC var encrypt(STRING* password)
{
FILE* fp_PW_File;
int istrlen, counter=0;
char cencrypted;

istrlen = int(_FLOAT(str_len(_CHR(password))));

if(!(fp_PW_File = fopen("data\\password.txt", "w+")))
{
return(_VAR(0));
}
while(counter < istrlen)
{
cencrypted = password->chars[counter];
cencrypted += cryption_formula(counter, cencrypted);
fwrite(&cencrypted, sizeof(char), 1, fp_PW_File);
counter ++;
}
fclose(fp_PW_File);
return(_VAR(1));
}

DLLFUNC var decrypt()
{
FILE* fp_PW_File;
int counter = 0,istrlen;
char cencrypted;
char cdecrypted[200];

if(!(fp_PW_File = fopen("data\\password.txt", "r")))
{
return(_VAR(0));
}

strcpy(cdecrypted, "\n\n\n\ndecrypted: ");
istrlen = strlen(cdecrypted);

while(!feof(fp_PW_File))
{
if(!fread(&cencrypted, sizeof(char), 1, fp_PW_File) || counter > 200)
{
break;
}
cencrypted -= cryption_formula(counter, cencrypted);
cdecrypted[counter+istrlen] = cencrypted;
counter ++;
}
fclose(fp_PW_File);

if(!(fp_PW_File = fopen("data\\password.txt", "a")))
{
return(_VAR(1));
}
fwrite(&cdecrypted, sizeof(char), strlen(cdecrypted), fp_PW_File);

fclose(fp_PW_File);
return(_VAR(1));
}
#endif;

int do_extract_currentfile(unzFile uf, char* file_password)
{
char filename_inzip[256];
char* filename_withoutpath;
char* p;
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;

unz_file_info file_info;
uLong ratio=0;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);

if (err!=UNZ_OK)
{
error("Error in zipfile. Engine shutdown");
return err;
}

size_buf = file_info.uncompressed_size ;//WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
if (buf==NULL)
{
error("Unable to allocate memory. Engine shutdown");
return UNZ_INTERNALERROR;
}
p = filename_withoutpath = filename_inzip;
while ((*p) != '\0')
{
if (((*p)=='/') || ((*p)=='\\'))
filename_withoutpath = p+1;
p++;
}

err = unzOpenCurrentFilePassword(uf,file_password);
err = unzReadCurrentFile(uf,buf,size_buf);
add_buffer(filename_withoutpath,buf);
unzCloseCurrentFile (uf);

return(UNZ_OK);
}

int do_extract(unzFile uf, char* file_password)
{
uLong i;
unz_global_info gi;
int err=UNZ_OK;
FILE *fout=NULL;

err = unzGetGlobalInfo (uf,&gi);
if (err==UNZ_OK)
{
for (i=0;i<gi.number_entry;i++)
{
err = do_extract_currentfile(uf, file_password);
if ( err != UNZ_OK)
break;
if ((i+1)<gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
{
break;
}
}
}
}

return(err);
}
//NDEBUG
DLLFUNC var add_zip_resource_PW(STRING* password_str)
{
unzFile uf=NULL;
int err;

dll_encrypt(password_str);

uf = unzOpen(zipfilename);
if (uf == NULL)
{
return _VAR(-1);
}
err = do_extract(uf, _CHR(password_str));
unzClose(uf);
return _VAR(err);
}




and here the c-script
Code:

...
dllfunction add_zip_resource_PW(string1);
dllfunction encrypt(string1);
dllfunction decrypt();

Plugindir = "data";

string zip_string = "Hello! That's the sentence to all resources!";

function main()
{
encrypt(zip_string) //write password.txt
decrypt(); //decrypt password.txt again, and add the real string to the file

//add custom resources from RESOURCE.ZIP
if(add_zip_resource_PW(zip_string) == -1)
{
error("Unable to unzip file to buffer. Engine shutdown.");
exit;
}
...
}



Of course, the encryption formula is not THAT strong , you could improve the encryption of your data to much higher levels. But you have to be aware of none copy-able strings: you have to copy them from the password.txt into your zip-file.

I hope someone is interested in that
Sinthoras

Re: Your own RESOURCE file without A6PRO edition [Re: Sinthoras] #55062
11/10/05 16:14
11/10/05 16:14
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I'm currently not able to compile a dll, can you please do that?

Ciao

Re: Your own RESOURCE file without A6PRO edition [Re: HeelX] #55063
11/10/05 16:21
11/10/05 16:21
Joined: Mar 2005
Posts: 309
Germany, Bavaria
Sinthoras Offline
Senior Member
Sinthoras  Offline
Senior Member

Joined: Mar 2005
Posts: 309
Germany, Bavaria
I have no web space, should i send it to you by mail?

Re: Your own RESOURCE file without A6PRO edition [Re: Sinthoras] #55064
11/10/05 18:50
11/10/05 18:50
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
Same prolem as HeelX has.. if ye can, sen it to my mail: inestical[at]luuku.com

would appreciated


"Yesterday was once today's tomorrow."
Page 4 of 8 1 2 3 4 5 6 7 8

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1