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)
-   -   [Tutorial?][HEX] Adding new crystal_type to itemdata (https://postpacific.mmorpg-game.online/showthread.php?t=2256)

Livid 17.10.2005 16:36

[Tutorial?][HEX] Adding new crystal_type to itemdata
 
First, I don't know how you can find that. It is just luck or skill or both. I will just explain what do you need to change and why do you need to change that.

Task: add new crystal_type property value. Just add. Nothing more. Hex is a bit incomplete, ex. if you crush item with new cryst. type you will either get crash or bunch of no-crystal thing.

A bit of theory: Server parses all script files and stores them in memory. It stores those in rather... complex format, but most of properties are being saved as word or dword (since c works with numbers faster). There is a function, actually, that converts string assigned to property into numeric value. And it is resided in here : 00567840. So, all we need is to read this function carefully and understand what actually does it do. Consider that as your hometask. I will stop only on moments needed for our task.

Practice?
First, if you read that one carefuly, you can understand how it works. It checks on appropriate string in table and substitutes it with appropriate numeric value.
Also, it makes 80h cycles, meaning that it's for-loop.
This:
Code:

00567849  |.  BE 4C566C00  MOV ESI,L2server.006C564C
gives us a clue where the array (or table if you wish) resides. For those who did not understand, it's in .6C564C.
Second, what's length of our table item and its structure?
Code:

00567850  |> /396E FC      /CMP DWORD PTR DS:[ESI-4],EBP  ;check if table item is referenced to proerty field we have. Notice [esi-4]!
00567853  |. /75 14        |JNE SHORT L2server.00567869  ;if it's not, jump
00567855  |. |8B06          |MOV EAX,DWORD PTR DS:[ESI]  ;Get first element of table item to eax
00567857  |. |85C0          |TEST EAX,EAX ; Check if it's NULL
00567859  |. |74 1A        |JE SHORT L2server.00567875 ; if it is, break; exit; return error.
0056785B  |. |53            |PUSH EBX ;in [EBX] you have string from .txt
0056785C  |. |50            |PUSH EAX ;in EAX you have first element of table item
0056785D  |. |E8 4E350300  |CALL <L2server.cmpstr> ; it is standart VC++ compare string routine. Every hexer should recognize it from first sight. Consider it as your hometask.
00567862  |. |83C4 08      |ADD ESP,8 ; Shift Stack by 8 (2 values we pushed earlier)
00567865  |. |85C0          |TEST EAX,EAX ; Check if function returned NULL*
00567867  |. |74 16        |JE SHORT L2server.0056787F ; If it did, then strings are equal. Exit cycle.
00567869  |> \47            |INC EDI ; increment for-loop variable by one
0056786A  |.  83C6 10      |ADD ESI,10 ; add 10h to table pointer**
0056786D      81FF 80000000 CMP EDI,80 ; check if we've got for-loop variable = 80h
00567873  |.^ 72 DB        \JB SHORT L2server.00567850 ; if not, continue on cycle.

*According to stdcall and Ccall, function stores return value in EAX.
**Which means we increment table item pointer by one. Which means that one table item is 10h = 16 bytes long.

Now, let's see to code which is being executed when we got strings matched.
Code:

0056787F  |> \C1E7 04      SHL EDI,4 ;this actually means "divide EDI by 2^4 and take whole part" = [EDI/16]
00567882  |.  8B87 50566C00 MOV EAX,DWORD PTR DS:[EDI+6C5650] ;EDI+006C564C+4. Obviously, second element of item we exited on.
00567888  |.  8B97 54566C00 MOV EDX,DWORD PTR DS:[EDI+6C5654] ;Obviously, third element of item we exited on.

Then exit function in normal way.
This means that function returns two values in EAX and EDX. First one is dword value of string. Second... I don't know, but in this context it doesn't matter (if you're curious, look what is that in near of .568CB5. That's where this function is being called and EDI is being used).

So, we need
1) add new element to table in format:
(int field, PWideChar StringValue, int DwordValue, int Unknown=0)
2) Increase loop count by one.

Second is easy. Change
Code:

0056786D      81FF 80000000 CMP EDI,80
to
Code:

0056786D      81FF 80000000 CMP EDI,81
First is a bit harder. Just a bit.
I just added it at the end of table, like that:
Code:

006C5E48:  26000000 585E6C00 06000000 00000000
Which means:
int field = 26h (which is crystal_type)
PWideChar StringValue = 6C5E58 = UNICODE 'e'
int DwordValue = 6
int Unknown = 0

It is also possible to move table somewhere else, where is more space if you need it. In this case, we did not.
Well... I think that's all. Any feedback is welcomed.

Software
I usually get asked what soft do I use. I always answer, but it gets annoying, so I want to make it clear.
I use ollydbg 1.10 for debugging, often hexing, usually to post my hexes here.
I use Hex workshop to search for strings and cross-section references.
I use hiew to hex fast fixes in different versions of exes.

Stop. Nothing more.

wton 17.10.2005 17:03

thaks for help to comunity.. nice tutorial..

thanks again :)

demon 17.10.2005 19:26

Novice
change item 5789,5790,2369,10,6,2370
to crystal_type=e from crystal_type=none
now novice SS can be used only in starting weapons
also edit consume

Livid 18.10.2005 10:32

... Thought I'll bump this thread. Just in case.
166 views and 2 posts...
I fear people look and think: "I don't understand a word" and go out.

midnight 18.10.2005 10:55

woo coollll, thanks livid

Aikeleer 18.10.2005 11:50

Quote:

Originally Posted by demon
Novice
change item 5789,5790,2369,10,6,2370
to crystal_type=e from crystal_type=none
now novice SS can be used only in starting weapons
also edit consume

Why do you want to do that? It works for all no-grade weapons on retail...

bwgreen 18.10.2005 12:14

Starter weapons use soulshot_none_for_rookie etc. I believe he's trying to allow them to use these or something.

Aikeleer 18.10.2005 12:26

Starter weapons use no grade soulshots, the soulshot_none_for_rookie are the same as no grade soulshots, but they just don't weigh as much and you get them with quests. There is no difference in crystal_type on retail; you can use the rookie soulshots with i.e. a comp bow if you'd like. ;)

Livid 18.10.2005 12:35

I belive you can use rookie soulshots/spiritshots only with limited ammount of weapons. Specifically with some of weapons that do not use normal soulshots/spss.
And you get rookie SS only for tutorial quest (as a part of tutorial actually) that was the point.

bwgreen 18.10.2005 14:13

ty for clarifying

torune 18.10.2005 16:36

wow, nice hex livid

torune 25.12.2005 01:58

For some people this might be useful, just finished a dll to do it automaticly
i dont gurantee the code works :)
Code:

//ITEMDATA
typedef struct{       
        DWORD field;
        LPWSTR string;
        DWORD value;
        DWORD empty;
} ITEMDATA, *LPITEMDATA;

void copyBlock(LPDWORD destination, const DWORD* source, int _size)
{
        for(int i=_size>>2;--i>=0;) {
                *destination = *source;
                destination += 4;
                source += 4;
        }
}

void replaceByte(LPDWORD destination, BYTE data)
{
        *destination = data;
}

L2EXT_API void parseItemData()
{
        int ItemDataType
        LPITEMDATA _lpDwords;
        LPITEMDATA _lpCopy = new ITEMDATA();
        LPDWORD _lpCounter;
        __asm
        {
                mov _lpDwords, 0x6C5E48;
                mov _lpCounter, 0x56786F;
                mov ItemDataType, eax;
        }
        copyBlock((LPDWORD)_lpCopy, (LPDWORD)_lpDwords, 16);

        _lpDwords->field = 0x26;
        _lpDwords->string = 0x6C5E58;
        _lpDwords->value = 0x06;
        _lpDwords->empty = 0;

        replaceByte(_lpCounter, 0x81);
        __asm {
                push ItemDataType;
                CALL _fnItemDataParser;
                ADD ESP,4;
                push eax
        }

        replaceByte(_lpCounter, 0x80);
        copyBlock((LPDWORD)_lpDwords,(LPDWORD)_lpCopy,  16);
        delete _lpCopy;
        _asm pop eax;
}


top-gear 25.12.2005 23:25

A big thanks to you for your help ^^ Do you guys imagine what would happen if ppl like livid and torune had the c3 source in theri hands.wohooo! Keep up the good work guys

Domzelan 26.12.2005 15:45

Livid and torune, you are the most shared in hexing. Help me if you can :) in full party - should be a bonus 90% of exp for full paty - in my server have bonus too - 7% (i think so :)) question: Where i shold increse parametr for this?

sory for my bad english.

rus Пати бонус - должно быть 90% если полная пати говарят что есть 7% как сделать 90%?

bwgreen 27.12.2005 01:00

try making a new post instead of going offtopic

TheOrder 27.12.2005 08:37

Tnx for the share Livid !!!

yobzhik 16.01.2006 10:41

Sorry, but i dont find post about novice SS|BSPS...
It deleted ?

P.S. Ill try search - dont found =(

bwgreen 16.01.2006 10:46

Novice ss/bsps are identical to no graed except for the name.


Could this be used for fishing rods? They all have their own grades and use fishing shots. I know this is for adding a new grade, but what about adding a new wepaon type of ROD?

Stormi 16.01.2006 12:27

Novice ss/bsps are identical to no graed except for the name.

does it mean that any wearpon (not just starter, but any) can be charged with Novice ss/bsps?

Aikeleer 16.01.2006 14:48

Yes. That's what I've been saying from the start...

yobzhik 16.01.2006 16:59

=(
if you have it, plz mail it to me.
evil@homei.net.ua
thanks

rodier 16.01.2006 21:22

SS for rookie are weaker than normal SS none..

elcapo 17.01.2006 03:15

Livid, nice Tutorial.
It makes us take courage and start to learn ASM and try to hex L2.

archonus 17.01.2006 23:07

livid can u add a new crystal higher than S grade (becouse crystal E is lower than D) , i was thinking on use a new crystal H (for example) for hero weapons , and make a new expertise H for hero , so then can use hero weapons and hero sets :)

bwgreen 18.01.2006 12:28

Quote:

Originally Posted by rodier
SS for rookie are weaker than normal SS none..

Wrong. They're exactly the same.

http://www.purp.co.uk/temp/clip-nssps.jpg http://www.purp.co.uk/temp/clip-nssps-n.jpg

Quote:

Originally Posted by yobzhik
=(

if you have it, plz mail it to me.
evil@homei.net.ua
thanks

Have what..?

Livid 06.03.2006 16:16

Quote:

Originally Posted by archonus
livid can u add a new crystal higher than S grade (becouse crystal E is lower than D) , i was thinking on use a new crystal H (for example) for hero weapons , and make a new expertise H for hero , so then can use hero weapons and hero sets :)

Is there any difference in character you use E or H?.. no, I think not.
Point was to make do-it-urself tutorial. Have fun.


All times are GMT. The time now is 22:52.