Workaround scePauth_F7AA47F6()

This commit is contained in:
raven02 committed 2014-04-27 17:26:40 +08:00
1 parent 6f008fb3a7
commit 80cff2dca4
1 file changed
+46 -5
+46 -5
View File
@@ -24,12 +24,53 @@
#include "Core/HLE/scePauth.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/Reporting.h"
int scePauth_F7AA47F6(u32 srcPtr, int srcLength, u32 destLengthPtr, u32 workArea)
{
ERROR_LOG_REPORT_ONCE(scePauth_F7AA47F6, HLE, "UNIMPL scePauth_F7AA47F6(%08x, %08x, %08x, %08x)", srcPtr, srcLength, destLengthPtr, workArea);
return 0;
u8 *src, *key;
u32 crc;
char name[256];
std::string hostPath;
FILE *fp;
int size;
INFO_LOG(HLE, "scePauth_F7AA47F6(%08x, %08x, %08x, %08x)", srcPtr, srcLength, destLengthPtr, workArea);
sprintf(name, "ms0:/PAUTH");
pspFileSystem.GetHostPath(std::string(name), hostPath);
src = (u8*)Memory::GetPointer(srcPtr);
key = (u8*)Memory::GetPointer(workArea);
crc = crc32(0, src, srcLength);
sprintf(name, "%s/pauth_%08x.bin.decrypt", hostPath.c_str(), crc);
fp = fopen(name, "rb");
if (fp){
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(src, 1, size, fp);
fclose(fp);
Memory::Write_U32(size, destLengthPtr);
INFO_LOG(HLE, "Read from decrypted file %s", name);
return 0;
}
pspFileSystem.MkDir("ms0:/PAUTH");
sprintf(name, "%s/pauth_%08x.bin", hostPath.c_str(), crc);
ERROR_LOG(HLE, "No decrypted file found! save as %s", name);
fp = fopen(name, "wb");
fwrite(src, 1, srcLength, fp);
fclose(fp);
sprintf(name, "%s/pauth_%08x.key", hostPath.c_str(), crc);
fp = fopen(name, "wb");
fwrite(key, 1, 16, fp);
fclose(fp);
return -1;
}
int scePauth_98B83B5D(u32 srcPtr, int srcLength, u32 destLengthPtr, u32 workArea)
@@ -59,14 +100,14 @@ int scePauth_98B83B5D(u32 srcPtr, int srcLength, u32 destLengthPtr, u32 workArea
fread(src, 1, size, fp);
fclose(fp);
Memory::Write_U32(size, destLengthPtr);
INFO_LOG(HLE, " read from decrypted file %s", name);
INFO_LOG(HLE, "Read from decrypted file %s", name);
return 0;
}
pspFileSystem.MkDir("ms0:/PAUTH");
sprintf(name, "%s/pauth_%08x.bin", hostPath.c_str(), crc);
ERROR_LOG(HLE, " no decrypted file found! save as %s", name);
ERROR_LOG(HLE, "No decrypted file found! save as %s", name);
fp = fopen(name, "wb");
fwrite(src, 1, srcLength, fp);