![]() |
|
|
|
|
#1 |
|
Архивный участник
Join Date: Dec 2005
Posts: 242
|
The code is the same with all dlls, and use GetCurrentProcessId(), anyway today and tomorrow I have some exams so the Wednesday I will post some code
![]() Good Luck! |
|
|
|
|
#2 | |
|
Архивный участник
Join Date: Jun 2005
Posts: 258
|
Quote:
I realize the code will be the same with all dll's but when I started I had nothing to go off. If you've never even written a dll or don't know anything about them, this would be a good place to start learning. That's all :P |
|
|
|
|
|
#3 |
|
Архивный участник
Join Date: Jun 2005
Posts: 258
|
Ok so I managed to finally figure out how to overwrite some data without crashing the server :P
First off, what you need to do is add a .asm file to your sources and call it whatever you want. I called mine FirstPatch.asm since it was the first thing I tried. Next create a custom build step so that your asm file is compiled and linked in to the dll. You'll need to add the function prototype to your header file. It should just be void since you're not doing anything but overwriting some bytes. Here's what my asm file looks like: Code:
PUBLIC FirstPatch .DATA sMessage word "C","o","n","g","r","a","t","s",","," ","Y","o","u"," ","O","v","e","r","w","r","o","t","e"," ","I","t",0 lastFunc dq 0064DC60h returnAdd dq 006362EFh .CODE FirstPatch: lea r8, sMessage call qword ptr [lastFunc] jmp returnAdd END The string up there is defined as Unicode since that's what the function you're calling is expecting the string to be in. If you do it in ASCII you will just see junk on the console window. Also, to get it so you don't have a prologue and epilogue just create the function label and leave it as is like I did. So what this does is simply overwrite what's already in r8, which was "Load QuestItem" with my string defined by sMessage. Why change that? It just happened to be one of the first unicode strings I came across while messing around in l2server. I used it as an example to myself to test whether or not this method would work. Anyway, if you go back to your dll, I was having problems with writeprocessmemory writing just a byte for the the jmp instruction, so I changed the bytes like in L2Extension project using pointers and it seems to be working fine. I kept crashing the server originally before I realized it was probably crashing on leaving my firstpatch function. You used to be able to push a return address on the stack and call retn, but that's obviously not the case anymore. Instead I just jmped back to the return address and everything went smoothly. |
|
|
|
|
#4 |
|
Архивный участник
Join Date: Dec 2005
Posts: 242
|
HongK do you have 64bits asm reference ? I need update my knowledge =)
btw, if you want we could speak by messenger and talk about C2/C5 Project :P gL! |
|
|
|
|
#5 |
|
Архивный участник
Join Date: Jun 2005
Posts: 258
|
|
|
|
|
|
#6 | |
|
Архивный участник
Join Date: Dec 2005
Posts: 242
|
Quote:
|
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: Jun 2005
Posts: 258
|
Any functions you want to call from your asm file must be defined with the "C" and extern modifiers in your source or header file.
Example: extern "C" funcName ( paramlist ) { . . . } or like this: extern "C" { void myFunc(); int thisFunc(int x, int y); blah blah } I've read from within your asm file you can call INVOKE <funcName>, but I tried doing that and I get an error, so I guess that's not an option anymore... So I tried just using a call <funcName> instruction and that worked fine. EDIT: Heheh .. "You do not have to use the INVOKE statement, of course. The same effect could be produced by using the CALL instruction" Well that and I think INVOKE must be outdated or at least not used in 64 bit asm |
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|