This source file includes following definitions.
- log_fwt_msg
- log_fwt_start
- filewritetask
- sub_fc065b7c_my
- sub_fc0660ae_my
- sub_fc065ca2_my
1 #include "lolevel.h"
2 #include "platform.h"
3
4 extern void _LogCameraEvent(int id,const char *fmt,...);
5
6 typedef struct {
7 unsigned int address;
8 unsigned int length;
9 } cam_ptp_data_chunk;
10
11 #define MAX_CHUNKS_FOR_FWT 7
12
13
14
15
16
17
18
19
20 typedef struct
21 {
22 int unkn1;
23 int file_offset;
24 int maybe_full_size;
25 int unkn2, unkn3;
26 int unkn4;
27 cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
28 int maybe_seek_flag;
29 int unkn5, unkn6;
30 char name[32];
31 } fwt_data_struct;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87 #include "../../../generic/filewrite.c"
88
89 void log_fwt_msg(fwt_data_struct *fwd)
90 {
91 int m=fwd->unkn1;
92 _LogCameraEvent(0x60,"fw m:%d o:0x%08x fs:0x%08x sf:0x%x",m,fwd->file_offset,fwd->maybe_full_size,fwd->maybe_seek_flag);
93 _LogCameraEvent(0x60,"fw %s",fwd->name);
94 if(m >= 0 && m <=6) {
95 _LogCameraEvent(0x60,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m].address,fwd->pdc[m].length);
96 }
97 _LogCameraEvent(0x60,"fw u %08x %08x %08x %08x %08x %08x",fwd->unkn2,fwd->unkn3,fwd->unkn4,fwd->unkn5,fwd->unkn6);
98 }
99
100 void log_fwt_start(void)
101 {
102 _LogCameraEvent(0x60,"fw start");
103 }
104
105
106 void __attribute__((naked,noinline)) filewritetask() {
107 asm volatile (
108 " push {r3, r4, r5, r6, r7, lr}\n"
109 " ldr r6, =0x09200001\n"
110 " movw r7, #0x428\n"
111 " ldr r5, =0x00024cb8\n"
112 " adds r6, #0x12\n"
113 "loc_fc065dd2:\n"
114 " mov r1, sp\n"
115 " movs r2, #0\n"
116 " ldr r0, [r5, #0x10]\n"
117 " blx sub_fc2cf348\n"
118 " cbz r0, loc_fc065de8\n"
119 " movs r0, #0\n"
120 " mov r2, r7\n"
121 " ldr r1, =0xfc065efc\n"
122 " blx sub_fc2cf408\n"
123 "loc_fc065de8:\n"
124 " ldr r0, [sp]\n"
125 "bl log_fwt_msg\n"
126 " ldr r0, [sp]\n"
127 " ldr r1, [r0]\n"
128 " cmp r1, #0xd\n"
129 " bhs loc_fc065dd2\n"
130 " tbb [pc, r1]\n"
131 "branchtable_fc065df4:\n"
132 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
133 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
134 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
135 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
136 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
137 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
138 " .byte((loc_fc065e36 - branchtable_fc065df4) / 2)\n"
139 " .byte((loc_fc065e3c - branchtable_fc065df4) / 2)\n"
140 " .byte((loc_fc065e02 - branchtable_fc065df4) / 2)\n"
141 " .byte((loc_fc065e14 - branchtable_fc065df4) / 2)\n"
142 " .byte((loc_fc065e30 - branchtable_fc065df4) / 2)\n"
143 " .byte((loc_fc065e08 - branchtable_fc065df4) / 2)\n"
144 " .byte((loc_fc065e0e - branchtable_fc065df4) / 2)\n"
145 ".align 1\n"
146 "loc_fc065e02:\n"
147 " bl sub_fc065fb6\n"
148 " b loc_fc065dd2\n"
149 "loc_fc065e08:\n"
150 " bl sub_fc066002\n"
151 " b loc_fc065dd2\n"
152 "loc_fc065e0e:\n"
153 " bl sub_fc065b7c_my\n"
154 " b loc_fc065dd2\n"
155 "loc_fc065e14:\n"
156 " ldr r1, [r0, #4]\n"
157 " movs r2, #0\n"
158 " mov r4, r0\n"
159 " ldr r0, [r5, #4]\n"
160 " bl _lseek\n"
161 " adds r0, r0, #1\n"
162 " bne loc_fc065dd2\n"
163 " movs r0, #7\n"
164 " mov r1, r4\n"
165 " str r6, [r4, #0x14]\n"
166 " bl sub_fc065b04\n"
167 " b loc_fc065dd2\n"
168 "loc_fc065e30:\n"
169 " bl sub_fc066056\n"
170 " b loc_fc065dd2\n"
171 "loc_fc065e36:\n"
172 " bl sub_fc0660ae_my\n"
173 " b loc_fc065dd2\n"
174 "loc_fc065e3c:\n"
175 " bl sub_fc065ca2_my\n"
176 " b loc_fc065dd2\n"
177 ".ltorg\n"
178 );
179 }
180
181 void __attribute__((naked,noinline)) sub_fc065b7c_my() {
182 asm volatile (
183 " push.w {r4, r5, r6, r7, r8, sb, lr}\n"
184 " mov r4, r0\n"
185
186
187 " BL filewrite_main_hook\n"
188 " mov r0, r4\n"
189 " ldr r0, [r0, #0x50]\n"
190 " sub sp, #0x3c\n"
191 " lsls r1, r0, #0x1f\n"
192 " bne loc_fc065b8e\n"
193 " lsls r0, r0, #0x1d\n"
194 " bpl loc_fc065c7e\n"
195 "loc_fc065b8e:\n"
196 " ldr r7, =0x00024cb8\n"
197 " ldr r0, [r7, #0x18]\n"
198 " cbz r0, loc_fc065b96\n"
199 " blx r0\n"
200 "loc_fc065b96:\n"
201 " add.w r0, r4, #0x5c\n"
202 " mov r8, r0\n"
203 " bl sub_fc33276c\n"
204 " movs r1, #0\n"
205 " bl sub_fc06e672\n"
206 " movs r1, #0\n"
207 " movs r0, #0x47\n"
208 " bl sub_fc325198\n"
209 " ldr r0, [r4, #0x50]\n"
210 " lsls r0, r0, #0x1f\n"
211 " beq loc_fc065c7e\n"
212 " ldr r0, [r4, #0x10]\n"
213 " bl sub_fc0cb96e\n"
214 " ldr r0, [r4, #0x50]\n"
215 " movw r5, #0x301\n"
216 " lsls r1, r0, #0x1b\n"
217 " bpl loc_fc065bc8\n"
218 " movs r5, #9\n"
219 " b loc_fc065bce\n"
220 "loc_fc065bc8:\n"
221 " lsls r1, r0, #0x19\n"
222 " bpl loc_fc065bce\n"
223 " movs r5, #1\n"
224 "loc_fc065bce:\n"
225 " lsls r0, r0, #0x1a\n"
226 " bmi loc_fc065bd8\n"
227 " ldr r0, [r4, #0x58]\n"
228 " cmp r0, #1\n"
229 " bne loc_fc065bdc\n"
230 "loc_fc065bd8:\n"
231 " orr r5, r5, #0x8000\n"
232 "loc_fc065bdc:\n"
233 " movw sb, #0x1b6\n"
234 " ldr r6, [r4, #0x10]\n"
235 " mov r2, sb\n"
236 " mov r1, r5\n"
237 " mov r0, r8\n"
238
239 " bl fwt_open\n"
240 " adds r1, r0, #1\n"
241 " bne loc_fc065c2a\n"
242 " mov r0, r8\n"
243 " bl sub_fc332d86\n"
244 " movs r2, #0xf\n"
245 " mov r1, r8\n"
246 " add r0, sp, #4\n"
247 " blx sub_fc2cf428\n"
248 " movs r0, #0\n"
249 " strb.w r0, [sp, #0x13]\n"
250 " movw r1, #0x41ff\n"
251 " str r1, [sp, #0x24]\n"
252 " strd r0, r6, [sp, #0x2c]\n"
253 " movs r1, #0x10\n"
254 " str r6, [sp, #0x34]\n"
255 " add r0, sp, #4\n"
256 " str r6, [sp, #0x38]\n"
257 " str r1, [sp, #0x28]\n"
258 " add r1, sp, #0x24\n"
259 " bl sub_fc0fb9da\n"
260 " mov r2, sb\n"
261 " mov r1, r5\n"
262 " mov r0, r8\n"
263 " bl _Open\n"
264 "loc_fc065c2a:\n"
265 " mov r5, r0\n"
266 " str r0, [r7, #4]\n"
267 " adds r0, r0, #1\n"
268 " bne loc_fc065c56\n"
269 " movs r1, #0\n"
270 " movs r0, #0x48\n"
271 " bl sub_fc325198\n"
272 " mov r0, r8\n"
273 " bl sub_fc33276c\n"
274 " ldr r1, [r7, #0x1c]\n"
275 " bl sub_fc06e6d0\n"
276 " ldr r1, [r7, #0x14]\n"
277 " cmp r1, #0\n"
278 " beq loc_fc065c9c\n"
279 " add sp, #0x3c\n"
280 " ldr r0, =0x09200001\n"
281 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
282 " bx r1\n"
283 "loc_fc065c56:\n"
284 " ldr r0, =0x002013cc\n"
285 " movs r2, #0x20\n"
286 " mov r1, r8\n"
287 " blx sub_fc2cf430\n"
288
289
290 " LDR R3, =current_write_ignored\n"
291 " LDR R3, [R3]\n"
292 " cbnz r3,loc_C\n"
293
294 " ldr r0, [r4, #0x50]\n"
295 " lsls r0, r0, #0x18\n"
296 " bpl loc_fc065c7e\n"
297 " ldr r1, [r4, #0xc]\n"
298 " mov r0, r5\n"
299 " bl sub_fc332b9c\n"
300 " cbnz r0, loc_fc065c7c\n"
301 " ldr r0, =0x09200001\n"
302 " mov r1, r4\n"
303 " adds r0, #0x16\n"
304 " str r0, [r4, #0x14]\n"
305 " movs r0, #7\n"
306 " b loc_fc065c94\n"
307 "loc_fc065c7c:\n"
308 " b loc_fc065c7e\n"
309 "loc_fc065c7e:\n"
310 "loc_C:\n"
311 " ldr r0, [r4, #0x50]\n"
312 " lsls r0, r0, #0x19\n"
313 " bmi loc_fc065c88\n"
314 " ldr r0, [r4, #4]\n"
315 " cbz r0, loc_fc065c90\n"
316 "loc_fc065c88:\n"
317 " movs r0, #9\n"
318 " mov r1, r4\n"
319 " bl sub_fc065b04\n"
320 "loc_fc065c90:\n"
321 " movs r0, #0\n"
322 " mov r1, r4\n"
323 "loc_fc065c94:\n"
324 " add sp, #0x3c\n"
325 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
326
327 " ldr pc, =0xfc065b05\n"
328 "loc_fc065c9c:\n"
329 " add sp, #0x3c\n"
330 " pop.w {r4, r5, r6, r7, r8, sb, pc}\n"
331 ".ltorg\n"
332 );
333 }
334
335
336 void __attribute__((naked,noinline)) sub_fc0660ae_my() {
337 asm volatile (
338 " push.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
339 " mov r5, r0\n"
340 " ldr r0, [r0]\n"
341 " cmp r0, #6\n"
342 " bhi loc_fc0660c6\n"
343 " add.w r0, r5, r0, lsl #3\n"
344 " ldrd r7, r6, [r0, #0x18]\n"
345 " cbnz r6, loc_fc0660da\n"
346 " b loc_fc0660d4\n"
347 "loc_fc0660c6:\n"
348 " movw r2, #0x36d\n"
349 " ldr r1, =0xfc065efc\n"
350 " movs r0, #0\n"
351 " blx sub_fc2cf408\n"
352 "loc_fc0660d4:\n"
353 " movs r0, #7\n"
354 " mov r1, r5\n"
355 " b loc_fc06614a\n"
356 "loc_fc0660da:\n"
357 " ldr.w sl, =0x00024cb8\n"
358 " mov.w sb, #0x1000000\n"
359 " mov r4, r6\n"
360 "loc_fc0660e4:\n"
361 " ldr r0, [r5, #4]\n"
362 " cmp r4, sb\n"
363 " mov r1, sb\n"
364 " bhi loc_fc0660ee\n"
365 " mov r1, r4\n"
366 "loc_fc0660ee:\n"
367 " lsls r2, r0, #8\n"
368 " beq loc_fc066100\n"
369 " bic r0, r0, #0xff000000\n"
370 " rsb.w r0, r0, #0x1000000\n"
371 " cmp r1, r0\n"
372 " bls loc_fc066100\n"
373 " mov r1, r0\n"
374 "loc_fc066100:\n"
375 " ldr.w r0, [sl, #4]\n"
376 " mov r8, r1\n"
377 " mov r2, r1\n"
378 " mov r1, r7\n"
379
380 " bl fwt_write\n"
381 " ldr r1, [r5, #4]\n"
382 " cmp r8, r0\n"
383 " add r1, r0\n"
384 " str r1, [r5, #4]\n"
385 " beq loc_fc06612a\n"
386 " adds r0, r0, #1\n"
387 " bne loc_fc066122\n"
388 " ldr r0, =0x09200006\n"
389 " subs r0, r0, #1\n"
390 " b loc_fc066126\n"
391 "loc_fc066122:\n"
392 " ldr r0, =0x09200006\n"
393 " adds r0, #0xf\n"
394 "loc_fc066126:\n"
395 " str r0, [r5, #0x14]\n"
396 " b loc_fc0660d4\n"
397 "loc_fc06612a:\n"
398 " subs r4, r4, r0\n"
399 " cmp r4, r6\n"
400 " add r7, r0\n"
401 " blo loc_fc066140\n"
402 " movw r2, #0x398\n"
403 " ldr r1, =0xfc065efc\n"
404 " movs r0, #0\n"
405 " blx sub_fc2cf408\n"
406 "loc_fc066140:\n"
407 " cmp r4, #0\n"
408 " bne loc_fc0660e4\n"
409 " ldr r0, [r5]\n"
410 " mov r1, r5\n"
411 " adds r0, r0, #1\n"
412 "loc_fc06614a:\n"
413 " pop.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
414
415 " ldr pc,=0xfc065b05\n"
416 ".ltorg\n"
417 );
418 }
419
420
421 void __attribute__((naked,noinline)) sub_fc065ca2_my() {
422 asm volatile (
423 " push {r4, r5, r6, lr}\n"
424 " mov r4, r0\n"
425
426 " ldr r0, [r0, #0x50]\n"
427 " ldr r5, =0x00024cb8\n"
428 " sub sp, #0x38\n"
429 " lsls r1, r0, #0x1e\n"
430 " bmi loc_fc065cb6\n"
431 " lsls r0, r0, #0x1c\n"
432 " bpl loc_fc065db4\n"
433 " b loc_fc065cf8\n"
434 "loc_fc065cb6:\n"
435 " lsls r0, r0, #0x18\n"
436 " bpl loc_fc065cd4\n"
437 " ldrd r1, r0, [r4, #8]\n"
438 " cmp r1, r0\n"
439 " beq loc_fc065cd4\n"
440 " ldr r0, [r5, #4]\n"
441 " bl sub_fc332b9c\n"
442 " cbnz r0, loc_fc065cd0\n"
443 " ldr r0, =0x09200001\n"
444 " adds r0, #0x16\n"
445 " str r0, [r4, #0x14]\n"
446 "loc_fc065cd0:\n"
447 " ldr r0, [r4, #8]\n"
448 " str r0, [sp, #0x28]\n"
449 "loc_fc065cd4:\n"
450 " ldr r0, [r5, #4]\n"
451 " adds r1, r0, #1\n"
452 " beq loc_fc065cf8\n"
453 " ldr r6, =0x09200001\n"
454 " ldr r1, [r4, #0x58]\n"
455 " adds r6, r6, #2\n"
456 " cmp r1, #1\n"
457 " bne loc_fc065cea\n"
458
459 " LDR R3, =current_write_ignored\n"
460 " LDR R3, [R3]\n"
461 " cbnz R3,loc_D\n"
462
463 " bl sub_fc3329e6\n"
464 " b loc_fc065cee\n"
465 "loc_fc065cea:\n"
466 "loc_D:\n"
467
468 " bl fwt_close\n"
469 "loc_fc065cee:\n"
470 " cbz r0, loc_fc065cf2\n"
471 " str r6, [r4, #0x14]\n"
472 "loc_fc065cf2:\n"
473 " mov.w r0, #-1\n"
474 " str r0, [r5, #4]\n"
475 "loc_fc065cf8:\n"
476 " add.w r6, r4, #0x5c\n"
477 " ldr r0, [r4, #0x14]\n"
478 " lsls r0, r0, #0x1f\n"
479 " bne loc_fc065d9c\n"
480 " ldr r0, [r4, #0x50]\n"
481 " lsls r1, r0, #0x1f\n"
482 " beq loc_fc065d24\n"
483 " movw r0, #0x81ff\n"
484 " str r0, [sp, #0x20]\n"
485 " movs r0, #0x20\n"
486 " str r0, [sp, #0x24]\n"
487 " ldr r0, [r4, #4]\n"
488 " str r0, [sp, #0x28]\n"
489 " ldr r0, [r4, #0x10]\n"
490 " str r0, [sp, #0x2c]\n"
491 " ldr r0, [r4, #0x10]\n"
492 " str r0, [sp, #0x30]\n"
493 " ldr r0, [r4, #0x10]\n"
494 " str r0, [sp, #0x34]\n"
495 " b loc_fc065d46\n"
496 "loc_fc065d24:\n"
497 " lsls r0, r0, #0x1b\n"
498 " bpl loc_fc065d46\n"
499 " add r1, sp, #0x20\n"
500 " mov r0, r6\n"
501 " bl sub_fc0fb964\n"
502 " cbnz r0, loc_fc065d3e\n"
503 " movs r0, #0\n"
504 " movw r2, #0x3ee\n"
505 " ldr r1, =0xfc065efc\n"
506 " blx sub_fc2cf408\n"
507 "loc_fc065d3e:\n"
508 " ldr r0, [sp, #0x28]\n"
509 " ldr r1, [r4, #4]\n"
510 " add r0, r1\n"
511 " str r0, [sp, #0x28]\n"
512 "loc_fc065d46:\n"
513 " ldr r0, [r4, #0x50]\n"
514 " lsls r0, r0, #0x19\n"
515 " bmi loc_fc065d54\n"
516 " add r1, sp, #0x20\n"
517 " mov r0, r6\n"
518 " bl sub_fc0fb9da\n"
519 "loc_fc065d54:\n"
520 " ldr r0, [r4, #0x50]\n"
521 " lsls r0, r0, #0x1a\n"
522 " bpl loc_fc065d9c\n"
523 " movs r2, #0x20\n"
524 " mov r1, r6\n"
525 " mov r0, sp\n"
526 " blx sub_fc2cf430\n"
527 " mov r0, sp\n"
528 " bl _strlen\n"
529 " add r0, sp, r0\n"
530 " movs r1, #0x54\n"
531 " strb r1, [r0, #-0x3]!\n"
532 " movs r1, #0x4d\n"
533 " strb r1, [r0, #1]\n"
534 " movs r1, #0x50\n"
535 " strb r1, [r0, #2]\n"
536 " mov r1, sp\n"
537 " mov r0, r6\n"
538 " bl sub_fc0cbb46\n"
539 " cbnz r0, loc_fc065d90\n"
540 " movs r0, #0\n"
541 " movw r2, #0x179\n"
542 " ldr r1, =0xfc065efc\n"
543 " blx sub_fc2cf408\n"
544 "loc_fc065d90:\n"
545 " mov r0, sp\n"
546 " bl sub_fc0fbccc\n"
547 " mov r0, r6\n"
548 " bl sub_fc0fbccc\n"
549 "loc_fc065d9c:\n"
550 " movs r1, #0\n"
551 " movs r0, #0x48\n"
552 " bl sub_fc325198\n"
553 " mov r0, r6\n"
554 " bl sub_fc33276c\n"
555 " ldr r1, [r5, #0x1c]\n"
556 " bl sub_fc06e6d0\n"
557 " b loc_fc065db8\n"
558 " b loc_fc065db4\n"
559 "loc_fc065db4:\n"
560 " ldr r0, [r5, #0x1c]\n"
561 " blx r0\n"
562 "loc_fc065db8:\n"
563 " ldr r1, [r5, #0x14]\n"
564 " cmp r1, #0\n"
565 " beq loc_fc065dc2\n"
566 " ldr r0, [r4, #0x14]\n"
567 " blx r1\n"
568 "loc_fc065dc2:\n"
569 " add sp, #0x38\n"
570 " pop {r4, r5, r6, pc}\n"
571 ".ltorg\n"
572 );
573 }
574