| 269 | } |
| 270 | |
| 271 | void MemorySearcherTool::Load() |
| 272 | { |
| 273 | const auto memorySearcherPath = ActiveSettings::GetUserDataPath("memorySearcher/{:016x}.ini", CafeSystem::GetForegroundTitleId()); |
| 274 | auto memSearcherIniContents = FileStream::LoadIntoMemory(memorySearcherPath); |
| 275 | if (!memSearcherIniContents) |
| 276 | return; |
| 277 | |
| 278 | IniParser iniParser(*memSearcherIniContents, _pathToUtf8(memorySearcherPath)); |
| 279 | while (iniParser.NextSection()) |
| 280 | { |
| 281 | auto option_description = iniParser.FindOption("description"); |
| 282 | auto option_address = iniParser.FindOption("address"); |
| 283 | auto option_type = iniParser.FindOption("type"); |
| 284 | auto option_value = iniParser.FindOption("value"); |
| 285 | |
| 286 | if (!option_description || !option_address || !option_type || !option_value) |
| 287 | continue; |
| 288 | |
| 289 | try |
| 290 | { |
| 291 | const auto addr = StringHelpers::ToInt64(*option_address); |
| 292 | if (!IsAddressValid(addr)) |
| 293 | continue; |
| 294 | } |
| 295 | catch (const std::invalid_argument&) |
| 296 | { |
| 297 | continue; |
| 298 | } |
| 299 | |
| 300 | bool found = false; |
| 301 | for (const auto& entry : kDataTypeNames) |
| 302 | { |
| 303 | if (boost::iequals(entry.ToStdString(), *option_type)) |
| 304 | { |
| 305 | found = true; |
| 306 | break; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | if (!found && !boost::iequals(kDatatypeString.ToStdString(), *option_type)) |
| 311 | continue; |
| 312 | |
| 313 | wxVector<wxVariant> data; |
| 314 | data.push_back(std::string(*option_description).c_str()); |
| 315 | data.push_back(std::string(*option_address).c_str()); |
| 316 | data.push_back(std::string(*option_type).c_str()); |
| 317 | data.push_back(std::string(*option_value).c_str()); |
| 318 | data.push_back(!option_value->empty()); |
| 319 | m_listEntryTable->AppendItem(data); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | void MemorySearcherTool::Save() |
| 324 | { |
no test coverage detected