├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── premake5.lua └── src └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | project 3 | premake5.exe -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Bootil"] 2 | path = Bootil 3 | url = https://github.com/garrynewman/bootil.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2017 Matt Stevens 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | Very simple utility application to extract the LZMA compressed Lua cache downloaded from Garry's Mod servers. 4 | 5 | ## Usage 6 | 7 | This program decompiles the **WHOLE** lua folder, not just one file. 8 | Therefore, you must provide the garrysmod\lua folder as the first argument. 9 | 10 | NOTE: Without setting a custom output folder, this WILL OVERRIDE all exsisting files with their decompiled versions. 11 | Make sure to set the output folder to somewhere else to avoid having to redownload the original files. 12 | 13 | Syntax: `gluaextract <[GMOD FOLDER]\garrysmod\lua> [output folder]` (*`out` is optional and defaults to `in`*) 14 | 15 | ## Prerequisites 16 | 17 | Depends on `Bootil` which is included as a git submodule and `premake5` to build project files. 18 | 19 | ## Building From Source 20 | 21 | First run: `git submodule update --init --recursive` to grab Bootil. 22 | 23 | * **Windows**: Generate your project files using `premake5 vs2015` and build using `project/gluacacheextract.sln` 24 | * **Linux**: Run `premake5 gmake && make` 25 | 26 | ## License 27 | 28 | [The MIT License (MIT) - Copyright (c) 2014-2017 Matt Stevens](LICENSE) 29 | -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | solution "gluacacheextract" 2 | configurations { "Debug", "Release" } 3 | platforms { "x32", "x64" } 4 | 5 | language "C++" 6 | characterset "MBCS" 7 | location "project" 8 | targetdir "bin" 9 | 10 | filter "platforms:x32" 11 | architecture "x32" 12 | 13 | filter "platforms:x64" 14 | architecture "x64" 15 | 16 | project "gluacacheextract" 17 | kind "ConsoleApp" 18 | targetname "gluaextract" 19 | flags { "Symbols", "NoEditAndContinue", "NoPCH", "StaticRuntime", "EnableSSE" } 20 | links "bootil_static" 21 | includedirs "Bootil/include" 22 | 23 | if os.is( "linux" ) then 24 | buildoptions { "-fPIC", "-pthread" } 25 | linkoptions { "-pthread" } 26 | end 27 | 28 | files { "src/main.cpp" } 29 | 30 | include "Bootil/projects/bootil_premake5.lua" -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Bootil/Bootil.h" 2 | 3 | using namespace Bootil; 4 | 5 | void decompress(BString& in, BString& out) 6 | { 7 | Output::Msg("%s", in.c_str()); 8 | 9 | AutoBuffer inBuf; 10 | File::Read(in, inBuf); 11 | 12 | // Extract using LZMA with 32 bytes as base 13 | AutoBuffer outBuf; 14 | Compression::LZMA::Extract(inBuf.GetBase(32), inBuf.GetSize() - 32, outBuf); 15 | 16 | File::Write(out, outBuf); 17 | 18 | Output::Msg(" -> %s (%i bytes)\n", out.c_str(), outBuf.GetSize()); 19 | } 20 | 21 | int main( int argc, char** argv ) 22 | { 23 | Debug::SuppressPopups( true ); 24 | CommandLine::Set( argc, argv ); 25 | 26 | BString strInFolder = CommandLine::GetArg( 0, "" ); 27 | BString strOutFolder = CommandLine::GetArg( 1, strInFolder ); 28 | 29 | if (strInFolder == "") 30 | Output::Error("Usage: gluaextract [out]"); 31 | 32 | String::List files; 33 | String::List folders; 34 | File::Find(&files, &folders, strInFolder + "/*.lua", false); 35 | File::CreateFolder(strOutFolder); 36 | 37 | Output::Msg("Converting %i files\n", files.size()); 38 | 39 | BOOTIL_FOREACH_CONST(f, files, String::List) 40 | { 41 | decompress(strInFolder + "/" + *f, strOutFolder + "/" + *f); 42 | } 43 | 44 | Output::Msg("Done!\n"); 45 | 46 | return 0; 47 | } --------------------------------------------------------------------------------