├── .gitignore
├── CFFFlashFileTools.pro
├── CFFFlashFileTools_ru_RU.ts
├── LICENSE
├── README.md
├── cffflashcontainer.cpp
├── cffflashcontainer.h
├── cffflashdatablock.cpp
├── cffflashdatablock.h
├── cffflashdatablocksmodel.cpp
├── cffflashdatablocksmodel.h
├── cffflashdescriptionheader.cpp
├── cffflashdescriptionheader.h
├── cffflashheader.cpp
├── cffflashheader.h
├── cffflashsegment.cpp
├── cffflashsegment.h
├── cffflashsegmentmodel.cpp
├── cffflashsegmentmodel.h
├── cffutils.cpp
├── cffutils.h
├── ctfheader.cpp
├── ctfheader.h
├── ctflanguage.cpp
├── ctflanguage.h
├── defs.h
├── icon.ico
├── images.qrc
├── images
└── save_btn.svg
├── main.cpp
├── qml.qrc
├── qml
├── FlashDataBlockDelegate.qml
├── FlashInfoScreen.qml
├── FlashSegmentModel.qml
├── HomeScreen.qml
└── main.qml
├── qtquickcontrols2.conf
└── setup_package.iss
/.gitignore:
--------------------------------------------------------------------------------
1 | # C++ objects and libs
2 | *.slo
3 | *.lo
4 | *.o
5 | *.a
6 | *.la
7 | *.lai
8 | *.so
9 | *.so.*
10 | *.dll
11 | *.dylib
12 |
13 | # Qt-es
14 | object_script.*.Release
15 | object_script.*.Debug
16 | *_plugin_import.cpp
17 | /.qmake.cache
18 | /.qmake.stash
19 | *.pro.user
20 | *.pro.user.*
21 | *.qbs.user
22 | *.qbs.user.*
23 | *.moc
24 | moc_*.cpp
25 | moc_*.h
26 | qrc_*.cpp
27 | ui_*.h
28 | *.qmlc
29 | *.jsc
30 | Makefile*
31 | *build-*
32 | *.qm
33 | *.prl
34 |
35 | # Qt unit tests
36 | target_wrapper.*
37 |
38 | # QtCreator
39 | *.autosave
40 |
41 | # QtCreator Qml
42 | *.qmlproject.user
43 | *.qmlproject.user.*
44 |
45 | # QtCreator CMake
46 | CMakeLists.txt.user*
47 |
48 | # QtCreator 4.8< compilation database
49 | compile_commands.json
50 |
51 | # QtCreator local machine specific files for imported projects
52 | *creator.user*
53 |
--------------------------------------------------------------------------------
/CFFFlashFileTools.pro:
--------------------------------------------------------------------------------
1 | QT += qml quick widgets
2 |
3 | CONFIG += c++20
4 | win32:CONFIG += c++latest
5 | win32:QMAKE_CXXFLAGS += /std:c++latest
6 |
7 | TARGET=CFFFlashFileTools
8 |
9 | # You can make your code fail to compile if it uses deprecated APIs.
10 | # In order to do so, uncomment the following line.
11 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
12 |
13 | SOURCES += \
14 | cffflashcontainer.cpp \
15 | cffflashdatablock.cpp \
16 | cffflashdatablocksmodel.cpp \
17 | cffflashdescriptionheader.cpp \
18 | cffflashheader.cpp \
19 | cffflashsegment.cpp \
20 | cffflashsegmentmodel.cpp \
21 | cffutils.cpp \
22 | ctfheader.cpp \
23 | ctflanguage.cpp \
24 | main.cpp
25 |
26 | RESOURCES += qml.qrc \
27 | images.qrc
28 |
29 | TRANSLATIONS += \
30 | CFFFlashFileTools_ru_RU.ts
31 |
32 | # Additional import path used to resolve QML modules in Qt Creator's code model
33 | QML_IMPORT_PATH =
34 |
35 | # Additional import path used to resolve QML modules just for Qt Quick Designer
36 | QML_DESIGNER_IMPORT_PATH =
37 |
38 | # Default rules for deployment.
39 | qnx: target.path = /tmp/$${TARGET}/bin
40 | else: unix:!android: target.path = /opt/$${TARGET}/bin
41 | !isEmpty(target.path): INSTALLS += target
42 |
43 | HEADERS += \
44 | cffflashcontainer.h \
45 | cffflashdatablock.h \
46 | cffflashdatablocksmodel.h \
47 | cffflashdescriptionheader.h \
48 | cffflashheader.h \
49 | cffflashsegment.h \
50 | cffflashsegmentmodel.h \
51 | cffutils.h \
52 | ctfheader.h \
53 | ctflanguage.h \
54 | defs.h
55 |
--------------------------------------------------------------------------------
/CFFFlashFileTools_ru_RU.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CFFFlashFileTools
2 |
3 | ## Overview
4 | CFFFlashFileTools is an open-source project designed to parse and extract flash binaries from Mercedes-Benz CFF (Container Flash File). CFF files are typically used to store firmware updates and vehicle configuration data for automotive control units (ECUs). It simplifies the process of working with these proprietary files, making it easier for developers and reverse engineers to analyze and manipulate flash memory content.
5 |
6 | ## Features
7 | - Extracts binaries from CFF files
8 | - C++ and QML-based implementation
9 | - Provides insights into flash segments, headers, and blocks.
10 | - Supports file parsing and flash segment extraction
11 | - Compatible with Mercedes-Benz vehicle systems
12 |
13 | ## License
14 | Licensed under the GPL-3.0 license.
15 |
16 | ## Contributions
17 | Feel free to fork, enhance, and contribute!
18 |
--------------------------------------------------------------------------------
/cffflashcontainer.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashcontainer.h"
3 | #include "cffflashheader.h"
4 | #include "ctfheader.h"
5 |
6 | #include
7 |
8 | static uint CrcTable[] = {
9 | 0x00000000, 0x77073096, 0x0EE0E612C, 0x990951BA, 0x76DC419, 0x706AF48F, 0x0E963A535, 0x9E6495A3,
10 | 0x0EDB8832, 0x79DCB8A4, 0x0E0D5E91E, 0x97D2D988, 0x9B64C2B, 0x7EB17CBD, 0x0E7B82D07, 0x90BF1D91,
11 | 0x1DB71064, 0x6AB020F2, 0x0F3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0x0F4D4B551, 0x83D385C7,
12 | 0x136C9856, 0x646BA8C0, 0x0FD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0x0FA0F3D63, 0x8D080DF5,
13 | 0x3B6E20C8, 0x4C69105E, 0x0D56041E4, 0x0A2677172, 0x3C03E4D1, 0x4B04D447, 0x0D20D85FD, 0x0A50AB56B,
14 | 0x35B5A8FA, 0x42B2986C, 0x0DBBBC9D6, 0x0ACBCF940, 0x32D86CE3, 0x45DF5C75, 0x0DCD60DCF, 0x0ABD13D59,
15 | 0x26D930AC, 0x51DE003A, 0x0C8D75180, 0x0BFD06116, 0x21B4F4B5, 0x56B3C423, 0x0CFBA9599, 0x0B8BDA50F,
16 | 0x2802B89E, 0x5F058808, 0x0C60CD9B2, 0x0B10BE924, 0x2F6F7C87, 0x58684C11, 0x0C1611DAB, 0x0B6662D3D,
17 | 0x76DC4190, 0x1DB7106, 0x98D220BC, 0x0EFD5102A, 0x71B18589, 0x6B6B51F, 0x9FBFE4A5, 0x0E8B8D433,
18 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0x0E10E9818, 0x7F6A0DBB, 0x86D3D2D, 0x91646C97, 0x0E6635C01,
19 | 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0x0F262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0x0F50FC457,
20 | 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0x0FCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0x0FBD44C65,
21 | 0x4DB26158, 0x3AB551CE, 0x0A3BC0074, 0x0D4BB30E2, 0x4ADFA541, 0x3DD895D7, 0x0A4D1C46D, 0x0D3D6F4FB,
22 | 0x4369E96A, 0x346ED9FC, 0x0AD678846, 0x0DA60B8D0, 0x44042D73, 0x33031DE5, 0x0AA0A4C5F, 0x0DD0D7CC9,
23 | 0x5005713C, 0x270241AA, 0x0BE0B1010, 0x0C90C2086, 0x5768B525, 0x206F85B3, 0x0B966D409, 0x0CE61E49F,
24 | 0x5EDEF90E, 0x29D9C998, 0x0B0D09822, 0x0C7D7A8B4, 0x59B33D17, 0x2EB40D81, 0x0B7BD5C3B, 0x0C0BA6CAD,
25 | 0x0EDB88320, 0x9ABFB3B6, 0x3B6E20C, 0x74B1D29A, 0x0EAD54739, 0x9DD277AF, 0x4DB2615, 0x73DC1683,
26 | 0x0E3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0x0E40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
27 | 0x0F00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0x0F762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
28 | 0x0FED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0x0F9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
29 | 0x0D6D6A3E8, 0x0A1D1937E, 0x38D8C2C4, 0x4FDFF252, 0x0D1BB67F1, 0x0A6BC5767, 0x3FB506DD, 0x48B2364B,
30 | 0x0D80D2BDA, 0x0AF0A1B4C, 0x36034AF6, 0x41047A60, 0x0DF60EFC3, 0x0A867DF55, 0x316E8EEF, 0x4669BE79,
31 | 0x0CB61B38C, 0x0BC66831A, 0x256FD2A0, 0x5268E236, 0x0CC0C7795, 0x0BB0B4703, 0x220216B9, 0x5505262F,
32 | 0x0C5BA3BBE, 0x0B2BD0B28, 0x2BB45A92, 0x5CB36A04, 0x0C2D7FFA7, 0x0B5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
33 | 0x9B64C2B0, 0x0EC63F226, 0x756AA39C, 0x26D930A, 0x9C0906A9, 0x0EB0E363F, 0x72076785, 0x5005713,
34 | 0x95BF4A82, 0x0E2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0x0E5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
35 | 0x86D3D2D4, 0x0F1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0x0F6B9265B, 0x6FB077E1, 0x18B74777,
36 | 0x88085AE6, 0x0FF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0x0F862AE69, 0x616BFFD3, 0x166CCF45,
37 | 0x0A00AE278, 0x0D70DD2EE, 0x4E048354, 0x3903B3C2, 0x0A7672661, 0x0D06016F7, 0x4969474D, 0x3E6E77DB,
38 | 0x0AED16A4A, 0x0D9D65ADC, 0x40DF0B66, 0x37D83BF0, 0x0A9BCAE53, 0x0DEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
39 | 0x0BDBDF21C, 0x0CABAC28A, 0x53B39330, 0x24B4A3A6, 0x0BAD03605, 0x0CDD70693, 0x54DE5729, 0x23D967BF,
40 | 0x0B3667A2E, 0x0C4614AB8, 0x5D681B02, 0x2A6F2B94, 0x0B40BBE37, 0x0C30C8EA1, 0x5A05DF1B, 0x2D02EF8D
41 | };
42 |
43 |
44 |
45 | CFFFlashContainer::CFFFlashContainer(QObject *parent) : QObject(parent)
46 | {
47 |
48 |
49 | }
50 |
51 |
52 | CFFFlashContainer * CFFFlashContainer::openCaesarFlashContainer(QString fname, QObject *parent)
53 | {
54 | if(fname.startsWith(QStringLiteral("file:")))
55 | {
56 | fname = QDir::toNativeSeparators(QUrl(fname).toLocalFile());
57 | }
58 | else fname = QDir::toNativeSeparators(fname);
59 |
60 | qDbg() << fname;
61 |
62 | auto container = new CFFFlashContainer(parent);
63 | container->m_cff_file = new QFile(QDir::toNativeSeparators(fname), container);
64 | if(!container->m_cff_file->exists() || !container->m_cff_file->open(QIODevice::ReadOnly))
65 | {
66 | qDbg() << "Can't open CFF file: " << fname;
67 | return Q_NULLPTR;
68 | }
69 | container->m_cff_mem = container->m_cff_file->readAll();
70 | container->m_cff_file->seek(0);
71 | qDbg() << "";
72 | return container;
73 | }
74 |
75 | QByteArray CFFFlashContainer::readHeader()
76 | {
77 | auto header = this->m_cff_file->read(this->StubHeaderSize);
78 | int cbfHeaderIdentifier = header[0x401];
79 | switch(cbfHeaderIdentifier)
80 | {
81 |
82 | case 3:
83 | qDbg() << "CBF File";
84 | break;
85 |
86 | case 5:
87 | qDbg() << "CFF File";
88 | break;
89 |
90 | case 0:
91 | case 1:
92 | case 2:
93 | qDbg() << "not implemented";
94 | break;
95 | }
96 |
97 | return header;
98 | }
99 |
100 | QByteArray CFFFlashContainer::readCFFHeader()
101 | {
102 | qDbg() << this->m_cff_file->pos();
103 | int32_t cffHeaderSize = 0;
104 | this->m_cff_file->read((char*)&cffHeaderSize, 4);
105 | auto cffHeaderData = this->m_cff_file->read(cffHeaderSize);
106 |
107 | qDbg() << "CFF Header size: " << cffHeaderSize;
108 |
109 | return cffHeaderData;
110 | }
111 |
112 | uint32_t CFFFlashContainer::readChecksum()
113 | {
114 | uint32_t chksum = 0;
115 | memcpy(&chksum, this->m_cff_mem.right(4).data(), sizeof(uint32_t));
116 | qDbg() << "checsum: " << chksum;
117 | return chksum;
118 | }
119 |
120 | uint32_t CFFFlashContainer::genChecksum()
121 | {
122 | auto inputBuffer = this->m_cff_mem.data();
123 | auto length = this->m_cff_mem.length()-4;
124 | uint currentChecksum = 0xFFFFFFFF;
125 |
126 | for (int i = 0; i < length; i++)
127 | {
128 | uint tableIndex = (currentChecksum ^ inputBuffer[i]) & 0xFF;
129 | uint tableValue = CrcTable[tableIndex];
130 | // mix in the loaded byte into the crc on the most significant byte
131 | currentChecksum >>= 8;
132 | currentChecksum &= 0xFFFFFF;
133 | currentChecksum ^= tableValue;
134 | }
135 |
136 | qDbg() << "Calculated checksum: " << currentChecksum;
137 | return currentChecksum;
138 | }
139 |
140 | CFFFlashHeader * CFFFlashContainer::readFlashCFF()
141 | {
142 | this->m_FlashHeader = CFFFlashHeader::readFlashHeader(this->m_cff_file, this);
143 | return this->m_FlashHeader;
144 | }
145 |
146 | CTFHeader * CFFFlashContainer::readCTF()
147 | {
148 | //auto CtfHeader = CTFHeader::readCTFHeader(this->m_cff_file, )
149 | if (this->m_FlashHeader->CTFHeaderTable() == 0)
150 | {
151 | qDbg() << "No CTF Header found";
152 | return Q_NULLPTR;
153 | }
154 |
155 | long ctfOffset = this->m_FlashHeader->BaseAddress() + this->m_FlashHeader->CTFHeaderTable();
156 | this->m_CTFHeader = CTFHeader::readCTFHeader(this->m_cff_file, ctfOffset, this->m_FlashHeader->CffHeaderSize(), this);
157 |
158 | return this->m_CTFHeader;
159 | }
160 |
--------------------------------------------------------------------------------
/cffflashcontainer.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHCONTAINER_H
2 | #define CFFFLASHCONTAINER_H
3 |
4 | #include
5 | #include
6 |
7 | class CFFFlashHeader;
8 |
9 | class CTFHeader;
10 | class CFFFlashContainer : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit CFFFlashContainer(QObject *parent = nullptr);
15 |
16 |
17 | Q_INVOKABLE static CFFFlashContainer * openCaesarFlashContainer(QString fname, QObject *parent = nullptr);
18 |
19 | Q_INVOKABLE uint32_t readChecksum();
20 | Q_INVOKABLE uint32_t genChecksum();
21 |
22 | QByteArray readHeader();
23 | QByteArray readCFFHeader();
24 |
25 | Q_INVOKABLE CFFFlashHeader * readFlashCFF();
26 | Q_INVOKABLE CTFHeader * readCTF();
27 |
28 |
29 | signals:
30 |
31 |
32 | private:
33 | QFile * m_cff_file;
34 | QByteArray m_cff_mem;
35 |
36 |
37 | CFFFlashHeader * m_FlashHeader;
38 | CTFHeader * m_CTFHeader;
39 |
40 | const int StubHeaderSize = 0x410;
41 | QString FileHeader = "CBF-TRANSLATOR-VERSION:04.00";
42 |
43 | };
44 |
45 | #endif // CFFFLASHCONTAINER_H
46 |
--------------------------------------------------------------------------------
/cffflashdatablock.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashdatablock.h"
3 | #include
4 |
5 | CFFFlashDataBlock::CFFFlashDataBlock(QObject *parent) : QObject(parent)
6 | {
7 |
8 | }
9 |
10 | CFFFlashDataBlock * CFFFlashDataBlock::readFlashDataBlock(QFile * cff, long baseAddress, uint32_t CffHeaderSize, uint32_t LanguageBlockLength, QObject * parent)
11 | {
12 | auto cff_flash_block = new CFFFlashDataBlock(parent);
13 | cff_flash_block->m_CffHeaderSize = CffHeaderSize;
14 | cff_flash_block->m_LanguageBlockLength = LanguageBlockLength;
15 | cff_flash_block->readCFFData(cff, baseAddress);
16 | return cff_flash_block;
17 | }
18 |
19 | void CFFFlashDataBlock::readCFFData(QFile * cff, long baseAddress)
20 | {
21 | this->setBaseAddress(baseAddress);
22 | cff->seek(baseAddress);
23 |
24 | ulong bitFlags = 0;
25 | cff->read((char*)&bitFlags, 4);
26 |
27 | ushort tmp = 0;
28 | cff->read((char*)&tmp, 2);
29 |
30 | this->setQualifier(CFFUtils::ReadBitflagString(bitFlags, cff, baseAddress));
31 |
32 | int32_t LongName = ReadBitflag4Byte(LongName, bitFlags, cff);
33 | this->setLongName(LongName);
34 | int32_t Description = ReadBitflag4Byte(Description, bitFlags, cff);
35 | this->setDescription(Description);
36 | int32_t FlashData = ReadBitflag4Byte(FlashData, bitFlags, cff);
37 | this->setFlashData(FlashData);
38 |
39 |
40 | int32_t BlockLength = ReadBitflag4Byte(BlockLength, bitFlags, cff);
41 | this->setBlockLength(BlockLength);
42 | int32_t DataFormat = ReadBitflag4Byte(DataFormat, bitFlags, cff);
43 | this->setDataFormat(DataFormat);
44 |
45 | int32_t FileName = ReadBitflag4Byte(FileName, bitFlags, cff);
46 | this->setFileName(FileName);
47 |
48 | int32_t NumberOfFilters = ReadBitflag4Byte(NumberOfFilters, bitFlags, cff);
49 | this->setNumberOfFilters(NumberOfFilters);
50 |
51 |
52 | int32_t FiltersOffset = ReadBitflag4Byte(FiltersOffset, bitFlags, cff);
53 | this->setFiltersOffset(FiltersOffset);
54 | int32_t NumberOfSegments = ReadBitflag4Byte(NumberOfSegments, bitFlags, cff);
55 | this->setNumberOfSegments(NumberOfSegments);
56 | int32_t SegmentOffset = ReadBitflag4Byte(SegmentOffset, bitFlags, cff);
57 | this->setSegmentOffset(SegmentOffset);
58 | int32_t EncryptionMode = ReadBitflag4Byte(EncryptionMode, bitFlags, cff);
59 | this->setEncryptionMode(EncryptionMode);
60 |
61 | int32_t KeyLength = ReadBitflag4Byte(KeyLength, bitFlags, cff);
62 | this->setKeyLength(KeyLength);
63 | int32_t KeyBuffer = ReadBitflag4Byte(KeyBuffer, bitFlags, cff);
64 | this->setKeyBuffer(KeyBuffer);
65 | int32_t NumberOfOwnIdents = ReadBitflag4Byte(NumberOfOwnIdents, bitFlags, cff);
66 | this->setNumberOfOwnIdents(NumberOfOwnIdents);
67 | int32_t IdentsOffset = ReadBitflag4Byte(IdentsOffset, bitFlags, cff);
68 | this->setIdentsOffset(IdentsOffset);
69 |
70 | int32_t NumberOfSecurities = ReadBitflag4Byte(NumberOfSecurities, bitFlags, cff);
71 | this->setNumberOfSecurities(NumberOfSecurities);
72 | int32_t SecuritiesOffset = ReadBitflag4Byte(SecuritiesOffset, bitFlags, cff);
73 | this->setSecuritiesOffset(SecuritiesOffset);
74 | this->setDataBlockType(CFFUtils::ReadBitflagString(bitFlags, cff, baseAddress));
75 | int32_t UniqueObjectId = ReadBitflag4Byte(UniqueObjectId, bitFlags, cff);
76 | this->setUniqueObjectId(UniqueObjectId);
77 |
78 | this->setFlashDataInfo_Idk(CFFUtils::ReadBitflagString(bitFlags, cff, baseAddress));
79 | int32_t FlashDataInfoLang1 = ReadBitflag4Byte(FlashDataInfoLang1, bitFlags, cff);
80 | this->setFlashDataInfoLang1(FlashDataInfoLang1);
81 | int32_t FlashDataInfoLang2 = ReadBitflag4Byte(FlashDataInfoLang2, bitFlags, cff);
82 | this->setFlashDataInfoLang2(FlashDataInfoLang2);
83 | int32_t FlashDataInfo_Idk2 = ReadBitflag4Byte(FlashDataInfo_Idk2, bitFlags, cff);
84 | this->setFlashDataInfo_Idk2(FlashDataInfo_Idk2);
85 |
86 |
87 | long fileCursor = 0;
88 | // CtfUnk1 = CaesarReader.ReadBitflagInt32(ref ctfBitflags, reader);
89 | auto FlashSegments = QList();
90 | for (int segmentIndex = 0; segmentIndex < NumberOfSegments; segmentIndex++)
91 | {
92 | long segmentEntryAddress = SegmentOffset + baseAddress + (segmentIndex * 4);
93 | cff->seek(segmentEntryAddress);
94 |
95 | int32_t pos = 0;
96 | cff->read((char*)&pos, 4);
97 | long segmentBaseAddress = SegmentOffset + baseAddress + pos;
98 |
99 | long offset = this->FlashData() + this->m_CffHeaderSize + this->m_LanguageBlockLength + fileCursor + 0x414;
100 | auto segment = CFFFlashSegment::readFlashSegment(cff,segmentBaseAddress, offset, this);
101 |
102 | fileCursor += segment->SegmentLength();
103 |
104 | FlashSegments.append(segment);
105 | }
106 | this->setFlashSegments(FlashSegments);
107 |
108 | qDbg() << "Qualifier" << this->Qualifier();
109 | qDbg() << "FlashDataInfo_Idk" << this->FlashDataInfo_Idk();
110 | qDbg() << "BlockLength " << this->BlockLength();
111 | qDbg() << "FlashData " << this->FlashData();
112 | qDbg() << "FileName " << this->FileName();
113 | qDbg() << "LongName " << this->LongName();
114 |
115 | }
116 |
117 | void CFFFlashDataBlock::updateModel(CFFFlashSegmentModel * model)
118 | {
119 | qDbg() << "update blocks model!";
120 | model->addFlashSegments(this->m_FlashSegments);
121 | }
122 |
123 | QString CFFFlashDataBlock::exportSegments(QString fpath, QString prefix)
124 | {
125 | if(fpath.startsWith(QStringLiteral("file:")))
126 | {
127 | fpath = QDir::toNativeSeparators(QUrl(fpath).toLocalFile());
128 | }
129 | else fpath = QDir::toNativeSeparators(fpath);
130 |
131 | if(!fpath.endsWith(QDir::separator()))
132 | {
133 | fpath.append(QDir::separator());
134 | }
135 |
136 | foreach(auto segment, this->FlashSegments())
137 | {
138 | qDbg() << "Segment: " << fpath+prefix+"_"+this->FlashDataInfo_Idk()+QLatin1String("_")+segment->SegmentName()+".segment";
139 | QFile seg_file(fpath+prefix+"_"+this->FlashDataInfo_Idk()+QLatin1String("_")+segment->SegmentName()+".segment");
140 | if(seg_file.open(QIODevice::WriteOnly))
141 | {
142 | seg_file.write(segment->readFlashSegment());
143 | seg_file.close();
144 | }
145 | }
146 |
147 | return fpath;
148 | }
149 |
--------------------------------------------------------------------------------
/cffflashdatablock.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHDATABLOCK_H
2 | #define CFFFLASHDATABLOCK_H
3 |
4 |
5 | #include
6 | #include
7 |
8 | #include
9 | #include "cffflashsegment.h"
10 | #include "cffflashsegmentmodel.h"
11 |
12 | class CFFFlashDataBlock : public QObject
13 | {
14 | Q_OBJECT
15 | public:
16 | CFFFlashDataBlock(QObject *parent = nullptr);
17 | static CFFFlashDataBlock * readFlashDataBlock(QFile * cff, long baseAddress, uint32_t CffHeaderSize, uint32_t LanguageBlockLength, QObject * parent = Q_NULLPTR);
18 |
19 | Q_PROPERTY(QString Qualifier READ Qualifier WRITE setQualifier NOTIFY QualifierChanged);
20 | Q_PROPERTY(QString DataBlockType READ DataBlockType WRITE setDataBlockType NOTIFY DataBlockTypeChanged);
21 | Q_PROPERTY(QString FlashDataInfo_Idk READ FlashDataInfo_Idk WRITE setFlashDataInfo_Idk NOTIFY FlashDataInfo_IdkChanged);
22 | Q_PROPERTY(int32_t LongName READ LongName WRITE setLongName NOTIFY LongNameChanged);
23 | Q_PROPERTY(int32_t Description READ Description WRITE setDescription NOTIFY DescriptionChanged);
24 | Q_PROPERTY(int32_t FlashData READ FlashData WRITE setFlashData NOTIFY FlashDataChanged);
25 | Q_PROPERTY(int32_t BlockLength READ BlockLength WRITE setBlockLength NOTIFY BlockLengthChanged);
26 | Q_PROPERTY(int32_t DataFormat READ DataFormat WRITE setDataFormat NOTIFY DataFormatChanged);
27 | Q_PROPERTY(int32_t FileName READ FileName WRITE setFileName NOTIFY FileNameChanged);
28 | Q_PROPERTY(int32_t NumberOfFilters READ NumberOfFilters WRITE setNumberOfFilters NOTIFY NumberOfFiltersChanged);
29 | Q_PROPERTY(int32_t FiltersOffset READ FiltersOffset WRITE setFiltersOffset NOTIFY FiltersOffsetChanged);
30 | Q_PROPERTY(int32_t NumberOfSegments READ NumberOfSegments WRITE setNumberOfSegments NOTIFY NumberOfSegmentsChanged);
31 | Q_PROPERTY(int32_t SegmentOffset READ SegmentOffset WRITE setSegmentOffset NOTIFY SegmentOffsetChanged);
32 | Q_PROPERTY(int32_t EncryptionMode READ EncryptionMode WRITE setEncryptionMode NOTIFY EncryptionModeChanged);
33 | Q_PROPERTY(int32_t KeyLength READ KeyLength WRITE setKeyLength NOTIFY KeyLengthChanged);
34 | Q_PROPERTY(int32_t KeyBuffer READ KeyBuffer WRITE setKeyBuffer NOTIFY KeyBufferChanged);
35 | Q_PROPERTY(int32_t NumberOfOwnIdents READ NumberOfOwnIdents WRITE setNumberOfOwnIdents NOTIFY NumberOfOwnIdentsChanged);
36 | Q_PROPERTY(int32_t IdentsOffset READ IdentsOffset WRITE setIdentsOffset NOTIFY IdentsOffsetChanged);
37 | Q_PROPERTY(int32_t NumberOfSecurities READ NumberOfSecurities WRITE setNumberOfSecurities NOTIFY NumberOfSecuritiesChanged);
38 | Q_PROPERTY(int32_t SecuritiesOffset READ SecuritiesOffset WRITE setSecuritiesOffset NOTIFY SecuritiesOffsetChanged);
39 | Q_PROPERTY(int32_t UniqueObjectId READ UniqueObjectId WRITE setUniqueObjectId NOTIFY UniqueObjectIdChanged);
40 | Q_PROPERTY(int32_t FlashDataInfoLang1 READ FlashDataInfoLang1 WRITE setFlashDataInfoLang1 NOTIFY FlashDataInfoLang1Changed);
41 | Q_PROPERTY(int32_t FlashDataInfoLang2 READ FlashDataInfoLang2 WRITE setFlashDataInfoLang2 NOTIFY FlashDataInfoLang2Changed);
42 | Q_PROPERTY(int32_t FlashDataInfo_Idk2 READ FlashDataInfo_Idk2 WRITE setFlashDataInfo_Idk2 NOTIFY FlashDataInfo_Idk2Changed);
43 | Q_PROPERTY(QList FlashSegments READ FlashSegments WRITE setFlashSegments NOTIFY FlashSegmentsChanged);
44 | Q_PROPERTY(long BaseAddress READ BaseAddress WRITE setBaseAddress NOTIFY BaseAdressChanged);
45 |
46 | Q_INVOKABLE void updateModel(CFFFlashSegmentModel * model);
47 | Q_INVOKABLE QString exportSegments(QString fpath, QString prefix = QLatin1String());
48 |
49 | QString Qualifier(){return this->m_Qualifier;}
50 | int32_t LongName(){return this->m_LongName;}
51 | int32_t Description(){return this->m_Description;}
52 | int32_t FlashData(){return this->m_FlashData;}
53 | int32_t BlockLength(){return this->m_BlockLength;}
54 | int32_t DataFormat(){return this->m_DataFormat;}
55 | int32_t FileName(){return this->m_FileName;}
56 | int32_t NumberOfFilters(){return this->m_NumberOfFilters;}
57 | int32_t FiltersOffset(){return this->m_FiltersOffset;}
58 | int32_t NumberOfSegments(){return this->m_NumberOfSegments;}
59 | int32_t SegmentOffset(){return this->m_SegmentOffset;}
60 | int32_t EncryptionMode(){return this->m_EncryptionMode;}
61 | int32_t KeyLength(){return this->m_KeyLength;}
62 | int32_t KeyBuffer(){return this->m_KeyBuffer;}
63 | int32_t NumberOfOwnIdents(){return this->m_NumberOfOwnIdents;}
64 | int32_t IdentsOffset(){return this->m_IdentsOffset;}
65 | int32_t NumberOfSecurities(){return this->m_NumberOfSecurities;}
66 | int32_t SecuritiesOffset(){return this->m_SecuritiesOffset;}
67 | QString DataBlockType(){return this->m_DataBlockType;}
68 | int32_t UniqueObjectId(){return this->m_UniqueObjectId;}
69 | QString FlashDataInfo_Idk(){return this->m_FlashDataInfo_Idk;}
70 | int32_t FlashDataInfoLang1(){return this->m_FlashDataInfoLang1;}
71 | int32_t FlashDataInfoLang2(){return this->m_FlashDataInfoLang2;}
72 | int32_t FlashDataInfo_Idk2(){return this->m_FlashDataInfo_Idk2;}
73 | QList FlashSegments(){return this->m_FlashSegments;}
74 | long BaseAddress(){return this->m_BaseAddress;}
75 |
76 | void setQualifier(QString data){this->m_Qualifier = data; emit QualifierChanged();}
77 | void setLongName(int32_t data){this->m_LongName = data; emit LongNameChanged();}
78 | void setDescription(int32_t data){this->m_Description = data; emit DescriptionChanged();}
79 | void setFlashData(int32_t data){this->m_FlashData = data; emit FlashDataChanged();}
80 | void setBlockLength(int32_t data){this->m_BlockLength = data; emit BlockLengthChanged();}
81 | void setDataFormat(int32_t data){this->m_DataFormat = data; emit DataFormatChanged();}
82 | void setFileName(int32_t data){this->m_FileName = data; emit FileNameChanged();}
83 | void setNumberOfFilters(int32_t data){this->m_NumberOfFilters = data; emit NumberOfFiltersChanged();}
84 | void setFiltersOffset(int32_t data){this->m_FiltersOffset = data; emit FiltersOffsetChanged();}
85 | void setNumberOfSegments(int32_t data){this->m_NumberOfSegments = data; emit NumberOfSegmentsChanged();}
86 | void setSegmentOffset(int32_t data){this->m_SegmentOffset = data; emit SegmentOffsetChanged();}
87 | void setEncryptionMode(int32_t data){this->m_EncryptionMode = data; emit EncryptionModeChanged();}
88 | void setKeyLength(int32_t data){this->m_KeyLength = data; emit KeyLengthChanged();}
89 | void setKeyBuffer(int32_t data){this->m_KeyBuffer = data; emit KeyBufferChanged();}
90 | void setNumberOfOwnIdents(int32_t data){this->m_NumberOfOwnIdents = data; emit NumberOfOwnIdentsChanged();}
91 | void setIdentsOffset(int32_t data){this->m_IdentsOffset = data; emit IdentsOffsetChanged();}
92 | void setNumberOfSecurities(int32_t data){this->m_NumberOfSecurities = data; emit NumberOfSecuritiesChanged();}
93 | void setSecuritiesOffset(int32_t data){this->m_SecuritiesOffset = data; emit SecuritiesOffsetChanged();}
94 | void setDataBlockType(QString data){this->m_DataBlockType = data; emit DataBlockTypeChanged();}
95 | void setUniqueObjectId(int32_t data){this->m_UniqueObjectId = data; emit UniqueObjectIdChanged();}
96 | void setFlashDataInfo_Idk(QString data){this->m_FlashDataInfo_Idk = data; emit FlashDataInfo_IdkChanged();}
97 | void setFlashDataInfoLang1(int32_t data){this->m_FlashDataInfoLang1 = data; emit FlashDataInfoLang1Changed();}
98 | void setFlashDataInfoLang2(int32_t data){this->m_FlashDataInfoLang2 = data; emit FlashDataInfoLang2Changed();}
99 | void setFlashDataInfo_Idk2(int32_t data){this->m_FlashDataInfo_Idk2 = data; emit FlashDataInfo_Idk2Changed();}
100 | void setBaseAddress(long data){this->m_BaseAddress = data; emit BaseAdressChanged();}
101 | void setFlashSegments(QList data){this->m_FlashSegments = data; emit FlashSegmentsChanged();}
102 |
103 | private:
104 | void readCFFData(QFile * cff, long baseAddress);
105 |
106 | signals:
107 | void QualifierChanged();
108 | void LongNameChanged();
109 | void DescriptionChanged();
110 | void FlashDataChanged();
111 | void BlockLengthChanged();
112 | void DataFormatChanged();
113 | void FileNameChanged();
114 | void NumberOfFiltersChanged();
115 | void FiltersOffsetChanged();
116 | void NumberOfSegmentsChanged();
117 | void SegmentOffsetChanged();
118 | void EncryptionModeChanged();
119 | void KeyLengthChanged();
120 | void KeyBufferChanged();
121 | void NumberOfOwnIdentsChanged();
122 | void IdentsOffsetChanged();
123 | void NumberOfSecuritiesChanged();
124 | void SecuritiesOffsetChanged();
125 | void DataBlockTypeChanged();
126 | void UniqueObjectIdChanged();
127 | void FlashDataInfo_IdkChanged();
128 | void FlashDataInfoLang1Changed();
129 | void FlashDataInfoLang2Changed();
130 | void FlashDataInfo_Idk2Changed();
131 | void FlashSegmentsChanged();
132 | void BaseAdressChanged();
133 |
134 | private:
135 | QString m_Qualifier;
136 | int32_t m_LongName;
137 | int32_t m_Description;
138 | int32_t m_FlashData;
139 | int32_t m_BlockLength;
140 | int32_t m_DataFormat;
141 | int32_t m_FileName;
142 | int32_t m_NumberOfFilters;
143 | int32_t m_FiltersOffset;
144 | int32_t m_NumberOfSegments;
145 | int32_t m_SegmentOffset;
146 | int32_t m_EncryptionMode;
147 | int32_t m_KeyLength;
148 | int32_t m_KeyBuffer;
149 | int32_t m_NumberOfOwnIdents;
150 | int32_t m_IdentsOffset;
151 | int32_t m_NumberOfSecurities;
152 | int32_t m_SecuritiesOffset;
153 | QString m_DataBlockType;
154 | int32_t m_UniqueObjectId;
155 | QString m_FlashDataInfo_Idk;
156 | int32_t m_FlashDataInfoLang1;
157 | int32_t m_FlashDataInfoLang2;
158 | int32_t m_FlashDataInfo_Idk2;
159 | QList m_FlashSegments;
160 | long m_BaseAddress;
161 |
162 | uint32_t m_CffHeaderSize;
163 | uint32_t m_LanguageBlockLength;
164 |
165 | };
166 |
167 | #endif // CFFFLASHDATABLOCK_H
168 |
--------------------------------------------------------------------------------
/cffflashdatablocksmodel.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashdatablocksmodel.h"
3 | #include "cffflashdatablock.h"
4 |
5 | CFFFlashDataBlocksModel::CFFFlashDataBlocksModel(QObject *parent):QAbstractListModel(parent)
6 | {
7 | this->m_roles[Name] = "Name";
8 | this->m_roles[FlashDataBlock] = "FlashDataBlock";
9 | }
10 |
11 |
12 | QVariant CFFFlashDataBlocksModel::data(const QModelIndex &index, int role) const
13 | {
14 | qDbg() << " DATA " << index.row() << role;
15 | if (index.row() < 0 || index.row() > this->m_objs.size())return QVariant();
16 |
17 | auto block = this->m_objs[index.row()];
18 |
19 | switch(role)
20 | {
21 | case Name:
22 | return block->FileName();
23 | }
24 |
25 | return QVariant::fromValue(block);
26 | }
27 |
28 | void CFFFlashDataBlocksModel::addFlashDataBlocks(QList blocks)
29 | {
30 | qDbg() << "ADD BLOCKS" << blocks.count();
31 | //this->beginInsertRows(QModelIndex(), this->rowCount(), blocks.count()-1);
32 | //this->m_objs = blocks;
33 | //this->endInsertRows();
34 |
35 | foreach(auto block, blocks)
36 | {
37 | this->addFlashDataBlock(block);
38 | }
39 | }
40 |
41 | void CFFFlashDataBlocksModel::addFlashDataBlock(CFFFlashDataBlock * block)
42 | {
43 |
44 | this->beginInsertRows(QModelIndex(), this->rowCount(), this->rowCount());
45 | this->m_objs.append(block);
46 | this->endInsertRows();
47 | }
48 |
49 | void CFFFlashDataBlocksModel::removeFlashDataBlock(CFFFlashDataBlock * block)
50 | {
51 | auto idx = this->m_objs.indexOf(block);
52 | this->beginRemoveRows(QModelIndex(), idx, idx);
53 | this->m_objs.removeOne(block);
54 | this->endRemoveRows();
55 | }
56 |
57 | CFFFlashDataBlock * CFFFlashDataBlocksModel::blockAt(qint32 index)
58 | {
59 | if(index < this->rowCount())return this->m_objs.at(index);
60 | else return new CFFFlashDataBlock(this);
61 | }
62 |
--------------------------------------------------------------------------------
/cffflashdatablocksmodel.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHDATABLOCKSMODEL_H
2 | #define CFFFLASHDATABLOCKSMODEL_H
3 |
4 | #include
5 | #include
6 |
7 | #include "cffflashdatablock.h"
8 |
9 | class CFFFlashDataBlocksModel : public QAbstractListModel
10 | {
11 | Q_OBJECT
12 |
13 | public:
14 | explicit CFFFlashDataBlocksModel(QObject *parent = nullptr);
15 |
16 | enum ListRoles
17 | {
18 | Name = Qt::UserRole+1,
19 | FlashDataBlock
20 | };
21 |
22 | int rowCount(const QModelIndex &parent = QModelIndex()) const override {Q_UNUSED(parent) return this->m_objs.count();}
23 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
24 | QHash roleNames() const override{return this->m_roles;}
25 |
26 | Q_INVOKABLE void addFlashDataBlock(CFFFlashDataBlock *);
27 | Q_INVOKABLE void addFlashDataBlocks(QList);
28 | Q_INVOKABLE void removeFlashDataBlock(CFFFlashDataBlock *);
29 | Q_INVOKABLE CFFFlashDataBlock * blockAt(qint32 index);
30 |
31 | Q_INVOKABLE QList getFlashDataBlocks(){return this->m_objs;}
32 |
33 | private:
34 | QList m_objs;
35 | QHash m_roles;
36 | };
37 |
38 | #endif // CFFFLASHDATABLOCKSMODEL_H
39 |
--------------------------------------------------------------------------------
/cffflashdescriptionheader.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashdescriptionheader.h"
3 |
4 |
5 | CFFFlashDescriptionHeader::CFFFlashDescriptionHeader(QObject *parent):QObject(parent)
6 | {
7 |
8 | }
9 |
10 |
11 | CFFFlashDescriptionHeader * CFFFlashDescriptionHeader::readDescriptionHeader(QFile * cff, long baseAddress, QObject * parent)
12 | {
13 | auto cff_descr_header = new CFFFlashDescriptionHeader(parent);
14 | cff_descr_header->readCFFData(cff, baseAddress);
15 | return cff_descr_header;
16 | }
17 |
18 | void CFFFlashDescriptionHeader::readCFFData(QFile * cff, long baseAddress)
19 | {
20 | this->setBaseAddress(baseAddress);
21 |
22 | cff->seek(baseAddress);
23 | ulong flashBitFlags = 0;
24 | cff->read((char*)&flashBitFlags, 4);
25 |
26 | this->setQualifier(CFFUtils::ReadBitflagString(flashBitFlags, cff, baseAddress));
27 | int32_t Description = ReadBitflag4Byte(Description, flashBitFlags, cff);
28 | this->setDescription(Description);
29 | int32_t FlashAreaName = ReadBitflag4Byte(FlashAreaName, flashBitFlags, cff);
30 | this->setFlashAreaName(FlashAreaName);
31 | int32_t FlashTableStructureCount = ReadBitflag4Byte(FlashTableStructureCount, flashBitFlags, cff);
32 | this->setFlashTableStructureCount(FlashTableStructureCount);
33 | int32_t FlashTableStructureOffset = ReadBitflag4Byte(FlashTableStructureOffset, flashBitFlags, cff);
34 | this->setFlashTableStructureOffset(FlashTableStructureOffset);
35 | int32_t NumberOfUploads = ReadBitflag4Byte(NumberOfUploads, flashBitFlags, cff);
36 | this->setNumberOfUploads(NumberOfUploads);
37 | int32_t UploadTableRefTable = ReadBitflag4Byte(UploadTableRefTable, flashBitFlags, cff);
38 | this->setUploadTableRefTable(UploadTableRefTable);
39 | int32_t NumberOfIdentServices = ReadBitflag4Byte(NumberOfIdentServices, flashBitFlags, cff);
40 | this->setNumberOfIdentServices(NumberOfIdentServices);
41 | int32_t IdentServicesOffset = ReadBitflag4Byte(IdentServicesOffset, flashBitFlags, cff);
42 | this->setIdentServicesOffset(IdentServicesOffset);
43 | int32_t UniqueObjectID = ReadBitflag4Byte(UniqueObjectID, flashBitFlags, cff);
44 | this->setUniqueObjectID(UniqueObjectID);
45 | int32_t unkb = ReadBitflag4Byte(unkb, flashBitFlags, cff);
46 | this->setunkb(unkb);
47 | int32_t unkc = ReadBitflag4Byte(unkc, flashBitFlags, cff);
48 | this->setunkc(unkc);
49 |
50 | qDbg() << "BaseAddress: " << this->BaseAddress();
51 | qDbg() << "Qualifier: " << this->Qualifier();
52 | qDbg() << "FlashAreaName: " << this->FlashAreaName();
53 | qDbgVar(NumberOfUploads);
54 | qDbgVar(UniqueObjectID);
55 | }
56 |
--------------------------------------------------------------------------------
/cffflashdescriptionheader.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHDESCRIPTIONHEADER_H
2 | #define CFFFLASHDESCRIPTIONHEADER_H
3 |
4 | #include
5 | #include
6 |
7 | class CFFFlashDescriptionHeader : public QObject
8 | {
9 | Q_OBJECT
10 |
11 | public:
12 | explicit CFFFlashDescriptionHeader(QObject *parent = nullptr);
13 | static CFFFlashDescriptionHeader * readDescriptionHeader(QFile * cff, long baseAddress, QObject * parent = Q_NULLPTR);
14 |
15 | Q_PROPERTY(QString Qualifier READ Qualifier WRITE setQualifier NOTIFY QualifierChanged);
16 | Q_PROPERTY(int32_t Description READ Description WRITE setDescription NOTIFY DescriptionChanged);
17 | Q_PROPERTY(int32_t FlashAreaName READ FlashAreaName WRITE setFlashAreaName NOTIFY FlashAreaNameChanged);
18 | Q_PROPERTY(int32_t FlashTableStructureCount READ FlashTableStructureCount WRITE setFlashTableStructureCount NOTIFY FlashTableStructureCountChanged);
19 | Q_PROPERTY(int32_t FlashTableStructureOffset READ FlashTableStructureOffset WRITE setFlashTableStructureOffset NOTIFY FlashTableStructureOffsetChanged);
20 | Q_PROPERTY(int32_t NumberOfUploads READ NumberOfUploads WRITE setNumberOfUploads NOTIFY NumberOfUploadsChanged);
21 | Q_PROPERTY(int32_t UploadTableRefTable READ UploadTableRefTable WRITE setUploadTableRefTable NOTIFY UploadTableRefTableChanged);
22 | Q_PROPERTY(int32_t NumberOfIdentServices READ NumberOfIdentServices WRITE setNumberOfIdentServices NOTIFY NumberOfIdentServicesChanged);
23 | Q_PROPERTY(int32_t IdentServicesOffset READ IdentServicesOffset WRITE setIdentServicesOffset NOTIFY IdentServicesOffsetChanged);
24 | Q_PROPERTY(int32_t UniqueObjectID READ UniqueObjectID WRITE setUniqueObjectID NOTIFY UniqueObjectIDChanged);
25 | Q_PROPERTY(int32_t unkb READ unkb WRITE setunkb NOTIFY unkbChanged);
26 | Q_PROPERTY(int32_t unkc READ unkc WRITE setunkc NOTIFY unkcChanged);
27 | Q_PROPERTY(long BaseAddress READ BaseAddress WRITE setBaseAddress NOTIFY BaseAddressChanged);
28 |
29 | QString Qualifier(){return this->m_Qualifier;}
30 | int32_t Description(){return this->m_Description;}
31 | int32_t FlashAreaName(){return this->m_FlashAreaName;}
32 | int32_t FlashTableStructureCount(){return this->m_FlashTableStructureCount;}
33 | int32_t FlashTableStructureOffset(){return this->m_FlashTableStructureOffset;}
34 | int32_t NumberOfUploads(){return this->m_NumberOfUploads;}
35 | int32_t UploadTableRefTable(){return this->m_UploadTableRefTable;}
36 | int32_t NumberOfIdentServices(){return this->m_NumberOfIdentServices;}
37 | int32_t IdentServicesOffset(){return this->m_IdentServicesOffset;}
38 | int32_t UniqueObjectID(){return this->m_UniqueObjectID;}
39 | int32_t unkb(){return this->m_unkb;}
40 | int32_t unkc(){return this->m_unkc;}
41 | long BaseAddress(){return this->m_BaseAddress;}
42 |
43 | void setQualifier(QString data){this->m_Qualifier = data; emit QualifierChanged();}
44 | void setDescription(int32_t data){this->m_Description = data; emit DescriptionChanged();}
45 | void setFlashAreaName(int32_t data){this->m_FlashAreaName = data; emit FlashAreaNameChanged();}
46 | void setFlashTableStructureCount(int32_t data){this->m_FlashTableStructureCount = data; emit FlashTableStructureCountChanged();}
47 | void setFlashTableStructureOffset(int32_t data){this->m_FlashTableStructureOffset = data; emit FlashTableStructureOffsetChanged();}
48 | void setNumberOfUploads(int32_t data){this->m_NumberOfUploads = data; emit NumberOfUploadsChanged();}
49 | void setUploadTableRefTable(int32_t data){this->m_UploadTableRefTable = data; emit UploadTableRefTableChanged();}
50 | void setNumberOfIdentServices(int32_t data){this->m_NumberOfIdentServices = data; emit NumberOfIdentServicesChanged();}
51 | void setIdentServicesOffset(int32_t data){this->m_IdentServicesOffset = data; emit IdentServicesOffsetChanged();}
52 | void setUniqueObjectID(int32_t data){this->m_UniqueObjectID = data; emit UniqueObjectIDChanged();}
53 | void setunkb(int32_t data){this->m_unkb = data; emit unkbChanged();}
54 | void setunkc(int32_t data){this->m_unkc = data; emit unkcChanged();}
55 | void setBaseAddress(long data){this->m_BaseAddress = data; emit BaseAddressChanged();}
56 |
57 | signals:
58 | void QualifierChanged();
59 | void DescriptionChanged();
60 | void FlashAreaNameChanged();
61 | void FlashTableStructureCountChanged();
62 | void FlashTableStructureOffsetChanged();
63 | void NumberOfUploadsChanged();
64 | void UploadTableRefTableChanged();
65 | void NumberOfIdentServicesChanged();
66 | void IdentServicesOffsetChanged();
67 | void UniqueObjectIDChanged();
68 | void unkbChanged();
69 | void unkcChanged();
70 | void BaseAddressChanged();
71 |
72 | private:
73 | void readCFFData(QFile * cff, long baseAddress);
74 |
75 | private:
76 | QString m_Qualifier;
77 | int32_t m_Description;
78 | int32_t m_FlashAreaName;
79 | int32_t m_FlashTableStructureCount;
80 | int32_t m_FlashTableStructureOffset;
81 | int32_t m_NumberOfUploads;
82 | int32_t m_UploadTableRefTable;
83 | int32_t m_NumberOfIdentServices;
84 | int32_t m_IdentServicesOffset;
85 | int32_t m_UniqueObjectID;
86 | int32_t m_unkb;
87 | int32_t m_unkc;
88 | long m_BaseAddress;
89 |
90 |
91 | };
92 |
93 | #endif // CFFFLASHDESCRIPTIONHEADER_H
94 |
--------------------------------------------------------------------------------
/cffflashheader.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashheader.h"
3 | #include "cffflashdescriptionheader.h"
4 | #include "cffflashdatablock.h"
5 | #include "cffflashdatablocksmodel.h"
6 |
7 |
8 |
9 | CFFFlashHeader::CFFFlashHeader(QObject *parent) : QObject(parent)
10 | {
11 |
12 | }
13 |
14 | CFFFlashHeader * CFFFlashHeader::readFlashHeader(QFile * cff, QObject * parent)
15 | {
16 | auto cff_header = new CFFFlashHeader(parent);
17 | cff_header->m_cff_file = cff;
18 | cff_header->readFlash();
19 |
20 | return cff_header;
21 | }
22 |
23 | void CFFFlashHeader::readFlash()
24 | {
25 | this->m_cff_file->seek(0x410);
26 |
27 | this->m_CffHeaderSize = 0;
28 | this->m_cff_file->read((char*)&this->m_CffHeaderSize, 4); emit CffHeaderSizeChanged();
29 | qDbg() << "CffHeaderSize " << this->m_CffHeaderSize;
30 |
31 | this->m_BaseAddress = this->m_cff_file->pos(); emit BaseAddressChanged();
32 |
33 | ulong bitFlags = 0;
34 | this->m_cff_file->read((char*)&bitFlags, 4);
35 |
36 | ushort tmp = 0;
37 | this->m_cff_file->read((char*)&tmp, 2);
38 |
39 | this->setFlashName(CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress));
40 | this->m_FlashGenerationParams = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
41 |
42 | int32_t Unk3 = ReadBitflag4Byte(Unk3, bitFlags, this->m_cff_file);
43 | int32_t Unk4 = ReadBitflag4Byte(Unk4, bitFlags, this->m_cff_file);
44 |
45 | this->setFileAuthor(CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress));
46 | this->setFileCreationTime(CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress));
47 | this->m_AuthoringToolVersion = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
48 | this->m_FTRAFOVersionString = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
49 |
50 | this->m_FTRAFOVersionNumber = ReadBitflag4Byte(this->m_FTRAFOVersionNumber, bitFlags, this->m_cff_file);;
51 |
52 | this->m_CFFVersionString = CFFUtils::ReadBitflagString(bitFlags, this->m_cff_file, this->m_BaseAddress);
53 |
54 | int32_t NumberOfFlashAreas = ReadBitflag4Byte(NumberOfFlashAreas, bitFlags, this->m_cff_file);
55 | int32_t FlashDescriptionTable = ReadBitflag4Byte(FlashDescriptionTable, bitFlags, this->m_cff_file);
56 | int32_t DataBlockTableCountProbably = ReadBitflag4Byte(DataBlockTableCountProbably, bitFlags, this->m_cff_file);
57 | int32_t DataBlockRefTable = ReadBitflag4Byte(DataBlockRefTable, bitFlags, this->m_cff_file);
58 |
59 | this->m_CTFHeaderTable = ReadBitflag4Byte(this->m_CTFHeaderTable, bitFlags, this->m_cff_file); emit CTFHeaderTableChanged();
60 |
61 | int32_t LanguageBlockLength = ReadBitflag4Byte(LanguageBlockLength, bitFlags, this->m_cff_file);
62 | int32_t NumberOfECURefs = ReadBitflag4Byte(NumberOfECURefs, bitFlags, this->m_cff_file);
63 | int32_t ECURefTable = ReadBitflag4Byte(ECURefTable, bitFlags, this->m_cff_file);
64 | int32_t UnkTableCount = ReadBitflag4Byte(UnkTableCount, bitFlags, this->m_cff_file);
65 | int32_t UnkTableProbably = ReadBitflag4Byte(UnkTableProbably, bitFlags, this->m_cff_file);
66 |
67 | int Unk15 = ReadBitflag1Byte(Unk15, bitFlags, this->m_cff_file);
68 |
69 | //this->m_desc_headers = new QList();
70 |
71 | for (int flashDescIndex = 0; flashDescIndex < NumberOfFlashAreas; flashDescIndex++)
72 | {
73 | long flashTableEntryAddress = FlashDescriptionTable + this->m_BaseAddress + (flashDescIndex * 4);
74 |
75 | this->m_cff_file->seek(flashTableEntryAddress);
76 |
77 | int32_t desc_pos = 0;
78 | this->m_cff_file->read((char*)&desc_pos, 4);
79 |
80 | long flashEntryBaseAddress = FlashDescriptionTable + this->m_BaseAddress + desc_pos;
81 |
82 | auto fdh = CFFFlashDescriptionHeader::readDescriptionHeader(this->m_cff_file, flashEntryBaseAddress, this);
83 | this->m_desc_headers.append(fdh);
84 | }
85 | emit FlashDescriptionHeadersChanged();
86 |
87 |
88 | for (int dataBlockIndex = 0; dataBlockIndex < DataBlockTableCountProbably; dataBlockIndex++)
89 | {
90 | long datablockEntryAddress = DataBlockRefTable + this->m_BaseAddress + (dataBlockIndex * 4);
91 | this->m_cff_file->seek(datablockEntryAddress);
92 |
93 | int32_t block_pos = 0;
94 | this->m_cff_file->read((char*)&block_pos, 4);
95 |
96 | long datablockBaseAddress = DataBlockRefTable + this->m_BaseAddress + block_pos;
97 | auto fdb = CFFFlashDataBlock::readFlashDataBlock(this->m_cff_file, datablockBaseAddress, this->CffHeaderSize(), LanguageBlockLength, this);
98 | this->m_flash_data_blocks.append(fdb);
99 | }
100 | emit FlashDataBlocksChanged();
101 |
102 |
103 | qDbg() << "FlashName: " << this->FlashName();
104 | qDbg() << "FlashGenerationParams: " << this->m_FlashGenerationParams;
105 | qDbg() << "Unk3 " << Unk3 << "Unk4 " << Unk4;
106 | qDbg() << "FileAuthor: " << this->FileAuthor();
107 | qDbg() << "FileCreationTime: " << this->m_FileCreationTime;
108 | qDbg() << "AuthoringToolVersion: " << this->m_AuthoringToolVersion;
109 | qDbg() << "FTRAFOVersionString: " << this->m_FTRAFOVersionString;
110 | qDbg() << "FTRAFOVersionNumber: " << this->m_FTRAFOVersionNumber;
111 | qDbg() << "CFFVersionString: " << this->m_CFFVersionString;
112 |
113 | qDbgVar(NumberOfFlashAreas);
114 | qDbgVar(FlashDescriptionTable);
115 | qDbgVar(DataBlockTableCountProbably);
116 | qDbgVar(DataBlockRefTable);
117 | qDbgVar(LanguageBlockLength);
118 | qDbgVar(NumberOfECURefs);
119 | qDbgVar(ECURefTable);
120 | qDbgVar(UnkTableCount);
121 | qDbgVar(UnkTableProbably);
122 | qDbgVar(Unk15);
123 | }
124 |
125 | void CFFFlashHeader::updateModel(CFFFlashDataBlocksModel * model)
126 | {
127 | qDbg() << "update blocks model!";
128 | model->addFlashDataBlocks(this->m_flash_data_blocks);
129 | }
130 |
131 | QString CFFFlashHeader::FileCreationTime()
132 | {
133 | return QDateTime::fromString(this->m_FileCreationTime, Qt::ISODateWithMs).toString("dd.MM.yyyy hh:mm:ss");
134 | }
135 |
--------------------------------------------------------------------------------
/cffflashheader.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHHEADER_H
2 | #define CFFFLASHHEADER_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "cffflashdatablock.h"
9 | #include "cffflashdescriptionheader.h"
10 | #include "cffflashdatablocksmodel.h"
11 |
12 | //class CFFFlashDataBlocksModel;
13 | //class CFFFlashDescriptionHeader;
14 | //class CFFFlashDataBlock;
15 | class CFFFlashHeader : public QObject
16 | {
17 | Q_OBJECT
18 | public:
19 | explicit CFFFlashHeader(QObject *parent = nullptr);
20 | Q_INVOKABLE static CFFFlashHeader * readFlashHeader(QFile * cff, QObject * parent = Q_NULLPTR);
21 |
22 | Q_PROPERTY(QString FlashName READ FlashName WRITE setFlashName NOTIFY FlashNameChanged);
23 | Q_PROPERTY(QString FileAuthor READ FileAuthor WRITE setFileAuthor NOTIFY FileAuthorChanged);
24 | Q_PROPERTY(QString FileCreationTime READ FileCreationTime WRITE setFileCreationTime NOTIFY FileCreationTimeChanged);
25 |
26 | Q_PROPERTY(int32_t CTFHeaderTable READ CTFHeaderTable NOTIFY CTFHeaderTableChanged);
27 | Q_PROPERTY(int32_t CffHeaderSize READ CffHeaderSize NOTIFY CffHeaderSizeChanged);
28 | Q_PROPERTY(QList FlashDescriptionHeaders READ FlashDescriptionHeaders NOTIFY FlashDescriptionHeadersChanged);
29 | Q_PROPERTY(QList FlashDataBlocks READ FlashDataBlocks NOTIFY FlashDataBlocksChanged);
30 | Q_PROPERTY(long BaseAddress READ BaseAddress NOTIFY BaseAddressChanged);
31 |
32 | Q_INVOKABLE void updateModel(CFFFlashDataBlocksModel *);
33 |
34 | int32_t CTFHeaderTable(){return this->m_CTFHeaderTable;}
35 | int32_t CffHeaderSize(){return this->m_CffHeaderSize;}
36 | QList FlashDescriptionHeaders(){return this->m_desc_headers;}
37 | QList FlashDataBlocks(){return this->m_flash_data_blocks;}
38 | long BaseAddress(){return this->m_BaseAddress;}
39 | QString FlashName(){return this->m_FlashName;}
40 | QString FileAuthor(){return this->m_FileAuthor;}
41 | QString FileCreationTime();
42 |
43 | void setFlashName(QString data){this->m_FlashName = data;}
44 | void setFileAuthor(QString data){this->m_FileAuthor = data;}
45 | void setFileCreationTime(QString data){this->m_FileCreationTime = data;}
46 |
47 |
48 | private:
49 | void readFlash();
50 |
51 |
52 | signals:
53 | void CTFHeaderTableChanged();
54 | void CffHeaderSizeChanged();
55 | void FlashDescriptionHeadersChanged();
56 | void FlashDataBlocksChanged();
57 | void BaseAddressChanged();
58 | void FileAuthorChanged();
59 | void FlashNameChanged();
60 | void FileCreationTimeChanged();
61 |
62 | private:
63 | QFile * m_cff_file;
64 |
65 | QString m_FlashName;
66 | QString m_FileAuthor;
67 | QString m_FlashGenerationParams;
68 | QString m_FileCreationTime;
69 | QString m_AuthoringToolVersion;
70 | QString m_FTRAFOVersionString;
71 | int32_t m_FTRAFOVersionNumber;
72 | QString m_CFFVersionString;
73 |
74 |
75 | int32_t m_CTFHeaderTable;
76 | int32_t m_CffHeaderSize;
77 | long m_BaseAddress;
78 |
79 | QList m_desc_headers;
80 | QList m_flash_data_blocks;
81 | };
82 |
83 | #endif // CFFFLASHHEADER_H
84 |
--------------------------------------------------------------------------------
/cffflashsegment.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashsegment.h"
3 | #include
4 |
5 | CFFFlashSegment::CFFFlashSegment(QObject *parent) : QObject(parent)
6 | {
7 |
8 | }
9 |
10 |
11 | CFFFlashSegment * CFFFlashSegment::readFlashSegment(QFile * cff, long baseAddress, long flash_offset, QObject * parent)
12 | {
13 | auto cff_flash_segment = new CFFFlashSegment(parent);
14 | cff_flash_segment->p_cff_file = cff;
15 | cff_flash_segment->m_BaseAddress = baseAddress;
16 | cff_flash_segment->m_flash_offset = flash_offset;
17 | cff_flash_segment->readCFFData();
18 | return cff_flash_segment;
19 | }
20 |
21 |
22 | void CFFFlashSegment::readCFFData()
23 | {
24 | this->p_cff_file->seek(this->BaseAddress());
25 |
26 | ushort tmp = 0;
27 | this->p_cff_file->read((char*)&tmp, 2);
28 | ulong bitFlags = tmp;
29 |
30 | uint32_t FromAddress = ReadBitflag4Byte(FromAddress, bitFlags, this->p_cff_file);
31 | qDbg() << "FromAddr uint " << QString::number(FromAddress, 16) << sizeof(uint32_t);
32 | this->setFromAdress(FromAddress);
33 | uint32_t SegmentLength = ReadBitflag4Byte(SegmentLength, bitFlags, this->p_cff_file);
34 | this->setSegmentLength(SegmentLength);
35 | uint32_t Unk3 = ReadBitflag4Byte(Unk3, bitFlags, this->p_cff_file);
36 | this->setUnk3(Unk3);
37 |
38 | this->setSegmentName(CFFUtils::ReadBitflagString(bitFlags, this->p_cff_file, this->BaseAddress()));
39 |
40 | uint32_t Unk5 = ReadBitflag4Byte(Unk5, bitFlags, this->p_cff_file);
41 | this->setUnk5(Unk5);
42 | uint32_t Unk6 = ReadBitflag4Byte(Unk6, bitFlags, this->p_cff_file);
43 | this->setUnk6(Unk6);
44 | uint32_t Unk7 = ReadBitflag4Byte(Unk7, bitFlags, this->p_cff_file);
45 | this->setUnk7(Unk7);
46 |
47 | qDbg() << "SegmentName " << this->SegmentName();
48 | qDbg() << "SegmentLength " << this->SegmentLength();
49 | qDbg() << "FromAddress " << this->FromAdress() << QString::number(this->FromAdress(), 16);
50 |
51 | qDbg() << "Unks " << Unk3 << Unk5 << Unk6 << Unk7;
52 | }
53 |
54 |
55 | QByteArray CFFFlashSegment::readFlashSegment()
56 | {
57 | QByteArray data;
58 | if(this->FromAdress() <= 0 && this->SegmentLength() <= 0)
59 | {
60 | qDbg() << "FlashSegment not read or no flashsegment data";
61 | return data;
62 | }
63 |
64 | this->p_cff_file->seek(this->m_flash_offset);
65 |
66 | char * buff = new char[this->SegmentLength()];
67 | auto rlen = this->p_cff_file->read(buff, this->SegmentLength());
68 | if(rlen != this->SegmentLength())
69 | {
70 | qDbg() << "Warning: Segment data not complete!";
71 | }
72 | data = QByteArray::fromRawData(buff, this->SegmentLength());
73 |
74 | return data;
75 | }
76 |
77 | QString CFFFlashSegment::saveToFile(QString fpath)
78 | {
79 | if(fpath.startsWith(QStringLiteral("file:")))
80 | {
81 | fpath = QDir::toNativeSeparators(QUrl(fpath).toLocalFile());
82 | }
83 | else fpath = QDir::toNativeSeparators(fpath);
84 |
85 | qDbg() << fpath;
86 |
87 | QFile seg_file(fpath);
88 | if(seg_file.open(QIODevice::WriteOnly))
89 | {
90 | seg_file.write(this->readFlashSegment());
91 | seg_file.close();
92 | }
93 |
94 | return fpath;
95 | }
96 |
--------------------------------------------------------------------------------
/cffflashsegment.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHSEGMENT_H
2 | #define CFFFLASHSEGMENT_H
3 |
4 | #include
5 | #include
6 |
7 |
8 | class CFFFlashSegment : public QObject
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit CFFFlashSegment(QObject *parent = nullptr);
13 | static CFFFlashSegment * readFlashSegment(QFile * cff, long baseAddress, long flash_offset, QObject * parent = Q_NULLPTR);
14 |
15 | Q_PROPERTY(QString SegmentName READ SegmentName WRITE setSegmentName NOTIFY SegmentNameChanged);
16 | Q_PROPERTY(uint32_t FromAdress READ FromAdress WRITE setFromAdress NOTIFY FromAdressChanged);
17 | Q_PROPERTY(uint32_t SegmentLength READ SegmentLength WRITE setSegmentLength NOTIFY SegmentLengthChanged);
18 | Q_PROPERTY(uint32_t Unk3 READ Unk3 WRITE setUnk3 NOTIFY Unk3Changed);
19 | Q_PROPERTY(uint32_t Unk5 READ Unk5 WRITE setUnk5 NOTIFY Unk5Changed);
20 | Q_PROPERTY(uint32_t Unk6 READ Unk6 WRITE setUnk6 NOTIFY Unk6Changed);
21 | Q_PROPERTY(uint32_t Unk7 READ Unk7 WRITE setUnk7 NOTIFY Unk7Changed);
22 | Q_PROPERTY(long BaseAddress READ BaseAddress WRITE setBaseAddress NOTIFY BaseAddressChanged);
23 |
24 | Q_INVOKABLE QByteArray readFlashSegment();
25 | Q_INVOKABLE QString saveToFile(QString fpath);
26 |
27 | QString SegmentName(){return this->m_SegmentName;}
28 | uint32_t FromAdress(){return this->m_FromAdress;}
29 | uint32_t SegmentLength(){return this->m_SegmentLength;}
30 | uint32_t Unk3(){return this->m_Unk3;}
31 | uint32_t Unk5(){return this->m_Unk5;}
32 | uint32_t Unk6(){return this->m_Unk6;}
33 | uint32_t Unk7(){return this->m_Unk7;}
34 | long BaseAddress(){return this->m_BaseAddress;}
35 |
36 | void setSegmentName(QString data){this->m_SegmentName = data; emit SegmentNameChanged();}
37 | void setFromAdress(uint32_t data){this->m_FromAdress= data; emit FromAdressChanged();}
38 | void setSegmentLength(uint32_t data){this->m_SegmentLength= data; emit SegmentLengthChanged();}
39 | void setUnk3(uint32_t data){this->m_Unk3= data; emit Unk3Changed();}
40 | void setUnk5(uint32_t data){this->m_Unk5= data; emit Unk5Changed();}
41 | void setUnk6(uint32_t data){this->m_Unk6= data; emit Unk6Changed();}
42 | void setUnk7(uint32_t data){this->m_Unk7= data; emit Unk7Changed();}
43 | void setBaseAddress(long data){this->m_BaseAddress = data; emit BaseAddressChanged();}
44 |
45 | private:
46 | void readCFFData();
47 |
48 | signals:
49 | void SegmentNameChanged();
50 | void FromAdressChanged();
51 | void SegmentLengthChanged();
52 | void Unk3Changed();
53 | void Unk5Changed();
54 | void Unk6Changed();
55 | void Unk7Changed();
56 | void BaseAddressChanged();
57 |
58 | private:
59 | long m_flash_offset;
60 | QFile * p_cff_file;
61 |
62 | QString m_SegmentName;
63 | uint32_t m_FromAdress;
64 | uint32_t m_SegmentLength;
65 | uint32_t m_Unk3;
66 | uint32_t m_Unk5;
67 | uint32_t m_Unk6;
68 | uint32_t m_Unk7;
69 | long m_BaseAddress;
70 | };
71 |
72 | #endif // CFFFLASHSEGMENT_H
73 |
--------------------------------------------------------------------------------
/cffflashsegmentmodel.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "cffflashsegmentmodel.h"
3 |
4 |
5 | CFFFlashSegmentModel::CFFFlashSegmentModel(QObject *parent):QAbstractListModel(parent)
6 | {
7 | this->m_roles[Name] = "Name";
8 | this->m_roles[FlashSegment] = "FlashSegment";
9 | }
10 |
11 |
12 | QVariant CFFFlashSegmentModel::data(const QModelIndex &index, int role) const
13 | {
14 | qDbg() << " DATA " << index.row() << role;
15 | if (index.row() < 0 || index.row() > this->m_objs.size())return QVariant();
16 |
17 | auto block = this->m_objs[index.row()];
18 |
19 | switch(role)
20 | {
21 | case Name:
22 | return block->SegmentName();
23 | }
24 |
25 | return QVariant::fromValue(block);
26 | }
27 |
28 | void CFFFlashSegmentModel::addFlashSegments(QList blocks)
29 | {
30 | qDbg() << "ADD SEGMENTS" << blocks.count();
31 | //this->beginInsertRows(QModelIndex(), this->rowCount(), blocks.count()-1);
32 | //this->m_objs = blocks;
33 | //this->endInsertRows();
34 |
35 | foreach(auto block, blocks)
36 | {
37 | this->addFlashSegment(block);
38 | }
39 | }
40 |
41 | void CFFFlashSegmentModel::addFlashSegment(CFFFlashSegment * block)
42 | {
43 |
44 | this->beginInsertRows(QModelIndex(), this->rowCount(), this->rowCount());
45 | this->m_objs.append(block);
46 | this->endInsertRows();
47 | }
48 |
49 | void CFFFlashSegmentModel::removeFlashSegment(CFFFlashSegment * block)
50 | {
51 | auto idx = this->m_objs.indexOf(block);
52 | this->beginRemoveRows(QModelIndex(), idx, idx);
53 | this->m_objs.removeOne(block);
54 | this->endRemoveRows();
55 | }
56 |
57 | CFFFlashSegment * CFFFlashSegmentModel::segmentAt(qint32 index)
58 | {
59 | if(index < this->rowCount())return this->m_objs.at(index);
60 | else return new CFFFlashSegment(this);
61 | }
62 |
--------------------------------------------------------------------------------
/cffflashsegmentmodel.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFFLASHSEGMENTMODEL_H
2 | #define CFFFLASHSEGMENTMODEL_H
3 |
4 | #include
5 | #include
6 |
7 | #include "cffflashsegment.h"
8 |
9 | class CFFFlashSegmentModel : public QAbstractListModel
10 | {
11 | Q_OBJECT
12 |
13 | public:
14 | explicit CFFFlashSegmentModel(QObject *parent = nullptr);
15 |
16 | enum ListRoles
17 | {
18 | Name = Qt::UserRole+1,
19 | FlashSegment
20 | };
21 |
22 | int rowCount(const QModelIndex &parent = QModelIndex()) const override {Q_UNUSED(parent) return this->m_objs.count();}
23 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
24 | QHash roleNames() const override{return this->m_roles;}
25 |
26 | Q_INVOKABLE void addFlashSegment(CFFFlashSegment *);
27 | Q_INVOKABLE void addFlashSegments(QList);
28 | Q_INVOKABLE void removeFlashSegment(CFFFlashSegment *);
29 | Q_INVOKABLE CFFFlashSegment * segmentAt(qint32 index);
30 |
31 | Q_INVOKABLE QList getFlashSegments(){return this->m_objs;}
32 |
33 | private:
34 | QList m_objs;
35 | QHash m_roles;
36 | };
37 | #endif // CFFFLASHSEGMENTMODEL_H
38 |
--------------------------------------------------------------------------------
/cffutils.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 |
3 | CFFUtils::CFFUtils(QObject *parent) : QObject(parent)
4 | {
5 |
6 | }
7 |
8 |
9 | bool CFFUtils::CheckAndAdvanceBitflag(ulong & bitFlag)
10 | {
11 | bool flagIsSet = (bitFlag & 1) > 0;
12 | bitFlag >>= 1;
13 | return flagIsSet;
14 | }
15 |
16 |
17 | QString CFFUtils::ReadString(QFile * cff)
18 | {
19 | // read out a string, stopping at the first null terminator
20 | QByteArray writer;
21 |
22 | while (true)
23 | {
24 | char nextByte = 0;
25 | cff->read(&nextByte, 1);
26 | if (nextByte == 0)
27 | {
28 | auto stringRaw = QString(writer);
29 | return stringRaw;
30 | }
31 | else
32 | {
33 | writer.append(nextByte);
34 | }
35 | }
36 |
37 | return QString(writer);
38 | }
39 |
40 |
41 | QString CFFUtils::ReadBitflagString(ulong & bitFlags, QFile * cff, long virtualBase)
42 | {
43 | if (CheckAndAdvanceBitflag(bitFlags))
44 | {
45 | // read the string's offset relative to our current block
46 | int stringOffset = 0;
47 | cff->read((char*)&stringOffset, sizeof(int32_t)); //sizeof = 4
48 | // save our reading cursor
49 | long readerPosition = cff->pos();
50 | // seek to the specified offset, then read out the string
51 | cff->seek(stringOffset + virtualBase);
52 |
53 |
54 | auto result = CFFUtils::ReadString(cff);
55 | // restore our reading cursor
56 | cff->seek(readerPosition);
57 | return result;
58 | }
59 | else
60 | {
61 | // Console.WriteLine("Bitflag was off for string");
62 | return "(flag disabled)";
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/cffutils.h:
--------------------------------------------------------------------------------
1 | #ifndef CFFUTILS_H
2 | #define CFFUTILS_H
3 |
4 | #include
5 | #include
6 |
7 |
8 | #define ReadBitflag4Byte(o,b,f) 0;{if(CFFUtils::CheckAndAdvanceBitflag(b))f->read((char*)&o, 4);}
9 | #define ReadBitflag2Byte(o,b,f) 0;{if(CFFUtils::CheckAndAdvanceBitflag(b))f->read((char*)&o, 2);}
10 | #define ReadBitflag1Byte(o,b,f) 0;{if(CFFUtils::CheckAndAdvanceBitflag(b))f->read((char*)&o, 1);}
11 |
12 |
13 | class CFFUtils : public QObject
14 | {
15 | Q_OBJECT
16 | public:
17 | explicit CFFUtils(QObject *parent = nullptr);
18 |
19 | static bool CheckAndAdvanceBitflag(ulong & bitFlag);
20 |
21 | static QString ReadString(QFile * cff);
22 | static QString ReadBitflagString(ulong & bitFlags, QFile * cff, long virtualBase = 0);
23 |
24 | signals:
25 |
26 | };
27 |
28 | #endif // CFFUTILS_H
29 |
--------------------------------------------------------------------------------
/ctfheader.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "ctfheader.h"
3 |
4 | CTFHeader::CTFHeader(QObject *parent) : QObject(parent)
5 | {
6 |
7 | }
8 |
9 | CTFHeader * CTFHeader::readCTFHeader(QFile * cff, long baseAddress, int32_t headerSize, QObject * parent)
10 | {
11 | auto data = new CTFHeader(parent);
12 | data->readCFFData(cff, baseAddress, headerSize);
13 | return data;
14 | }
15 |
16 | void CTFHeader::readCFFData(QFile * cff, long baseAddress, int32_t headerSize)
17 | {
18 | this->m_BaseAddress = baseAddress;
19 | cff->seek(this->m_BaseAddress);
20 |
21 | ushort tmp = 0;
22 | cff->read((char*)&tmp, 2);
23 | ulong ctfBitflags = tmp;
24 |
25 | int32_t CtfUnk1 = ReadBitflag4Byte(CtfUnk1, ctfBitflags, cff);
26 | this->setCtfUnk1(CtfUnk1);
27 |
28 | this->setQualifier(CFFUtils::ReadBitflagString(ctfBitflags, cff, baseAddress));
29 |
30 | ushort CtfUnk3 = ReadBitflag2Byte(CtfUnk3, ctfBitflags, cff);
31 | this->setCtfUnk3(CtfUnk3);
32 |
33 | int32_t CtfUnk4 = ReadBitflag4Byte(CtfUnk4, ctfBitflags, cff);
34 | this->setCtfUnk4(CtfUnk4);
35 |
36 | qDbg() << "Qualifier" << this->Qualifier();
37 |
38 | this->m_CtfLanguageCount = ReadBitflag4Byte(this->m_CtfLanguageCount, ctfBitflags, cff);
39 | this->m_CtfLanguageTableOffset = ReadBitflag4Byte(this->m_CtfLanguageTableOffset, ctfBitflags, cff);
40 | this->setCtfUnkString(CFFUtils::ReadBitflagString(ctfBitflags, cff, baseAddress));
41 |
42 | qDbg() << " Lang count: " << this->m_CtfLanguageCount;
43 | qDbg() << "CtfUnkString " << this->CtfUnkString();
44 |
45 | long ctfLanguageTableOffsetRelativeToDefintions = this->m_CtfLanguageTableOffset + this->m_BaseAddress;
46 |
47 | // parse every language record
48 | auto CtfLanguages = QList();
49 | for (int languageEntry = 0; languageEntry < this->m_CtfLanguageCount; languageEntry++)
50 | {
51 | long languageTableEntryOffset = ctfLanguageTableOffsetRelativeToDefintions + (languageEntry * 4);
52 |
53 | cff->seek(languageTableEntryOffset);
54 |
55 | int32_t pos = 0;
56 | cff->read((char*)&pos, 4);
57 |
58 | long realLanguageEntryAddress = pos + ctfLanguageTableOffsetRelativeToDefintions;
59 | auto language = CTFLanguage::readCTFLanguage(cff, realLanguageEntryAddress, headerSize);
60 | CtfLanguages.append(language);
61 | }
62 | this->setCtfLanguages(CtfLanguages);
63 | }
64 |
--------------------------------------------------------------------------------
/ctfheader.h:
--------------------------------------------------------------------------------
1 | #ifndef CTFHEADER_H
2 | #define CTFHEADER_H
3 |
4 | #include
5 | #include
6 | #include "ctflanguage.h"
7 |
8 | class CTFHeader : public QObject
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit CTFHeader(QObject *parent = nullptr);
13 | static CTFHeader * readCTFHeader(QFile * cff, long baseAddress, int32_t headerSize, QObject * parent = Q_NULLPTR);
14 |
15 | Q_PROPERTY(QString Qualifier READ Qualifier WRITE setQualifier NOTIFY QualifierChanged);
16 | Q_PROPERTY(int32_t CtfUnk1 READ CtfUnk1 WRITE setCtfUnk1 NOTIFY CtfUnk1Changed);
17 | Q_PROPERTY(int32_t CtfUnk3 READ CtfUnk3 WRITE setCtfUnk3 NOTIFY CtfUnk3Changed);
18 | Q_PROPERTY(int32_t CtfUnk4 READ CtfUnk4 WRITE setCtfUnk4 NOTIFY CtfUnk4Changed);
19 | Q_PROPERTY(QString CtfUnkString READ CtfUnkString WRITE setCtfUnkString NOTIFY CtfUnkStringChanged);
20 | Q_PROPERTY(QList CtfLanguages READ CtfLanguages WRITE setCtfLanguages NOTIFY CtfLanguagesChanged);
21 |
22 | QString Qualifier(){return this->m_Qualifier;}
23 | int32_t CtfUnk1(){return this->m_CtfUnk1;}
24 | int32_t CtfUnk3(){return this->m_CtfUnk3;}
25 | int32_t CtfUnk4(){return this->m_CtfUnk4;}
26 | QString CtfUnkString(){return this->m_CtfUnkString;}
27 | QList CtfLanguages(){return this->m_CtfLanguages;}
28 |
29 | void setQualifier(QString data){this->m_Qualifier = data; emit QualifierChanged();}
30 | void setCtfUnk1(int32_t data){this->m_CtfUnk1 = data; emit CtfUnk1Changed();}
31 | void setCtfUnk3(int32_t data){this->m_CtfUnk3 = data; emit CtfUnk3Changed();}
32 | void setCtfUnk4(int32_t data){this->m_CtfUnk4 = data; emit CtfUnk4Changed();}
33 | void setCtfUnkString(QString data){this->m_CtfUnkString = data; emit CtfUnkStringChanged();}
34 | void setCtfLanguages(QList data){this->m_CtfLanguages = data; emit CtfLanguagesChanged();}
35 |
36 | private:
37 | void readCFFData(QFile * cff, long baseAddress, int32_t headerSize);
38 |
39 | signals:
40 | void QualifierChanged();
41 | void CtfUnk1Changed();
42 | void CtfUnk3Changed();
43 | void CtfUnk4Changed();
44 | void CtfUnkStringChanged();
45 | void CtfLanguagesChanged();
46 |
47 | private:
48 | QString m_Qualifier;
49 | QString m_CtfUnkString;
50 | int32_t m_CtfUnk1;
51 | int32_t m_CtfUnk3;
52 | int32_t m_CtfUnk4;
53 | int32_t m_CtfLanguageCount;
54 | int32_t m_CtfLanguageTableOffset;
55 |
56 | QList m_CtfLanguages;
57 | long m_BaseAddress;
58 | };
59 |
60 | #endif // CTFHEADER_H
61 |
--------------------------------------------------------------------------------
/ctflanguage.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include "ctflanguage.h"
3 |
4 | CTFLanguage::CTFLanguage(QObject *parent) : QObject(parent)
5 | {
6 |
7 | }
8 |
9 | CTFLanguage * CTFLanguage::readCTFLanguage(QFile * cff, long baseAddress, int32_t headerSize, QObject * parent)
10 | {
11 | auto data = new CTFLanguage(parent);
12 | data->readCFFData(cff, baseAddress, headerSize);
13 | return data;
14 | }
15 |
16 | void CTFLanguage::readCFFData(QFile * cff, long baseAddress, int32_t headerSize)
17 | {
18 | this->m_BaseAddress = baseAddress;
19 | cff->seek(this->m_BaseAddress);
20 |
21 | ushort tmp = 0;
22 | cff->read((char*)&tmp, 2);
23 | ulong languageEntryBitflags = tmp;
24 |
25 | this->setQualifier(CFFUtils::ReadBitflagString(languageEntryBitflags, cff, baseAddress));
26 |
27 | ushort LanguageIndex = ReadBitflag2Byte(LanguageIndex, languageEntryBitflags, cff);
28 | this->setLanguageIndex(LanguageIndex);
29 |
30 | this->m_StringPoolSize = ReadBitflag4Byte(this->m_StringPoolSize, languageEntryBitflags, cff);
31 | this->m_MaybeOffsetFromStringPoolBase = ReadBitflag4Byte(this->m_MaybeOffsetFromStringPoolBase, languageEntryBitflags, cff);
32 | this->m_StringCount = ReadBitflag4Byte(this->m_StringCount, languageEntryBitflags, cff);
33 |
34 | this->loadStrings(cff, headerSize);
35 | }
36 |
37 | void CTFLanguage::loadStrings(QFile * cff, int32_t headerSize)
38 | {
39 | QStringList StringEntries;
40 | int caesarStringTableOffset = headerSize + 0x410 + 4; // header.CffHeaderSize; strange that this has to be manually computed
41 | for (int i = 0; i < this->m_StringCount; i++)
42 | {
43 | cff->seek(caesarStringTableOffset + (i * 4));
44 | int32_t stringOffset = 0;
45 | cff->read((char*)&stringOffset, 4);
46 |
47 | cff->seek(caesarStringTableOffset + stringOffset);
48 | auto result = CFFUtils::ReadString(cff);
49 | qDbg() << "String loaded: " << result;
50 | StringEntries.append(result);
51 | }
52 | this->setStringEntries(StringEntries);
53 | }
54 |
--------------------------------------------------------------------------------
/ctflanguage.h:
--------------------------------------------------------------------------------
1 | #ifndef CTFLANGUAGE_H
2 | #define CTFLANGUAGE_H
3 |
4 | #include
5 | #include
6 |
7 |
8 | class CTFLanguage : public QObject
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit CTFLanguage(QObject *parent = nullptr);
13 | static CTFLanguage * readCTFLanguage(QFile * cff, long baseAddress, int32_t headerSize, QObject * parent = Q_NULLPTR);
14 |
15 | Q_PROPERTY(QString Qualifier READ Qualifier WRITE setQualifier NOTIFY QualifierChanged);
16 | Q_PROPERTY(int32_t LanguageIndex READ LanguageIndex WRITE setLanguageIndex NOTIFY LanguageIndexChanged);
17 | Q_PROPERTY(QStringList StringEntries READ StringEntries WRITE setStringEntries NOTIFY StringEntriesChanged);
18 |
19 | QString Qualifier(){return this->m_Qualifier;}
20 | int32_t LanguageIndex(){return this->m_LanguageIndex;}
21 | QStringList StringEntries(){return this->m_StringEntries;}
22 |
23 | void setQualifier(QString data){this->m_Qualifier = data; emit QualifierChanged();}
24 | void setLanguageIndex(int32_t data){this->m_LanguageIndex = data; emit LanguageIndexChanged();}
25 | void setStringEntries(QStringList data){this->m_StringEntries = data; emit StringEntriesChanged();}
26 |
27 | private:
28 | void readCFFData(QFile * cff, long baseAddress, int32_t headerSize);
29 | void loadStrings(QFile * cff, int32_t headerSize);
30 |
31 | signals:
32 | void QualifierChanged();
33 | void LanguageIndexChanged();
34 | void StringEntriesChanged();
35 |
36 | private:
37 | QString m_Qualifier;
38 | int32_t m_LanguageIndex;
39 | QStringList m_StringEntries;
40 | int32_t m_StringPoolSize;
41 | int32_t m_MaybeOffsetFromStringPoolBase;
42 | int32_t m_StringCount;
43 | long m_BaseAddress;
44 |
45 | };
46 |
47 | #endif // CTFLANGUAGE_H
48 |
--------------------------------------------------------------------------------
/defs.h:
--------------------------------------------------------------------------------
1 | #ifndef DEFS_H
2 | #define DEFS_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 |
12 | #define DELETE_OBJ(o){if(o != Q_NULLPTR){delete o; o = Q_NULLPTR;}}
13 | #define DELETE_OBJ_LATER(o){if(o != Q_NULLPTR){o->deleteLater();}}
14 | #define DELETE_STR(s){if(s != Q_NULLPTR){delete [] s; s = Q_NULLPTR;}}
15 |
16 | #define qDbg() qDebug() << "["<< (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) << __func__ << __LINE__ << "]: "
17 | #define qDbgVar(v) qDbg() << #v << v;
18 | #define qMd5(s) QCryptographicHash::hash(s.toLocal8Bit(), QCryptographicHash::Md5).toHex()
19 |
20 | #include "cffutils.h"
21 |
22 | /*
23 | #define MEMWATCH(obj, objq) ExMemWatcher::getInstance()->addObject(reinterpret_cast(obj), QStringLiteral(#objq)); \
24 | connect(obj, &objq::destroyed, [o=obj](){ExMemWatcher::getInstance()->removeObject(reinterpret_cast(o));})
25 | */
26 |
27 | #endif // DEFS_H
28 |
--------------------------------------------------------------------------------
/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Xplatforms/CFFFlashFileTools/4a15655f64811ccecad213240049966cc38dbc38/icon.ico
--------------------------------------------------------------------------------
/images.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/save_btn.svg
4 |
5 |
6 |
--------------------------------------------------------------------------------
/images/save_btn.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | #include "defs.h"
2 | #include
3 | #include
4 |
5 | #include "cffflashcontainer.h"
6 | #include "cffflashheader.h"
7 | #include "cffflashdescriptionheader.h"
8 | #include "cffflashdatablock.h"
9 | #include "cffflashdatablocksmodel.h"
10 | #include "cffflashsegment.h"
11 | #include "cffflashsegmentmodel.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
16 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
17 | #endif
18 |
19 | QApplication app(argc, argv);
20 |
21 | app.setApplicationName("CFFFlashFileTools");
22 | app.setApplicationVersion("0.1_alpha");
23 | app.setOrganizationName("xplatforms");
24 |
25 | qRegisterMetaType("uint32_t");
26 | qmlRegisterType("xplatforms.cffflashcontainer.container", 1, 0, "CFFFlashContainer");
27 | qmlRegisterType("xplatforms.cffflashcontainer.flashheader", 1, 0, "CFFFlashHeader");
28 | qmlRegisterType("xplatforms.cffflashcontainer.flashblock", 1, 0, "CFFFlashDataBlock");
29 | qmlRegisterType("xplatforms.cffflashcontainer.flashsegment", 1, 0, "CFFFlashSegment");
30 | qmlRegisterType("xplatforms.cffflashcontainer.flashblocksmodel", 1, 0, "CFFFlashDataBlocksModel");
31 | qmlRegisterType("xplatforms.cffflashcontainer.flashsegmentmodel", 1, 0, "CFFFlashSegmentModel");
32 |
33 |
34 |
35 | QQmlApplicationEngine engine;
36 | const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
37 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
38 | &app, [url](QObject *obj, const QUrl &objUrl) {
39 | if (!obj && url == objUrl)
40 | QCoreApplication::exit(-1);
41 | }, Qt::QueuedConnection);
42 | engine.load(url);
43 |
44 | return app.exec();
45 | }
46 |
47 |
48 | /*
49 | auto cff = CFFFlashContainer::openCaesarFlashContainer("c:\\Dev\\2194470151_001.cff", obj);
50 |
51 | auto header = cff->readHeader();
52 | auto cff_header = cff->readCFFHeader();
53 | auto cff_chksum = cff->readChecksum();
54 | auto cff_calc_chksum = cff->genChecksum();
55 | auto cff_flash_header = cff->readFlashCFF();
56 | auto ctf_header = cff->readCTF();
57 |
58 | qDbg() << " foreach data bloc";
59 | foreach(auto db, cff_flash_header->FlashDataBlocks())
60 | {
61 | foreach(auto segment, db->FlashSegments())
62 | {
63 | qDbg() << "Segment: " << segment->SegmentName();
64 | QFile seg_file("c:\\Dev\\MB\\"+segment->SegmentName()+".flash");
65 | if(seg_file.open(QIODevice::WriteOnly))
66 | {
67 | seg_file.write(segment->readFlashSegment());
68 | seg_file.close();
69 | }
70 | }
71 | }*/
72 |
73 | //foreach(auto db , cff_flash_header->)
74 |
--------------------------------------------------------------------------------
/qml.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | qml/main.qml
4 | qtquickcontrols2.conf
5 | qml/HomeScreen.qml
6 | qml/FlashInfoScreen.qml
7 | qml/FlashDataBlockDelegate.qml
8 | qml/FlashSegmentModel.qml
9 |
10 |
11 |
--------------------------------------------------------------------------------
/qml/FlashDataBlockDelegate.qml:
--------------------------------------------------------------------------------
1 | import QtQuick
2 | import QtQuick.Layouts
3 | import QtQuick.Controls
4 | import Qt.labs.platform
5 |
6 | import xplatforms.cffflashcontainer.flashheader 1.0
7 | import xplatforms.cffflashcontainer.flashblock 1.0
8 | import xplatforms.cffflashcontainer.flashsegment 1.0
9 | import xplatforms.cffflashcontainer.flashsegmentmodel 1.0
10 |
11 |
12 | ColumnLayout
13 | {
14 | property CFFFlashHeader header;
15 | property CFFFlashDataBlock block;
16 | property CFFFlashSegmentModel segments_model: CFFFlashSegmentModel{}
17 | Component.onCompleted: {
18 | block.updateModel(segments_model);
19 | //segments_model.addFlashSegments(block.FlashSegments);
20 | console.log("Component width: " + width)
21 | }
22 |
23 | Layout.fillWidth: true
24 |
25 | RowLayout
26 | {
27 | Label{
28 | font.bold: true
29 | text: "qualifier: "
30 | }
31 | Label{text: block.Qualifier}
32 | //Label{text: "test"}
33 | }
34 |
35 | RowLayout
36 | {
37 | Layout.fillWidth: true
38 | Label{
39 | font.bold: true
40 | text: "FlashDataInfo_Idk: "
41 | }
42 | Label{text: block.FlashDataInfo_Idk}
43 | //Label{text: "test"}
44 | Rectangle
45 | {
46 | height: 1
47 | Layout.fillWidth: true
48 | }
49 | Button
50 | {
51 | id: btn_export_all
52 |
53 | text: " Export all segments... "
54 | onClicked:
55 | {
56 | console.log("export all segments");
57 | export_dialog.open();
58 |
59 | }
60 | }
61 | }
62 |
63 | Rectangle
64 | {
65 | Layout.fillWidth: true
66 | height: 1
67 | color: "black"
68 | }
69 |
70 | Rectangle
71 | {
72 | Layout.fillWidth: true
73 | height: 10
74 | color: "white"
75 | }
76 |
77 | ListView
78 | {
79 | Layout.fillHeight: true
80 | Layout.fillWidth: true
81 | implicitHeight: 220
82 | snapMode: ListView.SnapOneItem
83 | //height: 200
84 | model: segments_model
85 | //block.getSegmentsModel()//segments_model.addFlashSegments(block.FlashSegments)
86 | delegate: FlashSegmentModel{flash_name: header.FlashName; idk: block.FlashDataInfo_Idk; segment: FlashSegment}
87 | }
88 |
89 | FolderDialog
90 | {
91 | id: export_dialog
92 | title: "Please choose where to export flash segments"
93 | //fileMode: FolderDialog.OpenFolder
94 | //folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
95 |
96 | //nameFilters: [FlashSegment.SegmentName+".segment"]
97 |
98 | onAccepted: {
99 | console.log("You chose: " + export_dialog.folder)
100 | ttip_id.show("Segments saved to: " +block.exportSegments(export_dialog.folder, header.FlashName), 2500);
101 | }
102 | onRejected: {
103 | console.log("Canceled")
104 | //Qt.quit()
105 | }
106 | //Component.onCompleted: visible = true
107 | }
108 |
109 | ToolTip
110 | {
111 | id: ttip_id
112 | //parent: parent//btn_export_all
113 | anchors.centerIn: parent
114 | margins: 20
115 | }
116 | }
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/qml/FlashInfoScreen.qml:
--------------------------------------------------------------------------------
1 | import QtQuick
2 | import QtQuick.Controls
3 | import QtQuick.Layouts
4 | import QtQuick.Dialogs
5 |
6 | import xplatforms.cffflashcontainer.container 1.0
7 | import xplatforms.cffflashcontainer.flashheader 1.0
8 | import xplatforms.cffflashcontainer.flashblock 1.0
9 | import xplatforms.cffflashcontainer.flashblocksmodel 1.0
10 | import xplatforms.cffflashcontainer.flashsegmentmodel 1.0
11 |
12 | Page {
13 |
14 | title: qsTr("CFF Flash Files Tools")
15 | padding: 5
16 |
17 | property CFFFlashContainer cff: CFFFlashContainer{}
18 | property CFFFlashDataBlocksModel blocks_model: CFFFlashDataBlocksModel{}
19 | property CFFFlashHeader flash_header: null
20 | property int cff_checksum: 0
21 | property int cff_calculated_checksum: 0
22 |
23 | Component.onCompleted:
24 | {
25 | cff = cff.openCaesarFlashContainer(cff_object.selected_fname)
26 | cff_checksum = cff.readChecksum();
27 | cff_calculated_checksum = cff.genChecksum();
28 |
29 | flash_header = cff.readFlashCFF();
30 | //blocks_model.addFlashDataBlocks(flash_header.FlashDataBlocks);
31 | flash_header.updateModel(blocks_model);
32 | console.log(flash_header.FlashName)
33 | }
34 |
35 | ColumnLayout
36 | {
37 | anchors.fill: parent
38 | anchors.margins: 5
39 | spacing: 8
40 |
41 | Component.onCompleted: {console.log("ColumnLayout width: " + width)}
42 |
43 | RowLayout
44 | {
45 | Label
46 | {
47 | text: qsTr("flash name:")
48 | font: window.headerFont12
49 | }
50 | Label
51 | {
52 | text: flash_header.FlashName
53 | }
54 |
55 | Rectangle
56 | {
57 | height: 1
58 | Layout.fillWidth: true
59 | }
60 | Button
61 | {
62 | //Layout.fillWidth: true
63 | text: " GO BACK "
64 | onClicked:
65 | {
66 | stackView.pop();
67 | delete cff;
68 | }
69 | }
70 | }
71 |
72 | RowLayout
73 | {
74 | Label
75 | {
76 | text: qsTr("author:")
77 | font: window.headerFont12
78 |
79 | }
80 | Label
81 | {
82 | text: flash_header.FileAuthor
83 | }
84 |
85 | Label
86 | {
87 | Layout.leftMargin: 10
88 | text: qsTr("creation date:")
89 | font: window.headerFont12
90 |
91 | }
92 | Label
93 | {
94 | text: flash_header.FileCreationTime
95 | }
96 | }
97 |
98 | Rectangle
99 | {
100 | Layout.fillWidth: true
101 | height: 1
102 | color: "black"
103 | }
104 |
105 | RowLayout
106 | {
107 | width: parent.width
108 | Layout.fillHeight: true
109 | Layout.fillWidth: true
110 |
111 | Component.onCompleted: {console.log("RowLayout width: " + width)}
112 |
113 | ListView
114 | {
115 |
116 | Component.onCompleted: {console.log("ListView width: " + width)}
117 |
118 | width: parent.width
119 | Layout.fillWidth: true
120 | //anchors.fill: parent
121 | model: blocks_model
122 | delegate: FlashDataBlockDelegate{header: flash_header; block: FlashDataBlock; width: parent.width}
123 | }
124 | }
125 |
126 | Rectangle
127 | {
128 | Layout.fillHeight: true
129 | //Layout.fillWidth: true
130 | width: 1
131 | }
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/qml/FlashSegmentModel.qml:
--------------------------------------------------------------------------------
1 | import QtQuick
2 | import QtQuick.Layouts
3 | import QtQuick.Controls
4 | import Qt.labs.platform
5 |
6 | import xplatforms.cffflashcontainer.flashblock 1.0
7 | import xplatforms.cffflashcontainer.flashsegment 1.0
8 | import xplatforms.cffflashcontainer.flashsegmentmodel 1.0
9 |
10 |
11 | ColumnLayout
12 | {
13 | property string flash_name;
14 | property string idk;
15 | property CFFFlashSegment segment;
16 |
17 | width: parent.width
18 | RowLayout
19 | {
20 | spacing: 20
21 | Layout.fillWidth: true
22 | Label
23 | {
24 | font.weight: Font.DemiBold
25 | text: segment.SegmentName
26 | }
27 | Label
28 | {
29 | text: "Address: "
30 | }
31 | Label
32 | {
33 | text: segment.FromAdress
34 | }
35 | Label
36 | {
37 | text: "Length (byte): "
38 | }
39 | Label
40 | {
41 | text: segment.SegmentLength
42 | }
43 |
44 | Rectangle
45 | {
46 | height: 1
47 | Layout.fillWidth: true
48 | }
49 |
50 | Button
51 | {
52 | //text: "Save segment to file"
53 | icon.source: "qrc:/images/save_btn.svg"
54 | flat: true
55 | onClicked:
56 | {
57 | file_save_dialog.open()
58 | }
59 | }
60 | }
61 |
62 | FolderDialog
63 | {
64 | id: file_save_dialog
65 | title: "Please choose where to save flash segment"
66 | //fileMode: FolderDialog.OpenFolder
67 | //folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
68 |
69 | //nameFilters: [FlashSegment.SegmentName+".segment"]
70 |
71 | onAccepted: {
72 | console.log("You chose: " + file_save_dialog.folder)
73 | ttip_id.show("Segment saved to: " +segment.saveToFile(file_save_dialog.folder+"/"+flash_name+"_"+idk+"_"+segment.SegmentName+".segment"), 2500);
74 | //loadCFF(fileDialog.currentFile);
75 | //Qt.quit()
76 | }
77 | onRejected: {
78 | console.log("Canceled")
79 | //Qt.quit()
80 | }
81 | //Component.onCompleted: visible = true
82 | }
83 |
84 | ToolTip
85 | {
86 | id: ttip_id
87 | //parent: parent//btn_export_all
88 | anchors.centerIn: parent
89 | margins: 20
90 | }
91 |
92 | }
93 |
94 |
95 |
--------------------------------------------------------------------------------
/qml/HomeScreen.qml:
--------------------------------------------------------------------------------
1 | import QtQuick
2 | import QtQuick.Controls
3 | import QtQuick.Layouts
4 | import Qt.labs.platform
5 |
6 | import xplatforms.cffflashcontainer.container 1.0
7 |
8 | Page {
9 |
10 | title: qsTr("CFF Flash Files Tools")
11 |
12 | function loadCFF(fname)
13 | {
14 | cff_object.selected_fname = fname;
15 | console.log(cff_object.selected_fname);
16 | stackView.push("FlashInfoScreen.qml")
17 | }
18 |
19 | FileDialog
20 | {
21 | id: fileDialog
22 | title: "Please choose CFF Flash file"
23 | fileMode: FileDialog.OpenFile
24 | //folder: shortcuts.home
25 | //selectExisting: true
26 | //selectMultiple: false
27 | nameFilters: [ "CFF Flash files (*.cff)", "All files (*)" ]
28 | onAccepted: {
29 | console.log("You choose: " + fileDialog.currentFile)
30 | loadCFF(fileDialog.currentFile);
31 | //Qt.quit()
32 | }
33 | onRejected: {
34 | console.log("Canceled")
35 | //Qt.quit()
36 | }
37 | //Component.onCompleted: visible = true
38 | }
39 |
40 | ColumnLayout
41 | {
42 | anchors.fill: parent
43 | //anchors.leftMargin: 6
44 | spacing: 8
45 |
46 | RowLayout
47 | {
48 | Layout.fillWidth: true
49 | Layout.margins: 20
50 |
51 | Label
52 | {
53 | Layout.fillWidth: true
54 | text: qsTr("Please select or drop CFF File: ")
55 | font: window.headerFont
56 | //anchors.centerIn: parent
57 | }
58 |
59 | Button
60 | {
61 | Layout.alignment: Qt.AlignLeft
62 | Layout.fillWidth: true
63 | implicitWidth: 200
64 | text: qsTr("Select")
65 | onClicked: fileDialog.open();
66 | }
67 |
68 | }
69 |
70 |
71 | Rectangle
72 | {
73 | id: drop_rect_id
74 | Layout.fillHeight: true
75 | Layout.fillWidth: true
76 | Layout.margins: 20
77 | Layout.topMargin: 0
78 | border.color: "grey"
79 | border.width: 2
80 |
81 | Label{
82 |
83 | //anchors.fill: parent
84 | anchors.centerIn: parent
85 | text: qsTr("Drop CFF Flash file here.")
86 | }
87 |
88 | DropArea
89 | {
90 | anchors.fill: parent
91 | onDropped:
92 | {
93 |
94 | if(drop.hasUrls)loadCFF(drop.urls[0]);
95 | else if(drop.hasText)loadCFF(drop.text);
96 | }
97 | }
98 | }
99 |
100 |
101 | }
102 |
103 |
104 |
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/qml/main.qml:
--------------------------------------------------------------------------------
1 | import QtQuick
2 | import QtQuick.Controls
3 | import Qt.labs.platform
4 | import xplatforms.cffflashcontainer.container 1.0
5 |
6 | ApplicationWindow {
7 | id: window
8 | width: 1020
9 | height: 420
10 | visible: true
11 | title: qsTr("CFF Flash Files Tools")
12 |
13 | QtObject
14 | {
15 | id: cff_object
16 | //property CFFFlashContainer container: CFFFlashContainer{}
17 | property string selected_fname: ""
18 | }
19 |
20 | property font headerFont: Qt.font(
21 | {
22 | family: 'Segoe UI',
23 | weight: Font.DemiBold,
24 | italic: false,
25 | pointSize: 14
26 | })
27 |
28 | property font headerFont12: Qt.font(
29 | {
30 | family: 'Segoe UI',
31 | weight: Font.DemiBold,
32 | italic: false,
33 | pointSize: 12
34 | })
35 |
36 |
37 |
38 |
39 | /*
40 | header: ToolBar {
41 | contentHeight: toolButton.implicitHeight
42 |
43 | ToolButton {
44 | id: toolButton
45 | text: stackView.depth > 1 ? "\u25C0" : "\u2630"
46 | font.pixelSize: Qt.application.font.pixelSize * 1.6
47 | onClicked: {
48 | if (stackView.depth > 1) {
49 | stackView.pop()
50 | } else {
51 | drawer.open()
52 | }
53 | }
54 | }
55 |
56 | Label {
57 | text: stackView.currentItem.title
58 | anchors.centerIn: parent
59 | }
60 | }
61 | */
62 |
63 | /*
64 | Drawer {
65 | id: drawer
66 | width: window.width * 0.66
67 | height: window.height
68 |
69 | Column {
70 | anchors.fill: parent
71 |
72 | ItemDelegate {
73 | text: qsTr("Page 1")
74 | width: parent.width
75 | onClicked: {
76 | stackView.push("Page1Form.ui.qml")
77 | drawer.close()
78 | }
79 | }
80 | ItemDelegate {
81 | text: qsTr("Page 2")
82 | width: parent.width
83 | onClicked: {
84 | stackView.push("Page2Form.ui.qml")
85 | drawer.close()
86 | }
87 | }
88 | }
89 | }
90 | */
91 |
92 | StackView {
93 | id: stackView
94 | initialItem: "HomeScreen.qml"
95 | anchors.fill: parent
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/qtquickcontrols2.conf:
--------------------------------------------------------------------------------
1 | ; This file can be edited to change the style of the application
2 | ; Read "Qt Quick Controls 2 Configuration File" for details:
3 | ; https://doc.qt.io/qt/qtquickcontrols2-configuration.html
4 |
5 | [Controls]
6 | Style=Universal
7 |
--------------------------------------------------------------------------------
/setup_package.iss:
--------------------------------------------------------------------------------
1 | ; Script generated by the Inno Setup Script Wizard.
2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3 |
4 | #define MyAppName "CFFFlashFileTools"
5 | #define MyAppNameUninstall "CFFFlashFileTools"
6 | #define MyAppFolderName "CFFFlashFileTools"
7 | #define MyAppVersion "0.0.001a"
8 | #define MyAppPublisher "Xplatforms"
9 | #define MyAppURL "https://github.com/Xplatforms/CFFFlashFileTools/releases"
10 | #define MyAppExeName "CFFFlashFileTools.exe"
11 | #define registrychars "%1"
12 |
13 |
14 | [Setup]
15 | ; NOTE: The value of AppId uniquely identifies this application. 83x108
16 | ; Do not use the same AppId value in installers for other applications.
17 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
18 |
19 |
20 | AppId={{0DE3DC29-300C-478C-8DA4-4F5EE741C2EB}}
21 |
22 | AppName={#MyAppName}
23 | AppVersion={#MyAppVersion}
24 | ;AppVerName={#MyAppName} {#MyAppVersion}
25 | AppPublisher={#MyAppPublisher}
26 | AppPublisherURL={#MyAppURL}
27 | AppSupportURL="https://github.com/Xplatforms/CFFFlashFileTools"
28 | AppUpdatesURL={#MyAppURL}
29 | UsePreviousAppDir=no
30 | DefaultDirName={code:DefDirRoot}\Xplatforms\{#MyAppFolderName}
31 | DefaultGroupName=Xplatforms\{#MyAppName}
32 | LicenseFile=LICENSE
33 | OutputDir=..\BUILDS\
34 | OutputBaseFilename=CFFFlashFileTools_x64_{#MyAppVersion}
35 | SetupIconFile=Resources\icon.ico
36 | Compression=lzma
37 | SolidCompression=yes
38 | AlwaysUsePersonalGroup=yes
39 | PrivilegesRequired=lowest
40 |
41 |
42 | ;ArchitecturesInstallIn64BitMode=x64
43 | ;Check: not Is64BitInstallMode
44 | ;Check: Is64BitInstallMode
45 |
46 |
47 | [Tasks]
48 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
49 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
50 |
51 | [Files]
52 | Source: "..\BUILDS\CFFFlashFileTools\*"; DestDir: "{app}"; Flags: ignoreversion overwritereadonly replacesameversion recursesubdirs
53 | Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion overwritereadonly replacesameversion recursesubdirs
54 |
55 | [Icons]
56 | Name: "{userprograms}\Xplatforms\{#MyAppName}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";
57 | Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
58 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
59 |
60 | [Code]
61 | function InitializeSetup(): Boolean;
62 | var
63 | oldVersion: String;
64 | uninstaller: String;
65 | ErrorCode: Integer;
66 | begin
67 | if RegKeyExists(HKEY_CURRENT_USER,
68 | 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AppId}_is1') then
69 | begin
70 | RegQueryStringValue(HKEY_CURRENT_USER,
71 | 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AppId}_is1',
72 | 'UninstallString', uninstaller);
73 | uninstaller := RemoveQuotes(uninstaller);
74 | Exec(uninstaller, '/SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_HIDE, TRUE, ErrorCode);
75 | end;
76 | Result := True;
77 | end;
78 |
79 | function IsRegularUser(): Boolean;
80 | begin
81 | Result := not (IsAdminLoggedOn);
82 | end;
83 |
84 | function DefDirRoot(Param: String): String;
85 | begin
86 | if IsRegularUser then
87 | Result := ExpandConstant('{localappdata}')
88 | else
89 | Result := ExpandConstant('{pf}')
90 | end;
91 |
92 | procedure RunOtherInstaller;
93 | var
94 | ResultCode: Integer;
95 | begin
96 | if not Exec(ExpandConstant('{app}\OtherInstaller.exe'), '', '', SW_SHOWNORMAL,
97 | ewWaitUntilTerminated, ResultCode)
98 | then
99 | MsgBox('Other installer failed to run!' + #13#10 +
100 | SysErrorMessage(ResultCode), mbError, MB_OK);
101 | end;
102 |
103 | function CmdLineParamExists(const Value: string): Boolean;
104 | var
105 | I: Integer;
106 | begin
107 | Result := False;
108 | for I := 1 to ParamCount do
109 | if CompareText(ParamStr(I), Value) = 0 then
110 | begin
111 | Result := True;
112 | Exit;
113 | end;
114 | end;
115 |
116 |
117 | function VerySilentRun: Boolean;
118 | begin
119 | Result := CmdLineParamExists('/VERYSILENT');;
120 | end;
121 |
122 | [Run]
123 | Filename: "{app}\vc_redist.x86.exe"; Description: "{cm:LaunchProgram,{#StringChange("vc_redist.x86.exe installer", "&", "&&")}}"; Flags: postinstall
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------