From f4d9353b6d0abc86b96ab727574bf69ab42520f2 Mon Sep 17 00:00:00 2001 From: atom0s Date: Wed, 30 Nov 2016 22:56:49 -0800 Subject: [PATCH] Initial code commit. --- .gitignore | 224 +++++++++ ExamplePlugin.sln | 28 ++ ExamplePlugin/ExamplePlugin.cpp | 509 ++++++++++++++++++++ ExamplePlugin/ExamplePlugin.h | 104 ++++ ExamplePlugin/ExamplePlugin.vcxproj | 169 +++++++ ExamplePlugin/ExamplePlugin.vcxproj.filters | 32 ++ ExamplePlugin/exports.def | 5 + 7 files changed, 1071 insertions(+) create mode 100644 .gitignore create mode 100644 ExamplePlugin.sln create mode 100644 ExamplePlugin/ExamplePlugin.cpp create mode 100644 ExamplePlugin/ExamplePlugin.h create mode 100644 ExamplePlugin/ExamplePlugin.vcxproj create mode 100644 ExamplePlugin/ExamplePlugin.vcxproj.filters create mode 100644 ExamplePlugin/exports.def diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e97667 --- /dev/null +++ b/.gitignore @@ -0,0 +1,224 @@ +# ---> 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 + +*.VC.db +*.VC.opendb \ No newline at end of file diff --git a/ExamplePlugin.sln b/ExamplePlugin.sln new file mode 100644 index 0000000..4aef371 --- /dev/null +++ b/ExamplePlugin.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}") = "ExamplePlugin", "ExamplePlugin\ExamplePlugin.vcxproj", "{A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}" +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 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Debug|x64.ActiveCfg = Debug|x64 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Debug|x64.Build.0 = Debug|x64 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Debug|x86.ActiveCfg = Debug|Win32 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Debug|x86.Build.0 = Debug|Win32 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Release|x64.ActiveCfg = Release|x64 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Release|x64.Build.0 = Release|x64 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Release|x86.ActiveCfg = Release|Win32 + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ExamplePlugin/ExamplePlugin.cpp b/ExamplePlugin/ExamplePlugin.cpp new file mode 100644 index 0000000..b046eaf --- /dev/null +++ b/ExamplePlugin/ExamplePlugin.cpp @@ -0,0 +1,509 @@ +/** + * Ashita - Copyright (c) 2014 - 2016 atom0s [atom0s@live.com] + * + * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to + * Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * + * By using Ashita, you agree to the above license and its terms. + * + * Attribution - You must give appropriate credit, provide a link to the license and indicate if changes were + * made. You must do so in any reasonable manner, but not in any way that suggests the licensor + * endorses you or your use. + * + * Non-Commercial - You may not use the material (Ashita) for commercial purposes. + * + * No-Derivatives - If you remix, transform, or build upon the material (Ashita), you may not distribute the + * modified material. You are, however, allowed to submit the modified works back to the original + * Ashita project in attempt to have it added to the original project. + * + * You may not apply legal terms or technological measures that legally restrict others + * from doing anything the license permits. + * + * No warranties are given. + */ + +#include "ExamplePlugin.h" + +/** + * Constructor and Deconstructor + */ +ExamplePlugin::ExamplePlugin(void) + : m_AshitaCore(nullptr) + , m_LogManager(nullptr) + , m_PluginId(0) + , m_Direct3DDevice(nullptr) +{ } +ExamplePlugin::~ExamplePlugin(void) +{ } + + +/** + * Returns the plugins information structure. + * + * @returns {plugininfo_t} The plugin information structure of the plugin. + */ +plugininfo_t ExamplePlugin::GetPluginInfo(void) +{ + return *g_PluginInfo; +} + +/** + * Invoked when the plugin is loaded, allowing it to prepare for usage. + * + * @param {IAshitaCore*} core - The Ashita core object to interact with the various Ashita managers. + * @param {ILogManager*} log - The log manager used to interact with the current log file. + * @param {uint32_t} id - The plugins id, or its module base, that identifies it other than its name. + * @returns {bool} True on success, false otherwise. (If false, the plugin will not be loaded.) + * + * @notes + * + * Plugins must return true here or they will be considered invalid and unload immediately. + * Returning false means that the plugin failed to initialize and should not be used. + */ +bool ExamplePlugin::Initialize(IAshitaCore* core, ILogManager* log, uint32_t id) +{ + // Store the variables for later usage.. + this->m_AshitaCore = core; + this->m_LogManager = log; + this->m_PluginId = id; + + return true; +} + +/** + * Invoked when the plugin is being unloaded, allowing it to cleanup its resources. + * + * @notes + * + * Plugins should use this function to cleanup non-Direct3D related objects. + * - Delete created font objects. + * - Delete created Gui objects. + * - Internal memory allocations. + */ +void ExamplePlugin::Release(void) +{ } + +/** + * Invoked when a command is being processed by the game client. + * + * Note: + * Please note, this handles all things done via the game in terms of commands + * and chat. All / commands as well as normal chat you type, macros, etc. will + * be processed through here. You should only use this to handle / commands. + * + * If you wish to handle other bits of outgoing text before the client sees it, + * then use the HandleOutgoingText callback instead. + * + * @param {const char*} command - The raw command string being processed. + * @param {uint32_t} type - The type of the command being processed. (See Ashita::CommandInputType enumeration.) + * @returns {bool} True if handled and should be blocked, false otherwise. + * + * @notes + * + * Plugins can handle and block input from being sent to the game in this function. Returning + * true will block the current command from happening at all within the client. Plugins should + * only return true when the command passed to this function is being handled by the plugin. + */ +bool ExamplePlugin::HandleCommand(const char* command, int32_t type) +{ + UNREFERENCED_PARAMETER(type); + + // Split the command into args.. + std::vector args; + auto count = Ashita::Commands::GetCommandArgs(command, &args); + + // Handle the example slash command.. + HANDLECOMMAND("/example") + { + this->m_AshitaCore->GetChatManager()->Write("Example command was entered!"); + + // Check for a parameter.. + if (count >= 2 && args[1] == "test") + this->m_AshitaCore->GetChatManager()->Write("Example command was entered with parameter test!"); + + // Return true here to block this command from going to the client. + return true; + } + + // Return false here to allow unhandled commands to continue to be processed. + return false; +} + +/** + * Invoked when incoming text being sent to the chat log is being processed. + * + * @param {int16_t} mode - The mode of the message being added to the chatlog. + * @param {const char*} message - The raw message being added to the chat log. + * @param {int16_t*} modifiedMode - The modified mode, if any, that has been altered by other plugins/addons. + * @param {char*} modifiedMessage - The modified message, if any, that has been altered by other plugins/addons. + * @param {bool} blocked - Flag if this message has been blocked already by another plugin. (Once blocked, other plugins cannot restore it.) + * @returns {bool} True if handled and should be blocked, false otherwise. + * + * @notes + * + * Plugins can block the incoming text line by returning true in this function. + * Plugins can override the incoming text mode by setting the value of modifiedMode. + * Plugins can override the incoming text by writing a new message to the modifiedMessage buffer. + * Plugins can check if other plugins have blocked the current message by checking of the blocked param is true. + */ +bool ExamplePlugin::HandleIncomingText(int16_t mode, const char* message, int16_t* modifiedMode, char* modifiedMessage, bool blocked) +{ + UNREFERENCED_PARAMETER(mode); + UNREFERENCED_PARAMETER(message); + UNREFERENCED_PARAMETER(modifiedMode); + UNREFERENCED_PARAMETER(modifiedMessage); + UNREFERENCED_PARAMETER(blocked); + + return false; +} + +/** + * Invoked when outgoing text has not been handled by other plugins/addons. + * Invoked after HandleCommand if nothing else processed the data. + * + * @param {int16_t} mode - The type of the text that is being sent. (See Ashita::CommandInputType enumeration.) + * @param {const char*} message - The raw message being sent. + * @param {int16_t*} modifiedMode - The modified mode, if any, that has been altered by other plugins/addons. + * @param {char*} modifiedMessage - The modified message, if any, that has been altered by other plugins/addons. + * @param {bool} blocked - Flag if this message has been blocked already by another plugin. (Once blocked, other plugins cannot restore it.) + * @returns {bool} True if handled and should be blocked, false otherwise. + * + * @notes + * + * Plugins can block the outgoing text line by returning true in this function. + * Plugins can override the outgoing text mode by setting the value of modifiedMode. + * Plugins can override the outgoing text by writing a new message to the modifiedMessage buffer. + * Plugins can check if other plugins have blocked the current message by checking of the blocked param is true. + * + * Plugins can use this event as a last-ditch effort to handle outgoing text being sent from the client. + * This event can be used for overriding things like custom token parsing for things such as: + * %player_name% to be parsed out and replaced with the actual player name. + */ +bool ExamplePlugin::HandleOutgoingText(int32_t type, const char* message, int32_t* modifiedType, char* modifiedMessage, bool blocked) +{ + UNREFERENCED_PARAMETER(type); + UNREFERENCED_PARAMETER(message); + UNREFERENCED_PARAMETER(modifiedType); + UNREFERENCED_PARAMETER(modifiedMessage); + UNREFERENCED_PARAMETER(blocked); + + return false; +} + +/** + * Invoked when an incoming packet is being handled. + * + * @param {uint16_t} id - The id of the packet. + * @param {uint32_t} size - The size of the packet data. + * @param {void*} data - The raw data of the packet. + * @param {void*} modified - The modified data, if any, that has been altered by other plugins/addons. + * @param {bool} blocked - Flag if this message has been blocked already by another plugin. (Once blocked, other plugins cannot restore it.) + * @returns {bool} True if handled and should be blocked, false otherwise. + * + * @notes + * + * Plugins can block the packet by returning true in this function. + * Plugins can alter the data of the packet by editing the modified data parameter. + * Plugins can check if other plugins have blocked the current packet by checking if the blocked param is true. + * + * Please note; altering packets incorrectly or altering the flow of packets incorrectly can have adverse affects + * and possibly lead to players being banned. Edit with caution! + */ +bool ExamplePlugin::HandleIncomingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) +{ + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(size); + UNREFERENCED_PARAMETER(data); + UNREFERENCED_PARAMETER(modified); + UNREFERENCED_PARAMETER(blocked); + + return false; +} + +/** + * Invoked when an outgoing packet is being handled. + * + * @param {uint16_t} id - The id of the packet. + * @param {uint32_t} size - The size of the packet data. + * @param {void*} data - The raw data of the packet. + * @param {void*} modified - The modified data, if any, that has been altered by other plugins/addons. + * @param {bool} blocked - Flag if this message has been blocked already by another plugin. (Once blocked, other plugins cannot restore it.) + * @returns {bool} True if handled and should be blocked, false otherwise. + * + * @notes + * + * Plugins can block the packet by returning true in this function. + * Plugins can alter the data of the packet by editing the modified data parameter. + * Plugins can check if other plugins have blocked the current packet by checking if the blocked param is true. + * + * Please note; altering packets incorrectly or altering the flow of packets incorrectly can have adverse affects + * and possibly lead to players being banned. Edit with caution! + */ +bool ExamplePlugin::HandleOutgoingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) +{ + UNREFERENCED_PARAMETER(id); + UNREFERENCED_PARAMETER(size); + UNREFERENCED_PARAMETER(data); + UNREFERENCED_PARAMETER(modified); + UNREFERENCED_PARAMETER(blocked); + + return false; +} + +/** + * Invoked when the plugin is being initialized for Direct3D rendering. + * + * Note: + * Plugins must return true with this function in order to have the other Direct3D + * functions invoked. Returning false is ideal here if you do not need to use the + * Direct3D functions within your plugin. This can help with overall performance. + * + * @param {IDirect3DDevice8*} device - The Direct3D device pointer currently being used by the game. + * @return {bool} True if the plugin should handle the other Direct3D messages, false otherwise. + */ +bool ExamplePlugin::Direct3DInitialize(IDirect3DDevice8* device) +{ + // Store the device for later usage.. + this->m_Direct3DDevice = device; + + /** + * Returning true here for the sake of the example plugin! If you do not need + * to make use of any of the Direct3D calls, it is recommended to return false + * here to save on performance! + */ + + return true; +} + +/** + * Invoked when the plugin is being unloaded and is able to cleanup its Direct3D related resources. + * + * @notes + * + * Plugins should use this function to cleanup Direct3D related objects. + * - Index Buffers, Vertex Buffers + * - Textures + */ +void ExamplePlugin::Direct3DRelease(void) +{ } + +/** + * Invoked when the Direct3D device is beginning to render. (BeginScene) + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called after BeginScene is called. + */ +void ExamplePlugin::Direct3DPreRender(void) +{ } + +/** + * Invoked when the Direct3D device is ending its rendering. (EndScene) + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before EndScene is called. + */ +void ExamplePlugin::Direct3DRender(void) +{ } + +/** + * Invoked when the Direct3D device is presenting the scene. (Present) + * + * @param {RECT*} pSourceRect - The source rect being rendered into. + * @param {RECT*} pDestRect - The destination rect being rendered from. + * @param {HWND} hDestWindowOverride - The window handle, if any, to override the rendering into. + * @param {RGNDATA*} pDirtyRegion - The dirty region data. + * @returns {bool} True if the call should be blocked, false otherwise. + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before Present is called. + * + * Plugins can block the call from happening by returning true. + */ +bool ExamplePlugin::Direct3DPresent(const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion) +{ + UNREFERENCED_PARAMETER(pSourceRect); + UNREFERENCED_PARAMETER(pDestRect); + UNREFERENCED_PARAMETER(hDestWindowOverride); + UNREFERENCED_PARAMETER(pDirtyRegion); + + return false; +} + +/** + * Invoked when the Direct3D device is drawing a primitive to the scene. (DrawPrimitive) + * + * @param {D3DPRIMITIVETYPE} PrimitiveType - The type of primitive being rendered. + * @param {UINT} StartVertex - Index of the first vertex to load. + * @param {UINT} PrimitiveCount - Number of primitives to render. + * @returns {bool} True if the call should be blocked, false otherwise. + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before DrawPrimitive is called. + * + * Plugins can block the call from happening by returning true. + */ +bool ExamplePlugin::Direct3DDrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) +{ + UNREFERENCED_PARAMETER(PrimitiveType); + UNREFERENCED_PARAMETER(StartVertex); + UNREFERENCED_PARAMETER(PrimitiveType); + + return false; +} + +/** + * Invoked when the Direct3D device is drawing a primitive to the scene. (DrawIndexedPrimitive) + * + * @param {D3DPRIMITIVETYPE} PrimitiveType - The type of primitive being rendered. + * @param {UINT} minIndex - Minimum vertex index for vertices used during this call. + * @param {UINT} numVertices - Number of vertices used during this call + * @param {UINT} startIndex - Index of the first index to use when accesssing the vertex buffer. + * @param {UINT} primCount - Number of primitives to render. + * @returns {bool} True if the call should be blocked, false otherwise. + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before DrawIndexedPrimitive is called. + * + * Plugins can block the call from happening by returning true. + */ +bool ExamplePlugin::Direct3DDrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount) +{ + UNREFERENCED_PARAMETER(PrimitiveType); + UNREFERENCED_PARAMETER(minIndex); + UNREFERENCED_PARAMETER(NumVertices); + UNREFERENCED_PARAMETER(startIndex); + UNREFERENCED_PARAMETER(primCount); + + return false; +} + +/** + * Invoked when the Direct3D device is drawing a primitive to the scene. (DrawPrimitiveUP) + * + * @param {D3DPRIMITIVETYPE} PrimitiveType - The type of primitive being rendered. + * @param {UINT} PrimitiveCount - Number of primitives to render. + * @param {void*} pVertexStreamZeroData - User memory pointer to the vertex data. + * @param {UINT} VertexStreamZeroStride - The number of bytes of data for each vertex. + * @returns {bool} True if the call should be blocked, false otherwise. + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before DrawPrimitiveUP is called. + * + * Plugins can block the call from happening by returning true. + */ +bool ExamplePlugin::Direct3DDrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) +{ + UNREFERENCED_PARAMETER(PrimitiveType); + UNREFERENCED_PARAMETER(PrimitiveCount); + UNREFERENCED_PARAMETER(pVertexStreamZeroData); + UNREFERENCED_PARAMETER(VertexStreamZeroStride); + + return false; +} + +/** + * Invoked when the Direct3D device is drawing a primitive to the scene. (DrawIndexedPrimitiveUP) + * + * @param {D3DPRIMITIVETYPE} PrimitiveType - The type of primitive being rendered. + * @param {UINT} MinVertexIndex - Minimum vertex index. + * @param {UINT} NumVertexIndices - Number of vertices used during this call. + * @param {UINT} PrimitiveCount - Number of primitives to render. + * @param {void*} pIndexData - User memory pointer to the index data. + * @param {D3DFORMAT} IndexDataFormat - The format of the index data. + * @param {void*} pVertexStreamZeroData - User memory pointer to the vertex data. + * @param {UINT} VertexStreamZeroStride - The number of bytes of data for each vertex. + * @returns {bool} True if the call should be blocked, false otherwise. + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before DrawIndexedPrimitiveUP is called. + * + * Plugins can block the call from happening by returning true. + */ +bool ExamplePlugin::Direct3DDrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) +{ + UNREFERENCED_PARAMETER(PrimitiveType); + UNREFERENCED_PARAMETER(MinVertexIndex); + UNREFERENCED_PARAMETER(NumVertexIndices); + UNREFERENCED_PARAMETER(PrimitiveCount); + UNREFERENCED_PARAMETER(pIndexData); + UNREFERENCED_PARAMETER(IndexDataFormat); + UNREFERENCED_PARAMETER(pVertexStreamZeroData); + UNREFERENCED_PARAMETER(VertexStreamZeroStride); + + return false; +} + +/** + * Invoked when the Direct3D device is setting a render state. (SetRenderState) + * + * @param {D3DRENDERSTATETYPE} state - The render state to alter. + * @param {DWORD} value - The new value for the render state. + * @returns {bool} True if the call should be blocked, false otherwise. + * + * @notes + * + * This will only be called if you returned true inside of Direct3DInitialize! + * This function is called before SetRenderState is called. + * + * Plugins can block the call from happening by returning true. + */ +bool ExamplePlugin::Direct3DSetRenderState(D3DRENDERSTATETYPE State, DWORD Value) +{ + UNREFERENCED_PARAMETER(State); + UNREFERENCED_PARAMETER(Value); + + return false; +} + +/** + * Returns the interface version this plugin was compiled with. + * + * @returns {double} The Ashita interface version. + */ +__declspec(dllexport) double __stdcall GetInterfaceVersion(void) +{ + return ASHITA_INTERFACE_VERSION; +} + +/** + * Creates and populates the plugins information structure. + * + * @returns {double} The Ashita interface version. + */ +__declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* info) +{ + // Store the pointer from Ashita.. + g_PluginInfo = info; + + // Populate the structure with our plugins information.. + strcpy_s(info->Author, sizeof(info->Author), "atom0s"); + strcpy_s(info->Name, sizeof(info->Name), "ExamplePlugin"); + info->InterfaceVersion = ASHITA_INTERFACE_VERSION; + info->PluginVersion = 3.0f; + info->Priority = 0; +} + +/** + * Creates an instance of the plugins main class. + * + * @returns {IPlugin*} The plugin base class instance created by this plugin. + */ +__declspec(dllexport) IPlugin* __stdcall CreatePlugin(void) +{ + return (IPlugin*)new ExamplePlugin; +} \ No newline at end of file diff --git a/ExamplePlugin/ExamplePlugin.h b/ExamplePlugin/ExamplePlugin.h new file mode 100644 index 0000000..93d3565 --- /dev/null +++ b/ExamplePlugin/ExamplePlugin.h @@ -0,0 +1,104 @@ +/** + * Ashita - Copyright (c) 2014 - 2016 atom0s [atom0s@live.com] + * + * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to + * Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * + * By using Ashita, you agree to the above license and its terms. + * + * Attribution - You must give appropriate credit, provide a link to the license and indicate if changes were + * made. You must do so in any reasonable manner, but not in any way that suggests the licensor + * endorses you or your use. + * + * Non-Commercial - You may not use the material (Ashita) for commercial purposes. + * + * No-Derivatives - If you remix, transform, or build upon the material (Ashita), you may not distribute the + * modified material. You are, however, allowed to submit the modified works back to the original + * Ashita project in attempt to have it added to the original project. + * + * You may not apply legal terms or technological measures that legally restrict others + * from doing anything the license permits. + * + * No warranties are given. + */ + +#ifndef __ASHITA_EXAMPLEPLUGIN_H_INCLUDED__ +#define __ASHITA_EXAMPLEPLUGIN_H_INCLUDED__ + +#if defined (_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/** + * Main Ashita ADK Header + * + * This is the main header to include while creating Ashita v3 plugins. This header includes + * various things that are useful to plugins as well as includes all the other ADK files in + * a single header. Update this path to match where you have Ashita v3 installed to. + */ +#include "G:/Code/git.ashita.atom0s.com/Ashita v3/Ashita-src/build/plugins/ADK/Ashita.h" + +/** + * Plugin Information + * + * This object holds information specific to this plugin. The CreatePluginInfo exported function + * uses this object to create information about the plugin which is used internally with Ashita. + * + * Please note: Ashita maintains the pointer of this object! Your plugin should never try to delete + * this object manually! + */ +plugininfo_t* g_PluginInfo = nullptr; + +/** + * Main Plugin Class Instance + * + * The main class the plugin will expose back to Ashita when loaded. + * This class must inherit from IPlugin in order to be valid! + * + * See ExamplePlugin.cpp for more information about the functions in this class. + */ +class ExamplePlugin : IPlugin +{ + IAshitaCore* m_AshitaCore; + ILogManager* m_LogManager; + uint32_t m_PluginId; + IDirect3DDevice8* m_Direct3DDevice; + +public: + // Constructor and Deconstructor + ExamplePlugin(void); + ~ExamplePlugin(void); + +public: + // Plugin Information Callback + plugininfo_t GetPluginInfo(void) override; + +public: + // Main Initialization and Cleanup Callbacks + bool Initialize(IAshitaCore* core, ILogManager* log, uint32_t id) override; + void Release(void) override; + + // Chat Manager Callbacks + bool HandleCommand(const char* command, int32_t type) override; + bool HandleIncomingText(int16_t mode, const char* message, int16_t* modifiedMode, char* modifiedMessage, bool blocked) override; + bool HandleOutgoingText(int32_t type, const char* message, int32_t* modifiedType, char* modifiedMessage, bool blocked) override; + + // Packet Manager Callbacks + bool HandleIncomingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) override; + bool HandleOutgoingPacket(uint16_t id, uint32_t size, void* data, void* modified, bool blocked) override; + + // Direct3D Related Callbacks + bool Direct3DInitialize(IDirect3DDevice8* device) override; + void Direct3DRelease(void) override; + void Direct3DPreRender(void) override; + void Direct3DRender(void) override; + bool Direct3DPresent(const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion) override; + bool Direct3DDrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) override; + bool Direct3DDrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount) override; + bool Direct3DDrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override; + bool Direct3DDrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) override; + bool Direct3DSetRenderState(D3DRENDERSTATETYPE State, DWORD Value) override; +}; + +#endif // __ASHITA_EXAMPLEPLUGIN_H_INCLUDED__ \ No newline at end of file diff --git a/ExamplePlugin/ExamplePlugin.vcxproj b/ExamplePlugin/ExamplePlugin.vcxproj new file mode 100644 index 0000000..ec35ff1 --- /dev/null +++ b/ExamplePlugin/ExamplePlugin.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {A08DCC6D-9911-4A47-8D11-9BC12DF62BC9} + Win32Proj + ExamplePlugin + 8.1 + + + + DynamicLibrary + true + v140_xp + MultiByte + + + DynamicLibrary + false + v140_xp + true + MultiByte + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;EXAMPLEPLUGIN_EXPORTS;%(PreprocessorDefinitions) + true + ProgramDatabase + true + false + Async + + + Windows + true + exports.def + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;EXAMPLEPLUGIN_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + exports.def + + + + + Level3 + NotUsing + Full + false + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;EXAMPLEPLUGIN_EXPORTS;%(PreprocessorDefinitions) + true + true + true + Async + + + Windows + true + true + true + exports.def + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;EXAMPLEPLUGIN_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + exports.def + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExamplePlugin/ExamplePlugin.vcxproj.filters b/ExamplePlugin/ExamplePlugin.vcxproj.filters new file mode 100644 index 0000000..d6fe889 --- /dev/null +++ b/ExamplePlugin/ExamplePlugin.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {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 + + + + + Header Files + + + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/ExamplePlugin/exports.def b/ExamplePlugin/exports.def new file mode 100644 index 0000000..d2dc511 --- /dev/null +++ b/ExamplePlugin/exports.def @@ -0,0 +1,5 @@ +LIBRARY "ExamplePlugin" +EXPORTS + GetInterfaceVersion + CreatePluginInfo + CreatePlugin \ No newline at end of file