fix PSO PC encryption

This commit is contained in:
Martin Michelsen
2022-04-01 21:24:42 -07:00
parent 3f5f2fc61d
commit 46add5fb74
2 changed files with 13 additions and 7 deletions
+2 -4
View File
@@ -30,8 +30,7 @@ void PSOPCEncryption::update_stream() {
eax = edi; eax = edi;
while (edx > 0) { while (edx > 0) {
esi = this->stream[eax + 0x1F]; esi = this->stream[eax + 0x1F];
ebp = this->stream[eax]; ebp = this->stream[eax] - esi;
ebp = ebp - esi;
this->stream[eax] = ebp; this->stream[eax] = ebp;
eax++; eax++;
edx--; edx--;
@@ -41,8 +40,7 @@ void PSOPCEncryption::update_stream() {
eax = edi; eax = edi;
while (edx > 0) { while (edx > 0) {
esi = this->stream[eax - 0x18]; esi = this->stream[eax - 0x18];
ebp = this->stream[eax]; ebp = this->stream[eax] - esi;
ebp = ebp - esi;
this->stream[eax] = ebp; this->stream[eax] = ebp;
eax++; eax++;
edx--; edx--;
+11 -3
View File
@@ -8,7 +8,7 @@
#define PC_STREAM_LENGTH 57 #define PC_STREAM_LENGTH 56
#define GC_STREAM_LENGTH 521 #define GC_STREAM_LENGTH 521
#define BB_STREAM_LENGTH 1042 #define BB_STREAM_LENGTH 1042
@@ -18,6 +18,14 @@ public:
virtual void encrypt(void* data, size_t size, bool advance = true) = 0; virtual void encrypt(void* data, size_t size, bool advance = true) = 0;
virtual void decrypt(void* data, size_t size, bool advance = true); virtual void decrypt(void* data, size_t size, bool advance = true);
inline void encrypt(std::string& data, bool advance = true) {
this->encrypt(data.data(), data.size(), advance);
}
inline void decrypt(std::string& data, bool advance = true) {
this->decrypt(data.data(), data.size(), advance);
}
virtual void skip(size_t size) = 0; virtual void skip(size_t size) = 0;
protected: protected:
@@ -35,8 +43,8 @@ protected:
void update_stream(); void update_stream();
uint32_t next(bool advance = true); uint32_t next(bool advance = true);
uint32_t stream[PC_STREAM_LENGTH]; uint32_t stream[PC_STREAM_LENGTH + 1];
uint16_t offset; uint8_t offset;
}; };
class PSOGCEncryption : public PSOEncryption { class PSOGCEncryption : public PSOEncryption {