Tutorial - Enabling debug console only for a unique roleid | hrace009 Community

Tutorial Enabling debug console only for a unique roleid


Staff member
Guide showing how to enable debug console for a Unique Roleid (Gamemaster or normal player).
be aware this method will replace Logging instruction so you will lost a small part of logging.

you will need a IDA Pro for x86 applications.

To start working you will have to find a method called "gplayer_controller::DebugCommandHandler", to find it you need to load gs from which version you want to create this function, and after done select method box and press ALT Key + T Key at same time, insert inside the box the function name above and press ok.

so you gonna find the function we are looking for, Press F5 to have a pseudo C++ code overview.
if you go down a little bit you're going to find this instruction to Log the DebugCommand, we gonna erase it and replace with our instruction.

set your mouse pointer and click on the middle of string "this->_imp->_parent_ID.id", then press TAB.
you will see a instruction like this in the IDA, where Yellow is the instruction mov the roleid to EAX memory block and one line after yellow block, the instruction of system pull roleid from pointer EAX+30h.


Make sure to remember the entire yellow block instructions plus the pointer EAX+30h ( can be other depending on gs version ).

set your mouse pointer on the instruction "push [ebp+cmd_type]" and go on menu bar in top of IDA Pro, select Edit -> Patch Program -> Assemble.
you gonna write the word "NOP" until you reach the instruction "mov eax, [ebp+cmd_type]".
after you done, it will looks like this.


now you need to know where your method "DebugCommandHandler" finish it, my trick for this is click on next method in the method box and then go a little bit above the function , you will find the end of debughandler and then you need copy the locale instruction to a notepad or kind of, in my example the locale in on left-top of instruction, "loc_812B8D1".


so now you can build the new instructions code as you have the old code plus the compare to the roleid number, for my example i'll have those instructions.
remember to replace the mov eax and pointer eax 30h to match with the one of your gs, also replace myroleid with the ID of your desired character and also replace in last line the Loc that you find in the ending of the method.

mov     eax, [ebp+this]
mov     eax, [eax+4]
mov     eax, [eax+8]
cmp     dword ptr [eax+30h], MYROLEIDHERE
jnz     loc_812B8D1
Go to the first NOP in instructions and patch again but now with each line above, after done you will have to transfer the code to your gs again, so go to the menu bar from IDA, select Edit -> Patch Program -> Apply Patches, then select your original gs file loaded in the IDA previous, then replace in your server with this patched GS and test, Debug should works fine only for the designed roleid.

The final instruction will looks like this: