Extraire et décompresser un stylebook
Bonjour,
Aujourd'hui je m'attaque au cœur de la cible, à savoir le contenu d'un TStyleBook
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| procedure TForm5.Button2Click(Sender: TObject);
function Serialization(const O1: TComponent): string; // ALWEBER production ;-)
var
MS1, MS2: TMemoryStream;
Sl1: TStringList;
begin
MS1 := TMemoryStream.Create;
MS2 := TMemoryStream.Create;
Sl1 := TStringList.Create;
MS1.WriteComponent(O1);
MS1.Seek(0, soFromBeginning);
ObjectBinaryToText(MS1, MS2);
MS2.Seek(0, soFromBeginning);
Sl1.LoadFromStream(MS2);
Result := Sl1.text;
Sl1.Free;
MS2.Free;
MS1.Free
end;
begin
memo1.lines.AddStrings(Serialization(Stylebook1));
end; |
Voici le résultat de cette première opération
Code:
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| object StyleBook2: TStyleBook
Styles = <
item
ResourcesBin = {
464D585F5354594C4520322E3501060C7A627574746F6E7374796C65037E0E00
5450463007544C61796F757400095374796C654E616D65060C7A627574746F6E
7374796C6505416C69676E070643656E7465720A53697A652E57696474680500
0000000000009408400B53697A652E4865696768740500000000000080810840
1453697A652E506C6174666F726D44656661756C7408085461624F7264657202
03001254427574746F6E5374796C654F626A65637400095374796C654E616D65
060A6261636B67726F756E6405416C69676E0708436F6E74656E74730C536F75
7263654C6F6F6B7570061743616C7970736F2053452057696E7374796C652E70
6E670A53697A652E576964746805000000000000009408400B53697A652E4865
6967687405000000000000808108401453697A652E506C6174666F726D446566
61756C740807486F744C696E6B0E010E436170496E736574732E4C6566740500
000000000000E001400D436170496E736574732E546F700500000000000000E0
01400F436170496E736574732E52696768740500000000000000E00140104361
70496E736574732E426F74746F6D0500000000000000E001400F536F75726365
526563742E4C6566740500000000000000C001400E536F75726365526563742E
546F700500000000000000C8064010536F75726365526563742E526967687405
0000000000000088044011536F75726365526563742E426F74746F6D05000000
00000000E5064000010E436170496E736574732E4C6566740500000000000000
A002400D436170496E736574732E546F700500000000000000A002400F436170
496E736574732E52696768740500000000000000A0024010436170496E736574
732E426F74746F6D0500000000000000A00240055363616C6505000000000000
00C0FF3F0F536F75726365526563742E4C65667405000000000000009002400E
536F75726365526563742E546F70050000000000000096074010536F75726365
526563742E52696768740500000000000000CC044011536F7572636552656374
2E426F74746F6D0500000000000080AB074000010E436170496E736574732E4C
6566740500000000000000E002400D436170496E736574732E546F7005000000
00000000E002400F436170496E736574732E52696768740500000000000000E0
024010436170496E736574732E426F74746F6D0500000000000000E002400553
63616C6505000000000000008000400F536F75726365526563742E4C65667405
00000000000000C002400E536F75726365526563742E546F7005000000000000
00C8074010536F75726365526563742E52696768740500000000000000880540
11536F75726365526563742E426F74746F6D0500000000000000E5074000000B
466F63757365644C696E6B0E010E436170496E736574732E4C65667405000000
00000000E001400D436170496E736574732E546F700500000000000000E00140
0F436170496E736574732E52696768740500000000000000E001401043617049
6E736574732E426F74746F6D0500000000000000E001400F536F757263655265
63742E4C6566740500000000000000C001400E536F75726365526563742E546F
700500000000000000C8064010536F75726365526563742E5269676874050000
000000000088044011536F75726365526563742E426F74746F6D050000000000
0000E5064000010E436170496E736574732E4C6566740500000000000000A002
400D436170496E736574732E546F700500000000000000A002400F436170496E
736574732E52696768740500000000000000A0024010436170496E736574732E
426F74746F6D0500000000000000A00240055363616C650500000000000000C0
FF3F0F536F75726365526563742E4C65667405000000000000009002400E536F
75726365526563742E546F70050000000000000096074010536F757263655265
63742E52696768740500000000000000CC044011536F75726365526563742E42
6F74746F6D0500000000000000AC074000010E436170496E736574732E4C6566
740500000000000000E002400D436170496E736574732E546F70050000000000
0000E002400F436170496E736574732E52696768740500000000000000E00240
10436170496E736574732E426F74746F6D0500000000000000E0024005536361
6C6505000000000000008000400F536F75726365526563742E4C656674050000
0000000000C002400E536F75726365526563742E546F700500000000000000C8
074010536F75726365526563742E526967687405000000000000008805401153
6F75726365526563742E426F74746F6D0500000000000000E5074000000A4E6F
726D616C4C696E6B0E010E436170496E736574732E4C65667405000000000000
00E001400D436170496E736574732E546F700500000000000000E001400F4361
70496E736574732E52696768740500000000000000E0014010436170496E7365
74732E426F74746F6D0500000000000000E001400F536F75726365526563742E
4C6566740500000000000000C001400E536F75726365526563742E546F700500
000000000000A2064010536F75726365526563742E5269676874050000000000
000088044011536F75726365526563742E426F74746F6D0500000000000000BF
064000010E436170496E736574732E4C6566740500000000000000A002400D43
6170496E736574732E546F700500000000000000A002400F436170496E736574
732E52696768740500000000000000A0024010436170496E736574732E426F74
746F6D0500000000000000A00240055363616C650500000000000000C0FF3F0F
536F75726365526563742E4C65667405000000000000009002400E536F757263
65526563742E546F700500000000000000F3064010536F75726365526563742E
52696768740500000000000000CC044011536F75726365526563742E426F7474
6F6D05000000000000008F074000010E436170496E736574732E4C6566740500
000000000000E002400D436170496E736574732E546F700500000000000000E0
02400F436170496E736574732E52696768740500000000000000E00240104361
70496E736574732E426F74746F6D0500000000000000E00240055363616C6505
000000000000008000400F536F75726365526563742E4C656674050000000000
0000C002400E536F75726365526563742E546F700500000000000000A2074010
536F75726365526563742E5269676874050000000000000088054011536F7572
6365526563742E426F74746F6D0500000000000000BF074000000B5072657373
65644C696E6B0E010E436170496E736574732E4C6566740500000000000000E0
01400D436170496E736574732E546F700500000000000000E001400F43617049
6E736574732E52696768740500000000000000E0014010436170496E73657473
2E426F74746F6D0500000000000000E001400F536F75726365526563742E4C65
66740500000000000000C001400E536F75726365526563742E546F7005000000
00000000EB064010536F75726365526563742E52696768740500000000000000
88044011536F75726365526563742E426F74746F6D0500000000000000840740
00010E436170496E736574732E4C6566740500000000000000A002400D436170
496E736574732E546F700500000000000000A002400F436170496E736574732E
52696768740500000000000000A0024010436170496E736574732E426F74746F
6D0500000000000000A00240055363616C650500000000000000C0FF3F0F536F
75726365526563742E4C65667405000000000000009002400E536F7572636552
6563742E546F700500000000000000B0074010536F75726365526563742E5269
6768740500000000000000CC044011536F75726365526563742E426F74746F6D
0500000000000080C5074000010E436170496E736574732E4C65667405000000
00000000E002400D436170496E736574732E546F700500000000000000E00240
0F436170496E736574732E52696768740500000000000000E002401043617049
6E736574732E426F74746F6D0500000000000000E00240055363616C65050000
00000000008000400F536F75726365526563742E4C6566740500000000000000
C002400E536F75726365526563742E546F700500000000000000EB074010536F
75726365526563742E5269676874050000000000000088054011536F75726365
526563742E426F74746F6D0500000000000000840840000013546F756368416E
696D6174696F6E2E4C696E6B0E0000000654476C79706800095374796C654E61
6D65060A676C7970687374796C650C4D617267696E732E4C6566740500000000
000000C000400B4D617267696E732E546F7005000000000000008000400D4D61
7267696E732E5269676874050000000000000080FF3F0E4D617267696E732E42
6F74746F6D050000000000000080004005416C69676E07044C6566740A53697A
652E576964746805000000000000008003400B53697A652E4865696768740500
0000000000008003401453697A652E506C6174666F726D44656661756C740800
001654427574746F6E5374796C65546578744F626A65637400095374796C654E
616D6506047465787405416C69676E0706436C69656E74064C6F636B6564090C
4D617267696E732E4C65667405000000000000008000400B4D617267696E732E
546F7005000000000000008000400D4D617267696E732E526967687405000000
000000008000400E4D617267696E732E426F74746F6D05000000000000008000
400A53697A652E576964746805000000000000009308400B53697A652E486569
67687405000000000000808008401453697A652E506C6174666F726D44656661
756C74080454657874060454657874165465787453657474696E67732E466F6E
74436F6C6F720709636C6159656C6C6F770D536861646F7756697369626C6508
08486F74436F6C6F7207097846463134323533460C466F6375736564436F6C6F
7207097846463134323533460B4E6F726D616C436F6C6F720709636C6159656C
6C6F770C50726573736564436F6C6F720709784646313432353346000000}
end>
Left = 456
Top = 105
end |
comme vous le constatez c'est du binaire compressé.
Citation:
le composant StyleBook enregistre les informations de style dans un format compressé binaire dans le fichier FMX
La première fois qu'Embarcadero a utilisé cette technique (Delphi XE4), Marco Cantu avait produit un outil (cf blog)
Depuis, hélas, Code Central est plus que vacillant :roll: difficile de récupérer (mais j'y ai eu accès ) le dit outil qui de toute façon n'était que pour XE4.
Donc, je voudrais tenter :
1- D'obtenir uniquement le binaire (ResourcesBin)
2- Tenter de le décompresser. Dans un premier temps histoire de voir ce que cela contient.
Pour l'instant, le problème est posé mais, je sèche. Si, AMHA, il s'agit d'un Stream de ressource je ne vois pas comment le travailler au corps