Skip to content

Commit

Permalink
vanguard patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Mar 28, 2024
1 parent 86ba488 commit dc06972
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/buildit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
run: |
curl --output C:/qt5.7z -L "https://github.com/LoL-Fantome/lolcustomskin-tools/releases/download/release23/qt5.15.5-x86_64-msvc-static.7z"
7z x -oC:/ C:/qt5.7z
- name: "Download patcher"
shell: bash
run: |
curl --output cslol-patcher.zip -L "https://github.com/LeagueToolkit/cslol-patcher/releases/latest/download/cslol-patcher.zip"
7z x -o./cslol-tools/ cslol-patcher.zip
- name: "Build"
run: |
mkdir build
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
run: |
curl --output C:/qt5.7z -L "https://github.com/LoL-Fantome/lolcustomskin-tools/releases/download/release23/qt5.15.5-x86_64-msvc-static.7z"
7z x -oC:/ C:/qt5.7z
- name: "Download patcher"
shell: bash
run: |
curl --output cslol-patcher.zip -L "https://github.com/LeagueToolkit/cslol-patcher/releases/latest/download/cslol-patcher.zip"
7z x -o./cslol-tools/ cslol-patcher.zip
- name: "Build"
run: |
mkdir build
Expand Down
17 changes: 17 additions & 0 deletions cslol-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,20 @@ add_executable(wad-make
src/main_wad_make.cpp
)
target_link_libraries(wad-make PRIVATE cslol-lib)

if (WIN32)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/cslol-patcher")
add_library(cslol-patcher SHARED IMPORTED)
set_target_properties(cslol-patcher PROPERTIES
IMPORTED_IMPLIB ${CMAKE_CURRENT_LIST_DIR}/cslol-patcher/cslol-dll.lib
IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/cslol-patcher/cslol-dll.dll
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/cslol-patcher/
)
target_link_libraries(cslol-lib PUBLIC cslol-patcher)
add_custom_command(TARGET mod-tools POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:mod-tools> $<TARGET_RUNTIME_DLLS:mod-tools>
COMMAND_EXPAND_LISTS
)
endif()
endif()

70 changes: 69 additions & 1 deletion cslol-tools/lib/lol/patcher/patcher_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,23 @@ static auto skinhack_detected() -> char const* {
lol_throw_msg("NEW PATCH DETECTED, THIS IS NOT AN ERROR!\n");
}

static auto new_patcher(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path,
fs::names const& opts) -> bool;

auto patcher::run(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path,
fs::names const& opts) -> void {

lol_throw_if(skinhack_detected());
for (auto const& o : opts) {
if (o == "dllpatcher") {
if (new_patcher(std::move(update), profile_path, config_path, game_path, opts)) return;
}
}
auto ctx = Context{};
ctx.set_prefix(profile_path);
ctx.kernel32 = Kernel32::load();
Expand Down Expand Up @@ -392,4 +402,62 @@ auto patcher::run(std::function<void(Message, char const*)> update,
}
}

# if !__has_include("cslol-api.h")
static auto new_patcher(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path,
fs::names const& opts) -> bool {
return false;
}
# else
# include "cslol-api.h"
static auto new_patcher(std::function<void(Message, char const*)> update,
fs::path const& profile_path,
fs::path const& config_path,
fs::path const& game_path,
fs::names const& opts) -> bool {
// Initialize first proces.
lol_throw_if(cslol_init());
lol_throw_if(cslol_set_flags(CSLOL_HOOK_DISALBE_NONE));
lol_throw_if(cslol_set_log_level(CSLOL_LOG_INFO));
lol_throw_if(cslol_set_config(profile_path.generic_u16string().c_str()));

for (;;) {
auto tid = run_until_or(
30s,
Intervals{10ms},
[&] {
update(M_WAIT_START, "");
return cslol_find();
},
[]() -> std::uint32_t { return 0; });
if (!tid) {
continue;
}

// Signal that process has been found.
update(M_FOUND, "");

// Hook in 30 seconds or error.
lol_throw_if(cslol_hook(tid, 30000, 100));

// Wait for exit.
update(M_WAIT_EXIT, "");
run_until_or(
3h,
Intervals{5s, 10s, 15s},
[&, tid] {
char const* msg = NULL;
while ((msg = cslol_log_pull())) {
// post log message
update(M_WAIT_EXIT, msg);
}
if (!msg) update(M_WAIT_EXIT, "");
return tid != cslol_find();
},
[]() -> bool { throw PatcherTimeout(std::string("Timed out exit")); });
}
}
# endif
#endif
7 changes: 7 additions & 0 deletions cslol-tools/src/main_mod_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ static auto mod_runoverlay(fs::path overlay, fs::path config_file, fs::path game
*lock = false;
}
}
if (msg == patcher::M_WAIT_EXIT) {
if (arg && *arg) {
fprintf(stdout, "patcher: %s\n", arg);
fflush(stdout);
old_msg = patcher::M_COUNT_OF;
}
}
},
overlay,
config_file,
Expand Down
1 change: 1 addition & 0 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ copy2folder() {
cp "./LICENSE" "$2"

cp "$1/cslol-tools/"*.exe "$2/cslol-tools"
cp "$1/cslol-tools/"*.dll "$2/cslol-tools"
cp "$1/cslol-manager.exe" "$2"
echo "windeployqt is only necessary for non-static builds"
windeployqt --qmldir "src/qml" "$2/cslol-manager.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/CSLOLTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CSLOLTools : public QObject {
void deleteMod(QString name);
void exportMod(QString name, QString dest);
void installFantomeZip(QString path);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict, bool experimentalDll);
void loadProfile(QString name);
void deleteProfile(QString name);
void stopProfile();
Expand Down
4 changes: 2 additions & 2 deletions src/CSLOLToolsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void CSLOLToolsImpl::doUpdate(QString urls) {
}
}

void CSLOLToolsImpl::saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict) {
void CSLOLToolsImpl::saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict, bool experimentalDll) {
if (state_ == CSLOLState::StateIdle) {
setState(CSLOLState::StateBusy);

Expand Down Expand Up @@ -541,7 +541,7 @@ void CSLOLToolsImpl::saveProfile(QString name, QJsonObject mods, bool run, bool
prog_ + "/profiles/" + name,
prog_ + "/profiles/" + name + ".config",
"--game:" + game_,
"--opts:" + QString("none"),
"--opts:" + QString(experimentalDll ? "dllpatcher" : "none"),
});
} else {
setState(CSLOLState::StateIdle);
Expand Down
2 changes: 1 addition & 1 deletion src/CSLOLToolsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public slots:
void deleteMod(QString name);
void exportMod(QString name, QString dest);
void installFantomeZip(QString path);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict);
void saveProfile(QString name, QJsonObject mods, bool run, bool skipConflict, bool experimentalDll);
void loadProfile(QString name);
void deleteProfile(QString name);
void stopProfile();
Expand Down
7 changes: 7 additions & 0 deletions src/qml/CSLOLDialogSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Dialog {
property alias enableSystray: enableSystrayCheck.checked
property alias enableAutoRun: enableAutoRunCheck.checked
property alias updateUrls: updateUrlsTextArea.text
property alias experimentalDll: experimentalDllCheck.checked

property var colors_LIST: [
"Red",
Expand Down Expand Up @@ -115,6 +116,12 @@ Dialog {
checked: false
Layout.fillWidth: true
}
Switch {
id: experimentalDllCheck
text: qsTr("Experimental dll patcher(might result in bans)")
checked: false
Layout.fillWidth: true
}
}

ColumnLayout {
Expand Down
3 changes: 2 additions & 1 deletion src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ApplicationWindow {
property alias themeDarkMode: cslolDialogSettings.themeDarkMode
property alias themePrimaryColor: cslolDialogSettings.themePrimaryColor
property alias themeAccentColor: cslolDialogSettings.themeAccentColor
property alias experimentalDll: cslolDialogSettings.experimentalDll

property alias removeUnknownNames: cslolDialogEditMod.removeUnknownNames
property alias lastZipDirectory: cslolDialogOpenZipFantome.folder
Expand Down Expand Up @@ -97,7 +98,7 @@ ApplicationWindow {
let name = cslolToolBar.profilesCurrentName
let mods = cslolModsView.saveProfile()
if (checkGamePath()) {
cslolTools.saveProfile(name, mods, run, settings.suppressInstallConflicts)
cslolTools.saveProfile(name, mods, run, settings.suppressInstallConflicts, settings.experimentalDll)
}
}

Expand Down

1 comment on commit dc06972

@merto352
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HOW CAN I DOWLAND THAT AND WHAT SHOULD I DO AFTER I DOWNLAND

Please sign in to comment.