s32 identify(u64 titleid, u32 *ios){ char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(0x20); u8 *tmdBuffer = NULL; u32 tmdSize; signed_blob *tikBuffer = NULL; u32 tikSize; u8 *certBuffer = NULL; u32 certSize; int ret; printf("Reading TMD..."); fflush(stdout); sprintf(filepath, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(titleid), TITLE_LOWER(titleid)); ret = read_file(filepath, &tmdBuffer, &tmdSize); if (ret < 0) { printf("Reading TMD failed\n"); return ret; } printf("done\n"); *ios = (u32)(tmdBuffer[0x18b]); printf("Generating fake ticket..."); fflush(stdout); /* sprintf(filepath, "/ticket/%08x/%08x.tik", TITLE_UPPER(titleid), TITLE_LOWER(titleid)); ret = read_file(filepath, &tikBuffer, &tikSize); if (ret < 0) { printf("Reading ticket failed\n"); free(tmdBuffer); return ret; }*/ Identify_GenerateTik(&tikBuffer,&tikSize); printf("done\n"); printf("Reading certs..."); fflush(stdout); sprintf(filepath, "/sys/cert.sys"); ret = read_file(filepath, &certBuffer, &certSize); if (ret < 0) { printf("Reading certs failed\n"); free(tmdBuffer); free(tikBuffer); return ret; } printf("done\n"); printf("ES_Identify..."); fflush(stdout); ret = ES_Identify((signed_blob*)certBuffer, certSize, (signed_blob*)tmdBuffer, tmdSize, tikBuffer, tikSize, NULL); if (ret < 0) { switch(ret) { case ES_EINVAL: printf("Error! ES_Identify (ret = %d;) Data invalid!\n", ret); break; case ES_EALIGN: printf("Error! ES_Identify (ret = %d;) Data not aligned!\n", ret); break; case ES_ENOTINIT: printf("Error! ES_Identify (ret = %d;) ES not initialized!\n", ret); break; case ES_ENOMEM: printf("Error! ES_Identify (ret = %d;) No memory!\n", ret); break; default: printf("Error! ES_Identify (ret = %d)\n", ret); break; } free(tmdBuffer); free(tikBuffer); free(certBuffer); return ret; } printf("done\n"); free(tmdBuffer); free(tikBuffer); free(certBuffer); return 0; }
s32 identify(u64 titleid, u32 *ios) { char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); u8 *tmdBuffer = NULL; u32 tmdSize; signed_blob *tikBuffer = NULL; u32 tikSize; u8 *certBuffer = NULL; u32 certSize; int ret; debug("Reading TMD..."); fflush(stdout); sprintf(filepath, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(titleid), TITLE_LOWER(titleid)); ret = read_full_file_from_nand(filepath, &tmdBuffer, &tmdSize); if (ret < 0) { debug("ERR: (identify) Reading TMD failed\n"); return ret; } debug("done\n"); *ios = (u32)(tmdBuffer[0x18b]); debug("Generating fake ticket..."); fflush(stdout); Identify_GenerateTik(&tikBuffer,&tikSize); debug("done\n"); debug("Reading certs..."); fflush(stdout); sprintf(filepath, "/sys/cert.sys"); ret = read_full_file_from_nand(filepath, &certBuffer, &certSize); if (ret < 0) { debug("Reading certs failed, trying to use embedded one\n"); certBuffer = allocate_memory(cert_sys_size); certSize = cert_sys_size; if (certBuffer != NULL) memcpy (certBuffer, cert_sys, cert_sys_size); else { free(tmdBuffer); free(tikBuffer); return ret; } } debug("done\n"); debug("ES_Identify..."); fflush(stdout); ret = ES_Identify((signed_blob*)certBuffer, certSize, (signed_blob*)tmdBuffer, tmdSize, tikBuffer, tikSize, NULL); if (ret < 0) { switch(ret) { case ES_EINVAL: debug("ERR: (identify) ES_Identify (ret = %d;) Data invalid!\n", ret); break; case ES_EALIGN: debug("ERR: (identify) ES_Identify (ret = %d;) Data not aligned!\n", ret); break; case ES_ENOTINIT: debug("ERR: (identify) ES_Identify (ret = %d;) ES not initialized!\n", ret); break; case ES_ENOMEM: debug("ERR: (identify) ES_Identify (ret = %d;) No memory!\n", ret); break; default: debug("ERR: (identify) ES_Identify (ret = %d)\n", ret); break; } free(tmdBuffer); free(tikBuffer); free(certBuffer); sleep (5); return ret; } debug("done\n"); free(tmdBuffer); free(tikBuffer); free(certBuffer); return 0; }