Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 11.12.2006, 16:34   #1
RipperX
Архивный участник
 
Join Date: Dec 2005
Posts: 242
Default

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!
RipperX is offline  
Old 11.12.2006, 17:04   #2
HongK
Архивный участник
 
Join Date: Jun 2005
Posts: 258
Default

Quote:
Originally Posted by RipperX View Post
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!
lol yea just realized I wrote that wrong .. I was copying and pasting some stuff out my current dll and changed that but forgot to change it back to currentprocessid.

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
HongK is offline  
Old 12.12.2006, 15:08   #3
HongK
Архивный участник
 
Join Date: Jun 2005
Posts: 258
Default

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
Whether or not that call instruction is the best way of doing it, I'm not sure. I'm not really an assembler guru, but it compiles ok and works so atm that was all I cared about :P

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.
HongK is offline  
Old 12.12.2006, 20:50   #4
RipperX
Архивный участник
 
Join Date: Dec 2005
Posts: 242
Default

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!
RipperX is offline  
Old 12.12.2006, 22:03   #5
HongK
Архивный участник
 
Join Date: Jun 2005
Posts: 258
Default

Quote:
Originally Posted by RipperX View Post
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!
Sure, I sent you a private message with my msn info...

Look forward to talking to you
HongK is offline  
Old 12.12.2006, 22:21   #6
RipperX
Архивный участник
 
Join Date: Dec 2005
Posts: 242
Default

Quote:
Originally Posted by HongK View Post
Sure, I sent you a private message with my msn info...

Look forward to talking to you
I added you, but I dunno if you are online :P I saw you offline, otherway addme you. [email protected]
RipperX is offline  
Old 13.12.2006, 15:19   #7
HongK
Архивный участник
 
Join Date: Jun 2005
Posts: 258
Default Calling C++ Functions from Assembly

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
HongK is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 20:40.