├── External └── src │ ├── common.cpp │ ├── pointers.hpp │ ├── pointer.hpp │ ├── file_manager │ ├── file.hpp │ ├── folder.hpp │ ├── folder.cpp │ └── file.cpp │ ├── pointers.cpp │ ├── script_loader.hpp │ ├── pattern.hpp │ ├── common.hpp │ ├── ysc_file.hpp │ ├── rage │ ├── joaat.hpp │ ├── natives.hpp │ ├── script_program.hpp │ └── script_thread.hpp │ ├── file_manager.hpp │ ├── main.cpp │ ├── process.hpp │ ├── pattern.cpp │ ├── ysc_file.cpp │ ├── script_loader.cpp │ └── logger.hpp ├── modmenu.ysc ├── helloworld.ysc ├── GenerateProjects.bat ├── .gitmodules ├── README.md ├── premake5.lua ├── .gitignore └── JITYSC └── src └── ysc.hpp /External/src/common.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | -------------------------------------------------------------------------------- /modmenu.ysc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maybegreat48/External/HEAD/modmenu.ysc -------------------------------------------------------------------------------- /helloworld.ysc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maybegreat48/External/HEAD/helloworld.ysc -------------------------------------------------------------------------------- /GenerateProjects.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | premake5 vs2019 3 | IF %ERRORLEVEL% NEQ 0 ( 4 | PAUSE 5 | ) 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "g3log"] 2 | path = g3log 3 | url = https://github.com/KjellKod/g3log.git 4 | [submodule "json"] 5 | path = json 6 | url = https://github.com/nlohmann/json 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # External 2 | A POC for loading RAGE script files externally 3 | 4 | Also see my version of [SC-CL](https://github.com/maybegreat48/SC-CL) which can be used to make RAGE script files 5 | -------------------------------------------------------------------------------- /External/src/pointers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pointer.hpp" 3 | 4 | namespace ext 5 | { 6 | class pointers 7 | { 8 | public: 9 | explicit pointers(); 10 | ~pointers(); 11 | public: 12 | pointer m_is_session_started; 13 | pointer m_script_threads; 14 | pointer m_script_program_table; 15 | pointer m_native_registration_table; 16 | pointer m_ret_true_function; 17 | }; 18 | 19 | inline pointers* g_pointers; 20 | } -------------------------------------------------------------------------------- /External/src/pointer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "process.hpp" 3 | 4 | namespace ext 5 | { 6 | template 7 | class pointer 8 | { 9 | std::uint64_t address; 10 | public: 11 | inline pointer(std::uint64_t address) : 12 | address(address) 13 | { 14 | } 15 | 16 | inline T operator*() const 17 | { 18 | return g_process->read(address); 19 | } 20 | 21 | inline operator uint64_t() const 22 | { 23 | return address; 24 | } 25 | }; 26 | } -------------------------------------------------------------------------------- /External/src/file_manager/file.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ext 4 | { 5 | class file_manager; 6 | 7 | class file 8 | { 9 | public: 10 | 11 | file(std::filesystem::path file_path); 12 | 13 | file copy(std::filesystem::path new_path); 14 | bool exists() const; 15 | const std::filesystem::path get_path() const; 16 | file move(std::filesystem::path new_path); 17 | 18 | protected: 19 | file(file_manager* file_manager, std::filesystem::path file_path); 20 | 21 | private: 22 | friend class file_manager; 23 | 24 | bool m_is_project_file; 25 | std::filesystem::path m_file_path; 26 | 27 | }; 28 | } -------------------------------------------------------------------------------- /External/src/file_manager/folder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ext 4 | { 5 | class file; 6 | class file_manager; 7 | 8 | class folder 9 | { 10 | 11 | public: 12 | folder(std::filesystem::path folder_path); 13 | 14 | file get_file(std::filesystem::path file_path) const; 15 | const std::filesystem::path get_path() const; 16 | 17 | protected: 18 | folder(file_manager* file_manager, std::filesystem::path file_path); 19 | 20 | private: 21 | 22 | friend class file_manager; 23 | file_manager* m_file_manager; 24 | 25 | bool m_is_project_file; 26 | 27 | std::filesystem::path m_folder_path; 28 | 29 | }; 30 | } -------------------------------------------------------------------------------- /External/src/pointers.cpp: -------------------------------------------------------------------------------- 1 | #include "pointers.hpp" 2 | #include "pattern.hpp" 3 | 4 | namespace ext 5 | { 6 | pointers::pointers() : 7 | m_is_session_started(pattern("ISA", "40 38 35 ? ? ? ? 75 0E 4C 8B C3 49 8B D7 49 8B CE").add(3).rip()), 8 | m_script_threads(pattern("ST", "45 33 F6 8B E9 85 C9 B8").sub(4).rip().sub(8)), 9 | m_script_program_table(pattern("SP", "44 8B 0D ? ? ? ? 4C 8B 1D ? ? ? ? 48 8B 1D ? ? ? ? 41 83 F8 FF 74 3F 49 63 C0 42 0F B6 0C 18 81 E1").add(17).rip()), 10 | m_native_registration_table(pattern("NH", "48 8D 0D ? ? ? ? 48 8B 14 FA E8 ? ? ? ? 48 85 C0 75 0A").add(3).rip()), 11 | m_ret_true_function(pattern("RT", "B0 01 C3")) 12 | { 13 | g_pointers = this; 14 | } 15 | 16 | pointers::~pointers() 17 | { 18 | g_pointers = nullptr; 19 | } 20 | } -------------------------------------------------------------------------------- /External/src/script_loader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pointers.hpp" 3 | #include "rage/script_thread.hpp" 4 | #include "rage/script_program.hpp" 5 | #include "rage/natives.hpp" 6 | #include 7 | 8 | namespace ext 9 | { 10 | class script_loader 11 | { 12 | std::map m_handler_cache{}; 13 | rage::scrNativeRegistrationTable m_native_registration; 14 | rage::joaat_t m_required_script; 15 | rage::scrThread m_thread{0}; 16 | rage::scrProgram m_program{0}; 17 | std::uint64_t m_fake_vft; 18 | OPENFILENAMEA m_ofn; 19 | char m_file_name[260]{}; 20 | 21 | public: 22 | script_loader(); 23 | ~script_loader(); 24 | 25 | void find_thread(); 26 | void pick_script(); 27 | void initalize_thread(); 28 | }; 29 | 30 | inline script_loader* g_script_loader; 31 | } -------------------------------------------------------------------------------- /External/src/file_manager/folder.cpp: -------------------------------------------------------------------------------- 1 | #include "file_manager.hpp" 2 | #include "folder.hpp" 3 | 4 | namespace ext 5 | { 6 | folder::folder(file_manager* file_manager, std::filesystem::path file_path) 7 | : folder(file_manager->get_base_dir() / file_path) 8 | { 9 | m_file_manager = file_manager; 10 | m_is_project_file = true; 11 | } 12 | 13 | folder::folder(std::filesystem::path folder_path) 14 | : m_folder_path(file_manager::ensure_folder_exists(folder_path)) 15 | { 16 | 17 | } 18 | 19 | file folder::get_file(std::filesystem::path file_path) const 20 | { 21 | if (file_path.is_absolute()) 22 | throw std::exception("folder#get_file requires a relative path."); 23 | 24 | return file( 25 | m_folder_path / file_path 26 | ); 27 | } 28 | 29 | const std::filesystem::path folder::get_path() const 30 | { 31 | return m_folder_path; 32 | } 33 | } -------------------------------------------------------------------------------- /External/src/pattern.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "process.hpp" 3 | #define CHUNK_SIZE 0x1000 4 | 5 | namespace ext { 6 | 7 | class pattern { 8 | std::vector> compiled; 9 | std::string name; 10 | uintptr_t address = 0; 11 | 12 | public: 13 | inline pattern(std::string name, std::string x) : 14 | name(name) 15 | { 16 | compile(x); 17 | scan(); 18 | } 19 | 20 | inline pattern(std::string name_, uintptr_t addr) { 21 | name = name_; 22 | address = addr; 23 | } 24 | 25 | void compile(const std::string& pat); 26 | 27 | pattern& scan(); 28 | 29 | inline pattern add(size_t n) { 30 | return pattern(name, address + n); 31 | } 32 | 33 | inline pattern sub(size_t n) { 34 | return pattern(name, address - n); 35 | } 36 | 37 | pattern rip(); 38 | 39 | inline operator std::uint64_t() const 40 | { 41 | return address; 42 | } 43 | }; 44 | }; -------------------------------------------------------------------------------- /External/src/common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DISABLE_VECTORED_EXCEPTIONHANDLING 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | #pragma comment(lib, "psapi.lib") 24 | 25 | #include "logger.hpp" 26 | 27 | namespace std 28 | { 29 | template class Template> 30 | struct is_specialization : std::false_type {}; 31 | 32 | template