MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / exportIPSPatch

Function exportIPSPatch

src/gui2/imhex_overrides/main_menu_items.cpp:284–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282 }
283
284 void exportIPSPatch() {
285 auto provider = ImHexApi::Provider::get();
286
287 auto patches = Patches::fromProvider(provider);
288 if (!patches.has_value()) {
289 handleIPSError(patches.error());
290 return;
291 }
292
293 // Make sure there's no patch at address 0x00454F46 because that would cause the patch to contain the sequence "EOF" which signals the end of the patch
294 if (!patches->get().contains(0x00454F45) && patches->get().contains(0x00454F46)) {
295 u8 value = 0;
296 provider->read(0x00454F45, &value, sizeof(u8));
297 patches->get().at(0x00454F45) = value;
298 }
299
300 TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [patches](auto &) {
301 auto data = patches->toIPSPatch();
302
303 TaskManager::doLater([data] {
304 fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const auto &path) {
305 auto file = wolv::io::File(path, wolv::io::File::Mode::Create);
306 if (!file.isValid()) {
307 ui::ToastError::open("hex.builtin.menu.file.export.ips.popup.export_error"_lang);
308 return;
309 }
310
311 if (data.has_value()) {
312 const auto& bytes = data.value();
313 file.writeVector(bytes);
314 EventPatchCreated::post(bytes.data(), bytes.size(), PatchKind::IPS);
315 } else {
316 handleIPSError(data.error());
317 }
318 });
319 });
320 });
321 }
322
323 void exportIPS32Patch() {
324 auto provider = ImHexApi::Provider::get();

Callers

nothing calls this directly

Calls 8

handleIPSErrorFunction · 0.85
FileClass · 0.50
containsMethod · 0.45
getMethod · 0.45
readMethod · 0.45
valueMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected