private void BuildX86(BuildEntry entry) { int methodRID = _state.MethodDefHash.IndexOf(entry.MethodSignature) + 1; // Add fixup entry var fixup = new VTableFixupEntry(); fixup.Type = VTableFixupType.SlotSize32Bit | VTableFixupType.FromUnmanaged; fixup.Add(MetadataToken.Get(MetadataTokenType.Method, methodRID)); _state.VTableFixupTable.Add(fixup); int pos = _codeBlob.Length; if (pos > 0) { pos = pos.Align(0x10); } PE.Fixups.Add(new X86Fixup(_codeBlob, pos, fixup)); // jmp _state.ExportTable.AddRVAEntry(entry.MethodName, _codeBlob, pos); _codeBlob.Write(ref pos, new byte[] { 0xFF, 0x25 }); // VA of method (through VTable) _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.HIGHLOW); _codeBlob.Write(ref pos, (uint)0); }
private void BuildIA64(BuildEntry entry) { int methodRID = _state.MethodDefHash.IndexOf(entry.MethodSignature) + 1; // Add fixup entry var fixup = new VTableFixupEntry(); fixup.Type = VTableFixupType.SlotSize64Bit | VTableFixupType.FromUnmanaged; fixup.Add(MetadataToken.Get(MetadataTokenType.Method, methodRID)); _state.VTableFixupTable.Add(fixup); int pos = _codeBlob.Length; if (pos > 0) { pos = pos.Align(0x10); } PE.Fixups.Add(new IA64Fixup(_codeBlob, pos, fixup)); // IA64 stub // ld8 r9 = [gp] ;; // ld8 r10 = [r9],8 // nop.i ;; // ld8 gp = [r9] // mov b6 = r10 // br.cond.sptk.few b6 _codeBlob.Write(ref pos, new byte[] { 0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00, }); // VA of IA64 stub _state.ExportTable.AddRVAEntry(entry.MethodName, _codeBlob, pos); _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.DIR64); _codeBlob.Write(ref pos, (ulong)0); // VA of method (through VTable) _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.DIR64); _codeBlob.Write(ref pos, (ulong)0); }