首页
社区
课程
招聘
[求助]WhiteMagic - Injected .NET Helper Library
发表于: 2010-9-4 05:54 1273

[求助]WhiteMagic - Injected .NET Helper Library

2010-9-4 05:54
1273
WhiteMagic - Injected .NET Helper Library

    Well, since Shynd released his BlackMagic library for out of process work, I figured I'd release my own little library, for in process work.

    Aptly named: WhiteMagic. (My creativity is awesome isn't it?)

    Anyhow... this library is aimed towards users who inject their .NET applications into processes. It provides ways to hook/detour functions, create memory patches, find patterns (via my FindPatternSharp stuff), as well as read/write memory (basic datatypes, structs, etc).

    It's released under the GPLv3 license (so you silly commercial people can't just go stealing code all willy nilly like).

    The API is fairly well rounded, with only 1 class instantiation required (or omitted if you choose), and you can do pretty much everything from there.

    Anyhow, I'm not releasing an example with this, because... if you don't know how to use it properly... you shouldn't be using it at all.

    HOWEVER, I will answer questions based on API troubles and the like. Other than that, it's up to you to figure out.

    The code is commented, and will throw more than enough exceptions to make sure you code is kept in line of requirements. (Eg; proper attributes, etc)

Edit: Since I got a few PMs about how to actually use the Detour API, here's a quick example.
Please note, the addresses used, are from WoW. Using the proper addresses to your DXDevice should produce the same results.

using System;
using System.Runtime.InteropServices;

using WhiteMagic;

namespace ConsoleApplication1
{
    internal class Program
    {
        #region Delegates

        [UnmanagedFunctionPointer(CallingConvention.WinApi)]
        public delegate int EndSceneDelegate(IntPtr instance);

        #endregion

        private static readonly EndSceneDelegate EndSceneHandler = EndScene;

        private static readonly Magic m = new Magic();

        private static int EndScene(IntPtr instance)
        {
            // Pulse();

            return (int)m.Detours["EndScene"].CallOriginal(instance);
        }

        private static void Main(string[] args)
        {
            IntPtr endSceneAddr = m.GetObjectVtableFunction(m.Read<IntPtr>(0x0123E908, 0x397C), 42);
            m.Detours.CreateAndApply(m.RegisterDelegate<EndSceneDelegate>(endSceneAddr), EndSceneHandler, "EndScene");
        }
    }
}


Changes:

9/20/2009 (v0.0.1.1)
- Added x64 support. Simply build with X64 as a define.
- Added support to turn off most exceptions. Simply build with NOEXCEPTIONS as a define.
- Cleaned up some code.
- Added more documentation, etc.
- Fixed a bug in the Detour class that caused it to crash. (Forgot to set the _win32 var)
- Minor other fixes

Credits:

Major credit to Shynd, who's name I pretty much stole (from his BlackMagic lib, aimed towards out of proc editors)
kynox; being an awesome ausfag
Cypher: being a portability nazi kiwi (yes, this lib is mainly for x86, no x64 support is implied)
jjaa; a good bit of his code is used in this library, however, I've changed/rewritten a good chunk of it.
Shynd; the BlackMagic library that I used as a basis of.. well... even writing this one...
Everyone at GD; just plain awesome people.
MMOwned; 95% retarded dimwits, but some of you are awesome.

[课程]Android-CTF解题方法汇总!

上传的附件:
收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//