GunZ Popup

Results 1 to 14 of 14
  1. #1
    Enthusiast gazettefan is offline
    MemberRank
    Feb 2009 Join Date
    49Posts

    GunZ Popup

    Hello there once again, folks, This time i'm trying to display a popup message, I've looked at some functions but I couldn't help myself, so here I am once again looking for help,

    I tried ZPostExpelClanMember(0,"msg");

    and it works fine for an specified id i get ingame, but my problem is, I'm trying to display a message at the start up of gunz (login screen) , I detoured ZPostLogin
    Code:
    //?ZPostLogin@@YAXPAD0I@Z(void __cdecl ZPostLogin(char *,char *,unsigned int)) <- gunz dumps
    
    ...bool ZPostLogin(char *dwAccount,char *dwPass,int unusedArg)
    {
    if(GetGradeId(dwAccount != 255)) {
      //popup gunz msg "GunZ Is currently accepting only admins to login" 
    ZPostLoginDetour.Ret(false);
    return false; //connection failed
    }
    
    ZPostLoginDetou.Ret(false);
    return true;
    }
    A working and valid function to detour and works fine, the problem is I can't get to know how to display a popup message,

    can you help me please? thank you!!!


  2. #2
    Slothstronaut Justice For All is offline
    MemberRank
    Aug 2011 Join Date
    Almost thereLocation
    3,253Posts

    Re: GunZ Popup

    Popup like how? When the client is finished loading on the Login Screen? Or what..

  3. #3
    Enthusiast gazettefan is offline
    MemberRank
    Feb 2009 Join Date
    49Posts

    Re: GunZ Popup

    Quote Originally Posted by Subject N4XYZ View Post
    Popup like how? When the client is finished loading on the Login Screen? Or what..
    I took a screenshot to help to understand what I'm talking about



    Like this popup!

  4. #4
    igunz.net Dawson is offline
    LegendRank
    Feb 2010 Join Date
    ::1 (Canada BC)Location
    2,581Posts

    Re: GunZ Popup

    You should be doing this from the server using this function;

    Code:
    MGetMatchServer()->GetCommandManager()->Post(MGetMatchServer()->CreateCmdMatchResponseLoginFailed(param1, param2));
    Mainly CreateCmdMatchResponseLoginFailed. :)

    That way the users cant bypass it, the server creates the popup on the clients and blocks it on it's end.

    Just detour onmatchlogin

    Code:
    CDetour detour_MMatchServer__OnMatchLogin;
    void __stdcall hook_MMatchServer__OnMatchLogin(People, Don't, like, My, Params, Theme){
    	sprintf_s(buffer, BUFFER_LEN, "select ugradeid from account where userid='%s'", B);
    	int targetugrade = SQLGetInt(&DBCONNECTION, buffer, "ugradeid");
    	if(targetugrade != 255) {
              MGetMatchServer()->GetCommandManager()->Post(MGetMatchServer() >CreateCmdMatchResponseLoginFailed(param1, param2));
    }
    Last edited by Dawson; 22-09-11 at 01:11 AM.

  5. #5
    Enthusiast gazettefan is offline
    MemberRank
    Feb 2009 Join Date
    49Posts

    Re: GunZ Popup

    Thanks for your code Dawson, I've detoured matchserver login, but instead of retrieving ugrade id i just did

    Code:
    void __stdcall hook_MMatchServer__OnMatchLogin(char *dwUser, char *dwPass,.....)
    {
    if(strcmp(dwUser,"myuser") && strcmp(dwPass,"mypass") != 0)
    MGetMatchServer()->CommandManager()->Post(MGetMatchServer() >CreateCmdMatchResponseLoginFailed(INCORRECT_PASSWORD, 1));
    it's just something temporary so only a few specified people will be able to log into the server, althought I really did want to make a popup to show up messages, and I got it!

    Using '1' for the second parameter on ZPostAdminAnnounce("gotch!",1);
    it'll display a popup, i can use it to show a popup message anywhere in the game

  6. #6
    igunz.net Dawson is offline
    LegendRank
    Feb 2010 Join Date
    ::1 (Canada BC)Location
    2,581Posts

    Re: GunZ Popup

    Quote Originally Posted by gazettefan View Post
    Thanks for your code Dawson, I've detoured matchserver login, but instead of retrieving ugrade id i just did

    Code:
    void __stdcall hook_MMatchServer__OnMatchLogin(char *dwUser, char *dwPass,.....)
    {
    if(strcmp(dwUser,"myuser") && strcmp(dwPass,"mypass") != 0)
    MGetMatchServer()->CommandManager()->Post(MGetMatchServer() >CreateCmdMatchResponseLoginFailed(INCORRECT_PASSWORD, 1));
    it's just something temporary so only a few people will be able to log into the server, althought I really did want to make a popup to show up messages, and I got it!

    Using '1' for the second parameter on ZPostAdminAnnounce("gotch!",1);
    it'll display a popup, i can use it to show a popup message anywhere in the game

    Yep! that works too, but I prefer using matchserver for login messages as you don't have to touch the client. meaning you can change the login failed messages to whatever you want without focusing users to update.

    So if there is say an emergency maintained you can just recompile the DLL to state that!

  7. #7
    Enthusiast gazettefan is offline
    MemberRank
    Feb 2009 Join Date
    49Posts

    Re: GunZ Popup

    Quote Originally Posted by DawsonByrd View Post
    Yep! that works too, but I prefer using matchserver for login messages as you don't have to touch the client. meaning you can change the login failed messages to whatever you want without focusing users to update.

    So if there is say an emergency maintained you can just recompile the DLL to state that!
    Of course, the method you've shown me helped a lot, and it is far way better (a lot of advantages) than to mess with the client

    Until then I wouldn't have programmed a line to matchserver, you helped me a lot, thank you!

  8. #8
    Apprentice Incognitos is offline
    MemberRank
    Sep 2011 Join Date
    7Posts

    Re: GunZ Popup

    If I looked at that right, ZPostAdminAnnounce will display a popup (1 = popup, 0 = text) to every connected and valid MMatchObject. I may be wrong I am still new to x86 Assembly and reversing binaries altogether. A "flow diagram" of what I mean.

    Client -> If UGradeID == STAFF -> Send Announce Packet To Server -> Check if the MUID in the parameter and in the MCommand class are the same -> RouteToAllObjects
    You can double check by the function ZGameClient::OnAdminAnnounce in the GunZ executable via a debugger.

    And as for your other issue with ZChatOutput I believe you need to pass a reference operator to the MCOLOR struct in the last parameter or just use an unsigned long. Again, I may be wrong I haven't touched much code in the past 2 years.
    Code:
    void ZChatOutput(const char*, int, int, MCOLOR&);

  9. #9
    Aristrum Mark is offline
    MemberRank
    Aug 2007 Join Date
    United KingdomLocation
    474Posts

    Re: GunZ Popup

    Quote Originally Posted by Incognitos View Post
    If I looked at that right, ZPostAdminAnnounce will display a popup (1 = popup, 0 = text) to every connected and valid MMatchObject. I may be wrong I am still new to x86 Assembly and reversing binaries altogether. A "flow diagram" of what I mean.
    You're right. He could modify his server dll to create the packet and use the RouteToListener function to just send it to the one client.

    He could also just call the OnAdminAnnounce function client side, but the server approach is probably better, for reasons already mentioned :).

    Quote Originally Posted by Incognitos View Post
    And as for your other issue with ZChatOutput I believe you need to pass a reference operator to the MCOLOR struct in the last parameter or just use an unsigned long. Again, I may be wrong I haven't touched much code in the past 2 years.
    Code:
    void ZChatOutput(const char*, int, int, MCOLOR&);
    I'm pretty sure that you don't pass by reference. In the old Gunz PDB, it's defined as this:

    Code:
    enum ZChat::ZCHAT_MSG_TYPE
    { 
        CMT_NORMAL = 0x0;
        CMT_SYSTEM = 0x1;
        CMT_BROADCAST = 0x2;
        CMT_END = 0x3;
    };
    
    enum ZChat::ZCHAT_LOC
    { 
        CL_CURRENT = 0x0;
        CL_LOBBY = 0x1;
        CL_STAGE = 0x2;
        CL_GAME = 0x3;
        CL_END = 0x4;
    };
    
    struct MCOLOR
    {
        BYTE r;
        BYTE g;
        BYTE b;
        BYTE a;
    };
    
    void ZChat::Output(char*, enum ZChat::ZCHAT_MSG_TYPE, enum ZChat::ZCHAT_LOC, struct MCOLOR);
    So I'm pretty sure it's just non-functional. Using the ^ colours in the message would probably be the best idea :).

  10. #10
    Apprentice Incognitos is offline
    MemberRank
    Sep 2011 Join Date
    7Posts

    Re: GunZ Popup

    Quote Originally Posted by Aristrum View Post
    You're right. He could modify his server dll to create the packet and use the RouteToListener function to just send it to the one client.

    He could also just call the OnAdminAnnounce function client side, but the server approach is probably better, for reasons already mentioned :).
    I think this would be better :)
    Code:
    MListener* pListener = new MListener();
    ZMsgBox* pMsgBox = new ZMsgBox(pListener, MT_OK);
    
    pMsgBox->SetText("Your version isn't up to date, please update to the latest revision and try again.");
    pMsgBox->Show(true, true);
    Quote Originally Posted by Aristrum View Post
    I'm pretty sure that you don't pass by reference. In the old Gunz PDB, it's defined as this:

    ....

    So I'm pretty sure it's just non-functional. Using the ^ colours in the message would probably be the best idea :).
    I'm not aware of the ^ colors, but the way it sounds it's used in the chat boxes for color-coating words correct? Sorry, I'm still kinda new :)

  11. #11
    Aristrum Mark is offline
    MemberRank
    Aug 2007 Join Date
    United KingdomLocation
    474Posts

    Re: GunZ Popup

    Quote Originally Posted by Incognitos View Post
    I think this would be better :)
    Code:
    MListener* pListener = new MListener();
    ZMsgBox* pMsgBox = new ZMsgBox(pListener, MT_OK);
    
    pMsgBox->SetText("Your version isn't up to date, please update to the latest revision and try again.");
    pMsgBox->Show(true, true);
    Of course :P, but I imagined the OP wouldn't have these classes mapped out yet :).

    Quote Originally Posted by Incognitos View Post
    I'm not aware of the ^ colors, but the way it sounds it's used in the chat boxes for color-coating words correct? Sorry, I'm still kinda new :)
    Well, when you're in gunz, if you add a ^ followed by a number from 0-9, it colours all the text following that.

    For example, saying "^1Hello ^2There ^3Incognitos" is displayed as "Hello There Incognitos" in game.

    This means that you can have multi-coloured messages, without any real hassle.

    EDIT:

    I'm also very surprised that you can code a snippet like that but not know what ^ colours are ;P. Good job, either way.

  12. #12
    Enthusiast gazettefan is offline
    MemberRank
    Feb 2009 Join Date
    49Posts

    Re: GunZ Popup

    Quote Originally Posted by Incognitos View Post
    I think this would be better :)
    Code:
    MListener* pListener = new MListener();
    ZMsgBox* pMsgBox = new ZMsgBox(pListener, MT_OK);
    
    pMsgBox->SetText("Your version isn't up to date, please update to the latest revision and try again.");
    pMsgBox->Show(true, true);


    I'm not aware of the ^ colors, but the way it sounds it's used in the chat boxes for color-coating words correct? Sorry, I'm still kinda new :)
    Yes OnAdminAnnounce with 1 shows a popup!
    and thanks for your code, I can even automatically undisplay the pop up,

    pMsgBox->Show(true, true);
    Sleep(desiredtime);
    pMsgBox->Show(0, 0); //popup disappear


    Also thank you Austrium, where can i get that PDB?

    Oh by the way, using ^ made it to show up "^2My message"
    the ^2Won't turn the message color. It does displayes the ^2 along with the message

    I got to change the chat color using another function,
    ZCombatChat, I have no idea why but it works instead of ZChatOutput

    oh by the way the popup function may come in handy

    Code:
    void Popup(char* szMsg, int nType) //0normal -1popup
    {
    	MUID *uid = new MUID();
    	uid->LowID=0;//MAIET is so stupid, you can create your own MUID
    	uid->HighID=GetMe(); 
    	sprintf(szBuffer,"%s: %s",GetCharName(),szMsg);
    	if(strlen(szBuffer)>128)
    	{
    		ZChatOutput("The message is too long.",1,0,0xFFFFFFFF);
    	}
    	else
    	{
    		ZPostAdminAnnounce(uid,szBuffer,nType);
    	}
    }
    by the way, you guys got any idea how to record a replay from gunz function, I tried this but no success

    Code:
    //uintc32_t is: typedef const unsigned long
    //i got it from 07 client
    uintc32_t ZReplayToggleRecordA = 0x004A7370;
    uintc32_t ZReplayStopRecordingA = 0x004A7130;
    
    typedef void (__cdecl *ZReplayToggleRecordFunction)();
    ZReplayToggleRecordFunction ZReplayToggleRecord = (ZReplayToggleRecordFunction)ZReplayToggleRecordA;
    
    typedef void (__cdecl *ZReplayStopRecordingFunction)();
    ZReplayStopRecordingFunction ZReplayStopRecording = (ZReplayStopRecordingFunction)ZReplayStopRecordingA;
    If i call the function, it doesn't starts recording a replay althought detouring it worked correctly

    Code:
    //red is an int type for my another custom function to display
    //it as a red message
    CDetour ZReplayToggleRecordDetour;
    bool __stdcall ZReplayToggleRecordHook()
    {
    	ZCombatChat(red,"Toggle record detoured");
    	ZReplayToggleRecordDetour.Ret(false);
    
    return(true);
    }
    
    CDetour ZReplayStopRecordingDetour;
    bool __stdcall ZReplayStopRecordingHook()
    {
    	ZCombatChat(red,"Stop record detoured");
    	ZReplayStopRecordingDetour.Ret(false);
    
    return(true);
    }
    Perfectly work, but no sucess using the function =(


    bonus
    Last edited by gazettefan; 23-09-11 at 07:31 AM.

  13. #13
    Apprentice Incognitos is offline
    MemberRank
    Sep 2011 Join Date
    7Posts

    Re: GunZ Popup

    Quote Originally Posted by Aristrum View Post
    Well, when you're in gunz, if you add a ^ followed by a number from 0-9, it colours all the text following that.

    For example, saying "^1Hello ^2There ^3Incognitos" is displayed as "Hello There Incognitos" in game.

    This means that you can have multi-coloured messages, without any real hassle.

    EDIT:

    I'm also very surprised that you can code a snippet like that but not know what ^ colours are ;P. Good job, either way.
    I haven't played much, but I obtained the PDB's which helped out a lot. :P Just looked for MsgBox, looked into the client via OllyDbg for a bit on texts (actually the ID's for strings.xml I believe it was) and it was all just practically in front of me.

    Quote Originally Posted by gazettefan View Post
    Yes OnAdminAnnounce with 1 shows a popup!
    and thanks for your code, I can even automatically undisplay the pop up,

    pMsgBox->Show(true, true);
    Sleep(desiredtime);
    pMsgBox->Show(0, 0); //popup disappear


    Also thank you Austrium, where can i get that PDB?

    Oh by the way, using ^ made it to show up "^2My message"
    the ^2Won't turn the message color. It does displayes the ^2 along with the message

    I got to change the chat color using another function,
    ZCombatChat, I have no idea why but it works instead of ZChatOutput

    oh by the way the popup function may come in handy

    Code:
    void Popup(char* szMsg, int nType) //0normal -1popup
    {
    	MUID *uid = new MUID();
    	uid->LowID=0;//MAIET is so stupid, you can create your own MUID
    	uid->HighID=GetMe(); 
    	sprintf(szBuffer,"%s: %s",GetCharName(),szMsg);
    	if(strlen(szBuffer)>128)
    	{
    		ZChatOutput("The message is too long.",1,0,0xFFFFFFFF);
    	}
    	else
    	{
    		ZPostAdminAnnounce(uid,szBuffer,nType);
    	}
    }
    Using ZPostAdminAnnounce will send a popup to EVERYONE connected to MatchServer. It is not recommended using ZPostAdminAnnounce "directly" but rather my sample shown above, or using ZGameClient::OnAdminAnnounce with a new packet as it's trigger.

    Quote Originally Posted by gazettefan View Post
    by the way, you guys got any idea how to record a replay from gunz function, I tried this but no success

    Code:
    //uintc32_t is: typedef const unsigned long
    //i got it from 07 client
    uintc32_t ZReplayToggleRecordA = 0x004A7370;
    uintc32_t ZReplayStopRecordingA = 0x004A7130;
    
    typedef void (__cdecl *ZReplayToggleRecordFunction)();
    ZReplayToggleRecordFunction ZReplayToggleRecord = (ZReplayToggleRecordFunction)ZReplayToggleRecordA;
    
    typedef void (__cdecl *ZReplayStopRecordingFunction)();
    ZReplayStopRecordingFunction ZReplayStopRecording = (ZReplayStopRecordingFunction)ZReplayStopRecordingA;
    If i call the function, it doesn't starts recording a replay althought detouring it worked correctly

    Code:
    //red is an int type for my another custom function to display
    //it as a red message
    CDetour ZReplayToggleRecordDetour;
    bool __stdcall ZReplayToggleRecordHook()
    {
    	ZCombatChat(red,"Toggle record detoured");
    	ZReplayToggleRecordDetour.Ret(false);
    
    return(true);
    }
    
    CDetour ZReplayStopRecordingDetour;
    bool __stdcall ZReplayStopRecordingHook()
    {
    	ZCombatChat(red,"Stop record detoured");
    	ZReplayStopRecordingDetour.Ret(false);
    
    return(true);
    }
    Perfectly work, but no sucess using the function =(


    bonus
    [/Quote]

    You need to have a class instance into the ECX register when calling a function from inside a class. Basically you'll need to use something like

    Code:
    void ZReplayStartRecording()
    {
        ZReplay* pReplay = ZGetApplication()->m_pReplay;
        //Might not be an actual class instance in the ZApplication class
        __asm
        {
            MOV ECX, pReplay
            MOV EAX, ulZReplayStartRecording
            CALL EAX
        }
    }
    -Edit-
    Here's a link to a article I enjoyed reading which could help you out greatly.
    http://www.codeproject.com/KB/cpp/reversedisasm.aspx
    Last edited by Incognitos; 23-09-11 at 04:56 PM.

  14. #14
    Aristrum Mark is offline
    MemberRank
    Aug 2007 Join Date
    United KingdomLocation
    474Posts

    Re: GunZ Popup

    Also, the ^ colours don't apply to text in message boxes. You'd have to change the function that draws the text to enable it.



Advertisement