Enabling debug console only for a unique roleid

Results 1 to 15 of 15
  1. #1
    Would You Kindly? Bola is offline
    DeveloperRank
    Dec 2011 Join Date
    BrazilLocation
    1,680Posts

    Enabling debug console only for a unique roleid

    Hello ragezoners, i'm glad to bring to this forum a 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.

    Code:
    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:



    credits: me
    Last edited by Bola; 30-04-21 at 08:28 PM.


  2. #2
    Member pwpnix is offline
    MemberRank
    Aug 2011 Join Date
    25Posts

    Re: Enabling debug console only for a unique roleid

    Wow, very nice Bola, thanks!
    Almost paid for this in another for├║m

  3. #3
    JD | Web Developer mrosenov is offline
    True MemberRank
    Jun 2012 Join Date
    BulgariaLocation
    535Posts

    Re: Enabling debug console only for a unique roleid

    Hehe nice tutorial its somehow good to know that somebody still contributes for the game.
    Shall we?

  4. #4
    Registered Optimus777 is offline
    MemberRank
    Feb 2016 Join Date
    12Posts

    Re: Enabling debug console only for a unique roleid

    Thank you for sharing with us those kind of stuff people would normally charge for... really, thank you!

  5. #5
    Member wanted587 is offline
    MemberRank
    Aug 2013 Join Date
    BrazilLocation
    81Posts

    Re: Enabling debug console only for a unique roleid

    Thanks for placing the credits.

  6. #6
    sarcasm-mode: active jv90 is offline
    True MemberRank
    Jun 2013 Join Date
    IDALocation
    456Posts

    Re: Enabling debug console only for a unique roleid

    It is interesting to note your methods here to maintain GS file-length. At the cost of logging but that is repayed for in production server safety in c2scmd. Great guide.

  7. #7
    Would You Kindly? Bola is offline
    DeveloperRank
    Dec 2011 Join Date
    BrazilLocation
    1,680Posts

    Re: Enabling debug console only for a unique roleid

    Quote Originally Posted by jv90 View Post
    It is interesting to note your methods here to maintain GS file-length. At the cost of logging but that is repayed for in production server safety in c2scmd. Great guide.
    yeah there many things in GS "useless" somehow that you can erase and rewrite new instructions to add new behaviors, for example, inside gs you find a big function to save elements.data to a binary file again, since we know GS is not able to edit elements.data, we can override all entire code with our own functions and call it from somewhere in the gs to add custom behaviors.

  8. #8
    Member lokitopw is offline
    MemberRank
    Feb 2016 Join Date
    25Posts

    Re: Enabling debug console only for a unique roleid

    I followed the tutorial, however when using "c2scmd" gs falls

    - - - Updated - - -

    Bump, anyone?
    Last edited by lokitopw; 21-06-20 at 05:40 AM.

  9. #9
    sarcasm-mode: active jv90 is offline
    True MemberRank
    Jun 2013 Join Date
    IDALocation
    456Posts

    Re: Enabling debug console only for a unique roleid

    Quote Originally Posted by lokitopw View Post
    I followed the tutorial, however when using "c2scmd" gs falls

    - - - Updated - - -

    Bump, anyone?
    It means your modifications are not executing right for one reason or another.

    You are basically causing the execute-able ELF file aka GS to crash with faulty code. Double check your edits to make sure it emulates the same thing here and if the code is similar enough when checking role for it and such for it to work the same

  10. #10
    Member lokitopw is offline
    MemberRank
    Feb 2016 Join Date
    25Posts

    Re: Enabling debug console only for a unique roleid

    The code is correct and working, the problem is when using the code "c2scmd", nothing more! But it doesn't matter anymore, I corrected it in another way!

    Thanks!

  11. #11
    sarcasm-mode: active jv90 is offline
    True MemberRank
    Jun 2013 Join Date
    IDALocation
    456Posts

    Re: Enabling debug console only for a unique roleid

    Quote Originally Posted by lokitopw View Post
    The code is correct and working, the problem is when using the code "c2scmd", nothing more! But it doesn't matter anymore, I corrected it in another way!

    Thanks!
    If the modification was to allow c2scmd access for only one single role and your GS crashed on invoking that functionality then the modification caused the issue one way or another. If its causing your GS to crash then its not 'fine and working' The literal debug console is c2scmd. Hence the name... But glad its solved.

  12. #12
    Member Dylen676 is offline
    MemberRank
    Nov 2007 Join Date
    46Posts

    Re: Enabling debug console only for a unique roleid

    Hi!

    Can this be set up on a 1.5.5 server as well, and if so, how?
    Does this setting apply to all GMs?
    Thanks

  13. #13
    Would You Kindly? Bola is offline
    DeveloperRank
    Dec 2011 Join Date
    BrazilLocation
    1,680Posts

    Re: Enabling debug console only for a unique roleid

    Quote Originally Posted by Dylen676 View Post
    Hi!

    Can this be set up on a 1.5.5 server as well, and if so, how?
    Does this setting apply to all GMs?
    Thanks
    this tutorial is universal, should work on any version, just pay attention on steps to perform changes properly

  14. #14
    Member Dylen676 is offline
    MemberRank
    Nov 2007 Join Date
    46Posts

    Re: Enabling debug console only for a unique roleid

    Thanks

  15. #15
    Member Dylen676 is offline
    MemberRank
    Nov 2007 Join Date
    46Posts

    Re: Enabling debug console only for a unique roleid

    Unfortunately, I ran into a problem. My gs displays differently. Can you tell me what to rewrite?



Advertisement