Просмотр исходного кода

BleSpam: Memory management improvements

Willy-JL 2 лет назад
Родитель
Сommit
cb38588d1b

+ 1 - 1
ble_spam/application.fam

@@ -3,7 +3,7 @@ App(
     name="BLE Spam",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="ble_spam",
-    stack_size=6 * 1024,
+    stack_size=2 * 1024,
     fap_icon="ble_spam_10px.png",
     fap_category="Bluetooth",
     fap_author="@Willy-JL @ECTO-1A @Spooks4576",

+ 1 - 1
ble_spam/ble_spam.c

@@ -620,7 +620,7 @@ int32_t ble_spam(void* p) {
     state->thread = furi_thread_alloc();
     furi_thread_set_callback(state->thread, adv_thread);
     furi_thread_set_context(state->thread, state);
-    furi_thread_set_stack_size(state->thread, 4096);
+    furi_thread_set_stack_size(state->thread, 2048);
     state->ctx.led_indicator = true;
     state->lock_timer = furi_timer_alloc(lock_timer_callback, FuriTimerTypeOnce, state);
 

+ 22 - 12
ble_spam/protocols/continuity.c

@@ -844,7 +844,6 @@ void scene_continuity_pp_model_on_enter(void* _ctx) {
     ContinuityCfg* cfg = &payload->cfg.continuity;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
     bool value = payload->mode == PayloadModeValue ||
                  (payload->mode == PayloadModeBruteforce &&
                   cfg->data.proximity_pair.bruteforce_mode != ContinuityPpBruteforceModel);
@@ -882,7 +881,8 @@ bool scene_continuity_pp_model_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_continuity_pp_model_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void pp_model_custom_callback(void* _ctx) {
@@ -918,7 +918,9 @@ bool scene_continuity_pp_model_custom_on_event(void* _ctx, SceneManagerEvent eve
     return false;
 }
 void scene_continuity_pp_model_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }
 
 static void pp_color_callback(void* _ctx, uint32_t index) {
@@ -960,7 +962,6 @@ void scene_continuity_pp_color_on_enter(void* _ctx) {
     ContinuityCfg* cfg = &payload->cfg.continuity;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
     bool value = payload->mode == PayloadModeValue ||
                  (payload->mode == PayloadModeBruteforce &&
                   cfg->data.proximity_pair.bruteforce_mode != ContinuityPpBruteforceColor);
@@ -1006,7 +1007,8 @@ bool scene_continuity_pp_color_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_continuity_pp_color_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void pp_color_custom_callback(void* _ctx) {
@@ -1041,7 +1043,9 @@ bool scene_continuity_pp_color_custom_on_event(void* _ctx, SceneManagerEvent eve
     return false;
 }
 void scene_continuity_pp_color_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }
 
 static void pp_prefix_callback(void* _ctx, uint32_t index) {
@@ -1069,7 +1073,6 @@ void scene_continuity_pp_prefix_on_enter(void* _ctx) {
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
     bool found = false;
-    submenu_reset(submenu);
 
     submenu_add_item(submenu, "Automatic", 0, pp_prefix_callback, ctx);
     if(cfg->data.proximity_pair.prefix == 0x00) {
@@ -1099,7 +1102,8 @@ bool scene_continuity_pp_prefix_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_continuity_pp_prefix_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void pp_prefix_custom_callback(void* _ctx) {
@@ -1131,7 +1135,9 @@ bool scene_continuity_pp_prefix_custom_on_event(void* _ctx, SceneManagerEvent ev
     return false;
 }
 void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }
 
 static void na_action_callback(void* _ctx, uint32_t index) {
@@ -1166,7 +1172,6 @@ void scene_continuity_na_action_on_enter(void* _ctx) {
     ContinuityCfg* cfg = &payload->cfg.continuity;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
 
     submenu_add_item(submenu, "Random", 0, na_action_callback, ctx);
     if(payload->mode == PayloadModeRandom) {
@@ -1202,7 +1207,8 @@ bool scene_continuity_na_action_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_continuity_na_action_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void na_action_custom_callback(void* _ctx) {
@@ -1235,7 +1241,9 @@ bool scene_continuity_na_action_custom_on_event(void* _ctx, SceneManagerEvent ev
     return false;
 }
 void scene_continuity_na_action_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }
 
 static void na_flags_callback(void* _ctx) {
@@ -1269,4 +1277,6 @@ void scene_continuity_na_flags_on_exit(void* _ctx) {
     Payload* payload = &ctx->attack->payload;
     ContinuityCfg* cfg = &payload->cfg.continuity;
     cfg->data.nearby_action.flags = (ctx->byte_store[0] << 0x00);
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }

+ 7 - 5
ble_spam/protocols/easysetup.c

@@ -398,7 +398,6 @@ void scene_easysetup_buds_model_on_enter(void* _ctx) {
     EasysetupCfg* cfg = &payload->cfg.easysetup;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
 
     submenu_add_item(submenu, "Random", 0, buds_model_callback, ctx);
     if(payload->mode == PayloadModeRandom) {
@@ -434,7 +433,8 @@ bool scene_easysetup_buds_model_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_easysetup_buds_model_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void buds_model_custom_callback(void* _ctx) {
@@ -470,7 +470,9 @@ bool scene_easysetup_buds_model_custom_on_event(void* _ctx, SceneManagerEvent ev
     return false;
 }
 void scene_easysetup_buds_model_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }
 
 static void watch_model_callback(void* _ctx, uint32_t index) {
@@ -505,7 +507,6 @@ void scene_easysetup_watch_model_on_enter(void* _ctx) {
     EasysetupCfg* cfg = &payload->cfg.easysetup;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
 
     submenu_add_item(submenu, "Random", 0, watch_model_callback, ctx);
     if(payload->mode == PayloadModeRandom) {
@@ -541,7 +542,8 @@ bool scene_easysetup_watch_model_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_easysetup_watch_model_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void watch_model_custom_callback(void* _ctx) {

+ 5 - 3
ble_spam/protocols/fastpair.c

@@ -746,7 +746,6 @@ void scene_fastpair_model_on_enter(void* _ctx) {
     FastpairCfg* cfg = &payload->cfg.fastpair;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
 
     submenu_add_item(submenu, "Random", 0, model_callback, ctx);
     if(payload->mode == PayloadModeRandom) {
@@ -781,7 +780,8 @@ bool scene_fastpair_model_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_fastpair_model_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void model_custom_callback(void* _ctx) {
@@ -817,5 +817,7 @@ bool scene_fastpair_model_custom_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_fastpair_model_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }

+ 5 - 3
ble_spam/protocols/lovespouse.c

@@ -216,7 +216,6 @@ void scene_lovespouse_mode_on_enter(void* _ctx) {
     LovespouseCfg* cfg = &payload->cfg.lovespouse;
     Submenu* submenu = ctx->submenu;
     uint32_t selected = 0;
-    submenu_reset(submenu);
 
     submenu_add_item(submenu, "Random", 0, mode_callback, ctx);
     if(payload->mode == PayloadModeRandom) {
@@ -252,7 +251,8 @@ bool scene_lovespouse_mode_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_lovespouse_mode_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    submenu_reset(ctx->submenu);
 }
 
 static void mode_custom_callback(void* _ctx) {
@@ -288,5 +288,7 @@ bool scene_lovespouse_mode_custom_on_event(void* _ctx, SceneManagerEvent event)
     return false;
 }
 void scene_lovespouse_mode_custom_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    byte_input_set_result_callback(ctx->byte_input, NULL, NULL, NULL, NULL, 0);
+    byte_input_set_header_text(ctx->byte_input, "");
 }

+ 2 - 2
ble_spam/protocols/swiftpair.c

@@ -111,7 +111,6 @@ void scene_swiftpair_name_on_enter(void* _ctx) {
     Payload* payload = &ctx->attack->payload;
     SwiftpairCfg* cfg = &payload->cfg.swiftpair;
     TextInput* text_input = ctx->text_input;
-    text_input_reset(text_input);
 
     text_input_set_header_text(text_input, "Press back for random");
 
@@ -131,5 +130,6 @@ bool scene_swiftpair_name_on_event(void* _ctx, SceneManagerEvent event) {
     return false;
 }
 void scene_swiftpair_name_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    text_input_reset(ctx->text_input);
 }

+ 2 - 2
ble_spam/scenes/config.c

@@ -40,7 +40,6 @@ static void config_callback(void* _ctx, uint32_t index) {
 void scene_config_on_enter(void* _ctx) {
     Ctx* ctx = _ctx;
     VariableItemList* list = ctx->variable_item_list;
-    variable_item_list_reset(list);
 
     variable_item_list_set_header(list, ctx->attack->title);
 
@@ -71,5 +70,6 @@ bool scene_config_on_event(void* _ctx, SceneManagerEvent event) {
 }
 
 void scene_config_on_exit(void* _ctx) {
-    UNUSED(_ctx);
+    Ctx* ctx = _ctx;
+    variable_item_list_reset(ctx->variable_item_list);
 }