okEnvoyé par farscape
et je lance bien la lecture des .dll et du .exe (pas les fichiers de code) ?
okEnvoyé par farscape
et je lance bien la lecture des .dll et du .exe (pas les fichiers de code) ?
et... je ne vois pas dans ton code où tu indiques quel fichier lire...
salut,avec ca devrait etre bon (j'ai pas teste)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 char *aszFileName[]={"nom1.exe","nom2.exe"}; unsigned long original_crc=CRC_MASK; FILE* stream; int i=0; // utilisation BuildCRCTable();// initialisation for(int i=0;i<sizeof(aszFileName)/sizeof(char *);i++) { stream = fopen(aszFileName[i],"rb"); fseek( stream, 0L, SEEK_SET); while(!feof( stream )) { original_crc=UpdateCharacterCRC32(original_crc,fgetc( stream )); } fclose(stream); } original_crc^=CRC_MASK;
salut,
projet simple complet dispo sous :
http://farscape-dev.chez.tiscali.fr/download.htm
prendre CRC32.
okEnvoyé par farscape
c'est gentil mais le zip est corrompu quand je le download.
J'ai intégré ton code. Ca marche bien sauf que je pensais qu'un CRC32 était de la forme A4B2 par exemple (8x4 = 32). Là, j'ai un CRC du genre 51BBE4B4... dois-je modifier le MASK ?
mince pour le zip c'est mon prog ftp qui a foiré ca sera reparé ce soir.
par contre la je comprends pas le sens de ta question .Ca marche bien sauf que je pensais qu'un CRC32 était de la forme A4B2 par exemple (8x4 = 32). Là, j'ai un CRC du genre 51BBE4B4... dois-je modifier le MASK ?
le crc resultant peut etre afficher sous forme de chaine hexadecimale:
en utilisant %X ou à un format fixe %10X
dans tous les cas c'est le resultat du calcul du polynome .changer la valeur du mask me semble hasardeux sauf à en maitriser le calcul ce qui n'est pas mon cas!
oui ben je l'affiche avec %.4X mais il est trop grand et s'affiche sur 8 caractères hexa : 51BBE4B4Envoyé par farscape
euh... scuse, là c'est moi qui déconne...
en fait, j'avais besoin d'un CRC 16 bits
FF 8 bits char
FFFF 16 bits short integer (en mode 32bits)
FFFF-FFFF 32 bits.... long ou un int
maintenant si tu veux un crc 16 bits je peux trouver ça mais il faut savoir que la precision est moins bonne.
oui je veux bien un algo sur 16Envoyé par farscape
(m'en fiche de la précision)
mon message est arrivé apres le tiens !
je regarde pour le 16bits reponse dans pas longtemps.
voila !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 unsigned short int Ccitt16Table[ 256 ]; void BuildTable16( ) { int i; int j; int k; int crc; for ( i = 0 ; i < 256 ; i++ ) { k = i << 8; crc = 0; for ( j = 0 ; j < 8 ; j++ ) { if ( ( crc ^ k ) & 0x8000 ) crc = ( crc << 1 ) ^ 0x1021; else crc <<= 1; k <<= 1; } Ccitt16Table[ i ] = crc; } } #define CalculateCharacterCRC16(crc,c) (unsigned short int) ( ( crc << 8 ) ^ Ccitt16Table[ (crc >> 8 ) ^ c ] )
j'ai modifié :
#define CRC_MASK 0xFFFFFFFFL
par :
#define CRC_MASK 0xFFFFL
résultat : nickel !
et je dirais :
merci tu m'as sauvé la vie ! (comme toujours)
valeur initial du Mask 0.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 crc=0; crc=CalculateCharacterCRC16(crc,c)
original_crc^=CRC_MASK;
se transforme aussi en original_crc^=0; ??? t'es sûr ?
apparement il y pas besoin de le faire à la fin.
autre chose :
je compile, j'execute : crc = AC9A
je ré-execute : crc = AC9A
je recompile (sans changer le code d'un pouce), j'execute : crc = 0EFF.
normalement, si je recompile sans changer le code, j'ai le même CRC non ?
effectivement ,
moi je ferais le test suivant:
je compile j'execute je regarde le crc ,je mets le prg de cote
je recompile j'execute je regarde le crc si <> je reteste avec le prog mis de cote .
si le resultat est le même ça veut dire que le compilo ne produit toujours la même chose sinon bug
tient moi au courant .
le plus simple est que je te file mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 unsigned short int Ccitt16Table[ 256 ]; void BuildTable16( ) { int i; int j; int k; int crc; for ( i = 0 ; i < 256 ; i++ ) { k = i << 8; crc = 0; for ( j = 0 ; j < 8 ; j++ ) { if ( ( crc ^ k ) & 0x8000 ) crc = ( crc << 1 ) ^ 0x1021; else crc <<= 1; k <<= 1; } Ccitt16Table[ i ] = crc; } } #define CalculateCharacterCRC16(crc,c) (unsigned short int) ( ( crc << 8 ) ^ Ccitt16Table[ (crc >> 8 ) ^ c ] ) // utilisation unsigned long CalculeCRC(){ char system_path[1000]; GetWindowsDirectory(system_path, 1000); char DllPlop[1000]; sprintf(DllPlop, "%s\\DllPlop.dll",system_path); char Classe[1000]; sprintf(Classe, "%s\\Classe.dll",system_path); char *aszFileName[]={DllPlop,Classe, "MON_APPLI.exe"}; unsigned long original_crc=0; FILE* stream; int k=0; BuildTable16();// initialisation for(k=0;k<sizeof(aszFileName)/sizeof(char *);k++) { stream = fopen(aszFileName[k],"rb"); fseek( stream, 0L, SEEK_SET); while(!feof( stream )) { original_crc=CalculateCharacterCRC16(original_crc,fgetc( stream )); } fclose(stream); } //original_crc^=CRC_MASK; return original_crc; }
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager