commit ffecc4ddaf4683a6921bd0e7c700381c20924b87 Author: atom0s Date: Tue Jan 3 17:03:18 2017 -0800 Initial code commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2792f41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,221 @@ +# ---> VisualStudio +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +/Ashita.exp +/Ashita.lib diff --git a/No-ckback.sln b/No-ckback.sln new file mode 100644 index 0000000..dc87011 --- /dev/null +++ b/No-ckback.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "No-ckback", "No-ckback\No-ckback.vcxproj", "{9430017C-9E01-4954-B378-81CB23EB8C31}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9430017C-9E01-4954-B378-81CB23EB8C31}.Debug|x64.ActiveCfg = Debug|x64 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Debug|x64.Build.0 = Debug|x64 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Debug|x86.ActiveCfg = Debug|Win32 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Debug|x86.Build.0 = Debug|Win32 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Release|x64.ActiveCfg = Release|x64 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Release|x64.Build.0 = Release|x64 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Release|x86.ActiveCfg = Release|Win32 + {9430017C-9E01-4954-B378-81CB23EB8C31}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/No-ckback/DSP-Utils.h b/No-ckback/DSP-Utils.h new file mode 100644 index 0000000..d11caed --- /dev/null +++ b/No-ckback/DSP-Utils.h @@ -0,0 +1,219 @@ +#define RBUFP(p,pos) (((uint8_t*)(p)) + (pos)) +#define RBUFB(p,pos) (*(uint8_t*)RBUFP((p),(pos))) +#define RBUFW(p,pos) (*(uint16_t*)RBUFP((p),(pos))) +#define RBUFL(p,pos) (*(uint32_t*)RBUFP((p),(pos))) +#define RBUFF(p,pos) (*(float*)RBUFP((p),(pos))) + +#define WBUFP(p,pos) (((uint8_t*)(p)) + (pos)) +#define WBUFB(p,pos) (*(uint8_t*)WBUFP((p),(pos))) +#define WBUFW(p,pos) (*(uint16_t*)WBUFP((p),(pos))) +#define WBUFL(p,pos) (*(uint32_t*)WBUFP((p),(pos))) +#define WBUFF(p,pos) (*(float*)WBUFP((p),(pos))) + +#include + +uint32_t packBitsBE(uint8_t* target, uint64_t value, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) +{ + byteOffset += (bitOffset >> 3); //correct bitOffsets>=8 + bitOffset %= 8; + + uint64_t bitmask = 0xFFFFFFFFFFFFFFFFLL; //Generate bitmask + + bitmask >>= (64 - lengthInBit); + bitmask <<= bitOffset; + + value <<= bitOffset; //shift value + value &= bitmask; + + bitmask ^= 0xFFFFFFFFFFFFFFFFLL; //invert bitmask + + if ((lengthInBit + bitOffset) <= 8) //write shifted value to target + { + uint8_t* dataPointer = (uint8_t*)&target[byteOffset]; + + uint8_t bitmaskUC = (uint8_t)bitmask; + uint8_t valueUC = (uint8_t)value; + + *dataPointer &= bitmaskUC; + *dataPointer |= valueUC; + } + else if ((lengthInBit + bitOffset) <= 16) + { + uint16_t* dataPointer = (uint16_t*)&target[byteOffset]; + + uint16_t bitmaskUC = (uint16_t)bitmask; + uint16_t valueUC = (uint16_t)value; + + *dataPointer &= bitmaskUC; + *dataPointer |= valueUC; + } + else if ((lengthInBit + bitOffset) <= 32) + { + uint32_t* dataPointer = (uint32_t*)&target[byteOffset]; + + uint32_t bitmaskUC = (uint32_t)bitmask; + uint32_t valueUC = (uint32_t)value; + + *dataPointer &= bitmaskUC; + *dataPointer |= valueUC; + } + else if ((lengthInBit + bitOffset) <= 64) + { + uint64_t* dataPointer = (uint64_t*)&target[byteOffset]; + + *dataPointer &= bitmask; + *dataPointer |= value; + } + else + { + //ShowError("Pack Bits Error: packBitsBE(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset)); + } + return ((byteOffset << 3) + bitOffset + lengthInBit); +} + +uint32_t packBitsBE(uint8_t* target, uint64_t value, int32_t bitOffset, uint8_t lengthInBit) +{ + return packBitsBE(target, value, 0, bitOffset, lengthInBit); +} + +uint64_t unpackBitsBE(uint8_t* target, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) +{ + byteOffset += (bitOffset >> 3); + bitOffset %= 8; + + uint64_t bitmask = 0xFFFFFFFFFFFFFFFFLL; + + bitmask >>= (64 - lengthInBit); + bitmask <<= bitOffset; + + uint64_t retVal; + + if ((lengthInBit + bitOffset) <= 8) + { + uint8_t* dataPointer = (uint8_t*)&target[byteOffset]; + + retVal = ((*dataPointer)&(uint8_t)bitmask) >> bitOffset; + } + else if ((lengthInBit + bitOffset) <= 16) + { + uint16_t* dataPointer = (uint16_t*)&target[byteOffset]; + + retVal = ((*dataPointer)&(uint16_t)bitmask) >> bitOffset; + } + else if ((lengthInBit + bitOffset) <= 32) + { + uint32_t* dataPointer = (uint32_t*)&target[byteOffset]; + + retVal = ((*dataPointer)&(uint32_t)bitmask) >> bitOffset; + } + else if ((lengthInBit + bitOffset) <= 64) + { + uint64_t* dataPointer = (uint64_t*)&target[byteOffset]; + + retVal = ((*dataPointer)&(uint64_t)bitmask) >> bitOffset; + } + else + { + //ShowError("Unpack Bits Error: unpackBits(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset)); + return 0; + } + return retVal; +} + +uint64_t unpackBitsBE(uint8_t* target, int32_t bitOffset, uint8_t lengthInBit) +{ + return unpackBitsBE(target, 0, bitOffset, lengthInBit); +} + +uint32_t packBitsLE(uint8_t* target, uint64_t value, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) +{ + byteOffset += (bitOffset >> 3); //correct bitOffsets >= 8 + bitOffset %= 8; + + uint8_t bytesNeeded; //calculate how many bytes are needed + if ((bitOffset + lengthInBit) <= 8) + bytesNeeded = 1; + else if ((bitOffset + lengthInBit) <= 16) + bytesNeeded = 2; + else if ((bitOffset + lengthInBit) <= 32) + bytesNeeded = 4; + else if ((bitOffset + lengthInBit) <= 64) + bytesNeeded = 8; + else + { + //ShowError("Pack Bits Error: packBitsLE(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset)); + return 0; + } + + uint8_t* modifiedTarget = new uint8_t[bytesNeeded]; //convert byteOrder to Big Endian + + for (uint8_t curByte = 0; curByte < bytesNeeded; ++curByte) + { + modifiedTarget[curByte] = target[byteOffset + (bytesNeeded - 1) - curByte]; + } + + int32_t newBitOffset = (bytesNeeded << 3) - (bitOffset + lengthInBit); //calculate new bitOffset + + packBitsBE(&modifiedTarget[0], value, 0, newBitOffset, lengthInBit); //write data to modified array + + for (uint8_t curByte = 0; curByte < bytesNeeded; ++curByte) //copy back to target + { + target[byteOffset + (bytesNeeded - 1) - curByte] = modifiedTarget[curByte]; + } + + if (modifiedTarget) delete[] modifiedTarget; + return ((byteOffset << 3) + bitOffset + lengthInBit); +} + +uint32_t packBitsLE(uint8_t* target, uint64_t value, int32_t bitOffset, uint8_t lengthInBit) +{ + return packBitsLE(target, value, 0, bitOffset, lengthInBit); +} + +uint64_t unpackBitsLE(uint8_t* target, int32_t byteOffset, int32_t bitOffset, uint8_t lengthInBit) +{ + byteOffset += (bitOffset >> 3); + bitOffset %= 8; + + uint8_t bytesNeeded; + if ((bitOffset + lengthInBit) <= 8) + bytesNeeded = 1; + else if ((bitOffset + lengthInBit) <= 16) + bytesNeeded = 2; + else if ((bitOffset + lengthInBit) <= 32) + bytesNeeded = 4; + else if ((bitOffset + lengthInBit) <= 64) + bytesNeeded = 8; + else + { + //ShowError("Unpack Bits Error: packBitsLE(...) not implemented for targetsizes above 64 bits.\n Targetsize: %d\n", (lengthInBit + bitOffset)); + return 0; + } + + uint64_t retVal; + + uint8_t* modifiedTarget = new uint8_t[bytesNeeded]; + + for (uint8_t curByte = 0; curByte < bytesNeeded; ++curByte) + { + modifiedTarget[curByte] = target[byteOffset + (bytesNeeded - 1) - curByte]; + } + if (bytesNeeded == 1) + { + uint8_t bitmask = 0xFF >> bitOffset; + retVal = (modifiedTarget[0] & bitmask) >> (8 - (lengthInBit + bitOffset)); + } + else + { + int32_t newBitOffset = (bytesNeeded * 8) - (bitOffset + lengthInBit); + retVal = unpackBitsBE(&modifiedTarget[0], 0, newBitOffset, lengthInBit); + } + + if (modifiedTarget) delete[]modifiedTarget; + return retVal; +} + +uint64_t unpackBitsLE(uint8_t* target, int32_t bitOffset, uint8_t lengthInBit) +{ + return unpackBitsLE(target, 0, bitOffset, lengthInBit); +} diff --git a/No-ckback/Exports.def b/No-ckback/Exports.def new file mode 100644 index 0000000..df06e0e --- /dev/null +++ b/No-ckback/Exports.def @@ -0,0 +1,5 @@ +LIBRARY "No-ckback" +EXPORTS + GetInterfaceVersion + CreatePluginInfo + CreatePlugin \ No newline at end of file diff --git a/No-ckback/Main.cpp b/No-ckback/Main.cpp new file mode 100644 index 0000000..8d832ef --- /dev/null +++ b/No-ckback/Main.cpp @@ -0,0 +1,74 @@ +#include "No-ckback.h" +#include "DSP-Utils.h" + +#include +#include + +plugininfo_t* g_PluginInfo; + +bool Nockback::Initialize(IAshitaCore* core, ILogManager* log, uint32_t id) +{ + this->m_AshitaCore = core; + this->m_PluginId = id; + this->m_LogManager = log; + + return true; +} + +void Nockback::Release() +{ +} + +plugininfo_t Nockback::GetPluginInfo() +{ + return *g_PluginInfo; +} + +bool Nockback::HandleIncomingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) +{ + if (id == 0x28) + { + uint8_t actionType = (uint8_t)(unpackBitsBE((unsigned char*)data, 82, 4)); + + if (actionType == 11) + { + uint8_t targetNum = RBUFB(data, 0x09); + uint16_t startBit = 150; + for (int i = 0; i < targetNum; i++) + { + packBitsBE((unsigned char*)data, 0, startBit + 60, 3); + if (unpackBitsBE((unsigned char*)data, startBit + 121, 1) & 0x1) + { + startBit += 37; + } + if (unpackBitsBE((unsigned char*)data, startBit + 122, 1) & 0x1) + { + startBit += 34; + } + startBit += 123; + } + } + } + return false; +} + +__declspec(dllexport) double __stdcall GetInterfaceVersion(void) +{ + return ASHITA_INTERFACE_VERSION; +} + +__declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* Data) +{ + g_PluginInfo = Data; + g_PluginInfo->PluginVersion = 1.05; + g_PluginInfo->InterfaceVersion = ASHITA_INTERFACE_VERSION; + g_PluginInfo->Priority = 0; + + strncpy_s(g_PluginInfo->Name, "No-ckback", 256); + strncpy_s(g_PluginInfo->Author, "kjLotus", 256); +} + +__declspec(dllexport) IPlugin* __stdcall CreatePlugin(void) +{ + return (IPlugin*)new Nockback(); +} diff --git a/No-ckback/No-ckback.h b/No-ckback/No-ckback.h new file mode 100644 index 0000000..aa733d3 --- /dev/null +++ b/No-ckback/No-ckback.h @@ -0,0 +1,27 @@ +#include "C:\Ashita 3\plugins\ADK\Ashita.h" +#include + +class Nockback : public IPlugin +{ +private: + IAshitaCore* m_AshitaCore; + ILogManager* m_LogManager; + DWORD m_PluginId; + IDirect3DDevice8* m_Direct3DDevice; + +public: + Nockback() {} + virtual ~Nockback() {} + bool Initialize(IAshitaCore* core, ILogManager* log, uint32_t id); + + void Release(); + + plugininfo_t GetPluginInfo(); + + bool HandleIncomingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked); +}; + +//Exports +__declspec(dllexport) double __stdcall GetInterfaceVersion(void); +__declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpPluginData); +__declspec(dllexport) IPlugin* __stdcall CreatePlugin(void); diff --git a/No-ckback/No-ckback.vcxproj b/No-ckback/No-ckback.vcxproj new file mode 100644 index 0000000..cee32da --- /dev/null +++ b/No-ckback/No-ckback.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {9430017C-9E01-4954-B378-81CB23EB8C31} + Win32Proj + Nockback + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140_xp + true + MultiByte + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + ..\..\..\..\..\..\..\..\Ashita 3\plugins + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;NOCKBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + Exports.def + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;NOCKBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + Exports.def + + + + + Level3 + + + Full + false + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;NOCKBACK_EXPORTS;%(PreprocessorDefinitions) + true + true + true + Async + + + Windows + true + true + true + Exports.def + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;NOCKBACK_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + Exports.def + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/No-ckback/No-ckback.vcxproj.filters b/No-ckback/No-ckback.vcxproj.filters new file mode 100644 index 0000000..dcf2d42 --- /dev/null +++ b/No-ckback/No-ckback.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c7f39a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# No-ckback \ No newline at end of file