![]() |
[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. |
| All times are GMT. The time now is 21:45. |