root/platform/ixus1000_sd4500/sub/102b/filewrite.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. filewritetask
  2. sub_FFAB7398_my
  3. sub_FFAB74D8_my
  4. sub_FFAB6F4C_my

   1 /*
   2  * filewrite.c - auto-generated by CHDK code_gen.
   3  */
   4 #include "lolevel.h"
   5 #include "platform.h"
   6 
   7 typedef struct {
   8     unsigned int address;
   9     unsigned int length;
  10 } cam_ptp_data_chunk; //camera specific structure
  11 
  12 #define MAX_CHUNKS_FOR_FWT 7   // filewritetask is prepared for this many chunks
  13 /*
  14  * fwt_data_struct: defined here as it's camera dependent
  15  * unneeded members are designated with unkn
  16  * pdc is required, everything after that is optional (DryOS < R50)
  17  * file_offset, full_size, seek_flag only needs to be defined for DryOS>=r50 generation cameras
  18  */
  19 typedef struct
  20 {
  21     int unkn1[5];                                   // 101a sub_FFAB7444 --> "LDR     R7, [R0, #0x14]!"
  22     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
  23     int unkn2;
  24     char name[32];                                  // 101a sub_FFAB7304 --> "ADD     R0, R0, #0x50"
  25                                                     // offset of 'name' from start = 0x50 = 80 bytes = 20 words
  26 } fwt_data_struct;
  27 
  28 #include "../../../generic/filewrite.c"
  29 
  30 /*************************************************************/
  31 //** filewritetask @ 0xFFAB70C0 - 0xFFAB719C, length=56
  32 void __attribute__((naked,noinline)) filewritetask() {
  33 asm volatile (
  34 "    STMFD   SP!, {R1-R5,LR} \n"
  35 "    LDR     R4, =0xBDC0 \n"
  36 
  37 "loc_FFAB70C8:\n"
  38 "    LDR     R0, [R4, #0x10] \n"
  39 "    MOV     R2, #0 \n"
  40 "    ADD     R1, SP, #8 \n"
  41 "    BL      sub_FF83AE20 /*_ReceiveMessageQueue*/ \n"
  42 "    CMP     R0, #0 \n"
  43 "    LDRNE   R1, =0x33F \n"
  44 "    LDRNE   R0, =0xFFAB71B0 /*'dwFWrite.c'*/ \n"
  45 "    BLNE    _DebugAssert \n"
  46 "    LDR     R0, [SP, #8] \n"
  47 "    LDR     R1, [R0] \n"
  48 "    CMP     R1, #9 \n"
  49 "    ADDLS   PC, PC, R1, LSL#2 \n"
  50 "    B       loc_FFAB70C8 \n"
  51 "    B       loc_FFAB7190 \n"
  52 "    B       loc_FFAB7190 \n"
  53 "    B       loc_FFAB7190 \n"
  54 "    B       loc_FFAB7190 \n"
  55 "    B       loc_FFAB7190 \n"
  56 "    B       loc_FFAB7190 \n"
  57 "    B       loc_FFAB7190 \n"
  58 "    B       loc_FFAB7198 \n"
  59 "    B       loc_FFAB7124 \n"
  60 "    B       loc_FFAB7188 \n"
  61 
  62 "loc_FFAB7124:\n"
  63 "    MOV     R0, #0 \n"
  64 "    STR     R0, [SP] \n"
  65 
  66 "loc_FFAB712C:\n"
  67 "    LDR     R0, [R4, #0x10] \n"
  68 "    MOV     R1, SP \n"
  69 "    BL      sub_FF83B064 /*_GetNumberOfPostedMessages*/ \n"
  70 "    LDR     R0, [SP] \n"
  71 "    CMP     R0, #0 \n"
  72 "    BEQ     loc_FFAB7158 \n"
  73 "    LDR     R0, [R4, #0x10] \n"
  74 "    MOV     R2, #0 \n"
  75 "    ADD     R1, SP, #4 \n"
  76 "    BL      sub_FF83AE20 /*_ReceiveMessageQueue*/ \n"
  77 "    B       loc_FFAB712C \n"
  78 
  79 "loc_FFAB7158:\n"
  80 "    LDR     R0, [R4, #4] \n"
  81 "    CMN     R0, #1 \n"
  82 "    BEQ     loc_FFAB717C \n"
  83 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
  84 "    MVN     R0, #0 \n"
  85 "    STR     R0, [R4, #4] \n"
  86 "    LDR     R0, =0x1000E0 \n"
  87 "    BL      sub_FF8759D4 \n"
  88 "    BL      sub_FF873C30 \n"
  89 
  90 "loc_FFAB717C:\n"
  91 "    LDR     R0, [R4, #0xC] \n"
  92 "    BL      _GiveSemaphore \n"
  93 "    B       loc_FFAB70C8 \n"
  94 
  95 "loc_FFAB7188:\n"
  96 "    BL      sub_FFAB7398_my \n"  // --> Patched. Old value = 0xFFAB7398.
  97 "    B       loc_FFAB70C8 \n"
  98 
  99 "loc_FFAB7190:\n"
 100 "    BL      sub_FFAB74D8_my \n"  // --> Patched. Old value = 0xFFAB74D8.
 101 "    B       loc_FFAB70C8 \n"
 102 
 103 "loc_FFAB7198:\n"
 104 "    BL      sub_FFAB6F4C_my \n"  // --> Patched. Old value = 0xFFAB6F4C.
 105 "    B       loc_FFAB70C8 \n"
 106 );
 107 }
 108 
 109 /*************************************************************/
 110 //** sub_FFAB7398_my @ 0xFFAB7398 - 0xFFAB73EC, length=22
 111 void __attribute__((naked,noinline)) sub_FFAB7398_my() {
 112 asm volatile (
 113 "    STMFD   SP!, {R4-R8,LR} \n"
 114 "    MOV     R4, R0 \n"
 115 "    ADD     R0, R0, #0x50 \n"
 116 "    SUB     SP, SP, #0x38 \n"
 117 "    BL      sub_FF8759D4 \n"
 118 "    MOV     R1, #0 \n"
 119 "    BL      sub_FF873BC8 \n"
 120 "    LDR     R0, [R4, #0xC] \n"
 121 "    BL      sub_FF810338 \n"
 122 "    LDR     R0, [R4, #0x4C] \n"
 123 "    LDR     R8, =0x1B6 \n"
 124 "    CMP     R0, #1 \n"
 125 "    LDREQ   R0, [R4, #8] \n"
 126 "    ADD     R6, R4, #0x50 \n"
 127 "    ORREQ   R0, R0, #0x8000 \n"
 128 "    STREQ   R0, [R4, #8] \n"
 129 "    LDR     R7, [R4, #8] \n"
 130 "    LDR     R5, [R4, #0xC] \n"
 131 //hook start
 132 "    STMFD   SP!, {R4-R12,LR} \n"
 133 "    MOV     R0, R4 \n"
 134 "    BL      filewrite_main_hook \n"
 135 "    LDMFD   SP!, {R4-R12,LR} \n"
 136 //hook end
 137 "    MOV     R0, R6 \n"
 138 "    MOV     R2, R8 \n"
 139 "    MOV     R1, R7 \n"
 140 "    BL      fwt_open \n"  // --> Patched. Old value = _Open.
 141 "    LDR     PC, =0xFFAB73F0 \n"  // Continue in firmware
 142 );
 143 }
 144 
 145 /*************************************************************/
 146 //** sub_FFAB74D8_my @ 0xFFAB74D8 - 0xFFAB7558, length=33
 147 void __attribute__((naked,noinline)) sub_FFAB74D8_my() {
 148 asm volatile (
 149 "    STMFD   SP!, {R4-R10,LR} \n"
 150 "    MOV     R5, R0 \n"
 151 "    LDR     R0, [R0] \n"
 152 "    CMP     R0, #6 \n"
 153 "    BHI     loc_FFAB750C \n"
 154 "    ADD     R0, R5, R0, LSL#3 \n"
 155 "    LDR     R7, [R0, #0x14]! \n"
 156 "    LDR     R6, [R0, #4] \n"
 157 "    CMP     R6, #0 \n"
 158 "    BNE     loc_FFAB751C \n"
 159 
 160 "loc_FFAB7500:\n"
 161 "    MOV     R1, R5 \n"
 162 "    MOV     R0, #7 \n"
 163 "    B       sub_FFAB75B0 \n"
 164 
 165 "loc_FFAB750C:\n"
 166 "    LDR     R1, =0x299 \n"
 167 "    LDR     R0, =0xFFAB71B0 /*'dwFWrite.c'*/ \n"
 168 "    BL      _DebugAssert \n"
 169 "    B       loc_FFAB7500 \n"
 170 
 171 "loc_FFAB751C:\n"
 172 "    LDR     R9, =0xBDC0 \n"
 173 "    MOV     R4, R6 \n"
 174 "    LDR     R0, [R5, #4] \n"
 175 "    CMP     R4, #0x1000000 \n"
 176 "    MOVLS   R8, R4 \n"
 177 "    MOVHI   R8, #0x1000000 \n"
 178 "    BIC     R1, R0, #0xFF000000 \n"
 179 "    CMP     R1, #0 \n"
 180 "    BICNE   R0, R0, #0xFF000000 \n"
 181 "    RSBNE   R0, R0, #0x1000000 \n"
 182 "    CMPNE   R8, R0 \n"
 183 "    MOVHI   R8, R0 \n"
 184 "    LDR     R0, [R9, #4] \n"
 185 "    MOV     R2, R8 \n"
 186 "    MOV     R1, R7 \n"
 187 "    BL      fwt_write \n"  // --> Patched. Old value = _Write.
 188 "    LDR     PC, =0xFFAB755C \n"  // Continue in firmware
 189 );
 190 }
 191 
 192 /*************************************************************/
 193 //** sub_FFAB6F4C_my @ 0xFFAB6F4C - 0xFFAB6F80, length=14
 194 void __attribute__((naked,noinline)) sub_FFAB6F4C_my() {
 195 asm volatile (
 196 "    STMFD   SP!, {R4-R6,LR} \n"
 197 "    LDR     R5, =0xBDC0 \n"
 198 "    MOV     R4, R0 \n"
 199 "    LDR     R0, [R5, #4] \n"
 200 "    SUB     SP, SP, #0x38 \n"
 201 "    CMN     R0, #1 \n"
 202 "    BEQ     sub_FFAB6F94 \n"
 203 "    LDR     R1, [R4, #8] \n"
 204 "    LDR     R6, =0x9200003 \n"
 205 "    TST     R1, #0x8000 \n"
 206 "    BEQ     loc_FFAB6F80 \n"
 207 "    BL      sub_FF872C74 \n"
 208 "    B       sub_FFAB6F84 \n"
 209 
 210 "loc_FFAB6F80:\n"
 211 "    BL      fwt_close \n"  // --> Patched. Old value = _Close.
 212 "    LDR     PC, =0xFFAB6F84 \n"  // Continue in firmware
 213 );
 214 }

/* [<][>][^][v][top][bottom][index][help] */