leaf wrote:[color=blue]
> Where did i got the data to pass to 'int serialID' and 'const void*
> params'?[/color]
Uh, I don't have time to read the whole paper, but it's describing a
crude RPC mechanism which doesn't deal with issues of passing or
returning reference data, or marshalling data between different machine
architectures.
The serialID comes over the network. It is computed on the client side
by fetching the instruction pointer and searching through the client's
g_Functions table! The serialID travels over the network to the RPC
server, where it is used to locate the corresponding and fetch its
machine address.
The client-side functions are just RPC stubs, and so the g_Functions
array in the client contains the addresses of these RPC stubs. On the
server side, the corresponding array (which must be constructed in
exactly the same order) contains the real functions.
Each stub can find itself in the client-side array by computing its own
address from the instruction pointer register and searching through the
table for the nearest address. This is done by the FindFunction()
routine which is not shown. And that is how each stub knows its own
serialID, and also the meta-information about itself, such as the size
of its argument list on the stack.
The void * parameter is just the packaged up arguments which also come
from the client. It's crude. The client stub information from its
function descriptor to know how big the arguments are, and simply takes
a snapshot off the stack. This is sent as part of the RPC packet to the
other side, which copies it to the stack as part of the function
calling mechanism.
All this stuff is quite so Windows-specific, you have to wonder why the
guy is trying to reinvent Microsoft RPC. Even Microsoft weren't that
dumb; they took their RPC from the Distributed Computing Environment
(DCE) project.
If you don't want that, there are other RPC implementations out there,
complete with interface description languages. No need to hack like
this.
[color=blue]
>From the "Further Work" paper:[/color]
you could create a tool to scan windows.h and other header files
and extract the unmangled function prototypes, converting them
into a type library. "
Yes, indeed. You could re-invent RPC-type tools which already exist.
And that's just your "Further Work". Doh!
For instance:
http://www.swig.org/exec.html
If you have work to do, don't waste your time on undergraduate-level
"oh my god I've discovered you can memcpy pieces of a stack to do RPC"
type of stuff.