ItsMods

Full Version: NoKnife Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
it works, great, thx sooooooo much!
thank you for this plug in you are amazing
Could you post proper source code? I want to do some editing Sad
zxz0O0, you wrote "This plugin uses signature scans to find the offsets"
But i see there are no code for that scan in the 1-st post.

I use the code below for scanning. But it seems the addresses are wrong.
Can you help to correct this, please.
Code:
namespace NoKnife
{
    using Addon;
    using System;
    using System.Runtime.InteropServices;

    public class Class1 : CPlugin
    {
        private int DefaultKnifeAddress;
        private int KnifeRange;
        private string str_Knife = "enabled";
        private bool Working = true;
        private int ZeroAddress;

        private int FindMem(byte?[] search, int num = 1, int start = 0x1000000, int end = 0x3d00000)
        {
            int num2 = 0;
            try
            {
                int num3 = 0;
                for (int i = start; i < end; i++)
                {
                    num2 = i;
                    bool flag = false;
                    for (int j = 0; j < search.Length; j++)
                    {
                        if (search[j].HasValue)
                        {
                            int num7 = num2[0];
                            if (num7 != search[j])
                            {
                                break;
                            }
                        }
                        if (j == (search.Length - 1))
                        {
                            if (num == 1)
                            {
                                flag = true;
                            }
                            else
                            {
                                num3++;
                                if (num3 == num)
                                {
                                    flag = true;
                                }
                            }
                        }
                        else
                        {
                            num2++;
                        }
                    }
                    if (flag)
                    {
                        return i;
                    }
                }
            }
            catch (Exception exception)
            {
                base.ServerPrint(string.Concat(new object[] { "FindMem: ", exception.Message, "\nAddress: ", num2 }));
            }
            return 0;
        }

        private void Knife(bool bl)
        {
            if (!bl)
            {
                this.KnifeRange(0) = this.ZeroAddress;
                this.str_Knife = "disabled";
                base.ServerSay("Knifing disabled", false);
            }
            else
            {
                this.KnifeRange[0] = this.DefaultKnifeAddress;
                this.str_Knife = "enabled";
                base.ServerSay("Knifing enabled", false);
            }
        }

        public override ChatType OnSay(string Message, ServerClient Client)
        {
            if (Message == "!knife")
            {
                base.TellClient(Client.ClientNum, "PM: Knifing " + this.str_Knife, true);
                return ChatType.ChatNone;
            }
            if (!Message.StartsWith("!knife "))
            {
                return ChatType.ChatContinue;
            }
            if (!this.Working)
            {
                base.TellClient(Client.ClientNum, "NoKnife Plugin is not working. Addresses are wrong", true);
            }
            else if (Message == "!knife 0")
            {
                this.Knife(false);
            }
            else if (Message == "!knife 1")
            {
                this.Knife(true);
            }
            return ChatType.ChatNone;
        }

        public override void OnServerLoad()
        {
            try
            {
                base.ServerPrint("\n NoKnife Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh and Makavel\n");
                base.ServerPrint(" www.youtube.com/zxz0O0 \n www.itsmods.com\n");
                byte?[] search = new byte?[] {
                    0x8b, null, null, null, 0x83, null, 4, null, 0x83, null, 12, 0xd9, null, null, null, 0x8b,
                    null, 0xd9, null, null, null, 0xd9, 5
                 };
                this.KnifeRange = this.FindMem(search, 1, 0x400000, 0x500000) + search.Length;
                if (this.KnifeRange == search.Length)
                {
                    byte?[] nullableArray2 = new byte?[] {
                        0x8b, null, null, null, 0x83, null, 0x18, null, 0x83, null, 12, 0xd9, null, null, null, 0x8d,
                        null, null, null, 0xd9, null, null, null, 0xd9, 5
                     };
                    this.KnifeRange = this.FindMem(nullableArray2, 1, 0x400000, 0x500000) + nullableArray2.Length;
                    if (this.KnifeRange == nullableArray2.Length)
                    {
                        this.KnifeRange = 0;
                    }
                }
                this.DefaultKnifeAddress = this.KnifeRange[0];
                byte?[] nullableArray3 = new byte?[] {
                    0xd9, 0x5c, null, null, 0xd8, null, null, 0xd8, null, null, 0xd9, 0x5c, null, null, 0x83, null,
                    1, 15, 0x86, null, 0, 0, 0, 0xd9
                 };
                this.ZeroAddress = (this.FindMem(nullableArray3, 1, 0x400000, 0x500000) + nullableArray3.Length)[2];
                if (((this.KnifeRange == 0) || (this.DefaultKnifeAddress == 0)) || (this.ZeroAddress == 0))
                {
                    base.ServerPrint("Error finding address: NoKnife Plugin will not work");
                    this.Working = false;
                }
                else
                {
                    uint num;
                    VirtualProtect((IntPtr)this.KnifeRange, (IntPtr)4, 0x40, out num);
                }
                if (base.GetServerCFG("Knife", "Enabled", "1") == "0")
                {
                    this.Knife(false);
                }
            }
            catch (Exception exception)
            {
                base.ServerPrint("Error in NoKnife Plugin. Plugin will not work.");
                base.ServerPrint(exception.ToString());
                this.Working = false;
            }
        }

        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport("kernel32.dll")]
        private static extern bool VirtualProtect(IntPtr lpAddress, IntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
    }
}
(05-14-2013, 21:15)Diskretor Wrote: [ -> ]zxz0O0, you wrote "This plugin uses signature scans to find the offsets"
But i see there are no code for that scan in the 1-st post.

I use the code below for scanning. But it seems the addresses are wrong.
Can you help to correct this, please.

The plugin is working AFAIK, the source code on the main post is outdated I think.
did you decompile it or what?
This code is outdated and doesn't work for me.
Yes. I trying to see the source of DLL that normally worked.
Pages: 1 2 3 4 5 6 7 8 9