int main() { char *pch; char word[] = "Hello world"; char key[] = "Secret"; char input[80]; char str1[]="Sample string"; char str2[40]; char str3[40]; char str[] = "fcba73"; char keys[] = "1234567890"; char *substring; int i; printf("%s's length is %d\n",word,asm_strlen(word)); pch=asm_strchr(word,'l'); while(pch!=NULL) { printf("Using asm_strchr, 'l' is at position : %d\n",pch-word+1); pch=asm_strchr(pch+1,'l'); } pch = (char*) asm_memchr(word, 'l', asm_strlen(word)); if (pch!=NULL) printf ("Using asm_memchr, 'l' found at position %d.\n", pch-word+1); else printf ("'l' not found.\n"); printf("Using asm_memset, %s is now : ",word); asm_memset(word,'-',6); puts (word); do { printf ("Type 'Secret' to quit (using asm_strcmp)\n"); gets (input); } while (asm_strcmp (key,input) != 0); pch = asm_strcpy(str2,"asm_strcpy is awesome"); asm_strcpy (str3,"Yeah, really awesome"); printf ("str1: %s\nstr2: %s\nstr3: %s\n",pch,str2,str3); pch=asm_strrchr(key,'e'); printf ("With asm_strrchr, the last occurence of 'e' was found at %d \n",pch-key+1); printf ("Using asm_execute, the result of add(3,4,5) is : %d\n",asm_execute(add,3,4,5)); i = asm_strcspn (str,keys); printf ("Using asm_strcspn, the first number in %s is at position %d.\n",str,i+1); substring = asm_substr(keys,-3,3); printf("The three last chars of %s are %s\n",keys, substring); substring = asm_substr(keys,0,3); printf("And the three first chars of %s are %s\n",keys, substring); asm_memcpy (str3,"copy successful",16); printf("%s\n", str3); return 0; }
void firmlaunch_arm9hax() { invalidate_data_cache(); invalidate_instruction_cache(); print("Invalidated instruction and data cache"); uint32_t code_offset = 0x3F00000; asm_memcpy((void *)(fw->fcram_address + code_offset), (void *)(fw->fcram_address + APP_CFW_OFFSET), ARM9_PAYLOAD_MAXSIZE); print("Copied arm9 code"); setup_gpu(); asm_memcpy((void *)fw->jump_table_address, &jump_table, (&jump_table_end - &jump_table + 1) * 4); print("Copied jump table"); *(uint32_t *)(fw->jump_table_address + (&jt_return - &jump_table) * 4) = fw->func_patch_return; *(uint32_t *)(fw->jump_table_address + (&jt_pdn_regs - &jump_table) * 4) = fw->pdn_regs; *(uint32_t *)(fw->jump_table_address + (&jt_pxi_regs - &jump_table) * 4) = fw->pxi_regs; print("Written firmware specific offsets"); *(uint32_t *)fw->func_patch_address = 0xE51FF004; *(uint32_t *)(fw->func_patch_address + 4) = 0xFFFF0C80; *(uint32_t *)fw->reboot_patch_address = 0xE51FF004; *(uint32_t *)(fw->reboot_patch_address + 4) = 0x1FFF4C80+4; print("Patched arm11 functions"); invalidate_data_cache(); print("Invalidated data cache"); print("Triggering reboot"); ((void (*)())fw->reboot_func_address)(0, 0, 2, 0); while (1) {}; }