コード例 #1
0
ファイル: Patch.cs プロジェクト: sn206/DecompiledD2Bot
 public Patch(Patch.Dll dll, int offset, byte[] bytes)
 {
     this.DLL      = dll;
     this.Offset   = offset;
     this.OldCode  = new byte[bytes.Length];
     this.NewCode  = bytes;
     this.Injected = false;
 }
コード例 #2
0
ファイル: Patch.cs プロジェクト: sn206/DecompiledD2Bot
        public static IntPtr GetDllOffset(Process p, Patch.Dll dll, int offset)
        {
            string[] strArray = new string[15]
            {
                "D2CLIENT.dll",
                "D2COMMON.dll",
                "D2GFX.dll",
                "D2LANG.dll",
                "D2WIN.dll",
                "D2NET.dll",
                "D2GAME.dll",
                "D2LAUNCH.dll",
                "FOG.dll",
                "BNCLIENT.dll",
                "STORM.dll",
                "D2CMP.dll",
                "D2MULTI.dll",
                "D2MCPCLIENT.dll",
                "D2CMP.dll"
            };
            if (dll == Patch.Dll.GAME)
            {
                return(IntPtr.Add(p.MainModule.BaseAddress, offset));
            }
            IntPtr moduleHandle = Kernel32.FindModuleHandle(p, strArray[(int)dll]);

            if (moduleHandle == IntPtr.Zero)
            {
                if (!Kernel32.LoadRemoteLibrary(p, (object)strArray[(int)dll]))
                {
                    return(IntPtr.Zero);
                }
                moduleHandle = Kernel32.FindModuleHandle(p, strArray[(int)dll]);
            }
            return(IntPtr.Add(moduleHandle, offset));
        }