Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashi committed Nov 8, 2022
2 parents ffffb6c + e17d61b commit df47802
Show file tree
Hide file tree
Showing 133 changed files with 6,049 additions and 4,963 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ jobs:
- name: Update xmake repository
run: xmake.exe repo --update

# Fetch xmake dephash
#- name: Retrieve dependencies hash
# id: dep_hash
# run: echo "::set-output name=hash::$(xmake.exe dephash)"

# Cache xmake dependencies
#- name: Retrieve cached xmake dependencies
# uses: actions/cache@v2
# with:
# path: xmake-global\.xmake\packages
# key: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}

# Setup compilation mode and install project dependencies
- name: Configure xmake and install dependencies
run: xmake.exe config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes
Expand Down
98 changes: 97 additions & 1 deletion ThirdParty_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,100 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

============ Noto Sans fonts ============

Copyright 2015-2021 Google LLC. All Rights Reserved.

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added fonts/NotoSans-Regular.ttf
Binary file not shown.
Binary file added fonts/NotoSansJP-Regular.otf
Binary file not shown.
Binary file added fonts/NotoSansKR-Regular.otf
Binary file not shown.
Binary file added fonts/NotoSansMono-Regular.ttf
Binary file not shown.
Binary file added fonts/NotoSansSC-Regular.otf
Binary file not shown.
Binary file added fonts/NotoSansTC-Regular.otf
Binary file not shown.
Binary file added fonts/NotoSansThai-Regular.ttf
Binary file not shown.
12 changes: 9 additions & 3 deletions ida/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ def get_groups() -> List[Group]:
# Add new patterns here, please try to keep the groups ordering alphabetized.
return [
Group(name='CRenderGlobal', pointers=[
Item(name='InstanceOffset', pattern='49 8B 95 ? ? ? ? 48 8D 44 24 30 0F 57 C0', expected=1, offset=3),
# instance offset is used by CRenderNode_Present_DoInternal
Item(name='InstanceOffset', pattern='48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35', expected=1, offset=32),
Item(name='_DoNotUse_RenderQueueOffset', pattern='49 39 29 0F 84 ? ? ? ? 41 39 69 24 0F 84 ? ? ? ? 49 8B 95', expected=1)
], functions=[
Item(name='Resize', pattern='44 88 4C 24 20 44 89 44 24 18 89 54 24 10 89 4C', expected=1)
Item(name='Resize', pattern='44 88 4C 24 20 44 89 44 24 18 89 54 24 10 89 4C', expected=1) ,
Item(name='Shutdown', pattern='48 89 6C 24 20 41 56 48 83 EC 20 48 8D 05 3E 85 99 00', expected=1)
]),
Group(name='CRenderNode_Present', functions=[
Item(name='DoInternal', pattern='48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35', expected=1)
Item(name='DoInternal', pattern='48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 30 8B 01 41 8B F8 4C 8B 35', expected=1)
]),
Group(name='CScript', functions=[
Item(name='RunPureScript', pattern='40 55 48 81 EC D0 00 00 00 48 8D 6C 24 40 8B', expected=1),
Expand All @@ -44,6 +46,7 @@ def get_groups() -> List[Group]:
Item(name='LogChannel', pattern='4C 8B DC 49 89 5B 08 49 89 73 18 57 48 83 EC 70 48 8B 02 ? ? ? ? ? ? ? FE 42 62 4D 8D 43 10 33 FF 45 33 C9 49 89 7B 10 48 8B DA 48 89 7A', expected=1),
Item(name='TDBIDConstructorDerive', pattern='40 53 48 83 EC 30 33 C0 4C 89 44 24 20 48 8B DA', expected=1),
Item(name='ProcessRunningState', pattern='40 53 48 83 EC 20 48 8B 0D ? ? ? ? 48 8B DA E8 ? ? ? ? 84 C0', expected=1),
Item(name='ProcessShutdownState', pattern='48 89 6C 24 18 56 48 83 EC 30 48 8B 0D ? ? ? ?', expected=1),
Item(name='TranslateBytecode', pattern='4C 8B DC 55 53 57 41 55 49 8D 6B A1 48 81 EC 98 00 00 00 48 8B 1A 4C 8B E9 8B 42 0C 48 8D 3C C3'),
Item(name='TweakDBLoad', pattern='48 89 5C 24 18 55 57 41 56 48 8B EC 48 83 EC 70 48 8B D9 45 33 F6 48 8D', expected=1),
Item(name='RegisterMemberFunction', pattern='48 89 5C 24 08 57 48 83 EC 20 49 8B C1 4D 8B D0 44 8B 4C 24 58 48 8B DA 41 83 C9 03', expected=1)
Expand Down Expand Up @@ -75,5 +78,8 @@ def get_groups() -> List[Group]:
Group(name='CGame', functions=[
Item(name='Main', pattern='40 57 48 83 EC 70 48 8B F9 0F 29 7C 24 50 48 8D 4C 24 38', expected=1)
]),
Group(name='PlayerSystem', functions=[
Item(name='OnPlayerSpawned', pattern='48 8B C4 4C 89 48 20 55 56 57 48 8B EC 48 81 EC 80 00 00 00 44 8B 15 25 60 54 02 48 8B F1', expected=1)
]),
]

Binary file removed resources/archivehashes.zip
Binary file not shown.
3 changes: 0 additions & 3 deletions scripts/autoexec.lua

This file was deleted.

12 changes: 4 additions & 8 deletions src/CET.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void CET::Shutdown()

CET& CET::Get()
{
// we should always call this after initialization, never before!
assert(s_pInstance);
return *s_pInstance;
}

Expand Down Expand Up @@ -61,21 +63,15 @@ bool CET::IsRunning() noexcept
CET::CET()
: m_options(m_paths)
, m_bindings(m_paths, m_options)
, m_window(&m_overlay, &m_bindings, &m_d3d12)
, m_window(&m_bindings, &m_d3d12)
, m_d3d12(m_window, m_paths, m_options)
, m_vm(m_paths, m_bindings, m_d3d12, m_options)
, m_vm(m_paths, m_bindings, m_d3d12)
, m_overlay(m_d3d12, m_bindings, m_options, m_vm)
, m_tasks(m_options)
{
m_bindings.ConnectUpdate(m_d3d12);

m_vm.Initialize();
}

CET::~CET()
{
s_isRunning = false;

m_bindings.DisconnectUpdate(m_d3d12);
m_bindings.Clear();
}
14 changes: 7 additions & 7 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Image::Initialize()

auto* pImage = GetModuleHandle(nullptr);

auto sectionHeaders = mainModule.section_headers();
const auto sectionHeaders = mainModule.section_headers();

base_address = reinterpret_cast<uintptr_t>(pImage);

Expand All @@ -58,14 +58,14 @@ void Image::Initialize()

auto& dosHeader = mainModule.dos_header();
auto* pFileHeader = reinterpret_cast<IMAGE_FILE_HEADER*>(base_address + dosHeader.e_lfanew + 4);
auto* pOptionalHeader = reinterpret_cast<IMAGE_OPTIONAL_HEADER*>(((char*)pFileHeader) + sizeof(IMAGE_FILE_HEADER));
auto* pDataDirectory = &pOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG];
auto* pDebugDirectory = reinterpret_cast<IMAGE_DEBUG_DIRECTORY*>(base_address + pDataDirectory->VirtualAddress);
const auto* pOptionalHeader = reinterpret_cast<IMAGE_OPTIONAL_HEADER*>(reinterpret_cast<char*>(pFileHeader) + sizeof(IMAGE_FILE_HEADER));
const auto* pDataDirectory = &pOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG];
const auto* pDebugDirectory = reinterpret_cast<IMAGE_DEBUG_DIRECTORY*>(base_address + pDataDirectory->VirtualAddress);

// Check to see that the data has the right type
if (IMAGE_DEBUG_TYPE_CODEVIEW == pDebugDirectory->Type)
{
PdbInfo* pdb_info = (PdbInfo*)(base_address + pDebugDirectory->AddressOfRawData);
auto* pdb_info = reinterpret_cast<PdbInfo*>(base_address + pDebugDirectory->AddressOfRawData);
if (0 == memcmp(&pdb_info->Signature, "RSDS", 4))
{
for (const auto& v : cVersions)
Expand All @@ -79,8 +79,8 @@ void Image::Initialize()

if (version == 0)
{
for (auto c : pdb_info->Guid)
Log::Error("{:X}", (uint32_t)c);
for (const auto c : pdb_info->Guid)
Log::Error("{:X}", static_cast<uint32_t>(c));

throw std::runtime_error("Abort loading");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ struct Image
return std::make_tuple(1, 60);
}

static uint64_t MakeVersion(uint32_t aMajor, uint16_t aMinor) noexcept
static uint64_t MakeVersion(const uint32_t acMajor, const uint16_t acMinor) noexcept
{
return static_cast<uint64_t>(aMajor) << 32 | static_cast<uint64_t>(aMinor) << 16;
return static_cast<uint64_t>(acMajor) << 32 | static_cast<uint64_t>(acMinor) << 16;
}

[[nodiscard]] std::tuple<uint32_t, uint16_t> GetVersion() const noexcept
Expand Down
43 changes: 24 additions & 19 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

void Options::Load()
{
if (exists(m_paths.Config()))
const auto path = GetAbsolutePath(m_paths.Config(), "", false);
if (!path.empty())
{
std::ifstream configFile(m_paths.Config());
std::ifstream configFile(path);
if(configFile)
{
auto config = nlohmann::json::parse(configFile);
const auto config = nlohmann::json::parse(configFile);
PatchRemovePedestrians = config.value("remove_pedestrians", PatchRemovePedestrians);
PatchSkipStartMenu = config.value("skip_start_menu", PatchSkipStartMenu);
PatchAmdSmt = config.value("amd_smt", PatchAmdSmt);
Expand All @@ -23,7 +24,7 @@ void Options::Load()
PatchMinimapFlicker = config.value("minimap_flicker", PatchMinimapFlicker);

RemoveDeadBindings = config.value("cetdev_remove_dead_bindings", RemoveDeadBindings);
EnableImGuiAssertions = config.value("cetdev_enable_imgui_assertions", EnableImGuiAssertions);
EnableImGuiAssertionsLogging = config.value("cetdev_enable_imgui_assertions_logging", EnableImGuiAssertionsLogging);
DumpGameOptions = config.value("dump_game_options", DumpGameOptions);
PatchEnableDebug = config.value("enable_debug", PatchEnableDebug);

Expand All @@ -40,7 +41,7 @@ void Options::Load()
}

// set global "Enable ImGui Assertions"
g_ImGuiAssertionsEnabled = EnableImGuiAssertions;
g_ImGuiAssertionsEnabled = EnableImGuiAssertionsLogging;
}

void Options::Save()
Expand All @@ -59,19 +60,20 @@ void Options::Save()
config["minimap_flicker"] = PatchMinimapFlicker;

config["cetdev_remove_dead_bindings"] = RemoveDeadBindings;
config["cetdev_enable_imgui_assertions"] = EnableImGuiAssertions;
config["cetdev_enable_imgui_assertions_logging"] = EnableImGuiAssertionsLogging;
config["enable_debug"] = PatchEnableDebug;
config["dump_game_options"] = DumpGameOptions;

config["font_path"] = FontPath;
config["font_glyph_ranges"] = FontGlyphRanges;
config["font_size"] = FontSize;

std::ofstream o(m_paths.Config());
const auto path = GetAbsolutePath(m_paths.Config(), "", true);
std::ofstream o(path);
o << config.dump(4) << std::endl;

// set global "Enable ImGui Assertions"
g_ImGuiAssertionsEnabled = EnableImGuiAssertions;
g_ImGuiAssertionsEnabled = EnableImGuiAssertionsLogging;
}

void Options::ResetToDefaults()
Expand All @@ -88,21 +90,25 @@ void Options::ResetToDefaults()
PatchMinimapFlicker = false;

RemoveDeadBindings = true;
EnableImGuiAssertions = false;
EnableImGuiAssertionsLogging = false;
PatchEnableDebug = false;
DumpGameOptions = false;

FontPath = "";
FontGlyphRanges = "Default";
FontSize = 18.0f;

Save();
}

Options::Options(Paths& aPaths)
: m_paths(aPaths)
{
const auto* exePathStr = aPaths.Executable().native().c_str();
int verInfoSz = GetFileVersionInfoSize(exePathStr, nullptr);
const auto verInfoSz = GetFileVersionInfoSize(exePathStr, nullptr);
if(verInfoSz)
{
auto verInfo = std::make_unique<BYTE[]>(verInfoSz);
const auto verInfo = std::make_unique<BYTE[]>(verInfoSz);
if(GetFileVersionInfo(exePathStr, 0, verInfoSz, verInfo.get()))
{
struct
Expand Down Expand Up @@ -131,13 +137,12 @@ Options::Options(Paths& aPaths)
}
}
// check if exe name matches in case previous check fails
ExeValid = ExeValid || (aPaths.Executable().filename() == "Cyberpunk2077.exe");
ExeValid = ExeValid || aPaths.Executable().filename() == "Cyberpunk2077.exe";

if (!ExeValid)
throw std::runtime_error("Not Cyberpunk2077.exe");

set_default_logger(CreateLogger(m_paths.CETRoot() / "cyber_engine_tweaks.log", "main"));

set_default_logger(CreateLogger(GetAbsolutePath(L"cyber_engine_tweaks.log", m_paths.CETRoot(), true), "main", nullptr, "[%Y-%m-%d %H:%M:%S UTC%z] [%l] [%!] [%t] %v"));

Log::Info("Cyber Engine Tweaks is starting...");

Expand All @@ -148,13 +153,13 @@ Options::Options(Paths& aPaths)
Log::Info("CET version {} [{}]", CET_BUILD_COMMIT, CET_BUILD_BRANCH);
auto [major, minor] = GameImage.GetVersion();
Log::Info("Game version {}.{:02d}", major, minor);
Log::Info("Root path: \"{}\"", aPaths.GameRoot().string());
Log::Info("Cyber Engine Tweaks path: \"{}\"", aPaths.CETRoot().string());
Log::Info("Lua scripts search path: \"{}\"", aPaths.ModsRoot().string());
Log::Info("Root path: \"{}\"", UTF16ToUTF8(aPaths.GameRoot().native()));
Log::Info("Cyber Engine Tweaks path: \"{}\"", UTF16ToUTF8(aPaths.CETRoot().native()));
Log::Info("Lua scripts search path: \"{}\"", UTF16ToUTF8(aPaths.ModsRoot().native()));

if (GameImage.GetVersion() != GameImage.GetSupportedVersion())
if (GameImage.GetVersion() != Image::GetSupportedVersion())
{
auto [smajor, sminor] = GameImage.GetSupportedVersion();
const auto [smajor, sminor] = Image::GetSupportedVersion();
Log::Error("Unsupported game version! Only {}.{:02d} is supported.", smajor, sminor);
throw std::runtime_error("Unsupported version");
}
Expand Down
Loading

0 comments on commit df47802

Please sign in to comment.