1
0
mirror of synced 2025-02-01 04:15:50 +01:00

File hooks + NESYS emulator improvements

- Hooked FindFirstFileA/W to have even better file redirection.
- News file is now extracted to OpenParrot dir for each Nesica title.
- News file is actually now given to NESYS titles so they don't crash / go crazy because of missing news.png
- Ikaruga now works.
- Crimzon Clover now works.
This commit is contained in:
Reaver 2018-09-17 19:03:43 +03:00
parent 946c5d5272
commit c892a4c2ed
6 changed files with 130 additions and 4 deletions

View File

@ -64,6 +64,19 @@ static InitFunction initFunction_MB([]()
injector::MakeNOP(imageBase + 0x56B21, 2);
}, GameID::MagicalBeat);
static InitFunction initFunction_CC([]()
{
uintptr_t imageBase = (uintptr_t)GetModuleHandleA(0);
init_FastIoEmu();
init_RfidEmu();
init_RegHooks();
init_NesysEmu();
init_CryptoPipe(GameDetect::NesicaKey);
// Skip stuck on Warning screen. NESYS emu must be improved for this to work properly!
injector::MakeNOP(imageBase + 0x1015E7, 2);
}, GameID::CrimzonClover);
static InitFunction initFunction_SOR([]()
{
uintptr_t imageBase = (uintptr_t)GetModuleHandleA(0);

View File

@ -2,6 +2,7 @@
#include "NesysEmu.h"
//#if _M_IX86
#include "Utility/Utils.h"
#include "NesysNewsFile.h"
#pragma optimize("", off)
NesysEmu::NesysEmu()
: m_initialized(false)
@ -66,8 +67,8 @@ NesysEmu::NesysEmu()
strcpy(response->tenpo.pref_name, "t33l");
response->news.type = 0;
response->news.size = 1337;
strcpy(response->news.iFilePath, "/wat");
response->news.size = strlen("./OpenParrot/news.png");
strcpy(response->news.iFilePath, "./OpenParrot/news.png");
response->serverSize = strlen(wat);
memcpy(response->server, wat, strlen(wat));
@ -525,8 +526,21 @@ DWORD WINAPI GetIfEntryFunc(
return 0;
}
void WriteNewsFile()
{
// News for NESYS Emu
FILE *pFile = fopen(".\\OpenParrot\\news.png", "wb");
if (pFile != NULL)
{
fwrite(nesysNews, sizeof(char), sizeof(nesysNews), pFile);
fclose(pFile);
}
}
void init_NesysEmu()
{
CreateDirectoryA("OpenParrot", nullptr);
WriteNewsFile();
MH_Initialize();
MH_CreateHookApi(L"iphlpapi.dll", "GetIfEntry", GetIfEntryFunc, (void**)&g_origGetIfEntry);
MH_EnableHook(MH_ALL_HOOKS);

View File

@ -0,0 +1,72 @@
#pragma once
unsigned char nesysNews[818] = {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00,
0x08, 0x03, 0x00, 0x00, 0x00, 0xC3, 0xA6, 0x24, 0xC8, 0x00, 0x00, 0x00,
0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72,
0x65, 0x00, 0x41, 0x64, 0x6F, 0x62, 0x65, 0x20, 0x49, 0x6D, 0x61, 0x67,
0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x71, 0xC9, 0x65, 0x3C, 0x00, 0x00,
0x00, 0x06, 0x50, 0x4C, 0x54, 0x45, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
0xA5, 0xD9, 0x9F, 0xDD, 0x00, 0x00, 0x02, 0xC2, 0x49, 0x44, 0x41, 0x54,
0x78, 0xDA, 0xEC, 0xDD, 0x41, 0x0E, 0x82, 0x40, 0x10, 0x45, 0x41, 0xBC,
0xFF, 0xA5, 0xDD, 0x92, 0x10, 0xE0, 0x77, 0x33, 0x0A, 0x19, 0xAA, 0x96,
0x06, 0xC6, 0x91, 0x7E, 0x2B, 0x22, 0xBA, 0x2C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0,
0x1A, 0x9F, 0x1D, 0xF1, 0x81, 0x3B, 0x87, 0x9F, 0x1C, 0xBF, 0x39, 0x29,
0x5E, 0xCC, 0xC8, 0x04, 0x80, 0x00, 0x10, 0x00, 0x02, 0x40, 0x00, 0x08,
0x00, 0x01, 0x20, 0x00, 0xAE, 0x8C, 0x3E, 0xB8, 0xD8, 0xC5, 0xC3, 0x4F,
0x26, 0x1A, 0xEF, 0x46, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00,
0x01, 0x08, 0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x10, 0x00, 0x02, 0x60,
0xE2, 0x00, 0xF2, 0x37, 0x41, 0x00, 0x08, 0x00, 0x01, 0x20, 0x00, 0x04,
0x80, 0x00, 0x10, 0x00, 0x02, 0x60, 0x82, 0x00, 0xD6, 0xA7, 0x0A, 0x40,
0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x20, 0x00, 0x04,
0x80, 0x00, 0x10, 0x00, 0xF7, 0x04, 0x70, 0xFD, 0xD9, 0xC0, 0x60, 0x37,
0xF1, 0x3B, 0x21, 0x00, 0x04, 0x80, 0x00, 0x10, 0x00, 0x02, 0x40, 0x00,
0x08, 0x80, 0x7F, 0xDD, 0x08, 0xAA, 0x2E, 0xDF, 0xDF, 0x8D, 0x00, 0x04,
0x20, 0x00, 0x01, 0x18, 0x9C, 0x00, 0x10, 0x00, 0x02, 0x40, 0x00, 0x08,
0x00, 0x01, 0x30, 0x73, 0x00, 0x87, 0x7B, 0x42, 0x00, 0x08, 0x00, 0x01,
0x20, 0x00, 0x04, 0x80, 0x00, 0x10, 0x00, 0x02, 0x40, 0x00, 0x08, 0x00,
0x01, 0x20, 0x00, 0x04, 0x80, 0x00, 0x10, 0x00, 0x02, 0x40, 0x00, 0x1C,
0x5C, 0xF8, 0xE2, 0xC3, 0x7B, 0xBD, 0x85, 0x5B, 0x7D, 0x09, 0x40, 0x00,
0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x20, 0x00, 0x04, 0x80,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x83, 0xE5,
0x3F, 0xC9, 0x76, 0x7C, 0xEE, 0xA0, 0xE5, 0x5B, 0xDB, 0x69, 0xFD, 0x68,
0x5D, 0xEB, 0x13, 0x0B, 0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20,
0x00, 0x01, 0x08, 0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00,
0x01, 0x4C, 0x12, 0xC0, 0xCE, 0xEB, 0xA3, 0x2E, 0x79, 0xB2, 0xFC, 0xA0,
0xFF, 0xA5, 0x0C, 0x26, 0xFA, 0xEA, 0xA9, 0x0B, 0x40, 0x00, 0x02, 0x10,
0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00, 0x02, 0x10, 0x80,
0x00, 0x04, 0x20, 0x00, 0x01, 0xDC, 0x3F, 0x21, 0x01, 0x08, 0x40, 0x00,
0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00, 0x02,
0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00, 0x02, 0x10,
0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00, 0x02, 0x10, 0x80,
0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00, 0xC3, 0x02, 0xA8, 0x3E,
0xBC, 0x57, 0x9C, 0xD0, 0x0F, 0x9E, 0x0D, 0x14, 0x80, 0x00, 0x04, 0x20,
0x00, 0x01, 0x08, 0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00,
0x01, 0x08, 0x40, 0x00, 0x23, 0x6E, 0x04, 0xF5, 0x82, 0x09, 0xEE, 0xD4,
0x54, 0xFB, 0x12, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00,
0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40, 0x00, 0x02,
0x10, 0xC0, 0xFD, 0x01, 0x14, 0xEF, 0x04, 0x26, 0x13, 0xF2, 0x8D, 0x20,
0x01, 0x08, 0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01,
0x08, 0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08,
0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40,
0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0xE0, 0xC5,
0x01, 0x6C, 0x4F, 0x8A, 0x3F, 0x8F, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08,
0x40, 0x00, 0x02, 0x10, 0x80, 0x00, 0x04, 0x20, 0x00, 0x01, 0x08, 0x40,
0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3C, 0xD2, 0x57, 0x80, 0x01, 0x00, 0x9B, 0x23, 0x44, 0x42, 0x24, 0x20,
0x35, 0x32, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42,
0x60, 0x82
};

View File

@ -801,10 +801,30 @@ static BOOL __stdcall CreateDirectoryWWrap(
return g_origCreateDirectoryW(ParseFileNamesW(lpPathName), lpSecurityAttributes);
}
static HANDLE(__stdcall *g_origFindFirstFileA)(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
static HANDLE __stdcall FindFirstFileAWrap(
LPCSTR lpFileName,
LPWIN32_FIND_DATAA lpFindFileData
)
{
return g_origFindFirstFileA(ParseFileNamesA(lpFileName), lpFindFileData);
}
static HANDLE(__stdcall *g_origFindFirstFileW)(LPCWSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
static HANDLE __stdcall FindFirstFileWWrap(
LPCWSTR lpFileName,
LPWIN32_FIND_DATAA lpFindFileData
)
{
return g_origFindFirstFileW(ParseFileNamesW(lpFileName), lpFindFileData);
}
void init_RfidEmu()
{
MH_Initialize();
CreateDirectoryA("OpenParrot", nullptr);
MH_CreateHookApi(L"kernel32.dll", "FindFirstFileA", FindFirstFileAWrap, (void**)&g_origFindFirstFileA);
MH_CreateHookApi(L"kernel32.dll", "FindFirstFileW", FindFirstFileWWrap, (void**)&g_origFindFirstFileW);
MH_CreateHookApi(L"kernel32.dll", "CreateDirectoryA", CreateDirectoryAWrap, (void**)&g_origCreateDirectoryA);
MH_CreateHookApi(L"kernel32.dll", "CreateDirectoryW", CreateDirectoryWWrap, (void**)&g_origCreateDirectoryW);
MH_CreateHookApi(L"kernel32.dll", "GetFileAttributesA", GetFileAttributesAWrap, (void**)&g_origGetFileAttributesA);

View File

@ -33,13 +33,19 @@ void GameDetect::DetectCurrentGame()
NesicaKey = NesicaKey::MagicalBeat;
isNesica = true;
break;
case 0x2809c7c0: // Ikaruga
currentGame = GameID::Nesica;
NesicaKey = NesicaKey::None;
isNesica = true;
break;
case 0x6e67076f:
currentGame = GameID::Nesica;
NesicaKey = NesicaKey::BlazBlueCentralFriction;
isNesica = true;
break;
case 0xd98bed41: // Crimzon Clover
currentGame = GameID::Nesica;
currentGame = GameID::CrimzonClover;
NesicaKey = NesicaKey::None;
isNesica = true;
break;

View File

@ -43,5 +43,6 @@ enum class GameID
GrooveCoaster2,
PuzzleBobble,
WMMT5,
MagicalBeat
MagicalBeat,
CrimzonClover
};