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