#include <allegro.h> #define MAX_TYPES 64 typedef struct{ char step_pos; unsigned char step_str[26]; int step_int; int step_long; }ONE_STEP; typedef struct{ char steps; ONE_STEP step[16]; char name[20]; char ext[4]; }FORMAT; char db_num; FORMAT dbase[MAX_TYPES]; // ta toto je perfekt struktura (jednoducha, prehladna :-@ ) void draw_info_from_db(char t,char y) { gotoxy(13,y); cprintf(" %s ",dbase[t].ext); gotoxy(22,y); cprintf(" %s",dbase[t].name); } void draw_info_extended_db(char t) { gotoxy(50,6);cprintf("%s",dbase[t].ext); gotoxy(50,8);cprintf("%s",dbase[t].name); } void load_database() { char tbuf[10]; PACKFILE *s; packfile_password("IdeaZ"); s=pack_fopen("filehack.fhd",F_READ); if(s==0){ s=pack_fopen("#",F_READ); if(s==0) koniec("Internal CRC error!"); } pack_fread(tbuf,10,s); if(memcmp(tbuf,"FileHacker",10)) koniec("Database CRC error!"); db_num=pack_igetw(s); s=pack_fopen_chunk(s,FALSE); pack_fread(dbase,sizeof(FORMAT)*db_num,s); s=pack_fclose_chunk(s); pack_fclose(s); /* set_config_file("filehack.dat#database.ini"); db_num=get_config_int(0,"num",0); if(db_num==0) koniec("Error reading external database!"); for(i=0;i<db_num;i++){ set_config_file("filehack.dat#database.ini"); sprintf(tbuf,"name%d",i); sprintf(tbuf,"filehack.dat#%s",get_config_string(0,tbuf,0)); set_config_file(tbuf); strcpy(name,get_config_string(0,"name","noname")); memset(dbase[i].name,' ',18); dbase[i].name[18]=0; memcpy(dbase[i].name,name,strlen(name)); strcpy(dbase[i].ext,get_config_string(0,"ext","$$$")); dbase[i].steps=get_config_int(0,"step",0); for(c=0;c<dbase[i].steps;c++){ sprintf(tbuf,"s%02d_str",c); strcpy(dbase[i].step[c].step_str,get_config_string(0,tbuf,"")); sprintf(tbuf,"s%02d_int",c); dbase[i].step[c].step_int=get_config_int(0,tbuf,0); sprintf(tbuf,"s%02d_pos",c); dbase[i].step[c].step_pos=get_config_int(0,tbuf,0); sprintf(tbuf,"s%02d_long",c); dbase[i].step[c].step_long=get_config_int(0,tbuf,0); } } */ } void dopln_ext(char name[80],int t) { strcat(name,dbase[t].ext); } int is_step(int i,int c,unsigned char text[51]) { int h; if(dbase[i].step[c].step_str[0]!=0){ if(!memcmp(dbase[i].step[c].step_str, text+dbase[i].step[c].step_pos, strlen(dbase[i].step[c].step_str))) return 1; return 0; } else{ h=text[dbase[i].step[c].step_pos]; h+=text[dbase[i].step[c].step_pos+1]*256; if(h==dbase[i].step[c].step_int) return 1; } return 0; } int look_in_database(unsigned char text[51]) { int i,c; char a; char steps; for(i=0;i<db_num;i++){ steps=dbase[i].steps; a=1; for(c=0;c<steps;c++){ if(is_step(i,c,text)==0){ a=0; break; } } if(a==1) return i; } return -1; }