Post Pacific

Post Pacific (https://postpacific.mmorpg-game.online/index.php)
-   Lineage 2 Server Modifications ONLY! (https://postpacific.mmorpg-game.online/forumdisplay.php?f=28)
-   -   [share]void SendMacroList() (https://postpacific.mmorpg-game.online/showthread.php?t=4729)

torune 06.06.2006 16:40

[share]void SendMacroList()
 
this only gives you single macro, but at least you have something eh

its a part of code from my old l2ext.dll(junk project which was started around half years ago and it ends because somebody hacked into my server, stole all my script/geodata and ofcoz server files, lol).

messy crappy code :P

how it works?

client sends add/edit macro list, it just dummy reply with same data.

not really easy to understand what i wrote, but can be a good start if you wanna get your own dll.
Code:


void SendMacroList(){       
        __asm pushad;
        string _sfFormat;
        BYTE *pData;
        wchar_t *pName;
        wchar_t *pDesc;
        wchar_t *pAcronym;
        LPBYTE dwIcon;
        LPBYTE dwLength;
        int count;
        int i;
        int stackCount = 52;
        DWORD pUser;
        __asm{
                LEA EDX,DWORD PTR DS:[EBX+ESI+0X11];
                mov pData,EDx;
                mov pUser,EDI;
        }
        pData +=4;
        pName = (wchar_t*)pData;
        pData += (wcslen(pName)*2 + 2);
        pDesc = (wchar_t*)pData;
        pData += (wcslen(pDesc)*2 + 2);
        pAcronym = (wchar_t*)pData;
        pData += (wcslen(pAcronym)*2 + 2);
        dwIcon = pData;
        pData ++;
        dwLength = pData;
        pData ++;
        count = *dwLength;
        _sfFormat += _sfMacroString_a;
        _sfFormat += _sfMacroString_b;
        for (i=0; i < count; i++) {
                _sfFormat += _sfMacroString_c;
        }
        for (i=1; i <= count; i++) {
                LPBYTE pEntry;
                LPBYTE pType;
                LPDWORD pD1;
                LPBYTE pD2;
                wchar_t *pCommand;
                stackCount +=20;
                pEntry = pData;
                pData++;
                pType = pData;
                pData++;
                pD1 = (LPDWORD)pData;
                pData+=4;
                pD2 = pData;
                pData++;
                pCommand = (wchar_t*)pData;
                pData += (wcslen(pCommand)*2 + 2);
                __asm{
                        mov eax, pCommand
                        push eax; //s

                        mov eax, pD2
                        push DWORD PTR[eax]; //c

                        mov eax, pD1
                        push DWORD PTR[eax]; //d

                        mov eax, pType
                        push DWORD PTR[eax]; //c

                        push DWORD PTR[i]; //c
                }               
        }
        __asm{
                mov eax, dwLength
                push DWORD PTR[eax]; //c
                mov eax, dwIcon
                push DWORD PTR[eax]; //c
                mov eax, pAcronym
                push eax; //s
                mov eax, pDesc
                push eax; //s
                mov eax, pName
                PUSH eax; //s
                PUSH 0; //D
                push 1; //C
                push 1; //C
                push 0; //C
                push 1;        //D
                PUSH 0x110;
                mov eax, dword ptr[ebp-0x50]//_sfFormat;
                push eax;
                push pUser;
                CALL _fnSendToSinglePlayer;
                ADD ESP,stackCount;
                __asm popad;
        }
}


torune 06.06.2006 17:48

hmm, no replys, interesting

poplo8 06.06.2006 17:52

表示同情!

top-gear 06.06.2006 17:57

i would personally prefer a reply at my pm:)

toolpunk 06.06.2006 18:02

you really get me scared :|
this looks like something good, but unfortunately i hardly understand the code :cry:
seems i have to learn asm when i get some more time.
maybe during the summer holidays...
'cause now i don't make a lot of progress. i started reading the "Art of Assembly" about a month ago and currently i'm on page 47 which ain't a lot facing this book has more than 1k pages T_T

torune 06.06.2006 18:23

Quote:

Originally Posted by poplo8
表示同情!

我干吗这么傻逼帮老外啊,自作孽不å� ¯活
嗷嗷后悔, 以后不贴了, 继续玩魔兽世界

Grillo 06.06.2006 18:26

Sorry to interupt your little chat and hijack your thread but:
9.) Posting language
We only allow english post, so if you can't write it use a translator (http://babelfish.altavista.com/). You guys can post it in both languages, russian/english, spanish/english, whatever/english but always leave a english version with it.

torune 06.06.2006 18:37

i do not give a damn
and
i do know the rule
and
i dont care
and
if mod want to, feel free to ban/warnning me

mcrabben7 06.06.2006 19:34

Thanks for the share Torune. If I continue my own project I will probably use this.

zcold 06.06.2006 19:48

Quote:

Originally Posted by torune
i do not give a damn
and
i do know the rule
and
i dont care
and
if mod want to, feel free to ban/warnning me

and
я - Д'Артаньян, а вы - личеры. Хуй забаните!

Sounds good, let's all do like you ;)

RipperX 06.06.2006 22:52

Interesting, can u do a dll source with this func. ? Just for view a dll base code of L2.

Thx 4 all.

torune 07.06.2006 00:18

/offtopic:
if you spend hundreds times to load up l2server, viewing the memory stack and check the dll's asm code in ollydbg, thats what i do at the beginning.

/ontopic:
are you blind? its dll source code

RipperX 07.06.2006 01:08

i'm not blind torune, i say a "complete" source. only compile. I don't know how programm a l2server dll file.
thx again, i don't want distorb u.

tpuNIsher 07.06.2006 04:35

viva la revolution!
The question is :> Did you manage more than one? :P


And yah awesome ting :P
Makes me wonder how much is your experience in asm...

Mesgabalis 07.06.2006 05:49

Thanks man, you're a light in the tunnel :D

Off:
我们是感激的为什么您。我是外国人å’ Œ开始开发我自己的图书馆。您的代码æ ˜¯一件好事学会并且我了解大多数。很 快我将分享一些来源如果一切将工作å¾ —好

testdude 07.06.2006 12:15

well, for those who are interested in making their own dll's, i got some stuff too ;o
Code:

int RequestMakeMacroPacket(DWORD hSocket, unsigned char* hBuffer)
{
        DWORD id;
        unsigned char icon;
        unsigned char count;
        wchar_t name[255];
        wchar_t desc[255];
        wchar_t acr[255];

        unsigned char buf[4095];
        unsigned char entry;
        unsigned char type;
        DWORD skill;
        unsigned char shortcut;
        wchar_t cmd[1023];
        bool bEditMode = false;

        MACRO *pMacroAux;

        int charId = GetCharIDFromSocket(hSocket);
        if (charId == NULL)
                return 1;

        Disassemble(hBuffer, FMT_REQUEST_MAKE_MACRO_MAIN, &id, 64, name, 64, desc, 64, acr, &icon, &count, 4095, buf);
       

        unsigned short i;
        for (i = 0; i < pInfoTable[charId]->macro_list.size(); i++)
        {
                if (pInfoTable[charId]->macro_list[i]->id == id)
                {
                        bEditMode = true;

                        break;
                }
        }

        pInfoTable[charId]->macro_rev++;

        if (bEditMode)
                pMacroAux = pInfoTable[charId]->macro_list[i];
        else
                pMacroAux = (MACRO *)malloc(sizeof(MACRO));
 
        pMacroAux->id = id;
        pMacroAux->count = count;
        pMacroAux->icon = icon;

        if (bEditMode)
        {
                pMacroAux->name = (wchar_t *)realloc(pMacroAux->name, (wcslen(name)+2) * sizeof(wchar_t));
                pMacroAux->desc = (wchar_t *)realloc(pMacroAux->desc, (wcslen(desc)+2) * sizeof(wchar_t));
                pMacroAux->acr = (wchar_t *)realloc(pMacroAux->acr, (wcslen(acr)+2) * sizeof(wchar_t));
        }       
        else
        {
                pMacroAux->name = (wchar_t *)malloc((wcslen(name)+2) * sizeof(wchar_t));
                pMacroAux->desc = (wchar_t *)malloc((wcslen(desc)+2) * sizeof(wchar_t));
                pMacroAux->acr = (wchar_t *)malloc((wcslen(acr)+2) * sizeof(wchar_t));
        }

        wcscpy(pMacroAux->name, name);
        wcscpy(pMacroAux->desc, desc);
        wcscpy(pMacroAux->acr, acr);

        if (bEditMode)
        {
                for (short j = 0; j < pMacroAux->count; j++)
                        free(pMacroAux->cmds[j].cmd);

                free(pMacroAux->cmds);
        }

        pMacroAux->cmds = (MACRO_CMD *)malloc(sizeof(MACRO_CMD)*count);

        size_t x = 0;
        for (short i = 0; i < count; i++)
        {
                Disassemble(buf + x, FMT_REQUEST_MAKE_MACRO_ELEM, &entry, &type, &skill, &shortcut, 1023, cmd);

                pMacroAux->cmds[i].cmd = (wchar_t *)malloc((wcslen(cmd)+2) * sizeof(wchar_t));
                wcscpy(pMacroAux->cmds[i].cmd, cmd);
               
                pMacroAux->cmds[i].id = id;
                pMacroAux->cmds[i].shortcut = shortcut;
                pMacroAux->cmds[i].skill = skill;
                pMacroAux->cmds[i].type = type;
               
                x += ((wcslen(cmd) + 1)*sizeof(wchar_t) + 1 + 1 + 4 + 1);
        }

        if (!bEditMode)
                pInfoTable[charId]->macro_list.push_back(pMacroAux);

        SendMacroList(charId);

        return 0;
}

its part of an old project i was working on with some friends that kinda died as the lead coder went MIA >.> 100% C++, no ASM cos i hate it, pInfoTable struct contains main info needed about a char, stored by charid for easy lookup if anyone was wondering :P hope it helps someone ^.^

RipperX 07.06.2006 12:25

Quote:

Originally Posted by testdude
well, for those who are interested in making their own dll's, i got some stuff too ;o
Code:

int RequestMakeMacroPacket(DWORD hSocket, unsigned char* hBuffer)
{
        DWORD id;
        unsigned char icon;
        unsigned char count;
        wchar_t name[255];
        wchar_t desc[255];
        wchar_t acr[255];

        unsigned char buf[4095];
        unsigned char entry;
        unsigned char type;
        DWORD skill;
        unsigned char shortcut;
        wchar_t cmd[1023];
        bool bEditMode = false;

        MACRO *pMacroAux;

        int charId = GetCharIDFromSocket(hSocket);
        if (charId == NULL)
                return 1;

        Disassemble(hBuffer, FMT_REQUEST_MAKE_MACRO_MAIN, &id, 64, name, 64, desc, 64, acr, &icon, &count, 4095, buf);
       

        unsigned short i;
        for (i = 0; i < pInfoTable[charId]->macro_list.size(); i++)
        {
                if (pInfoTable[charId]->macro_list[i]->id == id)
                {
                        bEditMode = true;

                        break;
                }
        }

        pInfoTable[charId]->macro_rev++;

        if (bEditMode)
                pMacroAux = pInfoTable[charId]->macro_list[i];
        else
                pMacroAux = (MACRO *)malloc(sizeof(MACRO));
 
        pMacroAux->id = id;
        pMacroAux->count = count;
        pMacroAux->icon = icon;

        if (bEditMode)
        {
                pMacroAux->name = (wchar_t *)realloc(pMacroAux->name, (wcslen(name)+2) * sizeof(wchar_t));
                pMacroAux->desc = (wchar_t *)realloc(pMacroAux->desc, (wcslen(desc)+2) * sizeof(wchar_t));
                pMacroAux->acr = (wchar_t *)realloc(pMacroAux->acr, (wcslen(acr)+2) * sizeof(wchar_t));
        }       
        else
        {
                pMacroAux->name = (wchar_t *)malloc((wcslen(name)+2) * sizeof(wchar_t));
                pMacroAux->desc = (wchar_t *)malloc((wcslen(desc)+2) * sizeof(wchar_t));
                pMacroAux->acr = (wchar_t *)malloc((wcslen(acr)+2) * sizeof(wchar_t));
        }

        wcscpy(pMacroAux->name, name);
        wcscpy(pMacroAux->desc, desc);
        wcscpy(pMacroAux->acr, acr);

        if (bEditMode)
        {
                for (short j = 0; j < pMacroAux->count; j++)
                        free(pMacroAux->cmds[j].cmd);

                free(pMacroAux->cmds);
        }

        pMacroAux->cmds = (MACRO_CMD *)malloc(sizeof(MACRO_CMD)*count);

        size_t x = 0;
        for (short i = 0; i < count; i++)
        {
                Disassemble(buf + x, FMT_REQUEST_MAKE_MACRO_ELEM, &entry, &type, &skill, &shortcut, 1023, cmd);

                pMacroAux->cmds[i].cmd = (wchar_t *)malloc((wcslen(cmd)+2) * sizeof(wchar_t));
                wcscpy(pMacroAux->cmds[i].cmd, cmd);
               
                pMacroAux->cmds[i].id = id;
                pMacroAux->cmds[i].shortcut = shortcut;
                pMacroAux->cmds[i].skill = skill;
                pMacroAux->cmds[i].type = type;
               
                x += ((wcslen(cmd) + 1)*sizeof(wchar_t) + 1 + 1 + 4 + 1);
        }

        if (!bEditMode)
                pInfoTable[charId]->macro_list.push_back(pMacroAux);

        SendMacroList(charId);

        return 0;
}

its part of an old project i was working on with some friends that kinda died as the lead coder went MIA >.> 100% C++, no ASM cos i hate it, pInfoTable struct contains main info needed about a char, stored by charid for easy lookup if anyone was wondering :P hope it helps someone ^.^

Amazing, MACRO struct is defined inside L2Server ?
thx in advance.

testdude 07.06.2006 12:47

Code:

typedef struct __MACRO
{
        short id;
        short icon;
        wchar_t* name;
        wchar_t* desc;
        wchar_t* acr;
        short count;
        MACRO_CMD* cmds;
} MACRO;


torune 07.06.2006 17:09

i wonder what's in pInfoTable lol

testdude 07.06.2006 17:21

Quote:

Originally Posted by torune
i wonder what's in pInfoTable lol

well...
Code:

typedef struct INFOEXT
{
        long        sid;
        long        XCoord;
        long        YCoord;
        long        ZCoord;
        long        HairObjectId;
        long        HairItemId;
        long        HairSid;
        long        ClanPrivileges;
        long        Armory1;
        long        Armory2;
        long        Armory3;
        short        RecommendationsLeft;
        short        RecommendationsHave;
        short        MaxInventory;
        short        SpecialEffects;
        long        MaxCP;
        long        CurrentCP;
        short        TeamCircle;
        short        Level;
        char        Class;
        DWORD        Socket;
        char        Hero;
        char        FishingMode;
        long        NameColor;
        short        stat_str;
        short        stat_dex;
        short        stat_con;
        short        stat_int;
        short        stat_wit;
        short        stat_men;

        char        UserMsgSent;
        char        MacroListLoaded;

        short*        pstat_str;
        short*        pstat_dex;
        short*        pstat_con;
        short*        pstat_int;
        short*        pstat_wit;
        short*        pstat_men;

        wchar_t* Name;

        unsigned long        macro_rev;
        vector<MACRO *>  macro_list;

} UCINFOEXT;

thats what xD and i know ur gonna ask whats with the storing of stats, well, it was for a beta of henna, cos we never kinda figured out how to get the userinfo struct from l2server in C++... so work on henna kinda stopped....

torune 07.06.2006 18:28

.........you guys even put TeamCircle?.........
wow, thats something i didnt expect

torune 07.06.2006 18:34

i guess most stuff are the same
Code:

        DWORD HairslotItemId;
        DWORD HairslotObjectId;
        DWORD dwArmory[3];
        DWORD RecomHave;
        DWORD RecomLeft;
        DWORD CurrentCp;
        DWORD MaxCp;
        DWORD oldX;
        DWORD oldY;
        DWORD oldZ;
        DWORD ClanPrivileges;
        DWORD nRecipeBook;
        DWORD AllowedRecipeBook;
        DWORD CraftCustomer;
        DWORD nCreateList;
        wchar_t * pRecipeShopName;
        bool * MacroList;
        int SoulShot;
        int SpiritShot;       
        bool isHero;                //if hero

the userinfo struct in l2sesrver is not easy to understand, i only get 70% out of it, may be some people have more. but they are good for me already.

testdude 07.06.2006 19:31

yeah... i was gonna do a builder cmd to change team for events n stuff, was just a little something we had never seen on another server :P with the userinfo struct... we just never figured out how to get it.... the pointer to it that was sent to some functions was never the same for the same person, i never had a chance to do any looking around with it though so i dont know if theres any specific function to call that returns the pointer to it...

also, we hooked the call to the send function for char/userinfo packets, instead of hooking the function from the dword table, simply because it was easyer than having to retrieve the info from the struct sent to the char/userinfo functions, though now im starting to think that it may have been wise to do that instead, as i wouldnt need to find out how to get the userinfo struct cos it would be sent to the func for me xD

Aikeleer 07.06.2006 20:37

Hmm, thanks, I'm beginning to understand more what you guys are doing. :) Thanks both Torune and Testdude.

Alien003 07.06.2006 22:37

Quote:

Originally Posted by testdude
yeah... i was gonna do a builder cmd to change team for events n stuff, was just a little something we had never seen on another server :P with the userinfo struct... we just never figured out how to get it.... the pointer to it that was sent to some functions was never the same for the same person, i never had a chance to do any looking around with it though so i dont know if theres any specific function to call that returns the pointer to it...

also, we hooked the call to the send function for char/userinfo packets, instead of hooking the function from the dword table, simply because it was easyer than having to retrieve the info from the struct sent to the char/userinfo functions, though now im starting to think that it may have been wise to do that instead, as i wouldnt need to find out how to get the userinfo struct cos it would be sent to the func for me xD

at the start of any User:: function the ECX is always the user struct


All times are GMT. The time now is 23:27.