include/mgba/core/mem-search.h (view raw)
1/* Copyright (c) 2013-2017 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef CORE_MEM_SEARCH_H
7#define CORE_MEM_SEARCH_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba-util/vector.h>
14
15enum mCoreMemorySearchType {
16 mCORE_MEMORY_SEARCH_INT,
17 mCORE_MEMORY_SEARCH_STRING,
18 mCORE_MEMORY_SEARCH_GUESS,
19};
20
21enum mCoreMemorySearchOp {
22 mCORE_MEMORY_SEARCH_EQUAL,
23 mCORE_MEMORY_SEARCH_GREATER,
24 mCORE_MEMORY_SEARCH_LESS,
25 mCORE_MEMORY_SEARCH_ANY,
26 mCORE_MEMORY_SEARCH_DELTA,
27 mCORE_MEMORY_SEARCH_DELTA_POSITIVE,
28 mCORE_MEMORY_SEARCH_DELTA_NEGATIVE,
29 mCORE_MEMORY_SEARCH_DELTA_ANY,
30};
31
32struct mCoreMemorySearchParams {
33 int memoryFlags;
34 enum mCoreMemorySearchType type;
35 enum mCoreMemorySearchOp op;
36 int align;
37 int width;
38 union {
39 const char* valueStr;
40 int32_t valueInt;
41 };
42};
43
44struct mCoreMemorySearchResult {
45 uint32_t address;
46 int segment;
47 uint32_t guessDivisor;
48 uint32_t guessMultiplier;
49 enum mCoreMemorySearchType type;
50 int width;
51 int32_t oldValue;
52};
53
54DECLARE_VECTOR(mCoreMemorySearchResults, struct mCoreMemorySearchResult);
55
56struct mCore;
57void mCoreMemorySearch(struct mCore* core, const struct mCoreMemorySearchParams* params, struct mCoreMemorySearchResults* out, size_t limit);
58void mCoreMemorySearchRepeat(struct mCore* core, const struct mCoreMemorySearchParams* params, struct mCoreMemorySearchResults* inout);
59
60CXX_GUARD_END
61
62#endif