├── .gitattributes ├── .github └── workflows │ └── cmake-single-platform.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeSettings.json ├── LICENSE ├── README.md ├── Resource.rc ├── lantern ├── InternalHooks │ ├── Minecraft.cpp │ └── Minecraft.h ├── Lantern.cpp ├── Lantern.h ├── LanternMod.h ├── ModSettings.cpp ├── ModSettings.h ├── Util │ ├── Event.cpp │ ├── Event.h │ ├── HookHelper.h │ ├── Logger.cpp │ └── Logger.h ├── framework.h ├── pch.cpp └── pch.h ├── lib └── detours │ └── CMakeLists.txt └── resource.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/cmake-single-platform.yml: -------------------------------------------------------------------------------- 1 | # This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. 2 | # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml 3 | name: CMake on a single platform 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | pull_request: 9 | branches: [ "main" ] 10 | 11 | env: 12 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 13 | BUILD_TYPE: Release 14 | 15 | jobs: 16 | build: 17 | # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. 18 | # You can convert this to a matrix build if you need cross-platform coverage. 19 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 20 | runs-on: windows-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | with: 25 | submodules: recursive 26 | 27 | - name: Configure CMake 28 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 29 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 30 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 31 | 32 | - name: Build 33 | # Build your program with the given configuration 34 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 35 | 36 | - name: Upload build artifacts 37 | uses: actions/upload-artifact@v4 38 | with: 39 | name: Lantern 40 | path: ${{github.workspace}}\build\Release 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | 365 | # Lantern 366 | out 367 | lantern/Util/LogFile* 368 | lantern/Util/DrogAndDrap* 369 | /.idea 370 | *.kate-swp 371 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Detours"] 2 | path = lib/detours/detours 3 | url = https://github.com/microsoft/Detours.git 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 2 | set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) 3 | 4 | cmake_minimum_required(VERSION 3.29) 5 | project(Lantern) 6 | set (CMAKE_CXX_STANDARD 20) 7 | 8 | include(FetchContent) 9 | FetchContent_Declare( 10 | yaml-cpp 11 | GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git 12 | GIT_TAG master 13 | ) 14 | FetchContent_MakeAvailable(yaml-cpp) 15 | 16 | set(SRC_FILES 17 | resource.h 18 | Resource.rc 19 | 20 | lantern/pch.h 21 | lantern/pch.cpp 22 | lantern/framework.h 23 | lantern/Lantern.cpp 24 | lantern/Lantern.h 25 | lantern/LanternMod.h 26 | 27 | lantern/Util/Event.cpp 28 | lantern/Util/Event.h 29 | lantern/Util/HookHelper.h 30 | lantern/Util/Logger.cpp 31 | lantern/Util/Logger.h 32 | 33 | lantern/InternalHooks/Minecraft.cpp 34 | lantern/InternalHooks/Minecraft.h 35 | "lantern/ModSettings.h" "lantern/ModSettings.cpp") 36 | 37 | include_directories(lantern ${CMAKE_SOURCE_DIR}/lib/detours/include) 38 | 39 | include(GenerateExportHeader) 40 | 41 | add_subdirectory(lib/detours/) 42 | 43 | add_library(Lantern SHARED ${SRC_FILES}) 44 | 45 | generate_export_header(Lantern) 46 | 47 | set_target_properties(Lantern 48 | PROPERTIES 49 | DEFINE_SYMBOL "LANTERN_EXPORTS" 50 | ) 51 | 52 | target_link_libraries(Lantern PUBLIC lib_detours) 53 | target_link_libraries(Lantern PUBLIC yaml-cpp::yaml-cpp) -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Release", 5 | "generator": "Ninja", 6 | "configurationType": "RelWithDebInfo", 7 | "buildRoot": "${projectDir}\\out\\build\\${name}", 8 | "installRoot": "${projectDir}\\out\\install\\${name}", 9 | "cmakeCommandArgs": "", 10 | "buildCommandArgs": "", 11 | "ctestCommandArgs": "", 12 | "inheritEnvironments": [ "msvc_x64_x64" ] 13 | }, 14 | { 15 | "name": "x64-Debug", 16 | "generator": "Ninja", 17 | "configurationType": "Debug", 18 | "buildRoot": "${projectDir}\\out\\build\\${name}", 19 | "installRoot": "${projectDir}\\out\\install\\${name}", 20 | "cmakeCommandArgs": "", 21 | "buildCommandArgs": "", 22 | "ctestCommandArgs": "", 23 | "inheritEnvironments": [ "msvc_x64_x64" ], 24 | "variables": [] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 LanternLCE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lantern 2 | A Minecraft: Xbox One Edition modloader 3 | 4 | > [!NOTE] 5 | > Much more work than this has been done but I had to rethink the entire plan as I was just doing it plain wrong (am C++ beginner and learning C++ almost completely due to this project + modding LCE) 6 | > Code quality might be messy. 7 | 8 | ## Roadmap 9 | 10 | - [ ] Torch API 11 | - Literally the entire API, will take a while. 12 | - [ ] Proper logging 13 | - [X] Example mod 14 | - [ ] Events -------------------------------------------------------------------------------- /Resource.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LanternLCE/Lantern/4f161c66580e3f77f338865666d2bd3db8911267/Resource.rc -------------------------------------------------------------------------------- /lantern/InternalHooks/Minecraft.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Minecraft.h" 3 | 4 | MINECRAFT_EVENT Event* Minecraft::onMain = new Event(); 5 | 6 | int Minecraft::main(int _Argc, char** _Argv, char** _Env) 7 | { 8 | onMain->fire(); 9 | return Minecraft_main(_Argc, _Argv, _Env); 10 | } 11 | -------------------------------------------------------------------------------- /lantern/InternalHooks/Minecraft.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "Util/Logger.h" 7 | #include "Util/HookHelper.h" 8 | #include "Util/Event.h" 9 | 10 | #ifdef LANTERN_EXPORTS 11 | #define MINECRAFT_EVENT __declspec(dllexport) 12 | #else 13 | #define MINECRAFT_EVENT __declspec(dllimport) 14 | #endif 15 | 16 | class Minecraft { 17 | public: 18 | /// 19 | /// An event provided for mods to initialize things that depend on the game having started. 20 | /// 21 | /// For example, trying to access UWP before main has been called does not work. 22 | /// 23 | static MINECRAFT_EVENT Event* onMain; 24 | 25 | static int main(int _Argc, char** _Argv, char** _Env); 26 | }; 27 | 28 | CREATE_FUNC(Minecraft_main, 0x1408a7570, int, int _Argc, char** _Argv, char** _Env); -------------------------------------------------------------------------------- /lantern/Lantern.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | #include 4 | #include "Util/Logger.h" 5 | #include 6 | #include 7 | #include "LanternMod.h" 8 | #include "Lantern.h" 9 | #include "Util/HookHelper.h" 10 | #include "InternalHooks/Minecraft.h" 11 | #include 12 | 13 | // TODO: When events happen, register internal event for mod menu uiscene 14 | 15 | //const LANTERN_API LogFile* Lantern::logFile; 16 | const std::string MODS_DIR = "./mods/LanternMods"; 17 | 18 | LANTERN_CLASS Lantern::Version Lantern::version = Lantern::Version(LANTERN_VERSION); 19 | 20 | // internal hooks 21 | std::vector> hooks; 22 | std::vector mods; 23 | 24 | typedef LanternMod* (*Initialize)(); 25 | typedef uint64_t(*GetTargetedLanternVersion)(); 26 | 27 | 28 | void registerMod(const std::filesystem::directory_entry& path) { 29 | HINSTANCE dll = LoadLibraryW(path.path().c_str()); 30 | 31 | if (!dll) { 32 | LOGW(L"Couldn't load mod ", path.path().c_str()); 33 | return; 34 | } 35 | 36 | Initialize init = (Initialize)GetProcAddress(dll, "Initialize"); 37 | if (!init) { 38 | LOGW(L"Couldn't find init function in mod ", path.path().c_str()); 39 | return; 40 | } 41 | 42 | bool notLegacy = false; 43 | 44 | LanternMod* mod = init(); 45 | mods.push_back(mod); 46 | 47 | uint64_t modLanternVersion = mod->GetTargetedLanternVersion(); 48 | 49 | if (modLanternVersion != Lantern::version.GetPackedVersion()) { 50 | LOGW_C(ANSIColor::YELLOW, L"Mod '", mod->GetName(), L"' was built for a different version of Lantern (v", Lantern::Version::Version(modLanternVersion).GetVersionString(), L"). You are running Lantern v", Lantern::version.GetVersionString()); 51 | } 52 | 53 | LOGW(L"Loaded mod '", mod->GetName(), L"' v", mod->GetVersion(), L" by '", mod->GetAuthorName(), L"'"); 54 | 55 | mod->Enable(); 56 | } 57 | 58 | BOOL APIENTRY DllMain(HMODULE hModule, 59 | DWORD callReason, 60 | LPVOID lpReserved) { 61 | // for funny ansi shit 62 | HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); 63 | DWORD dwMode = 0; 64 | GetConsoleMode(hOut, &dwMode); 65 | SetConsoleMode(hOut, dwMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); 66 | if (DetourIsHelperProcess()) { 67 | return TRUE; 68 | }; 69 | 70 | switch (callReason) 71 | { 72 | case DLL_PROCESS_ATTACH: { 73 | // drog and drap, from the desktop 74 | winrt::init_apartment(); 75 | LOGW_C(ANSIColor::GREEN, L"Starting Lantern v", Lantern::version.GetVersionString()); 76 | 77 | winrt::Windows::Storage::StorageFolder folder = (winrt::Windows::Storage::ApplicationData::Current()).LocalFolder(); 78 | std::filesystem::path lanternDir = std::filesystem::path(folder.Path().c_str()) / "Lantern"; 79 | 80 | if (!std::filesystem::exists(lanternDir)) { 81 | std::filesystem::create_directories(lanternDir); 82 | LOGW(L"Created Lantern config dir at ", lanternDir); 83 | } 84 | ModSettings* settings = new ModSettings(L"lantern"); 85 | 86 | LOG_C(ANSIColor::GREEN, "Registering internal hooks"); 87 | registerHook(&(PVOID&)Minecraft_main, &Minecraft::main); 88 | 89 | LOG_C(ANSIColor::GREEN, "Loading mods"); 90 | if (!std::filesystem::exists(MODS_DIR)) 91 | std::filesystem::create_directories(MODS_DIR); 92 | 93 | for (const std::filesystem::directory_entry& f : std::filesystem::directory_iterator(MODS_DIR)) { 94 | if (f.is_regular_file()) 95 | registerMod(f); 96 | } 97 | break; 98 | } 99 | case DLL_PROCESS_DETACH: { 100 | for (LanternMod* mod : mods) { 101 | mod->Disable(); 102 | } 103 | break; 104 | } 105 | default: break; 106 | } 107 | 108 | return TRUE; 109 | } 110 | 111 | Lantern::Version::Version(std::wstring version) 112 | { 113 | std::wstringstream ss(version); 114 | std::wstring ver; 115 | int verIdx = 0; 116 | 117 | while (std::getline(ss, ver, L'.') && verIdx < 4) { 118 | try { 119 | short value = static_cast(std::stoi(ver)); 120 | 121 | switch (verIdx) { 122 | case 0: major = value; break; 123 | case 1: minor = value; break; 124 | case 2: build = value; break; 125 | case 3: patch = value; break; 126 | } 127 | } 128 | catch (const std::invalid_argument& e) { 129 | LOGW(L"Invalid number in version string"); 130 | } 131 | catch (const std::out_of_range& e) { 132 | LOGW(L"Version number too big for a short"); 133 | } 134 | catch (const std::exception& e) { 135 | LOGW(L"Couldn't parse ver string: ", e.what()); 136 | } 137 | verIdx++; 138 | } 139 | } 140 | 141 | Lantern::Version::Version(uint16_t major, uint16_t minor, uint16_t build, uint16_t patch) : major(major), minor(minor), build(build), patch(patch) {} 142 | 143 | Lantern::Version::Version(uint64_t packed) 144 | { 145 | major = packed >> 48; 146 | minor = (packed >> 32) & 0xFFFF; 147 | build = (packed >> 16) & 0xFFFF; 148 | patch = packed & 0xFFFF; 149 | } 150 | 151 | uint64_t Lantern::Version::GetPackedVersion() 152 | { 153 | return ((uint64_t)major << 48) | ((uint64_t)minor << 32) | ((uint64_t)build << 16) | (uint64_t)patch; 154 | } 155 | 156 | std::wstring Lantern::Version::GetVersionString() 157 | { 158 | std::wstringstream ss; 159 | ss << major << L"." << minor << L"." << build << L"." << patch; 160 | return ss.str(); 161 | } 162 | 163 | -------------------------------------------------------------------------------- /lantern/Lantern.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef LANTERN_EXPORTS 4 | #define LANTERN_CLASS __declspec(dllexport) 5 | #else 6 | #define LANTERN_CLASS __declspec(dllimport) 7 | #endif 8 | 9 | //#include "Util/LogFile.h"; 10 | 11 | class Lantern { 12 | public: 13 | #define LANTERN_VERSION L"1.2.0.0" 14 | 15 | static class LANTERN_CLASS Version { 16 | public: 17 | uint16_t major; 18 | uint16_t minor; 19 | uint16_t build; 20 | uint16_t patch; 21 | 22 | Version(std::wstring version); 23 | Version(uint16_t major, uint16_t minor, uint16_t build, uint16_t patch); 24 | Version(uint64_t packed); 25 | uint64_t GetPackedVersion(); 26 | std::wstring GetVersionString(); 27 | }; 28 | 29 | static LANTERN_CLASS Version version; 30 | }; -------------------------------------------------------------------------------- /lantern/LanternMod.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef LANTERN_EXPORTS 4 | #define LANTERNMOD_CLASS __declspec(dllexport) 5 | #else 6 | #define LANTERNMOD_CLASS __declspec(dllimport) 7 | #endif 8 | 9 | #include 10 | #include 11 | class LanternMod { 12 | public: 13 | /// 14 | /// Runs when the mod is enabled 15 | /// 16 | virtual void Enable() = 0; 17 | /// 18 | /// Runs when the mod is disabled 19 | /// 20 | virtual void Disable() = 0; 21 | // TODO: maybe replace with Version class? 22 | /// 23 | /// Gets the mod version 24 | /// 25 | virtual std::wstring GetVersion() { 26 | return L"0.0.0"; 27 | }; 28 | /// 29 | /// Gets the mod name. 30 | /// If none is present, it returns the mod ID. 31 | /// 32 | virtual std::wstring GetName() { 33 | return GetID(); 34 | }; 35 | /// 36 | /// Gets the mod description. 37 | /// 38 | virtual std::wstring GetDescription() { 39 | return L""; 40 | }; 41 | /// 42 | /// Gets the mod author 43 | /// 44 | virtual std::wstring GetAuthorName() { 45 | return L"Unknown"; 46 | }; 47 | /// 48 | /// Gets the mod ID 49 | /// 50 | virtual std::wstring GetID() { 51 | return L"lantern_default_mod_id_changeme"; 52 | }; 53 | /// 54 | /// Gets the version of Lantern the mod was made for 55 | /// Overriding is discouraged as the Lantern version is already set when you build a mod. 56 | /// 57 | virtual uint64_t GetTargetedLanternVersion() { 58 | return Lantern::Version::Version(LANTERN_VERSION).GetPackedVersion(); 59 | }; 60 | }; -------------------------------------------------------------------------------- /lantern/ModSettings.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LanternLCE/Lantern/4f161c66580e3f77f338865666d2bd3db8911267/lantern/ModSettings.cpp -------------------------------------------------------------------------------- /lantern/ModSettings.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ModSettings { 10 | std::filesystem::path settingsPath; 11 | 12 | public: 13 | ModSettings(std::wstring name) { 14 | winrt::Windows::Storage::StorageFolder folder = (winrt::Windows::Storage::ApplicationData::Current()).LocalFolder(); 15 | std::filesystem::path lanternDir = std::filesystem::path(folder.Path().c_str()) / "Lantern"; 16 | 17 | std::filesystem::path configPath = lanternDir / "config"; 18 | if (!std::filesystem::exists(configPath)) 19 | std::filesystem::create_directories(configPath); 20 | 21 | settingsPath = configPath / (name + L".yml"); 22 | if (!std::filesystem::exists(settingsPath)) { 23 | std::ofstream file(settingsPath); 24 | file.close(); 25 | } 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /lantern/Util/Event.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Event.h" 3 | -------------------------------------------------------------------------------- /lantern/Util/Event.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #ifdef LANTERN_EXPORTS 6 | #define EVENT_API __declspec(dllexport) 7 | #else 8 | #define EVENT_API __declspec(dllimport) 9 | #endif 10 | 11 | /// 12 | /// Very barebones Event class. 13 | /// 14 | /// Allows for listeners to be registered and for all listeners to be later called. 15 | /// 16 | class EVENT_API Event { 17 | private: 18 | std::vector> listeners; 19 | public: 20 | /// 21 | /// Adds a listener to be called when the event is fired 22 | /// 23 | /// The method that will get called when fired 24 | void addEventListener(const std::function& listener) { 25 | listeners.push_back(listener); 26 | } 27 | 28 | // TODO: Does not exist for some reason (can't compare functions) 29 | ///// 30 | ///// Removes a listener from the registered listeners vector 31 | ///// 32 | ///// The listener that should be removed 33 | //void removeEventListener(const std::function& listener) { 34 | // listeners.erase(std::remove(listeners.begin(), listeners.end(), listener), listeners.end()); 35 | //} 36 | 37 | /// 38 | /// Fires an event, which will call all listeners. 39 | /// 40 | void fire() { 41 | for (const auto& listener : listeners) { 42 | listener(); 43 | } 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /lantern/Util/HookHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "framework.h" 4 | 5 | #ifdef LANTERN_EXPORTS 6 | #define ADDRHELPER_API __declspec(dllexport) 7 | #else 8 | #define ADDRHELPER_API __declspec(dllimport) 9 | #endif 10 | 11 | // TODO: Somehow make it more clear that they need to make this, or find a different way to store a hook registry 12 | extern std::vector> hooks; 13 | 14 | /// Gets the address within memory from the executable's address 15 | #define GET_ADDRESS(addr) ((reinterpret_cast(GetModuleHandleW(NULL))) + ((addr) - 0x140000000)) 16 | /// Gets the address within the executable from a memory address 17 | #define GET_ORIG_ADDRESS(addr) (((addr) - reinterpret_cast(GetModuleHandleW(NULL))) + 0x140000000) 18 | /// 19 | /// Defines a function that can be called and hooked into. 20 | /// 21 | /// The name that you want to use when referring to the original game function 22 | /// The address of the function relative to the program 23 | /// The return type of the function 24 | /// The arguments of the function 25 | #define CREATE_FUNC(name, addr, returnType, ...) \ 26 | using t##name = returnType(__fastcall*)(__VA_ARGS__); \ 27 | inline t##name name = reinterpret_cast(GET_ADDRESS(addr)); 28 | 29 | using VTable = void(*)(); 30 | 31 | /// 32 | /// Registers a hook 33 | /// 34 | /// The original function found within MC, defined using CREATE_FUNC 35 | /// The hook/replacement function, has to be static. 36 | /// 37 | inline LONG registerHook(PVOID* orig, PVOID hook) { 38 | DetourTransactionBegin(); 39 | DetourUpdateThread(GetCurrentThread()); 40 | LONG att = DetourAttach(orig, hook); 41 | hooks.push_back(std::tuple(orig, hook)); 42 | DetourTransactionCommit(); 43 | return att; 44 | } 45 | 46 | /// 47 | /// Unregisters a hook 48 | /// 49 | /// The original function found within MC, defined using CREATE_FUNC 50 | /// The hook/replacement function, has to be static. 51 | /// 52 | inline LONG unregisterHook(PVOID* orig, PVOID hook) { 53 | DetourTransactionBegin(); 54 | DetourUpdateThread(GetCurrentThread()); 55 | LONG att = DetourDetach(orig, hook); 56 | hooks.erase(std::remove(hooks.begin(), hooks.end(), std::tuple(orig, hook)), hooks.end()); 57 | DetourTransactionCommit(); 58 | return att; 59 | } 60 | 61 | /// 62 | /// Registers a hook 63 | /// 64 | /// The original function found within MC, defined using CREATE_FUNC 65 | /// The hook/replacement function, has to be static. 66 | /// The function to call when the hook is registered 67 | /// 68 | inline LONG registerHook(PVOID* orig, PVOID hook, void (*onRegister)()) { 69 | LONG att = registerHook(orig, hook); 70 | onRegister(); 71 | return att; 72 | } 73 | 74 | /// 75 | /// Registers a vector of hooks 76 | /// 77 | /// A vector of tuples (PVOID* orig, PVOID hook, void (*onRegister)()) 78 | /// The original function found within MC, defined using CREATE_FUNC 79 | /// The hook/replacement function, has to be static. 80 | /// The function to call when the hook is registered 81 | /// 82 | inline void registerHooks(std::vector> hooks_vec) { 83 | DetourTransactionBegin(); 84 | DetourUpdateThread(GetCurrentThread()); 85 | for (auto hook : hooks_vec) { 86 | LONG att = DetourAttach(std::get<0>(hook), std::get<1>(hook)); 87 | hooks.push_back(std::tuple(std::get<0>(hook), std::get<1>(hook))); 88 | void (*onRegister)() = std::get<2>(hook); 89 | if (onRegister != nullptr) 90 | onRegister(); 91 | } 92 | 93 | DetourTransactionCommit(); 94 | } 95 | 96 | /// 97 | /// Registers a vector of hooks 98 | /// 99 | /// A vector of tuples (PVOID* orig, PVOID hook, void (*onRegister)()) 100 | /// The original function found within MC, defined using CREATE_FUNC 101 | /// The hook/replacement function, has to be static. 102 | /// The function to call when the hook is registered 103 | /// 104 | inline void registerHooks(std::vector> hooks_vec) { 105 | DetourTransactionBegin(); 106 | DetourUpdateThread(GetCurrentThread()); 107 | for (auto hook : hooks_vec) { 108 | LONG att = DetourAttach(std::get<0>(hook), std::get<1>(hook)); 109 | hooks.push_back(hook); 110 | } 111 | 112 | DetourTransactionCommit(); 113 | } 114 | 115 | /// 116 | /// Unregisters a vector of hooks 117 | /// 118 | /// A vector of tuples (PVOID* orig, PVOID hook, void (*onUnregister)()) 119 | /// The original function found within MC, defined using CREATE_FUNC 120 | /// The hook/replacement function, has to be static. 121 | /// The function to call when the hook is unregistered 122 | /// 123 | inline void unregisterHooks(std::vector> hooks_vec) { 124 | DetourTransactionBegin(); 125 | DetourUpdateThread(GetCurrentThread()); 126 | for (auto hook : hooks_vec) { 127 | LONG att = DetourDetach(std::get<0>(hook), std::get<1>(hook)); 128 | hooks.erase(std::remove(hooks.begin(), hooks.end(), std::tuple(std::get<0>(hook), std::get<1>(hook))), hooks.end()); 129 | 130 | void (*onUnregister)() = std::get<2>(hook); 131 | if (onUnregister != nullptr) 132 | onUnregister(); 133 | } 134 | 135 | DetourTransactionCommit(); 136 | } 137 | 138 | /// 139 | /// Unregisters a vector of hooks 140 | /// 141 | /// A vector of tuples (PVOID* orig, PVOID hook) 142 | /// The original function found within MC, defined using CREATE_FUNC 143 | /// The hook/replacement function, has to be static. 144 | /// 145 | inline void unregisterHooks(std::vector> hooks_vec) { 146 | DetourTransactionBegin(); 147 | DetourUpdateThread(GetCurrentThread()); 148 | for (auto hook : hooks_vec) { 149 | LONG att = DetourDetach(std::get<0>(hook), std::get<1>(hook)); 150 | hooks.erase(std::remove(hooks.begin(), hooks.end(), hook), hooks.end()); 151 | } 152 | 153 | DetourTransactionCommit(); 154 | } -------------------------------------------------------------------------------- /lantern/Util/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "Logger.h" 9 | 10 | std::string ToHex(size_t v) { 11 | std::ostringstream oss; 12 | oss << std::hex << std::uppercase << v; 13 | return oss.str(); 14 | } -------------------------------------------------------------------------------- /lantern/Util/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | //#include "Lantern.h" 6 | 7 | #ifdef LANTERN_EXPORTS 8 | #define LOGGER_API __declspec(dllexport) 9 | #else 10 | #define LOGGER_API __declspec(dllimport) 11 | #endif 12 | 13 | // TODO: Logging to file to be readded when events exist... I need to sleep ASAP. 14 | 15 | enum ANSIColor : uint8_t { 16 | RESET = 0, 17 | BOLD = 1, 18 | ITALIC = 3, 19 | UNDERLINE = 4, 20 | STRIKETHROUGH = 9, 21 | BLACK = 30, 22 | RED = 31, 23 | GREEN = 32, 24 | YELLOW = 33, 25 | BLUE = 34, 26 | MAGENTA = 35, 27 | CYAN = 36, 28 | WHITE = 37, 29 | BLACK_BG = 40, 30 | RED_BG = 41, 31 | GREEN_BG = 42, 32 | YELLOW_BG = 43, 33 | BLUE_BG = 44, 34 | MAGENTA_BG = 45, 35 | CYAN_BG = 46, 36 | WHITE_BG = 47 37 | }; 38 | 39 | // TODO: Log the mod's name 40 | #define LOG(...) log(__func__, __VA_ARGS__) 41 | #define LOGW(...) logw(__func__, __VA_ARGS__) 42 | #define LOG_C(color, ...) log_c(__func__, color, __VA_ARGS__) 43 | #define LOGW_C(color, ...) logw_c(__func__, color, __VA_ARGS__) 44 | 45 | static std::string ToHex(size_t v); 46 | 47 | template 48 | static void log(const char* funcName, const Args&... args) { 49 | std::cout << "\033[96m"; 50 | (std::cout << "[" << funcName << "] "); 51 | std::cout << "\033[0m"; 52 | 53 | std::cout << "\033[36m"; 54 | (std::cout << ... << args); 55 | std::cout << "\033[0m" << std::endl; 56 | // MIGHT BE INEFFICIENT 57 | //if (Lantern::logFile != nullptr) { 58 | // std::wstring wfunc(funcName, funcName + strlen(funcName)); 59 | // std::wostringstream str; 60 | // (str << ... << args); 61 | // Lantern::logFile->WriteLine(L"[" + wfunc + L"] " + str.str()); 62 | //} 63 | } 64 | 65 | template 66 | static void logw(const char* funcName, const Args&... args) { 67 | std::wcout << L"\033[96m"; 68 | (std::cout << "[" << funcName << "] "); 69 | std::wcout << L"\033[0m"; 70 | 71 | std::wcout << L"\033[36m"; 72 | (std::wcout << ... << args); 73 | std::wcout << L"\033[0m" << std::endl; 74 | //if (Lantern::logFile != nullptr) { 75 | // std::wstring wfunc(funcName, funcName + strlen(funcName)); 76 | // std::wostringstream str; 77 | // (str << ... << args); 78 | // Lantern::logFile->WriteLine(L"[" + wfunc + L"] " + str.str()); 79 | //} 80 | } 81 | 82 | template 83 | static void log_c(const char* funcName, ANSIColor color, const Args&... args) { 84 | std::cout << "\033[96m"; 85 | (std::cout << "[" << funcName << "] "); 86 | std::cout << "\033[0m"; 87 | 88 | std::cout << "\033[" << color << "m"; 89 | (std::cout << ... << args); 90 | std::cout << "\033[0m" << std::endl; 91 | //if (Lantern::logFile != nullptr) { 92 | // std::wstring wfunc(funcName, funcName + strlen(funcName)); 93 | // std::wostringstream str; 94 | // (str << ... << args); 95 | // Lantern::logFile->WriteLine(L"[" + wfunc + L"] " + str.str()); 96 | //} 97 | } 98 | 99 | template 100 | static void logw_c(const char* funcName, ANSIColor color, const Args&... args) { 101 | std::wcout << L"\033[96m"; 102 | (std::cout << "[" << funcName << "] "); 103 | std::wcout << L"\033[0m"; 104 | 105 | std::wcout << "\033[" << color << "m"; 106 | (std::wcout << ... << args); 107 | std::wcout << "\033[0m" << std::endl; 108 | //if (Lantern::logFile != nullptr) { 109 | // std::wstring wfunc(funcName, funcName + strlen(funcName)); 110 | // std::wostringstream str; 111 | // (str << ... << args); 112 | // Lantern::logFile->WriteLine(L"[" + wfunc + L"] " + str.str()); 113 | //} 114 | } -------------------------------------------------------------------------------- /lantern/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 4 | // Windows Header Files 5 | #include 6 | #include -------------------------------------------------------------------------------- /lantern/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /lantern/pch.h: -------------------------------------------------------------------------------- 1 | // Files listed below are compiled only once, improving build performance for future builds. 2 | // This also affects IntelliSense performance, including code completion and many code browsing features. 3 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 4 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 5 | 6 | #ifndef PCH_H 7 | #define PCH_H 8 | 9 | // add headers that you want to pre-compile here 10 | #include "framework.h" 11 | 12 | #endif //PCH_H 13 | -------------------------------------------------------------------------------- /lib/detours/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # %Taken from https://github.com/0xeb/detours-cmake/blob/master/3rdparty/detours_lib/CMakeLists.txt 2 | # Licensed under MIT 3 | 4 | # Detours 5 | set (CMAKE_CXX_STANDARD 14) 6 | 7 | set(TARGET lib_detours) 8 | set(DETOURS_SOURCE Detours/src) 9 | 10 | add_library(${TARGET} STATIC 11 | ${DETOURS_SOURCE}/creatwth.cpp 12 | ${DETOURS_SOURCE}/detours.cpp 13 | ${DETOURS_SOURCE}/detours.h 14 | ${DETOURS_SOURCE}/detver.h 15 | ${DETOURS_SOURCE}/disasm.cpp 16 | ${DETOURS_SOURCE}/disolarm.cpp 17 | ${DETOURS_SOURCE}/disolarm64.cpp 18 | ${DETOURS_SOURCE}/disolia64.cpp 19 | ${DETOURS_SOURCE}/disolx64.cpp 20 | ${DETOURS_SOURCE}/disolx86.cpp 21 | ${DETOURS_SOURCE}/image.cpp 22 | ${DETOURS_SOURCE}/modules.cpp 23 | ${DETOURS_SOURCE}/uimports.cpp) 24 | 25 | # This file is included and not compiled on its own 26 | set_property ( 27 | SOURCE ${DETOURS_SOURCE}/uimports.cpp 28 | APPEND PROPERTY HEADER_FILE_ONLY true) 29 | 30 | target_compile_options(${TARGET} PRIVATE /W4 /WX /Zi /MT /Gy /Gm- /Zl /Od) 31 | target_include_directories(${TARGET} PUBLIC ${DETOURS_SOURCE}) 32 | 33 | # withdll 34 | add_executable(withdll Detours/samples/withdll/withdll.cpp) 35 | target_link_libraries(withdll lib_detours) 36 | 37 | # Static library for the syelog components 38 | add_library(syelog STATIC Detours/samples/syelog/syelog.cpp 39 | Detours/samples/syelog/syelog.h) 40 | target_include_directories(syelog PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Detours/samples/syelog) 41 | target_link_libraries(syelog PUBLIC lib_detours ws2_32 secur32) 42 | 43 | 44 | # syelogd 45 | add_executable(syelogd Detours/samples/syelog/syelogd.cpp 46 | Detours/samples/syelog/syelog.h) 47 | target_link_libraries(syelogd PRIVATE lib_detours) 48 | 49 | # traceapi example 50 | add_library(traceapi SHARED Detours/samples/traceapi/trcapi.cpp 51 | Detours/samples/traceapi/trcapi.rc) 52 | target_link_libraries(traceapi PRIVATE syelog) 53 | set_target_properties(traceapi PROPERTIES LINK_FLAGS /EXPORT:DetourFinishHelperProcess,@1,NONAME) 54 | 55 | # tracessl example 56 | add_library(tracessl SHARED Detours/samples/tracessl/trcssl.cpp Detours/samples/tracessl/trcssl.rc) 57 | target_link_libraries(tracessl PRIVATE syelog) 58 | set_target_properties(tracessl PROPERTIES LINK_FLAGS /EXPORT:DetourFinishHelperProcess,@1,NONAME) -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | --------------------------------------------------------------------------------