I was just playing around with MASM, trying to see what I could stick a dword ptr too..... And looking at my opcode book...
There is an indirect version of jmp :eek:
Hmmm, there is an indirect version of call, so I probably should have known that :o
I noticed then, that the MASM generated jump table uses the indirect form of jmp:
jmp dword ptr (some API call)
Then I tried doing crazy stuff:
Yes that works, and it is only 4 bytes of code.
or...
Yes that sets EIP to address 0.
My mind is currently trying to take in what this all means.... Jump Tables...
Anything else? Anyone have a clever, useful application for indirect jmp?
Thanks.
I also tried crazy stuff like call word ptr foobar, but call to a word ptr is completly useless in win32asm, as you cannot access memory that far down.
There is an indirect version of jmp :eek:
Hmmm, there is an indirect version of call, so I probably should have known that :o
I noticed then, that the MASM generated jump table uses the indirect form of jmp:
jmp dword ptr (some API call)
Then I tried doing crazy stuff:
jmp dword ptr [eax+ebx*2+36]
Yes that works, and it is only 4 bytes of code.
or...
jmp dword ptr foobar
foobar:
db 00,00,00,00
Yes that sets EIP to address 0.
My mind is currently trying to take in what this all means.... Jump Tables...
Anything else? Anyone have a clever, useful application for indirect jmp?
Thanks.
I also tried crazy stuff like call word ptr foobar, but call to a word ptr is completly useless in win32asm, as you cannot access memory that far down.
Thanks Eoin for those two link. I know nothing of using macros however, i write everything longhand.
I guess it is pretty hard for people to say how they use a particular instruction. Depends on context.
So I found out I can do some pretty wacky things with jmp. Now to find some more wacky things with other instructions.
I guess it is pretty hard for people to say how they use a particular instruction. Depends on context.
So I found out I can do some pretty wacky things with jmp. Now to find some more wacky things with other instructions.
OOP!
See NaN's and Thomas's OOP package, you'll find that all methods are referred via pointers. All Call's to methods are indirect calls.
Anything where control needs to be sent to one of N routines, and WHICH routine that needs to be called/jmped to can be determined at one time, can take advantage of pointers. Say at init you find that you have processor X, you have several routines optimized for processor X,Y,Z, you just change one pointer and voila! you have one pointer for the routine pointing to the routine optimized for processor X.
See NaN's and Thomas's OOP package, you'll find that all methods are referred via pointers. All Call's to methods are indirect calls.
Anything where control needs to be sent to one of N routines, and WHICH routine that needs to be called/jmped to can be determined at one time, can take advantage of pointers. Say at init you find that you have processor X, you have several routines optimized for processor X,Y,Z, you just change one pointer and voila! you have one pointer for the routine pointing to the routine optimized for processor X.
Where do I find these OOP packages? Just do a search on this site?
ThoughtCriminal,
MASM can handle both the default jump table at the end for API calls or direct calls. There is a utility in MASM32 that creates include files that use an EXTERNDEF format that assemble as direct calls. All you need to do is construct a set of includes with it from the libraries you are using.
Regards,
hutch@movsd.com
MASM can handle both the default jump table at the end for API calls or direct calls. There is a utility in MASM32 that creates include files that use an EXTERNDEF format that assemble as direct calls. All you need to do is construct a set of includes with it from the libraries you are using.
Regards,
hutch@movsd.com
There's a OOP framework in the \Masm32\Oop folder.