Set Any Chat Bar Limit (default is 64)

Results 1 to 8 of 8
  1. #1
    Account Upgraded | Title Enabled! Spiderman is offline
    MemberRank
    Feb 2010 Join Date
    419Posts

    Set Any Chat Bar Limit (default is 64)

    got sidetracked working on something and stumbled over this so thought i would share because i keep seeing it listed as a "feature"

    note that I am using this as a base but feel free to use your own: https://github.com/MinimumDelta/MapleClientEditTemplate

    all the addresses used are for v95 so looking them up to xref with your version will be easier.

    first you'll need to find the address for the function CUIStatusBar::ChatLogAdd
    and the address for CUIStatusBar::m_aChatLog, this can be seen inside the while loop in the above function.
    aob might look something like 74 ?? 83 78 FC 40 76
    take note of the addresses of the while loop because we want to skip (jmp) that whole section.
    in v95 it starts with a mov, then cmp, then a conditional jmp (this is the one we want).

    put this into MapleAPI.h:
    Code:
    HOOKTYPEDEF_H(void, __fastcall, CUIStatusBar__ChatLogAdd, void* pThis, void* edx, const char* sChat, int lType, int nChannelID, int bWhisperIcon, ZRef<void*> pItem);
    put this into MapleAPI.cpp:
    Code:
    HOOKTYPEDEF_C(CUIStatusBar__ChatLogAdd);
    Put this in your MainFunc() in dllmain.cpp:
    Code:
    INITMAPLEHOOK(
            _CUIStatusBar__ChatLogAdd,
            _CUIStatusBar__ChatLogAdd_t,
            MapleHooks::CUIStatusBar__ChatLogAdd,
            0x0087AEC0 // replace with address to CUIStatusBar::ChatLogAdd
        );
    
        // CUIStatusBar::ChatLogAdd -> remove old entries from chat
        BYTE val = x86JMP;
        MemEdit::WriteValue<BYTE>(0x0087B2E7, &val); // replace with address of the first conditional jmp in the while loop
    add this function to ExampleHooks.h:
    Code:
    void __fastcall CUIStatusBar__ChatLogAdd(void* pThis, void* edx,
            const char* sChat, int lType, int nChannelID,
            int bWhisperIcon, ZRef<void*> pItem);
    add this function inside the MapleHooks namespace in ExampleHooks.cpp:
    Code:
    void __fastcall CUIStatusBar__ChatLogAdd(void* pThis, void* edx,
            const char* sChat, int lType, int nChannelID,
            int bWhisperIcon, ZRef<void*> pItem)
        {
            ZArray<ZRef<CUIStatusBar::CChatLog>>* m_aChatLog = reinterpret_cast<ZArray<ZRef<CUIStatusBar::CChatLog>>*>(0x00C6F188); // replace with address to CUIStatusBar::m_aChatLog
    
            while (m_aChatLog->GetCount() > 1000) { // you can set your custom limit here
                auto idx = m_aChatLog->FindIndex(0);
                m_aChatLog->RemoveAt(idx);
            }
    
            _CUIStatusBar__ChatLogAdd(pThis, NULL, sChat, lType, nChannelID, bWhisperIcon, pItem);
        }
    and you'll also need to adjust the imports in that class too

    and finally add this into a new file called CUIStatusBar.h:
    Code:
    #pragma once
    #include <MapleTypes.h>
    
    struct CUIStatusBar
    {
        struct CChatLog : ZRefCounted 
        {
    // it doesnt really matter what is in here, ZAlloc knows the original size and will deallocate appropriately
        };
    };
    and thats it. you could do all of this in dllmain but i like organization.
    Last edited by Spiderman; 3 Weeks Ago at 04:17 PM.


  2. #2
    Novice Calculator is offline
    MemberRank
    May 2021 Join Date
    2Posts
    Code:
    WriteValue<BYTE>(0x0087B2E9+3, 1000);
    Could we just use this instead?

  3. #3
    Account Upgraded | Title Enabled! Spiderman is offline
    MemberRank
    Feb 2010 Join Date
    419Posts
    Quote Originally Posted by Calculator View Post
    Code:
    WriteValue<BYTE>(0x0087B2E9+3, 1000);
    Could we just use this instead?
    No. While that is a good thought, it will not work because the value that the loop checks against is a byte, which means the highest value that will fit is 255. If you want the limit to be 255 or less, then by all means, simply perform the single-byte edit that you described.

    If you are determined to do this with the fewest keystrokes possible, you will need to write an assembly routine containing your new comparison instructions, jump to it from 0x0087B2E9, then jump back to 0x0087B2ED.

    What I described is called a code-cave (maybe you are familiar), and here is a good link if you would like to learn more about it: https://gamehacking.academy/lesson/3/4.

    However, while code-caves can be quick and useful in some cases, they only (realistically) take you so far, and learning to properly use detours in an organized fashion will result in a much cleaner codebase that is easier to maintain, use, and modify.

  4. #4
    Apprentice barnix is offline
    MemberRank
    Aug 2018 Join Date
    6Posts
    hi
    im trying to do this with your template but while building i get some errors.
    <commonType.h> cant be found
    assert_size(sizeof(CUIStatusBar::CChatLog), 0x34) trows me an error for assert_size
    Severity Code Description Project File Line Suppression StateError (active) E1574 static assertion failed with "Static size assert failed."

  5. #5
    Account Upgraded | Title Enabled! Spiderman is offline
    MemberRank
    Feb 2010 Join Date
    419Posts
    Quote Originally Posted by barnix View Post
    hi
    im trying to do this with your template but while building i get some errors.
    <commonType.h> cant be found
    assert_size(sizeof(CUIStatusBar::CChatLog), 0x34) trows me an error for assert_size
    Severity Code Description Project File Line Suppression StateError (active) E1574 static assertion failed with "Static size assert failed."
    Thanks! Those are both errors on my part, I updated the original post and it should work now. The size assert isn't necessary (or you can set it to 0x12 if you want, I think that's the size of ZRefCounted iirc). I renamed MapleTypes to CommonTypes in my private fork but I never made that change in the public repo, so that is why that file can't be found.

  6. #6
    Apprentice barnix is offline
    MemberRank
    Aug 2018 Join Date
    6Posts
    im not too good at this and im getting a few new errors now.
    in MapleAPI.h i get a ZRef error. syntax error: identifier ZRef. maybe im not linking properly to mapleAPI.cpp?
    and i think because of that i get an error in ExampleHooks.cpp
    _CUIStatusBar__ChatLogAdd(pThis, NULL, sChat, lType, nChannelID, bWhisperIcon, pItem); too many arguments for call. it points to the pItem

  7. #7
    Account Upgraded | Title Enabled! Spiderman is offline
    MemberRank
    Feb 2010 Join Date
    419Posts
    Quote Originally Posted by barnix View Post
    im not too good at this and im getting a few new errors now.
    in MapleAPI.h i get a ZRef error. syntax error: identifier ZRef. maybe im not linking properly to mapleAPI.cpp?
    and i think because of that i get an error in ExampleHooks.cpp
    _CUIStatusBar__ChatLogAdd(pThis, NULL, sChat, lType, nChannelID, bWhisperIcon, pItem); too many arguments for call. it points to the pItem
    Include MapleTypes.h in MapleAPI.h. The MapleTypes header file has all the common maple types linked in it (such as ZRef).

  8. #8
    Apprentice barnix is offline
    MemberRank
    Aug 2018 Join Date
    6Posts
    Thank you! i got it to build. sadly it does crash my game after char select. im using v83 with these adresses:
    CUIStatusBar::ChatLogAdd: 0x008DB070
    whileloop: 0x008DB385
    CUIStatusBar::m_aChatLog: 0x00BF1100



Advertisement