mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-02 18:39:57 +08:00
rename global session
This commit is contained in:
parent
6a2f2b3979
commit
dd3b63ae32
20 changed files with 258 additions and 258 deletions
|
@ -208,7 +208,7 @@ int CmdHFTune(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
barMode_t style = session.bar_mode;
|
||||
barMode_t style = g_session.bar_mode;
|
||||
if (is_bar)
|
||||
style = STYLE_BAR;
|
||||
if (is_mix)
|
||||
|
|
|
@ -189,7 +189,7 @@ static int CmdHF14AList(const char *Cmd) {
|
|||
}
|
||||
|
||||
int hf14a_getconfig(hf14a_config *config) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
if (config == NULL)
|
||||
return PM3_EINVARG;
|
||||
|
@ -207,7 +207,7 @@ int hf14a_getconfig(hf14a_config *config) {
|
|||
}
|
||||
|
||||
int hf14a_setconfig(hf14a_config *config, bool verbose) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
clearCommandBuffer();
|
||||
if (config != NULL) {
|
||||
|
@ -247,7 +247,7 @@ static int hf_14a_config_example(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
static int CmdHf14AConfig(const char *Cmd) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14a config",
|
||||
|
|
|
@ -843,16 +843,16 @@ static int CmdConnect(const char *Cmd) {
|
|||
memcpy(port, g_conn.serial_port_name, sizeof(port));
|
||||
}
|
||||
|
||||
if (session.pm3_present) {
|
||||
CloseProxmark(session.current_device);
|
||||
if (g_session.pm3_present) {
|
||||
CloseProxmark(g_session.current_device);
|
||||
}
|
||||
|
||||
// 10 second timeout
|
||||
OpenProxmark(&session.current_device, port, false, 10, false, baudrate);
|
||||
OpenProxmark(&g_session.current_device, port, false, 10, false, baudrate);
|
||||
|
||||
if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
|
||||
if (g_session.pm3_present && (TestProxmark(g_session.current_device) != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark3\n");
|
||||
CloseProxmark(session.current_device);
|
||||
CloseProxmark(g_session.current_device);
|
||||
return PM3_ENOTTY;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -138,7 +138,7 @@ static int CmdLFTune(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
barMode_t style = session.bar_mode;
|
||||
barMode_t style = g_session.bar_mode;
|
||||
if (is_bar)
|
||||
style = STYLE_BAR;
|
||||
if (is_mix)
|
||||
|
@ -252,7 +252,7 @@ int CmdLFCommandRead(const char *Cmd) {
|
|||
bool cm = arg_get_lit(ctx, 8);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.pm3_present == false)
|
||||
if (g_session.pm3_present == false)
|
||||
return PM3_ENOTTY;
|
||||
|
||||
#define PAYLOAD_HEADER_SIZE (12 + (3 * LF_CMDREAD_MAX_EXTRA_SYMBOLS))
|
||||
|
@ -475,7 +475,7 @@ int lf_config_savereset(sample_config *config) {
|
|||
}
|
||||
|
||||
int lf_getconfig(sample_config *config) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
if (config == NULL)
|
||||
return PM3_EINVARG;
|
||||
|
@ -493,7 +493,7 @@ int lf_getconfig(sample_config *config) {
|
|||
}
|
||||
|
||||
int lf_config(sample_config *config) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
clearCommandBuffer();
|
||||
if (config != NULL)
|
||||
|
@ -548,7 +548,7 @@ int CmdLFConfig(const char *Cmd) {
|
|||
int16_t trigg = arg_get_int_def(ctx, 10, -1);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.pm3_present == false)
|
||||
if (g_session.pm3_present == false)
|
||||
return PM3_ENOTTY;
|
||||
|
||||
// if called with no params, just print the device config
|
||||
|
@ -629,7 +629,7 @@ int CmdLFConfig(const char *Cmd) {
|
|||
}
|
||||
|
||||
int lf_read(bool verbose, uint32_t samples) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
struct p {
|
||||
uint32_t samples : 31;
|
||||
|
@ -681,7 +681,7 @@ int CmdLFRead(const char *Cmd) {
|
|||
bool cm = arg_get_lit(ctx, 3);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.pm3_present == false)
|
||||
if (g_session.pm3_present == false)
|
||||
return PM3_ENOTTY;
|
||||
|
||||
if (cm) {
|
||||
|
@ -695,7 +695,7 @@ int CmdLFRead(const char *Cmd) {
|
|||
}
|
||||
|
||||
int lf_sniff(bool verbose, uint32_t samples) {
|
||||
if (!session.pm3_present) return PM3_ENOTTY;
|
||||
if (!g_session.pm3_present) return PM3_ENOTTY;
|
||||
|
||||
struct p {
|
||||
uint32_t samples : 31;
|
||||
|
@ -750,7 +750,7 @@ int CmdLFSniff(const char *Cmd) {
|
|||
bool cm = arg_get_lit(ctx, 3);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.pm3_present == false)
|
||||
if (g_session.pm3_present == false)
|
||||
return PM3_ENOTTY;
|
||||
|
||||
if (cm) {
|
||||
|
@ -842,7 +842,7 @@ int CmdLFSim(const char *Cmd) {
|
|||
uint16_t gap = arg_get_u32_def(ctx, 1, 0);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.pm3_present == false) {
|
||||
if (g_session.pm3_present == false) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: no proxmark present");
|
||||
return PM3_ENOTTY;
|
||||
}
|
||||
|
@ -1397,7 +1397,7 @@ int CmdLFfind(const char *Cmd) {
|
|||
bool search_unk = arg_get_lit(ctx, 3);
|
||||
CLIParserFree(ctx);
|
||||
int found = 0;
|
||||
bool is_online = (session.pm3_present && (use_gb == false));
|
||||
bool is_online = (g_session.pm3_present && (use_gb == false));
|
||||
if (is_online)
|
||||
lf_read(false, 30000);
|
||||
|
||||
|
|
|
@ -520,7 +520,7 @@ static int CmdAWIDBrute(const char *Cmd) {
|
|||
// main loop
|
||||
for (;;) {
|
||||
|
||||
if (!session.pm3_present) {
|
||||
if (!g_session.pm3_present) {
|
||||
PrintAndLogEx(WARNING, "Device offline\n");
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
|
|
|
@ -1390,7 +1390,7 @@ int CmdEM4x05Chk(const char *Cmd) {
|
|||
|
||||
for (uint32_t c = 0; c < keycount; ++c) {
|
||||
|
||||
if (!session.pm3_present) {
|
||||
if (!g_session.pm3_present) {
|
||||
PrintAndLogEx(WARNING, "device offline\n");
|
||||
free(keyBlock);
|
||||
return PM3_ENODATA;
|
||||
|
@ -1569,7 +1569,7 @@ int CmdEM4x05Unlock(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (session.pm3_present == false) {
|
||||
if (g_session.pm3_present == false) {
|
||||
PrintAndLogEx(WARNING, "device offline\n");
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
|
|
|
@ -556,7 +556,7 @@ static int CmdHIDBrute(const char *Cmd) {
|
|||
fin_hi = fin_low = false;
|
||||
do {
|
||||
|
||||
if (!session.pm3_present) {
|
||||
if (!g_session.pm3_present) {
|
||||
PrintAndLogEx(WARNING, "Device offline\n");
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
|
|
|
@ -775,7 +775,7 @@ static bool DecodeT5555TraceBlock(void) {
|
|||
|
||||
// sanity check. Don't use proxmark if it is offline and you didn't specify useGraphbuf
|
||||
static int SanityOfflineCheck(bool useGraphBuffer) {
|
||||
if (!useGraphBuffer && !session.pm3_present) {
|
||||
if (!useGraphBuffer && !g_session.pm3_present) {
|
||||
PrintAndLogEx(WARNING, "Your proxmark3 device is offline. Specify [1] to use graphbuffer data instead");
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
|
@ -3197,7 +3197,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
|||
|
||||
for (uint32_t c = 0; c < keycount && found == false; ++c) {
|
||||
|
||||
if (!session.pm3_present) {
|
||||
if (!g_session.pm3_present) {
|
||||
PrintAndLogEx(WARNING, "device offline\n");
|
||||
free(keyblock);
|
||||
return PM3_ENODATA;
|
||||
|
|
|
@ -229,12 +229,12 @@ static int CmdHints(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (turn_off) {
|
||||
session.show_hints = false;
|
||||
g_session.show_hints = false;
|
||||
} else if (turn_on) {
|
||||
session.show_hints = true;
|
||||
g_session.show_hints = true;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "Hints are %s", (session.show_hints) ? "ON" : "OFF");
|
||||
PrintAndLogEx(INFO, "Hints are %s", (g_session.show_hints) ? "ON" : "OFF");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ bool AlwaysAvailable(void) {
|
|||
}
|
||||
|
||||
bool IfPm3Present(void) {
|
||||
if (session.help_dump_mode)
|
||||
if (g_session.help_dump_mode)
|
||||
return false;
|
||||
return session.pm3_present;
|
||||
return g_session.pm3_present;
|
||||
}
|
||||
|
||||
bool IfPm3Rdv4Fw(void) {
|
||||
|
@ -195,8 +195,8 @@ void CmdsHelp(const command_t Commands[]) {
|
|||
|
||||
int CmdsParse(const command_t Commands[], const char *Cmd) {
|
||||
|
||||
if (session.client_exe_delay != 0) {
|
||||
msleep(session.client_exe_delay);
|
||||
if (g_session.client_exe_delay != 0) {
|
||||
msleep(g_session.client_exe_delay);
|
||||
}
|
||||
|
||||
// Help dump children
|
||||
|
|
|
@ -89,7 +89,7 @@ void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, v
|
|||
print_hex_break((uint8_t *)&c.d, sizeof(c.d), 32);
|
||||
#endif
|
||||
|
||||
if (!session.pm3_present) {
|
||||
if (!g_session.pm3_present) {
|
||||
PrintAndLogEx(WARNING, "Sending bytes to Proxmark3 failed." _YELLOW_("offline"));
|
||||
return;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
|||
PrintAndLogEx(INFO, "Sending %s", ng ? "NG" : "MIX");
|
||||
#endif
|
||||
|
||||
if (!session.pm3_present) {
|
||||
if (!g_session.pm3_present) {
|
||||
PrintAndLogEx(INFO, "Sending bytes to proxmark failed - offline");
|
||||
return;
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout,
|
|||
|
||||
pthread_create(&communication_thread, NULL, &uart_communication, &g_conn);
|
||||
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
session.pm3_present = true; // TODO support for multiple devices
|
||||
g_session.pm3_present = true; // TODO support for multiple devices
|
||||
|
||||
fflush(stdout);
|
||||
if (*dev == NULL) {
|
||||
|
@ -689,7 +689,7 @@ void CloseProxmark(pm3_device *dev) {
|
|||
memset(&communication_thread, 0, sizeof(pthread_t));
|
||||
#endif
|
||||
|
||||
session.pm3_present = false;
|
||||
g_session.pm3_present = false;
|
||||
}
|
||||
|
||||
// Gives a rough estimate of the communication delay based on channel & baudrate
|
||||
|
|
|
@ -237,14 +237,14 @@ bool create_path(const char *dirname) {
|
|||
bool setDefaultPath(savePaths_t pathIndex, const char *Path) {
|
||||
|
||||
if (pathIndex < spItemCount) {
|
||||
if ((Path == NULL) && (session.defaultPaths[pathIndex] != NULL)) {
|
||||
free(session.defaultPaths[pathIndex]);
|
||||
session.defaultPaths[pathIndex] = NULL;
|
||||
if ((Path == NULL) && (g_session.defaultPaths[pathIndex] != NULL)) {
|
||||
free(g_session.defaultPaths[pathIndex]);
|
||||
g_session.defaultPaths[pathIndex] = NULL;
|
||||
}
|
||||
|
||||
if (Path != NULL) {
|
||||
session.defaultPaths[pathIndex] = (char *)realloc(session.defaultPaths[pathIndex], strlen(Path) + 1);
|
||||
strcpy(session.defaultPaths[pathIndex], Path);
|
||||
g_session.defaultPaths[pathIndex] = (char *)realloc(g_session.defaultPaths[pathIndex], strlen(Path) + 1);
|
||||
strcpy(g_session.defaultPaths[pathIndex], Path);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ typedef enum {
|
|||
|
||||
int fileExists(const char *filename);
|
||||
//bool create_path(const char *dirname);
|
||||
bool setDefaultPath(savePaths_t pathIndex, const char *Path); // set a path in the path list session.defaultPaths
|
||||
bool setDefaultPath(savePaths_t pathIndex, const char *Path); // set a path in the path list g_session.defaultPaths
|
||||
|
||||
char *newfilenamemcopy(const char *preferredName, const char *suffix);
|
||||
|
||||
|
|
|
@ -374,11 +374,11 @@ static int enter_bootloader(char *serial_port_name) {
|
|||
PrintAndLogEx(SUCCESS, "Press and hold down button NOW if your bootloader requires it.");
|
||||
}
|
||||
msleep(100);
|
||||
CloseProxmark(session.current_device);
|
||||
CloseProxmark(g_session.current_device);
|
||||
// Let time to OS to make the port disappear
|
||||
msleep(1000);
|
||||
|
||||
if (OpenProxmark(&session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
if (OpenProxmark(&g_session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
PrintAndLogEx(NORMAL, _GREEN_(" found"));
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
|
@ -552,7 +552,7 @@ int flash_write(flash_file_t *ctx) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Writing segments for file: %s", ctx->filename);
|
||||
|
||||
bool filter_ansi = !session.supports_colors;
|
||||
bool filter_ansi = !g_session.supports_colors;
|
||||
|
||||
for (int i = 0; i < ctx->num_segs; i++) {
|
||||
flash_seg_t *seg = &ctx->segments[i];
|
||||
|
|
|
@ -15,24 +15,24 @@
|
|||
|
||||
pm3_device *pm3_open(char *port) {
|
||||
pm3_init();
|
||||
OpenProxmark(&session.current_device, port, false, 20, false, USART_BAUD_RATE);
|
||||
if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
|
||||
OpenProxmark(&g_session.current_device, port, false, 20, false, USART_BAUD_RATE);
|
||||
if (g_session.pm3_present && (TestProxmark(g_session.current_device) != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark\n");
|
||||
CloseProxmark(session.current_device);
|
||||
CloseProxmark(g_session.current_device);
|
||||
}
|
||||
|
||||
if ((port != NULL) && (!session.pm3_present))
|
||||
if ((port != NULL) && (!g_session.pm3_present))
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (!session.pm3_present)
|
||||
if (!g_session.pm3_present)
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode");
|
||||
// For now, there is no real device context:
|
||||
return session.current_device;
|
||||
return g_session.current_device;
|
||||
}
|
||||
|
||||
void pm3_close(pm3_device *dev) {
|
||||
// Clean up the port
|
||||
if (session.pm3_present) {
|
||||
if (g_session.pm3_present) {
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_QUIT_SESSION, NULL, 0);
|
||||
msleep(100); // Make sure command is sent before killing client
|
||||
|
@ -51,5 +51,5 @@ const char *pm3_name_get(pm3_device *dev) {
|
|||
}
|
||||
|
||||
pm3_device *pm3_get_current_dev(void) {
|
||||
return session.current_device;
|
||||
return g_session.current_device;
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
// Add the default value for the setting in the settings_load page below
|
||||
// Update the preferences_load_callback to load your setting into the stucture
|
||||
// Update the preferences_save_callback to ensure your setting gets saved when needed.
|
||||
// use the preference as needed : session.<preference name>
|
||||
// Can use (session.preferences_loaded) to check if json settings file was used
|
||||
// use the preference as needed : g_session.<preference name>
|
||||
// Can use (g_session.preferences_loaded) to check if json settings file was used
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "preferences.h"
|
||||
|
@ -40,21 +40,21 @@ static char *prefGetFilename(void) {
|
|||
int preferences_load(void) {
|
||||
|
||||
// Set all defaults
|
||||
session.client_debug_level = cdbOFF;
|
||||
// session.device_debug_level = ddbOFF;
|
||||
session.window_changed = false;
|
||||
session.plot.x = 10;
|
||||
session.plot.y = 30;
|
||||
session.plot.h = 400;
|
||||
session.plot.w = 800;
|
||||
session.overlay.x = session.plot.x;
|
||||
session.overlay.y = 60 + session.plot.y + session.plot.h;
|
||||
session.overlay.h = 200;
|
||||
session.overlay.w = session.plot.w;
|
||||
session.overlay_sliders = true;
|
||||
session.show_hints = true;
|
||||
g_session.client_debug_level = cdbOFF;
|
||||
// g_session.device_debug_level = ddbOFF;
|
||||
g_session.window_changed = false;
|
||||
g_session.plot.x = 10;
|
||||
g_session.plot.y = 30;
|
||||
g_session.plot.h = 400;
|
||||
g_session.plot.w = 800;
|
||||
g_session.overlay.x = g_session.plot.x;
|
||||
g_session.overlay.y = 60 + g_session.plot.y + g_session.plot.h;
|
||||
g_session.overlay.h = 200;
|
||||
g_session.overlay.w = g_session.plot.w;
|
||||
g_session.overlay_sliders = true;
|
||||
g_session.show_hints = true;
|
||||
|
||||
session.bar_mode = STYLE_VALUE;
|
||||
g_session.bar_mode = STYLE_VALUE;
|
||||
setDefaultPath(spDefault, "");
|
||||
setDefaultPath(spDump, "");
|
||||
setDefaultPath(spTrace, "");
|
||||
|
@ -77,7 +77,7 @@ int preferences_load(void) {
|
|||
else
|
||||
setDefaultPath(spTrace, ".");
|
||||
|
||||
if (session.incognito) {
|
||||
if (g_session.incognito) {
|
||||
PrintAndLogEx(INFO, "No preferences file will be loaded");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -91,11 +91,11 @@ int preferences_load(void) {
|
|||
char *fn = prefGetFilename();
|
||||
if (fileExists(fn)) {
|
||||
if (loadFileJSON(fn, &dummyData, sizeof(dummyData), &dummyDL, &preferences_load_callback) == PM3_SUCCESS) {
|
||||
session.preferences_loaded = true;
|
||||
g_session.preferences_loaded = true;
|
||||
}
|
||||
}
|
||||
free(fn);
|
||||
// Note, if session.settings_loaded == false then the settings_save
|
||||
// Note, if g_session.settings_loaded == false then the settings_save
|
||||
// will be called in main () to save settings as set in defaults and main() checks.
|
||||
|
||||
return PM3_SUCCESS;
|
||||
|
@ -104,7 +104,7 @@ int preferences_load(void) {
|
|||
// Save all settings from memory (struct) to file
|
||||
int preferences_save(void) {
|
||||
// Note sure if backup has value ?
|
||||
if (session.incognito) {
|
||||
if (g_session.incognito) {
|
||||
PrintAndLogEx(INFO, "No preferences file will be saved");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void preferences_save_callback(json_t *root) {
|
|||
JsonSaveStr(root, "FileType", "settings");
|
||||
|
||||
// Emoji
|
||||
switch (session.emoji_mode) {
|
||||
switch (g_session.emoji_mode) {
|
||||
case EMO_ALIAS:
|
||||
JsonSaveStr(root, "show.emoji", "alias");
|
||||
break;
|
||||
|
@ -173,29 +173,29 @@ void preferences_save_callback(json_t *root) {
|
|||
JsonSaveStr(root, "show.emoji", "ALIAS");
|
||||
}
|
||||
|
||||
JsonSaveBoolean(root, "show.hints", session.show_hints);
|
||||
JsonSaveBoolean(root, "show.hints", g_session.show_hints);
|
||||
|
||||
JsonSaveBoolean(root, "os.supports.colors", session.supports_colors);
|
||||
JsonSaveBoolean(root, "os.supports.colors", g_session.supports_colors);
|
||||
|
||||
JsonSaveStr(root, "file.default.savepath", session.defaultPaths[spDefault]);
|
||||
JsonSaveStr(root, "file.default.dumppath", session.defaultPaths[spDump]);
|
||||
JsonSaveStr(root, "file.default.tracepath", session.defaultPaths[spTrace]);
|
||||
JsonSaveStr(root, "file.default.savepath", g_session.defaultPaths[spDefault]);
|
||||
JsonSaveStr(root, "file.default.dumppath", g_session.defaultPaths[spDump]);
|
||||
JsonSaveStr(root, "file.default.tracepath", g_session.defaultPaths[spTrace]);
|
||||
|
||||
// Plot window
|
||||
JsonSaveInt(root, "window.plot.xpos", session.plot.x);
|
||||
JsonSaveInt(root, "window.plot.ypos", session.plot.y);
|
||||
JsonSaveInt(root, "window.plot.hsize", session.plot.h);
|
||||
JsonSaveInt(root, "window.plot.wsize", session.plot.w);
|
||||
JsonSaveInt(root, "window.plot.xpos", g_session.plot.x);
|
||||
JsonSaveInt(root, "window.plot.ypos", g_session.plot.y);
|
||||
JsonSaveInt(root, "window.plot.hsize", g_session.plot.h);
|
||||
JsonSaveInt(root, "window.plot.wsize", g_session.plot.w);
|
||||
|
||||
// Overlay/Slider window
|
||||
JsonSaveInt(root, "window.overlay.xpos", session.overlay.x);
|
||||
JsonSaveInt(root, "window.overlay.ypos", session.overlay.y);
|
||||
JsonSaveInt(root, "window.overlay.hsize", session.overlay.h);
|
||||
JsonSaveInt(root, "window.overlay.wsize", session.overlay.w);
|
||||
JsonSaveBoolean(root, "window.overlay.sliders", session.overlay_sliders);
|
||||
JsonSaveInt(root, "window.overlay.xpos", g_session.overlay.x);
|
||||
JsonSaveInt(root, "window.overlay.ypos", g_session.overlay.y);
|
||||
JsonSaveInt(root, "window.overlay.hsize", g_session.overlay.h);
|
||||
JsonSaveInt(root, "window.overlay.wsize", g_session.overlay.w);
|
||||
JsonSaveBoolean(root, "window.overlay.sliders", g_session.overlay_sliders);
|
||||
|
||||
// Log level, convert to text
|
||||
switch (session.client_debug_level) {
|
||||
switch (g_session.client_debug_level) {
|
||||
case cdbOFF:
|
||||
JsonSaveStr(root, "client.debug.level", "off");
|
||||
break;
|
||||
|
@ -209,7 +209,7 @@ void preferences_save_callback(json_t *root) {
|
|||
JsonSaveStr(root, "logging.level", "NORMAL");
|
||||
}
|
||||
|
||||
switch (session.bar_mode) {
|
||||
switch (g_session.bar_mode) {
|
||||
case STYLE_BAR:
|
||||
JsonSaveStr(root, "show.bar.mode", "bar");
|
||||
break;
|
||||
|
@ -223,7 +223,7 @@ void preferences_save_callback(json_t *root) {
|
|||
JsonSaveStr(root, "show.bar.mode", "value");
|
||||
}
|
||||
/*
|
||||
switch (session.device_debug_level) {
|
||||
switch (g_session.device_debug_level) {
|
||||
case ddbOFF:
|
||||
JsonSaveStr(root, "device.debug.level", "off");
|
||||
break;
|
||||
|
@ -243,7 +243,7 @@ void preferences_save_callback(json_t *root) {
|
|||
JsonSaveStr(root, "logging.level", "NORMAL");
|
||||
}
|
||||
*/
|
||||
JsonSaveInt(root, "client.exe.delay", session.client_exe_delay);
|
||||
JsonSaveInt(root, "client.exe.delay", g_session.client_exe_delay);
|
||||
|
||||
}
|
||||
void preferences_load_callback(json_t *root) {
|
||||
|
@ -257,9 +257,9 @@ void preferences_load_callback(json_t *root) {
|
|||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "client.debug.level", &s1) == 0) {
|
||||
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||
str_lower(tempStr);
|
||||
if (strncmp(tempStr, "off", 3) == 0) session.client_debug_level = cdbOFF;
|
||||
if (strncmp(tempStr, "simple", 6) == 0) session.client_debug_level = cdbSIMPLE;
|
||||
if (strncmp(tempStr, "full", 4) == 0) session.client_debug_level = cdbFULL;
|
||||
if (strncmp(tempStr, "off", 3) == 0) g_session.client_debug_level = cdbOFF;
|
||||
if (strncmp(tempStr, "simple", 6) == 0) g_session.client_debug_level = cdbSIMPLE;
|
||||
if (strncmp(tempStr, "full", 4) == 0) g_session.client_debug_level = cdbFULL;
|
||||
}
|
||||
|
||||
// default save path
|
||||
|
@ -276,49 +276,49 @@ void preferences_load_callback(json_t *root) {
|
|||
|
||||
// window plot
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0)
|
||||
session.plot.x = i1;
|
||||
g_session.plot.x = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.ypos", &i1) == 0)
|
||||
session.plot.y = i1;
|
||||
g_session.plot.y = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.hsize", &i1) == 0)
|
||||
session.plot.h = i1;
|
||||
g_session.plot.h = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.wsize", &i1) == 0)
|
||||
session.plot.w = i1;
|
||||
g_session.plot.w = i1;
|
||||
|
||||
// overlay/slider plot
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.xpos", &i1) == 0)
|
||||
session.overlay.x = i1;
|
||||
g_session.overlay.x = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.ypos", &i1) == 0)
|
||||
session.overlay.y = i1;
|
||||
g_session.overlay.y = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.hsize", &i1) == 0)
|
||||
session.overlay.h = i1;
|
||||
g_session.overlay.h = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.wsize", &i1) == 0)
|
||||
session.overlay.w = i1;
|
||||
g_session.overlay.w = i1;
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "window.overlay.sliders", &b1) == 0)
|
||||
session.overlay_sliders = (bool)b1;
|
||||
g_session.overlay_sliders = (bool)b1;
|
||||
|
||||
// show options
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.emoji", &s1) == 0) {
|
||||
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||
str_lower(tempStr);
|
||||
if (strncmp(tempStr, "alias", 5) == 0) session.emoji_mode = EMO_ALIAS;
|
||||
if (strncmp(tempStr, "emoji", 5) == 0) session.emoji_mode = EMO_EMOJI;
|
||||
if (strncmp(tempStr, "alttext", 7) == 0) session.emoji_mode = EMO_ALTTEXT;
|
||||
if (strncmp(tempStr, "none", 4) == 0) session.emoji_mode = EMO_NONE;
|
||||
if (strncmp(tempStr, "alias", 5) == 0) g_session.emoji_mode = EMO_ALIAS;
|
||||
if (strncmp(tempStr, "emoji", 5) == 0) g_session.emoji_mode = EMO_EMOJI;
|
||||
if (strncmp(tempStr, "alttext", 7) == 0) g_session.emoji_mode = EMO_ALTTEXT;
|
||||
if (strncmp(tempStr, "none", 4) == 0) g_session.emoji_mode = EMO_NONE;
|
||||
}
|
||||
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "show.hints", &b1) == 0)
|
||||
session.show_hints = (bool)b1;
|
||||
g_session.show_hints = (bool)b1;
|
||||
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0)
|
||||
session.supports_colors = (bool)b1;
|
||||
g_session.supports_colors = (bool)b1;
|
||||
|
||||
// bar mode
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.bar.mode", &s1) == 0) {
|
||||
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||
str_lower(tempStr);
|
||||
if (strncmp(tempStr, "bar", 5) == 0) session.bar_mode = STYLE_BAR;
|
||||
if (strncmp(tempStr, "mixed", 5) == 0) session.bar_mode = STYLE_MIXED;
|
||||
if (strncmp(tempStr, "value", 7) == 0) session.bar_mode = STYLE_VALUE;
|
||||
if (strncmp(tempStr, "bar", 5) == 0) g_session.bar_mode = STYLE_BAR;
|
||||
if (strncmp(tempStr, "mixed", 5) == 0) g_session.bar_mode = STYLE_MIXED;
|
||||
if (strncmp(tempStr, "value", 7) == 0) g_session.bar_mode = STYLE_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -326,16 +326,16 @@ void preferences_load_callback(json_t *root) {
|
|||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "device.debug.level", &s1) == 0) {
|
||||
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||
str_lower(tempStr);
|
||||
if (strncmp(tempStr, "off", 3) == 0) session.device_debug_level = ddbOFF;
|
||||
if (strncmp(tempStr, "error", 5) == 0) session.device_debug_level = ddbERROR;
|
||||
if (strncmp(tempStr, "info", 4) == 0) session.device_debug_level = ddbINFO;
|
||||
if (strncmp(tempStr, "debug", 5) == 0) session.device_debug_level = ddbDEBUG;
|
||||
if (strncmp(tempStr, "extended", 8) == 0) session.device_debug_level = ddbEXTENDED;
|
||||
if (strncmp(tempStr, "off", 3) == 0) g_session.device_debug_level = ddbOFF;
|
||||
if (strncmp(tempStr, "error", 5) == 0) g_session.device_debug_level = ddbERROR;
|
||||
if (strncmp(tempStr, "info", 4) == 0) g_session.device_debug_level = ddbINFO;
|
||||
if (strncmp(tempStr, "debug", 5) == 0) g_session.device_debug_level = ddbDEBUG;
|
||||
if (strncmp(tempStr, "extended", 8) == 0) g_session.device_debug_level = ddbEXTENDED;
|
||||
}
|
||||
*/
|
||||
// client command execution delay
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "client.exe.delay", &i1) == 0)
|
||||
session.client_exe_delay = i1;
|
||||
g_session.client_exe_delay = i1;
|
||||
}
|
||||
|
||||
// Help Functions
|
||||
|
@ -358,7 +358,7 @@ static const char *prefShowMsg(prefShowOpt_t Opt) {
|
|||
|
||||
static void showEmojiState(prefShowOpt_t opt) {
|
||||
|
||||
switch (session.emoji_mode) {
|
||||
switch (g_session.emoji_mode) {
|
||||
case EMO_ALIAS:
|
||||
PrintAndLogEx(INFO, " %s emoji.................. "_GREEN_("alias"), prefShowMsg(opt));
|
||||
break;
|
||||
|
@ -378,7 +378,7 @@ static void showEmojiState(prefShowOpt_t opt) {
|
|||
|
||||
static void showColorState(prefShowOpt_t opt) {
|
||||
|
||||
if (session.supports_colors)
|
||||
if (g_session.supports_colors)
|
||||
PrintAndLogEx(INFO, " %s color.................. "_GREEN_("ansi"), prefShowMsg(opt));
|
||||
else
|
||||
PrintAndLogEx(INFO, " %s color.................. "_WHITE_("off"), prefShowMsg(opt));
|
||||
|
@ -386,7 +386,7 @@ static void showColorState(prefShowOpt_t opt) {
|
|||
|
||||
static void showClientDebugState(prefShowOpt_t opt) {
|
||||
|
||||
switch (session.client_debug_level) {
|
||||
switch (g_session.client_debug_level) {
|
||||
case cdbOFF:
|
||||
PrintAndLogEx(INFO, " %s client debug........... "_WHITE_("off"), prefShowMsg(opt));
|
||||
break;
|
||||
|
@ -402,7 +402,7 @@ static void showClientDebugState(prefShowOpt_t opt) {
|
|||
}
|
||||
/*
|
||||
static void showDeviceDebugState(prefShowOpt_t opt) {
|
||||
switch (session.device_debug_level) {
|
||||
switch (g_session.device_debug_level) {
|
||||
case ddbOFF:
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_WHITE_("off"), prefShowMsg(opt));
|
||||
break;
|
||||
|
@ -443,7 +443,7 @@ static void showSavePathState(savePaths_t path_index, prefShowOpt_t opt) {
|
|||
}
|
||||
|
||||
if (path_index < spItemCount) {
|
||||
if ((session.defaultPaths[path_index] == NULL) || (strcmp(session.defaultPaths[path_index], "") == 0)) {
|
||||
if ((g_session.defaultPaths[path_index] == NULL) || (strcmp(g_session.defaultPaths[path_index], "") == 0)) {
|
||||
PrintAndLogEx(INFO, " %s %s "_WHITE_("not set"),
|
||||
prefShowMsg(opt),
|
||||
s
|
||||
|
@ -452,7 +452,7 @@ static void showSavePathState(savePaths_t path_index, prefShowOpt_t opt) {
|
|||
PrintAndLogEx(INFO, " %s %s "_GREEN_("%s"),
|
||||
prefShowMsg(opt),
|
||||
s,
|
||||
session.defaultPaths[path_index]
|
||||
g_session.defaultPaths[path_index]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -460,31 +460,31 @@ static void showSavePathState(savePaths_t path_index, prefShowOpt_t opt) {
|
|||
|
||||
static void showPlotPosState(void) {
|
||||
PrintAndLogEx(INFO, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.plot.x,
|
||||
session.plot.y,
|
||||
session.plot.h,
|
||||
session.plot.w
|
||||
g_session.plot.x,
|
||||
g_session.plot.y,
|
||||
g_session.plot.h,
|
||||
g_session.plot.w
|
||||
);
|
||||
}
|
||||
|
||||
static void showOverlayPosState(void) {
|
||||
PrintAndLogEx(INFO, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.overlay.x,
|
||||
session.overlay.y,
|
||||
session.overlay.h,
|
||||
session.overlay.w
|
||||
g_session.overlay.x,
|
||||
g_session.overlay.y,
|
||||
g_session.overlay.h,
|
||||
g_session.overlay.w
|
||||
);
|
||||
}
|
||||
|
||||
static void showHintsState(prefShowOpt_t opt) {
|
||||
if (session.show_hints)
|
||||
if (g_session.show_hints)
|
||||
PrintAndLogEx(INFO, " %s hints.................. "_GREEN_("on"), prefShowMsg(opt));
|
||||
else
|
||||
PrintAndLogEx(INFO, " %s hints.................. "_WHITE_("off"), prefShowMsg(opt));
|
||||
}
|
||||
|
||||
static void showPlotSliderState(prefShowOpt_t opt) {
|
||||
if (session.overlay_sliders)
|
||||
if (g_session.overlay_sliders)
|
||||
PrintAndLogEx(INFO, " %s show plot sliders...... "_GREEN_("on"), prefShowMsg(opt));
|
||||
else
|
||||
PrintAndLogEx(INFO, " %s show plot sliders...... "_WHITE_("off"), prefShowMsg(opt));
|
||||
|
@ -492,7 +492,7 @@ static void showPlotSliderState(prefShowOpt_t opt) {
|
|||
|
||||
static void showBarModeState(prefShowOpt_t opt) {
|
||||
|
||||
switch (session.bar_mode) {
|
||||
switch (g_session.bar_mode) {
|
||||
case STYLE_BAR:
|
||||
PrintAndLogEx(INFO, " %s barmode................ "_GREEN_("bar"), prefShowMsg(opt));
|
||||
break;
|
||||
|
@ -508,7 +508,7 @@ static void showBarModeState(prefShowOpt_t opt) {
|
|||
}
|
||||
|
||||
static void showClientExeDelayState(void) {
|
||||
PrintAndLogEx(INFO, " Cmd execution delay.... "_GREEN_("%u"), session.client_exe_delay);
|
||||
PrintAndLogEx(INFO, " Cmd execution delay.... "_GREEN_("%u"), g_session.client_exe_delay);
|
||||
}
|
||||
|
||||
|
||||
|
@ -539,7 +539,7 @@ static int setCmdEmoji(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
emojiMode_t new_value = session.emoji_mode;
|
||||
emojiMode_t new_value = g_session.emoji_mode;
|
||||
|
||||
if (show_a) {
|
||||
new_value = EMO_ALIAS;
|
||||
|
@ -554,9 +554,9 @@ static int setCmdEmoji(const char *Cmd) {
|
|||
new_value = EMO_NONE;
|
||||
}
|
||||
|
||||
if (session.emoji_mode != new_value) {// changed
|
||||
if (g_session.emoji_mode != new_value) {// changed
|
||||
showEmojiState(prefShowOLD);
|
||||
session.emoji_mode = new_value;
|
||||
g_session.emoji_mode = new_value;
|
||||
showEmojiState(prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -589,7 +589,7 @@ static int setCmdColor(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
bool new_value = session.supports_colors;
|
||||
bool new_value = g_session.supports_colors;
|
||||
if (use_c) {
|
||||
new_value = true;
|
||||
}
|
||||
|
@ -598,9 +598,9 @@ static int setCmdColor(const char *Cmd) {
|
|||
new_value = false;
|
||||
}
|
||||
|
||||
if (session.supports_colors != new_value) {
|
||||
if (g_session.supports_colors != new_value) {
|
||||
showColorState(prefShowOLD);
|
||||
session.supports_colors = new_value;
|
||||
g_session.supports_colors = new_value;
|
||||
showColorState(prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -635,7 +635,7 @@ static int setCmdDebug(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
clientdebugLevel_t new_value = session.client_debug_level;
|
||||
clientdebugLevel_t new_value = g_session.client_debug_level;
|
||||
|
||||
if (use_off) {
|
||||
new_value = cdbOFF;
|
||||
|
@ -647,9 +647,9 @@ static int setCmdDebug(const char *Cmd) {
|
|||
new_value = cdbFULL;
|
||||
}
|
||||
|
||||
if (session.client_debug_level != new_value) {
|
||||
if (g_session.client_debug_level != new_value) {
|
||||
showClientDebugState(prefShowOLD);
|
||||
session.client_debug_level = new_value;
|
||||
g_session.client_debug_level = new_value;
|
||||
g_debugMode = new_value;
|
||||
showClientDebugState(prefShowNEW);
|
||||
preferences_save();
|
||||
|
@ -690,7 +690,7 @@ static int setCmdDeviceDebug (const char *Cmd)
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
devicedebugLevel_t new_value = session.device_debug_level;
|
||||
devicedebugLevel_t new_value = g_session.device_debug_level;
|
||||
|
||||
if (use_off) {
|
||||
new_value = ddbOFF;
|
||||
|
@ -708,18 +708,18 @@ static int setCmdDeviceDebug (const char *Cmd)
|
|||
new_value = ddbEXTENDED;
|
||||
}
|
||||
|
||||
if (session.device_debug_level != new_value) {// changed
|
||||
if (g_session.device_debug_level != new_value) {// changed
|
||||
showDeviceDebugState (prefShowOLD);
|
||||
session.device_debug_level = new_value;
|
||||
g_session.device_debug_level = new_value;
|
||||
showDeviceDebugState (prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
showDeviceDebugState (prefShowNone);
|
||||
}
|
||||
|
||||
if (session.pm3_present) {
|
||||
if (g_session.pm3_present) {
|
||||
PrintAndLogEx (INFO,"setting device debug loglevel");
|
||||
SendCommandNG(CMD_SET_DBGMODE, &session.device_debug_level, 1);
|
||||
SendCommandNG(CMD_SET_DBGMODE, &g_session.device_debug_level, 1);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_SET_DBGMODE, &resp, 2000) == false)
|
||||
PrintAndLogEx (WARNING,"failed to set device debug loglevel");
|
||||
|
@ -746,9 +746,9 @@ static int setCmdExeDelay(const char *Cmd) {
|
|||
uint16_t new_value = (uint16_t)arg_get_int_def(ctx, 1, 0);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.client_exe_delay != new_value) {
|
||||
if (g_session.client_exe_delay != new_value) {
|
||||
showClientExeDelayState();
|
||||
session.client_exe_delay = new_value;
|
||||
g_session.client_exe_delay = new_value;
|
||||
showClientExeDelayState();
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -780,7 +780,7 @@ static int setCmdHint(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
bool new_value = session.show_hints;
|
||||
bool new_value = g_session.show_hints;
|
||||
if (use_off) {
|
||||
new_value = false;
|
||||
}
|
||||
|
@ -788,9 +788,9 @@ static int setCmdHint(const char *Cmd) {
|
|||
new_value = true;
|
||||
}
|
||||
|
||||
if (session.show_hints != new_value) {
|
||||
if (g_session.show_hints != new_value) {
|
||||
showHintsState(prefShowOLD);
|
||||
session.show_hints = new_value;
|
||||
g_session.show_hints = new_value;
|
||||
showHintsState(prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -823,7 +823,7 @@ static int setCmdPlotSliders(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
bool new_value = session.overlay_sliders;
|
||||
bool new_value = g_session.overlay_sliders;
|
||||
if (use_off) {
|
||||
new_value = false;
|
||||
}
|
||||
|
@ -831,9 +831,9 @@ static int setCmdPlotSliders(const char *Cmd) {
|
|||
new_value = true;
|
||||
}
|
||||
|
||||
if (session.overlay_sliders != new_value) {
|
||||
if (g_session.overlay_sliders != new_value) {
|
||||
showPlotSliderState(prefShowOLD);
|
||||
session.overlay_sliders = new_value;
|
||||
g_session.overlay_sliders = new_value;
|
||||
showPlotSliderState(prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -910,7 +910,7 @@ static int setCmdSavePaths(const char *Cmd) {
|
|||
// create_path (newValue); //mkdir (newValue,0x777);
|
||||
|
||||
if (path_item < spItemCount) {
|
||||
if (strcmp(path, session.defaultPaths[path_item]) != 0) {
|
||||
if (strcmp(path, g_session.defaultPaths[path_item]) != 0) {
|
||||
showSavePathState(path_item, prefShowOLD);
|
||||
setDefaultPath(path_item, path);
|
||||
showSavePathState(path_item, prefShowNEW);
|
||||
|
@ -948,7 +948,7 @@ static int setCmdBarMode(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
barMode_t new_value = session.bar_mode;
|
||||
barMode_t new_value = g_session.bar_mode;
|
||||
if (show_bar) {
|
||||
new_value = STYLE_BAR;
|
||||
}
|
||||
|
@ -959,9 +959,9 @@ static int setCmdBarMode(const char *Cmd) {
|
|||
new_value = STYLE_VALUE;
|
||||
}
|
||||
|
||||
if (session.bar_mode != new_value) {
|
||||
if (g_session.bar_mode != new_value) {
|
||||
showBarModeState(prefShowOLD);
|
||||
session.bar_mode = new_value;
|
||||
g_session.bar_mode = new_value;
|
||||
showBarModeState(prefShowNEW);
|
||||
preferences_save();
|
||||
} else {
|
||||
|
@ -1156,7 +1156,7 @@ static int CmdPrefShow(const char *Cmd) {
|
|||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (session.preferences_loaded) {
|
||||
if (g_session.preferences_loaded) {
|
||||
char *fn = prefGetFilename();
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "Using "_YELLOW_("%s"), fn);
|
||||
|
|
|
@ -192,7 +192,7 @@ void ProxGuiQT::MainLoop() {
|
|||
// pictureWidget->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
|
||||
// Set picture widget position if no settings.
|
||||
if (session.preferences_loaded == false) {
|
||||
if (g_session.preferences_loaded == false) {
|
||||
// Move controller widget below plot
|
||||
//pictureController->move(x(), y() + frameSize().height());
|
||||
//pictureController->resize(size().width(), 200);
|
||||
|
@ -250,8 +250,8 @@ ProxGuiQT::~ProxGuiQT(void) {
|
|||
// -------------------------------------------------
|
||||
PictureWidget::PictureWidget() {
|
||||
// Set the initail postion and size from settings
|
||||
// if (session.preferences_loaded)
|
||||
// setGeometry(session.pw.x, session.pw.y, session.pw.w, session.pw.h);
|
||||
// if (g_session.preferences_loaded)
|
||||
// setGeometry(g_session.pw.x, g_session.pw.y, g_session.pw.w, g_session.pw.h);
|
||||
// else
|
||||
resize(400, 400);
|
||||
}
|
||||
|
@ -269,23 +269,23 @@ void PictureWidget::closeEvent(QCloseEvent *event) {
|
|||
|
||||
SliderWidget::SliderWidget() {
|
||||
// Set the initail postion and size from settings
|
||||
if (session.preferences_loaded)
|
||||
setGeometry(session.overlay.x, session.overlay.y, session.overlay.w, session.overlay.h);
|
||||
if (g_session.preferences_loaded)
|
||||
setGeometry(g_session.overlay.x, g_session.overlay.y, g_session.overlay.w, g_session.overlay.h);
|
||||
else
|
||||
resize(800, 400);
|
||||
}
|
||||
|
||||
void SliderWidget::resizeEvent(QResizeEvent *event) {
|
||||
session.overlay.h = event->size().height();
|
||||
session.overlay.w = event->size().width();
|
||||
session.window_changed = true;
|
||||
g_session.overlay.h = event->size().height();
|
||||
g_session.overlay.w = event->size().width();
|
||||
g_session.window_changed = true;
|
||||
|
||||
}
|
||||
|
||||
void SliderWidget::moveEvent(QMoveEvent *event) {
|
||||
session.overlay.x = event->pos().x();
|
||||
session.overlay.y = event->pos().y();
|
||||
session.window_changed = true;
|
||||
g_session.overlay.x = event->pos().x();
|
||||
g_session.overlay.y = event->pos().y();
|
||||
g_session.window_changed = true;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
|
@ -331,8 +331,8 @@ void ProxWidget::vchange_dthr_down(int v) {
|
|||
ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
||||
this->master = master;
|
||||
// Set the initail postion and size from settings
|
||||
if (session.preferences_loaded)
|
||||
setGeometry(session.plot.x, session.plot.y, session.plot.w, session.plot.h);
|
||||
if (g_session.preferences_loaded)
|
||||
setGeometry(g_session.plot.x, g_session.plot.y, g_session.plot.w, g_session.plot.h);
|
||||
else
|
||||
resize(800, 400);
|
||||
|
||||
|
@ -357,7 +357,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int)));
|
||||
QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int)));
|
||||
|
||||
controlWidget->setGeometry(session.overlay.x, session.overlay.y, session.overlay.w, session.overlay.h);
|
||||
controlWidget->setGeometry(g_session.overlay.x, g_session.overlay.y, g_session.overlay.w, g_session.overlay.h);
|
||||
|
||||
// Set up the plot widget, which does the actual plotting
|
||||
plot = new Plot(this);
|
||||
|
@ -373,7 +373,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
show();
|
||||
|
||||
// Set Slider/Overlay position if no settings.
|
||||
if (session.preferences_loaded == false) {
|
||||
if (g_session.preferences_loaded == false) {
|
||||
// Move controller widget below plot
|
||||
controlWidget->move(x(), y() + frameSize().height());
|
||||
controlWidget->resize(size().width(), 200);
|
||||
|
@ -387,7 +387,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
// controlWidget->show();
|
||||
|
||||
// now that is up, reset pos/size change flags
|
||||
session.window_changed = false;
|
||||
g_session.window_changed = false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -422,7 +422,7 @@ void ProxWidget::hideEvent(QHideEvent *event) {
|
|||
plot->hide();
|
||||
}
|
||||
void ProxWidget::showEvent(QShowEvent *event) {
|
||||
if (session.overlay_sliders)
|
||||
if (g_session.overlay_sliders)
|
||||
controlWidget->show();
|
||||
else
|
||||
controlWidget->hide();
|
||||
|
@ -430,14 +430,14 @@ void ProxWidget::showEvent(QShowEvent *event) {
|
|||
plot->show();
|
||||
}
|
||||
void ProxWidget::moveEvent(QMoveEvent *event) {
|
||||
session.plot.x = event->pos().x();
|
||||
session.plot.y = event->pos().y();
|
||||
session.window_changed = true;
|
||||
g_session.plot.x = event->pos().x();
|
||||
g_session.plot.y = event->pos().y();
|
||||
g_session.window_changed = true;
|
||||
}
|
||||
void ProxWidget::resizeEvent(QResizeEvent *event) {
|
||||
session.plot.h = event->size().height();
|
||||
session.plot.w = event->size().width();
|
||||
session.window_changed = true;
|
||||
g_session.plot.h = event->size().height();
|
||||
g_session.plot.w = event->size().width();
|
||||
g_session.window_changed = true;
|
||||
}
|
||||
|
||||
//----------- Plotting
|
||||
|
|
|
@ -126,27 +126,27 @@ static void prompt_compose(char *buf, size_t buflen, const char *promptctx, cons
|
|||
|
||||
static int check_comm(void) {
|
||||
// If communications thread goes down. Device disconnected then this should hook up PM3 again.
|
||||
if (IsCommunicationThreadDead() && session.pm3_present) {
|
||||
if (IsCommunicationThreadDead() && g_session.pm3_present) {
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n");
|
||||
prompt_dev = PROXPROMPT_DEV_OFFLINE;
|
||||
#ifdef HAVE_READLINE
|
||||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !session.supports_colors);
|
||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
|
||||
rl_set_prompt(prompt_filtered);
|
||||
rl_redisplay();
|
||||
#endif
|
||||
CloseProxmark(session.current_device);
|
||||
CloseProxmark(g_session.current_device);
|
||||
}
|
||||
msleep(10);
|
||||
return 0;
|
||||
}
|
||||
#ifdef HAVE_READLINE
|
||||
static void flush_history(void) {
|
||||
if (session.history_path) {
|
||||
write_history(session.history_path);
|
||||
free(session.history_path);
|
||||
if (g_session.history_path) {
|
||||
write_history(g_session.history_path);
|
||||
free(g_session.history_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ static bool DetectWindowsAnsiSupport(void) {
|
|||
#endif
|
||||
|
||||
// disable colors if stdin or stdout are redirected
|
||||
if ((! session.stdinOnTTY) || (! session.stdoutOnTTY))
|
||||
if ((! g_session.stdinOnTTY) || (! g_session.stdoutOnTTY))
|
||||
return false;
|
||||
|
||||
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -250,7 +250,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
|||
bool stdinOnPipe = !isatty(STDIN_FILENO);
|
||||
char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest
|
||||
|
||||
if (session.pm3_present) {
|
||||
if (g_session.pm3_present) {
|
||||
// cache Version information now:
|
||||
if (execCommand || script_cmds_file || stdinOnPipe)
|
||||
pm3_version(false, false);
|
||||
|
@ -272,13 +272,13 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
|||
}
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
session.history_path = NULL;
|
||||
if (session.incognito) {
|
||||
g_session.history_path = NULL;
|
||||
if (g_session.incognito) {
|
||||
PrintAndLogEx(INFO, "No history will be recorded");
|
||||
} else {
|
||||
if (searchHomeFilePath(&session.history_path, NULL, PROXHISTORY, true) != PM3_SUCCESS) {
|
||||
if (searchHomeFilePath(&g_session.history_path, NULL, PROXHISTORY, true) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "No history will be recorded");
|
||||
session.history_path = NULL;
|
||||
g_session.history_path = NULL;
|
||||
} else {
|
||||
|
||||
# if defined(_WIN32)
|
||||
|
@ -291,7 +291,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
|||
# endif
|
||||
rl_catch_signals = 1;
|
||||
rl_set_signals();
|
||||
read_history(session.history_path);
|
||||
read_history(g_session.history_path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -300,7 +300,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
|||
while (1) {
|
||||
|
||||
bool printprompt = false;
|
||||
if (session.pm3_present) {
|
||||
if (g_session.pm3_present) {
|
||||
if (g_conn.send_via_fpc_usart == false)
|
||||
prompt_dev = PROXPROMPT_DEV_USB;
|
||||
else
|
||||
|
@ -380,13 +380,13 @@ check_script:
|
|||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !session.supports_colors);
|
||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !g_session.supports_colors);
|
||||
g_pendingPrompt = true;
|
||||
#ifdef HAVE_READLINE
|
||||
script_cmd = readline(prompt_filtered);
|
||||
#if defined(_WIN32)
|
||||
//Check if color support needs to be enabled again in case the window buffer did change
|
||||
session.supports_colors = DetectWindowsAnsiSupport();
|
||||
g_session.supports_colors = DetectWindowsAnsiSupport();
|
||||
#endif
|
||||
if (script_cmd != NULL) {
|
||||
execCommand = true;
|
||||
|
@ -475,7 +475,7 @@ check_script:
|
|||
}
|
||||
} // end while
|
||||
|
||||
if (session.pm3_present) {
|
||||
if (g_session.pm3_present) {
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_QUIT_SESSION, NULL, 0);
|
||||
msleep(100); // Make sure command is sent before killing client
|
||||
|
@ -496,14 +496,14 @@ check_script:
|
|||
|
||||
#ifndef LIBPM3
|
||||
static void dumpAllHelp(int markdown, bool full_help) {
|
||||
session.help_dump_mode = true;
|
||||
g_session.help_dump_mode = true;
|
||||
PrintAndLogEx(NORMAL, "\n%sProxmark3 command dump%s\n\n", markdown ? "# " : "", markdown ? "" : "\n======================");
|
||||
PrintAndLogEx(NORMAL, "Some commands are available only if a Proxmark3 is actually connected.%s\n", markdown ? " " : "");
|
||||
PrintAndLogEx(NORMAL, "Check column \"offline\" for their availability.\n");
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
command_t *cmds = getTopLevelCommandTable();
|
||||
dumpCommandsRecursive(cmds, markdown, full_help);
|
||||
session.help_dump_mode = false;
|
||||
g_session.help_dump_mode = false;
|
||||
PrintAndLogEx(NORMAL, "Full help dump done.");
|
||||
}
|
||||
#endif //LIBPM3
|
||||
|
@ -678,7 +678,7 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[
|
|||
PrintAndLogEx(SUCCESS, " "_YELLOW_("%s"), filepaths[i]);
|
||||
}
|
||||
|
||||
if (OpenProxmark(&session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
if (OpenProxmark(&g_session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
PrintAndLogEx(NORMAL, _GREEN_(" found"));
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Could not find Proxmark3 on " _RED_("%s") ".\n", serial_port_name);
|
||||
|
@ -718,7 +718,7 @@ finish:
|
|||
if (ret != PM3_SUCCESS)
|
||||
PrintAndLogEx(INFO, "The flashing procedure failed, follow the suggested steps!");
|
||||
ret = flash_stop_flashing();
|
||||
CloseProxmark(session.current_device);
|
||||
CloseProxmark(g_session.current_device);
|
||||
finish2:
|
||||
for (int i = 0 ; i < num_files; ++i) {
|
||||
if (filepaths[i] != NULL)
|
||||
|
@ -736,13 +736,13 @@ finish2:
|
|||
void pm3_init(void) {
|
||||
srand(time(0));
|
||||
|
||||
session.pm3_present = false;
|
||||
session.help_dump_mode = false;
|
||||
session.incognito = false;
|
||||
session.supports_colors = false;
|
||||
session.emoji_mode = EMO_ALTTEXT;
|
||||
session.stdinOnTTY = false;
|
||||
session.stdoutOnTTY = false;
|
||||
g_session.pm3_present = false;
|
||||
g_session.help_dump_mode = false;
|
||||
g_session.incognito = false;
|
||||
g_session.supports_colors = false;
|
||||
g_session.emoji_mode = EMO_ALTTEXT;
|
||||
g_session.stdinOnTTY = false;
|
||||
g_session.stdoutOnTTY = false;
|
||||
|
||||
// set global variables soon enough to get the log path
|
||||
set_my_executable_path();
|
||||
|
@ -788,17 +788,17 @@ int main(int argc, char *argv[]) {
|
|||
// For info, grep --color=auto is doing sth like this, plus test getenv("TERM") != "dumb":
|
||||
// struct stat tmp_stat;
|
||||
// if ((fstat (STDOUT_FILENO, &tmp_stat) == 0) && (S_ISCHR (tmp_stat.st_mode)) && isatty(STDIN_FILENO))
|
||||
session.stdinOnTTY = isatty(STDIN_FILENO);
|
||||
session.stdoutOnTTY = isatty(STDOUT_FILENO);
|
||||
session.supports_colors = false;
|
||||
session.emoji_mode = EMO_ALTTEXT;
|
||||
if (session.stdinOnTTY && session.stdoutOnTTY) {
|
||||
g_session.stdinOnTTY = isatty(STDIN_FILENO);
|
||||
g_session.stdoutOnTTY = isatty(STDOUT_FILENO);
|
||||
g_session.supports_colors = false;
|
||||
g_session.emoji_mode = EMO_ALTTEXT;
|
||||
if (g_session.stdinOnTTY && g_session.stdoutOnTTY) {
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
session.supports_colors = true;
|
||||
session.emoji_mode = EMO_EMOJI;
|
||||
g_session.supports_colors = true;
|
||||
g_session.emoji_mode = EMO_EMOJI;
|
||||
#elif defined(_WIN32)
|
||||
session.supports_colors = DetectWindowsAnsiSupport();
|
||||
session.emoji_mode = EMO_ALTTEXT;
|
||||
g_session.supports_colors = DetectWindowsAnsiSupport();
|
||||
g_session.emoji_mode = EMO_ALTTEXT;
|
||||
#endif
|
||||
}
|
||||
for (int i = 1; i < argc; i++) {
|
||||
|
@ -960,7 +960,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// do not use history nor log files
|
||||
if (strcmp(argv[i], "--incognito") == 0) {
|
||||
session.incognito = true;
|
||||
g_session.incognito = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1002,14 +1002,14 @@ int main(int argc, char *argv[]) {
|
|||
preferences_load();
|
||||
// quick patch for debug level
|
||||
if (! debug_mode_forced)
|
||||
g_debugMode = session.client_debug_level;
|
||||
g_debugMode = g_session.client_debug_level;
|
||||
// settings_save ();
|
||||
// End Settings
|
||||
|
||||
// even if prefs, we disable colors if stdin or stdout is not a TTY
|
||||
if ((! session.stdinOnTTY) || (! session.stdoutOnTTY)) {
|
||||
session.supports_colors = false;
|
||||
session.emoji_mode = EMO_ALTTEXT;
|
||||
if ((! g_session.stdinOnTTY) || (! g_session.stdoutOnTTY)) {
|
||||
g_session.supports_colors = false;
|
||||
g_session.emoji_mode = EMO_ALTTEXT;
|
||||
}
|
||||
|
||||
// Let's take a baudrate ok for real UART, USB-CDC & BT don't use that info anyway
|
||||
|
@ -1048,36 +1048,36 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// try to open USB connection to Proxmark
|
||||
if (port != NULL) {
|
||||
OpenProxmark(&session.current_device, port, waitCOMPort, 20, false, speed);
|
||||
OpenProxmark(&g_session.current_device, port, waitCOMPort, 20, false, speed);
|
||||
}
|
||||
|
||||
if (session.pm3_present && (TestProxmark(session.current_device) != PM3_SUCCESS)) {
|
||||
if (g_session.pm3_present && (TestProxmark(g_session.current_device) != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") " cannot communicate with the Proxmark\n");
|
||||
CloseProxmark(session.current_device);
|
||||
CloseProxmark(g_session.current_device);
|
||||
}
|
||||
|
||||
if ((port != NULL) && (!session.pm3_present))
|
||||
if ((port != NULL) && (!g_session.pm3_present))
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (!session.pm3_present)
|
||||
if (!g_session.pm3_present)
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Check " _YELLOW_("\"%s -h\"") " if it's not what you want.\n", exec_name);
|
||||
|
||||
// ascii art only in interactive client
|
||||
if (!script_cmds_file && !script_cmd && session.stdinOnTTY && session.stdoutOnTTY && !flash_mode)
|
||||
if (!script_cmds_file && !script_cmd && g_session.stdinOnTTY && g_session.stdoutOnTTY && !flash_mode)
|
||||
showBanner();
|
||||
|
||||
// Save settings if not loaded from settings json file.
|
||||
// Doing this here will ensure other checks and updates are saved to over rule default
|
||||
// e.g. Linux color use check
|
||||
if ((!session.preferences_loaded) && (!session.incognito)) {
|
||||
if ((!g_session.preferences_loaded) && (!g_session.incognito)) {
|
||||
PrintAndLogEx(INFO, "Creating initial preferences file"); // json save reports file name, so just info msg here
|
||||
preferences_save(); // Save defaults
|
||||
session.preferences_loaded = true;
|
||||
g_session.preferences_loaded = true;
|
||||
} /* else {
|
||||
// Set device debug level
|
||||
PrintAndLogEx(INFO,"setting device debug loglevel");
|
||||
if (session.pm3_present) {
|
||||
SendCommandNG(CMD_SET_DBGMODE, &session.device_debug_level, 1);
|
||||
if (g_session.pm3_present) {
|
||||
SendCommandNG(CMD_SET_DBGMODE, &g_session.device_debug_level, 1);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_SET_DBGMODE, &resp, 2000) == false)
|
||||
PrintAndLogEx (INFO,"failed to set device debug loglevel");
|
||||
|
@ -1108,11 +1108,11 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
|
||||
// Clean up the port
|
||||
if (session.pm3_present) {
|
||||
CloseProxmark(session.current_device);
|
||||
if (g_session.pm3_present) {
|
||||
CloseProxmark(g_session.current_device);
|
||||
}
|
||||
|
||||
if (session.window_changed) // Plot/Overlay moved or resized
|
||||
if (g_session.window_changed) // Plot/Overlay moved or resized
|
||||
preferences_save();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <time.h>
|
||||
#include "emojis.h"
|
||||
#include "emojis_alt.h"
|
||||
session_arg_t session;
|
||||
session_arg_t g_session;
|
||||
|
||||
double g_CursorScaleFactor = 1;
|
||||
char g_CursorScaleFactorUnit[11] = {0};
|
||||
|
@ -187,7 +187,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
|||
return;
|
||||
|
||||
// skip HINT messages if client has hints turned off i.e. 'HINT 0'
|
||||
if (session.show_hints == false && level == HINT)
|
||||
if (g_session.show_hints == false && level == HINT)
|
||||
return;
|
||||
|
||||
char prefix[40] = {0};
|
||||
|
@ -202,14 +202,14 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
|||
};
|
||||
switch (level) {
|
||||
case ERR:
|
||||
if (session.emoji_mode == EMO_EMOJI)
|
||||
if (g_session.emoji_mode == EMO_EMOJI)
|
||||
strncpy(prefix, "[" _RED_("!!") "] :rotating_light: ", sizeof(prefix) - 1);
|
||||
else
|
||||
strncpy(prefix, "[" _RED_("!!") "] ", sizeof(prefix) - 1);
|
||||
stream = stderr;
|
||||
break;
|
||||
case FAILED:
|
||||
if (session.emoji_mode == EMO_EMOJI)
|
||||
if (g_session.emoji_mode == EMO_EMOJI)
|
||||
strncpy(prefix, "[" _RED_("-") "] :no_entry: ", sizeof(prefix) - 1);
|
||||
else
|
||||
strncpy(prefix, "[" _RED_("-") "] ", sizeof(prefix) - 1);
|
||||
|
@ -224,7 +224,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
|||
strncpy(prefix, "[" _GREEN_("+") "] ", sizeof(prefix) - 1);
|
||||
break;
|
||||
case WARNING:
|
||||
if (session.emoji_mode == EMO_EMOJI)
|
||||
if (g_session.emoji_mode == EMO_EMOJI)
|
||||
strncpy(prefix, "[" _CYAN_("!") "] :warning: ", sizeof(prefix) - 1);
|
||||
else
|
||||
strncpy(prefix, "[" _CYAN_("!") "] ", sizeof(prefix) - 1);
|
||||
|
@ -233,7 +233,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
|||
strncpy(prefix, "[" _YELLOW_("=") "] ", sizeof(prefix) - 1);
|
||||
break;
|
||||
case INPLACE:
|
||||
if (session.emoji_mode == EMO_EMOJI) {
|
||||
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||
strncpy(prefix, spinner_emoji[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
||||
PrintAndLogEx_spinidx++;
|
||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner_emoji))
|
||||
|
@ -288,8 +288,8 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
|||
if (level == INPLACE) {
|
||||
char buffer3[sizeof(buffer2)] = {0};
|
||||
char buffer4[sizeof(buffer2)] = {0};
|
||||
memcpy_filter_ansi(buffer3, buffer2, sizeof(buffer2), !session.supports_colors);
|
||||
memcpy_filter_emoji(buffer4, buffer3, sizeof(buffer3), session.emoji_mode);
|
||||
memcpy_filter_ansi(buffer3, buffer2, sizeof(buffer2), !g_session.supports_colors);
|
||||
memcpy_filter_emoji(buffer4, buffer3, sizeof(buffer3), g_session.emoji_mode);
|
||||
fprintf(stream, "\r%s", buffer4);
|
||||
fflush(stream);
|
||||
} else {
|
||||
|
@ -309,7 +309,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
|||
pthread_mutex_lock(&g_print_lock);
|
||||
bool linefeed = true;
|
||||
|
||||
if (logging && session.incognito) {
|
||||
if (logging && g_session.incognito) {
|
||||
logging = 0;
|
||||
}
|
||||
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && !logfile) {
|
||||
|
@ -330,7 +330,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
|||
logging = 0;
|
||||
} else {
|
||||
|
||||
if (session.supports_colors) {
|
||||
if (g_session.supports_colors) {
|
||||
printf("["_YELLOW_("=")"] Session log " _YELLOW_("%s") "\n", my_logfile_path);
|
||||
} else {
|
||||
printf("[=] Session log %s\n", my_logfile_path);
|
||||
|
@ -367,10 +367,10 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
|||
linefeed = false;
|
||||
buffer[strlen(buffer) - 1] = 0;
|
||||
}
|
||||
bool filter_ansi = !session.supports_colors;
|
||||
bool filter_ansi = !g_session.supports_colors;
|
||||
memcpy_filter_ansi(buffer2, buffer, sizeof(buffer), filter_ansi);
|
||||
if (g_printAndLog & PRINTANDLOG_PRINT) {
|
||||
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), session.emoji_mode);
|
||||
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), g_session.emoji_mode);
|
||||
fprintf(stream, "%s", buffer3);
|
||||
if (linefeed)
|
||||
fprintf(stream, "\n");
|
||||
|
@ -661,7 +661,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
"\xe2\x96\x88",
|
||||
};
|
||||
|
||||
int mode = (session.emoji_mode == EMO_EMOJI);
|
||||
int mode = (g_session.emoji_mode == EMO_EMOJI);
|
||||
|
||||
const char *block[] = {"#", "\xe2\x96\x88"};
|
||||
// use a 3-byte space in emoji mode to ease computations
|
||||
|
@ -694,7 +694,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
char *cbar = (char *)calloc(collen, sizeof(uint8_t));
|
||||
|
||||
// Add colors
|
||||
if (session.supports_colors) {
|
||||
if (g_session.supports_colors) {
|
||||
int p60 = unit * (width * 60 / 100);
|
||||
int p20 = unit * (width * 20 / 100);
|
||||
snprintf(cbar, collen, _GREEN_("%.*s"), p60, bar);
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef struct {
|
|||
pm3_device *current_device;
|
||||
} session_arg_t;
|
||||
|
||||
extern session_arg_t session;
|
||||
extern session_arg_t g_session;
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue