Created
December 18, 2022 20:52
-
-
Save KirillOsenkov/9f63d372620d3ae9e315e3e84ab3a2db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
static class PdbGuidAndAgeExtractor | |
{ | |
public static string GetGuidAndAge(string pdbFile) | |
{ | |
var dataSource = (IDiaDataSource) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("83AB22C8-993A-4D14-A0E0-37BC0AAEA793"))); | |
dataSource.loadDataFromPdb(pdbFile); | |
IDiaSession session; | |
dataSource.openSession(out session); | |
var globalScope = session.globalScope; | |
return (globalScope.guid.ToString("N") + globalScope.age.ToString("X")).ToUpperInvariant(); | |
} | |
} | |
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
[Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D")] | |
interface IDiaDataSource | |
{ | |
#region Unused | |
void lastError(); | |
#endregion | |
void loadDataFromPdb(string pdbPath); | |
#region Unused | |
void loadAndValidateDataFromPdb(); | |
void loadDataForExe(); | |
void loadDataFromIStream(); | |
#endregion | |
void openSession(out IDiaSession ppSession); | |
} | |
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
[Guid("6FC5D63F-011E-40C2-8DD2-E6486E9D6B68")] | |
interface IDiaSession | |
{ | |
#region Unused | |
void get_loadAddress(); | |
void set_loadAddress(); | |
#endregion | |
IDiaSymbol globalScope { get; } | |
} | |
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
[Guid("CB787B2F-BD6C-4635-BA52-933126BD2DCD")] | |
interface IDiaSymbol | |
{ | |
#region Unused | |
void symIndexId(); | |
void symTag(); | |
void name(); | |
void lexicalParent(); | |
void classParent(); | |
void type(); | |
void dataKind(); | |
void locationType(); | |
void addressSection(); | |
void addressOffset(); | |
void relativeVirtualAddress(); | |
void virtualAddress(); | |
void registerId(); | |
void offset(); | |
void length(); | |
void slot(); | |
void volatileType(); | |
void constType(); | |
void unalignedType(); | |
void access(); | |
void libraryName(); | |
void platform(); | |
void language(); | |
void editAndContinueEnabled(); | |
void frontEndMajor(); | |
void frontEndMinor(); | |
void frontEndBuild(); | |
void backEndMajor(); | |
void backEndMinor(); | |
void backEndBuild(); | |
void sourceFileName(); | |
void unused(); | |
void thunkOrdinal(); | |
void thisAdjust(); | |
void virtualBaseOffset(); | |
void @virtual(); | |
void intro(); | |
void pure(); | |
void callingConvention(); | |
void value(); | |
void baseType(); | |
void token(); | |
void timeStamp(); | |
#endregion | |
Guid guid { get; } | |
#region Unused | |
void symbolsFileName(); | |
void reference(); | |
void count(); | |
void bitPosition(); | |
void arrayIndexType(); | |
void packed(); | |
void constructor(); | |
void overloadedOperator(); | |
void nested(); | |
void hasNestedTypes(); | |
void hasAssignmentOperator(); | |
void hasCastOperator(); | |
void scoped(); | |
void virtualBaseClass(); | |
void indirectVirtualBaseClass(); | |
void virtualBasePointerOffset(); | |
void virtualTableShape(); | |
void lexicalParentId(); | |
void classParentId(); | |
void typeId(); | |
void arrayIndexTypeId(); | |
void virtualTableShapeId(); | |
void code(); | |
void function(); | |
void managed(); | |
void msil(); | |
void virtualBaseDispIndex(); | |
void undecoratedName(); | |
#endregion | |
uint age { get; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment