Files
DevourClient/framework/helpers.cpp
Jadis0x 0b84c20f4a code optimization &new helper functions added / modified
- UnityCore namespace changed to UnityEngine
- Object class is no longer a template. FindObjectOfType function set to template
- Added LogComponents function. It helps us retrieve components from the target gameObject.
- Added GetObjectName function to Object structure (same method is available in utils header)
- Added ConvertToSystemString function.
Converts const char to system.string (app::String)
2024-06-06 20:43:35 +03:00

63 lines
1.9 KiB
C++

// Generated C++ file by Il2CppInspector - http://www.djkaty.com - https://github.com/djkaty
// Helper functions
#include "pch-il2cpp.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string>
#include <codecvt>
#include "helpers.h"
// Log file location
extern const LPCWSTR LOG_FILE;
// Helper function to get the module base address
uintptr_t il2cppi_get_base_address() {
return (uintptr_t) GetModuleHandleW(L"GameAssembly.dll");
}
// Helper function to append text to a file
void il2cppi_log_write(std::string text) {
HANDLE hfile = CreateFileW(LOG_FILE, FILE_APPEND_DATA, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hfile == INVALID_HANDLE_VALUE)
MessageBoxW(0, L"Could not open log file", 0, 0);
DWORD written;
WriteFile(hfile, text.c_str(), (DWORD) text.length(), &written, NULL);
WriteFile(hfile, "\r\n", 2, &written, NULL);
CloseHandle(hfile);
}
// Helper function to open a new console window and redirect stdout there
void il2cppi_new_console() {
AllocConsole();
freopen_s((FILE**) stdout, "CONOUT$", "w", stdout);
}
void il2cpp_close_console() {
fclose((FILE *)stdout);
FreeConsole();
}
#if _MSC_VER >= 1920
// Helper function to convert Il2CppString to std::string
std::string il2cppi_to_string(Il2CppString* str) {
std::u16string u16(reinterpret_cast<const char16_t*>(str->chars));
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(u16);
}
// Helper function to convert System.String to std::string
std::string il2cppi_to_string(app::String* str) {
return il2cppi_to_string(reinterpret_cast<Il2CppString*>(str));
}
app::String* ConvertToSystemString(const char* str)
{
Il2CppString* il2cpp_str = il2cpp_string_new(str);
app::String* system_string_str = reinterpret_cast<app::String*>(il2cpp_str);
return system_string_str;
}
#endif