Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 DbgRuntimeObjectIdService GetRuntimeObjectIdService(DbgRuntime runtime)
 {
     return(runtime.GetOrCreateData <DbgRuntimeObjectIdService>(() => {
         var service = new DbgRuntimeObjectIdServiceImpl(runtime, GetEngineObjectIdFactory(runtime.Guid));
         service.ObjectIdsChanged += DbgRuntimeObjectIdService_ObjectIdsChanged;
         return service;
     }));
 }
Exemplo n.º 3
0
        public override DbgDynamicModuleProvider?Create(DbgRuntime runtime)
        {
            var engine = DbgEngineImpl.TryGetEngine(runtime);

            if (!(engine is null))
            {
                return(runtime.GetOrCreateData(() => new DbgDynamicModuleProviderImpl(engine)));
            }

            return(null);
        }
Exemplo n.º 4
0
        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);
            }
        }