Skip to content

Commit

Permalink
v2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
HolographicHat committed Apr 12, 2023
1 parent 58dcd5b commit c60d3a3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
10 changes: 5 additions & 5 deletions lib/src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
using Genshin::ByteArray, Genshin::ClientKcpEvent, Genshin::KcpPacket, Genshin::KcpEventType;
using std::to_string;

HWND unityWnd = 0;
HANDLE hPipe = 0;
HWND unityWnd = nullptr;
HANDLE hPipe = nullptr;

// Allow Protocol: GetPlayerToken, PlayerLogin, AchievementAllDataNotify, Ping
std::set<UINT16> PacketWhitelist = { 167, 175, 154, 164, 2698, 14, 34, 106 };
std::set<UINT16> PacketWhitelist = { 190, 196, 189, 176, 2659, 16, 56, 152 };

bool OnPacket(KcpPacket* pkt) {
if (pkt->data == nullptr) return true;
Expand All @@ -30,7 +30,7 @@ bool OnPacket(KcpPacket* pkt) {
return false;
}
printf("Passed cmdid: %d\n", ReadMapped<UINT16>(data->vector, 2));
if (ReadMapped<UINT16>(data->vector, 2) == 2698) {
if (ReadMapped<UINT16>(data->vector, 2) == 2659) {
auto headLength = ReadMapped<UINT16>(data->vector, 4);
auto dataLength = ReadMapped<UINT32>(data->vector, 6);
auto iStr = Genshin::ToBase64String(data, 10 + headLength, dataLength, nullptr);
Expand Down Expand Up @@ -86,7 +86,7 @@ void Run(HMODULE* phModule) {
//freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
while (
GetModuleHandle("UserAssembly.dll") == nullptr ||
(unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == 0
(unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == nullptr
) {
Sleep(1000);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/il2cpp-api-functions.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DO_API(0x991b10, 0x99ad10, Il2CppString*, il2cpp_string_new, (const char* str));
DO_API(0x897c10, 0x8951f0, Il2CppString*, il2cpp_string_new, (const char* str));
28 changes: 14 additions & 14 deletions lib/src/il2cpp-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ using namespace Genshin;

// DO_APP_FUNC(CN_OFFSET, OS_OFFSET, RETURN, FUNC_NAME, (ARGS...));

DO_APP_FUNC(0x728c160, 0x71cc2e0, Il2CppString*, ToBase64String, (ByteArray* value, int offset, int length, void* method));
DO_APP_FUNC(0x6790b00, 0x6839fa0, Il2CppString*, ToBase64String, (ByteArray* value, int offset, int length, void* method));

DO_APP_FUNC(0x2e2c930, 0x2dc4b90, void, SetVersion, (void* obj, Il2CppString* value, void* method));
DO_APP_FUNC(0x379bb90, 0x3821a40, void, SetVersion, (void* obj, Il2CppString* value, void* method));

DO_APP_FUNC(0x7c318d0, 0x7b69060, ByteArray*, RecordUserData, (int32_t nType));
DO_APP_FUNC(0x7040220, 0x70f3890, ByteArray*, RecordUserData, (int32_t nType));

DO_APP_FUNC(0x1ba7d30, 0x1b7b9f0, void, XorEncrypt, (ByteArray** data, int length, void* method));
DO_APP_FUNC(0xf85bf0, 0xf90450, void, XorEncrypt, (ByteArray** data, int length, void* method));

DO_APP_FUNC(0xc3fe80, 0xc47280, int, KcpSend, (void* client, KcpPacket* pkt, void* method));
DO_APP_FUNC(0x156e740, 0x158a1e0, int, KcpSend, (void* client, KcpPacket* pkt, void* method));

DO_APP_FUNC(0xf1ec70, 0xf1bca0, bool, KcpRecv, (void* client, ClientKcpEvent* evt, void* method));
DO_APP_FUNC(0x2ce2040, 0x2d44790, bool, KcpRecv, (void* client, ClientKcpEvent* evt, void* method));

DO_APP_FUNC(0x75a6880, 0x74e4b80, LPVOID, GetDefaultEncoding, ());
DO_APP_FUNC(0x6a4e700, 0x6afb5e0, LPVOID, GetDefaultEncoding, ());

DO_APP_FUNC(0x75a6130, 0x74e4420, Il2CppString*, GetString, (LPVOID encoding, LPVOID bytes));
DO_APP_FUNC(0x6a4dfb0, 0x6afae80, Il2CppString*, GetString, (LPVOID encoding, LPVOID bytes));

DO_APP_FUNC(0x75a4fc0, 0x74e32b0, ByteArray*, GetBytes, (LPVOID encoding, LPVOID str));
DO_APP_FUNC(0x6a4ce50, 0x6af9d50, ByteArray*, GetBytes, (LPVOID encoding, LPVOID str));

DO_APP_FUNC(0x1bf31f0, 0x1bc5f60, VOID, RequestLogin, (LPVOID obj, LPVOID token, UINT uid));
DO_APP_FUNC(0x36a1260, 0x3723bc0, VOID, RequestLogin, (LPVOID obj, LPVOID token, UINT uid));

DO_APP_FUNC(0x4922d40, 0x4879590, VOID, SetChecksum, (LPVOID obj, Il2CppString* value));
DO_APP_FUNC(0x26506b0, 0x1b0c690, VOID, SetChecksum, (LPVOID obj, Il2CppString* value));

DO_APP_FUNC(0x34780d0, 0x3401460, VOID, ForceQuit, (LPVOID obj));
DO_APP_FUNC(0xf25990, 0xf2f110, VOID, ForceQuit, (LPVOID obj));

DO_APP_FUNC(0x57df820, 0x5727410, LPVOID, GetSingletonManager, ());
DO_APP_FUNC(0x4aac4c0, 0x4b57410, LPVOID, GetSingletonManager, ());

DO_APP_FUNC(0x57df550, 0x5727140, LPVOID, GetSingletonInstance, (LPVOID obj, Il2CppString* value));
DO_APP_FUNC(0x4aac1f0, 0x4b57140, LPVOID, GetSingletonInstance, (LPVOID obj, Il2CppString* value));
2 changes: 1 addition & 1 deletion lib/src/il2cpp-unity-functions.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using namespace Genshin;

DO_UNI_FUNC(0x00100570, 0x00100570, ByteArray*, UnityEngine_RecordUserData, (int32_t nType));
DO_UNI_FUNC(0x100640, 0x100640, ByteArray*, UnityEngine_RecordUserData, (int32_t nType));
12 changes: 6 additions & 6 deletions lib/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
VOID DisableVMProtect() {
DWORD oldProtect = 0;
auto ntdll = GetModuleHandleA("ntdll.dll");
BYTE callcode = ((BYTE*)GetProcAddress(ntdll, "NtQuerySection"))[4] - 1;
BYTE restore[] = { 0x4C, 0x8B, 0xD1, 0xB8, callcode };
auto nt_vp = (BYTE*)GetProcAddress(ntdll, "NtProtectVirtualMemory");
VirtualProtect(nt_vp, sizeof(restore), PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(nt_vp, restore, sizeof(restore));
VirtualProtect(nt_vp, sizeof(restore), oldProtect, &oldProtect);
auto pNtProtectVirtualMemory = GetProcAddress(ntdll, "NtProtectVirtualMemory");
auto pNtQuerySection = GetProcAddress(ntdll, "NtQuerySection");
DWORD old;
VirtualProtect(pNtProtectVirtualMemory, 1, PAGE_EXECUTE_READWRITE, &old);
*(uintptr_t*)pNtProtectVirtualMemory = *(uintptr_t*)pNtQuerySection & ~(0xFFui64 << 32) | (uintptr_t)(*(uint32_t*)((uintptr_t)pNtQuerySection + 4) - 1) << 32;
VirtualProtect(pNtProtectVirtualMemory, 1, old, &old);
}

#pragma region StringConvert
Expand Down
12 changes: 6 additions & 6 deletions res/proto/AchievementAllDataNotify.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ message Achievement {
FINISHED = 2;
REWARD_TAKEN = 3;
}
uint32 timestamp = 13;
uint32 current = 2;
uint32 total = 5;
uint32 id = 9;
Status status = 6;
uint32 timestamp = 9;
uint32 current = 3;
uint32 total = 4;
uint32 id = 10;
Status status = 2;
}

message AchievementAllDataNotify {
repeated Achievement list = 15;
repeated Achievement list = 11;
}
4 changes: 2 additions & 2 deletions src/GlobalVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static class GlobalVars {
public static readonly string CachePath = Path.Combine(DataPath, "cache");
public static readonly string LibFilePath = Path.Combine(DataPath, "YaeAchievement.dll");

public const uint AppVersionCode = 36;
public const string AppVersionName = "2.6";
public const uint AppVersionCode = 37;
public const string AppVersionName = "2.7";

public const string PipeName = "YaeAchievementPipe";
public const string BucketHost = "https://cn-cd-1259389942.file.myqcloud.com";
Expand Down

0 comments on commit c60d3a3

Please sign in to comment.