rpcrt4: Check for null endpoint in RpcServerUseProtseqEpExW

lkcl lkcl at lkcl.net
Sun Mar 1 14:43:00 CST 2009

David Gerard-2 wrote:
> 2009/2/22 Luke Kenneth Casson Leighton <lkcl at lkcl.net>:
> I don't think anyone questions this. But (speaking as an observer, not
> someone with any particular power to garner interest for this), I
> suspect that your best bet for getting traction on this in Wine is:
> * some apps that use this and work in Windows, but won't work on Wine
> without the admittedly bletcherous interface being implemented - that
> is, a good reason to implement this particular interface
> (remembering that there are large chunks of win32 that Wine doesn't
> bother implementing because it turns out they're all but unused by
> actual app developers)
> * then a conformance test or several that works in Windows but not in
> Wine.
> That is, the first thing is a real-life use case or several.

hiya david, thanks for responding.  it's going to be difficult for me to
explain this, but i'm going to try.  part of the difficulty comes from being
able to look at the two sets of code and see very clearly that the wine
rpcrt4 implementation is line-for-line virtually identical - it _has_ to be,
otherwise there will be no interoperability.

under ordinary circumstances, with something as relatively simple as a
publicly-document MSDN function call, one where you can pretty much go out
on the internet and find working examples, i'd say - yep, great: grab some
of that, knock up a test case, go for it.

however, MSRPC isn't part of the "public API" - it's as if you'd expect
microsoft to document the internal workings of their [proprietary] c / c++
compiler, because WIDL.EXE is a "tool" not an API.  it was so fundamentally
ingrained into the bedrock that it was - and still is - quietly taken for

so there _is_ no documentation, there are no test cases or examples on the
internet to copy: you create an IDL file, you hand it to WIDL.EXE, WIDL.EXE
and the endpoint mapper and rpcrt4.dll all do their jobs, and you don't get
a squeak out of the "documentation" from microsoft - because there isn't

the point is: MSRPC is "core" technology.  seamless, transparent,

and it's so forgotten-about, even inside microsoft, that even microsoft's
own engineers make the daft mistake of putting [in,out] onto buffers that
can go as large as 10mb in size, resulting in 8mb of uninitialised crap
being sent by the spoolss service, an ERROR_MORE_DATA along with the same
8mb uninitialised crap being returned and a new suggestion to send 8.1mb of
crap, which the API dutifully obeys... :)

it's probably increased significantly, but last time i checked (2005?),
wine's source code came in at a whopping one million lines.  the DCE/RPC 1.1
reference implementation, the foundation on which MSRPC was created with
some (relatively) minor and strategically important enhancements, comes in
at 250,000 lines.

MSRPC isn't just some "optional bit of the Win32 API" - it's a bit more
fundamental than that.  the following are all MSRPC services:

* The Registry Service (WINREG) 
* The Service Control Manager (SVCCTL)
* Printing (SPOOLSS)
* WKSSVC (NetWkstaGetInfo and friends)
* SRVSVC (NetShareEnum, NetServerGetInfo and friends)
* LSARPC (LsaQueryInformationPolicy and friends)
* SAMR (very _very_ indirectly - NetUserGetInfo and friends)
*  NETLOGON (very _very_ indirectly the GINAs talk to this.  it's

i could go on - but you should be getting a clear picture that a very very
large amount of the quotes public quotes Win32 API is fundamentally based on
something as quietly unobtrusive as an extremely effective RPC mechanism.

oh - and then there's DCOM, on top of which you have MSHTML, MS-XML, and
much much more.  i looked last week and there are about _thirty_
applications in Wine that import stdole.tlb (a good indication that they are
DCOM-based services).

so it's not like we're talking about a "little function or two" - we're
talking a quarter of a million lines of code in order to get full and total
interoperability, and that's _without_ having the NT Domains Authentication
infrastructure, which in samba tng comprises about another ... 80,000 lines
of code for an LSA, Samr and NETLOGON implementation, along-side 200,000
lines of code for an actual SMB server, without which you cannot get a
NamedPipes transport (over SMB Trans2 IPC$).

so it would seem quite logical, against that background and context, to pull
in all the extra help that you can get, otherwise you're quite likely to be
yet _another_ decade before the job's completed.  which is why i find it so
frustrating when people are unresponsive when i point people at the
fully-functional reference implementation, or they go "duuuuh? y'whaaat?" :)

not to knock the progress that's been made so far on WIDL.EXE and rpcrt4,
it's absolutely fantastic to see.  however, you haven't got round to adding
in any authentication plugins, yet, nor hooked in to an SMB server (to get
NamedPipes) and so much more, which, when that's done, takes Wine up to a
wholllle new level.

so, david, i understand that it seems logical to create a few test cases to
identify missing functionality, but we're talking about a sub-project that's
15 to 20% of the size of the codebase of Wine, and is Wine's fundamental
underpinning infrastructure, and has no available documentational equivalent
in the MSDN.

the best guide you can get (if you can still find it) is a KB article from
around ... 1996 or earlier which, when DCE/RPC was popular in Government
projects, helped you to port DCE/RPC applications to MSRPC.  it had a header
file which provided function-name and data-structure mappings from
dce_rpc_function_names to MsRpcFunctionNames e.g. #define
rpc_server_use_protseq_ep  RpcServerUseProtSeqEp and there were well over
200 of these conversion #defines.  they only helped you so far because the
prototype in dce/rpc is this:

PUBLIC void rpc_server_use_protseq_ep
    (rpc_protseq, max_calls, endpoint, status)

unsigned_char_p_t       rpc_protseq;
unsigned32              max_calls;
unsigned_char_p_t       endpoint;
unsigned32              *status;

and the prototype for MSRPC is this:

    unsigned char *Protseq,
    unsigned int MaxCalls,
    unsigned char *Endpoint,
    void *SecurityDescriptor

note the addition of the security descriptor, but also note the moving of
the "status code" as a return result in the MSRPC version and as a parameter
in the DCE/RPC version?  bit of a bugger, that one, when you have 250,000
lines of code to wade through :)

not only that, but as you can see from the subject line of this discussion,
MSRPC adds "dual" functions - both ascii (A suffix) and UCS-2 versions (W
suffix) of the _same_ function, with the ascii version typically doing a
dumb-conversion to UCS-2 and then freeing up the strings created to do it.

so - to reiterate, and answer your question: MSRPC isn't just "a few public
documented APIs" - it's more fundamental than that.  and the core
functionality of wine critically depends on having MSRPC working correctly
and working well, and, as you can see, it's a big damn job.

when i saw your message i did that thing, you know, where you put your hand
over your eyes and pull down, to stretch your face? :)  it was like, "ohh
maaan - how the _heck_ am i going to explain this to david?  where do i
_start_?" :)

hope this clarifies things.


View this message in context: http://www.nabble.com/Re%3A-rpcrt4%3A-Check-for-null-endpoint-in-RpcServerUseProtseqEpExW-tp21870382p22277703.html
Sent from the Wine - Devel mailing list archive at Nabble.com.

More information about the wine-devel mailing list