internal static uint[] LoadRemapTable(Stream read) { //tokenToSourceMapping = new Dictionary<uint, PdbTokenLine>(); BitAccess bits = new BitAccess(512 * 1024); PdbFileHeader head = new PdbFileHeader(read, bits); PdbReader reader = new PdbReader(read, head.pageSize); MsfDirectory dir = new MsfDirectory(reader, head, bits); DbiModuleInfo[] modules = null; DbiDbgHdr header; dir.streams[1].Read(reader, bits); Dictionary <string, int> nameIndex = LoadNameIndex(bits); int nameStream; if (!nameIndex.TryGetValue("/NAMES", out nameStream)) { throw new PdbDebugException("No `name' stream"); } dir.streams[nameStream].Read(reader, bits); IntHashTable names = LoadNameStream(bits); int srcsrvStream; string sourceServerData; if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream)) { sourceServerData = string.Empty; } else { DataStream dataStream = dir.streams[srcsrvStream]; byte[] bytes = new byte[dataStream.contentSize]; dataStream.Read(reader, bits); sourceServerData = bits.ReadBString(bytes.Length); } dir.streams[3].Read(reader, bits); LoadDbiStream(bits, out modules, out header, true); #if SKIP_THIS ArrayList funcList = new ArrayList(); if (modules != null) { for (int m = 0; m < modules.Length; m++) { var module = modules[m]; if (module.stream > 0) { dir.streams[module.stream].Read(reader, bits); if (module.moduleName == "TokenSourceLineInfo") { LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping); continue; } LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader, ilreader); } } } PdbFunction[] funcs = (PdbFunction[])funcList.ToArray(typeof(PdbFunction)); #endif // After reading the functions, apply the token remapping table if it exists. if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff) { uint[] ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4]; dir.streams[header.snTokenRidMap].Read(reader, bits); bits.ReadUInt32(ridMap); return(ridMap); } return(null); }
internal PdbConstant(BitAccess bits) { bits.ReadUInt32(out this.token); byte tag1; bits.ReadUInt8(out tag1); byte tag2; bits.ReadUInt8(out tag2); if (tag2 == 0) { this.value = tag1; } else if (tag2 == 0x80) { switch (tag1) { case 0x00: //sbyte sbyte sb; bits.ReadInt8(out sb); this.value = sb; break; case 0x01: //short short s; bits.ReadInt16(out s); this.value = s; break; case 0x02: //ushort ushort us; bits.ReadUInt16(out us); this.value = us; break; case 0x03: //int int i; bits.ReadInt32(out i); this.value = i; break; case 0x04: //uint uint ui; bits.ReadUInt32(out ui); this.value = ui; break; case 0x05: //float this.value = bits.ReadFloat(); break; case 0x06: //double this.value = bits.ReadDouble(); break; case 0x09: //long long sl; bits.ReadInt64(out sl); this.value = sl; break; case 0x0a: //ulong ulong ul; bits.ReadUInt64(out ul); this.value = ul; break; case 0x10: //string string str; bits.ReadBString(out str); this.value = str; break; case 0x19: //decimal this.value = bits.ReadDecimal(); break; default: //TODO: error break; } } else { //TODO: error } bits.ReadCString(out name); }
internal PdbConstant(BitAccess bits) { bits.ReadUInt32(out this.token); byte tag1; bits.ReadUInt8(out tag1); byte tag2; bits.ReadUInt8(out tag2); if (tag2 == 0) { this.value = tag1; } else if (tag2 == 0x80) { switch (tag1) { case 0x00: //sbyte sbyte sb; bits.ReadInt8(out sb); this.value = sb; break; case 0x01: //short short s; bits.ReadInt16(out s); this.value = s; break; case 0x02: //ushort ushort us; bits.ReadUInt16(out us); this.value = us; break; case 0x03: //int int i; bits.ReadInt32(out i); this.value = i; break; case 0x04: //uint uint ui; bits.ReadUInt32(out ui); this.value = ui; break; case 0x05: //float this.value = bits.ReadFloat(); break; case 0x06: //double this.value = bits.ReadDouble(); break; case 0x09: //long long sl; bits.ReadInt64(out sl); this.value = sl; break; case 0x0a: //ulong ulong ul; bits.ReadUInt64(out ul); this.value = ul; break; case 0x10: //string string str; bits.ReadBString(out str); this.value = str; break; case 0x19: //decimal this.value = bits.ReadDecimal(); break; default: //TODO: error break; } } else { //TODO: error } bits.ReadCString(out name); }
internal static PdbFunction[] LoadFunctions(Stream read, out Dictionary<uint, PdbTokenLine> tokenToSourceMapping, out string sourceServerData) { tokenToSourceMapping = new Dictionary<uint, PdbTokenLine>(); BitAccess bits = new BitAccess(512 * 1024); PdbFileHeader head = new PdbFileHeader(read, bits); PdbReader reader = new PdbReader(read, head.pageSize); MsfDirectory dir = new MsfDirectory(reader, head, bits); DbiModuleInfo[] modules = null; DbiDbgHdr header; dir.streams[1].Read(reader, bits); Dictionary<string, int> nameIndex = LoadNameIndex(bits); int nameStream; if (!nameIndex.TryGetValue("/NAMES", out nameStream)) { throw new PdbException("No `name' stream"); } dir.streams[nameStream].Read(reader, bits); IntHashTable names = LoadNameStream(bits); int srcsrvStream; if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream)) sourceServerData = string.Empty; else { DataStream dataStream = dir.streams[srcsrvStream]; byte[] bytes = new byte[dataStream.contentSize]; dataStream.Read(reader, bits); sourceServerData = bits.ReadBString(bytes.Length); } dir.streams[3].Read(reader, bits); LoadDbiStream(bits, out modules, out header, true); ArrayList funcList = new ArrayList(); if (modules != null) { for (int m = 0; m < modules.Length; m++) { var module = modules[m]; if (module.stream > 0) { dir.streams[module.stream].Read(reader, bits); if (module.moduleName == "TokenSourceLineInfo") { LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping); continue; } LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader); } } } PdbFunction[] funcs = (PdbFunction[])funcList.ToArray(typeof(PdbFunction)); // After reading the functions, apply the token remapping table if it exists. if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff) { dir.streams[header.snTokenRidMap].Read(reader, bits); uint[] ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4]; bits.ReadUInt32(ridMap); foreach (PdbFunction func in funcs) { func.token = 0x06000000 | ridMap[func.token & 0xffffff]; } } // Array.Sort(funcs, PdbFunction.byAddressAndToken); //Array.Sort(funcs, PdbFunction.byToken); return funcs; }
internal static PdbInfo LoadFunctions(Stream read) { PdbInfo pdbInfo = new PdbInfo(); pdbInfo.TokenToSourceMapping = new Dictionary <uint, PdbTokenLine>(); BitAccess bits = new BitAccess(64 * 1024); PdbFileHeader head = new PdbFileHeader(read, bits); PdbReader reader = new PdbReader(read, head.pageSize); MsfDirectory dir = new MsfDirectory(reader, head, bits); DbiModuleInfo[] modules = null; DbiDbgHdr header; Dictionary <string, PdbSource> sourceCache = new Dictionary <string, PdbSource>(); dir.streams[1].Read(reader, bits); Dictionary <string, int> nameIndex = LoadNameIndex(bits, out pdbInfo.Age, out pdbInfo.Guid); int nameStream; if (!nameIndex.TryGetValue("/NAMES", out nameStream)) { throw new PdbException("Could not find the '/NAMES' stream: the PDB file may be a public symbol file instead of a private symbol file"); } dir.streams[nameStream].Read(reader, bits); IntHashTable names = LoadNameStream(bits); int srcsrvStream; if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream)) { pdbInfo.SourceServerData = string.Empty; } else { DataStream dataStream = dir.streams[srcsrvStream]; byte[] bytes = new byte[dataStream.contentSize]; dataStream.Read(reader, bits); pdbInfo.SourceServerData = bits.ReadBString(bytes.Length); } dir.streams[3].Read(reader, bits); LoadDbiStream(bits, out modules, out header, true); List <PdbFunction> funcList = new List <PdbFunction>(); if (modules != null) { for (int m = 0; m < modules.Length; m++) { var module = modules[m]; if (module.stream > 0) { dir.streams[module.stream].Read(reader, bits); if (module.moduleName == "TokenSourceLineInfo") { LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, pdbInfo.TokenToSourceMapping, sourceCache); continue; } LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader, sourceCache); } } } PdbFunction[] funcs = funcList.ToArray(); // After reading the functions, apply the token remapping table if it exists. if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff) { dir.streams[header.snTokenRidMap].Read(reader, bits); uint[] ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4]; bits.ReadUInt32(ridMap); foreach (PdbFunction func in funcs) { func.token = 0x06000000 | ridMap[func.token & 0xffffff]; } } // Array.Sort(funcs, PdbFunction.byAddressAndToken); //Array.Sort(funcs, PdbFunction.byToken); pdbInfo.Functions = funcs; return(pdbInfo); }
internal PdbConstant(BitAccess bits) { bits.ReadUInt32(out this.Token); byte tag1; bits.ReadUInt8(out tag1); byte tag2; bits.ReadUInt8(out tag2); switch (tag2) { case 0: this.Value = tag1; break; case 0x80: switch (tag1) { case 0x01: //short short s; bits.ReadInt16(out s); this.Value = s; break; case 0x02: //ushort ushort us; bits.ReadUInt16(out us); this.Value = us; break; case 0x03: //int int i; bits.ReadInt32(out i); this.Value = i; break; case 0x04: //uint uint ui; bits.ReadUInt32(out ui); this.Value = ui; break; case 0x05: //float this.Value = bits.ReadFloat(); break; case 0x06: //double this.Value = bits.ReadDouble(); break; case 0x09: //long long sl; bits.ReadInt64(out sl); this.Value = sl; break; case 0x0a: //ulong ulong ul; bits.ReadUInt64(out ul); this.Value = ul; break; case 0x10: //string string str; bits.ReadBString(out str); this.Value = str; break; case 0x19: //decimal this.Value = bits.ReadDecimal(); break; } break; } bits.ReadCString(out this.Name); }
internal PdbConstant(BitAccess bits) { bits.ReadUInt32(out this.Token); byte tag1; bits.ReadUInt8(out tag1); byte tag2; bits.ReadUInt8(out tag2); switch (tag2) { case 0: this.Value = tag1; break; case 0x80: switch (tag1) { case 0x01: //short short s; bits.ReadInt16(out s); this.Value = s; break; case 0x02: //ushort ushort us; bits.ReadUInt16(out us); this.Value = us; break; case 0x03: //int int i; bits.ReadInt32(out i); this.Value = i; break; case 0x04: //uint uint ui; bits.ReadUInt32(out ui); this.Value = ui; break; case 0x05: //float this.Value = bits.ReadFloat(); break; case 0x06: //double this.Value = bits.ReadDouble(); break; case 0x09: //long long sl; bits.ReadInt64(out sl); this.Value = sl; break; case 0x0a: //ulong ulong ul; bits.ReadUInt64(out ul); this.Value = ul; break; case 0x10: //string string str; bits.ReadBString(out str); this.Value = str; break; case 0x19: //decimal this.Value = bits.ReadDecimal(); break; } break; } bits.ReadCString(out this.Name); }
internal static PdbFunction[] LoadFunctions(Stream read, out Dictionary <uint, PdbTokenLine> tokenToSourceMapping, out string sourceServerData, System.Compiler.Metadata.Reader ilreader) { tokenToSourceMapping = new Dictionary <uint, PdbTokenLine>(); BitAccess bits = new BitAccess(512 * 1024); PdbFileHeader head = new PdbFileHeader(read, bits); PdbReader reader = new PdbReader(read, head.pageSize); MsfDirectory dir = new MsfDirectory(reader, head, bits); DbiModuleInfo[] modules = null; DbiDbgHdr header; Dictionary <string, PdbSource> sourceCache = new Dictionary <string, PdbSource>(); dir.streams[1].Read(reader, bits); Dictionary <string, int> nameIndex = LoadNameIndex(bits); int nameStream; if (!nameIndex.TryGetValue("/NAMES", out nameStream)) { throw new NoNameStreamPdbException(); } dir.streams[nameStream].Read(reader, bits); IntHashTable names = LoadNameStream(bits); int srcsrvStream; if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream)) { sourceServerData = string.Empty; } else { DataStream dataStream = dir.streams[srcsrvStream]; byte[] bytes = new byte[dataStream.contentSize]; dataStream.Read(reader, bits); sourceServerData = bits.ReadBString(bytes.Length); } dir.streams[3].Read(reader, bits); LoadDbiStream(bits, out modules, out header, true); ArrayList funcList = new ArrayList(); if (modules != null) { for (int m = 0; m < modules.Length; m++) { var module = modules[m]; if (module.stream > 0) { dir.streams[module.stream].Read(reader, bits); if (module.moduleName == "TokenSourceLineInfo") { LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping, sourceCache); continue; } LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader, ilreader, sourceCache); } } } PdbFunction[] funcs = (PdbFunction[])funcList.ToArray(typeof(PdbFunction)); // After reading the functions, apply the token remapping table if it exists. if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff) { uint[] ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4]; dir.streams[header.snTokenRidMap].Read(reader, bits); bits.ReadUInt32(ridMap); foreach (PdbFunction func in funcs) { func.MapTokens(ridMap, ilreader); } } else { foreach (PdbFunction func in funcs) { func.MapTokens(null, ilreader); } } // Array.Sort(funcs, PdbFunction.byAddressAndToken); //Array.Sort(funcs, PdbFunction.byToken); return(funcs); }