public override DbgRawMetadata Create(DbgRuntime runtime, bool isFileLayout, byte[] moduleBytes) { if (runtime is null) { throw new ArgumentNullException(nameof(runtime)); } if (moduleBytes is null) { throw new ArgumentNullException(nameof(moduleBytes)); } var state = runtime.GetOrCreateData <RuntimeState>(); lock (state.LockObj) { var rawMd = new DbgRawMetadataImpl(moduleBytes, isFileLayout); try { state.OtherMetadata.Add(rawMd); } catch { rawMd.Release(); throw; } return(rawMd); } }
public override DbgRawMetadata Create(DbgRuntime runtime, bool isFileLayout, ulong moduleAddress, int moduleSize) { if (runtime is null) { throw new ArgumentNullException(nameof(runtime)); } if (moduleAddress == 0) { throw new ArgumentOutOfRangeException(nameof(moduleAddress)); } if (moduleSize <= 0) { throw new ArgumentOutOfRangeException(nameof(moduleSize)); } var state = runtime.GetOrCreateData <RuntimeState>(); lock (state.LockObj) { if (state.Dict.TryGetValue(moduleAddress, out var rawMd)) { if (rawMd.TryAddRef() is not null) { if (rawMd.IsFileLayout != isFileLayout || rawMd.Size != moduleSize) { rawMd.Release(); throw new InvalidOperationException(); } return(rawMd); } state.Dict.Remove(moduleAddress); } rawMd = new DbgRawMetadataImpl(runtime.Process, isFileLayout, moduleAddress, moduleSize); try { state.Dict.Add(moduleAddress, rawMd); } catch { rawMd.Release(); throw; } return(rawMd); } }