public Module(ProcessMemory mem, Diag::ProcessModule mod) { this.mem = mem; this.mod = mod; this.mbase = mem.GetPtr(mod.BaseAddress); // DOS Header this.dhead = mbase.Reinterpret <IMAGE.DOS_HEADER>(); if (dhead[0].magic != IMAGE.SIGNATURE.DOS) { dhead = default(RemotePtr <IMAGE.DOS_HEADER>); return; } // COFF Header remote_ptr ptr = mbase + dhead[0].lfanew; if (ptr.Read <uint>() != (uint)IMAGE.SIGNATURE.NT) { return; } this.chead = (ptr + 4).Reinterpret <IMAGE.FILE_HEADER>(); // Optional Header ohead = (chead + 1).Reinterpret <IMAGE.STD_OPTIONAL_HEADER>(); omagic = ohead[0].Magic; }
internal ImageImportDirectory( Module module, IMAGE.DATA_DIRECTORY data, IMAGE.DIRECTORY_ENTRY type ) : base(module, data, type) { unsafe { modcount = (int)(data.Size / sizeof(IMAGE.IMPORT_DESCRIPTOR)) - 1; //modcount--; // 最後の空項目を除く } descs = base.pData.Reinterpret <IMAGE.IMPORT_DESCRIPTOR>(); }
internal ImportModule(Module module, IMAGE.IMPORT_DESCRIPTOR desc) { this.module = module; this.desc = desc; int i = 0; if (desc.FirstThunk != 0) { switch (module.omagic) { case IMAGE.OPTIONAL_MAGIC.NT_HDR32: this.pIAT32 = (module.mbase + (int)desc.FirstThunk).Reinterpret <IMAGE.THUNK_DATA32>(); this.pINT32 = (module.mbase + (int)desc.OriginalFirstThunk).Reinterpret <IMAGE.THUNK_DATA32>(); while (pIAT32[i].Function != 0) { i++; } break; case IMAGE.OPTIONAL_MAGIC.NT_HDR64: this.pIAT64 = (module.mbase + (int)desc.FirstThunk).Reinterpret <IMAGE.THUNK_DATA64>(); this.pINT64 = (module.mbase + (int)desc.OriginalFirstThunk).Reinterpret <IMAGE.THUNK_DATA64>(); while (pIAT64[i].Function != 0) { i++; } break; default: throw new System.InvalidProgramException( "ROM Image には ImportTable は存在しない筈です。\r\n" + "このオブジェクトが存在することはプログラムとして誤っています。"); } } this.funccount = i; }
public ImportFunction(ushort ordinal, RemotePtr <FPtr> ppfn) { this.ordinal = ordinal; this.name = null; this.ppfn = ppfn; }
public ImportFunction(string name, RemotePtr <FPtr> ppfn) { ordinal = 0xffff; this.name = name; this.ppfn = ppfn; }
public void Write <U>(U value) where U : struct { RemotePtr <U> .Write(this.mem, this._base, value); }
public U Read <U>() where U : struct { return(RemotePtr <U> .Read(this.mem, this._base)); }