From 1b891ff2f166a5d00270c1cd00d2606d8cfd114d Mon Sep 17 00:00:00 2001 From: BobTheBob9 Date: Sat, 3 Sep 2022 01:08:39 +0100 Subject: various formatting changes and fixes --- NorthstarDLL/NorthstarDLL.vcxproj | 1349 ++++++++++++++--------------- NorthstarDLL/NorthstarDLL.vcxproj.filters | 3 - NorthstarDLL/dedicatedmaterialsystem.cpp | 1 - NorthstarDLL/exploitfixes.cpp | 30 +- NorthstarDLL/hoststate.cpp | 2 +- NorthstarDLL/logging.cpp | 12 +- NorthstarDLL/scriptdatatables.cpp | 23 +- NorthstarDLL/sigscanning.cpp | 41 - NorthstarDLL/squirrel.cpp | 2 +- NorthstarDLL/vector.h | 10 +- loader_launcher_proxy/Memory.cpp | 82 -- loader_launcher_proxy/Memory.h | 24 - 12 files changed, 718 insertions(+), 861 deletions(-) delete mode 100644 NorthstarDLL/sigscanning.cpp delete mode 100644 loader_launcher_proxy/Memory.cpp delete mode 100644 loader_launcher_proxy/Memory.h diff --git a/NorthstarDLL/NorthstarDLL.vcxproj b/NorthstarDLL/NorthstarDLL.vcxproj index ac1b3991..7b2ece51 100644 --- a/NorthstarDLL/NorthstarDLL.vcxproj +++ b/NorthstarDLL/NorthstarDLL.vcxproj @@ -1,676 +1,675 @@ - - - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {cfad2623-064f-453c-8196-79ee10292e32} - NorthstarDedicatedTest - 10.0 - NorthstarDLL - - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - - true - Northstar - - - false - Northstar - - - - Level3 - true - _DEBUG;NORTHSTARDEDICATEDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);CURL_STATICLIB - true - Use - pch.h - stdcpp20 - $(ProjectDir)include;%(AdditionalIncludeDirectories) - - - Windows - true - false - $(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;version.lib;%(AdditionalDependencies) - - - %(AdditionalLibraryDirectories) - - - - - - - copy /Y "$(TargetPath)" "$(SolutionDir)..\..\" - - - - - Level3 - true - true - true - NDEBUG;NORTHSTARDEDICATEDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);CURL_STATICLIB - true - Use - pch.h - stdcpp20 - $(ProjectDir)include;%(AdditionalIncludeDirectories) - MultiThreadedDLL - - - Windows - true - true - true - false - $(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;version.lib;%(AdditionalDependencies) - - - %(AdditionalLibraryDirectories) - - - - - - - copy /Y "$(TargetPath)" "$(SolutionDir)..\..\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {cfad2623-064f-453c-8196-79ee10292e32} + NorthstarDedicatedTest + 10.0 + NorthstarDLL + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + true + Northstar + + + false + Northstar + + + + Level3 + true + _DEBUG;NORTHSTARDEDICATEDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);CURL_STATICLIB + true + Use + pch.h + stdcpp20 + $(ProjectDir)include;%(AdditionalIncludeDirectories) + + + Windows + true + false + $(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;version.lib;%(AdditionalDependencies) + + + %(AdditionalLibraryDirectories) + + + + + + + copy /Y "$(TargetPath)" "$(SolutionDir)..\..\" + + + + + Level3 + true + true + true + NDEBUG;NORTHSTARDEDICATEDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);CURL_STATICLIB + true + Use + pch.h + stdcpp20 + $(ProjectDir)include;%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Windows + true + true + true + false + $(ProjectDir)include\MinHook.x64.lib;$(ProjectDir)include\libcurl\lib\libcurl_a.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;version.lib;%(AdditionalDependencies) + + + %(AdditionalLibraryDirectories) + + + + + + + copy /Y "$(TargetPath)" "$(SolutionDir)..\..\" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NorthstarDLL/NorthstarDLL.vcxproj.filters b/NorthstarDLL/NorthstarDLL.vcxproj.filters index 293543f7..66fe25ca 100644 --- a/NorthstarDLL/NorthstarDLL.vcxproj.filters +++ b/NorthstarDLL/NorthstarDLL.vcxproj.filters @@ -1652,9 +1652,6 @@ Source Files\Hooks - - Source Files\Hooks - Source Files\Math diff --git a/NorthstarDLL/dedicatedmaterialsystem.cpp b/NorthstarDLL/dedicatedmaterialsystem.cpp index 18bf6a57..5dfa19ec 100644 --- a/NorthstarDLL/dedicatedmaterialsystem.cpp +++ b/NorthstarDLL/dedicatedmaterialsystem.cpp @@ -1,4 +1,3 @@ -#pragma once #include "pch.h" #include "dedicated.h" #include "tier0.h" diff --git a/NorthstarDLL/exploitfixes.cpp b/NorthstarDLL/exploitfixes.cpp index dbe065cc..419fc448 100644 --- a/NorthstarDLL/exploitfixes.cpp +++ b/NorthstarDLL/exploitfixes.cpp @@ -5,6 +5,7 @@ #include "tier0.h" #include "r2engine.h" #include "r2client.h" +#include "vector.h" AUTOHOOK_INIT() @@ -26,23 +27,6 @@ ConVar* Cvar_sv_cheats; return false; \ }()) -// Make sure 3 or less floats are valid -bool ValidateFloats(float a, float b = 0, float c = 0) -{ - return !isnan(a) && !isnan(b) && !isnan(c); -} - -struct Float3 -{ - float vals[3]; - - void MakeValid() - { - for (auto& val : vals) - if (isnan(val)) - val = 0; - } -}; // block bad netmessages // Servers can literally request a screenshot from any client, yeah no AUTOHOOK(CLC_Screenshot_WriteToBuffer, engine.dll + 0x22AF20, @@ -209,11 +193,11 @@ void, __fastcall, (void* buf, void* pCmd_move, void* pCmd_from)) // 4C 89 44 24 DWORD command_number; DWORD tick_count; float command_time; - Float3 worldViewAngles; + Vector3 worldViewAngles; BYTE gap18[4]; - Float3 localViewAngles; - Float3 attackangles; - Float3 move; + Vector3 localViewAngles; + Vector3 attackangles; + Vector3 move; DWORD buttons; BYTE impulse; short weaponselect; @@ -221,8 +205,8 @@ void, __fastcall, (void* buf, void* pCmd_move, void* pCmd_from)) // 4C 89 44 24 BYTE gap4C[24]; char headoffset; BYTE gap65[11]; - Float3 cameraPos; - Float3 cameraAngles; + Vector3 cameraPos; + Vector3 cameraAngles; BYTE gap88[4]; int tickSomething; DWORD dword90; diff --git a/NorthstarDLL/hoststate.cpp b/NorthstarDLL/hoststate.cpp index 6008a0f2..875d671d 100644 --- a/NorthstarDLL/hoststate.cpp +++ b/NorthstarDLL/hoststate.cpp @@ -72,7 +72,7 @@ void,, (CHostState* self)) g_pServerPresence->SetMap(g_pHostState->m_levelName); } -AUTOHOOK(CHostState__State_GameShutdown, engine.dll + 0x16E520, +AUTOHOOK(CHostState__State_GameShutdown, engine.dll + 0x16E640, void,, (CHostState* self)) { spdlog::info("HostState: GameShutdown"); diff --git a/NorthstarDLL/logging.cpp b/NorthstarDLL/logging.cpp index e82c2131..5bd5ae40 100644 --- a/NorthstarDLL/logging.cpp +++ b/NorthstarDLL/logging.cpp @@ -4,6 +4,7 @@ #include "concommand.h" #include "nsprefix.h" #include "bitbuf.h" +#include "tier0.h" #include "spdlog/sinks/basic_file_sink.h" #include @@ -225,11 +226,12 @@ void InitialiseLogging() AllocConsole(); // Bind stdout to receive console output. - FILE* fp; - freopen_s(&fp, "CONOUT$", "w", stdout); - //_dup2(_fileno(stdout), _fileno(stderr)); - - spdlog::default_logger()->set_pattern("[%H:%M:%S] [%l] %v"); + // these two lines are responsible for stuff to not show up in the console sometimes, from talking about it on discord + // apparently they were meant to make logging work when using -northstar, however from testing it seems that it doesnt + // work regardless of these two lines + // freopen("CONOUT$", "w", stdout); + // freopen("CONOUT$", "w", stderr); + spdlog::default_logger()->set_pattern("[%H:%M:%S] [%^%l%$] %v"); } ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", EngineSpewFuncHooks, ConVar, (CModule module)) diff --git a/NorthstarDLL/scriptdatatables.cpp b/NorthstarDLL/scriptdatatables.cpp index cd8a6b2a..2861b964 100644 --- a/NorthstarDLL/scriptdatatables.cpp +++ b/NorthstarDLL/scriptdatatables.cpp @@ -46,7 +46,6 @@ struct Datatable ConVar* Cvar_ns_prefer_datatable_from_disk; template Datatable* (*SQ_GetDatatableInternal)(HSquirrelVM* sqvm); -std::string DataTableToString(Datatable* datatable); struct CSVData { @@ -97,6 +96,7 @@ Vector3 StringToVector(char* pString) return vRet; } +// var function GetDataTable( asset path ) template SQRESULT SQ_GetDatatable(HSquirrelVM* sqvm) { const char* pAssetName; @@ -271,6 +271,7 @@ template SQRESULT SQ_GetDatatable(HSquirrelVM* sqvm) } } +// int function GetDataTableRowCount( var datatable, string columnName ) template SQRESULT SQ_GetDataTableColumnByName(HSquirrelVM* sqvm) { CSVData** pData; @@ -297,6 +298,7 @@ template SQRESULT SQ_GetDataTableColumnByName(HSquirrelV return SQRESULT_NOTNULL; } +// int function GetDataTableRowCount( var datatable ) template SQRESULT SQ_GetDataTableRowCount(HSquirrelVM* sqvm) { CSVData** pData; @@ -307,12 +309,11 @@ template SQRESULT SQ_GetDataTableRowCount(HSquirrelVM* s return g_pSquirrel->m_funcOriginals["GetDatatableRowCount"](sqvm); CSVData* csv = *pData; - const char* pColumnName = g_pSquirrel->getstring(sqvm, 2); - g_pSquirrel->pushinteger(sqvm, csv->dataPointers.size()); return SQRESULT_NOTNULL; } +// string function GetDataTableString( var datatable, int row, int col ) template SQRESULT SQ_GetDataTableString(HSquirrelVM* sqvm) { CSVData** pData; @@ -339,6 +340,7 @@ template SQRESULT SQ_GetDataTableString(HSquirrelVM* sqv return SQRESULT_NOTNULL; } +// asset function GetDataTableAsset( var datatable, int row, int col ) template SQRESULT SQ_GetDataTableAsset(HSquirrelVM* sqvm) { CSVData** pData; @@ -365,6 +367,7 @@ template SQRESULT SQ_GetDataTableAsset(HSquirrelVM* sqvm return SQRESULT_NOTNULL; } +// int function GetDataTableInt( var datatable, int row, int col ) template SQRESULT SQ_GetDataTableInt(HSquirrelVM* sqvm) { CSVData** pData; @@ -391,6 +394,7 @@ template SQRESULT SQ_GetDataTableInt(HSquirrelVM* sqvm) return SQRESULT_NOTNULL; } +// float function GetDataTableFloat( var datatable, int row, int col ) template SQRESULT SQ_GetDataTableFloat(HSquirrelVM* sqvm) { CSVData** pData; @@ -417,6 +421,7 @@ template SQRESULT SQ_GetDataTableFloat(HSquirrelVM* sqvm return SQRESULT_NOTNULL; } +// bool function GetDataTableBool( var datatable, int row, int col ) template SQRESULT SQ_GetDataTableBool(HSquirrelVM* sqvm) { CSVData** pData; @@ -443,6 +448,7 @@ template SQRESULT SQ_GetDataTableBool(HSquirrelVM* sqvm) return SQRESULT_NOTNULL; } +// vector function GetDataTableVector( var datatable, int row, int col ) template SQRESULT SQ_GetDataTableVector(HSquirrelVM* sqvm) { CSVData** pData; @@ -466,6 +472,7 @@ template SQRESULT SQ_GetDataTableVector(HSquirrelVM* sqv return SQRESULT_NOTNULL; } +// int function GetDataTableRowMatchingStringValue( var datatable, int col, string value ) template SQRESULT SQ_GetDataTableRowMatchingStringValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -491,6 +498,7 @@ template SQRESULT SQ_GetDataTableRowMatchingStringValue( return SQRESULT_NOTNULL; } +// int function GetDataTableRowMatchingAssetValue( var datatable, int col, asset value ) template SQRESULT SQ_GetDataTableRowMatchingAssetValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -517,6 +525,7 @@ template SQRESULT SQ_GetDataTableRowMatchingAssetValue(H return SQRESULT_NOTNULL; } +// int function GetDataTableRowMatchingFloatValue( var datatable, int col, float value ) template SQRESULT SQ_GetDataTableRowMatchingFloatValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -542,6 +551,7 @@ template SQRESULT SQ_GetDataTableRowMatchingFloatValue(H return SQRESULT_NOTNULL; } +// int function GetDataTableRowMatchingIntValue( var datatable, int col, int value ) template SQRESULT SQ_GetDataTableRowMatchingIntValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -567,6 +577,7 @@ template SQRESULT SQ_GetDataTableRowMatchingIntValue(HSq return SQRESULT_NOTNULL; } +// int function GetDataTableRowMatchingVectorValue( var datatable, int col, vector value ) template SQRESULT SQ_GetDataTableRowMatchingVectorValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -593,6 +604,7 @@ template SQRESULT SQ_GetDataTableRowMatchingVectorValue( return SQRESULT_NOTNULL; } +// int function GetDataTableRowGreaterThanOrEqualToIntValue( var datatable, int col, int value ) template SQRESULT SQ_GetDataTableRowGreaterThanOrEqualToIntValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -619,6 +631,7 @@ template SQRESULT SQ_GetDataTableRowGreaterThanOrEqualTo return SQRESULT_NOTNULL; } +// int function GetDataTableRowLessThanOrEqualToIntValue( var datatable, int col, int value ) template SQRESULT SQ_GetDataTableRowLessThanOrEqualToIntValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -644,6 +657,7 @@ template SQRESULT SQ_GetDataTableRowLessThanOrEqualToInt return SQRESULT_NOTNULL; } +// int function GetDataTableRowGreaterThanOrEqualToFloatValue( var datatable, int col, float value ) template SQRESULT SQ_GetDataTableRowGreaterThanOrEqualToFloatValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -669,6 +683,7 @@ template SQRESULT SQ_GetDataTableRowGreaterThanOrEqualTo return SQRESULT_NOTNULL; } +// int function GetDataTableRowLessThanOrEqualToFloatValue( var datatable, int col, float value ) template SQRESULT SQ_GetDataTableRowLessThanOrEqualToFloatValue(HSquirrelVM* sqvm) { CSVData** pData; @@ -919,4 +934,4 @@ ON_DLL_LOAD_RELIESON("engine.dll", SharedScriptDataTables, ConVar, (CModule modu RegisterConCommand("dump_datatables", ConCommand_dump_datatables, "dumps all datatables from a hardcoded list", FCVAR_NONE); RegisterConCommand("dump_datatable", ConCommand_dump_datatable, "dump a datatable", FCVAR_NONE); -} \ No newline at end of file +} diff --git a/NorthstarDLL/sigscanning.cpp b/NorthstarDLL/sigscanning.cpp deleted file mode 100644 index 618645e0..00000000 --- a/NorthstarDLL/sigscanning.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "pch.h" -#include "sigscanning.h" -#include - -// note: sigscanning is only really intended to be used for resolving stuff like shared function definitions -// we mostly use raw function addresses for stuff - -size_t GetModuleLength(HMODULE moduleHandle) -{ - // based on sigscan code from ttf2sdk, which is in turn based on CSigScan from https://wiki.alliedmods.net/Signature_Scanning - MEMORY_BASIC_INFORMATION mem; - VirtualQuery(moduleHandle, &mem, sizeof(mem)); - - IMAGE_DOS_HEADER* dos = (IMAGE_DOS_HEADER*)mem.AllocationBase; - IMAGE_NT_HEADERS* pe = (IMAGE_NT_HEADERS*)((unsigned char*)dos + dos->e_lfanew); - - return pe->OptionalHeader.SizeOfImage; -} - -void* FindSignature(std::string dllName, const char* sig, const char* mask) -{ - HMODULE module = GetModuleHandleA(dllName.c_str()); - - unsigned char* dllAddress = (unsigned char*)module; - unsigned char* dllEnd = dllAddress + GetModuleLength(module); - - size_t sigLength = strlen(mask); - - for (auto i = dllAddress; i < dllEnd - sigLength + 1; i++) - { - int j = 0; - for (; j < sigLength; j++) - if (mask[j] != '?' && sig[j] != i[j]) - break; - - if (j == sigLength) // loop finished of its own accord - return i; - } - - return nullptr; -} diff --git a/NorthstarDLL/squirrel.cpp b/NorthstarDLL/squirrel.cpp index 4bd4bca8..cf5cb49e 100644 --- a/NorthstarDLL/squirrel.cpp +++ b/NorthstarDLL/squirrel.cpp @@ -135,7 +135,7 @@ template void SquirrelManager::VMDestroyed() template void SquirrelManager::ExecuteCode(const char* pCode) { - if (!m_pSQVM) + if (!m_pSQVM || !m_pSQVM->sqvm) { spdlog::error("Cannot execute code, {} squirrel vm is not initialised", GetContextName(context)); return; diff --git a/NorthstarDLL/vector.h b/NorthstarDLL/vector.h index a5d68003..122fd211 100644 --- a/NorthstarDLL/vector.h +++ b/NorthstarDLL/vector.h @@ -12,11 +12,19 @@ union Vector3 float raw[3]; Vector3() : x(0), y(0), z(0) {} + Vector3(float x, float y, float z) : x(x), y(y), z(z) {} Vector3(float* pRawFloats) // assumes float[3] => vector { memcpy(raw, pRawFloats, sizeof(this)); } + void MakeValid() + { + for (auto& fl : raw) + if (isnan(fl)) + fl = 0; + } + // todo: more operators maybe bool operator==(const Vector3& other) { @@ -41,4 +49,4 @@ union QAngle { return x == other.x && y == other.y && z == other.z && w == other.w; } -}; \ No newline at end of file +}; diff --git a/loader_launcher_proxy/Memory.cpp b/loader_launcher_proxy/Memory.cpp deleted file mode 100644 index 200246eb..00000000 --- a/loader_launcher_proxy/Memory.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "pch.h" - -extern HMODULE hTier0Module; -IMemAlloc** g_ppMemAllocSingleton; - -void LoadTier0Handle() -{ - if (!hTier0Module) - hTier0Module = GetModuleHandleA("tier0.dll"); - if (!hTier0Module) - return; - - g_ppMemAllocSingleton = (IMemAlloc**)GetProcAddress(hTier0Module, "g_pMemAllocSingleton"); -} - -const int STATIC_ALLOC_SIZE = 4096; - -size_t g_iStaticAllocated = 0; -void* g_pLastAllocated = nullptr; -char pStaticAllocBuf[STATIC_ALLOC_SIZE]; - -// they should never be used here, except in LibraryLoadError? - -void* malloc(size_t n) -{ - // allocate into static buffer - if (g_iStaticAllocated + n <= STATIC_ALLOC_SIZE) - { - void* ret = pStaticAllocBuf + g_iStaticAllocated; - g_iStaticAllocated += n; - return ret; - } - else - { - // try to fallback to g_pMemAllocSingleton - if (!hTier0Module || !g_ppMemAllocSingleton) - LoadTier0Handle(); - if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton) - return (*g_ppMemAllocSingleton)->m_vtable->Alloc(*g_ppMemAllocSingleton, n); - else - throw "Cannot allocate"; - } -} - -void free(void* p) -{ - // if it was allocated into the static buffer, just do nothing, safest way to deal with it - if (p >= pStaticAllocBuf && p <= pStaticAllocBuf + STATIC_ALLOC_SIZE) - return; - - if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton) - (*g_ppMemAllocSingleton)->m_vtable->Free(*g_ppMemAllocSingleton, p); -} - -void* realloc(void* old_ptr, size_t size) -{ - // it was allocated into the static buffer - if (old_ptr >= pStaticAllocBuf && old_ptr <= pStaticAllocBuf + STATIC_ALLOC_SIZE) - { - if (g_pLastAllocated == old_ptr) - { - // nothing was allocated after this - size_t old_size = g_iStaticAllocated - ((size_t)g_pLastAllocated - (size_t)pStaticAllocBuf); - size_t diff = size - old_size; - if (diff > 0) - g_iStaticAllocated += diff; - return old_ptr; - } - else - { - return malloc(size); - } - } - - if (g_ppMemAllocSingleton && *g_ppMemAllocSingleton) - return (*g_ppMemAllocSingleton)->m_vtable->Realloc(*g_ppMemAllocSingleton, old_ptr, size); - return nullptr; -} - -void* operator new(size_t n) { return malloc(n); } - -void operator delete(void* p) { return free(p); } diff --git a/loader_launcher_proxy/Memory.h b/loader_launcher_proxy/Memory.h deleted file mode 100644 index c983966c..00000000 --- a/loader_launcher_proxy/Memory.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -class IMemAlloc -{ -public: - struct VTable - { - void* unknown[1]; // alloc debug - void* (*Alloc) (IMemAlloc* memAlloc, size_t nSize); - void* unknown2[1]; // realloc debug - void* (*Realloc)(IMemAlloc* memAlloc, void* pMem, size_t nSize); - void* unknown3[1]; // free #1 - void (*Free) (IMemAlloc* memAlloc, void* pMem); - void* unknown4[2]; // nullsubs, maybe CrtSetDbgFlag - size_t(*GetSize) (IMemAlloc* memAlloc, void* pMem); - void* unknown5[9]; // they all do literally nothing - void (*DumpStats) (IMemAlloc* memAlloc); - void (*DumpStatsFileBase) (IMemAlloc* memAlloc, const char* pchFileBase); - void* unknown6[4]; - int (*heapchk) (IMemAlloc* memAlloc); - }; - - VTable* m_vtable; -}; -- cgit v1.2.3 From d2907aa522d56a4baacec1c17426f7d6f1fae3a2 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Sat, 3 Sep 2022 02:47:42 +0200 Subject: Fix changed icon (#264) --- NorthstarLauncher/ns_icon.ico | Bin 1441815 -> 1441814 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/NorthstarLauncher/ns_icon.ico b/NorthstarLauncher/ns_icon.ico index 76f4af69..fc9ad166 100644 Binary files a/NorthstarLauncher/ns_icon.ico and b/NorthstarLauncher/ns_icon.ico differ -- cgit v1.2.3