Mario Kart Wii Gecko Codes, Cheats, & Hacks

Full Version: Custom Exception Handler [Star / Riidefi]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Custom Exception Handler [Star / Riidefi]

This code will display exception information on the television screen when an exception occurs. After the console is finished scrolling, you will be returned to the Wii System Menu.

(NTSC-U)
C20235F4 00000011
9421FF80 BC410008
48000055 2A2A2A2A
2A2A2043 7573746F
6D204578 63657074
696F6E20 48616E64
6C657220 2A2A2A2A
2A0A2A2A 2A2A2A2A
2A2A2A20 62792053
74617220 26205269
69646566 69202A2A
2A2A2A2A 2A2A2A0A
00000000 7C6802A6
4CC63182 3D808002
618C3500 7D8803A6
4E800021 B8410008
38210080 28030011
60000000 00000000
040238A8 281E0005
C20238BC 0000000D
9421FF80 BC410008
48000039 596F7520
77696C6C 206E6F77
20626520 72657475
726E6564 20746F20
74686520 57696920
53797374 656D204D
656E752E 00000000
7C6802A6 4CC63182
3D808002 618C3500
7D8803A6 4E800021
B8410008 38210080
39610020 00000000
C2226260 00000003
3D808000 618CB0E8
7D8803A6 4E800020
60000000 00000000
042A3084 00000000
022A3090 00000023

(PAL)
C2023694 00000011
9421FF80 BC410008
48000055 2A2A2A2A
2A2A2043 7573746F
6D204578 63657074
696F6E20 48616E64
6C657220 2A2A2A2A
2A0A2A2A 2A2A2A2A
2A2A2A20 62792053
74617220 26205269
69646566 69202A2A
2A2A2A2A 2A2A2A0A
00000000 7C6802A6
4CC63182 3D808002
618C35A0 7D8803A6
4E800021 B8410008
38210080 28030011
60000000 00000000
04023948 281E0005
C202395C 0000000D
9421FF80 BC410008
48000039 596F7520
77696C6C 206E6F77
20626520 72657475
726E6564 20746F20
74686520 57696920
53797374 656D204D
656E752E 00000000
7C6802A6 4CC63182
3D808002 618C35A0
7D8803A6 4E800021
B8410008 38210080
39610020 00000000
C22265E4 00000003
3D808000 618CB188
7D8803A6 4E800020
60000000 00000000
042A7404 00000000
022A7410 00000023

(NTSC-J)
C20235B4 00000011
9421FF80 BC410008
48000055 2A2A2A2A
2A2A2043 7573746F
6D204578 63657074
696F6E20 48616E64
6C657220 2A2A2A2A
2A0A2A2A 2A2A2A2A
2A2A2A20 62792053
74617220 26205269
69646566 69202A2A
2A2A2A2A 2A2A2A0A
00000000 7C6802A6
4CC63182 3D808002
618C34C0 7D8803A6
4E800021 B8410008
38210080 28030011
60000000 00000000
04023868 281E0005
C202387C 0000000D
9421FF80 BC410008
48000039 596F7520
77696C6C 206E6F77
20626520 72657475
726E6564 20746F20
74686520 57696920
53797374 656D204D
656E752E 00000000
7C6802A6 4CC63182
3D808002 618C34C0
7D8803A6 4E800021
B8410008 38210080
39610020 00000000
C2226504 00000003
3D808000 618CB0AC
7D8803A6 4E800020
60000000 00000000
042A6D84 00000000
022A6D90 00000023

(NTSC-K)
C20236F4 00000011
9421FF80 BC410008
48000055 2A2A2A2A
2A2A2043 7573746F
6D204578 63657074
696F6E20 48616E64
6C657220 2A2A2A2A
2A0A2A2A 2A2A2A2A
2A2A2A20 62792053
74617220 26205269
69646566 69202A2A
2A2A2A2A 2A2A2A0A
00000000 7C6802A6
4CC63182 3D808002
618C3600 7D8803A6
4E800021 B8410008
38210080 28030011
60000000 00000000
040239A8 281E0005
C20239BC 0000000D
9421FF80 BC410008
48000039 596F7520
77696C6C 206E6F77
20626520 72657475
726E6564 20746F20
74686520 57696920
53797374 656D204D
656E752E 00000000
7C6802A6 4CC63182
3D808002 618C3600
7D8803A6 4E800021
B8410008 38210080
39610020 00000000
C2226958 00000003
3D808000 618CB234
7D8803A6 4E800020
60000000 00000000
04295404 00000000
02295410 00000023

Code:
#============================================================#
#                           Source                           #
#------------------------------------------------------------#
# nw4r::db::PrintContext_ Exception Type Address Ports:      #
# RMCE - 0x800235F4                                          #
# RMCP - 0x80023694                                          #
# RMCJ - 0x800235B4                                          #
# RMCK - 0x800236F4                                          #
#============================================================#

.macro push_stack size, registers
       stwu r1, \size(r1)
       stmw \registers, 8(r1)
.endm

.macro absolute_bl register, address
       lis \register, \address@h
       ori \register, \register, \address@l
       mtlr \register
       blrl
.endm

.macro pop_stack registers, size
       lmw \registers, 8(r1)
       addi r1, r1, \size
.endm

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set nw4r_db_Exception_Printf_, 0x80023500
.elseif (region == 'P' || region == 'p') # RMCP
        .set nw4r_db_Exception_Printf_, 0x800235A0
.elseif (region == 'J' || region == 'j') # RMCJ
        .set nw4r_db_Exception_Printf_, 0x800234C0
.elseif (region == 'K' || region == 'k') # RMCK
        .set nw4r_db_Exception_Printf_, 0x80023600
.else # Invalid Region
        .abort
.endif

# Function Prologue...
push_stack -128, r2

bl branch_link_write_exception_printf_statement

.string "****** Custom Exception Handler *****\n********* by Star & Riidefi *********\n\0\0\0"

branch_link_write_exception_printf_statement:
mflr r3 # Store the pointer to the String into r3

# Call nw4r::db::Exception_Printf_
crclr 4*cr1+eq
absolute_bl r12, nw4r_db_Exception_Printf_

# Function Epilogue...
pop_stack r2, 128

# Original Instruction
cmplwi r3, 0x11 # if (error < OS_ERROR_MAX)

#============================================================#
#                  nw4r::db::ShowStackTrace_                 #
#============================================================#
# Display a stacktrace of up to 5 levels of the stack.       #
#============================================================#

(NTSC-U)
040238A8 281E0005

(PAL)
04023948 281E0005

(NTSC-J)
04023868 281E0005

(NTSC-K)
040239A8 281E0005

#============================================================#
#                           Source                           #
#------------------------------------------------------------#
# nw4r::db::PrintContext_ Function Return Address Ports:     #
# RMCE - 0x800238BC                                          #
# RMCP - 0x8002395C                                          #
# RMCJ - 0x8002387C                                          #
# RMCK - 0x800239BC                                          #
#============================================================#

.macro push_stack size, registers
       stwu r1, \size(r1)
       stmw \registers, 8(r1)
.endm

.macro absolute_bl register, address
       lis \register, \address@h
       ori \register, \register, \address@l
       mtlr \register
       blrl
.endm

.macro pop_stack registers, size
       lmw \registers, 8(r1)
       addi r1, r1, \size
.endm

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set nw4r_db_Exception_Printf_, 0x80023500
.elseif (region == 'P' || region == 'p') # RMCP
        .set nw4r_db_Exception_Printf_, 0x800235A0
.elseif (region == 'J' || region == 'j') # RMCJ
        .set nw4r_db_Exception_Printf_, 0x800234C0
.elseif (region == 'K' || region == 'k') # RMCK
        .set nw4r_db_Exception_Printf_, 0x80023600
.else # Invalid Region
        .abort
.endif

# Function Prologue...
push_stack -128, r2

bl branch_link_write_exception_printf_statement

.string "You will now be returned to the Wii System Menu.\0\0\0"

branch_link_write_exception_printf_statement:
mflr r3 # Store the pointer to the String into r3

# Call nw4r::db::Exception_Printf_
crclr 4*cr1+eq
absolute_bl r12, nw4r_db_Exception_Printf_

# Function Epilogue...
pop_stack r2, 128

# Original Instruction
addi r11, r1, 32

#============================================================#
#                           Source                           #
#------------------------------------------------------------#
# offset = Console_GetBufferHeadLine(console) Address Ports: #
# RMCE - 0x80226260                                          #
# RMCP - 0x802265E4                                          #
# RMCJ - 0x80226504                                          #
# RMCK - 0x80226958                                          #
#============================================================#

.macro absolute_b register, address
       lis \register, \address@h
       ori \register, \register, \address@l
       mtlr \register
       blr
.endm

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set System_SystemManager_returnToMenu, 0x8000B0E8
.elseif (region == 'P' || region == 'p') # RMCP
        .set System_SystemManager_returnToMenu, 0x8000B188
.elseif (region == 'J' || region == 'j') # RMCJ
        .set System_SystemManager_returnToMenu, 0x8000B0AC
.elseif (region == 'K' || region == 'k') # RMCK
        .set System_SystemManager_returnToMenu, 0x8000B234
.else # Invalid Region
        .abort
.endif

# Call System::SystemManager::returnToMenu
absolute_b r12, System_SystemManager_returnToMenu

#============================================================#
#                            Note                            #
#------------------------------------------------------------#
# Since we do not return from the function call, there is no #
# need to preserve any registers.                            #
#============================================================#

#============================================================#
#                  nw4r::db::exception .bss                  #
#============================================================#

#============================================================#
#              EGG::Exception::setUserCallBack               #
#============================================================#
# Automatically display the exception console.               #
#============================================================#

(NTSC-U)
042A3084 00000000

(PAL)
042A7404 00000000

(NTSC-J)
042A6D84 00000000

(NTSC-K)
04295404 00000000

#============================================================#
#                sException.dispInfo = info;                 #
#============================================================#
# enum                                                       #
# {                                                          #
#     EXCEPTION_INFO_MAIN     = 0x1,                         #
#     EXCEPTION_INFO_GPR      = 0x2,                         #
#     EXCEPTION_INFO_GPRMAP   = 0x4,                         #
#     EXCEPTION_INFO_SRR0MAP  = 0x8,                         #
#     EXCEPTION_INFO_FPR      = 0x10,                        #
#     EXCEPTION_INFO_TRACE    = 0x20,                        #
#                                                            #
#     EXCEPTION_INFO_ALL      = 0x3F,                        #
#     EXCEPTION_INFO_DEFAULT  = EXCEPTION_INFO_MAIN  |       #
#                               EXCEPTION_INFO_TRACE         #
# };                                                         #
#                                                            #
# Set the information flag to display the Main Information,  #
# General Purpose Registers, and a Stack Trace.              #
#============================================================#

(NTSC-U)
022A3090 00000023

(PAL)
022A7410 00000023

(NTSC-J)
022A6D90 00000023

(NTSC-K)
02295410 00000023

Code Creators: Star, Riidefi
For my 1 years worth of modding, I've never seen this code work on my end. I've encounter crashes daily only to have it never appear. Does the code need to be alone/not patched with any other codes? LE-CODE uses one and I've had some success with that one, but not all the time.
Sometimes crashes are so bad that the exception handling routine is simply never reached. This code has worked for me on both normal games and lecode distributions
(11-11-2020, 09:39 PM)JoshuaMK Wrote: [ -> ]Sometimes crashes are so bad that the exception handling routine is simply never reached. This code has worked for me on both normal games and lecode distributions

Hmm, I mean at least in my cases, most seem to be code type crashes (a code gets put in and doesnt work). Like, 80% of the crashes I get don't bring them up, and the location of the crashes is always stupid.
The simple fact is you have to be doing something horribly wrong. I imagine you know how to region match the codes to your distribution.

How are you patching them in?
(11-11-2020, 11:51 PM)JoshuaMK Wrote: [ -> ]The simple fact is you have to be doing something horribly wrong. I imagine you know how to region match the codes to your distribution.

How are you patching them in?

Directly into the main.dol thru wiimms szs tools. I do this command "wstrt patch main.dol --wiimmfi --region 20034 --vs x --bt x --gct-move=ON --add-section RMCE01.gct"
I've personally had certain codes work fine (standard GCT usage) then not work at all when patched via wstrt.

And JoshuaMK is saying that there is probably an infinite loop somewhere before the execution of the Exception Handler.

To see if it's wiimm tools jacking up the code via its patching method, you could hex edit in the code on the main.dol + staticr.rel, but that's a pain to do.
You could also use GeckoLoader to patch your codes into the main.dol. I haven't seen anybody specifically use it on a wii game but it should work as it is designed to.

Basically patch the dol with wstrt to get the region and wiimmfi patched, and then after that patch it with your codes using GeckoLoader.

Lemme know if this works (or at least does the same as wstrt)
(11-12-2020, 01:07 AM)JoshuaMK Wrote: [ -> ]You could also use GeckoLoader to patch your codes into the main.dol. I haven't seen anybody specifically use it on a wii game but it should work as it is designed to.

Basically patch the dol with wstrt to get the region and wiimmfi patched, and then after that patch it with your codes using GeckoLoader.

Lemme know if this works (or at least does the same as)
What is Geckoloader? How would I go about patching it with it?
(11-12-2020, 03:06 AM)TheNinjaKingOW Wrote: [ -> ]
(11-12-2020, 01:07 AM)JoshuaMK Wrote: [ -> ]You could also use GeckoLoader to patch your codes into the main.dol. I haven't seen anybody specifically use it on a wii game but it should work as it is designed to.

Basically patch the dol with wstrt to get the region and wiimmfi patched, and then after that patch it with your codes using GeckoLoader.

Lemme know if this works (or at least does the same as)
What is Geckoloader? How would I go about patching it with it?

https://mkwii.com/showthread.php?tid=1516
Pages: 1 2