From 699c220b8c3947435edff77ebcfa41bab241fec1 Mon Sep 17 00:00:00 2001 From: Zarklord Date: Tue, 18 Feb 2020 15:27:09 -0500 Subject: [PATCH] current update wip. --- .gitignore | 8 +- UniversalPropertyReplacement.sln | 34 +- UniversalPropertyReplacement/ReadMe.txt | 23 +- .../SdkPathConfig.props | 18 + UniversalPropertyReplacement/TestingCheat.cpp | 120 ---- .../UniversalPropertyReplacement.cpp | 625 ++++++++++-------- .../UniversalPropertyReplacement.h | 138 ++-- .../UniversalPropertyReplacement.vcxproj | 293 +------- ...iversalPropertyReplacement.vcxproj.filters | 53 +- .../VerificationCheat.cpp | 347 ++++++++++ .../{TestingCheat.h => VerificationCheat.h} | 7 +- UniversalPropertyReplacement/dllmain.cpp | 47 +- UniversalPropertyReplacement/stdafx.h | 2 +- 13 files changed, 872 insertions(+), 843 deletions(-) create mode 100644 UniversalPropertyReplacement/SdkPathConfig.props delete mode 100644 UniversalPropertyReplacement/TestingCheat.cpp create mode 100644 UniversalPropertyReplacement/VerificationCheat.cpp rename UniversalPropertyReplacement/{TestingCheat.h => VerificationCheat.h} (90%) diff --git a/.gitignore b/.gitignore index 8096af9..f686db7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,12 +23,8 @@ bld/ [Oo]bj/ # Intermidate Building Things -UniversalPropertyReplacement/[Dd]ebug - Disk/ -UniversalPropertyReplacement/[Dd]ebug - Steam Patched/ -UniversalPropertyReplacement/[Dd]ebug - Steam/ -UniversalPropertyReplacement/[Rr]elease - Disk/ -UniversalPropertyReplacement/[Rr]elease - Steam Patched/ -UniversalPropertyReplacement/[Rr]elease - Steam/ +UniversalPropertyReplacement/[Dd]ebug/ +UniversalPropertyReplacement/[Rr]elease/ # Visual Studio 2015 cache/options directory .vs/ diff --git a/UniversalPropertyReplacement.sln b/UniversalPropertyReplacement.sln index 34d46de..1e11679 100644 --- a/UniversalPropertyReplacement.sln +++ b/UniversalPropertyReplacement.sln @@ -1,40 +1,34 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29728.190 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UniversalPropertyReplacement", "UniversalPropertyReplacement\UniversalPropertyReplacement.vcxproj", "{07FC5B61-B575-4207-B464-AFAE6AF3FC19}" + ProjectSection(ProjectDependencies) = postProject + {F057451A-1413-4D68-AF56-1BF529933420} = {F057451A-1413-4D68-AF56-1BF529933420} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Spore ModAPI", "..\..\Spore ModAPI\Spore ModAPI.vcxproj", "{F057451A-1413-4D68-AF56-1BF529933420}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug - Disk|x86 = Debug - Disk|x86 - Debug - Steam Patched|x86 = Debug - Steam Patched|x86 - Debug - Steam|x86 = Debug - Steam|x86 Debug|x86 = Debug|x86 - Release - Disk|x86 = Release - Disk|x86 - Release - Steam Patched|x86 = Release - Steam Patched|x86 - Release - Steam|x86 = Release - Steam|x86 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug - Disk|x86.ActiveCfg = Debug - Disk|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug - Disk|x86.Build.0 = Debug - Disk|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug - Steam Patched|x86.ActiveCfg = Debug - Steam Patched|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug - Steam Patched|x86.Build.0 = Debug - Steam Patched|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug - Steam|x86.ActiveCfg = Debug - Steam|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug - Steam|x86.Build.0 = Debug - Steam|Win32 {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug|x86.ActiveCfg = Debug|Win32 {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Debug|x86.Build.0 = Debug|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release - Disk|x86.ActiveCfg = Release - Disk|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release - Disk|x86.Build.0 = Release - Disk|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release - Steam Patched|x86.ActiveCfg = Release - Steam Patched|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release - Steam Patched|x86.Build.0 = Release - Steam Patched|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release - Steam|x86.ActiveCfg = Release - Steam|Win32 - {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release - Steam|x86.Build.0 = Release - Steam|Win32 {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release|x86.ActiveCfg = Release|Win32 {07FC5B61-B575-4207-B464-AFAE6AF3FC19}.Release|x86.Build.0 = Release|Win32 + {F057451A-1413-4D68-AF56-1BF529933420}.Debug|x86.ActiveCfg = Debug|Win32 + {F057451A-1413-4D68-AF56-1BF529933420}.Debug|x86.Build.0 = Debug|Win32 + {F057451A-1413-4D68-AF56-1BF529933420}.Release|x86.ActiveCfg = Release|Win32 + {F057451A-1413-4D68-AF56-1BF529933420}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D7E7D6E5-C4EB-4E80-9522-972DAA109DD9} + EndGlobalSection EndGlobal diff --git a/UniversalPropertyReplacement/ReadMe.txt b/UniversalPropertyReplacement/ReadMe.txt index f154caf..4833c95 100644 --- a/UniversalPropertyReplacement/ReadMe.txt +++ b/UniversalPropertyReplacement/ReadMe.txt @@ -1,43 +1,32 @@ ======================================================================== - DYNAMIC LINK LIBRARY : Universal_Property_Replacement Project Overview + DYNAMIC LINK LIBRARY : UniversalPropertyReplacement Project Overview ======================================================================== -AppWizard has created this Universal_Property_Replacement DLL for you. +AppWizard has created this UniversalPropertyReplacement DLL for you. This file contains a summary of what you will find in each of the files that -make up your Universal_Property_Replacement application. +make up your UniversalPropertyReplacement application. -Universal_Property_Replacement.vcxproj +UniversalPropertyReplacement.vcxproj This is the main project file for VC++ projects generated using an Application Wizard. It contains information about the version of Visual C++ that generated the file, and information about the platforms, configurations, and project features selected with the Application Wizard. -Universal_Property_Replacement.vcxproj.filters +UniversalPropertyReplacement.vcxproj.filters This is the filters file for VC++ projects generated using an Application Wizard. It contains information about the association between the files in your project and the filters. This association is used in the IDE to show grouping of files with similar extensions under a specific node (for e.g. ".cpp" files are associated with the "Source Files" filter). -Universal_Property_Replacement.cpp - This is the main DLL source file. - - When created, this DLL does not export any symbols. As a result, it - will not produce a .lib file when it is built. If you wish this project - to be a project dependency of some other project, you will either need to - add code to export some symbols from the DLL so that an export library - will be produced, or you can set the Ignore Input Library property to Yes - on the General propert page of the Linker folder in the project's Property - Pages dialog box. - ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file - named Universal_Property_Replacement.pch and a precompiled types file named StdAfx.obj. + named UniversalPropertyReplacement.pch and a precompiled types file named StdAfx.obj. ///////////////////////////////////////////////////////////////////////////// Other notes: diff --git a/UniversalPropertyReplacement/SdkPathConfig.props b/UniversalPropertyReplacement/SdkPathConfig.props new file mode 100644 index 0000000..a115af5 --- /dev/null +++ b/UniversalPropertyReplacement/SdkPathConfig.props @@ -0,0 +1,18 @@ + + + + + F:\Spore\Spore-ModAPI\ + F:\Spore\Spore ModAPI Launcher Kit\ + + + + + + $(SporeSdkPath) + + + $(SporeLauncherPath) + + + \ No newline at end of file diff --git a/UniversalPropertyReplacement/TestingCheat.cpp b/UniversalPropertyReplacement/TestingCheat.cpp deleted file mode 100644 index 362491a..0000000 --- a/UniversalPropertyReplacement/TestingCheat.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2018 Zarklord -* -* This file is part of UniversalPropertyReplacement. -* -* UniversalPropertyReplacement is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with UniversalPropertyReplacement. If not, see . -****************************************************************************/ - -#include "stdafx.h" -#include "TestingCheat.h" -#include -#include -#include -#include -#include - -void TestingCheat::ParseLine(const ArgScript::Line & line) { - App::PropertyList::Pointer pProp = nullptr; - App::IPropManager::Get()->GetPropertyList(Hash::FNV("testing"), Hash::FNV("testing"), pProp); - bool testFailed = false; - bool boolTest; - App::Property::GetBool(pProp.get(), Hash::FNV("boolValue"), boolTest); - if (boolTest == false) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "boolReplacement failed!"); - testFailed = true; - } - float floatTest; - App::Property::GetFloat(pProp.get(), Hash::FNV("floatValue"), floatTest); - if (floatTest == 2.0) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "floatReplacement failed!"); - testFailed = true; - } - int32_t int32Test; - App::Property::GetInt32(pProp.get(), Hash::FNV("intValue"), int32Test); - if (int32Test == -10) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "int32Replacement failed!"); - testFailed = true; - } - uint32_t uint32Test; - App::Property::GetUInt32(pProp.get(), Hash::FNV("uintValue"), uint32Test); - if (uint32Test == 65535) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "uint32Replacement failed!"); - testFailed = true; - } - Vector2 vector2Test; - App::Property::GetVector2(pProp.get(), Hash::FNV("vector2Value"), vector2Test); - if (vector2Test.x == 13 && vector2Test.y == 37) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "vector2Replacement failed!"); - testFailed = true; - } - Vector3 vector3Test; - App::Property::GetVector3(pProp.get(), Hash::FNV("vector3Value"), vector3Test); - if (vector3Test.x == 1 && vector3Test.y == 33 && vector3Test.z == 7) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "vector3Replacement failed!"); - testFailed = true; - } - Vector4 vector4Test; - App::Property::GetVector4(pProp.get(), Hash::FNV("vector4Value"), vector4Test); - if (vector4Test.x == 1 && vector4Test.y == 3 && vector4Test.z == 3 && vector4Test.w == 7) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "vector4Replacement failed!"); - testFailed = true; - } - ColorRGB colorRGBTest; - App::Property::GetColorRGB(pProp.get(), Hash::FNV("colorRGBValue"), colorRGBTest); - if (colorRGBTest.r == 0.0 && colorRGBTest.g == 1.0 && colorRGBTest.b == 0.0) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "colorRGBReplacement failed!"); - testFailed = true; - } - ColorRGBA colorRGBATest; - App::Property::GetColorRGBA(pProp.get(), Hash::FNV("colorRGBAValue"), colorRGBATest); - if (colorRGBATest.r == 0 && colorRGBATest.g == 1 && colorRGBATest.b == 0 && colorRGBATest.a == 0.5) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "colorRGBAReplacement failed!"); - testFailed = true; - } - ResourceKey keyTest; - App::Property::GetKey(pProp.get(), Hash::FNV("keyoverrideValue"), keyTest); - if (keyTest.mnGroupID == Hash::FNV("prop_overrides") && keyTest.mnInstanceID == Hash::FNV("testingOverrides") && keyTest.mnTypeID == Hash::FNV("prop")) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "keyReplacement failed!"); - testFailed = true; - } - eastl::string stringTest; - App::Property::GetString8(pProp.get(), Hash::FNV("string8Value"), stringTest); - if (stringTest == "string8") { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "string8Replacement failed!"); - testFailed = true; - } - char * cstringTest; - App::Property::GetCString8(pProp.get(), Hash::FNV("cstring8Value"), cstringTest); - if (strcmp(cstringTest, "cstring8") == 0) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "cstring8Replacement failed!"); - testFailed = true; - } - eastl::string16 string16Test; - App::Property::GetString16(pProp.get(), Hash::FNV("string16Value"), string16Test); - if (string16Test.compare(eastl::string16{"string16"}) == 0) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "string16Replacement failed!"); - testFailed = true; - } - wchar_t * wcstringTest; - App::Property::GetCString16(pProp.get(), Hash::FNV("cstring16Value"), wcstringTest); - if (wcscmp(wcstringTest, L"cstring16") == 0) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "cstring16Replacement failed!"); - testFailed = true; - } - - if (!testFailed) { - ArgScript::PrintF(App::ICheatManager::GetConsoleStream(), "no replacement tests failed!"); - } -} diff --git a/UniversalPropertyReplacement/UniversalPropertyReplacement.cpp b/UniversalPropertyReplacement/UniversalPropertyReplacement.cpp index a1a61b5..e287c51 100644 --- a/UniversalPropertyReplacement/UniversalPropertyReplacement.cpp +++ b/UniversalPropertyReplacement/UniversalPropertyReplacement.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -* Copyright (C) 2018 Zarklord +* Copyright (C) 2018, 2020 Zarklord * * This file is part of UniversalPropertyReplacement. * @@ -17,302 +17,371 @@ * along with UniversalPropertyReplacement. If not, see . ****************************************************************************/ -// UniversalPropertyReplacement.cpp : Defines the exported functions for the DLL application. -// - #include "stdafx.h" #include "UniversalPropertyReplacement.h" -//#include "TestingCheat.h" -#include -#include -#include -#include -#include -#include -#include - - -long UniversalPropReplacement::AttachDetours() { - SetDetourAddress(GetBool, GetMethodAddress(App::Property, GetBool)); - SetDetourAddress(GetFloat, GetMethodAddress(App::Property, GetFloat)); - SetDetourAddress(GetInt32, GetMethodAddress(App::Property, GetInt32)); - SetDetourAddress(GetUInt32, GetMethodAddress(App::Property, GetUInt32)); - SetDetourAddress(GetVector2, GetMethodAddress(App::Property, GetVector2)); - SetDetourAddress(GetVector3, GetMethodAddress(App::Property, GetVector3)); - SetDetourAddress(GetVector4, GetMethodAddress(App::Property, GetVector4)); - SetDetourAddress(GetColorRGB, GetMethodAddress(App::Property, GetColorRGB)); - SetDetourAddress(GetColorRGBA, GetMethodAddress(App::Property, GetColorRGBA)); - SetDetourAddress(GetKey, GetMethodAddress(App::Property, GetKey)); - SetDetourAddress(GetString8, GetMethodAddress(App::Property, GetString8)); - SetDetourAddress(GetCString8, GetMethodAddress(App::Property, GetCString8)); - SetDetourAddress(GetString16, GetMethodAddress(App::Property, GetString16)); - SetDetourAddress(GetCString16, GetMethodAddress(App::Property, GetCString16)); - long result = 0; - - result |= AttachDetourFunction(GetBool, DetouredGetBool); - result |= AttachDetourFunction(GetFloat, DetouredGetFloat); - result |= AttachDetourFunction(GetInt32, DetouredGetInt32); - result |= AttachDetourFunction(GetUInt32, DetouredGetUInt32); - result |= AttachDetourFunction(GetVector2, DetouredGetVector2); - result |= AttachDetourFunction(GetVector3, DetouredGetVector3); - result |= AttachDetourFunction(GetVector4, DetouredGetVector4); - result |= AttachDetourFunction(GetColorRGB, DetouredGetColorRGB); - result |= AttachDetourFunction(GetColorRGBA, DetouredGetColorRGBA); - result |= AttachDetourFunction(GetKey, DetouredGetKey); - result |= AttachDetourFunction(GetString8, DetouredGetString8); - result |= AttachDetourFunction(GetCString8, DetouredGetCString8); - result |= AttachDetourFunction(GetString16, DetouredGetString16); - result |= AttachDetourFunction(GetCString16, DetouredGetCString16); - // You can compare result to NO_ERROR to see if there was any error. Or you can just ignore it. - return result; -} - -bool UniversalPropReplacement::Inititalize() { - //App::ICheatManager::Get()->AddCheat("runTests", new TestingCheat()); - uint32_t groupID = Hash::FNV("prop_overrides"); - eastl::vector instanceList{}; - App::IPropManager::Get()->GetAllListIDs(groupID, instanceList); - - for (eastl_size_t i = 0; i < instanceList.size(); i++) { - App::PropertyList::Pointer pProp = nullptr; // this is just an intrusive_ptr - App::IPropManager::Get()->GetPropertyList(instanceList[i], groupID, pProp); - - size_t stringCount = 0; - eastl::string8 * stringList = nullptr; - App::Property::GetArrayString8(pProp.get(), Hash::FNV("replacementList"), stringCount, stringList); - for (size_t j = 0; j < stringCount; j++) { - bool result = false; - bool override = false; - eastl::string typeString{}; - uint32_t replaceHash = 0; - eastl::string valueString{}; - - //as much as GetArrayString8 says it gives a string8 array it doesn't, this took alot of debugging to get this right, the strings are seperated every 0x8 bytes as pointers to the strings. - ArgScript::Line PropLine = ArgScript::Line(*(char**) (static_cast(static_cast(stringList)) + (0x8 * j))); - if (PropLine.GetArgumentsCount() < 3 && PropLine.GetArgumentsCount() > 4) continue; - typeString = PropLine.GetArgumentAt(0); - replaceHash = std::strtoul(PropLine.GetArgumentAt(1), nullptr, 16); - valueString = PropLine.GetArgumentAt(2); - override = PropLine.HasFlag("override"); - - typeString.make_lower(); - - if (typeString == "bool") { - bool value; - result = App::Property::GetBool(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - boolValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - boolValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - } else if (typeString == "float") { - float value; - result = App::Property::GetFloat(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - floatValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - floatValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - } else if (typeString == "int32") { - int32_t value; - result = App::Property::GetInt32(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - int32ValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - int32ValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "uint32") { - uint32_t value; - result = App::Property::GetUInt32(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - uint32ValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - uint32ValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "vector2") { - Vector2 value; - result = App::Property::GetVector2(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - vector2ValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - vector2ValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "vector3") { - Vector3 value; - result = App::Property::GetVector3(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - vector3ValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - vector3ValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } +#include "VerificationCheat.h" +#include +namespace UniversalPropertyReplacement { + long AttachDetours() { + long result = 0; + result |= GetPropertyAlt__detour::attach(GetAddress(App::PropertyList, GetPropertyAlt)); + result |= GetProperty__detour::attach(GetAddress(App::PropertyList, GetProperty)); + result |= GetPropertyObject__detour::attach(GetAddress(App::PropertyList, GetPropertyObject)); - } else if (typeString == "vector4") { - Vector4 value; - result = App::Property::GetVector4(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - vector4ValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - vector4ValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "colorrgb") { - ColorRGB value; - result = App::Property::GetColorRGB(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - colorRGBValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - colorRGBValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "colorrgba") { - ColorRGBA value; - result = App::Property::GetColorRGBA(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - colorRGBAValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - colorRGBAValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "key") { - ResourceKey value; - result = App::Property::GetKey(pProp.get(), Hash::FNV(valueString.c_str()), value); - if (!result) continue; - if (override) { - resourceKeyValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - } else { - resourceKeyValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - } - - - } else if (typeString == "string8") { - eastl::string value; - char * cvalue; - result = App::Property::GetString8(pProp.get(), Hash::FNV(valueString.c_str()), value); - result |= App::Property::GetCString8(pProp.get(), Hash::FNV(valueString.c_str()), cvalue); - if (!result) continue; - if (override) { - stringValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - cstringValueMapOverride.emplace_back(eastl::pair{replaceHash, cvalue}); - } else { - stringValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - cstringValueMapDefault.emplace_back(eastl::pair{replaceHash, cvalue}); - } - - - } else if (typeString == "string16") { - eastl::string16 value; - wchar_t * cvalue; - result = App::Property::GetString16(pProp.get(), Hash::FNV(valueString.c_str()), value); - result |= App::Property::GetCString16(pProp.get(), Hash::FNV(valueString.c_str()), cvalue); - if (!result) continue; - if (override) { - wstringValueMapOverride.emplace_back(eastl::pair{replaceHash, value}); - wcstringValueMapOverride.emplace_back(eastl::pair{replaceHash, cvalue}); - } else { - wstringValueMapDefault.emplace_back(eastl::pair{replaceHash, value}); - wcstringValueMapDefault.emplace_back(eastl::pair{replaceHash, cvalue}); - } - - } - } + return result; } - return true; -} - -template -bool DetouredGetProp(method_t &method, eastl::vector> &override, eastl::vector> &default, const App::PropertyList * pPropertyList, uint32_t propertyID, T &dst) { - for (size_t i = 0; i < override.size(); i++) { - if (propertyID == override[i].first) { - dst = override[i].second; - return true; - } - } - bool result = method(pPropertyList, propertyID, dst); - if (result == false) { - for (size_t i = 0; i < default.size(); i++) { - if (propertyID == default[i].first) { - dst = default[i].second; - return true; + bool Inititalize() { + App::ICheatManager::Get()->AddCheat("VerifyUPR", new VerificationCheat()); + uint32_t groupID = id("prop_overrides"); + eastl::vector instanceList{}; + App::IPropManager::Get()->GetAllListIDs(groupID, instanceList); + + for (eastl_size_t i = 0; i < instanceList.size(); i++) { + PropertyListPtr propList; + PropManager.GetPropertyList(instanceList[i], groupID, propList); + + size_t stringCount = 0; + eastl::string8* stringList = nullptr; + App::Property::GetArrayString8(propList.get(), id("replacementList"), stringCount, stringList); + for (size_t j = 0; j < stringCount; j++) { + bool result = false; + App::Property* out; + uint32_t size; + eastl::string typeString{}; + uint32_t replaceHash = 0; + eastl::string valueString{}; + + //as much as GetArrayString8 says it gives a string8 array it doesn't, this took alot of debugging to get this right, the strings are seperated every 0x8 bytes as pointers to the strings. + ArgScript::Line PropLine = ArgScript::Line(*(char**)(static_cast(static_cast(stringList)) + (0x8 * j))); + if (PropLine.GetArgumentsCount() < 3 && PropLine.GetArgumentsCount() > 4) continue; + typeString = PropLine.GetArgumentAt(0); + replaceHash = std::strtoul(PropLine.GetArgumentAt(1), nullptr, 16); + valueString = PropLine.GetArgumentAt(2); + + typeString.make_lower(); + + if (typeString == "bool") { + bool value; + result = App::Property::GetBool(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + boolValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "int32") { + int32_t value; + result = App::Property::GetInt32(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + int32ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "uint32") { + uint32_t value; + result = App::Property::GetUInt32(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + uint32ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "float") { + float value; + result = App::Property::GetFloat(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + floatValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "string8") { + eastl::string value; + result = App::Property::GetString8(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + string8ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "string16") { + eastl::string16 value; + result = App::Property::GetString16(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + string16ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "key") { + ResourceKey value; + result = App::Property::GetKey(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + keyValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "text") { + LocalizedString value; + result = App::Property::GetText(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + textValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "vector2") { + Vector2 value; + result = App::Property::GetVector2(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + vector2ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "vector3") { + Vector3 value; + result = App::Property::GetVector3(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + vector3ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "vector4") { + Vector4 value; + result = App::Property::GetVector4(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + vector4ValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "colorrgb") { + ColorRGB value; + result = App::Property::GetColorRGB(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + colorRGBValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "colorrgba") { + ColorRGBA value; + result = App::Property::GetColorRGBA(propList.get(), id(valueString.c_str()), value); + if (!result) continue; + colorRGBAValueMapOverride.emplace(eastl::pair{replaceHash, value}); + } else if (typeString == "transform") { + /*ManualBreakpoint(); + Transform value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = *(out->GetValueTransform()); + transformValueMapOverride.emplace(eastl::pair{replaceHash, value});*/ + } else if (typeString == "bbox") { + /*BoundingBox value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = *(out->GetValueBBox()); + bBoxValueMapOverride.emplace(eastl::pair{replaceHash, value});*/ + } else if (typeString == "bools") { + bool* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueBool(); + size = out->GetItemCount(); + boolValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "int32s") { + int32_t* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueInt32(); + size = out->GetItemCount(); + int32ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "uint32s") { + uint32_t* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueUInt32(); + size = out->GetItemCount(); + uint32ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "floats") { + float* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueFloat(); + size = out->GetItemCount(); + floatValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "string8s") { + eastl::string* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueString8(); + size = out->GetItemCount(); + string8ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "string16s") { + eastl::string16* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueString16(); + size = out->GetItemCount(); + string16ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "keys") { + ResourceKey* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueKey(); + size = out->GetItemCount(); + keyValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "texts") { + LocalizedString* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueText(); + size = out->GetItemCount(); + textValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "vector2s") { + Vector2* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueVector2(); + size = out->GetItemCount(); + vector2ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "vector3s") { + Vector3* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueVector3(); + size = out->GetItemCount(); + vector3ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "vector4s") { + Vector4* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueVector4(); + size = out->GetItemCount(); + vector4ValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "colorrgbs") { + ColorRGB* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueColorRGB(); + size = out->GetItemCount(); + colorRGBValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "colorrgbas") { + ColorRGBA* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueColorRGBA(); + size = out->GetItemCount(); + colorRGBAValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "transforms") { + Transform* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueTransform(); + size = out->GetItemCount(); + transformValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } else if (typeString == "bboxs") { + BoundingBox* value; + result = propList.get()->GetProperty(id(valueString.c_str()), out); + if (!result) continue; + value = out->GetValueBBox(); + size = out->GetItemCount(); + bBoxValueMapArrayOverride.emplace(eastl::pair>{replaceHash, {value, size}}); + } } } + return true; } - return result; } +using namespace UniversalPropertyReplacement; -bool DetouredGetBool(const App::PropertyList *pPropertyList, uint32_t propertyID, bool &dst) { - return DetouredGetProp(GetBool_original, boolValueMapOverride, boolValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetFloat(const App::PropertyList *pPropertyList, uint32_t propertyID, float &dst) { - return DetouredGetProp(GetFloat_original, floatValueMapOverride, floatValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetInt32(const App::PropertyList *pPropertyList, uint32_t propertyID, int32_t &dst) { - return DetouredGetProp(GetInt32_original, int32ValueMapOverride, int32ValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetUInt32(const App::PropertyList *pPropertyList, uint32_t propertyID, uint32_t &dst) { - return DetouredGetProp(GetUInt32_original, uint32ValueMapOverride, uint32ValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetVector2(const App::PropertyList *pPropertyList, uint32_t propertyID, Vector2 &dst) { - return DetouredGetProp(GetVector2_original, vector2ValueMapOverride, vector2ValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetVector3(const App::PropertyList *pPropertyList, uint32_t propertyID, Vector3 &dst) { - return DetouredGetProp(GetVector3_original, vector3ValueMapOverride, vector3ValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetVector4(const App::PropertyList *pPropertyList, uint32_t propertyID, Vector4 &dst) { - return DetouredGetProp(GetVector4_original, vector4ValueMapOverride, vector4ValueMapDefault, pPropertyList, propertyID, dst); -} - -bool DetouredGetColorRGB(const App::PropertyList *pPropertyList, uint32_t propertyID, ColorRGB &dst) { - return DetouredGetProp(GetColorRGB_original, colorRGBValueMapOverride, colorRGBValueMapDefault, pPropertyList, propertyID, dst); +template +void ApplyTemplateValueMapProperty(App::Property*& prop, uint32_t propertyID, eastl::map& map) { + auto iter = map.find(propertyID); + if (iter != map.end()) { + prop->Set(prop->mnType, 0, (void*)&(iter->second), sizeof(T), 1); + } } -bool DetouredGetColorRGBA(const App::PropertyList *pPropertyList, uint32_t propertyID, ColorRGBA &dst) { - return DetouredGetProp(GetColorRGBA_original, colorRGBAValueMapOverride, colorRGBAValueMapDefault, pPropertyList, propertyID, dst); +template +void ApplyTemplateValueMapArrayProperty(App::Property*& prop, uint32_t propertyID, eastl::map>& map) { + auto iter = map.find(propertyID); + if (iter != map.end()) { + prop->Set(prop->mnType, App::Property::PropertyFlags::kPropertyFlagArray, (void*)(iter->second.first), sizeof(T), iter->second.second); + } } -bool DetouredGetKey(const App::PropertyList *pPropertyList, uint32_t propertyID, ResourceKey &dst) { - return DetouredGetProp(GetKey_original, resourceKeyValueMapDefault, resourceKeyValueMapDefault, pPropertyList, propertyID, dst); +void ApplyValueMapProperty(App::Property*& prop, uint32_t propertyID) { + if (prop->mnFlags & App::Property::PropertyFlags::kPropertyFlagArray) { + switch (prop->mnType) { + case App::PropertyType::Bool: { + auto iter = boolValueMapArrayOverride.find(propertyID); + return ApplyTemplateValueMapArrayProperty(prop, propertyID, boolValueMapArrayOverride); + } + case App::PropertyType::Int32: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, int32ValueMapArrayOverride); + } + case App::PropertyType::UInt32: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, uint32ValueMapArrayOverride); + } + case App::PropertyType::Float: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, floatValueMapArrayOverride); + } + case App::PropertyType::String8: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, string8ValueMapArrayOverride); + } + case App::PropertyType::String16: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, string16ValueMapArrayOverride); + } + case App::PropertyType::Key: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, keyValueMapArrayOverride); + } + case App::PropertyType::Text: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, textValueMapArrayOverride); + } + case App::PropertyType::Vector2: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, vector2ValueMapArrayOverride); + } + case App::PropertyType::Vector3: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, vector3ValueMapArrayOverride); + } + case App::PropertyType::Vector4: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, vector4ValueMapArrayOverride); + } + case App::PropertyType::ColorRGB: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, colorRGBValueMapArrayOverride); + } + case App::PropertyType::ColorRGBA: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, colorRGBAValueMapArrayOverride); + } + case App::PropertyType::Transform: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, transformValueMapArrayOverride); + } + case App::PropertyType::BBox: { + return ApplyTemplateValueMapArrayProperty(prop, propertyID, bBoxValueMapArrayOverride); + } + } + return; + } + switch (prop->mnType) { + case App::PropertyType::Bool: { + return ApplyTemplateValueMapProperty(prop, propertyID, boolValueMapOverride); + } + case App::PropertyType::Int32: { + return ApplyTemplateValueMapProperty(prop, propertyID, int32ValueMapOverride); + } + case App::PropertyType::UInt32: { + return ApplyTemplateValueMapProperty(prop, propertyID, uint32ValueMapOverride); + } + case App::PropertyType::Float: { + return ApplyTemplateValueMapProperty(prop, propertyID, floatValueMapOverride); + } + case App::PropertyType::String8: { + return ApplyTemplateValueMapProperty(prop, propertyID, string8ValueMapOverride); + } + case App::PropertyType::String16: { + return ApplyTemplateValueMapProperty(prop, propertyID, string16ValueMapOverride); + } + case App::PropertyType::Key: { + return ApplyTemplateValueMapProperty(prop, propertyID, keyValueMapOverride); + } + case App::PropertyType::Text: { + return ApplyTemplateValueMapProperty(prop, propertyID, textValueMapOverride); + } + case App::PropertyType::Vector2: { + return ApplyTemplateValueMapProperty(prop, propertyID, vector2ValueMapOverride); + } + case App::PropertyType::Vector3: { + return ApplyTemplateValueMapProperty(prop, propertyID, vector3ValueMapOverride); + } + case App::PropertyType::Vector4: { + return ApplyTemplateValueMapProperty(prop, propertyID, vector4ValueMapOverride); + } + case App::PropertyType::ColorRGB: { + return ApplyTemplateValueMapProperty(prop, propertyID, colorRGBValueMapOverride); + } + case App::PropertyType::ColorRGBA: { + return ApplyTemplateValueMapProperty(prop, propertyID, colorRGBAValueMapOverride); + } + case App::PropertyType::Transform: { + return ApplyTemplateValueMapProperty(prop, propertyID, transformValueMapOverride); + } + case App::PropertyType::BBox: { + return ApplyTemplateValueMapProperty(prop, propertyID, bBoxValueMapOverride); + } + } } -bool DetouredGetString8(const App::PropertyList *pPropertyList, uint32_t propertyID, eastl::string &dst) { - return DetouredGetProp(GetString8_original, stringValueMapOverride, stringValueMapDefault, pPropertyList, propertyID, dst); +bool UniversalPropertyReplacement::GetPropertyAlt__detour::DETOUR(uint32_t propertyID, App::Property*& result) { + return this->GetProperty(propertyID, result); } -bool DetouredGetCString8(const App::PropertyList *pPropertyList, uint32_t propertyID, char* &dst) { - return DetouredGetProp(GetCString8_original, cstringValueMapOverride, cstringValueMapDefault, pPropertyList, propertyID, dst); +bool UniversalPropertyReplacement::GetProperty__detour::DETOUR(uint32_t propertyID, App::Property*& result) { + bool ret = original_function(this, propertyID, result); + if (ret) ApplyValueMapProperty(result, propertyID); + return ret; } -bool DetouredGetString16(const App::PropertyList *pPropertyList, uint32_t propertyID, eastl::string16 &dst) { - return DetouredGetProp(GetString16_original, wstringValueMapOverride, wstringValueMapDefault, pPropertyList, propertyID, dst); +App::Property* UniversalPropertyReplacement::GetPropertyObject__detour::DETOUR(uint32_t propertyID) { + App::Property* ret = original_function(this, propertyID); + ApplyValueMapProperty(ret, propertyID); + return ret; } - -bool DetouredGetCString16(const App::PropertyList *pPropertyList, uint32_t propertyID, wchar_t * &dst) { - return DetouredGetProp(GetCString16_original, wcstringValueMapOverride, wcstringValueMapDefault, pPropertyList, propertyID, dst); -} \ No newline at end of file diff --git a/UniversalPropertyReplacement/UniversalPropertyReplacement.h b/UniversalPropertyReplacement/UniversalPropertyReplacement.h index 0949985..e347250 100644 --- a/UniversalPropertyReplacement/UniversalPropertyReplacement.h +++ b/UniversalPropertyReplacement/UniversalPropertyReplacement.h @@ -1,5 +1,5 @@ /**************************************************************************** -* Copyright (C) 2018 Zarklord +* Copyright (C) 2018, 2020 Zarklord * * This file is part of UniversalPropertyReplacement. * @@ -18,119 +18,59 @@ ****************************************************************************/ #pragma once +#include -#include -#include -#include -#include +namespace UniversalPropertyReplacement { + bool Inititalize(); + long AttachDetours(); -#define DetouredMethodStaticFixed(name, returnType, newName, parameters) typedef returnType (* name##_original_t)(parameters); \ - static name##_original_t name##_original; \ - static returnType newName (parameters); + static eastl::map boolValueMapOverride {}; + static eastl::map> boolValueMapArrayOverride {}; -class UniversalPropReplacement { -public: - static long AttachDetours(); - static bool Inititalize(); -}; -static eastl::vector> boolValueMapDefault{}; -static eastl::vector> boolValueMapOverride{}; - -static eastl::vector> floatValueMapDefault{}; -static eastl::vector> floatValueMapOverride{}; - -static eastl::vector> int32ValueMapDefault{}; -static eastl::vector> int32ValueMapOverride{}; - -static eastl::vector> uint32ValueMapDefault{}; -static eastl::vector> uint32ValueMapOverride{}; - -static eastl::vector> vector2ValueMapDefault{}; -static eastl::vector> vector2ValueMapOverride{}; - -static eastl::vector> vector3ValueMapDefault{}; -static eastl::vector> vector3ValueMapOverride{}; - -static eastl::vector> vector4ValueMapDefault{}; -static eastl::vector> vector4ValueMapOverride{}; - -static eastl::vector> colorRGBValueMapDefault{}; -static eastl::vector> colorRGBValueMapOverride{}; + static eastl::map int32ValueMapOverride {}; + static eastl::map> int32ValueMapArrayOverride {}; -static eastl::vector> colorRGBAValueMapDefault{}; -static eastl::vector> colorRGBAValueMapOverride{}; + static eastl::map uint32ValueMapOverride {}; + static eastl::map> uint32ValueMapArrayOverride {}; -static eastl::vector> resourceKeyValueMapDefault{}; -static eastl::vector> resourceKeyValueMapOverride{}; + static eastl::map floatValueMapOverride{}; + static eastl::map> floatValueMapArrayOverride {}; -static eastl::vector> stringValueMapDefault{}; -static eastl::vector> stringValueMapOverride{}; + static eastl::map string8ValueMapOverride {}; + static eastl::map> string8ValueMapArrayOverride {}; -static eastl::vector> cstringValueMapDefault{}; -static eastl::vector> cstringValueMapOverride{}; + static eastl::map string16ValueMapOverride {}; + static eastl::map> string16ValueMapArrayOverride {}; -static eastl::vector> wstringValueMapDefault{}; -static eastl::vector> wstringValueMapOverride{}; + static eastl::map keyValueMapOverride {}; + static eastl::map> keyValueMapArrayOverride {}; -static eastl::vector> wcstringValueMapDefault{}; -static eastl::vector> wcstringValueMapOverride{}; + static eastl::map textValueMapOverride {}; + static eastl::map> textValueMapArrayOverride {}; -template -static bool DetouredGetProp(method_t &method, eastl::vector> &override, eastl::vector> &default, const App::PropertyList * pPropertyList, uint32_t propertyID, T &dst); + static eastl::map vector2ValueMapOverride{}; + static eastl::map> vector2ValueMapArrayOverride {}; + static eastl::map vector3ValueMapOverride{}; + static eastl::map> vector3ValueMapArrayOverride {}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetBool, bool, DetouredGetBool, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, bool &dst)); + static eastl::map vector4ValueMapOverride{}; + static eastl::map> vector4ValueMapArrayOverride {}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetFloat, bool, DetouredGetFloat, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, float &dst)); + static eastl::map colorRGBValueMapOverride{}; + static eastl::map> colorRGBValueMapArrayOverride {}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetInt32, bool, DetouredGetInt32, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, int32_t &dst)); + static eastl::map colorRGBAValueMapOverride {}; + static eastl::map> colorRGBAValueMapArrayOverride {}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetUInt32, bool, DetouredGetUInt32, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, uint32_t &dst)); + static eastl::map transformValueMapOverride {}; + static eastl::map> transformValueMapArrayOverride {}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetVector2, bool, DetouredGetVector2, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, Vector2 &dst)); + static eastl::map bBoxValueMapOverride {}; + static eastl::map> bBoxValueMapArrayOverride {}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetVector3, bool, DetouredGetVector3, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, Vector3 &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetVector4, bool, DetouredGetVector4, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, Vector4 &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetColorRGB, bool, DetouredGetColorRGB, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, ColorRGB &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetColorRGBA, bool, DetouredGetColorRGBA, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, ColorRGBA &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetKey, bool, DetouredGetKey, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, ResourceKey &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetString8, bool, DetouredGetString8, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, eastl::string &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetCString8, bool, DetouredGetCString8, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, char * &dst)); - -#pragma DisableOptimization -DetouredMethodStaticFixed(GetString16, bool, DetouredGetString16, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, eastl::string16 &dst)); + member_detour(GetPropertyAlt__detour, App::PropertyList, bool(uint32_t propertyID, App::Property*& result)) {}; + member_detour(GetProperty__detour, App::PropertyList, bool(uint32_t propertyID, App::Property*& result)) {}; + member_detour(GetPropertyObject__detour, App::PropertyList, App::Property*(uint32_t propertyID)) {}; +}; -#pragma DisableOptimization -DetouredMethodStaticFixed(GetCString16, bool, DetouredGetCString16, - PARAMS(const App::PropertyList *pPropertyList, uint32_t propertyID, wchar_t * &dst)); \ No newline at end of file diff --git a/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj b/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj index 2530b82..1927899 100644 --- a/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj +++ b/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj @@ -1,34 +1,10 @@  - + - - Debug - Disk - Win32 - - - Debug - Steam Patched - Win32 - - - Debug - Steam - Win32 - Debug Win32 - - Release - Disk - Win32 - - - Release - Steam Patched - Win32 - - - Release - Steam - Win32 - Release Win32 @@ -37,254 +13,70 @@ {07FC5B61-B575-4207-B464-AFAE6AF3FC19} Win32Proj - Universal_Property_Replacement - 10.0.16299.0 - UniversalPropertyReplacement + UniversalPropertyReplacement + 10.0 DynamicLibrary true - v141 - Unicode - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - true - v141 - Unicode - - - DynamicLibrary - true - v141 + v142 Unicode DynamicLibrary false - v141 - true - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - DynamicLibrary - false - v141 - true - Unicode - - - DynamicLibrary - false - v141 + v142 true Unicode - - - - - - - + + - - - - - - - - - - - - - + + true - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\debug;$(LibraryPath) - - - true - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\debug;$(LibraryPath) - $(ProjectName)-disk - $(SolutionDir)Debug\ - - - true - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\debug;$(LibraryPath) - $(ProjectName)-steam - $(SolutionDir)Debug\ - - - true - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\debug;$(LibraryPath) - $(ProjectName)-steam_patched - $(SolutionDir)Debug\ + $(SporeSdkPath)Spore ModAPI;$(SporeSdkPath)EASTL-3.02.01\test\packages\EABase\include\Common;$(SporeSdkPath)EASTL-3.02.01\test\packages\EAAssert\include;$(SporeSdkPath)EASTL-3.02.01\test\packages\EAStdC\include;$(SporeSdkPath)EASTL-3.02.01\include;$(SporeSdkPath)Detours\include\;$(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(SporeLauncherPath)coreLibs;$(SporeSdkPath)Detours\lib.X86;$(SporeSdkPath)lib\Debug;$(LibraryPath) + $(ProjectName) + $(SporeLauncherPath)mLibs + $(SporeLauncherPath)Spore ModAPI Launcher.exe + $(SporeLauncherPath) + WindowsLocalDebugger false - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\release;$(LibraryPath) - - - false - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\release;$(LibraryPath) - $(ProjectName)-disk - $(SolutionDir)Release\ - - - false - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\release;$(LibraryPath) - $(ProjectName)-steam - $(SolutionDir)Release\ - - - false - $(SolutionDir)\..\Spore ModAPI;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EABase\include\Common;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAAssert\include;$(SolutionDir)\..\EASTL-3.02.01\test\packages\EAStdC\include;$(SolutionDir)\..\EASTL-3.02.01\include;$(SolutionDir)\..\Detours\include\;$(IncludePath) - $(SolutionDir)\..\Detours\lib.X86;$(SolutionDir)\..\lib\release;$(LibraryPath) - $(ProjectName)-steam_patched - $(SolutionDir)Release\ + $(SporeSdkPath)Spore ModAPI;$(SporeSdkPath)EASTL-3.02.01\test\packages\EABase\include\Common;$(SporeSdkPath)EASTL-3.02.01\test\packages\EAAssert\include;$(SporeSdkPath)EASTL-3.02.01\test\packages\EAStdC\include;$(SporeSdkPath)EASTL-3.02.01\include;$(SporeSdkPath)Detours\include\;$(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(SporeLauncherPath)coreLibs;$(SporeSdkPath)Detours\lib.X86;$(SporeSdkPath)lib\Release;$(LibraryPath) + $(ProjectName) + $(SporeLauncherPath)mLibs + $(SporeLauncherPath)Spore ModAPI Launcher.exe + $(SporeLauncherPath) + WindowsLocalDebugger Use Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Windows true - detours.lib;%(AdditionalDependencies) - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;EXECUTABLE_TYPE=SPORE_STANDARD;PATCHED_SPORE=0;%(PreprocessorDefinitions) - true - - - Windows - true - detours.lib;SporeModAPIBase-disk.lib;%(AdditionalDependencies) - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;EXECUTABLE_TYPE=SPORE_STEAM;PATCHED_SPORE=0;%(PreprocessorDefinitions) - true - - - Windows - true - detours.lib;SporeModAPIBase-steam.lib;%(AdditionalDependencies) - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;EXECUTABLE_TYPE=SPORE_STEAM;PATCHED_SPORE=1;%(PreprocessorDefinitions) - true - - - Windows - true - detours.lib;SporeModAPIBase-steam_patched.lib;%(AdditionalDependencies) + detours.lib;SporeModAPIBase.lib;SporeModAPI.lib;%(AdditionalDependencies) - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - detours.lib;%(AdditionalDependencies) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;EXECUTABLE_TYPE=SPORE_STANDARD;PATCHED_SPORE=0;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - detours.lib;SporeModAPIBase-disk.lib;%(AdditionalDependencies) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;SPOREMODAPITEMPLATE_EXPORTS;EXECUTABLE_TYPE=SPORE_STEAM;PATCHED_SPORE=0;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - detours.lib;SporeModAPIBase-steam.lib;%(AdditionalDependencies) - - - Level3 Use @@ -299,7 +91,7 @@ true true true - detours.lib;SporeModAPIBase-steam_patched.lib;%(AdditionalDependencies) + detours.lib;SporeModAPIBase.lib;SporeModAPI.lib;%(AdditionalDependencies) @@ -308,48 +100,27 @@ - + false - false - false - false - - - - - - false - false - false - false - - - - - - - - Create - Create - Create - Create Create - Create - Create - Create + + + + + diff --git a/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj.filters b/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj.filters index cec843b..e6d223f 100644 --- a/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj.filters +++ b/UniversalPropertyReplacement/UniversalPropertyReplacement.vcxproj.filters @@ -1,48 +1,51 @@  - - {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 + + {3880d018-2395-4502-abfe-4b83e0817aab} + + + {d62ad12d-69d8-4933-8342-03043c9adc22} + - - - - - Header Files - - Header Files + Internal + + + Internal - Header Files + UniversalPropertyReplacement - - Header Files + + UniversalPropertyReplacement - - Source Files - - Source Files + UniversalPropertyReplacement + + + Internal - Source Files + UniversalPropertyReplacement - - Source Files + + UniversalPropertyReplacement + + + + + + Internal + + \ No newline at end of file diff --git a/UniversalPropertyReplacement/VerificationCheat.cpp b/UniversalPropertyReplacement/VerificationCheat.cpp new file mode 100644 index 0000000..d047948 --- /dev/null +++ b/UniversalPropertyReplacement/VerificationCheat.cpp @@ -0,0 +1,347 @@ +/**************************************************************************** +* Copyright (C) 2018, 2020 Zarklord +* +* This file is part of UniversalPropertyReplacement. +* +* UniversalPropertyReplacement is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with UniversalPropertyReplacement. If not, see . +****************************************************************************/ + +#include "stdafx.h" +#include "VerificationCheat.h" + +bool VerifyValue(bool& toverify) { + return toverify == false; +} +bool VerifyValue(int32_t& toverify) { + return toverify == -1; +} +bool VerifyValue(uint32_t& toverify) { + return toverify == 1; +} +bool VerifyValue(float& toverify) { + return toverify == 1.1; +} +bool VerifyValue(eastl::string& toverify) { + return toverify == "1"; +} +bool VerifyValue(char*& toverify) { + return strcmp(toverify, "1") == 0; +} +bool VerifyValue(eastl::string16& toverify) { + return toverify == eastl::string16 {"1"}; +} +bool VerifyValue(char16_t*& toverify) { + return wcscmp((wchar_t*)toverify, L"1") == 0; +} +bool VerifyValue(ResourceKey& toverify) { + return toverify.groupID == id("prop_overrides") && toverify.instanceID == id("VerifyUPROverrides") && toverify.typeID == id("prop"); +} +bool VerifyValue(LocalizedString& toverify) { + return toverify.GetText() == eastl::string16 {"Name Your Creature"}; +} +bool VerifyValue(Vector2& toverify) { + return toverify.x == 1 && toverify.y == 1; +} +bool VerifyValue(Vector3& toverify) { + return toverify.x == 1 && toverify.y == 1 && toverify.z == 1; +} +bool VerifyValue(Vector4& toverify) { + return toverify.x == 1 && toverify.y == 1 && toverify.z == 1 && toverify.w == 1; +} +bool VerifyValue(ColorRGB& toverify) { + return toverify.r == 1 && toverify.g == 1 && toverify.b == 1; +} +bool VerifyValue(ColorRGBA& toverify) { + return toverify.r == 1 && toverify.g == 1 && toverify.b == 1 && toverify.a == 1; +} +bool VerifyValue(Transform& toverify) { + auto o = toverify.GetOffset(); + auto s = toverify.GetScale(); + auto r = toverify.GetRotation().ToEuler(); + return o.x == 1 && o.y == 1 && o.z == 1 && s == 1 && r.x == 1 && r.y == 1 && r.z == 1; +} +bool VerifyValue(BoundingBox& toverify) { + auto l = toverify.lower; + auto u = toverify.upper; + return l.x == 1 && l.y == 1 && l.z == 1 && u.x == 1 && u.y == 1 && u.z == 1; +} + +bool VerifyCount(uint32_t& count) { + return count == 3; +} + +void ReportReplacementFailed(eastl::string str) { + App::ConsolePrintF("%s Replacement failed!", str.c_str()); +} + +uint32_t GetPropertyId(eastl::string str) { + return id((str + "Value").c_str()); +} + +void VerificationCheat::ParseLine(const ArgScript::Line& line) { + PropertyListPtr propList; + App::IPropManager::Get()->GetPropertyList(id("VerifyUPR"), id("VerifyUPR"), propList); + + App::Property* out; + bool testFailed = false; + + bool boolTest; + App::Property::GetBool(propList.get(), GetPropertyId("bool"), boolTest); + if (VerifyValue(boolTest)) { + ReportReplacementFailed("bool"); + testFailed = true; + } + int32_t int32Test; + App::Property::GetInt32(propList.get(), GetPropertyId("int32"), int32Test); + if (VerifyValue(int32Test)) { + ReportReplacementFailed("int32"); + testFailed = true; + } + uint32_t uint32Test; + App::Property::GetUInt32(propList.get(), GetPropertyId("uint32"), uint32Test); + if (VerifyValue(boolTest)) { + ReportReplacementFailed("uint32"); + testFailed = true; + } + float floatTest; + App::Property::GetFloat(propList.get(), GetPropertyId("float"), floatTest); + if (VerifyValue(floatTest)) { + ReportReplacementFailed("float"); + testFailed = true; + } + eastl::string stringTest; + App::Property::GetString8(propList.get(), GetPropertyId("string8"), stringTest); + if (VerifyValue(stringTest)) { + ReportReplacementFailed("string8"); + testFailed = true; + } + char* cstringTest; + App::Property::GetCString8(propList.get(), GetPropertyId("string8"), cstringTest); + if (VerifyValue(cstringTest)) { + ReportReplacementFailed("cstring8"); + testFailed = true; + } + eastl::string16 string16Test; + App::Property::GetString16(propList.get(), GetPropertyId("string16"), string16Test); + if (VerifyValue(string16Test)) { + ReportReplacementFailed("string16"); + testFailed = true; + } + char16_t* cstring16Test; + App::Property::GetCString16(propList.get(), GetPropertyId("string16"), cstring16Test); + if (VerifyValue(cstring16Test)) { + ReportReplacementFailed("cstring16"); + testFailed = true; + } + ResourceKey keyTest; + App::Property::GetKey(propList.get(), GetPropertyId("key"), keyTest); + if (VerifyValue(keyTest)) { + ReportReplacementFailed("key"); + testFailed = true; + } + LocalizedString textTest; + App::Property::GetText(propList.get(), GetPropertyId("text"), textTest); + if (VerifyValue(textTest)) { + ReportReplacementFailed("text"); + testFailed = true; + } + Vector2 vector2Test; + App::Property::GetVector2(propList.get(), GetPropertyId("vector2"), vector2Test); + if (VerifyValue(vector2Test)) { + ReportReplacementFailed("vector2"); + testFailed = true; + } + Vector3 vector3Test; + App::Property::GetVector3(propList.get(), GetPropertyId("vector3"), vector3Test); + if (VerifyValue(vector3Test)) { + ReportReplacementFailed("vector3"); + testFailed = true; + } + Vector4 vector4Test; + App::Property::GetVector4(propList.get(), GetPropertyId("vector4"), vector4Test); + if (VerifyValue(vector4Test)) { + ReportReplacementFailed("vector4"); + testFailed = true; + } + ColorRGB colorRGBTest; + App::Property::GetColorRGB(propList.get(), GetPropertyId("colorRGB"), colorRGBTest); + if (VerifyValue(colorRGBTest)) { + ReportReplacementFailed("colorRGB"); + testFailed = true; + } + ColorRGBA colorRGBATest; + App::Property::GetColorRGBA(propList.get(), GetPropertyId("colorRGBA"), colorRGBATest); + if (VerifyValue(colorRGBATest)) { + ReportReplacementFailed("colorRGBA"); + testFailed = true; + } + /*Transform transformTest; + if (propList.get()->GetProperty(GetPropertyId("transform"), out)) { + transformTest = *(out->GetValueTransform()); + if (VerifyValue(transformTest)) { + ReportReplacementFailed("transform"); + testFailed = true; + } + }*/ + /*BoundingBox bBoxTest; + if (propList.get()->GetProperty(GetPropertyId("bbox"), out)) { + bBoxTest = *(out->GetValueBBox()); + if (VerifyValue(bBoxTest)) { + ReportReplacementFailed("bbox"); + testFailed = true; + } + }*/ + + uint32_t count; + + bool* boolsTest; + if (propList.get()->GetProperty(GetPropertyId("bools"), out)) { + boolsTest = out->GetValueBool(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(boolsTest[0]) && VerifyValue(boolsTest[1]))) { + ReportReplacementFailed("bools"); + testFailed = true; + } + } + int32_t* int32sTest; + if (propList.get()->GetProperty(GetPropertyId("int32s"), out)) { + int32sTest = out->GetValueInt32(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(int32sTest[0]) && VerifyValue(int32sTest[1]))) { + ReportReplacementFailed("int32s"); + testFailed = true; + } + } + uint32_t* uint32sTest; + if (propList.get()->GetProperty(GetPropertyId("uint32s"), out)) { + uint32sTest = out->GetValueUInt32(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(uint32sTest[0]) && VerifyValue(uint32sTest[1]))) { + ReportReplacementFailed("uint32s"); + testFailed = true; + } + } + float* floatsTest; + if (propList.get()->GetProperty(GetPropertyId("floats"), out)) { + floatsTest = out->GetValueFloat(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(floatsTest[0]) && VerifyValue(floatsTest[1]))) { + ReportReplacementFailed("floats"); + testFailed = true; + } + } + eastl::string* string8sTest; + if (propList.get()->GetProperty(GetPropertyId("string8s"), out)) { + string8sTest = out->GetValueString8(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(string8sTest[0]) && VerifyValue(string8sTest[1]))) { + ReportReplacementFailed("string8s"); + testFailed = true; + } + } + eastl::string16* string16sTest; + if (propList.get()->GetProperty(GetPropertyId("string16s"), out)) { + string16sTest = out->GetValueString16(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(string16sTest[0]) && VerifyValue(string16sTest[1]))) { + ReportReplacementFailed("string16s"); + testFailed = true; + } + } + ResourceKey* keysTest; + if (propList.get()->GetProperty(GetPropertyId("keys"), out)) { + keysTest = out->GetValueKey(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(keysTest[0]) && VerifyValue(keysTest[1]))) { + ReportReplacementFailed("keys"); + testFailed = true; + } + } + LocalizedString* textsTest; + if (propList.get()->GetProperty(GetPropertyId("texts"), out)) { + textsTest = out->GetValueText(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(textsTest[0]) && VerifyValue(textsTest[1]))) { + ReportReplacementFailed("texts"); + testFailed = true; + } + } + Vector2* vector2sTest; + if (propList.get()->GetProperty(GetPropertyId("vector2s"), out)) { + vector2sTest = out->GetValueVector2(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(vector2sTest[0]) && VerifyValue(vector2sTest[1]))) { + ReportReplacementFailed("vector2s"); + testFailed = true; + } + } + Vector3* vector3sTest; + if (propList.get()->GetProperty(GetPropertyId("vector3s"), out)) { + vector3sTest = out->GetValueVector3(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(vector3sTest[0]) && VerifyValue(vector3sTest[1]))) { + ReportReplacementFailed("vector3s"); + testFailed = true; + } + } + Vector4* vector4sTest; + if (propList.get()->GetProperty(GetPropertyId("vector4s"), out)) { + vector4sTest = out->GetValueVector4(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(vector4sTest[0]) && VerifyValue(vector4sTest[1]))) { + ReportReplacementFailed("vector4s"); + testFailed = true; + } + } + ColorRGB* colorRGBsTest; + if (propList.get()->GetProperty(GetPropertyId("colorRGBs"), out)) { + colorRGBsTest = out->GetValueColorRGB(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(colorRGBsTest[0]) && VerifyValue(colorRGBsTest[1]))) { + ReportReplacementFailed("colorRGBs"); + testFailed = true; + } + } + ColorRGBA* colorRGBAsTest; + if (propList.get()->GetProperty(GetPropertyId("colorRGBAs"), out)) { + colorRGBAsTest = out->GetValueColorRGBA(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(colorRGBAsTest[0]) && VerifyValue(colorRGBAsTest[1]))) { + ReportReplacementFailed("colorRGBAs"); + testFailed = true; + } + } + Transform* transformsTest; + if (propList.get()->GetProperty(GetPropertyId("transforms"), out)) { + transformsTest = out->GetValueTransform(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(transformsTest[0]) && VerifyValue(transformsTest[1]))) { + ReportReplacementFailed("transforms"); + testFailed = true; + } + } + BoundingBox* bBoxsTest; + if (propList.get()->GetProperty(GetPropertyId("bboxs"), out)) { + bBoxsTest = out->GetValueBBox(); + count = out->GetItemCount(); + if (VerifyCount(count) || (VerifyValue(bBoxsTest[0]) && VerifyValue(bBoxsTest[1]))) { + ReportReplacementFailed("bboxs"); + testFailed = true; + } + } + + if (!testFailed) { + App::ConsolePrintF("no replacement tests failed!"); + } +} \ No newline at end of file diff --git a/UniversalPropertyReplacement/TestingCheat.h b/UniversalPropertyReplacement/VerificationCheat.h similarity index 90% rename from UniversalPropertyReplacement/TestingCheat.h rename to UniversalPropertyReplacement/VerificationCheat.h index 6d788aa..1cea0f7 100644 --- a/UniversalPropertyReplacement/TestingCheat.h +++ b/UniversalPropertyReplacement/VerificationCheat.h @@ -1,5 +1,5 @@ /**************************************************************************** -* Copyright (C) 2018 Zarklord +* Copyright (C) 2018, 2020 Zarklord * * This file is part of UniversalPropertyReplacement. * @@ -20,8 +20,9 @@ #pragma once #include -class TestingCheat : public ArgScript::ICommand { -public: + +class VerificationCheat: public ArgScript::ICommand { + public: virtual void ParseLine(const ArgScript::Line& line) override; }; diff --git a/UniversalPropertyReplacement/dllmain.cpp b/UniversalPropertyReplacement/dllmain.cpp index 9fa9180..5298904 100644 --- a/UniversalPropertyReplacement/dllmain.cpp +++ b/UniversalPropertyReplacement/dllmain.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -* Copyright (C) 2018 Zarklord +* Copyright (C) 2018, 2020 Zarklord * * This file is part of UniversalPropertyReplacement. * @@ -19,33 +19,54 @@ // dllmain.cpp : Defines the entry point for the DLL application. #include "stdafx.h" - -#include #include "UniversalPropertyReplacement.h" +void Initialize() +{ + // This method is executed when the game starts, before the user interface is shown + // Here you can do things such as: + // - Add new cheats + // - Add new simulator classes + // - Add new game modes + // - Add new space tools + // - Change materials + UniversalPropertyReplacement::Inititalize(); +} + +void Dispose() +{ + // This method is called when the game is closing +} + +void AttachDetours() +{ + //ManualBreakpoint(); + // Call the attach() method on any detours you want to add + // For example: cViewer_SetRenderType_detour::attach(GetAddress(cViewer, SetRenderType)); + UniversalPropertyReplacement::AttachDetours(); +} + + +// Generally, you don't need to touch any code here BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { - long error; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - - // This line is always necessary - ModAPI::ModAPIUtils::InitModAPI(); - - ModAPI::ModAPIUtils::AddInitFunction(UniversalPropReplacement::Inititalize); + ModAPI::AddPostInitFunction(Initialize); + ModAPI::AddDisposeFunction(Dispose); PrepareDetours(hModule); - // It is recommended to attach the detoured methods in specialised methods in the class - UniversalPropReplacement::AttachDetours(); - error = SendDetours(); + AttachDetours(); + CommitDetours(); + break; + case DLL_PROCESS_DETACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: break; } return TRUE; diff --git a/UniversalPropertyReplacement/stdafx.h b/UniversalPropertyReplacement/stdafx.h index 5f91bc8..5959e79 100644 --- a/UniversalPropertyReplacement/stdafx.h +++ b/UniversalPropertyReplacement/stdafx.h @@ -35,4 +35,4 @@ // TODO: reference additional headers your program requires here // This is used everywhere -#include \ No newline at end of file +#include \ No newline at end of file