@@ -462,11 +462,12 @@ u32* findCardReadStartOffsetType0(const module_params_t* moduleParams, const u32
462462 );
463463 if (cardReadStartOffset ) {
464464 dbg_printf ("ARM9 Card read start (type 0) found\n" );
465+ goto findCardReadStartOffsetType0_return ;
465466 } else {
466467 dbg_printf ("ARM9 Card read start (type 0) not found\n" );
467468 }
468469
469- if (! cardReadStartOffset && moduleParams -> sdk_version < 0x2008000 ) {
470+ if (moduleParams -> sdk_version < 0x2008000 ) {
470471 cardReadStartOffset = findOffsetBackwards (
471472 cardReadEndOffset , 0x118 ,
472473 cardReadStartSignatureAlt , 1
@@ -478,6 +479,7 @@ u32* findCardReadStartOffsetType0(const module_params_t* moduleParams, const u32
478479 }
479480 }
480481
482+ findCardReadStartOffsetType0_return :
481483 dbg_printf ("\n" );
482484 return cardReadStartOffset ;
483485}
@@ -496,34 +498,33 @@ u32* findCardReadStartOffsetType1(const u32* cardReadEndOffset) {
496498 );
497499 if (cardReadStartOffset ) {
498500 dbg_printf ("ARM9 Card read start alt 2 (type 1) found\n" );
501+ goto findCardReadStartOffsetType1_return ;
499502 } else {
500503 dbg_printf ("ARM9 Card read start alt 2 (type 1) not found\n" );
501504 }
502505
503- if (!cardReadStartOffset ) {
504- cardReadStartOffset = findOffsetBackwards (
505- cardReadEndOffset , 0x178 ,
506- cardReadStartSignatureDebug , 3
507- );
508- if (cardReadStartOffset ) {
509- dbg_printf ("ARM9 Card read start DEBUG (type 1) found\n" );
510- } else {
511- dbg_printf ("ARM9 Card read start DEBUG (type 1) not found\n" );
512- }
506+ cardReadStartOffset = findOffsetBackwards (
507+ cardReadEndOffset , 0x178 ,
508+ cardReadStartSignatureDebug , 3
509+ );
510+ if (cardReadStartOffset ) {
511+ dbg_printf ("ARM9 Card read start DEBUG (type 1) found\n" );
512+ goto findCardReadStartOffsetType1_return ;
513+ } else {
514+ dbg_printf ("ARM9 Card read start DEBUG (type 1) not found\n" );
513515 }
514516
515- if (!cardReadStartOffset ) {
516- cardReadStartOffset = findOffsetBackwards (
517- cardReadEndOffset , 0x118 ,
518- cardReadStartSignatureDebugAlt , 3
519- );
520- if (cardReadStartOffset ) {
521- dbg_printf ("ARM9 Card read start DEBUG alt (type 1) found\n" );
522- } else {
523- dbg_printf ("ARM9 Card read start DEBUG alt (type 1) not found\n" );
524- }
517+ cardReadStartOffset = findOffsetBackwards (
518+ cardReadEndOffset , 0x118 ,
519+ cardReadStartSignatureDebugAlt , 3
520+ );
521+ if (cardReadStartOffset ) {
522+ dbg_printf ("ARM9 Card read start DEBUG alt (type 1) found\n" );
523+ } else {
524+ dbg_printf ("ARM9 Card read start DEBUG alt (type 1) not found\n" );
525525 }
526526
527+ findCardReadStartOffsetType1_return :
527528 dbg_printf ("\n" );
528529 return cardReadStartOffset ;
529530}
@@ -546,22 +547,22 @@ u32* findCardReadStartOffset5(const module_params_t* moduleParams, const u32* ca
546547 );
547548 if (cardReadStartOffset ) {
548549 dbg_printf ("ARM9 Card read start SDK 5 found\n" );
550+ goto findCardReadStartOffset5_return ;
549551 } else {
550552 dbg_printf ("ARM9 Card read start SDK 5 not found\n" );
551553 }
552554
553- if (!cardReadStartOffset ) {
554- cardReadStartOffset = findOffsetBackwards (
555- (u32 * )cardReadEndOffset , 0x120 ,
556- cardReadStartSignature5Alt , 1
557- );
558- if (cardReadStartOffset ) {
559- dbg_printf ("ARM9 Card read start SDK 5.5 found\n" );
560- } else {
561- dbg_printf ("ARM9 Card read start SDK 5.5 not found\n" );
562- }
555+ cardReadStartOffset = findOffsetBackwards (
556+ (u32 * )cardReadEndOffset , 0x120 ,
557+ cardReadStartSignature5Alt , 1
558+ );
559+ if (cardReadStartOffset ) {
560+ dbg_printf ("ARM9 Card read start SDK 5.5 found\n" );
561+ } else {
562+ dbg_printf ("ARM9 Card read start SDK 5.5 not found\n" );
563563 }
564564
565+ findCardReadStartOffset5_return :
565566 dbg_printf ("\n" );
566567 return cardReadStartOffset ;
567568}
@@ -596,22 +597,22 @@ u16* findCardReadStartOffsetThumb(const u16* cardReadEndOffset) {
596597 );
597598 if (cardReadStartOffset ) {
598599 dbg_printf ("ARM9 Card read start thumb found\n" );
600+ goto findCardReadStartOffsetThumb_return ;
599601 } else {
600602 dbg_printf ("ARM9 Card read start thumb not found\n" );
601603 }
602604
603- if (!cardReadStartOffset ) {
604- cardReadStartOffset = findOffsetBackwardsThumb (
605- cardReadEndOffset , 0xC0 ,
606- cardReadStartSignatureThumbAlt , 2
607- );
608- if (cardReadStartOffset ) {
609- dbg_printf ("ARM9 Card read start thumb alt found\n" );
610- } else {
611- dbg_printf ("ARM9 Card read start thumb alt not found\n" );
612- }
605+ cardReadStartOffset = findOffsetBackwardsThumb (
606+ cardReadEndOffset , 0xC0 ,
607+ cardReadStartSignatureThumbAlt , 2
608+ );
609+ if (cardReadStartOffset ) {
610+ dbg_printf ("ARM9 Card read start thumb alt found\n" );
611+ } else {
612+ dbg_printf ("ARM9 Card read start thumb alt not found\n" );
613613 }
614614
615+ findCardReadStartOffsetThumb_return :
615616 dbg_printf ("\n" );
616617 return cardReadStartOffset ;
617618}
@@ -786,32 +787,30 @@ u32* findCardPullOutOffset(const tNDSHeader* ndsHeader, const module_params_t* m
786787 );
787788 if (cardPullOutOffset ) {
788789 dbg_printf ("Card pull out handler SDK 5 found\n" );
790+ goto findCardPullOutOffset_return ;
789791 } else {
790792 dbg_printf ("Card pull out handler SDK 5 not found\n" );
791793 }
792794
793- if (!cardPullOutOffset ) {
794- cardPullOutOffset = findOffset (
795- (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
796- cardPullOutSignature5Alt , 4
797- );
798- if (cardPullOutOffset ) {
799- dbg_printf ("Card pull out handler SDK 5 alt found\n" );
800- } else {
801- dbg_printf ("Card pull out handler SDK 5 alt not found\n" );
802- }
795+ cardPullOutOffset = findOffset (
796+ (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
797+ cardPullOutSignature5Alt , 4
798+ );
799+ if (cardPullOutOffset ) {
800+ dbg_printf ("Card pull out handler SDK 5 alt found\n" );
801+ goto findCardPullOutOffset_return ;
802+ } else {
803+ dbg_printf ("Card pull out handler SDK 5 alt not found\n" );
803804 }
804805
805- if (!cardPullOutOffset ) {
806- cardPullOutOffset = findOffset (
807- (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
808- cardPullOutSignatureDebug5 , 5
809- );
810- if (cardPullOutOffset ) {
811- dbg_printf ("Card pull out handler SDK 5 DEBUG found\n" );
812- } else {
813- dbg_printf ("Card pull out handler SDK 5 DEBUG not found\n" );
814- }
806+ cardPullOutOffset = findOffset (
807+ (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
808+ cardPullOutSignatureDebug5 , 5
809+ );
810+ if (cardPullOutOffset ) {
811+ dbg_printf ("Card pull out handler SDK 5 DEBUG found\n" );
812+ } else {
813+ dbg_printf ("Card pull out handler SDK 5 DEBUG not found\n" );
815814 }
816815 } else {
817816 if (moduleParams -> sdk_version > 0x2008000 && moduleParams -> sdk_version < 0x3000000 ) {
@@ -822,74 +821,76 @@ u32* findCardPullOutOffset(const tNDSHeader* ndsHeader, const module_params_t* m
822821 );
823822 if (cardPullOutOffset ) {
824823 dbg_printf ("Card pull out handler SDK 2 elaborate found\n" );
824+ goto findCardPullOutOffset_return ;
825825 } else {
826826 dbg_printf ("Card pull out handler SDK 2 elaborate not found\n" );
827827 }
828828 }
829829
830- if (! cardPullOutOffset && moduleParams -> sdk_version < 0x4000000 ) {
830+ if (moduleParams -> sdk_version < 0x4000000 ) {
831831 cardPullOutOffset = findOffset (
832832 (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
833833 cardPullOutSignature1 , 4
834834 );
835835 if (cardPullOutOffset ) {
836836 dbg_printf ("Card pull out handler found\n" );
837+ goto findCardPullOutOffset_return ;
837838 } else {
838839 dbg_printf ("Card pull out handler not found\n" );
839840 }
840841 }
841842
842- if (! cardPullOutOffset && moduleParams -> sdk_version < 0x2008000 ) {
843+ if (moduleParams -> sdk_version < 0x2008000 ) {
843844 // SDK 2
844845 cardPullOutOffset = findOffset (
845846 (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
846847 cardPullOutSignature2Alt , 4
847848 );
848849 if (cardPullOutOffset ) {
849850 dbg_printf ("Card pull out handler SDK 2 alt found\n" );
851+ goto findCardPullOutOffset_return ;
850852 } else {
851853 dbg_printf ("Card pull out handler SDK 2 alt not found\n" );
852854 }
853855 }
854856
855- if (!cardPullOutOffset ) {
856- // SDK 4
857- cardPullOutOffset = findOffset (
858- (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
859- cardPullOutSignature4 , 4
860- );
861- if (cardPullOutOffset ) {
862- dbg_printf ("Card pull out handler SDK 4 found\n" );
863- } else {
864- dbg_printf ("Card pull out handler SDK 4 not found\n" );
865- }
857+ // SDK 4
858+ cardPullOutOffset = findOffset (
859+ (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
860+ cardPullOutSignature4 , 4
861+ );
862+ if (cardPullOutOffset ) {
863+ dbg_printf ("Card pull out handler SDK 4 found\n" );
864+ goto findCardPullOutOffset_return ;
865+ } else {
866+ dbg_printf ("Card pull out handler SDK 4 not found\n" );
866867 }
867868
868- if (! cardPullOutOffset && moduleParams -> sdk_version > 0x4000000 ) {
869+ if (moduleParams -> sdk_version > 0x4000000 ) {
869870 cardPullOutOffset = findOffset (
870871 (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
871872 cardPullOutSignature1 , 4
872873 );
873874 if (cardPullOutOffset ) {
874875 dbg_printf ("Card pull out handler found\n" );
876+ goto findCardPullOutOffset_return ;
875877 } else {
876878 dbg_printf ("Card pull out handler not found\n" );
877879 }
878880 }
879881
880- if (!cardPullOutOffset ) {
881- cardPullOutOffset = findOffset (
882- (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
883- cardPullOutSignatureDebug , 5
884- );
885- if (cardPullOutOffset ) {
886- dbg_printf ("Card pull out handler DEBUG found\n" );
887- } else {
888- dbg_printf ("Card pull out handler DEBUG not found\n" );
889- }
882+ cardPullOutOffset = findOffset (
883+ (u32 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
884+ cardPullOutSignatureDebug , 5
885+ );
886+ if (cardPullOutOffset ) {
887+ dbg_printf ("Card pull out handler DEBUG found\n" );
888+ } else {
889+ dbg_printf ("Card pull out handler DEBUG not found\n" );
890890 }
891891 }
892892
893+ findCardPullOutOffset_return :
893894 dbg_printf ("\n" );
894895 return cardPullOutOffset ;
895896}
@@ -905,34 +906,33 @@ u16* findCardPullOutOffsetThumb(const tNDSHeader* ndsHeader) {
905906 );
906907 if (cardPullOutOffset ) {
907908 dbg_printf ("Card pull out handler thumb found\n" );
909+ goto findCardPullOutOffsetThumb_return ;
908910 } else {
909911 dbg_printf ("Card pull out handler thumb not found\n" );
910912 }
911913
912- if (!cardPullOutOffset ) {
913- cardPullOutOffset = findOffsetThumb (
914- (u16 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
915- cardPullOutSignatureThumbAlt , 4
916- );
917- if (cardPullOutOffset ) {
918- dbg_printf ("Card pull out handler thumb alt found\n" );
919- } else {
920- dbg_printf ("Card pull out handler thumb alt not found\n" );
921- }
914+ cardPullOutOffset = findOffsetThumb (
915+ (u16 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
916+ cardPullOutSignatureThumbAlt , 4
917+ );
918+ if (cardPullOutOffset ) {
919+ dbg_printf ("Card pull out handler thumb alt found\n" );
920+ goto findCardPullOutOffsetThumb_return ;
921+ } else {
922+ dbg_printf ("Card pull out handler thumb alt not found\n" );
922923 }
923924
924- if (!cardPullOutOffset ) {
925- cardPullOutOffset = findOffsetThumb (
926- (u16 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
927- cardPullOutSignatureThumbAlt2 , 4
928- );
929- if (cardPullOutOffset ) {
930- dbg_printf ("Card pull out handler thumb alt 2 found\n" );
931- } else {
932- dbg_printf ("Card pull out handler thumb alt 2 not found\n" );
933- }
925+ cardPullOutOffset = findOffsetThumb (
926+ (u16 * )ndsHeader -> arm9destination , iUncompressedSize ,//ndsHeader->arm9binarySize,
927+ cardPullOutSignatureThumbAlt2 , 4
928+ );
929+ if (cardPullOutOffset ) {
930+ dbg_printf ("Card pull out handler thumb alt 2 found\n" );
931+ } else {
932+ dbg_printf ("Card pull out handler thumb alt 2 not found\n" );
934933 }
935934
935+ findCardPullOutOffsetThumb_return :
936936 dbg_printf ("\n" );
937937 return cardPullOutOffset ;
938938}
0 commit comments