Add crc calculation in loading module

This commit is contained in:
sum2012 2022-10-04 08:29:23 +08:00
parent 1469a32a9d
commit 95e6eaa601
3 changed files with 12 additions and 7 deletions

View file

@ -67,6 +67,7 @@
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"
#include "UI/GameScreen.h"
enum {
PSP_THREAD_ATTR_KERNEL = 0x00001000,
@ -1144,6 +1145,9 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) {
}
static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) {
u32 crc = crc32(0, Z_NULL, 0);
crc = crc32(crc, ptr, elfSize);
const std::string crcstring = int2hexstr(crc);
PSPModule *module = new PSPModule();
kernelObjects.Create(module);
loadedModules.insert(module->GetUID());
@ -1170,7 +1174,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
if (IsHLEVersionedModule(head->modname)) {
int ver = (head->module_ver_hi << 8) | head->module_ver_lo;
INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x", head->modname, ver, head->devkitversion);
INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x, crc %s", head->modname, ver, head->devkitversion, crcstring.c_str());
reportedModule = true;
if (!strcmp(head->modname, "sceMpeg_library")) {

View file

@ -44,6 +44,7 @@
#include "UI/MainScreen.h"
#include "UI/BackgroundAudio.h"
#include "Core/Reporting.h"
#include <sstream>
GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
g_BackgroundAudio.SetGame(gamePath);
@ -55,12 +56,10 @@ GameScreen::~GameScreen() {
}
}
template <typename I> std::string int2hexstr(I w, size_t hex_len = sizeof(I) << 1) {
static const char* digits = "0123456789ABCDEF";
std::string rc(hex_len, '0');
for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4)
rc[i] = digits[(w >> j) & 0x0f];
return rc;
std::string int2hexstr(const int a) {
std::stringstream stream;
stream << std::hex << a;
return stream.str();
}
void GameScreen::update() {

View file

@ -29,6 +29,8 @@
// Uses GameInfoCache heavily to implement the functionality.
// Should possibly merge this with the PauseScreen.
std::string int2hexstr(const int a);
class GameScreen : public UIDialogScreenWithGameBackground {
public:
GameScreen(const Path &gamePath);