1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Advanced] CLI injection in WE using Grimoire

Discussion in 'Warcraft Editing Tools' started by Risc, Jun 8, 2008.

  1. Risc

    Risc

    Joined:
    Jun 5, 2007
    Messages:
    81
    Resources:
    1
    Tools:
    1
    Resources:
    1
    EDIT: Total revamp of the old post since it's all obsolete by the new version.

    I've created a couple of loaders that makes it possible to inject .NET assemblies into the World Editor using Grimoire.

    This works by injecting a native win32 library which loads the "CLI loader" that in turn loads your .NET assembly.
    The reason why we need two loaders is simple. A .NET assembly doesn't have any entry-points. Grimoire can inject it, but it won't execute since the system doesn't know which function to call. The PELoader calls the "load" function in the CLILoader, which in turn loads every assembly it can find that implements the IWePlugin interface. The second loader eliminates the need for exports in the target assembly, since CLI-assemblies doesn't export any functions by default.

    UPDATE: A plugin architecture has been implemented (thanks to BlacKDicK @ Wc3Campaigns). This approach requires your plugin to inherit the IWePlugin interface (by referencing Shared.dll). I guess plugin-creation has never been easier.. Below is a short example (also included in the archive).

    (pluginTest.dll)
    Code (Text):

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Shared;
    using System.Windows.Forms;

    namespace pluginTest
    {
        public class MyCoolPlugin : IWePlugin
        {
            private Version version;
            private String author;
            private IWeNotify notifier;
            public String PluginAuthor { get { return author; } }
            public Version PluginVersion { get { return version; } }
            public IWeNotify Notifier { get { return notifier; } }

            public MyCoolPlugin()
            {
                //set some properties
                author = "Risc";
                version = new Version("1.0");
            }

            public IWeNotify RegisterNotify()
            {
                notifier = new PluginNotifier();
                notifier.OnRegisterPlugin += new delegateRegisterPlugin(notifier_OnRegisterPlugin);
                notifier.WindowCreated += new delegateWindowCreated(notifier_WindowCreated);
                //the return-type is reserved for further use.
                return notifier;
            }

            void notifier_WindowCreated(string className, string windowText, IntPtr hWnd)
            {
                if(windowText == "About Warcraft III World Editor UMS")
                    MessageBox.Show("Cool");
            }

            void notifier_OnRegisterPlugin()
            {
                MessageBox.Show("Hello WorldEdit!");
            }
        }
    }

     
    To use the PELoader, you'll need to reference it in "we.conf.lua":
    Code (Text):

    -- CLILoader
    loaddll("bin\\PELoader.dll")
     
    CLILoader.dll, PELoader.dll and all plugins that should be loaded must reside inside Grimoire's bin-folder.
    Shared.dll needs to reside in your Warcraft III folder (due to pathing).

    Please submit any bugs/suggestions you can find.
    Happy coding!

    //Risc
     

    Attached Files:

    Last edited: Jun 16, 2008
  2. Risc

    Risc

    Joined:
    Jun 5, 2007
    Messages:
    81
    Resources:
    1
    Tools:
    1
    Resources:
    1
    Updated to V2.0, see first post.