From 183a59dcdf57fa17cb67c21526c4aa22ff6aa0a7 Mon Sep 17 00:00:00 2001 From: Mgamerz Date: Sat, 21 Nov 2020 17:28:33 -0700 Subject: [PATCH] Add GarbageCollectorForcer ASI. Make AceSlammer buildable (disable ragdoll features) --- AceSlammer/AceSlammer.cpp | 54 +++++++-- AceSlammer/AceSlammer.vcxproj | 2 +- ConsoleExtension/ConsoleExtension.cpp | 8 +- Experiments/Experiments.cpp | 78 +++++++----- FemShep-ME3-ASI-Plugins.sln | 8 ++ .../GarbageCollectionForcer.cpp | 58 +++++++++ .../GarbageCollectionForcer.filters | 22 ++++ .../GarbageCollectionForcer.rc | Bin 0 -> 4846 bytes .../GarbageCollectionForcer.vcxproj | 114 ++++++++++++++++++ GarbageCollectorForcer/resource.h | 14 +++ ME3ExplorerInterop/ME3ExpInterop.cpp | 12 +- ME3SDK/ME3TweaksHeader.h | 18 +++ SplashEnabler/SplashEnabler.vcxproj | 6 +- 13 files changed, 341 insertions(+), 53 deletions(-) create mode 100644 GarbageCollectorForcer/GarbageCollectionForcer.cpp create mode 100644 GarbageCollectorForcer/GarbageCollectionForcer.filters create mode 100644 GarbageCollectorForcer/GarbageCollectionForcer.rc create mode 100644 GarbageCollectorForcer/GarbageCollectionForcer.vcxproj create mode 100644 GarbageCollectorForcer/resource.h diff --git a/AceSlammer/AceSlammer.cpp b/AceSlammer/AceSlammer.cpp index f0ed2bc..96fb102 100644 --- a/AceSlammer/AceSlammer.cpp +++ b/AceSlammer/AceSlammer.cpp @@ -10,19 +10,22 @@ #define _CRT_SECURE_NO_WARNINGS #pragma comment(lib, "detours.lib") //Library needed for Hooking part. -ME3TweaksASILogger logger("Ace Slammer v1", "AceSlammer.txt"); +//ME3TweaksASILogger logger("Ace Slammer v1", "AceSlammer.txt"); -bool fetchNextItem = false; +bool changeGravity = false; const int NEXTSTATE_SLAMMING = 1; const int NEXTSTATE_ZEROG = 2; const int NEXTSTATE_UPGRAV = 3; const int NEXTSTATE_NORMAL = 4; int nextState = NEXTSTATE_UPGRAV; +int numTicksBetweenRagdoll = 12; +int currentRagdollTick = 0; + void __fastcall HookedPE(UObject* pObject, void* edx, UFunction* pFunction, void* pParms, void* pResult) { - if (fetchNextItem) { + if (changeGravity) { char* szName = pFunction->GetFullName(); if (strcmp(szName, "Function SFXGame.BioPlayerController.PlayerTick") == 0) { @@ -30,13 +33,13 @@ void __fastcall HookedPE(UObject* pObject, void* edx, UFunction* pFunction, void ABioPlayerController* bpc = reinterpret_cast(pObject); if (!nextStateSet && nextState == NEXTSTATE_SLAMMING) { - bpc->WorldInfo->WorldGravityZ = -3100; + bpc->WorldInfo->WorldGravityZ = -6000; //Slam it like Shaq nextState = NEXTSTATE_NORMAL; nextStateSet = true; } if (!nextStateSet && nextState == NEXTSTATE_NORMAL) { - bpc ->WorldInfo->WorldGravityZ = -981; + bpc->WorldInfo->WorldGravityZ = -981; //Normal nextState = NEXTSTATE_UPGRAV; nextStateSet = true; } @@ -48,15 +51,43 @@ void __fastcall HookedPE(UObject* pObject, void* edx, UFunction* pFunction, void } if (!nextStateSet && nextState == NEXTSTATE_UPGRAV) { - bpc->WorldInfo->WorldGravityZ = 500; + bpc->WorldInfo->WorldGravityZ = 700; //Going up nextState = NEXTSTATE_ZEROG; nextStateSet = true; } - logger.writeToLog(string_format("GRAVITY: %f\n", bpc->WorldInfo->WorldGravityZ), true); + //logger.writeToLog(string_format("GRAVITY: %f\n", bpc->WorldInfo->WorldGravityZ), true); //logger.writeToConsoleOnly(string_format("Default gravity: %f", wi->DefaultGravityZ), true); //logger.writeToLog(string_format("%s", szName), true); - fetchNextItem = false; + changeGravity = false; + //logger.writeToLog(string_format("Ragdoll tick %d/%d\n", currentRagdollTick, numTicksBetweenRagdoll), true); + //if (currentRagdollTick >= numTicksBetweenRagdoll) + //{ + // auto playerObj = FindObjectOfType(ASFXPawn_Player::StaticClass()); + // if (playerObj != NULL) { + // auto player = static_cast(playerObj); + // auto pawns = FindObjectsOfType(ABioPawn::StaticClass()); + // for (int i = 0; i < pawns.Count; i++) { + // auto pawn = static_cast(pawns.Data[i]); + // if (pawn != NULL && pawn->CanRagdoll() && pawn->bCanRagdoll) { + // auto pname = pawn->Name.GetName(); + // auto pid = pawn->Name.GetIndex(); + // if (pid > 0) { + // // I have no idea what i'm doing + // // But I hate C/C++ strings + // /*auto commandS = string_format("testragdoll %s_%d", pname, pid - 1); + // auto commandWS = s2ws(commandS); + // wchar_t* t = (wchar_t*)commandWS.c_str(); + // logger.writeToLog(t, true, true); + // pawn->Controller->ConsoleCommand(t, false);*/ + // //pawn->InitRagdoll(); + // //pawn->rag + // } + // } + // } + // } + // currentRagdollTick = 0; + //} } } ProcessEvent(pObject, pFunction, pParms, pResult); @@ -73,7 +104,7 @@ void timer_start(function func, unsigned int interval) } -unsigned test() +unsigned timerTick() { unsigned nextInterval = 100; //default 100ms if (nextState == NEXTSTATE_SLAMMING) @@ -92,7 +123,8 @@ unsigned test() { nextInterval = 250; } - fetchNextItem = true; + changeGravity = true; + currentRagdollTick++; return nextInterval; } @@ -104,7 +136,7 @@ void onAttach() DetourAttach(&(PVOID&)ProcessEvent, HookedPE); //This command will start your Hook. DetourTransactionCommit(); std::this_thread::sleep_for(std::chrono::milliseconds(10000)); - timer_start(test, 1000); + timer_start(timerTick, 1000); } BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) diff --git a/AceSlammer/AceSlammer.vcxproj b/AceSlammer/AceSlammer.vcxproj index b6c26a9..b39f470 100644 --- a/AceSlammer/AceSlammer.vcxproj +++ b/AceSlammer/AceSlammer.vcxproj @@ -74,7 +74,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;KismetLogger_EXPORTS;%(PreprocessorDefinitions) + _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;KismetLogger_EXPORTS;%(PreprocessorDefinitions) true MultiThreaded stdcpp17 diff --git a/ConsoleExtension/ConsoleExtension.cpp b/ConsoleExtension/ConsoleExtension.cpp index 1b00f54..00f434e 100644 --- a/ConsoleExtension/ConsoleExtension.cpp +++ b/ConsoleExtension/ConsoleExtension.cpp @@ -20,7 +20,7 @@ #pragma comment(lib, "detours.lib") //Library needed for Hooking part. -#define LOGGING 0 +#define LOGGING 1 #if LOGGING ME3TweaksASILogger logger("ConsoleExtension v1", "ConsoleExtension.txt", false); @@ -45,6 +45,8 @@ bool shouldSetCamPOV; FTPOV savedPOVs[10]; +wchar_t presencetext[256]; +wchar_t currentpresencetext[256]; void HandleConsoleCommand(USFXConsole* console, const wstring& cmd) { if (cmd.rfind(L"savecam ") == 0 && cmd.length() == 9) @@ -82,7 +84,7 @@ void HandleConsoleCommand(USFXConsole* console, const wstring& cmd) auto playerpawn = (ASFXPawn_Player*)playerpawns.Data[i]; playerpawn->GroundSpeed = 400.0; playerpawn->CombatGroundSpeed = 350.0; - playerpawn->StormSpeed = 700.0; + playerpawn->StormSpeed = 700.0; playerpawn->AccelRate = 1500.0; } } @@ -107,7 +109,7 @@ void __fastcall HookedPE(UObject* pObject, void* edx, UFunction* pFunction, void screenLogger.LogMessage(msg); #endif -} + } } #if LOGGING else if (!strcmp(funcName, "Function SFXGame.BioHUD.PostRender")) diff --git a/Experiments/Experiments.cpp b/Experiments/Experiments.cpp index 42d7e1f..c089c83 100644 --- a/Experiments/Experiments.cpp +++ b/Experiments/Experiments.cpp @@ -16,8 +16,11 @@ #pragma comment(lib, "detours.lib") //Library needed for Hooking part. //ME3TweaksASILogger logger("Match Stats Collector", "MatchStats.txt"); -ME3TweaksASILogger logger("MP Controller Client Fix", "WorldInfo.txt"); +//ME3TweaksASILogger logger("MP Controller Client Fix", "WorldInfo.txt"); +ME3TweaksASILogger logger("Experiments", "Experiments.txt"); bool logNextTick = false; +int interval = 60 * 10; //7 seconds (or 60fps ticks) +int currentTick = 0; FVector inline RotationToVector(FRotator Rotation) { FVector Vector; @@ -35,7 +38,19 @@ FVector inline RotationToVector(FRotator Rotation) { void __fastcall HookedPE(UObject* pObject, void* edx, UFunction* pFunction, void* pParms, void* pResult) { char* szName = pFunction->GetFullName(); - //if (isPartOf(szName, "Function Engine.DebugCameraHUD.PostRender")) + if (strcmp(szName, "Function SFXGame.SFXSFHandler_PCPersonalization.Update") == 0) + { + if (currentTick >= interval) + { + currentTick -= interval; + logger.writeToConsoleOnly(L"Garbage collecting.\n", true); + auto sfxHandler = static_cast(pObject); + sfxHandler->oWorldInfo->ForceGarbageCollection(false); + } else + { + currentTick++; + } + } //{ // ProcessEvent(pObject, pFunction, pParms, pResult); // ADebugCameraHUD* debugCameraHud = (ADebugCameraHUD*)pObject; @@ -114,24 +129,24 @@ void __fastcall HookedPE(UObject* pObject, void* edx, UFunction* pFunction, void // }*/ //} //else - if (isPartOf(szName, "Function SFXGame.SFXConsole.InputKey")) { - USFXConsole_execInputKey_Parms* params = (USFXConsole_execInputKey_Parms*)pParms; - //Event: 0 - > Down - //Event: 1 - > Up - //Event: 2 - > Holding - //logger.writeToConsoleOnly(string_format("Key pressed: %u %s\n", params->Event, params->Key.GetName()), true); - if (isPartOf(params->Key.GetName(), "Xbox")) { - if (params->Event == 0) { - logger.writeToConsoleOnly(string_format("%s DOWN\n", params->Key.GetName()), true); - } - else if (params->Event == 1) { - logger.writeToConsoleOnly(string_format("%s UP\n", params->Key.GetName()), true); - } - else if (params->Event == 2) { - logger.writeToConsoleOnly(string_format("%s HOLD\n", params->Key.GetName()), true); - } - } - } + //if (isPartOf(szName, "Function SFXGame.SFXConsole.InputKey")) { + // USFXConsole_execInputKey_Parms* params = (USFXConsole_execInputKey_Parms*)pParms; + // //Event: 0 - > Down + // //Event: 1 - > Up + // //Event: 2 - > Holding + // //logger.writeToConsoleOnly(string_format("Key pressed: %u %s\n", params->Event, params->Key.GetName()), true); + // if (isPartOf(params->Key.GetName(), "Xbox")) { + // if (params->Event == 0) { + // logger.writeToConsoleOnly(string_format("%s DOWN\n", params->Key.GetName()), true); + // } + // else if (params->Event == 1) { + // logger.writeToConsoleOnly(string_format("%s UP\n", params->Key.GetName()), true); + // } + // else if (params->Event == 2) { + // logger.writeToConsoleOnly(string_format("%s HOLD\n", params->Key.GetName()), true); + // } + // } + //} ProcessEvent(pObject, pFunction, pParms, pResult); } @@ -172,17 +187,18 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) { case DLL_PROCESS_ATTACH: // Check if DLC_MOD_ControllerSupport exists at ..\..\BioGame\DLC - if (dirExists("..\\..\\BIOGame\\DLC\\DLC_MOD_ControllerSupport") != 0) - { - DisableThreadLibraryCalls(hModule); - CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL); - } - /*else - { - MessageBoxW(NULL, L"Controller mod not installed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); - }*/ - //doesn't exist otherwise - return true; + //MessageBox(NULL, L"Take snapshot now.", L"Stall ASI", MB_ICONINFORMATION); + //if (dirExists("..\\..\\BIOGame\\DLC\\DLC_MOD_ControllerSupport") != 0) + //{ + DisableThreadLibraryCalls(hModule); + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL); + //} + ///*else + //{ + // MessageBoxW(NULL, L"Controller mod not installed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); + //}*/ + ////doesn't exist otherwise + //return true; break; case DLL_PROCESS_DETACH: diff --git a/FemShep-ME3-ASI-Plugins.sln b/FemShep-ME3-ASI-Plugins.sln index f35af47..61e3a6f 100644 --- a/FemShep-ME3-ASI-Plugins.sln +++ b/FemShep-ME3-ASI-Plugins.sln @@ -34,6 +34,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SplashEnabler", "SplashEnab EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SplashEnablerHost", "SplashEnablerHost\SplashEnablerHost.vcxproj", "{5C263389-C3FD-4A20-91CB-DE4AC00FBF57}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GarbageCollectionForcer", "GarbageCollectorForcer\GarbageCollectionForcer.vcxproj", "{5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -118,6 +120,12 @@ Global {5C263389-C3FD-4A20-91CB-DE4AC00FBF57}.Release|x64.Build.0 = Release|x64 {5C263389-C3FD-4A20-91CB-DE4AC00FBF57}.Release|x86.ActiveCfg = Release|Win32 {5C263389-C3FD-4A20-91CB-DE4AC00FBF57}.Release|x86.Build.0 = Release|Win32 + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}.Debug|x64.ActiveCfg = Debug|Win32 + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}.Debug|x86.ActiveCfg = Debug|Win32 + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}.Debug|x86.Build.0 = Debug|Win32 + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}.Release|x64.ActiveCfg = Release|Win32 + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}.Release|x86.ActiveCfg = Release|Win32 + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/GarbageCollectorForcer/GarbageCollectionForcer.cpp b/GarbageCollectorForcer/GarbageCollectionForcer.cpp new file mode 100644 index 0000000..17ee879 --- /dev/null +++ b/GarbageCollectorForcer/GarbageCollectionForcer.cpp @@ -0,0 +1,58 @@ +#include +#include +#include "../ME3SDK/SdkHeaders.h" +#include "../detours/detours.h" + +#define _CRT_SECURE_NO_WARNINGS +#pragma comment(lib, "detours.lib") //Library needed for Hooking part. + +typedef void(__thiscall* tProcessEvent)(class UObject*, class UFunction*, void*, void*); +tProcessEvent ProcessEvent = (tProcessEvent)0x00453120; + +auto _personalization_lastForcedGC = std::chrono::steady_clock::now(); // Init at app boot +auto _personalizationGCInterval = 8; + +void __fastcall HookedPE(UObject *pObject, void *edx, UFunction *pFunction, void *pParms, void *pResult) +{ + char* szName = pFunction->GetFullName(); + + // Force Garbage Collection when the personalization UI is open (armor locker) every 8 seconds. + if (strcmp(szName, "Function SFXGame.SFXSFHandler_PCPersonalization.Update") == 0) + { + auto now = std::chrono::steady_clock::now(); + auto time_elapsed = std::chrono::duration_cast(now - _personalization_lastForcedGC).count(); + if (time_elapsed > _personalizationGCInterval) + { + USFXSFHandler_PCPersonalization* sfxHandler = static_cast(pObject); + sfxHandler->oWorldInfo->ForceGarbageCollection(false); + _personalization_lastForcedGC = now; + } + } + ProcessEvent(pObject, pFunction, pParms, pResult); +} + +void onAttach() +{ + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); //This command set the current working thread to the game current thread. + DetourAttach(&(PVOID&)ProcessEvent, HookedPE); //This command will start your Hook. + DetourTransactionCommit(); +} + +BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hModule); + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL); + return true; + break; + + case DLL_PROCESS_DETACH: + return true; + break; + } + return true; +}; + diff --git a/GarbageCollectorForcer/GarbageCollectionForcer.filters b/GarbageCollectorForcer/GarbageCollectionForcer.filters new file mode 100644 index 0000000..87d32eb --- /dev/null +++ b/GarbageCollectorForcer/GarbageCollectionForcer.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/GarbageCollectorForcer/GarbageCollectionForcer.rc b/GarbageCollectorForcer/GarbageCollectionForcer.rc new file mode 100644 index 0000000000000000000000000000000000000000..88e7585b6868148776e4ddd78d3de4d5b1bec3aa GIT binary patch literal 4846 zcmdUzTW=CU6vxlAiQi$RFE%zUy}bC?3q>M@rd*;)6G98EjTIV}dP)53>hC|plwEeI zLN&o`hS@oD&Y5$cv;6$AWm^{6iQU+xjcjN!?>th*@;^yj}7hu@bi%y8~y_p4&4{*>dw5&;h%*VD}tuAw$1uAFSZ8MY-nit{k0s z@7t+0tZ6MfvWnHMV`o+Zdc=Fps`eg8gWnT708-^WoG%$x?+Ma{IkGZ#nYHm1RvOwT z^dDm#*`bNn@A$2t^&xu79wp#Aj9HKT-UnZteLY>;{;OxPAd!!bdu*jhxeVk1~S z@LjDrNEhMV0r_`}r($9tvX}ULz$)ZngEya*v90GsL7d2`8)vT)KDxXsg z@~1_19ddGq=&JIF?{}VPE@cxQXT)#^sv7j`?$j#K8qgMV*~Mvqc)T*aE9B}M+kkfi zyaOPfW)`EvuFq;80n%lD1Smh+X!4d*kN&$_ke}rtCNyhoW3znB$n77Xd)ZYAVMmiE zzw(}2aZ-KdKW{Nnsje(@Mqb4)Shn62?3}uFPDK0KKb3NxM7v8$wCFi&t{(TuG}RdY zs7B<~n{2cNAFWnZNlGILwGOlHe%`GFI{yQbjNKsuy4d&msKCQ?v4UJFX8DXHKxzbN4%7O zaz5{%{}I&5KGx?#I73lY;j}x~$zD6#Mb2I$pt75KVQ*1&&0W?P{HlMB*cn16D_>%H z&pAQ|QEA`z;OYXS31{_uUHgo-!s}0PwGwCT#Sge%|7CPe=Y7z1n;yRSFc#sf7*cmK zV%B%Wtf$IO`d}A%b=E4!&L;Y*7$HH=?Jpuh6-rtE*2T;n_EVf+(?5+L;zj4Cchp-Q zx?X1o%{BCm^pvQoPtH|DNSY93S|wxm-&^DqNrqVR-o@UmN3vS#dn6sbd45u@@-Z(@ zg$xK*Tf}2&`Ie8!Y4;NHJPS$JtG3fKcxIXUm#$JxETIY&<8Srl$qJ&|$X7?ztZf%# z#mUX!<(*19ebdb`zZ>~G-v`OgV71<*eRB9a{IRdUY&W)A8YQKXW?F~&ss970JAV9s cfMCm{6sz?v3FpWAfQqAks + + + + Debug + Win32 + + + Release + Win32 + + + + {5B71CD3D-EC3C-46BD-8993-9D25105D1D6F} + Win32Proj + GarbageCollectionForcer + 10.0 + GarbageCollectionForcer + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + true + .asi + + + false + false + .asi + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;GarbageCollectionForcer_EXPORTS;%(PreprocessorDefinitions) + false + /bigobj %(AdditionalOptions) + stdcpp17 + + + Windows + true + $(ProjectDir)..\detours;%(AdditionalLibraryDirectories) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;GarbageCollectionForcer_EXPORTS;%(PreprocessorDefinitions) + true + MultiThreaded + stdcpp17 + + + Windows + true + true + true + false + $(ProjectDir)..\detours;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GarbageCollectorForcer/resource.h b/GarbageCollectorForcer/resource.h new file mode 100644 index 0000000..8ad9c80 --- /dev/null +++ b/GarbageCollectorForcer/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by KismetLogger.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/ME3ExplorerInterop/ME3ExpInterop.cpp b/ME3ExplorerInterop/ME3ExpInterop.cpp index 430395d..ad80f7c 100644 --- a/ME3ExplorerInterop/ME3ExpInterop.cpp +++ b/ME3ExplorerInterop/ME3ExpInterop.cpp @@ -18,7 +18,7 @@ #pragma comment(lib, "detours.lib") //Library needed for Hooking part. #pragma comment(lib, "shlwapi.lib") -TCHAR actorDumpFilePath[MAX_PATH]; +TCHAR SplashPath[MAX_PATH]; char* GetUObjectClassName(UObject* object) { @@ -142,7 +142,7 @@ void DumpActors(USequenceOp* const op) Actors.Count = 0; //clear the array without de-allocating any memory. ofstream ofs; - ofs.open(actorDumpFilePath); + ofs.open(SplashPath); const auto actorClass = AActor::StaticClass(); for (auto j = 0; j < objCount; j++) { @@ -316,10 +316,10 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) switch (dwReason) { case DLL_PROCESS_ATTACH: - GetModuleFileName(hModule, actorDumpFilePath, MAX_PATH); - PathRemoveFileSpec(actorDumpFilePath); - PathRemoveFileSpec(actorDumpFilePath); - StringCchCat(actorDumpFilePath, MAX_PATH, L"\\ME3ExpActorDump.txt"); + GetModuleFileName(hModule, SplashPath, MAX_PATH); + PathRemoveFileSpec(SplashPath); + PathRemoveFileSpec(SplashPath); + StringCchCat(SplashPath, MAX_PATH, L"\\ME3ExpActorDump.txt"); DisableThreadLibraryCalls(hModule); CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)onAttach, NULL, 0, NULL); diff --git a/ME3SDK/ME3TweaksHeader.h b/ME3SDK/ME3TweaksHeader.h index e23d06f..cfee946 100644 --- a/ME3SDK/ME3TweaksHeader.h +++ b/ME3SDK/ME3TweaksHeader.h @@ -129,6 +129,24 @@ inline std::string ws2s(const std::wstring& wstr) return converterX.to_bytes(wstr); } +/// +/// Converts a string to a wide string +/// +/// +/// +std::wstring s2ws(const std::string& multi) { + std::wstring wide; wchar_t w; mbstate_t mb{}; + size_t n = 0, len = multi.length() + 1; + while (auto res = mbrtowc(&w, multi.c_str() + n, len - n, &mb)) { + if (res == size_t(-1) || res == size_t(-2)) + throw "invalid encoding"; + + n += res; + wide += w; + } + return wide; +} + class ME3TweaksASILogger { public: diff --git a/SplashEnabler/SplashEnabler.vcxproj b/SplashEnabler/SplashEnabler.vcxproj index 5a75717..19bcb77 100644 --- a/SplashEnabler/SplashEnabler.vcxproj +++ b/SplashEnabler/SplashEnabler.vcxproj @@ -51,6 +51,7 @@ false + .asi @@ -73,8 +74,10 @@ true true true - WIN32;NDEBUG;SPLASHENABLER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;WIN32;NDEBUG;SPLASHENABLER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdcpp17 + MultiThreaded Windows @@ -82,6 +85,7 @@ true true false + shlwapi.lib;%(AdditionalDependencies)