C'est ce qui empêche un programme d'aller lire/écrire ailleurs en mémoire que dans son segment de data. Enfin dans les systèmes qui l'intègrent

Ximoon :
Memory Mangement Unit
C'est ce qui empêche un programme d'aller lire/écrire ailleurs en mémoire que dans son segment de data. Enfin dans les systèmes qui l'intègrent
__attribute__((regparm))void *ALLOC_MEM(short mem_to_alloc) { mem_to_alloc=mem_to_alloc+2; if(Mem_aviable<mem_to_alloc) { BLOC[nb_ko]=malloc(1024); BLOC_p = BLOC[nb_ko]; memset(BLOC_p,0,1024); nb_ko++; Mem_aviable=1024; } Mem_aviable = Mem_aviable - mem_to_alloc; void *sav = BLOC_p; BLOC_p++; return sav; }
// Pour le texte void *BLOC[64]; void *BLOC_p; BLOC_p=BLOC[0]=malloc(1024); memset(BLOC_p,0,1024); short Mem_avaible=1024; short nb_ko=1; __attribute__((regparm))void *ALLOC_MEM(short mem_to_alloc) { if(Mem_avaible<mem_to_alloc) { BLOC[nb_ko]=malloc(1024); BLOC_p = BLOC[nb_ko]; memset(BLOC_p,0,1024); nb_ko++; Mem_avaible=1024; } Mem_avaible = Mem_avaible - mem_to_alloc; void *sav = BLOC_p; BLOC_p = BLOC_p+mem_to_alloc; return sav; } // Pour les paramètres void *PARAM_BLOC[64]; void *PARAM_BLOC_p=PARAM_BLOC[0]=malloc(1024); short param_mem=1024; short nb_ko_param=1; memset(PARAM_BLOC_p,0,1024); void *ALLOC_PARAM_MEM(short mem_to_alloc) { if(param_mem<(signed)mem_to_alloc) { PARAM_BLOC[nb_ko_param]=malloc(1024); PARAM_BLOC_p = PARAM_BLOC[nb_ko_param]; memset(PARAM_BLOC_p,0,1024); nb_ko_param++; param_mem=1024; } param_mem = param_mem - (mem_to_alloc); void *sav = PARAM_BLOC_p; PARAM_BLOC_p=PARAM_BLOC_p +mem_to_alloc; return sav; }
void *BLOC_p; BLOC_p=BLOC[0]=malloc(1024); memset(BLOC_p,0,1024); short Mem_avaible=1024; short nb_ko=1; __attribute__((regparm))void *ALLOC_MEM(short mem_to_alloc) { if(Mem_avaible<mem_to_alloc) { BLOC[nb_ko]=malloc(1024); BLOC_p = BLOC[nb_ko]; memset(BLOC_p,0,1024); nb_ko++; Mem_avaible=1024; } Mem_avaible = Mem_avaible - mem_to_alloc; void *sav = BLOC_p; BLOC_p = BLOC_p+mem_to_alloc; return sav; }
void *ALLOC_MEM(short mem_to_alloc) { if(mem_avaible<(signed)mem_to_alloc) { FILE *File =fopen("debugp","w+"); fwrite(File,1024,1,BLOC_p); fclose(File); BLOC[nb_ko]=malloc(1024); BLOC_p = BLOC[nb_ko]; memset(BLOC_p,0,1024); nb_ko++; mem_avaible=1024; }
Raphaël
: Ah oui, c'est fprintf() ?
Kevin Kofler
:Raphaël
: Ah oui, c'est fprintf() ?
fprintf, fputs, putc, fputc. Bref, tout ce qui travaille sur des caractères.
FILE *File=fopen("aemlpe","w"); short i=0; unsigned char *str = TEXT_BLOC[0]; for(i=0;i<1024;i++) { fputc(str[i],File); }
The argument mode points to a string. If the string is one of the following, the file is
open in the indicated mode. Otherwise, the behavior is undefined.214)
r open text file for reading
w truncate to zero length or create text file for writing
a append; open or create text file for writing at end-of-file
rb open binary file for reading
wb truncate to zero length or create binary file for writing
ab append; open or create binary file for writing at end-of-file
r+ open text file for update (reading and writing)
w+ truncate to zero length or create text file for update
a+ append; open or create text file for update, writing at end-of-file
r+b or rb+ open binary file for update (reading and writing)
w+b or wb+ truncate to zero length or create binary file for update a+b or ab+ append; open or create binary file for update, writing at end-of-file