首先声明,本人是P&D脑残粉,有关P&D的一切东西都想得到-_-#
好了,下面开始搞定今天要做的事:
首先我们假设游戏的音效一定在ipa里。进入默认目录“/Users/#userName#/Music/iTunes/iTunes Media/Mobile Applications”找到“P&D 5.1.2.ipa”;
用任意一种方法解压缩这个文件,进入这里-> "/P&D 5.1.2/Payload";
open it-
然后我们继续假设*.caf是音乐文件,DATA003.BIN是音效文件。(你够- -)
看见没有,这么多RIFF说明了什么?我的假设是不证自明的~!(路人:拍死它!)
根据目前所知的信息,我们可以开始编程了。为了节约时间,我选择用C语言写代码。
//
// main.c
// 各种C代码测试
//
// Created by FIREDOM on 4/22/13.
// Copyright (c) 2013 firedom. All rights reserved.
//
#include "Header.h"
int numaddition(char *numArray)
{
int temp = 0;
temp = atoi(numArray);
temp++;
sprintf(numArray, "%d", temp);
return (0);
}
int compare(unsigned char *leftArray, unsigned char *rightArray, int lengh)
{
for(int i = 0; i < lengh ; i++)
{
if(leftArray[i] != rightArray[i])
{
return (0);
}
}
return (1);
}
int makeFile(FILE *fp, unsigned char *fileKey, char *fileNum)
{
char final_leftName[20] = "DATA003-";
char rightName[] = ".wav";
strcat(final_leftName, fileNum);
strcat(final_leftName, rightName);
FILE *fp2;
fp2 = fopen(final_leftName, "wb");
if(fp2 == NULL)
{
puts("open 1 failed.");
return (-1);
}
int counter = 2;
unsigned char temp[4] = {0x0};
//
while(1)
{
fread(temp, 4, 1, fp);
if(counter)
{
if(feof(fp))
{
return (-1);
}
if(compare(fileKey, temp, 4))
{
counter = counter - 1;
if(counter == 0)
{
return (0);
}
}
fwrite(temp, 4, 1, fp2);
}
if(counter == 0)
{
return (0);
}
}
//
if(fclose(fp2))
{
puts("close failed.");
return (-1);
}
return (0);
}
int main(int argc, const char * argv[])
{
FILE *fp1;
fp1 = fopen("DATA003.BIN", "rb");
char fileNum[4] = "000";
if(fp1 == NULL)
{
puts("open failed.");
return (-1);
}
//
unsigned char buff[4] = {0x0};
fread(buff, 4, 1, fp1);
fseek(fp1, 0L, SEEK_SET);
while(1)
{
numaddition(fileNum);
if(makeFile(fp1, buff, fileNum))
{
break;
}
else
{
fseek(fp1, -4L, SEEK_CUR);
}
}
//
if(fclose(fp1))
{
puts("close failed.");
return (-1);
}
return 0;
}
现在出现在您眼前的是一句注释都没有的代码。在加上注释之前本人要出门吃烤肉去,稍后回来-_-#
#include "Header.h"
int numaddition(char *numArray)
{
int temp = 0;
temp = atoi(numArray);
temp++;
sprintf(numArray, "%d", temp);
return (0);
}
int compare(unsigned char *leftArray, unsigned char *rightArray, int lengh)
{
for(int i = 0; i < lengh ; i++)
{
if(leftArray[i] != rightArray[i])
{
return (0);
}
}
return (1);
}
int makeFile(FILE *fp, unsigned char *fileKey, char *fileNum)
{
char final_leftName[20] = "DATA003-";
char rightName[] = ".wav";
strcat(final_leftName, fileNum);
strcat(final_leftName, rightName);
FILE *fp2;
fp2 = fopen(final_leftName, "wb");
if(fp2 == NULL)
{
puts("open 1 failed.");
return (-1);
}
int counter = 2; // 计数器,当=0时停止复制。
unsigned char temp[4] = {0x0};
//
while(1)
{
fread(temp, 4, 1, fp);
if(counter)
{
if(feof(fp))
{
return (-1);
}
if(compare(fileKey, temp, 4)) // 寻找下一个文件的文件头
{
counter = counter - 1;
if(counter == 0)
{
return (0);
}
}
fwrite(temp, 4, 1, fp2);
}
if(counter == 0)
{
return (0);
}
}
//
if(fclose(fp2))
{
puts("close failed.");
return (-1);
}
return (0);
}
int main(int argc, const char * argv[])
{
FILE *fp1;
fp1 = fopen("DATA003.BIN", "rb");
char fileNum[4] = "000";
if(fp1 == NULL)
{
puts("open failed.");
return (-1);
}
//
unsigned char buff[4] = {0x0}; // 读取文件头
fread(buff, 4, 1, fp1);
fseek(fp1, 0L, SEEK_SET);
while(1)
{
numaddition(fileNum); // 设置文件编号
if(makeFile(fp1, buff, fileNum)) // 创建声音文件
{
break;
}
else
{
fseek(fp1, -4L, SEEK_CUR); // 偏移量调整
}
}
//
if(fclose(fp1))
{
puts("close failed.");
return (-1);
}
return (0);
}
过程就是这样。OK,下面是程序和导出的音效。
点击打开链接