1 //-----------------------------------------------------------------------------
2 // Copyright (C) Daniel Karling, 2021
3 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // See LICENSE.txt for the text of the license.
16 //-----------------------------------------------------------------------------
17 // main code for Multi Loader
18 //-----------------------------------------------------------------------------
19 #ifndef _DANKARMULTI_H_
20 #define _DANKARMULTI_H_
23 #error "Do not define MODE_NAME when including this first time"
27 #error "Do not define MODE_FILE when including this first time"
30 #define STRINGIZE(X) STRINGIZE2(X)
31 #define STRINGIZE2(X) #X
33 #define CONCAT(X,Y) CONCAT2(X,Y)
34 #define CONCAT2(X, Y) X##Y
36 typedef void (*func_ptr
)(void);
38 typedef struct mode_t
{
44 #define MODE_INTERNAL_NAME(name) CONCAT(standalone_mode, CONCAT(_,name))
45 #define MODE_INFO_FUNC(name) CONCAT(ModInfo, CONCAT(_,name))
46 #define MODE_RUN_FUNC(name) CONCAT(RunMod, CONCAT(_,name))
48 #define START_MODE_LIST mode_t *mode_list[] = {
49 #define ADD_MODE(name) &MODE_INTERNAL_NAME(name),
50 #define END_MODE_LIST }; static const int NUM_MODES = ARRAYLEN(mode_list);
55 #error "Define LOAD_MODE before including this file multiple times"
59 #error "Define LOAD_MODE before including this file multiple times"
62 void MODE_INFO_FUNC(MODE_NAME
)(void);
63 void MODE_RUN_FUNC(MODE_NAME
)(void);
65 #define ModInfo MODE_INFO_FUNC(MODE_NAME)
66 #define RunMod MODE_RUN_FUNC(MODE_NAME)
73 static mode_t
MODE_INTERNAL_NAME(MODE_NAME
) = {
74 .name
= STRINGIZE(MODE_NAME
),