-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmulti.h
64 lines (61 loc) · 1.68 KB
/
multi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef BNDIFF_MULTI_H
#define BNDIFF_MULTI_H
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <bndiff/module_cxx.h>
class ModuleCtx {
public:
ModuleCtx(module_t * _mod) {
mod = _mod;
bn = new bignum_cluster_t();
}
~ModuleCtx() {
delete bn;
}
void* getBnPtr() {
return bn->BN;
}
void* getBnIdx(size_t idx) {
return bn->BN[idx];
}
void** getBnIdxPtr(size_t idx) {
return &(bn->BN[idx]);
}
void clearBn() {
memset(bn, 0, sizeof(*bn));
}
module_t* mod;
bignum_cluster_t* bn;
};
class Multi {
public:
Multi(module_container_t loadmodules) {
for ( auto curmod : loadmodules ) {
modules.push_back( new ModuleCtx(curmod) );
}
//logging = true;
}
~Multi() {
destroy_bignum();
for ( auto curmod : modules ) {
delete curmod;
}
}
bool initialize(void);
bool bignum_from_bin(const uint8_t* data, size_t size, size_t bn_index);
void bignum_string_reset(void);
void bignum_string_free(void);
bool exec_operation(operation_t operation, uint8_t op);
bool compare(void);
void destroy_bignum(void);
void shutdown(void);
void swap_bignum(size_t a, size_t b);
private:
bool logging;
size_t get_num_modules(void);
std::vector<ModuleCtx*> modules;
int decimal_strcmp(const char *s1, const char *s2);
void log_state(std::vector<std::vector<char*>> strings);
};
#endif