// foreach (var item in unitReader.inventoryReader.EnumerateInventoryBackward(player, FilterSlots)) bool InitializeGameDataReaders() { foreach (var desc in this.processDescriptions) { try { reader = new ProcessMemoryReader(desc.ProcessName, desc.ModuleName, desc.SubModules); } catch (ProcessNotFoundException) { CleanUpDataReaders(); } if (reader != null) { break; } } if (reader == null) { return(false); } try { memory = CreateGameMemoryTableForReader(reader); CreateUnitReader(); Logger.Info($"Found the Diablo II process (version {reader.FileVersion})."); return(true); } catch (ModuleNotLoadedException e) { Logger.Error($"Diablo II Process was found, but the module {e.ModuleName} was not yet loaded. Try launching a game."); CleanUpDataReaders(); return(false); } catch (GameVersionUnsupportedException e) { Logger.Error($"Diablo II Process was found, but the version {e.GameVersion} is not supported."); CleanUpDataReaders(); return(false); } catch (ProcessMemoryReadException) { Logger.Error("Diablo II Process was found but failed to read memory."); CleanUpDataReaders(); return(false); } void CleanUpDataReaders() { reader?.Dispose(); reader = null; memory = null; unitReader = null; } }