Array of bytes ....

Résolu
ELCouz
Messages postés
135
Date d'inscription
jeudi 22 mars 2007
Statut
Membre
Dernière intervention
25 juillet 2008
- 4 mai 2007 à 00:32
florenth
Messages postés
1023
Date d'inscription
dimanche 1 août 2004
Statut
Membre
Dernière intervention
17 août 2008
- 13 mai 2007 à 16:46
bonjour,,

Je sais que cest possible dinserer des fichiers dans le programme en passant par :

const
music : array[1..905] of Byte = (
    $45,$78,$74,$65,$6E,$64,$65,$64,$20,$4D,$6F,$64,$75,$6C,$65,$3A,
    $20,$73,$6F,$66,$74,$20,$6D,$61,$6E,$69,$61,$63,$2D,$6D,$69,$6E,
    $69,$6D,$61,$6C,$00,$1A,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$04,$01,$34,$00,$00,$00,
    $20,$00,$00,$00,$02,$00,$0D,$00,$01,$00,$01,$00,$0A,$00,$91,$00,
    $00,$01,$02,$03,$04,$05,$06,$07,$00,$01,$02,$03,$04,$05,$06,$07,
    $08,$09,$0A,$0B,$08,$09,$0C,$0B,$08,$09,$0A,$0B,$08,$09,$0C,$0B,
    $09,$00,$00,$00,$00,$04,$00,$01,$00,$83,$16,$01,$80,$80,$2E,$01,
    $00,$0E,$60,$80,$3A,$01,$00,$0E,$62,$81,$61,$83,$35,$01,$09,$00,
    $00,$00,$00,$04,$00,$01,$00,$83,$16,$01,$80,$80,$2E,$01,$00,$0E,
    $60,$80,$35,$01,$00,$0E,$62,$81,$61,$83,$38,$01,$09,$00,$00,$00,
    $00,$04,$00,$01,$00,$83,$16,$01,$80,$80,$2E,$01,$00,$0E,$60,$80,
    $38,$01,$00,$0E,$62,$80,$83,$33,$01,$09,$00,$00,$00,$00,$06,$00,
    $01,$00,$83,$16,$01,$80,$80,$2E,$01,$00,$0E,$60,$80,$33,$01,$00,
    $0E,$61,$81,$61,$83,$35,$01,$83,$0D,$01,$83,$36,$01,$80,$83,$36,
    $01,$09,$00,$00,$00,$00,$04,$00,$01,$00,$83,$0F,$01,$80,$80,$2E,
    $01,$00,$0E,$60,$80,$36,$01,$00,$0E,$62,$81,$61,$83,$33,$01,$09,
    $00,$00,$00,$00,$06,$00,$01,$00,$83,$0F,$01,$80,$80,$2E,$01,$00,
    $0E,$60,$80,$33,$01,$00,$0E,$61,$81,$61,$83,$2E,$01,$83,$12,$01,
    $83,$33,$01,$80,$83,$35,$01,$09,$00,$00,$00,$00,$06,$00,$01,$00,
    $83,$16,$01,$80,$80,$2E,$01,$00,$0E,$60,$80,$35,$01,$00,$0E,$61,
    $81,$61,$83,$2E,$01,$83,$0D,$01,$83,$31,$01,$80,$83,$2E,$01,$09,
    $00,$00,$00,$00,$08,$00,$01,$00,$83,$12,$01,$98,$0A,$01,$83,$19,
    $01,$88,$0A,$83,$1E,$01,$81,$61,$83,$12,$01,$80,$83,$14,$01,$80,
    $83,$1B,$01,$80,$83,$20,$01,$80,$83,$14,$01,$80,$09,$00,$00,$00,
    $00,$08,$00,$01,$00,$83,$12,$01,$81,$61,$83,$19,$01,$80,$83,$1E,
    $01,$80,$83,$12,$01,$80,$83,$19,$01,$83,$31,$01,$83,$1E,$01,$80,
    $83,$12,$01,$83,$31,$01,$83,$19,$01,$80,$09,$00,$00,$00,$00,$08,
    $00,$01,$00,$83,$14,$01,$83,$33,$01,$83,$1B,$01,$80,$83,$20,$01,
    $83,$31,$01,$83,$14,$01,$80,$83,$1B,$01,$83,$30,$01,$83,$20,$01,
    $80,$83,$14,$01,$83,$31,$01,$83,$1B,$01,$80,$09,$00,$00,$00,$00,
    $08,$00,$01,$00,$83,$16,$01,$83,$30,$01,$83,$1D,$01,$83,$31,$01,
    $83,$22,$01,$83,$35,$01,$83,$16,$01,$98,$0A,$01,$83,$1D,$01,$88,
    $0A,$83,$22,$01,$81,$61,$83,$16,$01,$80,$83,$1D,$01,$80,$09,$00,
    $00,$00,$00,$08,$00,$01,$00,$83,$16,$01,$80,$83,$1D,$01,$80,$83,
    $22,$01,$80,$83,$16,$01,$80,$83,$18,$01,$80,$83,$1D,$01,$80,$83,
    $11,$01,$80,$83,$18,$01,$80,$09,$00,$00,$00,$00,$08,$00,$01,$00,
    $83,$16,$01,$83,$30,$01,$83,$1D,$01,$83,$31,$01,$83,$19,$01,$83,
    $2E,$01,$83,$16,$01,$98,$0A,$01,$83,$1D,$01,$88,$0A,$83,$19,$01,
    $81,$61,$83,$16,$01,$80,$83,$1D,$01,$80,$F1,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$27,$01,$00,$12,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$40,$00,$08,
    $00,$2C,$00,$0E,$00,$08,$00,$18,$00,$16,$00,$20,$00,$08,$00,$2D,
    $00,$0D,$00,$32,$00,$04,$00,$3C,$00,$07,$00,$44,$00,$04,$00,$5A,
    $00,$00,$00,$64,$00,$00,$00,$6E,$00,$00,$00,$00,$00,$20,$00,$0A,
    $00,$28,$00,$1E,$00,$18,$00,$32,$00,$20,$00,$3C,$00,$20,$00,$46,
    $00,$20,$00,$50,$00,$20,$00,$5A,$00,$20,$00,$64,$00,$20,$00,$6E,
    $00,$20,$00,$78,$00,$20,$00,$82,$00,$20,$00,$09,$06,$01,$02,$04,
    $02,$03,$05,$01,$00,$00,$00,$00,$00,$80,$00,$0C,$00,$00,$00,$00,
    $00,$00,$00,$0C,$00,$00,$00,$40,$00,$01,$80,$F9,$00,$BF,$00,$C3,
    $00,$0A,$00,$57,$00,$6E,$00,$23,$00
);

sa marche tres bien quand on a une fonction qui lit dans larray ... mais es-ce possible denregistrer un array vers un fichier ,,, ah oui aussi es-ce que c possible de «pointer» vers un array ?
car avec une dll (bass) on me demande un pointer (jutilise PChar quand je veut pointer vers un fichier) mais ya tu moyen de convertir un array pour que sa marche avec un pointer ??

merci

désolé si cest un peu compliqué

laurent !! :)

13 réponses

florenth
Messages postés
1023
Date d'inscription
dimanche 1 août 2004
Statut
Membre
Dernière intervention
17 août 2008
2
4 mai 2007 à 13:24
Oui enfin ... ton array peut être retrouvé en désassemblant on programme ...
Ou même sans ! Il suffit de connaitre les premiers octets ... et de faire une recherche !
Et comme les fichiers mp3 commencent toujours par la même séquence ... tu vois, la protection est très faible.

Si tu veux absolument protéger un fichier, il faut le crypter et demander la clé de cryptage (=mot de passe) à l'utilisateur au démarrage du programme. Sinon, tu n'auras jamais rien de très fiable.

Sinon, pour répondre à ta question, pour pointer vers le tableau, il suffit d'écrire @music ou encore Addr(music).
Poue enreigstrer ton array dans un fichier, tu peux utiliser un TFileStream et faire Stream.WriteBuffer(music, SizeOf(music));

Pour utiliser ta musique avec Bass, tu peux utiliser BASS_StreamCreateFile() en mettant le premier param à True et le deuxcième à l'addresse de ton fichier.
Exemple:
BASS_CreateStreamFile(True, @music, 0, SizeOf(music), *flags que tu veux*)

++
Flo
3