mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
parent
430ca985d3
commit
0542825567
5 changed files with 113 additions and 164 deletions
|
@ -26,7 +26,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "proxgui.h"
|
#include "proxgui.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "ui.h"
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "util_darwin.h"
|
#include "util_darwin.h"
|
||||||
|
@ -169,11 +168,6 @@ void ProxWidget::vchange_dthr_down(int v) {
|
||||||
}
|
}
|
||||||
ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
||||||
this->master = master;
|
this->master = master;
|
||||||
|
|
||||||
// Set the initail postion and size from settings
|
|
||||||
if (session.settings_loaded)
|
|
||||||
setGeometry (session.window_plot_xpos,session.window_plot_ypos,session.window_plot_wsize,session.window_plot_hsize);
|
|
||||||
else
|
|
||||||
resize(800, 400);
|
resize(800, 400);
|
||||||
|
|
||||||
// Setup the controller widget
|
// Setup the controller widget
|
||||||
|
|
|
@ -582,14 +582,10 @@ int main(int argc, char *argv[]) {
|
||||||
set_my_executable_path();
|
set_my_executable_path();
|
||||||
set_my_user_directory();
|
set_my_user_directory();
|
||||||
|
|
||||||
// Load Settings and assign
|
// Settings Load and Test
|
||||||
// This will allow the command line to override the settings.json values
|
// settings_load ();
|
||||||
settings_load ();
|
|
||||||
// quick patch for debug level
|
|
||||||
g_debugMode = session.logging_level;
|
|
||||||
|
|
||||||
// settings_save ();
|
// settings_save ();
|
||||||
|
// printf ("Ver : %s\n",mySettings.version);
|
||||||
// End Settings
|
// End Settings
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
|
|
|
@ -39,74 +39,51 @@
|
||||||
// Settings Functions
|
// Settings Functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Notes
|
|
||||||
// To add a new setting
|
|
||||||
// Add the new setting to the session_arg_t; in ui.h
|
|
||||||
// Add the default value for the setting in the settings_load page below
|
|
||||||
// Update the settings_load_callback to load your setting into the stucture
|
|
||||||
// Update the settings_save_callback to enusre your setting gets saved (not used yet)
|
|
||||||
// Include "settingdata.h" (if needed) in the source file where you wish to use the setting
|
|
||||||
// use the setting as needed : mySettings.<setting name>
|
|
||||||
// Should use if (mySettings.loaded) { use settings }
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "emv/emvjson.h"
|
#include "emv/emvjson.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
typedef struct {
|
|
||||||
bool stdinOnTTY;
|
|
||||||
bool stdoutOnTTY;
|
|
||||||
bool supports_colors;
|
|
||||||
emojiMode_t emoji_mode;
|
|
||||||
bool pm3_present;
|
|
||||||
bool help_dump_mode;
|
|
||||||
bool show_hints;
|
|
||||||
} session_arg_t;
|
|
||||||
|
|
||||||
extern session_arg_t session
|
|
||||||
*/
|
|
||||||
// Load all settings into memory (struct)
|
// Load all settings into memory (struct)
|
||||||
int settings_load (void)
|
int settings_load (void) {
|
||||||
{
|
|
||||||
|
|
||||||
// Set all defaults
|
|
||||||
// mySettings.os_windows_usecolor = false;
|
|
||||||
// mySettings.os_windows_useansicolor = false;
|
|
||||||
session.logging_level = NORMAL;
|
|
||||||
session.window_plot_xpos = 10;
|
|
||||||
session.window_plot_ypos = 30;
|
|
||||||
session.window_plot_hsize = 400;
|
|
||||||
session.window_plot_wsize = 800;
|
|
||||||
// mySettings.window_xpos = 10;
|
|
||||||
// mySettings.window_ypos = 210;
|
|
||||||
// mySettings.window_hsize = 300;
|
|
||||||
// mySettings.window_wsize = 500;
|
|
||||||
// mySettings.show_emoji = ALIAS;
|
|
||||||
session.emoji_mode = ALIAS;
|
|
||||||
session.show_hints = false;
|
|
||||||
|
|
||||||
// loadFileJson wants these, so pass in place holder values, though not used
|
// loadFileJson wants these, so pass in place holder values, though not used
|
||||||
// in settings load;
|
// in settings load;
|
||||||
uint8_t dummyData = 0x00;
|
uint8_t dummyData = 0x00;
|
||||||
size_t dummyDL = 0x00;
|
size_t dummyDL = 0x00;
|
||||||
|
|
||||||
|
// clear all settings
|
||||||
|
memset (&mySettings,0x00,sizeof(mySettings));
|
||||||
|
|
||||||
if (loadFileJSON(settingsFilename, &dummyData, sizeof(dummyData), &dummyDL) == PM3_SUCCESS) {
|
if (loadFileJSON(settingsFilename, &dummyData, sizeof(dummyData), &dummyDL) == PM3_SUCCESS) {
|
||||||
session.settings_loaded = true;
|
printf ("==> Settings Loaded\n");
|
||||||
|
mySettings.loaded = true;
|
||||||
}
|
}
|
||||||
else // Save default/create settings.json file
|
|
||||||
settings_save ();
|
|
||||||
|
|
||||||
|
|
||||||
|
// Test results
|
||||||
|
/*
|
||||||
|
bool os_windows_usecolor;
|
||||||
|
bool os_windows_useansicolor;
|
||||||
|
int window_xpos;
|
||||||
|
int window_ypos;
|
||||||
|
int window_hsize;
|
||||||
|
int window_wsize;
|
||||||
|
bool use_emojis
|
||||||
|
bool use_hints
|
||||||
|
*/
|
||||||
|
printf (" Settings Version : [%s]\n", mySettings.version);
|
||||||
|
printf (" os_windows_usecolor (bool) : [%d]\n", mySettings.os_windows_usecolor);
|
||||||
|
printf (" os_windows_useAnsicolor (bool) : [%d]\n", mySettings.os_windows_useansicolor);
|
||||||
|
printf (" window_xpos (int) : [%d]\n", mySettings.window_xpos);
|
||||||
|
printf (" window_ypos (int) : [%d]\n", mySettings.window_ypos);
|
||||||
|
printf (" window_hsize (int) : [%d]\n", mySettings.window_hsize);
|
||||||
|
printf (" window_wsize (int) : [%d]\n", mySettings.window_wsize);
|
||||||
|
printf (" use emoji (bool) : [%d]\n", mySettings.use_emojis);
|
||||||
|
printf (" use hints (bool) : [%d]\n", mySettings.use_hints);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save all settings from memory (struct) to file
|
// Save all settings from memory (struct) to file
|
||||||
int settings_save (void)
|
int settings_save(void) {
|
||||||
{
|
|
||||||
// Note sure if backup has value ?
|
// Note sure if backup has value ?
|
||||||
char backupFilename[500];
|
char backupFilename[500];
|
||||||
|
|
||||||
|
@ -135,112 +112,83 @@ int settings_save (void)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_save_callback (json_t *root)
|
void settings_save_callback(json_t *root) {
|
||||||
{
|
|
||||||
|
printf ("==> Save Settings\n");
|
||||||
|
//JsonSaveStr(root, "FileType", "settings");
|
||||||
|
//JsonSaveStr (root,"Test1.Test2","test settings");
|
||||||
|
/*
|
||||||
|
"version": "1.0 Nov 2019",
|
||||||
|
"os.windows.usecolor": true,
|
||||||
|
"os.windows.useAnsiColor": true,
|
||||||
|
"window.xpos": 10,
|
||||||
|
"window.ypos": 10,
|
||||||
|
"window.hsize": 300,
|
||||||
|
"window.wsize": 600
|
||||||
|
*/
|
||||||
JsonSaveStr (root,"FileType","settings");
|
JsonSaveStr (root,"FileType","settings");
|
||||||
// JsonSaveBoolean (root,"os.windows.useColor",mySettings.os_windows_usecolor);
|
JsonSaveStr (root,"version","1.0 Nov 2019");//mySettings.version);
|
||||||
// JsonSaveBoolean (root,"os.windows.useAnsiColor",mySettings.os_windows_useansicolor);
|
JsonSaveBoolean (root,"os.windows.useColor", mySettings.os_windows_usecolor);
|
||||||
// Log level, convert to text
|
JsonSaveBoolean (root,"os.windows.useAnsiColor", mySettings.os_windows_useansicolor);
|
||||||
// JsonSaveInt (root,"window.logging.level",mySettings.logging_level);
|
JsonSaveInt (root,"window.xpos", mySettings.window_xpos);
|
||||||
switch (session.logging_level)
|
JsonSaveInt (root,"window.ypos", mySettings.window_ypos);
|
||||||
{
|
JsonSaveInt (root,"window.hsize", mySettings.window_hsize);
|
||||||
case NORMAL: JsonSaveStr (root,"logging.level","normal"); break;
|
JsonSaveInt (root,"window.wsize", mySettings.window_wsize);
|
||||||
case SUCCESS: JsonSaveStr (root,"logging.level","success"); break;
|
JsonSaveBoolean (root,"client.useEmojis", mySettings.use_emojis);
|
||||||
case INFO: JsonSaveStr (root,"logging.level","info"); break;
|
JsonSaveBoolean (root,"client.useHints", mySettings.use_hints);
|
||||||
case FAILED: JsonSaveStr (root,"logging.level","failed"); break;
|
|
||||||
case WARNING: JsonSaveStr (root,"logging.level","warning"); break;
|
|
||||||
case ERR: JsonSaveStr (root,"logging.level","err"); break;
|
|
||||||
case DEBUG: JsonSaveStr (root,"logging.level","debug"); break;
|
|
||||||
case INPLACE: JsonSaveStr (root,"logging.level","inplace"); break;
|
|
||||||
case HINT: JsonSaveStr (root,"logging.level","hint"); break;
|
|
||||||
default:
|
|
||||||
JsonSaveStr (root,"logging.level","NORMAL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plot window
|
void settings_load_callback(json_t *root) {
|
||||||
JsonSaveInt (root,"window.plot.xpos",session.window_plot_xpos);
|
|
||||||
JsonSaveInt (root,"window.plot.ypos",session.window_plot_ypos);
|
|
||||||
JsonSaveInt (root,"window.plot.hsize",session.window_plot_hsize);
|
|
||||||
JsonSaveInt (root,"window.plot.wsize",session.window_plot_wsize);
|
|
||||||
// JsonSaveInt (root,"window.xpos",mySettings.window_xpos);
|
|
||||||
// JsonSaveInt (root,"window.ypos",mySettings.window_ypos);
|
|
||||||
// JsonSaveInt (root,"window.hsize",mySettings.window_hsize);
|
|
||||||
// JsonSaveInt (root,"window.wsize",mySettings.window_wsize);
|
|
||||||
|
|
||||||
// Emoji
|
|
||||||
switch (session.emoji_mode)
|
|
||||||
{
|
|
||||||
case ALIAS: JsonSaveStr (root,"show.emoji","alias"); break;
|
|
||||||
case EMOJI: JsonSaveStr (root,"show.emoji","emoji"); break;
|
|
||||||
case ALTTEXT: JsonSaveStr (root,"show.emoji","alttext"); break;
|
|
||||||
case ERASE: JsonSaveStr (root,"show.emoji","erase"); break;
|
|
||||||
default:
|
|
||||||
JsonSaveStr (root,"show.emoji","ALIAS");
|
|
||||||
}
|
|
||||||
JsonSaveBoolean (root,"show.hints",session.show_hints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void settings_load_callback (json_t *root)
|
|
||||||
{
|
|
||||||
json_error_t up_error = {0};
|
json_error_t up_error = {0};
|
||||||
bool b1;
|
int b1;
|
||||||
int i1;
|
int i1;
|
||||||
const char *s1;
|
const char *s1;
|
||||||
|
|
||||||
// Left for example of a string json read
|
if (json_unpack_ex(root, &up_error , 0, "{s:s}","version", &s1) == 0)
|
||||||
// if (json_unpack_ex(root, &up_error , 0, "{s:s}","version",&s1) == 0)
|
strncpy (mySettings.version,s1,sizeof (mySettings.version) - 1);
|
||||||
// strncpy (mySettings.version,s1,sizeof (mySettings.version) - 1);
|
else
|
||||||
/*
|
strncpy (mySettings.version,"unknown",sizeof (mySettings.version) - 1);
|
||||||
|
|
||||||
// os.windows...
|
// os.windows...
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:b}","os.windows.useColor",&b1) == 0)
|
if (json_unpack_ex(root,&up_error, 0, "{s:b}","os.windows.useColor",&b1) == 0)
|
||||||
mySettings.os_windows_usecolor = b1;
|
mySettings.os_windows_usecolor = b1;
|
||||||
|
else // default
|
||||||
|
mySettings.os_windows_useansicolor = false;
|
||||||
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:b}","os.windows.useAnsiColor",&b1) == 0)
|
if (json_unpack_ex(root,&up_error, 0, "{s:b}","os.windows.useAnsiColor",&b1) == 0)
|
||||||
mySettings.os_windows_useansicolor = b1;
|
mySettings.os_windows_useansicolor = b1;
|
||||||
*/
|
else // default
|
||||||
// Logging Level
|
mySettings.os_windows_useansicolor = false;
|
||||||
// typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE, HINT} logLevel_t;
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:s}","logging.level",&s1) == 0) {
|
|
||||||
if (strncasecmp (s1,"NORMAL",7) == 0) session.logging_level = NORMAL;
|
|
||||||
if (strncasecmp (s1,"SUCCESS",8) == 0) session.logging_level = SUCCESS;
|
|
||||||
if (strncasecmp (s1,"INFO",4) == 0) session.logging_level = INFO;
|
|
||||||
if (strncasecmp (s1,"FAILED",6) == 0) session.logging_level = FAILED;
|
|
||||||
if (strncasecmp (s1,"WARNING",7) == 0) session.logging_level = WARNING;
|
|
||||||
if (strncasecmp (s1,"ERR",3) == 0) session.logging_level = ERR;
|
|
||||||
if (strncasecmp (s1,"DEBUG",5) == 0) session.logging_level = DEBUG;
|
|
||||||
if (strncasecmp (s1,"INPLACE",7) == 0) session.logging_level = INPLACE;
|
|
||||||
if (strncasecmp (s1,"HINT",7) == 0) session.logging_level = HINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// window plot
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.xpos",&i1) == 0)
|
|
||||||
session.window_plot_xpos = i1;
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.ypos",&i1) == 0)
|
|
||||||
session.window_plot_ypos = i1;
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.hsize",&i1) == 0)
|
|
||||||
session.window_plot_hsize = i1;
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.wsize",&i1) == 0)
|
|
||||||
session.window_plot_wsize = i1;
|
|
||||||
/*
|
|
||||||
// window...
|
// window...
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.xpos",&i1) == 0)
|
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.xpos",&i1) == 0)
|
||||||
mySettings.window_xpos = i1;
|
mySettings.window_xpos = i1;
|
||||||
|
else // default
|
||||||
|
mySettings.window_xpos = 0;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.ypos",&i1) == 0)
|
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.ypos",&i1) == 0)
|
||||||
mySettings.window_ypos = i1;
|
mySettings.window_ypos = i1;
|
||||||
|
else // default
|
||||||
|
mySettings.window_ypos = 0;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.hsize",&i1) == 0)
|
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.hsize",&i1) == 0)
|
||||||
mySettings.window_hsize = i1;
|
mySettings.window_hsize = i1;
|
||||||
|
else // default
|
||||||
|
mySettings.window_hsize = 0;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.wsize",&i1) == 0)
|
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.wsize",&i1) == 0)
|
||||||
mySettings.window_wsize = i1;
|
mySettings.window_wsize = i1;
|
||||||
|
else // default
|
||||||
|
mySettings.window_wsize = 0;
|
||||||
|
|
||||||
*/
|
// Use EMOJIS
|
||||||
// show options
|
if (json_unpack_ex(root,&up_error, 0, "{s:b}","client.useEmojis",&b1) == 0)
|
||||||
// typedef enum emojiMode {ALIAS, EMOJI, ALTTEXT, ERASE} emojiMode_t;
|
mySettings.use_emojis = b1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","show.emoji",&s1) == 0) {
|
else // default
|
||||||
if (strncasecmp (s1,"ALIAS",5) == 0) session.emoji_mode = ALIAS;
|
mySettings.use_emojis = false;
|
||||||
if (strncasecmp (s1,"EMOJI",5) == 0) session.emoji_mode = EMOJI;
|
|
||||||
if (strncasecmp (s1,"ALTTEXT",7) == 0) session.emoji_mode = ALTTEXT;
|
// Use Hints
|
||||||
if (strncasecmp (s1,"ERASE",5) == 0) session.emoji_mode = ERASE;
|
if (json_unpack_ex(root,&up_error, 0, "{s:b}","client.useHints",&b1) == 0)
|
||||||
}
|
mySettings.use_hints = b1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:b}","show.hints",&b1) == 0)
|
else // default
|
||||||
session.show_hints = b1;
|
mySettings.use_hints = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,29 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Settings Functions
|
// Settings Functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#ifndef SETTINGS_H_
|
#ifndef settings_h
|
||||||
#define SETTINGS_H_
|
#define settings_h
|
||||||
|
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
|
|
||||||
#define settingsFilename "settings.json"
|
#define settingsFilename "settings.json"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool loaded;
|
||||||
|
char version[20];
|
||||||
|
bool os_windows_usecolor;
|
||||||
|
bool os_windows_useansicolor;
|
||||||
|
int window_xpos;
|
||||||
|
int window_ypos;
|
||||||
|
int window_hsize;
|
||||||
|
int window_wsize;
|
||||||
|
bool use_emojis;
|
||||||
|
bool use_hints;
|
||||||
|
} settings_t;
|
||||||
|
|
||||||
|
// Settings struct so as to be available to other modules by including settings.h
|
||||||
|
settings_t mySettings;
|
||||||
|
|
||||||
int settings_load (void);
|
int settings_load (void);
|
||||||
int settings_save (void);
|
int settings_save (void);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLA
|
||||||
typedef enum emojiMode {ALIAS, EMOJI, ALTTEXT, ERASE} emojiMode_t;
|
typedef enum emojiMode {ALIAS, EMOJI, ALTTEXT, ERASE} emojiMode_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool settings_loaded;
|
|
||||||
bool stdinOnTTY;
|
bool stdinOnTTY;
|
||||||
bool stdoutOnTTY;
|
bool stdoutOnTTY;
|
||||||
bool supports_colors;
|
bool supports_colors;
|
||||||
|
@ -29,12 +28,8 @@ typedef struct {
|
||||||
bool pm3_present;
|
bool pm3_present;
|
||||||
bool help_dump_mode;
|
bool help_dump_mode;
|
||||||
bool show_hints;
|
bool show_hints;
|
||||||
int window_plot_xpos;
|
|
||||||
int window_plot_ypos;
|
|
||||||
int window_plot_hsize;
|
|
||||||
int window_plot_wsize;
|
|
||||||
logLevel_t logging_level;
|
|
||||||
} session_arg_t;
|
} session_arg_t;
|
||||||
|
|
||||||
extern session_arg_t session;
|
extern session_arg_t session;
|
||||||
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue