#pragma once using std::string; bool IsLittleEndian(); HWND FindMainWindowByPID(DWORD pid); UINT32 GCHandle_New(LPVOID object, bool pinned); string IlStringToString(Il2CppString* str, UINT codePage = CP_ACP); #define cstring_new(str) il2cpp_string_new(str) #define string_new(str) cstring_new((str).c_str()) #define ErrorDialogT(title, msg) MessageBox(unityWnd, msg, title, MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); #define ErrorDialog(msg) ErrorDialogT("YaeAchievement", msg) #define Win32ErrorDialog(code) ErrorDialogT("YaeAchievement", ("CRITICAL ERROR!\nError code: " + std::to_string(GetLastError()) + "-"#code"\n\nPlease take the screenshot and contact developer by GitHub Issue to solve this problem\nNOT MIHOYO/COGNOSPHERE CUSTOMER SERVICE!").c_str()) template static T ReadMapped(void* data, int offset, bool littleEndian = false) { char* cData = (char*)data; T result = {}; if (IsLittleEndian() != littleEndian) { for (int i = 0; i < sizeof(T); i++) ((char*)&result)[i] = cData[offset + sizeof(T) - i - 1]; return result; } memcpy(&result, cData + offset, sizeof(result)); return result; } template static T* GCHandle_GetObject(UINT handle) { return (T*) il2cpp_gchandle_get_target(handle); }