Skip to content

Commit

Permalink
Welcome Minnie
Browse files Browse the repository at this point in the history
  • Loading branch information
qhy040404 committed Oct 29, 2024
1 parent 8bb4c8a commit da3d083
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Snap.Hutao.UnlockerIsland</id>
<version>1.1.17</version>
<version>1.1.18</version>
<authors>DGP Studio</authors>
<developmentDependency>true</developmentDependency>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
29 changes: 18 additions & 11 deletions src/UnlockerIsland/Snap.Hutao.UnlockerIsland/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,33 @@ using namespace Snap::Hutao::UnlockerIsland;
HANDLE hThread = NULL;
BOOL bDllExit = FALSE;

std::string checksum;
std::string minnie;

struct IslandEnvironment* pEnvironment = NULL;
struct IslandStaging staging {};

static VOID MickeyWonderPartner2Endpoint(LPVOID this__, LPVOID req, LPVOID methodInfo)
static VOID MickeyWonderPartner2Endpoint(LPVOID mickey, LPVOID house, LPVOID spell)
{
Il2CppString* pString = staging.MickeyWonderPartner(checksum.c_str());
Il2CppString* pCurrent = (Il2CppString*)((PBYTE)req + 0x90);
Il2CppString* pString = staging.MickeyWonderPartner(minnie.c_str());
Il2CppString** ppCurrent = (Il2CppString**)((PBYTE)house + 0x90);

Log("Current class: %p\n", pCurrent->object.klass);
if (*ppCurrent == NULL || IsBadReadPtr(*ppCurrent, sizeof(Il2CppString)))
{
Log("There is no mouse.\n");
return staging.MickeyWonderPartner2(mickey, house, spell);
}

Log("Current class: %p\n", (*ppCurrent)->object.klass);
LogW(L"Current Minnie: %s\n", &(*ppCurrent)->chars[0]);
Log("String class: %p\n", pString->object.klass);
LogW(L"String Minnie: %s\n", &pString->chars[0]);

WCHAR test = pCurrent->chars[0];
if (pCurrent->chars[0] == 0x0700)
if ((*ppCurrent)->object.klass == pString->object.klass)
{
*(LPVOID*)((PBYTE)req + 0x90) = pString;
*ppCurrent = pString;
}

staging.MickeyWonderPartner2(this__, req, methodInfo);
staging.MickeyWonderPartner2(mickey, house, spell);
}

static VOID SetFieldOfViewEndpoint(LPVOID pThis, FLOAT value)
Expand Down Expand Up @@ -60,7 +67,7 @@ static VOID OpenTeamEndpoint()
}
}

static VOID InitializeIslandStaging(Snap::Hutao::UnlockerIsland::IslandStaging& const staging, UINT64 base, Snap::Hutao::UnlockerIsland::IslandEnvironment* pEnvironment)
static VOID InitializeIslandStaging(IslandStaging& staging, UINT64 base, IslandEnvironment* pEnvironment)
{
// Magic
staging.MickeyWonder = reinterpret_cast<MickeyWonderMethod>(base + pEnvironment->FunctionOffsetMickeyWonderMethod);
Expand Down Expand Up @@ -132,7 +139,7 @@ static DWORD WINAPI IslandThread(LPVOID lpParam)
for (INT32 n = 0; n < 3; n++)
{
Il2CppArraySize* const result = staging.MickeyWonder(n);
checksum += std::string(reinterpret_cast<char*>(&result->vector[0]), result->max_length);
minnie += std::string(reinterpret_cast<char*>(&result->vector[0]), result->max_length);
}

Detours::Hook(&(LPVOID&)staging.MickeyWonderPartner2, MickeyWonderPartner2Endpoint);
Expand Down
12 changes: 11 additions & 1 deletion src/UnlockerIsland/Snap.Hutao.UnlockerIsland/framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ typedef struct Il2CppString

typedef Il2CppArraySize* (*MickeyWonderMethod)(INT32 value);
typedef Il2CppString* (*MickeyWonderMethodPartner)(PCSTR value);
typedef VOID (*MickeyWonderMethodPartner2)(LPVOID this__, LPVOID req, LPVOID methodInfo);
typedef VOID (*MickeyWonderMethodPartner2)(LPVOID mickey, LPVOID house, LPVOID spell);
typedef VOID (*SetFieldOfViewFunc)(LPVOID this__, FLOAT value);
typedef VOID (*SetEnableFogRenderingFunc)(bool value);
typedef VOID (*SetTargetFrameRateFunc)(INT32 value);
Expand All @@ -116,4 +116,14 @@ inline void Log(const char* format, ...)
vfprintf(stdout, format, args);
va_end(args);
#endif
}

inline void LogW(const WCHAR* format, ...)
{
#ifdef _DEBUG
va_list args;
va_start(args, format);
vfwprintf(stdout, format, args);
va_end(args);
#endif
}

0 comments on commit da3d083

Please sign in to comment.