![]() |
[Work In progress] Humble Beginnings of an L2Server C++ DLL
I have attached a Visual Studio 2005 C++ project, as well as included my current state of source code and compiled DLLs.
Disclaimer: these files DO NOT WORK or do anything that xx.xx9% of you will ever care about. LEECHERS LEAVE. This is posted in hopes of moving the community forward on good terms, rather than backwards over greed. You can attach them to an l2Server using the Stud_PE exe injector. So far this works with the tontor patch as well. I plan to keep compatibility with it to the very end. Currently this DLL does 3 things: 1) Changes the Server Protocol to 656 2) Changes the default server message to say "L2C4Extend 0.1 [mcrabben7@gmail.com]" 3) Hooks the L2Server at address 0050F8F4 and tries to redirect it to my own function. My issue is that after writing a new function hook in memory at the location 50F8F4 the L2Server will fail to jump to my HookReceivePacket function. it *never* gets there, or else my log file would show that it entered the function area. I have two more theories on why this function hook is failing to jump to my code in my DLL: 1) The address being written to the L2Server is in the wrong form? 2) The address being written to the L2Server needs to be rebased according to the Procedure's Base Address + an offset related to my DLL? Number 1 I have tried a few forms and to no avail will it run correctly. Number 2 I have not tried since my experience with such things is limited and I wanted to avoid such a route if possible. Here are a few code snippets of the code in question: Code:
//Receive Packet Function HookCode:
void HookReceivePacket()Error output using release/L2C4Extend.dll and my own exe based off the PP release: Code:
Server Up Time Fri Jun 16 03:45:57 2006Edit: Version 0.2 of the code is on page 2 of this thread. Download that for a better set of code! Вложения из исходного сообщения (сами файлы в копии отсутствуют): l2c4extend_209.rar — 548553 байт |
lovely work mate, keep it up!
|
I believe I found the problem. The function call that gets modified in the example uses a relative offset, so replacing it with an absolute address causes it to call the wrong address. If you replace
Code:
if( !WriteProcessMemory(dwHandle, (LPVOID)(0x0050F8F4+1), &HookReceivePacket, sizeof(&HookReceivePacket), &temp) )Code:
if( !WriteProcessMemory(dwHandle, (LPVOID)(0x0050F8F4+1), &HookReceivePacket - (0x0050F8F4+5), sizeof(&HookReceivePacket), &temp) ) |
Very happy to see you going through with this mcrabben7. Only wish I could help you out, but just reading your first reply made me feel small and stupid haha.
Good luck to you. |
Quote:
|
This snippet can replace the previous hook and one won't need to use WriteProcessMemory at all, tbh.
Code:
//Receive Packet Function HookMy log file managed to log this: Code:
Got Process Handle 00000088. |
woot +1 for American programmers :P good job man keep up the good work. There's nothing better than starting from the basics and understanding and building your knowledge on this subject
|
Books? Programming changes to often for that, usually. For Assembly, I learned in college and we used a book called Assembly Language for Intel-Based Computers by Kip R. Irvine.
MSDN library is your best reference for the entire Windows API, and the inner workings of Windows. You can find some (basic) DLL tutrials on the internet at sites like CodeProject.com and other places if you search. |
nice... btw a little snippet for those who dont want/like to use asm to call functions in l2server
Code:
#define CSOCKET_SEND_VA 0x004DFC70 |
Some progress:
Code:
switch ( opCode )Code:
L2C4Extend has started.Code:
Entered HookReceivePacket: now calling L2Server.00500FF0.I managed to write a ReplyRequestShowMiniMap() function. Sadly, when I open the minimap using Alt + m or the button I will see the map, and immediately get disconnected on a dual login error, and on my older code, kicked for a 'protocol' error. Code:
// Reply to Client Packet: RequestShowMiniMap(0xCD) |
mm can u name your project something else except l2extend its taken :)
we might get confused thanks for understanding |
Quote:
Also, I don't see anyone else sharing actual code or trying to build the community, so why should I care if you named it the same thing? Edit: I thought of a new name. Will use it later. Happy :P? |
Plz update your code, I'll try to do some packets and Reupload the code.
I like this project :) Project Name: PPL2Extender (or something) mcrabben7 if u want work in group add me to messenger/icq. GLuck! |
Ok RipperX, I'll add you to MSN like you PMed me. We can talk about working together.
Also, I'll be posting some new code soon, I think. At the very least I will share some parts of it that will help people learn simple fixes. |
im just woundering... still don know how to do alt+m...
asm push 681 push 9d push 'cd' push edi mov eax, 4dfc70 call eax add esp,10 xor eax,eax mov edx, 50fb70 jmp edx GL. |
__asm
{ push 0x0681 //dec: 1665 push 0x00B6 //dec: 182 push format //packet format 'cd' push packetStart //pushes the address of the start of the packet call fSendToSinglePlayer add esp,18 } maybe like this... but i maybe wrong |
I found out my problem in my code. Was a bastard stack issue, but I got it all squared away. Alt + M and Map button work 100% now :D
Code:
// Reply to Client Packet: RequestShowMiniMap(0xCD) |
Awesome man...now I can use a working example to start learning this stuff. :P
|
Yeah great work :D
|
Here is an updated set of code.
Also, I have renamed the project to the Lineage II Extension Project 'Elhaym'. Elhaym is just a nickname for the dll/project. This code I am releasing is under the assumption you won't abuse me being generous. If you compare the first release and this one, you'll see there were a lot of changes to the initial set of code, and a bit of fixing to the functions. All in all, it's a stable base to work off of for your own learning. READ BELOW: I ask one thing: if you manage to use this code base to create a fix, add a feature, or something that we could use, SHARE IT. If people will take this and won't give back, then I will stop sharing. I won't ask twice. READ ABOVE SHARE ANY PROGRESS YOU MAKE! I think the future of the L2Server community depends on if people will stop being selfish and work together. Also, RipperX has joined onto this project with me. We've begun working on some new code for different packet cases. As we make fixes, we will post the progress. Source code is, for now, an optional post from me, but so far you have 95% of the code I have written. Good luck to all people who try to understand this, learn from it, and hopefully people will GIVE BACK to this. Download the attached file for the source and a compiled dll as well. Вложения из исходного сообщения (сами файлы в копии отсутствуют): l2extensionprojectv0.2_532.rar — 359750 байт |
mcrabben7:
I know C++ a bit and maybe I'll help to your devteam in future, when I understand a code. :) Thanks. ;) |
Wow, nice, I will help in this topic soon! Thanks for share!
|
Code:
//enhant |
RipperX and I are looking for any information on how to access the User struct inside L2Server. We need to be able to see what class a player has, their stats, mp, hp, cp, and other stuff. Any help would be appreciated.
Max_Rain: yea, those are the enchant addresses. Later on when the project gets its own config file and we read values from it (I already got a class written for it) then we can let people set the enchant limits themselves. Thanks for the code. Btw, I already know the addresses for settings like Clan Leave penalty, Alliance leave Penalty, Clan War Penalty, and other penalties. Those can be added in the future. |
Sorry for the double post.
RipperX has already got the basic foundation for RecipeBook started. I am working on AutoSS right now. None of these are done yet. RecipeBook will need SQL and access to the UserStruct to be finished. If someone wants to work on something, pick a feature other than the ones above. |
the user struct in the l2server, as told to me by alien003, is stored in ECX for any User:: function, so then all you really need to do is hook the dword table address for userinfo, get all the info u need out of the user struct when the userinfo packet is sent, and store it in a struct... i found that the best way to store the info in the struct is by char id for easy lookup, though i didnt really look into it all that much, i also found it best to store the socket in the struct, aswell as charname and sid, so that for packets such as autoss you can look up in the table by socket, as thats the only thing u will have from the packet, though i dont know if there are any functions to get sid or charid or name from the socket in the l2server, so i dont really know, this was just easyest for what i did as i wasnt sure about any functions at the time...
|
DS:[socket + 1394h] = User Struct
8) |
wait a minute... so... the socket as in the one for the user? cos if so im gonna scream ^_^
|
Is the location where I hook packets (50F8F4) inside this same User scope so that I can get the information? Will the pointer to the start of the packet + 1394h give me the user struct? Also, I don't even know where to begin knowing what is in the User struct. Is there any good way to know what part of it is what, how big each entry is, etc.?
|
if im not mistaken what u have labled as the "start of the packet" is the socket, i dont know where u hooked the packets so i dunno, but i dont think its the same place i did mine xD
also, good way to find out what is where in user struct, debug userinfo packet |
Alright, thanks for the reply. I have (some) reference on what is in the UserInfo packet, so I'll try that. Thanks.
|
Quote:
dunno what arguments your hook function is using, I'm catching them using the function table, just like normal packets my functions prototypes are BOOL function(void* pSocket, const char* pData); DS:[pSocket + 1394h] = pUser DS:[DS:[pUser + 0f54h] + numberFromAI] = same parameter as in AI DS:[pUser + 0f60h] = CInventory and just correcting a thing testdude said Quote:
|
Procedures with offsets
Вложения из исходного сообщения (сами файлы в копии отсутствуют): 1190_142.rar — 14909 байт |
Great work mcabben7,
Good luck with project Elhaym Looks very promissing |
I wish my C++ knowledge was better, I can only create small stupid programs.
But I was wondering if the function , when u double click on an item, it changes in another item is possible to add in this dll, or is that function AI, don't know much about it. |
grillo, pm me in icq or msn
|
nice project, if I can i try help too :)
|
hmm maybe this is good but i dont think so:(
Code:
//ally limit |
Quote:
https://postpacific.mmorpg-game.onli...ic.php?p=43314 (its updated btw) |
CLan ppl limits
Code:
//clan limits |
| All times are GMT. The time now is 23:06. |