| @@ -0,0 +1,36 @@ | |||||
| | |||||
| Microsoft Visual Studio Solution File, Format Version 12.00 | |||||
| # Visual Studio Version 16 | |||||
| VisualStudioVersion = 16.0.30503.244 | |||||
| MinimumVisualStudioVersion = 10.0.40219.1 | |||||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BL3ProxySettings", "BL3ProxySettings.vcxproj", "{E70933C3-6395-4BB1-9B30-FB35D92D1643}" | |||||
| EndProject | |||||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BLua", "..\BL3Lua\BL3Lua.vcxproj", "{DF0B7199-3ED8-49DC-9544-46B6315D4390}" | |||||
| EndProject | |||||
| Global | |||||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||||
| Debug|x64 = Debug|x64 | |||||
| Debug-JIT|x64 = Debug-JIT|x64 | |||||
| Release|x64 = Release|x64 | |||||
| EndGlobalSection | |||||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||||
| {E70933C3-6395-4BB1-9B30-FB35D92D1643}.Debug|x64.ActiveCfg = Debug|x64 | |||||
| {E70933C3-6395-4BB1-9B30-FB35D92D1643}.Debug|x64.Build.0 = Debug|x64 | |||||
| {E70933C3-6395-4BB1-9B30-FB35D92D1643}.Debug-JIT|x64.ActiveCfg = Debug|x64 | |||||
| {E70933C3-6395-4BB1-9B30-FB35D92D1643}.Debug-JIT|x64.Build.0 = Debug|x64 | |||||
| {E70933C3-6395-4BB1-9B30-FB35D92D1643}.Release|x64.ActiveCfg = Release|x64 | |||||
| {E70933C3-6395-4BB1-9B30-FB35D92D1643}.Release|x64.Build.0 = Release|x64 | |||||
| {DF0B7199-3ED8-49DC-9544-46B6315D4390}.Debug|x64.ActiveCfg = Debug|x64 | |||||
| {DF0B7199-3ED8-49DC-9544-46B6315D4390}.Debug|x64.Build.0 = Debug|x64 | |||||
| {DF0B7199-3ED8-49DC-9544-46B6315D4390}.Debug-JIT|x64.ActiveCfg = Debug-JIT|x64 | |||||
| {DF0B7199-3ED8-49DC-9544-46B6315D4390}.Debug-JIT|x64.Build.0 = Debug-JIT|x64 | |||||
| {DF0B7199-3ED8-49DC-9544-46B6315D4390}.Release|x64.ActiveCfg = Release|x64 | |||||
| {DF0B7199-3ED8-49DC-9544-46B6315D4390}.Release|x64.Build.0 = Release|x64 | |||||
| EndGlobalSection | |||||
| GlobalSection(SolutionProperties) = preSolution | |||||
| HideSolutionNode = FALSE | |||||
| EndGlobalSection | |||||
| GlobalSection(ExtensibilityGlobals) = postSolution | |||||
| SolutionGuid = {E5BFF991-181E-41E5-903E-7245BE2D45B0} | |||||
| EndGlobalSection | |||||
| EndGlobal | |||||
| @@ -0,0 +1,127 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
| <ItemGroup Label="ProjectConfigurations"> | |||||
| <ProjectConfiguration Include="Debug|x64"> | |||||
| <Configuration>Debug</Configuration> | |||||
| <Platform>x64</Platform> | |||||
| </ProjectConfiguration> | |||||
| <ProjectConfiguration Include="Release|x64"> | |||||
| <Configuration>Release</Configuration> | |||||
| <Platform>x64</Platform> | |||||
| </ProjectConfiguration> | |||||
| </ItemGroup> | |||||
| <PropertyGroup Label="Globals"> | |||||
| <VCProjectVersion>16.0</VCProjectVersion> | |||||
| <Keyword>Win32Proj</Keyword> | |||||
| <ProjectGuid>{e70933c3-6395-4bb1-9b30-fb35d92d1643}</ProjectGuid> | |||||
| <RootNamespace>BL3ProxySettings</RootNamespace> | |||||
| <WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion> | |||||
| </PropertyGroup> | |||||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | |||||
| <ConfigurationType>DynamicLibrary</ConfigurationType> | |||||
| <UseDebugLibraries>true</UseDebugLibraries> | |||||
| <PlatformToolset>v142</PlatformToolset> | |||||
| <CharacterSet>Unicode</CharacterSet> | |||||
| </PropertyGroup> | |||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | |||||
| <ConfigurationType>DynamicLibrary</ConfigurationType> | |||||
| <UseDebugLibraries>false</UseDebugLibraries> | |||||
| <PlatformToolset>ClangCL</PlatformToolset> | |||||
| <WholeProgramOptimization>true</WholeProgramOptimization> | |||||
| <CharacterSet>Unicode</CharacterSet> | |||||
| <UseOfMfc>false</UseOfMfc> | |||||
| </PropertyGroup> | |||||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||||
| <ImportGroup Label="ExtensionSettings"> | |||||
| </ImportGroup> | |||||
| <ImportGroup Label="Shared"> | |||||
| </ImportGroup> | |||||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
| </ImportGroup> | |||||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
| </ImportGroup> | |||||
| <PropertyGroup Label="UserMacros" /> | |||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
| <LinkIncremental>true</LinkIncremental> | |||||
| <IncludePath>F:\Programmieren\C++\vcpkg\installed\x64-windows-static-md\include;$(IncludePath)</IncludePath> | |||||
| <LibraryPath>F:\Programmieren\C++\vcpkg\installed\x64-windows-static-md\debug\lib;$(LibraryPath)</LibraryPath> | |||||
| </PropertyGroup> | |||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
| <LinkIncremental>false</LinkIncremental> | |||||
| <IncludePath>F:\Programmieren\C++\vcpkg\installed\x64-windows\include;$(IncludePath)</IncludePath> | |||||
| <LibraryPath>F:\Programmieren\C++\vcpkg\installed\x64-windows\lib;$(LibraryPath)</LibraryPath> | |||||
| </PropertyGroup> | |||||
| <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
| <VcpkgUseStatic>true</VcpkgUseStatic> | |||||
| <VcpkgTriplet>x64-windows-static-md</VcpkgTriplet> | |||||
| </PropertyGroup> | |||||
| <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
| <VcpkgUseStatic>true</VcpkgUseStatic> | |||||
| <VcpkgTriplet>x64-windows-static-md</VcpkgTriplet> | |||||
| </PropertyGroup> | |||||
| <PropertyGroup Label="Vcpkg"> | |||||
| <VcpkgEnabled>true</VcpkgEnabled> | |||||
| <VcpkgAutoLink>false</VcpkgAutoLink> | |||||
| </PropertyGroup> | |||||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
| <ClCompile> | |||||
| <WarningLevel>Level3</WarningLevel> | |||||
| <SDLCheck>true</SDLCheck> | |||||
| <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
| <ConformanceMode>false</ConformanceMode> | |||||
| <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | |||||
| <LanguageStandard_C>stdc17</LanguageStandard_C> | |||||
| <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions> | |||||
| <LanguageStandard>stdcpp17</LanguageStandard> | |||||
| <BufferSecurityCheck>false</BufferSecurityCheck> | |||||
| <DebugInformationFormat>OldStyle</DebugInformationFormat> | |||||
| </ClCompile> | |||||
| <Link> | |||||
| <SubSystem>Console</SubSystem> | |||||
| <GenerateDebugInformation>DebugFull</GenerateDebugInformation> | |||||
| <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> | |||||
| </Link> | |||||
| </ItemDefinitionGroup> | |||||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
| <ClCompile> | |||||
| <WarningLevel>Level3</WarningLevel> | |||||
| <FunctionLevelLinking>true</FunctionLevelLinking> | |||||
| <IntrinsicFunctions>true</IntrinsicFunctions> | |||||
| <SDLCheck>true</SDLCheck> | |||||
| <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
| <ConformanceMode>false</ConformanceMode> | |||||
| <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | |||||
| <Optimization>MaxSpeed</Optimization> | |||||
| <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> | |||||
| <LanguageStandard_C>stdc17</LanguageStandard_C> | |||||
| <LanguageStandard>stdcpp17</LanguageStandard> | |||||
| <ExceptionHandling>Async</ExceptionHandling> | |||||
| <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> | |||||
| <BufferSecurityCheck>false</BufferSecurityCheck> | |||||
| <DebugInformationFormat>None</DebugInformationFormat> | |||||
| </ClCompile> | |||||
| <Link> | |||||
| <SubSystem>Console</SubSystem> | |||||
| <EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
| <OptimizeReferences>true</OptimizeReferences> | |||||
| <GenerateDebugInformation>false</GenerateDebugInformation> | |||||
| <IgnoreAllDefaultLibraries> | |||||
| </IgnoreAllDefaultLibraries> | |||||
| <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> | |||||
| <AdditionalOptions>/DEBUG:NONE %(AdditionalOptions)</AdditionalOptions> | |||||
| </Link> | |||||
| </ItemDefinitionGroup> | |||||
| <ItemGroup> | |||||
| <ClCompile Include="BL3ProxySettings.cpp" /> | |||||
| </ItemGroup> | |||||
| <ItemGroup> | |||||
| <ClInclude Include="include\patternscan.hpp" /> | |||||
| <ClInclude Include="SparkClasses.h" /> | |||||
| </ItemGroup> | |||||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||||
| <ImportGroup Label="ExtensionTargets"> | |||||
| </ImportGroup> | |||||
| </Project> | |||||
| @@ -0,0 +1,30 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
| <ItemGroup> | |||||
| <Filter Include="Source Files"> | |||||
| <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | |||||
| <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | |||||
| </Filter> | |||||
| <Filter Include="Header Files"> | |||||
| <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | |||||
| <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> | |||||
| </Filter> | |||||
| <Filter Include="Resource Files"> | |||||
| <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | |||||
| <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | |||||
| </Filter> | |||||
| </ItemGroup> | |||||
| <ItemGroup> | |||||
| <ClCompile Include="BL3ProxySettings.cpp"> | |||||
| <Filter>Source Files</Filter> | |||||
| </ClCompile> | |||||
| </ItemGroup> | |||||
| <ItemGroup> | |||||
| <ClInclude Include="include\patternscan.hpp"> | |||||
| <Filter>Header Files</Filter> | |||||
| </ClInclude> | |||||
| <ClInclude Include="SparkClasses.h"> | |||||
| <Filter>Header Files</Filter> | |||||
| </ClInclude> | |||||
| </ItemGroup> | |||||
| </Project> | |||||
| @@ -0,0 +1,13 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
| <LocalDebuggerCommand>E:\SteamLibrary\steamapps\common\Borderlands 3\OakGame\Binaries\Win64\Borderlands3.exe</LocalDebuggerCommand> | |||||
| <LocalDebuggerAttach>true</LocalDebuggerAttach> | |||||
| <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | |||||
| </PropertyGroup> | |||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
| <LocalDebuggerCommand>E:\SteamLibrary\steamapps\common\Borderlands 3\OakGame\Binaries\Win64\Borderlands3.exe</LocalDebuggerCommand> | |||||
| <LocalDebuggerAttach>true</LocalDebuggerAttach> | |||||
| <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | |||||
| </PropertyGroup> | |||||
| </Project> | |||||
| @@ -0,0 +1,249 @@ | |||||
| #pragma once | |||||
| // Created with ReClass.NET 1.2 by KN4CK3R | |||||
| class FSparkInitProcess | |||||
| { | |||||
| public: | |||||
| void* Something; //0x0008 | |||||
| uint32_t N000015F8; //0x0010 | |||||
| char pad_0014[84]; //0x0014 | |||||
| uint32_t N00001603; //0x0068 | |||||
| uint32_t N00001752; //0x006C | |||||
| uint32_t N00001604; //0x0070 | |||||
| uint32_t N00001754; //0x0074 | |||||
| uint32_t N00001605; //0x0078 | |||||
| uint32_t N00001756; //0x007C | |||||
| uint32_t N00001606; //0x0080 | |||||
| uint32_t N00001758; //0x0084 | |||||
| uint32_t N00001607; //0x0088 | |||||
| uint32_t N0000175A; //0x008C | |||||
| wchar_t* UniqueSparkIDW; //0x0090 | |||||
| char pad_0098[8]; //0x0098 | |||||
| float N0000160A; //0x00A0 | |||||
| int32_t N000016CD; //0x00A4 | |||||
| int32_t N0000160B; //0x00A8 | |||||
| float N000016D6; //0x00AC | |||||
| uint32_t N0000160C; //0x00B0 | |||||
| float N000016CF; //0x00B4 | |||||
| int32_t N0000160D; //0x00B8 | |||||
| float N000016C8; //0x00BC | |||||
| bool hasBeenRequested; //0x00C0 | |||||
| int8_t N00002E86; //0x00C1 | |||||
| int8_t N00002E8A; //0x00C2 | |||||
| int8_t N00002E90; //0x00C3 | |||||
| int8_t InitStep; //0x00C4 | |||||
| int8_t N00002E87; //0x00C5 | |||||
| int8_t N00002E8D; //0x00C6 | |||||
| int8_t N00002E88; //0x00C7 | |||||
| uint8_t N00002E78; //0x00C8 | |||||
| int8_t N00002E7B; //0x00C9 | |||||
| int8_t N00002E79; //0x00CA | |||||
| char pad_00CB[1]; //0x00CB | |||||
| uint8_t N00002E95; //0x00CC | |||||
| uint8_t N00002E98; //0x00CD | |||||
| uint8_t N00002E96; //0x00CE | |||||
| uint8_t N0000160F; //0x00CF | |||||
| uint8_t N00002E7F; //0x00D0 | |||||
| char pad_00D1[2]; //0x00D1 | |||||
| int32_t N00001729; //0x00D3 | |||||
| uint32_t N00001610; //0x00D7 | |||||
| char pad_00DB[56]; //0x00DB | |||||
| uint32_t N00001775; //0x0113 | |||||
| char pad_0117[24]; //0x0117 | |||||
| wchar_t* SteamIDW; //0x012F | |||||
| uint32_t N0000161C; //0x0137 | |||||
| uint32_t N0000172C; //0x013B | |||||
| uint32_t N0000161D; //0x013F | |||||
| uint32_t N0000172E; //0x0143 | |||||
| uint32_t N0000161E; //0x0147 | |||||
| uint32_t N00001730; //0x014B | |||||
| uint32_t N0000161F; //0x014F | |||||
| uint32_t N00001732; //0x0153 | |||||
| char pad_0157[12]; //0x0157 | |||||
| uint32_t N00001736; //0x0163 | |||||
| char pad_0167[8]; //0x0167 | |||||
| char* SteamIDA; //0x016F | |||||
| char* SteamIDA2; //0x0177 | |||||
| char pad_017F[8]; //0x017F | |||||
| wchar_t* UniqueSparkIDW2; //0x0187 | |||||
| char pad_018F[32]; //0x018F | |||||
| uint32_t N0000162B; //0x01AF | |||||
| uint32_t N000016E6; //0x01B3 | |||||
| char pad_01B7[8]; //0x01B7 | |||||
| uint32_t N0000162D; //0x01BF | |||||
| uint32_t N000016EA; //0x01C3 | |||||
| char* UniqueSparkIDA1; //0x01C7 | |||||
| char* UniqueSparkIDA2; //0x01CF | |||||
| char pad_01D7[8]; //0x01D7 | |||||
| wchar_t* N00001631; //0x01DF | |||||
| char pad_01E7[56]; //0x01E7 | |||||
| char* N00001639; //0x021F | |||||
| char* N0000163A; //0x0227 | |||||
| char pad_022F[8]; //0x022F | |||||
| wchar_t* N0000163C; //0x0237 | |||||
| char pad_023F[56]; //0x023F | |||||
| char* N00001644; //0x0277 | |||||
| char* N00001645; //0x027F | |||||
| char pad_0287[8]; //0x0287 | |||||
| wchar_t* N00001647; //0x028F | |||||
| char pad_0297[56]; //0x0297 | |||||
| char* N0000164F; //0x02CF | |||||
| char* N00001650; //0x02D7 | |||||
| char pad_02DF[72]; //0x02DF | |||||
| void* N0000165A; //0x0327 | |||||
| void* N0000165B; //0x032F | |||||
| void* N0000165C; //0x0337 | |||||
| void* N0000165D; //0x033F | |||||
| virtual void Function0(); | |||||
| virtual void Function1(); | |||||
| virtual void Function2(); | |||||
| virtual void Function3(); | |||||
| virtual void Function4(); | |||||
| virtual void Function5(); | |||||
| virtual void Function6(); | |||||
| virtual void Function7(); | |||||
| virtual void Function8(); | |||||
| virtual void Function9(); | |||||
| }; //Size: 0x0347 | |||||
| class N000016AF | |||||
| { | |||||
| public: | |||||
| class FSparkInitProcess* FSparkinitProcess; //0x0000 | |||||
| char pad_0008[128]; //0x0008 | |||||
| }; //Size: 0x0088 | |||||
| static_assert(sizeof(N000016AF) == 0x88); | |||||
| class FSparkManager | |||||
| { | |||||
| public: | |||||
| char pad_0008[8]; //0x0008 | |||||
| int64_t N00001928; //0x0010 | |||||
| void* N00001929; //0x0018 | |||||
| int32_t N0000192A; //0x0020 | |||||
| int32_t N00001A91; //0x0024 | |||||
| int32_t N0000192B; //0x0028 | |||||
| int32_t N0000199A; //0x002C | |||||
| void* N0000192C; //0x0030 | |||||
| int32_t N0000192D; //0x0038 | |||||
| int32_t N0000199C; //0x003C | |||||
| int32_t N0000192E; //0x0040 | |||||
| int32_t N0000199E; //0x0044 | |||||
| char pad_0048[8]; //0x0048 | |||||
| int32_t N00001930; //0x0050 | |||||
| int32_t N00001A8E; //0x0054 | |||||
| int32_t N00001931; //0x0058 | |||||
| int32_t N000019A2; //0x005C | |||||
| char pad_0060[8]; //0x0060 | |||||
| int32_t N00001933; //0x0068 | |||||
| int32_t N00001A8B; //0x006C | |||||
| int32_t N00001934; //0x0070 | |||||
| int32_t N000019A5; //0x0074 | |||||
| char pad_0078[16]; //0x0078 | |||||
| int32_t N00001937; //0x0088 | |||||
| int32_t N000019A8; //0x008C | |||||
| char pad_0090[8]; //0x0090 | |||||
| int32_t N00001939; //0x0098 | |||||
| int32_t N00001A82; //0x009C | |||||
| int32_t N0000193A; //0x00A0 | |||||
| int32_t N000019AB; //0x00A4 | |||||
| char pad_00A8[8]; //0x00A8 | |||||
| int32_t N0000193C; //0x00B0 | |||||
| int32_t N00001A85; //0x00B4 | |||||
| int32_t N0000193D; //0x00B8 | |||||
| int32_t N000019AE; //0x00BC | |||||
| char pad_00C0[8]; //0x00C0 | |||||
| int32_t N0000193F; //0x00C8 | |||||
| int32_t N00001A7F; //0x00CC | |||||
| int32_t N00001940; //0x00D0 | |||||
| int32_t N000019B1; //0x00D4 | |||||
| char pad_00D8[8]; //0x00D8 | |||||
| int32_t N00001942; //0x00E0 | |||||
| int32_t N00001A9D; //0x00E4 | |||||
| int32_t N00001943; //0x00E8 | |||||
| int32_t N000019B4; //0x00EC | |||||
| char pad_00F0[8]; //0x00F0 | |||||
| int32_t N00001945; //0x00F8 | |||||
| int32_t N00001A88; //0x00FC | |||||
| int32_t N00001946; //0x0100 | |||||
| int32_t N000019B7; //0x0104 | |||||
| char pad_0108[8]; //0x0108 | |||||
| int32_t N00001948; //0x0110 | |||||
| char pad_0114[12]; //0x0114 | |||||
| int32_t N0000194A; //0x0120 | |||||
| char pad_0124[20]; //0x0124 | |||||
| int32_t N0000194D; //0x0138 | |||||
| int32_t N000019BA; //0x013C | |||||
| char pad_0140[8]; //0x0140 | |||||
| int32_t N0000194F; //0x0148 | |||||
| int32_t N00001A9A; //0x014C | |||||
| int32_t N00001950; //0x0150 | |||||
| int32_t N000019BD; //0x0154 | |||||
| char pad_0158[8]; //0x0158 | |||||
| int32_t N00001952; //0x0160 | |||||
| int32_t N000019C0; //0x0164 | |||||
| char pad_0168[16]; //0x0168 | |||||
| int32_t N00001955; //0x0178 | |||||
| int32_t N000019C3; //0x017C | |||||
| char pad_0180[8]; //0x0180 | |||||
| int32_t N00001957; //0x0188 | |||||
| int32_t N000019C6; //0x018C | |||||
| char pad_0190[16]; //0x0190 | |||||
| wchar_t* N0000195A; //0x01A0 | |||||
| int32_t N0000195B; //0x01A8 | |||||
| int32_t N00001A73; //0x01AC | |||||
| char pad_01B0[208]; //0x01B0 | |||||
| class N000016AF* FSparkInitProcessPtr; //0x0280 | |||||
| char pad_0288[72]; //0x0288 | |||||
| void* SparkTMSThings; //0x02D0 | |||||
| void* N00001981; //0x02D8 | |||||
| wchar_t* PlatformName; //0x02E0 | |||||
| int32_t N00001983; //0x02E8 | |||||
| int32_t N00001A29; //0x02EC | |||||
| char pad_02F0[32]; //0x02F0 | |||||
| wchar_t* N00001988; //0x0310 | |||||
| char pad_0318[8]; //0x0318 | |||||
| wchar_t* N0000198A; //0x0320 | |||||
| char pad_0328[16]; //0x0328 | |||||
| wchar_t* GameTitle; //0x0338 | |||||
| char pad_0340[24]; //0x0340 | |||||
| wchar_t* PlatformName2; //0x0358 | |||||
| char pad_0360[40]; //0x0360 | |||||
| int32_t N00001997; //0x0388 | |||||
| int32_t N00001A78; //0x038C | |||||
| int32_t N00001998; //0x0390 | |||||
| int32_t N00001A7A; //0x0394 | |||||
| virtual void Function0(); | |||||
| virtual void SomethingBifrostTick(); | |||||
| virtual void SomethingGbxSpark(); | |||||
| virtual void Function3(); | |||||
| virtual void Function4(); | |||||
| virtual void SomethingTMS_FileVersion(); | |||||
| virtual void Something_timeoffset(); | |||||
| virtual void Something_long(); | |||||
| virtual void Something_timestamp(); | |||||
| virtual void Function9(); | |||||
| virtual void Soemthing_boolean(); | |||||
| virtual void Function11(); | |||||
| virtual void Function12(); | |||||
| virtual void Function13(); | |||||
| virtual void Function14(); | |||||
| virtual void Something_local_user_id(); | |||||
| virtual void Something_string(); | |||||
| virtual void Something_matchid(); | |||||
| virtual void Something_integer(); | |||||
| virtual void Something_timeoffset2(); | |||||
| virtual void Something_long2(); | |||||
| virtual void Something_timestamp2(); | |||||
| virtual void Something_float(); | |||||
| virtual void Something_boolean2(); | |||||
| virtual void Function24(); | |||||
| virtual void Function25(); | |||||
| virtual void Function26(); | |||||
| virtual void Function27(); | |||||
| virtual void Function28(); | |||||
| virtual void Function29(); | |||||
| }; //Size: 0x0398 | |||||
| static_assert(sizeof(FSparkManager) == 0x398); | |||||
| @@ -0,0 +1,199 @@ | |||||
| /* | |||||
| * MinHook - The Minimalistic API Hooking Library for x64/x86 | |||||
| * Copyright (C) 2009-2017 Tsuda Kageyu. | |||||
| * All rights reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in the | |||||
| * documentation and/or other materials provided with the distribution. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |||||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |||||
| * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |||||
| * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER | |||||
| * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |||||
| * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |||||
| * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |||||
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |||||
| * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |||||
| * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |||||
| * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
| */ | |||||
| #pragma once | |||||
| #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__) | |||||
| #error MinHook supports only x86 and x64 systems. | |||||
| #endif | |||||
| #include <windows.h> | |||||
| // MinHook Error Codes. | |||||
| typedef enum MH_STATUS | |||||
| { | |||||
| // Unknown error. Should not be returned. | |||||
| MH_UNKNOWN = -1, | |||||
| // Successful. | |||||
| MH_OK = 0, | |||||
| // MinHook is already initialized. | |||||
| MH_ERROR_ALREADY_INITIALIZED, | |||||
| // MinHook is not initialized yet, or already uninitialized. | |||||
| MH_ERROR_NOT_INITIALIZED, | |||||
| // The hook for the specified target function is already created. | |||||
| MH_ERROR_ALREADY_CREATED, | |||||
| // The hook for the specified target function is not created yet. | |||||
| MH_ERROR_NOT_CREATED, | |||||
| // The hook for the specified target function is already enabled. | |||||
| MH_ERROR_ENABLED, | |||||
| // The hook for the specified target function is not enabled yet, or already | |||||
| // disabled. | |||||
| MH_ERROR_DISABLED, | |||||
| // The specified pointer is invalid. It points the address of non-allocated | |||||
| // and/or non-executable region. | |||||
| MH_ERROR_NOT_EXECUTABLE, | |||||
| // The specified target function cannot be hooked. | |||||
| MH_ERROR_UNSUPPORTED_FUNCTION, | |||||
| // Failed to allocate memory. | |||||
| MH_ERROR_MEMORY_ALLOC, | |||||
| // Failed to change the memory protection. | |||||
| MH_ERROR_MEMORY_PROTECT, | |||||
| // The specified module is not loaded. | |||||
| MH_ERROR_MODULE_NOT_FOUND, | |||||
| // The specified function is not found. | |||||
| MH_ERROR_FUNCTION_NOT_FOUND | |||||
| } MH_STATUS; | |||||
| // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, | |||||
| // MH_QueueEnableHook or MH_QueueDisableHook. | |||||
| #define MH_ALL_HOOKS NULL | |||||
| #ifdef __cplusplus | |||||
| extern "C" | |||||
| { | |||||
| #endif | |||||
| // Initialize the MinHook library. You must call this function EXACTLY ONCE | |||||
| // at the beginning of your program. | |||||
| MH_STATUS WINAPI MH_Initialize(VOID); | |||||
| // Uninitialize the MinHook library. You must call this function EXACTLY | |||||
| // ONCE at the end of your program. | |||||
| MH_STATUS WINAPI MH_Uninitialize(VOID); | |||||
| // Creates a Hook for the specified target function, in disabled state. | |||||
| // Parameters: | |||||
| // pTarget [in] A pointer to the target function, which will be | |||||
| // overridden by the detour function. | |||||
| // pDetour [in] A pointer to the detour function, which will override | |||||
| // the target function. | |||||
| // ppOriginal [out] A pointer to the trampoline function, which will be | |||||
| // used to call the original target function. | |||||
| // This parameter can be NULL. | |||||
| MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); | |||||
| // Creates a Hook for the specified API function, in disabled state. | |||||
| // Parameters: | |||||
| // pszModule [in] A pointer to the loaded module name which contains the | |||||
| // target function. | |||||
| // pszTarget [in] A pointer to the target function name, which will be | |||||
| // overridden by the detour function. | |||||
| // pDetour [in] A pointer to the detour function, which will override | |||||
| // the target function. | |||||
| // ppOriginal [out] A pointer to the trampoline function, which will be | |||||
| // used to call the original target function. | |||||
| // This parameter can be NULL. | |||||
| MH_STATUS WINAPI MH_CreateHookApi( | |||||
| LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); | |||||
| // Creates a Hook for the specified API function, in disabled state. | |||||
| // Parameters: | |||||
| // pszModule [in] A pointer to the loaded module name which contains the | |||||
| // target function. | |||||
| // pszTarget [in] A pointer to the target function name, which will be | |||||
| // overridden by the detour function. | |||||
| // pDetour [in] A pointer to the detour function, which will override | |||||
| // the target function. | |||||
| // ppOriginal [out] A pointer to the trampoline function, which will be | |||||
| // used to call the original target function. | |||||
| // This parameter can be NULL. | |||||
| // ppTarget [out] A pointer to the target function, which will be used | |||||
| // with other functions. | |||||
| // This parameter can be NULL. | |||||
| MH_STATUS WINAPI MH_CreateHookApiEx( | |||||
| LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); | |||||
| // Removes an already created hook. | |||||
| // Parameters: | |||||
| // pTarget [in] A pointer to the target function. | |||||
| MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); | |||||
| // Enables an already created hook. | |||||
| // Parameters: | |||||
| // pTarget [in] A pointer to the target function. | |||||
| // If this parameter is MH_ALL_HOOKS, all created hooks are | |||||
| // enabled in one go. | |||||
| MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); | |||||
| // Disables an already created hook. | |||||
| // Parameters: | |||||
| // pTarget [in] A pointer to the target function. | |||||
| // If this parameter is MH_ALL_HOOKS, all created hooks are | |||||
| // disabled in one go. | |||||
| MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); | |||||
| // Queues to enable an already created hook. | |||||
| // Parameters: | |||||
| // pTarget [in] A pointer to the target function. | |||||
| // If this parameter is MH_ALL_HOOKS, all created hooks are | |||||
| // queued to be enabled. | |||||
| MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); | |||||
| // Queues to disable an already created hook. | |||||
| // Parameters: | |||||
| // pTarget [in] A pointer to the target function. | |||||
| // If this parameter is MH_ALL_HOOKS, all created hooks are | |||||
| // queued to be disabled. | |||||
| MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); | |||||
| // Applies all queued changes in one go. | |||||
| MH_STATUS WINAPI MH_ApplyQueued(VOID); | |||||
| // Translates the MH_STATUS to its name as a string. | |||||
| const char *WINAPI MH_StatusToString(MH_STATUS status); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| template <typename T> | |||||
| inline MH_STATUS MH_CreateHookEx(LPVOID pTarget, LPVOID pDetour, T **ppOriginal) | |||||
| { | |||||
| return MH_CreateHook(pTarget, pDetour, reinterpret_cast<LPVOID *>(ppOriginal)); | |||||
| } | |||||
| template <typename T> | |||||
| inline MH_STATUS MH_CreateHookApiEx( | |||||
| LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, T **ppOriginal) | |||||
| { | |||||
| return MH_CreateHookApi( | |||||
| pszModule, pszProcName, pDetour, reinterpret_cast<LPVOID *>(ppOriginal)); | |||||
| } | |||||
| @@ -0,0 +1,695 @@ | |||||
| #ifdef _WIN32 | |||||
| #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) | |||||
| #define _CRT_SECURE_NO_WARNINGS // _CRT_SECURE_NO_WARNINGS for sscanf errors in MSVC2013 Express | |||||
| #endif | |||||
| #ifndef WIN32_LEAN_AND_MEAN | |||||
| #define WIN32_LEAN_AND_MEAN | |||||
| #endif | |||||
| #include <fcntl.h> | |||||
| #include <WinSock2.h> | |||||
| #include <WS2tcpip.h> | |||||
| #pragma comment(lib, "ws2_32") | |||||
| #include <stdio.h> | |||||
| #include <stdlib.h> | |||||
| #include <string.h> | |||||
| #include <sys/types.h> | |||||
| #include <io.h> | |||||
| #ifndef _SSIZE_T_DEFINED | |||||
| typedef int ssize_t; | |||||
| #define _SSIZE_T_DEFINED | |||||
| #endif | |||||
| #ifndef _SOCKET_T_DEFINED | |||||
| typedef SOCKET socket_t; | |||||
| #define _SOCKET_T_DEFINED | |||||
| #endif | |||||
| #ifndef snprintf | |||||
| #define snprintf _snprintf_s | |||||
| #endif | |||||
| #if _MSC_VER >= 1600 | |||||
| // vs2010 or later | |||||
| #include <stdint.h> | |||||
| #else | |||||
| typedef __int8 int8_t; | |||||
| typedef unsigned __int8 uint8_t; | |||||
| typedef __int32 int32_t; | |||||
| typedef unsigned __int32 uint32_t; | |||||
| typedef __int64 int64_t; | |||||
| typedef unsigned __int64 uint64_t; | |||||
| #endif | |||||
| #define socketerrno WSAGetLastError() | |||||
| #define SOCKET_EAGAIN_EINPROGRESS WSAEINPROGRESS | |||||
| #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK | |||||
| #else | |||||
| #include <fcntl.h> | |||||
| #include <netdb.h> | |||||
| #include <netinet/in.h> | |||||
| #include <netinet/tcp.h> | |||||
| #include <stdio.h> | |||||
| #include <stdlib.h> | |||||
| #include <string.h> | |||||
| #include <sys/socket.h> | |||||
| #include <sys/time.h> | |||||
| #include <sys/types.h> | |||||
| #include <unistd.h> | |||||
| #include <stdint.h> | |||||
| #ifndef _SOCKET_T_DEFINED | |||||
| typedef int socket_t; | |||||
| #define _SOCKET_T_DEFINED | |||||
| #endif | |||||
| #ifndef INVALID_SOCKET | |||||
| #define INVALID_SOCKET (-1) | |||||
| #endif | |||||
| #ifndef SOCKET_ERROR | |||||
| #define SOCKET_ERROR (-1) | |||||
| #endif | |||||
| #define closesocket(s) ::close(s) | |||||
| #include <errno.h> | |||||
| #define socketerrno errno | |||||
| #define SOCKET_EAGAIN_EINPROGRESS EAGAIN | |||||
| #define SOCKET_EWOULDBLOCK EWOULDBLOCK | |||||
| #endif | |||||
| #include <vector> | |||||
| #include <string> | |||||
| #include "easywsclient.hpp" | |||||
| using easywsclient::BytesCallback_Imp; | |||||
| using easywsclient::Callback_Imp; | |||||
| namespace | |||||
| { // private module-only namespace | |||||
| socket_t hostname_connect(const std::string &hostname, int port) | |||||
| { | |||||
| struct addrinfo hints; | |||||
| struct addrinfo *result; | |||||
| struct addrinfo *p; | |||||
| int ret; | |||||
| socket_t sockfd = INVALID_SOCKET; | |||||
| char sport[16]; | |||||
| memset(&hints, 0, sizeof(hints)); | |||||
| hints.ai_family = AF_UNSPEC; | |||||
| hints.ai_socktype = SOCK_STREAM; | |||||
| snprintf(sport, 16, "%d", port); | |||||
| if ((ret = getaddrinfo(hostname.c_str(), sport, &hints, &result)) != 0) | |||||
| { | |||||
| fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret)); | |||||
| return 1; | |||||
| } | |||||
| for (p = result; p != NULL; p = p->ai_next) | |||||
| { | |||||
| sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); | |||||
| if (sockfd == INVALID_SOCKET) | |||||
| { | |||||
| continue; | |||||
| } | |||||
| if (connect(sockfd, p->ai_addr, p->ai_addrlen) != SOCKET_ERROR) | |||||
| { | |||||
| break; | |||||
| } | |||||
| closesocket(sockfd); | |||||
| sockfd = INVALID_SOCKET; | |||||
| } | |||||
| freeaddrinfo(result); | |||||
| return sockfd; | |||||
| } | |||||
| class _DummyWebSocket : public easywsclient::WebSocket | |||||
| { | |||||
| public: | |||||
| void poll(int timeout) {} | |||||
| void send(const std::string &message) {} | |||||
| void sendBinary(const std::string &message) {} | |||||
| void sendBinary(const std::vector<uint8_t> &message) {} | |||||
| void sendPing() {} | |||||
| void close() {} | |||||
| readyStateValues getReadyState() const { return CLOSED; } | |||||
| void _dispatch(Callback_Imp &callable) {} | |||||
| void _dispatchBinary(BytesCallback_Imp &callable) {} | |||||
| }; | |||||
| class _RealWebSocket : public easywsclient::WebSocket | |||||
| { | |||||
| public: | |||||
| // http://tools.ietf.org/html/rfc6455#section-5.2 Base Framing Protocol | |||||
| // | |||||
| // 0 1 2 3 | |||||
| // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |||||
| // +-+-+-+-+-------+-+-------------+-------------------------------+ | |||||
| // |F|R|R|R| opcode|M| Payload len | Extended payload length | | |||||
| // |I|S|S|S| (4) |A| (7) | (16/64) | | |||||
| // |N|V|V|V| |S| | (if payload len==126/127) | | |||||
| // | |1|2|3| |K| | | | |||||
| // +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | |||||
| // | Extended payload length continued, if payload len == 127 | | |||||
| // + - - - - - - - - - - - - - - - +-------------------------------+ | |||||
| // | |Masking-key, if MASK set to 1 | | |||||
| // +-------------------------------+-------------------------------+ | |||||
| // | Masking-key (continued) | Payload Data | | |||||
| // +-------------------------------- - - - - - - - - - - - - - - - + | |||||
| // : Payload Data continued ... : | |||||
| // + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | |||||
| // | Payload Data continued ... | | |||||
| // +---------------------------------------------------------------+ | |||||
| struct wsheader_type | |||||
| { | |||||
| unsigned header_size; | |||||
| bool fin; | |||||
| bool mask; | |||||
| enum opcode_type | |||||
| { | |||||
| CONTINUATION = 0x0, | |||||
| TEXT_FRAME = 0x1, | |||||
| BINARY_FRAME = 0x2, | |||||
| CLOSE = 8, | |||||
| PING = 9, | |||||
| PONG = 0xa, | |||||
| } opcode; | |||||
| int N0; | |||||
| uint64_t N; | |||||
| uint8_t masking_key[4]; | |||||
| }; | |||||
| std::vector<uint8_t> rxbuf; | |||||
| std::vector<uint8_t> txbuf; | |||||
| std::vector<uint8_t> receivedData; | |||||
| socket_t sockfd; | |||||
| readyStateValues readyState; | |||||
| bool useMask; | |||||
| bool isRxBad; | |||||
| _RealWebSocket(socket_t sockfd, bool useMask) | |||||
| : sockfd(sockfd), readyState(OPEN), useMask(useMask), isRxBad(false) | |||||
| { | |||||
| } | |||||
| readyStateValues getReadyState() const | |||||
| { | |||||
| return readyState; | |||||
| } | |||||
| void poll(int timeout) | |||||
| { // timeout in milliseconds | |||||
| if (readyState == CLOSED) | |||||
| { | |||||
| if (timeout > 0) | |||||
| { | |||||
| timeval tv = {timeout / 1000, (timeout % 1000) * 1000}; | |||||
| select(0, NULL, NULL, NULL, &tv); | |||||
| } | |||||
| return; | |||||
| } | |||||
| if (timeout != 0) | |||||
| { | |||||
| fd_set rfds; | |||||
| fd_set wfds; | |||||
| timeval tv = {timeout / 1000, (timeout % 1000) * 1000}; | |||||
| FD_ZERO(&rfds); | |||||
| FD_ZERO(&wfds); | |||||
| FD_SET(sockfd, &rfds); | |||||
| if (txbuf.size()) | |||||
| { | |||||
| FD_SET(sockfd, &wfds); | |||||
| } | |||||
| select(sockfd + 1, &rfds, &wfds, 0, timeout > 0 ? &tv : 0); | |||||
| } | |||||
| while (true) | |||||
| { | |||||
| // FD_ISSET(0, &rfds) will be true | |||||
| int N = rxbuf.size(); | |||||
| ssize_t ret; | |||||
| rxbuf.resize(N + 1500); | |||||
| ret = recv(sockfd, (char *)&rxbuf[0] + N, 1500, 0); | |||||
| if (false) | |||||
| { | |||||
| } | |||||
| else if (ret < 0 && (socketerrno == SOCKET_EWOULDBLOCK || socketerrno == SOCKET_EAGAIN_EINPROGRESS)) | |||||
| { | |||||
| rxbuf.resize(N); | |||||
| break; | |||||
| } | |||||
| else if (ret <= 0) | |||||
| { | |||||
| rxbuf.resize(N); | |||||
| closesocket(sockfd); | |||||
| readyState = CLOSED; | |||||
| fputs(ret < 0 ? "Connection error!\n" : "Connection closed!\n", stderr); | |||||
| break; | |||||
| } | |||||
| else | |||||
| { | |||||
| rxbuf.resize(N + ret); | |||||
| } | |||||
| } | |||||
| while (txbuf.size()) | |||||
| { | |||||
| int ret = ::send(sockfd, (char *)&txbuf[0], txbuf.size(), 0); | |||||
| if (false) | |||||
| { | |||||
| } // ?? | |||||
| else if (ret < 0 && (socketerrno == SOCKET_EWOULDBLOCK || socketerrno == SOCKET_EAGAIN_EINPROGRESS)) | |||||
| { | |||||
| break; | |||||
| } | |||||
| else if (ret <= 0) | |||||
| { | |||||
| closesocket(sockfd); | |||||
| readyState = CLOSED; | |||||
| fputs(ret < 0 ? "Connection error!\n" : "Connection closed!\n", stderr); | |||||
| break; | |||||
| } | |||||
| else | |||||
| { | |||||
| txbuf.erase(txbuf.begin(), txbuf.begin() + ret); | |||||
| } | |||||
| } | |||||
| if (!txbuf.size() && readyState == CLOSING) | |||||
| { | |||||
| closesocket(sockfd); | |||||
| readyState = CLOSED; | |||||
| } | |||||
| } | |||||
| // Callable must have signature: void(const std::string & message). | |||||
| // Should work with C functions, C++ functors, and C++11 std::function and | |||||
| // lambda: | |||||
| //template<class Callable> | |||||
| //void dispatch(Callable callable) | |||||
| virtual void _dispatch(Callback_Imp &callable) | |||||
| { | |||||
| struct CallbackAdapter : public BytesCallback_Imp | |||||
| // Adapt void(const std::string<uint8_t>&) to void(const std::string&) | |||||
| { | |||||
| Callback_Imp &callable; | |||||
| CallbackAdapter(Callback_Imp &callable) : callable(callable) {} | |||||
| void operator()(const std::vector<uint8_t> &message) | |||||
| { | |||||
| std::string stringMessage(message.begin(), message.end()); | |||||
| callable(stringMessage); | |||||
| } | |||||
| }; | |||||
| CallbackAdapter bytesCallback(callable); | |||||
| _dispatchBinary(bytesCallback); | |||||
| } | |||||
| virtual void _dispatchBinary(BytesCallback_Imp &callable) | |||||
| { | |||||
| // TODO: consider acquiring a lock on rxbuf... | |||||
| if (isRxBad) | |||||
| { | |||||
| return; | |||||
| } | |||||
| while (true) | |||||
| { | |||||
| wsheader_type ws; | |||||
| if (rxbuf.size() < 2) | |||||
| { | |||||
| return; /* Need at least 2 */ | |||||
| } | |||||
| const uint8_t *data = (uint8_t *)&rxbuf[0]; // peek, but don't consume | |||||
| ws.fin = (data[0] & 0x80) == 0x80; | |||||
| ws.opcode = (wsheader_type::opcode_type)(data[0] & 0x0f); | |||||
| ws.mask = (data[1] & 0x80) == 0x80; | |||||
| ws.N0 = (data[1] & 0x7f); | |||||
| ws.header_size = 2 + (ws.N0 == 126 ? 2 : 0) + (ws.N0 == 127 ? 8 : 0) + (ws.mask ? 4 : 0); | |||||
| if (rxbuf.size() < ws.header_size) | |||||
| { | |||||
| return; /* Need: ws.header_size - rxbuf.size() */ | |||||
| } | |||||
| int i = 0; | |||||
| if (ws.N0 < 126) | |||||
| { | |||||
| ws.N = ws.N0; | |||||
| i = 2; | |||||
| } | |||||
| else if (ws.N0 == 126) | |||||
| { | |||||
| ws.N = 0; | |||||
| ws.N |= ((uint64_t)data[2]) << 8; | |||||
| ws.N |= ((uint64_t)data[3]) << 0; | |||||
| i = 4; | |||||
| } | |||||
| else if (ws.N0 == 127) | |||||
| { | |||||
| ws.N = 0; | |||||
| ws.N |= ((uint64_t)data[2]) << 56; | |||||
| ws.N |= ((uint64_t)data[3]) << 48; | |||||
| ws.N |= ((uint64_t)data[4]) << 40; | |||||
| ws.N |= ((uint64_t)data[5]) << 32; | |||||
| ws.N |= ((uint64_t)data[6]) << 24; | |||||
| ws.N |= ((uint64_t)data[7]) << 16; | |||||
| ws.N |= ((uint64_t)data[8]) << 8; | |||||
| ws.N |= ((uint64_t)data[9]) << 0; | |||||
| i = 10; | |||||
| if (ws.N & 0x8000000000000000ull) | |||||
| { | |||||
| // https://tools.ietf.org/html/rfc6455 writes the "the most | |||||
| // significant bit MUST be 0." | |||||
| // | |||||
| // We can't drop the frame, because (1) we don't we don't | |||||
| // know how much data to skip over to find the next header, | |||||
| // and (2) this would be an impractically long length, even | |||||
| // if it were valid. So just close() and return immediately | |||||
| // for now. | |||||
| isRxBad = true; | |||||
| fprintf(stderr, "ERROR: Frame has invalid frame length. Closing.\n"); | |||||
| close(); | |||||
| return; | |||||
| } | |||||
| } | |||||
| if (ws.mask) | |||||
| { | |||||
| ws.masking_key[0] = ((uint8_t)data[i + 0]) << 0; | |||||
| ws.masking_key[1] = ((uint8_t)data[i + 1]) << 0; | |||||
| ws.masking_key[2] = ((uint8_t)data[i + 2]) << 0; | |||||
| ws.masking_key[3] = ((uint8_t)data[i + 3]) << 0; | |||||
| } | |||||
| else | |||||
| { | |||||
| ws.masking_key[0] = 0; | |||||
| ws.masking_key[1] = 0; | |||||
| ws.masking_key[2] = 0; | |||||
| ws.masking_key[3] = 0; | |||||
| } | |||||
| // Note: The checks above should hopefully ensure this addition | |||||
| // cannot overflow: | |||||
| if (rxbuf.size() < ws.header_size + ws.N) | |||||
| { | |||||
| return; /* Need: ws.header_size+ws.N - rxbuf.size() */ | |||||
| } | |||||
| // We got a whole message, now do something with it: | |||||
| if (false) | |||||
| { | |||||
| } | |||||
| else if ( | |||||
| ws.opcode == wsheader_type::TEXT_FRAME || ws.opcode == wsheader_type::BINARY_FRAME || ws.opcode == wsheader_type::CONTINUATION) | |||||
| { | |||||
| if (ws.mask) | |||||
| { | |||||
| for (size_t i = 0; i != ws.N; ++i) | |||||
| { | |||||
| rxbuf[i + ws.header_size] ^= ws.masking_key[i & 0x3]; | |||||
| } | |||||
| } | |||||
| receivedData.insert(receivedData.end(), rxbuf.begin() + ws.header_size, rxbuf.begin() + ws.header_size + (size_t)ws.N); // just feed | |||||
| if (ws.fin) | |||||
| { | |||||
| callable((const std::vector<uint8_t>)receivedData); | |||||
| receivedData.erase(receivedData.begin(), receivedData.end()); | |||||
| std::vector<uint8_t>().swap(receivedData); // free memory | |||||
| } | |||||
| } | |||||
| else if (ws.opcode == wsheader_type::PING) | |||||
| { | |||||
| if (ws.mask) | |||||
| { | |||||
| for (size_t i = 0; i != ws.N; ++i) | |||||
| { | |||||
| rxbuf[i + ws.header_size] ^= ws.masking_key[i & 0x3]; | |||||
| } | |||||
| } | |||||
| std::string data(rxbuf.begin() + ws.header_size, rxbuf.begin() + ws.header_size + (size_t)ws.N); | |||||
| sendData(wsheader_type::PONG, data.size(), data.begin(), data.end()); | |||||
| } | |||||
| else if (ws.opcode == wsheader_type::PONG) | |||||
| { | |||||
| } | |||||
| else if (ws.opcode == wsheader_type::CLOSE) | |||||
| { | |||||
| close(); | |||||
| } | |||||
| else | |||||
| { | |||||
| fprintf(stderr, "ERROR: Got unexpected WebSocket message.\n"); | |||||
| close(); | |||||
| } | |||||
| rxbuf.erase(rxbuf.begin(), rxbuf.begin() + ws.header_size + (size_t)ws.N); | |||||
| } | |||||
| } | |||||
| void sendPing() | |||||
| { | |||||
| std::string empty; | |||||
| sendData(wsheader_type::PING, empty.size(), empty.begin(), empty.end()); | |||||
| } | |||||
| void send(const std::string &message) | |||||
| { | |||||
| sendData(wsheader_type::TEXT_FRAME, message.size(), message.begin(), message.end()); | |||||
| } | |||||
| void sendBinary(const std::string &message) | |||||
| { | |||||
| sendData(wsheader_type::BINARY_FRAME, message.size(), message.begin(), message.end()); | |||||
| } | |||||
| void sendBinary(const std::vector<uint8_t> &message) | |||||
| { | |||||
| sendData(wsheader_type::BINARY_FRAME, message.size(), message.begin(), message.end()); | |||||
| } | |||||
| template <class Iterator> | |||||
| void sendData(wsheader_type::opcode_type type, uint64_t message_size, Iterator message_begin, Iterator message_end) | |||||
| { | |||||
| // TODO: | |||||
| // Masking key should (must) be derived from a high quality random | |||||
| // number generator, to mitigate attacks on non-WebSocket friendly | |||||
| // middleware: | |||||
| const uint8_t masking_key[4] = {0x12, 0x34, 0x56, 0x78}; | |||||
| // TODO: consider acquiring a lock on txbuf... | |||||
| if (readyState == CLOSING || readyState == CLOSED) | |||||
| { | |||||
| return; | |||||
| } | |||||
| std::vector<uint8_t> header; | |||||
| header.assign(2 + (message_size >= 126 ? 2 : 0) + (message_size >= 65536 ? 6 : 0) + (useMask ? 4 : 0), 0); | |||||
| header[0] = 0x80 | type; | |||||
| if (false) | |||||
| { | |||||
| } | |||||
| else if (message_size < 126) | |||||
| { | |||||
| header[1] = (message_size & 0xff) | (useMask ? 0x80 : 0); | |||||
| if (useMask) | |||||
| { | |||||
| header[2] = masking_key[0]; | |||||
| header[3] = masking_key[1]; | |||||
| header[4] = masking_key[2]; | |||||
| header[5] = masking_key[3]; | |||||
| } | |||||
| } | |||||
| else if (message_size < 65536) | |||||
| { | |||||
| header[1] = 126 | (useMask ? 0x80 : 0); | |||||
| header[2] = (message_size >> 8) & 0xff; | |||||
| header[3] = (message_size >> 0) & 0xff; | |||||
| if (useMask) | |||||
| { | |||||
| header[4] = masking_key[0]; | |||||
| header[5] = masking_key[1]; | |||||
| header[6] = masking_key[2]; | |||||
| header[7] = masking_key[3]; | |||||
| } | |||||
| } | |||||
| else | |||||
| { // TODO: run coverage testing here | |||||
| header[1] = 127 | (useMask ? 0x80 : 0); | |||||
| header[2] = (message_size >> 56) & 0xff; | |||||
| header[3] = (message_size >> 48) & 0xff; | |||||
| header[4] = (message_size >> 40) & 0xff; | |||||
| header[5] = (message_size >> 32) & 0xff; | |||||
| header[6] = (message_size >> 24) & 0xff; | |||||
| header[7] = (message_size >> 16) & 0xff; | |||||
| header[8] = (message_size >> 8) & 0xff; | |||||
| header[9] = (message_size >> 0) & 0xff; | |||||
| if (useMask) | |||||
| { | |||||
| header[10] = masking_key[0]; | |||||
| header[11] = masking_key[1]; | |||||
| header[12] = masking_key[2]; | |||||
| header[13] = masking_key[3]; | |||||
| } | |||||
| } | |||||
| // N.B. - txbuf will keep growing until it can be transmitted over the socket: | |||||
| txbuf.insert(txbuf.end(), header.begin(), header.end()); | |||||
| txbuf.insert(txbuf.end(), message_begin, message_end); | |||||
| if (useMask) | |||||
| { | |||||
| size_t message_offset = txbuf.size() - message_size; | |||||
| for (size_t i = 0; i != message_size; ++i) | |||||
| { | |||||
| txbuf[message_offset + i] ^= masking_key[i & 0x3]; | |||||
| } | |||||
| } | |||||
| } | |||||
| void close() | |||||
| { | |||||
| if (readyState == CLOSING || readyState == CLOSED) | |||||
| { | |||||
| return; | |||||
| } | |||||
| readyState = CLOSING; | |||||
| uint8_t closeFrame[6] = {0x88, 0x80, 0x00, 0x00, 0x00, 0x00}; // last 4 bytes are a masking key | |||||
| std::vector<uint8_t> header(closeFrame, closeFrame + 6); | |||||
| txbuf.insert(txbuf.end(), header.begin(), header.end()); | |||||
| } | |||||
| }; | |||||
| easywsclient::WebSocket::pointer from_url(const std::string &url, bool useMask, const std::string &origin, bool internal = false) | |||||
| { | |||||
| char host[512]; | |||||
| int port; | |||||
| char path[512]; | |||||
| if (url.size() >= 512) | |||||
| { | |||||
| fprintf(stderr, "ERROR: url size limit exceeded: %s\n", url.c_str()); | |||||
| return NULL; | |||||
| } | |||||
| if (origin.size() >= 200) | |||||
| { | |||||
| fprintf(stderr, "ERROR: origin size limit exceeded: %s\n", origin.c_str()); | |||||
| return NULL; | |||||
| } | |||||
| if (false) | |||||
| { | |||||
| } | |||||
| else if (sscanf(url.c_str(), "ws://%[^:/]:%d/%s", host, &port, path) == 3) | |||||
| { | |||||
| } | |||||
| else if (sscanf(url.c_str(), "ws://%[^:/]/%s", host, path) == 2) | |||||
| { | |||||
| port = 80; | |||||
| } | |||||
| else if (sscanf(url.c_str(), "ws://%[^:/]:%d", host, &port) == 2) | |||||
| { | |||||
| path[0] = '\0'; | |||||
| } | |||||
| else if (sscanf(url.c_str(), "ws://%[^:/]", host) == 1) | |||||
| { | |||||
| port = 80; | |||||
| path[0] = '\0'; | |||||
| } | |||||
| else | |||||
| { | |||||
| fprintf(stderr, "ERROR: Could not parse WebSocket url: %s\n", url.c_str()); | |||||
| return NULL; | |||||
| } | |||||
| //fprintf(stderr, "easywsclient: connecting: host=%s port=%d path=/%s\n", host, port, path); | |||||
| socket_t sockfd = hostname_connect(host, port); | |||||
| if (sockfd == INVALID_SOCKET) | |||||
| { | |||||
| fprintf(stderr, "Unable to connect to %s:%d\n", host, port); | |||||
| return NULL; | |||||
| } | |||||
| { | |||||
| // XXX: this should be done non-blocking, | |||||
| char line[1024]; | |||||
| int status; | |||||
| int i; | |||||
| snprintf(line, 1024, "GET /%s HTTP/1.1\r\n", path); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| if (port == 80) | |||||
| { | |||||
| snprintf(line, 1024, "Host: %s\r\n", host); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| } | |||||
| else | |||||
| { | |||||
| snprintf(line, 1024, "Host: %s:%d\r\n", host, port); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| } | |||||
| snprintf(line, 1024, "Upgrade: websocket\r\n"); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| snprintf(line, 1024, "Connection: Upgrade\r\n"); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| if (!origin.empty()) | |||||
| { | |||||
| snprintf(line, 1024, "Origin: %s\r\n", origin.c_str()); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| } | |||||
| snprintf(line, 1024, "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==\r\n"); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| if (internal) | |||||
| { | |||||
| snprintf(line, 1024, "internal: true\r\n"); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| } | |||||
| snprintf(line, 1024, "Sec-WebSocket-Version: 13\r\n"); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| snprintf(line, 1024, "\r\n"); | |||||
| ::send(sockfd, line, strlen(line), 0); | |||||
| for (i = 0; i < 2 || (i < 1023 && line[i - 2] != '\r' && line[i - 1] != '\n'); ++i) | |||||
| { | |||||
| if (recv(sockfd, line + i, 1, 0) == 0) | |||||
| { | |||||
| return NULL; | |||||
| } | |||||
| } | |||||
| line[i] = 0; | |||||
| if (i == 1023) | |||||
| { | |||||
| fprintf(stderr, "ERROR: Got invalid status line connecting to: %s\n", url.c_str()); | |||||
| return NULL; | |||||
| } | |||||
| if (sscanf(line, "HTTP/1.1 %d", &status) != 1 || status != 101) | |||||
| { | |||||
| fprintf(stderr, "ERROR: Got bad status connecting to %s: %s", url.c_str(), line); | |||||
| return NULL; | |||||
| } | |||||
| // TODO: verify response headers, | |||||
| while (true) | |||||
| { | |||||
| for (i = 0; i < 2 || (i < 1023 && line[i - 2] != '\r' && line[i - 1] != '\n'); ++i) | |||||
| { | |||||
| if (recv(sockfd, line + i, 1, 0) == 0) | |||||
| { | |||||
| return NULL; | |||||
| } | |||||
| } | |||||
| if (line[0] == '\r' && line[1] == '\n') | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| int flag = 1; | |||||
| setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag)); // Disable Nagle's algorithm | |||||
| #ifdef _WIN32 | |||||
| u_long on = 1; | |||||
| ioctlsocket(sockfd, FIONBIO, &on); | |||||
| #else | |||||
| fcntl(sockfd, F_SETFL, O_NONBLOCK); | |||||
| #endif | |||||
| //fprintf(stderr, "Connected to: %s\n", url.c_str()); | |||||
| return easywsclient::WebSocket::pointer(new _RealWebSocket(sockfd, useMask)); | |||||
| } | |||||
| } // end of module-only namespace | |||||
| namespace easywsclient | |||||
| { | |||||
| WebSocket::pointer WebSocket::create_dummy() | |||||
| { | |||||
| static pointer dummy = pointer(new _DummyWebSocket); | |||||
| return dummy; | |||||
| } | |||||
| WebSocket::pointer WebSocket::from_url(const std::string &url, const std::string &origin, bool internal) | |||||
| { | |||||
| return ::from_url(url, true, origin, internal); | |||||
| } | |||||
| WebSocket::pointer WebSocket::from_url_no_mask(const std::string &url, const std::string &origin) | |||||
| { | |||||
| return ::from_url(url, false, origin); | |||||
| } | |||||
| } // namespace easywsclient | |||||
| @@ -0,0 +1,89 @@ | |||||
| #ifndef EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD | |||||
| #define EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD | |||||
| // This code comes from: | |||||
| // https://github.com/dhbaird/easywsclient | |||||
| // | |||||
| // To get the latest version: | |||||
| // wget https://raw.github.com/dhbaird/easywsclient/master/easywsclient.hpp | |||||
| // wget https://raw.github.com/dhbaird/easywsclient/master/easywsclient.cpp | |||||
| #include <string> | |||||
| #include <vector> | |||||
| namespace easywsclient | |||||
| { | |||||
| struct Callback_Imp | |||||
| { | |||||
| virtual void operator()(const std::string &message) = 0; | |||||
| }; | |||||
| struct BytesCallback_Imp | |||||
| { | |||||
| virtual void operator()(const std::vector<uint8_t> &message) = 0; | |||||
| }; | |||||
| class WebSocket | |||||
| { | |||||
| public: | |||||
| typedef WebSocket *pointer; | |||||
| typedef enum readyStateValues | |||||
| { | |||||
| CLOSING, | |||||
| CLOSED, | |||||
| CONNECTING, | |||||
| OPEN | |||||
| } readyStateValues; | |||||
| // Factories: | |||||
| static pointer create_dummy(); | |||||
| static pointer from_url(const std::string &url, const std::string &origin = std::string()); | |||||
| static pointer from_url(const std::string &url, const std::string &origin = std::string(), bool internal = false); | |||||
| static pointer from_url_no_mask(const std::string &url, const std::string &origin = std::string()); | |||||
| // Interfaces: | |||||
| virtual ~WebSocket() {} | |||||
| virtual void poll(int timeout = 0) = 0; // timeout in milliseconds | |||||
| virtual void send(const std::string &message) = 0; | |||||
| virtual void sendBinary(const std::string &message) = 0; | |||||
| virtual void sendBinary(const std::vector<uint8_t> &message) = 0; | |||||
| virtual void sendPing() = 0; | |||||
| virtual void close() = 0; | |||||
| virtual readyStateValues getReadyState() const = 0; | |||||
| template <class Callable> | |||||
| void dispatch(Callable callable) | |||||
| // For callbacks that accept a string argument. | |||||
| { // N.B. this is compatible with both C++11 lambdas, functors and C function pointers | |||||
| struct _Callback : public Callback_Imp | |||||
| { | |||||
| Callable &callable; | |||||
| _Callback(Callable &callable) : callable(callable) {} | |||||
| void operator()(const std::string &message) { callable(message); } | |||||
| }; | |||||
| _Callback callback(callable); | |||||
| _dispatch(callback); | |||||
| } | |||||
| template <class Callable> | |||||
| void dispatchBinary(Callable callable) | |||||
| // For callbacks that accept a std::vector<uint8_t> argument. | |||||
| { // N.B. this is compatible with both C++11 lambdas, functors and C function pointers | |||||
| struct _Callback : public BytesCallback_Imp | |||||
| { | |||||
| Callable &callable; | |||||
| _Callback(Callable &callable) : callable(callable) {} | |||||
| void operator()(const std::vector<uint8_t> &message) { callable(message); } | |||||
| }; | |||||
| _Callback callback(callable); | |||||
| _dispatchBinary(callback); | |||||
| } | |||||
| protected: | |||||
| virtual void _dispatch(Callback_Imp &callable) = 0; | |||||
| virtual void _dispatchBinary(BytesCallback_Imp &callable) = 0; | |||||
| }; | |||||
| } // namespace easywsclient | |||||
| #endif /* EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD */ | |||||
| @@ -0,0 +1,655 @@ | |||||
| #pragma once | |||||
| // #include <istream> | |||||
| // #include <fstream> | |||||
| // #include <vector> | |||||
| #include <string> | |||||
| // #include <sstream> | |||||
| // #include <Psapi.h> | |||||
| // #include <iterator> | |||||
| #include <Windows.h> | |||||
| // #include <assert.h> | |||||
| // #include <iostream> | |||||
| // #include <algorithm> | |||||
| #include <Psapi.h> | |||||
| // enum EPagePermissions | |||||
| // { | |||||
| // Execute = PAGE_EXECUTE, | |||||
| // ExecuteRead = PAGE_EXECUTE_READ, | |||||
| // ExecuteReadWrite = PAGE_EXECUTE_READWRITE, | |||||
| // ExecuteWriteCopy = PAGE_EXECUTE_WRITECOPY, | |||||
| // Read = PAGE_READONLY, | |||||
| // ReadWrite = PAGE_READWRITE, | |||||
| // WriteCopy = PAGE_WRITECOPY, | |||||
| // WriteCombine = PAGE_WRITECOMBINE | |||||
| // }; | |||||
| // struct PatternInfo | |||||
| // { | |||||
| // const char *Pattern; | |||||
| // EPagePermissions Permissions; | |||||
| // }; | |||||
| namespace PatternScan | |||||
| { | |||||
| // struct PatternByte | |||||
| // { | |||||
| // struct PatternNibble | |||||
| // { | |||||
| // unsigned char data; | |||||
| // bool wildcard; | |||||
| // } nibble[2]; | |||||
| // }; | |||||
| // static std::string formathexpattern(std::string patterntext) | |||||
| // { | |||||
| // std::string result; | |||||
| // int len = patterntext.length(); | |||||
| // for (int i = 0; i < len; i++) | |||||
| // if (patterntext[i] == '?' || isxdigit(patterntext[i])) | |||||
| // result += toupper(patterntext[i]); | |||||
| // return result; | |||||
| // } | |||||
| // static int hexchtoint(char ch) | |||||
| // { | |||||
| // if (ch >= '0' && ch <= '9') | |||||
| // return ch - '0'; | |||||
| // else if (ch >= 'A' && ch <= 'F') | |||||
| // return ch - 'A' + 10; | |||||
| // else if (ch >= 'a' && ch <= 'f') | |||||
| // return ch - 'a' + 10; | |||||
| // return 0; | |||||
| // } | |||||
| // static bool patterntransform(std::string patterntext, std::vector<PatternByte> &pattern) | |||||
| // { | |||||
| // pattern.clear(); | |||||
| // patterntext = formathexpattern(patterntext); | |||||
| // int len = patterntext.length(); | |||||
| // if (!len) | |||||
| // return false; | |||||
| // if (len % 2) //not a multiple of 2 | |||||
| // { | |||||
| // patterntext += '?'; | |||||
| // len++; | |||||
| // } | |||||
| // PatternByte newByte; | |||||
| // for (int i = 0, j = 0; i < len; i++) | |||||
| // { | |||||
| // if (patterntext[i] == '?') //wildcard | |||||
| // { | |||||
| // newByte.nibble[j].wildcard = true; //match anything | |||||
| // } | |||||
| // else //hex | |||||
| // { | |||||
| // newByte.nibble[j].wildcard = false; | |||||
| // newByte.nibble[j].data = hexchtoint(patterntext[i]) & 0xF; | |||||
| // } | |||||
| // j++; | |||||
| // if (j == 2) //two nibbles = one byte | |||||
| // { | |||||
| // j = 0; | |||||
| // pattern.push_back(newByte); | |||||
| // } | |||||
| // } | |||||
| // return true; | |||||
| // } | |||||
| // static bool patternmatchbyte(unsigned char byte, const PatternByte &pbyte) | |||||
| // { | |||||
| // int matched = 0; | |||||
| // unsigned char n1 = (byte >> 4) & 0xF; | |||||
| // if (pbyte.nibble[0].wildcard) | |||||
| // matched++; | |||||
| // else if (pbyte.nibble[0].data == n1) | |||||
| // matched++; | |||||
| // unsigned char n2 = byte & 0xF; | |||||
| // if (pbyte.nibble[1].wildcard) | |||||
| // matched++; | |||||
| // else if (pbyte.nibble[1].data == n2) | |||||
| // matched++; | |||||
| // return (matched == 2); | |||||
| // } | |||||
| // size_t patternfind(std::string pattern, int offset) | |||||
| // { | |||||
| // std::vector<PatternByte> searchpattern; | |||||
| // std::string::iterator end_pos = std::remove(pattern.begin(), pattern.end(), ' '); | |||||
| // pattern.erase(end_pos, pattern.end()); | |||||
| // SYSTEM_INFO sysinf; | |||||
| // GetSystemInfo(&sysinf); | |||||
| // DWORD startAddress = (DWORD)sysinf.lpMinimumApplicationAddress; | |||||
| // unsigned char *data = (unsigned char *)startAddress; | |||||
| // //MEMORY_BASIC_INFORMATION mbi; | |||||
| // if (!patterntransform(pattern.c_str(), searchpattern)) | |||||
| // return (size_t)-1; | |||||
| // //#define MEMORY_READABLE (PAGE_READONLY | PAGE_READWRITE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE) | |||||
| // //#define MEMORY_WRITABLE (PAGE_READWRITE | PAGE_EXECUTE_READWRITE) | |||||
| // //#define MEMORY_EXECUTABLE (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE) | |||||
| // size_t searchpatternsize = searchpattern.size(); | |||||
| // for (size_t i = 0, pos = 0; i < 0x7FFFFFFF; i++) //search for the pattern | |||||
| // { | |||||
| // //if (VirtualQuery((LPVOID)i, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) != 0 | |||||
| // // && ((mbi.State != MEM_COMMIT) || !(mbi.Protect & MEMORY_READABLE) || (mbi.Protect & PAGE_GUARD))) | |||||
| // // //&& mbi.State == MEM_COMMIT && mbi.Protect != PAGE_NOACCESS && !(mbi.Protect & PAGE_GUARD)) | |||||
| // //{ | |||||
| // if (patternmatchbyte(data[i], searchpattern.at(pos))) //check if our pattern matches the current byte | |||||
| // { | |||||
| // pos++; | |||||
| // if (pos == searchpatternsize) //everything matched | |||||
| // { | |||||
| // if (offset >= 0) | |||||
| // return startAddress + i - searchpatternsize + 1 + offset; | |||||
| // if (offset < 0) | |||||
| // return startAddress + i - searchpatternsize + 1 - offset; | |||||
| // } | |||||
| // } | |||||
| // else if (pos > 0) //fix by Computer_Angel | |||||
| // { | |||||
| // i -= pos; | |||||
| // pos = 0; //reset current pattern position | |||||
| // } | |||||
| // /*} | |||||
| // else | |||||
| // i += mbi.RegionSize;*/ | |||||
| // } | |||||
| // return (size_t)-1; | |||||
| // } | |||||
| // // Find all occurences of the Pattern until a wildcard is hit | |||||
| // std::vector<uintptr_t> FindAllOccurences(std::vector<char *> pattern, std::vector<char> streamToSearch) | |||||
| // { | |||||
| // std::vector<uintptr_t> positions; | |||||
| // // Length of the pattern to look for | |||||
| // unsigned int patternLength = pattern.size(); | |||||
| // // Total length of file to look through | |||||
| // unsigned int totalLength = streamToSearch.size(); | |||||
| // // First Byte of the pattern to look for | |||||
| // //unsigned char* firstMatchByte; | |||||
| // auto firstMatchByte = std::strtol(reinterpret_cast<const char *>(pattern[0]), nullptr, 16); | |||||
| // std::vector<unsigned char> parsedPattern; | |||||
| // parsedPattern.reserve(pattern.size()); | |||||
| // for (auto &pat : pattern) | |||||
| // { | |||||
| // parsedPattern.push_back((unsigned char)std::strtoul(reinterpret_cast<const char *>(pat), nullptr, 16)); | |||||
| // } | |||||
| // for (unsigned int i = 0; i < totalLength; i++) | |||||
| // { | |||||
| // //auto cmp = (unsigned char)streamToSearch[i]; | |||||
| // //auto cmp2 = (unsigned char)firstMatchByte; | |||||
| // //auto cmp2 = std::strtol(reinterpret_cast<const char*>(streamToSearch.data()[i]), nullptr, 16); | |||||
| // //auto second = streamToSearch; | |||||
| // //memcpy(&firstMatchByte, streamToSearch[i], sizeof (unsigned char*)); | |||||
| // // If the first Byte of the Searchpattern is at the current location of i | |||||
| // // and the totalLength - i is greater or equal to the pattern length | |||||
| // //if(i == 0x00000000000dca41) | |||||
| // //{ | |||||
| // //Q_ASSERT(false); | |||||
| // //} | |||||
| // if ((unsigned char)streamToSearch[i] == firstMatchByte && totalLength - i >= patternLength) | |||||
| // //if (pattern.data()[0] == *(streamToSearch.begin() +i) && totalLength - i >= patternLength) | |||||
| // { | |||||
| // std::vector<unsigned char> match; //[patternLength]; | |||||
| // match.resize(patternLength); | |||||
| // memcpy(&match[0], &streamToSearch[i], patternLength); | |||||
| // // If the current range of the search matches the searchPattern | |||||
| // // add the current position(i) to the positionList and break | |||||
| // if (memcmp(match.data(), parsedPattern.data(), patternLength) == 0) | |||||
| // { | |||||
| // positions.push_back(static_cast<uintptr_t>(i)); | |||||
| // } | |||||
| // else | |||||
| // { | |||||
| // memset(&match, 0, patternLength); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // return positions; | |||||
| // } | |||||
| // // Find all occurences of the Pattern until a wildcard is hit | |||||
| // std::vector<uintptr_t> FindAllOccurences(std::vector<char *> pattern, uintptr_t startAddress, uintptr_t totalSize = 0x7FFFFFFF) | |||||
| // { | |||||
| // std::vector<uintptr_t> positions; | |||||
| // // Length of the pattern to look for | |||||
| // unsigned int patternLength = pattern.size(); | |||||
| // // Total length of file to look through | |||||
| // unsigned int totalLength = totalSize - startAddress; | |||||
| // // First Byte of the pattern to look for | |||||
| // //unsigned char* firstMatchByte; | |||||
| // auto firstMatchByte = std::strtol(reinterpret_cast<const char *>(pattern[0]), nullptr, 16); | |||||
| // std::vector<unsigned char> parsedPattern; | |||||
| // parsedPattern.reserve(pattern.size()); | |||||
| // for (auto &pat : pattern) | |||||
| // { | |||||
| // parsedPattern.push_back((unsigned char)std::strtol(reinterpret_cast<const char *>(pat), nullptr, 16)); | |||||
| // } | |||||
| // for (unsigned int i = 0; i < totalLength; i++) | |||||
| // { | |||||
| // if ((*(PBYTE)startAddress + i) == firstMatchByte && totalLength - i >= patternLength) | |||||
| // { | |||||
| // std::vector<unsigned char> match; //[patternLength]; | |||||
| // match.resize(patternLength); | |||||
| // memcpy(&match[0], (LPVOID)(*(PBYTE)startAddress + i), patternLength); | |||||
| // // If the current range of the search matches the searchPattern | |||||
| // // add the current position(i) to the positionList and break | |||||
| // if (memcmp(match.data(), parsedPattern.data(), patternLength) == 0) | |||||
| // { | |||||
| // positions.push_back(static_cast<uintptr_t>(i)); | |||||
| // } | |||||
| // else | |||||
| // { | |||||
| // memset(&match, 0, patternLength); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // return positions; | |||||
| // } | |||||
| // // Search the given Pattern iconst n the given& char-vector | |||||
| // uintptr_t SearchBytePattern(const std::string &pattern, std::vector<char> streamToSearch, int offset) | |||||
| // { | |||||
| // std::istringstream buf(pattern); | |||||
| // std::istream_iterator<std::string> beg(buf), end; | |||||
| // std::vector<std::string> tokens(beg, end); | |||||
| // std::vector<char *> patternArray; | |||||
| // patternArray.reserve(tokens.size()); | |||||
| // for (auto &data : tokens) | |||||
| // { | |||||
| // patternArray.push_back(_strdup(data.c_str())); | |||||
| // } | |||||
| // std::vector<char *> temp; | |||||
| // for (unsigned int i = 0; i < tokens.size(); i++) | |||||
| // { | |||||
| // // Using QString for the "startsWith function | |||||
| // // auto value = QString(patternArray[i]); | |||||
| // // if(!value.startsWith('?', Qt::CaseInsensitive)) | |||||
| // auto value = std::string(patternArray[i]); | |||||
| // if (!_strnicmp(value.c_str(), "?", sizeof("?"))) | |||||
| // { | |||||
| // temp.push_back(patternArray[i]); | |||||
| // } | |||||
| // else | |||||
| // break; | |||||
| // } | |||||
| // auto occurences = FindAllOccurences(temp, streamToSearch); | |||||
| // std::vector<unsigned char> parsedPattern; | |||||
| // parsedPattern.reserve(patternArray.size()); | |||||
| // for (auto &pat : patternArray) | |||||
| // { | |||||
| // parsedPattern.push_back((unsigned char)std::strtol(reinterpret_cast<const char *>(pat), nullptr, 16)); | |||||
| // } | |||||
| // std::vector<char> check(patternArray.size()); | |||||
| // for (auto &occ : occurences) | |||||
| // { | |||||
| // memset(check.data(), 0, patternArray.size()); | |||||
| // memcpy(check.data(), &streamToSearch[occ], patternArray.size()); | |||||
| // for (unsigned int o = 0; o < patternArray.size(); o++) | |||||
| // { | |||||
| // // If the current Patterncharacter is a wildcard, go to next index | |||||
| // if (isalnum(*patternArray[o]) == 0) // == 0 || isalpha(*patternArray[0]) == 0) | |||||
| // continue; | |||||
| // // Convert current Patternindex | |||||
| // char pat = (char)std::stoul(std::string(patternArray[o]), nullptr, 16); | |||||
| // // Compare memory, if equal, result is 0 | |||||
| // int mem = memcmp(&check[o], &pat, 1); | |||||
| // // If memory is not equal, the pattern doesn't match | |||||
| // if (mem != 0) | |||||
| // { | |||||
| // break; | |||||
| // } | |||||
| // // o can only be the size of the pattern if it matches | |||||
| // if (o == patternArray.size() - 1) | |||||
| // { | |||||
| // if (offset < 0) | |||||
| // return occ - offset; | |||||
| // if (offset > 0) | |||||
| // return occ + offset; | |||||
| // return occ; | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // // No result found | |||||
| // return 0; | |||||
| // } | |||||
| // uintptr_t SearchBytePattern(uintptr_t startAddress, uintptr_t fileSize, const std::string &pattern, int offset) | |||||
| // { | |||||
| // MODULEINFO miInfos = {NULL}; | |||||
| // HMODULE hmModule = GetModuleHandle(NULL); | |||||
| // if (hmModule) | |||||
| // { | |||||
| // GetModuleInformation(GetCurrentProcess(), hmModule, &miInfos, sizeof(MODULEINFO)); | |||||
| // } | |||||
| // std::istringstream buf(pattern); | |||||
| // std::istream_iterator<std::string> beg(buf), end; | |||||
| // std::vector<std::string> tokens(beg, end); | |||||
| // std::vector<char *> patternArray; | |||||
| // patternArray.reserve(tokens.size()); | |||||
| // for (auto &data : tokens) | |||||
| // { | |||||
| // patternArray.push_back(_strdup(data.c_str())); | |||||
| // } | |||||
| // std::vector<char *> temp; | |||||
| // for (unsigned int i = 0; i < tokens.size(); i++) | |||||
| // { | |||||
| // // Using QString for the "startsWith function | |||||
| // auto value = std::string(patternArray[i]); | |||||
| // if (_strnicmp(value.c_str(), "?", sizeof("?"))) | |||||
| // { | |||||
| // temp.push_back(patternArray[i]); | |||||
| // } | |||||
| // else | |||||
| // break; | |||||
| // } | |||||
| // auto occurences = FindAllOccurences(temp, startAddress); | |||||
| // std::vector<unsigned char> parsedPattern; | |||||
| // parsedPattern.reserve(patternArray.size()); | |||||
| // for (auto &pat : patternArray) | |||||
| // { | |||||
| // parsedPattern.push_back((unsigned char)std::strtol(reinterpret_cast<const char *>(pat), nullptr, 16)); | |||||
| // } | |||||
| // std::vector<char> check(patternArray.size()); | |||||
| // for (auto &occ : occurences) | |||||
| // { | |||||
| // memset(check.data(), 0, patternArray.size()); | |||||
| // memcpy(check.data(), (LPVOID)(startAddress + occ), patternArray.size()); | |||||
| // for (unsigned int o = 0; o < patternArray.size(); o++) | |||||
| // { | |||||
| // // If the current Patterncharacter is a wildcard, go to next index | |||||
| // if (isalnum(*patternArray[o]) == 0) // == 0 || isalpha(*patternArray[0]) == 0) | |||||
| // continue; | |||||
| // // Convert current Patternindex | |||||
| // char pat = (char)std::stoul(std::string(patternArray[o]), nullptr, 16); | |||||
| // // Compare memory, if equal, result is 0 | |||||
| // int mem = memcmp(&check[o], &pat, 1); | |||||
| // // If memory is not equal, the pattern doesn't match | |||||
| // if (mem != 0) | |||||
| // { | |||||
| // break; | |||||
| // } | |||||
| // // o can only be the size of the pattern if it matches | |||||
| // if (o == patternArray.size() - 1) | |||||
| // { | |||||
| // if (offset < 0) | |||||
| // return occ - offset; | |||||
| // if (offset > 0) | |||||
| // return occ + offset; | |||||
| // return occ; | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // // No result found | |||||
| // return 0; | |||||
| // } | |||||
| // /** | |||||
| // * \brief Returns first occurrence of byte pattern in a module | |||||
| // * \param module Base address of module | |||||
| // * \param signature IDA-style byte pattern | |||||
| // * \return Pointer to first occurrence | |||||
| // * \see CSGOSimple by MarkHC | |||||
| // */ | |||||
| // inline std::uint8_t *patternScan(void *module, std::string signature) | |||||
| // { | |||||
| // static auto pattern_to_byte = [](const char *pattern) { | |||||
| // auto bytes = std::vector<int>{}; | |||||
| // auto start = const_cast<char *>(pattern); | |||||
| // auto end = const_cast<char *>(pattern) + strlen(pattern); | |||||
| // for (auto current = start; current < end; ++current) | |||||
| // { | |||||
| // if (*current == '??') | |||||
| // { | |||||
| // ++current; | |||||
| // if (*current == '??') | |||||
| // ++current; | |||||
| // bytes.push_back(-1); | |||||
| // } | |||||
| // else | |||||
| // bytes.push_back(strtoul(current, ¤t, 16)); | |||||
| // } | |||||
| // return bytes; | |||||
| // }; | |||||
| // auto dosHeader = (PIMAGE_DOS_HEADER)module; | |||||
| // auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t *)module + dosHeader->e_lfanew); | |||||
| // auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage; | |||||
| // auto patternBytes = pattern_to_byte(signature.c_str()); | |||||
| // auto scanBytes = reinterpret_cast<std::uint8_t *>(module); | |||||
| // auto s = patternBytes.size(); | |||||
| // auto d = patternBytes.data(); | |||||
| // for (auto i = 0ul; i < sizeOfImage - s; ++i) | |||||
| // { | |||||
| // bool found = true; | |||||
| // for (auto j = 0ul; j < s; ++j) | |||||
| // { | |||||
| // if (scanBytes[i + j] != d[j] && d[j] != -1) | |||||
| // { | |||||
| // found = false; | |||||
| // break; | |||||
| // } | |||||
| // } | |||||
| // if (found) | |||||
| // return &scanBytes[i]; | |||||
| // } | |||||
| // return nullptr; | |||||
| // } | |||||
| // static std::vector<unsigned char> ParseSignature(std::string &pattern) | |||||
| // { | |||||
| // std::vector<unsigned char> bytes; | |||||
| // for (unsigned int i = 0; i < pattern.length(); i += 2) | |||||
| // { | |||||
| // std::string byteString = pattern.substr(i, 2); | |||||
| // char byte = (char)strtol(byteString.c_str(), NULL, 16); | |||||
| // bytes.push_back(byte); | |||||
| // } | |||||
| // return bytes; | |||||
| // } | |||||
| // static DWORD FindMySignature(const char *szModule, std::string szSignature, int offset) | |||||
| // { | |||||
| // /*AllocConsole(); | |||||
| // freopen("CONIN$", "r", stdin); | |||||
| // freopen("CONOUT$", "w", stdout); | |||||
| // freopen("CONOUT$", "w", stderr);*/ | |||||
| // MODULEINFO modInfo; | |||||
| // GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(szModule), &modInfo, sizeof(MODULEINFO)); | |||||
| // DWORD startAddress = (DWORD)modInfo.lpBaseOfDll; | |||||
| // DWORD endAddress = startAddress + modInfo.SizeOfImage; | |||||
| // std::string pattern = szSignature; | |||||
| // std::string::iterator end_pos = std::remove(szSignature.begin(), szSignature.end(), ' '); | |||||
| // szSignature.erase(end_pos, szSignature.end()); | |||||
| // //const char* pat = szSignature.c_str(); | |||||
| // auto pat = ParseSignature(szSignature); | |||||
| // DWORD firstMatch = 0; | |||||
| // //std::vector<char> check(sizeof(szSignature)); | |||||
| // //auto firstMatchByte = std::strtol(&pat[0], nullptr, 16); | |||||
| // auto firstMatchByte = (int)pat[0]; | |||||
| // std::cout << std::hex << (int)*(unsigned char *)startAddress << '\n'; | |||||
| // std::cout << "Pattern to search for: " << szSignature << '\n'; | |||||
| // std::cout << "Length of Pattern: " << szSignature.length() << '\n'; | |||||
| // std::cout << "FirstMatchByte: " << std::hex << firstMatchByte << '\n'; | |||||
| // SYSTEM_INFO sysinf; | |||||
| // GetSystemInfo(&sysinf); | |||||
| // MEMORY_BASIC_INFORMATION mbi; | |||||
| // //startAddress += 0x4F318C; | |||||
| // /*for (int i = 0; i < pat.size(); i++) | |||||
| // std::cout << (int)pat[i];*/ | |||||
| // for (DWORD pCur = startAddress; pCur < 0x7FFFFFFF; pCur++) | |||||
| // { | |||||
| // if (VirtualQuery((LPVOID)pCur, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) != 0 | |||||
| // //&& ((mBI.State != MEM_COMMIT) || !(mBI.Protect & MEMORY_READABLE) || (mBI.Protect & PAGE_GUARD))) | |||||
| // && mbi.State == MEM_COMMIT && mbi.Protect != PAGE_NOACCESS && !(mbi.Protect & PAGE_GUARD)) | |||||
| // { | |||||
| // //CREDITS: learn_more | |||||
| // #define INRANGE(x, a, b) (x >= a && x <= b) | |||||
| // #define getBits(x) (INRANGE((x & (~0x20)), 'A', 'F') ? ((x & (~0x20)) - 'A' + 0xa) : (INRANGE(x, '0', '9') ? x - '0' : 0)) | |||||
| // #define getByte(x) (getBits(x[0]) << 4 | getBits(x[1])) | |||||
| // const char *patt = pattern.c_str(); | |||||
| // if (!*patt) | |||||
| // return firstMatch; | |||||
| // if (*(PBYTE)patt == '\?' || *(BYTE *)pCur == getByte(patt)) | |||||
| // { | |||||
| // if (!firstMatch) | |||||
| // firstMatch = pCur; | |||||
| // if (!patt[2]) | |||||
| // return firstMatch; | |||||
| // if (*(PWORD)patt == '\?\?' || *(PBYTE)patt != '\?') | |||||
| // patt += 3; | |||||
| // else | |||||
| // patt += 2; //one ? | |||||
| // } | |||||
| // else | |||||
| // { | |||||
| // patt = szSignature.c_str(); | |||||
| // firstMatch = 0; | |||||
| // } | |||||
| // if ((int)*(unsigned char *)pCur == (int)firstMatchByte && endAddress - pCur >= szSignature.length()) | |||||
| // { | |||||
| // //if (pattern.data()[0] == *(streamToSearch.begin() +i) && totalLength - i >= patternLength) | |||||
| // for (unsigned int o = 0; o < pat.size(); o++) | |||||
| // { | |||||
| // // If the current Patterncharacter is a wildcard, go to next index | |||||
| // //if (isalnum(szSignature[o]) == 0)// == 0 || isalpha(*patternArray[0]) == 0) | |||||
| // if (pat[o] == strtol("??", 0, 16)) | |||||
| // { | |||||
| // //std::cout << "Current Patternindex is a wildcard: " << pat[o] << '\n'; | |||||
| // continue; | |||||
| // } | |||||
| // auto currentPat = (int)pat[o]; | |||||
| // /*std::cout << '\n\n'; | |||||
| // std::cout << "Startaddress: 0x" << std::hex << (DWORD)modInfo.lpBaseOfDll << '\n'; | |||||
| // std::cout << "Currentaddress: 0x" << std::hex << pCur + o << '\n'; | |||||
| // std::cout << "Current Byte is: " << std::hex << (int)*(unsigned char*)(pCur + o) << '\n'; | |||||
| // std::cout << "Current Pattern is: " << std::hex << currentPat << '\n'; | |||||
| // std::cout << '\n';*/ | |||||
| // if ((int)*(unsigned char *)(pCur + o) != currentPat) | |||||
| // { | |||||
| // //std::cout << "Cur Val: 0x" << std::hex << (int)*(unsigned char*)(pCur + o) << " Pattern: 0x" << std::hex << currentPat << '\n'; | |||||
| // break; | |||||
| // } | |||||
| // // o can only be the size of the pattern if it matches | |||||
| // if (o == pat.size() - 1) | |||||
| // { | |||||
| // if (offset < 0) | |||||
| // return pCur - offset; | |||||
| // if (offset > 0) | |||||
| // return pCur + offset; | |||||
| // return pCur; | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // else | |||||
| // pCur += mbi.RegionSize; | |||||
| // } | |||||
| // return NULL; | |||||
| // } | |||||
| static uintptr_t FindSignature(const char *szModule, const char *szSignature) | |||||
| { | |||||
| //CREDITS: learn_more | |||||
| #define INRANGE(x, a, b) (x >= a && x <= b) | |||||
| #define getBits(x) (INRANGE((x & (~0x20)), 'A', 'F') ? ((x & (~0x20)) - 'A' + 0xa) : (INRANGE(x, '0', '9') ? x - '0' : 0)) | |||||
| #define getByte(x) (getBits(x[0]) << 4 | getBits(x[1])) | |||||
| MODULEINFO modInfo; | |||||
| GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(szModule), &modInfo, sizeof(MODULEINFO)); | |||||
| uintptr_t startAddress = (uintptr_t)modInfo.lpBaseOfDll; | |||||
| uintptr_t endAddress = startAddress + modInfo.SizeOfImage; | |||||
| const char *pat = szSignature; | |||||
| uintptr_t firstMatch = 0; | |||||
| for (uintptr_t pCur = startAddress; pCur < endAddress; pCur++) | |||||
| { | |||||
| if (!*pat) | |||||
| return firstMatch; | |||||
| if (*(PBYTE)pat == '\?' || *(BYTE *)pCur == getByte(pat)) | |||||
| { | |||||
| if (!firstMatch) | |||||
| firstMatch = pCur; | |||||
| if (!pat[2]) | |||||
| return firstMatch; | |||||
| if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') | |||||
| //if (*(PWORD)pat == '\?' || *(PBYTE)pat != '\?') | |||||
| pat += 3; | |||||
| else | |||||
| pat += 2; //one ? | |||||
| } | |||||
| else | |||||
| { | |||||
| pat = szSignature; | |||||
| firstMatch = 0; | |||||
| } | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| } // namespace PatternScan | |||||
| @@ -0,0 +1,11 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project> | |||||
| <ProjectOutputs> | |||||
| <ProjectOutput> | |||||
| <FullPath>F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Debug\BL3ProxySettings.dll</FullPath> | |||||
| </ProjectOutput> | |||||
| </ProjectOutputs> | |||||
| <ContentFiles /> | |||||
| <SatelliteDlls /> | |||||
| <NonRecipeFileRefs /> | |||||
| </Project> | |||||
| @@ -0,0 +1,42 @@ | |||||
| cl : command line warning D9025: overriding '/sdl' with '/GS-' | |||||
| BL3ProxySettings.cpp | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(98,29): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'WCHAR *' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(98,29): message : consider using '%ls' in the format string | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(98,29): message : consider using '%lls' in the format string | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(98,29): message : consider using '%Ls' in the format string | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(98,29): message : consider using '%ws' in the format string | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(108,16): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(217,31): warning C4244: 'argument': conversion from 'socket_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(222,1): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(249,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(597,49): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(601,53): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(606,53): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(609,49): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(611,49): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(615,53): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(618,49): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(622,53): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(625,49): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(627,49): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(563,18): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(566,18): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(570,18): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(574,18): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\include\easywsclient.cpp(641,17): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(188,2): warning C4091: 'typedef ': ignored on left of '<unnamed-enum-CURLOPT_URL>' when no variable is declared | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(194,2): warning C4091: 'typedef ': ignored on left of '<unnamed-enum-CURLE_OK>' when no variable is declared | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(570,35): warning C4099: 'TArray<FNewsItem>': type name first seen using 'struct' now seen using 'class' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(570): message : see declaration of 'TArray<FNewsItem>' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(633,26): warning C4099: 'FString': type name first seen using 'struct' now seen using 'class' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(472): message : see declaration of 'FString' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(637,23): warning C4099: 'TArray<FString>': type name first seen using 'struct' now seen using 'class' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(637): message : see declaration of 'TArray<FString>' | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\BL3ProxySettings.cpp(723,5): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. | |||||
| libMinHook-MD.x64.lib(hook.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance | |||||
| LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification | |||||
| Creating library F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Debug\BL3ProxySettings.lib and object F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Debug\BL3ProxySettings.exp | |||||
| LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library | |||||
| Generating code | |||||
| Finished generating code | |||||
| BL3ProxySettings.vcxproj -> F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Debug\BL3ProxySettings.dll | |||||
| @@ -0,0 +1,2 @@ | |||||
| PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29910:TargetPlatformVersion=10.0.19041.0: | |||||
| Debug|x64|F:\Programmieren\C++\BL3\BL3ProxySettings\| | |||||
| @@ -0,0 +1 @@ | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Debug\BL3ProxySettings.dll | |||||
| @@ -0,0 +1 @@ | |||||
| | |||||
| @@ -0,0 +1,11 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project> | |||||
| <ProjectOutputs> | |||||
| <ProjectOutput> | |||||
| <FullPath>F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Release\BL3ProxySettings.dll</FullPath> | |||||
| </ProjectOutput> | |||||
| </ProjectOutputs> | |||||
| <ContentFiles /> | |||||
| <SatelliteDlls /> | |||||
| <NonRecipeFileRefs /> | |||||
| </Project> | |||||
| @@ -0,0 +1,41 @@ | |||||
| In file included from BL3ProxySettings.cpp:24: | |||||
| ./include/patternscan.hpp(641,24): warning : multi-character character constant [-Wmultichar] | |||||
| In file included from BL3ProxySettings.cpp:36: | |||||
| ./include/easywsclient.cpp(98,50): warning : format specifies type 'char *' but the argument has type 'WCHAR *' (aka 'wchar_t *') [-Wformat] | |||||
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\WS2tcpip.h(670,24): message : expanded from macro 'gai_strerror' | |||||
| In file included from BL3ProxySettings.cpp:36: | |||||
| ./include/easywsclient.cpp(563,18): warning : 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] | |||||
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h(2239,20): message : 'sscanf' has been explicitly marked deprecated here | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(320,55): message : expanded from macro '_CRT_INSECURE_DEPRECATE' | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(310,47): message : expanded from macro '_CRT_DEPRECATE_TEXT' | |||||
| In file included from BL3ProxySettings.cpp:36: | |||||
| ./include/easywsclient.cpp(566,18): warning : 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] | |||||
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h(2239,20): message : 'sscanf' has been explicitly marked deprecated here | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(320,55): message : expanded from macro '_CRT_INSECURE_DEPRECATE' | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(310,47): message : expanded from macro '_CRT_DEPRECATE_TEXT' | |||||
| In file included from BL3ProxySettings.cpp:36: | |||||
| ./include/easywsclient.cpp(570,18): warning : 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] | |||||
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h(2239,20): message : 'sscanf' has been explicitly marked deprecated here | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(320,55): message : expanded from macro '_CRT_INSECURE_DEPRECATE' | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(310,47): message : expanded from macro '_CRT_DEPRECATE_TEXT' | |||||
| In file included from BL3ProxySettings.cpp:36: | |||||
| ./include/easywsclient.cpp(574,18): warning : 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] | |||||
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h(2239,20): message : 'sscanf' has been explicitly marked deprecated here | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(320,55): message : expanded from macro '_CRT_INSECURE_DEPRECATE' | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(310,47): message : expanded from macro '_CRT_DEPRECATE_TEXT' | |||||
| In file included from BL3ProxySettings.cpp:36: | |||||
| ./include/easywsclient.cpp(641,17): warning : 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] | |||||
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h(2239,20): message : 'sscanf' has been explicitly marked deprecated here | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(320,55): message : expanded from macro '_CRT_INSECURE_DEPRECATE' | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\MSVC\14.28.29910\include\vcruntime.h(310,47): message : expanded from macro '_CRT_DEPRECATE_TEXT' | |||||
| BL3ProxySettings.cpp(124,1): warning : typedef requires a name [-Wmissing-declarations] | |||||
| BL3ProxySettings.cpp(188,1): warning : typedef requires a name [-Wmissing-declarations] | |||||
| BL3ProxySettings.cpp(464,2): warning : class 'TArray' was previously declared as a struct; this is valid, but may result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags] | |||||
| BL3ProxySettings.cpp(227,8): message : previous use is here | |||||
| BL3ProxySettings.cpp(895,12): warning : unused variable 'replaceMode' [-Wunused-variable] | |||||
| BL3ProxySettings.cpp(1153,49): warning : implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast] | |||||
| BL3ProxySettings.cpp(1156,54): warning : implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast] | |||||
| BL3ProxySettings.cpp(1159,55): warning : implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast] | |||||
| BL3ProxySettings.cpp(1162,52): warning : implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast] | |||||
| BL3ProxySettings.cpp(1165,53): warning : implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast] | |||||
| BL3ProxySettings.vcxproj -> F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Release\BL3ProxySettings.dll | |||||
| @@ -0,0 +1,2 @@ | |||||
| PlatformToolSet=ClangCL:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29910:TargetPlatformVersion=10.0.19041.0: | |||||
| I:\Microsoft VisualStudio 2019\VC\Tools\Llvm\x64|11.0.0|Release|x64|F:\Programmieren\C++\BL3\BL3ProxySettings\| | |||||
| @@ -0,0 +1 @@ | |||||
| F:\Programmieren\C++\BL3\BL3ProxySettings\x64\Release\BL3ProxySettings.dll | |||||
| @@ -0,0 +1 @@ | |||||
| | |||||