What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » creating an asm opcode

Pages: (2): « First « 1 [ 2 ] Last »
creating an asm opcode
Author: Message:
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: creating an asm opcode
non of you understand this at all

in my first attempt in javascript...
ive allocated some memory for my function,.
Put each individual instruction into an array (in hex of course)
Used a for(i in Patch_Function) to help store each instruction into the allocated memory like so
code:
var BuffAddr = FunctionBuffer.DataPtr;
for(var i = 0; i < Patch_Function.length; i++){
        Patch(BuffAddr, Patch_Function[i]);
        BuffAddr += Patch_Function[i].length;
    }
this works fine and well but now i have to create a JMP to this FunctionBuffer.DataPtr so it can execute my code and IT CANNOT BE HARD CODED which you have all obviously got wrong even though you have read it is dynamically allocated!

to create the jump ive done this

code:
Hook_JMP = Interop.Allocate(6);
    var tmp = Interop.Allocate(6);
    tmp.WriteDWORD(1, FunctionBuffer.DataPtr-Hook_Address-5);
   
    var tmpbyte = tmp.GetAt(0);
    Hook_JMP.SetAt(5,tmpbyte);
   
    tmpbyte = tmp.GetAt(1);
    Hook_JMP.SetAt(4,tmpbyte);
   
    tmpbyte = tmp.GetAt(2);
    Hook_JMP.SetAt(3,tmpbyte);
   
    tmpbyte = tmp.GetAt(3);
    Hook_JMP.SetAt(2,tmpbyte);
   
    tmpbyte = tmp.GetAt(4);
    Hook_JMP.SetAt(0,tmpbyte);
   
    Hook_JMP.SetAt(0,0xE9);

I think the bytes have to be reversed thats why ive put the in a temp buffer then read it backwards but i am unsure.

OBVIOUSLY since its dynamic memory i can just use "asm (jmp $0xE900000000)"

This post was edited on 06-28-2007 at 11:28 AM by effection.
06-28-2007 11:28 AM
Profile E-Mail PM Find Quote Report
Verte
Full Member
***

Avatar

Posts: 272
Reputation: 7
Joined: Apr 2007
RE: creating an asm opcode
Oh no, I understood what you meant. I just thought you said you had the function there. If the location of the function is variable, then you will need to jump to the first instruction to be executed, for example, asm(jmp pointer_to_my_function).

Now, the thing that I am NOT understanding is how you're executing this. I was assuming that you've got a compiled program and you want to call your function from it at some point. This would mean you need to replace some instructions in the original program. How are you editing the program in Javascript? Have you got it also in a data array?

Because, in that case, this is what you could do, which is what I was saying. At some point, your function will be allocated into memory. And at that point, you can get it's location. The method will be different for different methods of allocation. It seems that you've got this function in memory from javascript, and you've got access to that data from +. Is this right so far?
was put impeccably into words at DebianDay for me last Saturday, by Knut Yrvin of Trolltech - adults try something once, fail, and then are like "ffs this doesn't work". Children try, fail, and then try again, and succeed - maybe on the second, or even fifth retry. But the thing is that they keep at it and overcome the problems in the end.

-andrewdodd13
06-28-2007 01:57 PM
Profile E-Mail PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: creating an asm opcode
Okay  I can access the location of the allocated function ( using interop.alloc) i have viewed it will Ollydbg and it is definitely copied there correctly. The way i am calling it is as you say replacing a current opp with a JMP to the allocated function. The problem comes in creating the JMP code. If you could possibly give me some help in creating this as my attempts so far have failed, even if its C or C++ code i dont mind as i can easily implement this into a dll that i can call with the interop object
06-28-2007 03:18 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: creating an asm opcode
I'm not quite sure if using the Interop.Allocate function is safe enough for this though. Maybe you're better of using the memory allocation APIs from windows directly. In that way you know exactly where you're doing what. And you can perfectly control the scope and lifetime of the allocated memory.


EDIT:
quote:
Originally posted by effection
non of you understand this at all
Sorry for saying this and certainly no offense, but I think we all understood your very good. And seeing what you finaly did in that other thread, it confirms what we were saying all this time though.... ;)

This post was edited on 07-03-2007 at 06:36 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-29-2007 02:40 AM
Profile PM Find Quote Report
Verte
Full Member
***

Avatar

Posts: 272
Reputation: 7
Joined: Apr 2007
RE: creating an asm opcode
Dynamic linking is not something I've done by hand before, but I don't think it will be much fun. Still, there's bound to be a dll interface definition on the internet somewhere.
was put impeccably into words at DebianDay for me last Saturday, by Knut Yrvin of Trolltech - adults try something once, fail, and then are like "ffs this doesn't work". Children try, fail, and then try again, and succeed - maybe on the second, or even fifth retry. But the thing is that they keep at it and overcome the problems in the end.

-andrewdodd13
06-29-2007 10:07 AM
Profile E-Mail PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: creating an asm opcode
ive got it all sorted thanks to some help from deAd :D
06-29-2007 05:49 PM
Profile E-Mail PM Find Quote Report
Verte
Full Member
***

Avatar

Posts: 272
Reputation: 7
Joined: Apr 2007
RE: creating an asm opcode
Nice! What did you end up doing?
was put impeccably into words at DebianDay for me last Saturday, by Knut Yrvin of Trolltech - adults try something once, fail, and then are like "ffs this doesn't work". Children try, fail, and then try again, and succeed - maybe on the second, or even fifth retry. But the thing is that they keep at it and overcome the problems in the end.

-andrewdodd13
06-29-2007 11:42 PM
Profile E-Mail PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: creating an asm opcode
I just did what i was always doing but there was something originally wrong with my Call creation code which i never could work out but it fixed itself eventually :)
06-30-2007 12:15 AM
Profile E-Mail PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On