Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Server Modifications ONLY!
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 16.06.2006, 10:44   #1
mcrabben7
Архивный участник
 
Join Date: Apr 2006
Posts: 461
Default [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 Hook
if( !WriteProcessMemory(dwHandle, (LPVOID)(0x0050F8F4+1), &HookReceivePacket, sizeof(&HookReceivePacket), &temp) )
{
	MessageBoxA(NULL, ErrMsgWriteProcessMemory, MsgBoxCaption, MB_OK || MB_ICONSTOP);
	file << "WriteProcessMemory on L2Server.0050F8F5 failed.  Error Code: " << GetLastError() << "\r\n";
}
else
{
	#ifdef __DEBUG__
		file << "Wrote L2Server.0050F8F5 with ReceivePacket Hook (" << temp
			<< " bytes).  New call address: " << hex << HookReceivePacket << ".\r\n";
	#endif
}
Code:
void HookReceivePacket()
{
	#ifdef __DEBUG__
		file << "Entered HookReceivePacket: now calling L2Server.005509E2.\r\n";
	#endif

	...some other code that currently never gets ran...

	#ifdef __DEBUG__
		file << "Exited HookReceivePacket. \r\n";
	#endif
}
After I run my DLL and it hooks the server, it will run fine and load everything. As soon as I try to log in, it will end up crashing with an access violation error. Sometimes in the same place, sometimes in other places. Depends on the state of my code at the time. The other issue is it will NEVER actually run the code inside the HookReceivePacket function. It never seems to get that far, which is why I assume I am somehow writing the hook wrong.

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 2006

Current Time : Fri Jun 16 03:50:26 2006

Elapsed Time : 0 days 0 hours 4 minutes 29 seconds
IOBufferPool - 5995

[(4048) 2006/06/16 03:50:26]: =======================
an Access Violation in module L2C4server656_FAV_PATCHES_v3_patch.dll_L2C4Extend.dll.exe at 001b:693d844e.
start at 2006/6/16 03:45:36
Read from location 693d844e caused an access violation.

Registers:
EAX=6134ce22 CS=001b EIP=693d844e EFLGS=00010282
EBX=6134ce10 SS=0023 ESP=4bd5fe28 EBP=4bd5fe94
ECX=87546eef DS=0023 ESI=00000002 FS=003b
EDX=00000029 ES=0023 EDI=5d75749c GS=0000
Bytes at CS:EIP:
?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 
Stack dump:
4bd5fe28: 0050f8f9 6134ce22 5d758814 00000029 0053ba66 5d75749c 77e6bb6d 4bd5fe30
4bd5fe48: 4bd5fe78 005afa90 00000000 4bd5fe84 4bd5feac 0000002e 44390038 31b9906c
4bd5fe68: 0053c19e 0053ba27 4bd5fe5c 0000002b 005a1550 0053ba27 6134ce10 4bd5fe38
4bd5fe88: 4bd5feb4 005ad778 ffffffff 4bd5fec0 00539866 0053ba66 5d75749c 77e6bb6d
4bd5fea8: 4bd5fedc 4bd5febc 4bd5fe9c 4bd5ff3c 005afaa0 ffffffff 4bd5ff48 0053be2a
4bd5fec8: 0000002b 00000001 0053cbe6 00000001 0000002b 5d75878c 00000000 00000000
4bd5fee8: 3fc7d040 00000000 00001000 00010000 bffeffff 00000001 00000001 0000024a
4bd5ff08: 00010000 08010006 e081f180 03f0dd02 00000172 f50d0c88 0000002b 0004f304
4bd5ff28: 00000000 f87e8000 5d75878c 5d75749c 4bd5fee0 4bd5ff68 005afca0 ffffffff
4bd5ff48: 4bd5ff78 0053cc96 00000000 00000000 00000000 3fc7d040 4bd5ff54 4bd5fa54


ver = Jun  8 2004____15:38:30 thread id=0

void IOThread_common(void *arglist) <-- 
void CIOSocket::ReadCallback(DWORD dwTransferred) <-- 
CUserSocket::OnRead

Thread[0] (ahehe):      Lock Stack  : 



[(4048) 2006/06/16 03:50:26]: *ioc.cpp:665(Sat May 15 01:37:29 2004) exception
Thanks everyone for your time. I hope I can get *constructive* posts and some help in progressing further with this work.

Edit: 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 байт
mcrabben7 is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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