Sync to Wine-20050111:

Robert Shearman <rob@codeweavers.com>
- Remove unnecessary WNDPROC casts.
- Implement RPC_E_DISCONNECTED in proxies.
Mike McCormack <mike@codeweavers.com>
- Use CreateEventW in preference to CreateEventA for unnamed events.
Michael Stefaniuc <mstefani@redhat.de>
- Do not check for non NULL pointer before HeapFree'ing it. It's
  redundant.
Bill Medland <billmedland@mercuryspeed.com>
- Implemented DceErrorInqText.

svn path=/trunk/; revision=12991
This commit is contained in:
Gé van Geldorp 2005-01-12 20:23:51 +00:00
parent 530cd953b8
commit 6aa3e62e96
6 changed files with 69 additions and 15 deletions

View file

@ -100,6 +100,13 @@ void WINAPI NdrProxySendReceive(void *This,
HRESULT hr;
TRACE("(%p,%p)\n", This, pStubMsg);
if (!pStubMsg->pRpcChannelBuffer)
{
WARN("Trying to use disconnected proxy %p\n", This);
RpcRaiseException(RPC_E_DISCONNECTED);
}
pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;
hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,
(RPCOLEMESSAGE*)pStubMsg->RpcMsg,

View file

@ -96,7 +96,7 @@ LPWSTR RPCRT4_strndupW(LPWSTR src, INT slen)
void RPCRT4_strfree(LPSTR src)
{
if (src) HeapFree(GetProcessHeap(), 0, src);
HeapFree(GetProcessHeap(), 0, src);
}
RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPSTR Protseq, LPSTR NetworkAddr, LPSTR Endpoint, LPSTR NetworkOptions, RpcBinding* Binding)
@ -147,7 +147,7 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
HeapFree(GetProcessHeap(), 0, pname);
memset(&Connection->ovl, 0, sizeof(Connection->ovl));
Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
if (!ConnectNamedPipe(Connection->conn, &Connection->ovl)) {
WARN("Couldn't ConnectNamedPipe (error was %ld)\n", GetLastError());
if (GetLastError() == ERROR_PIPE_CONNECTED) {
@ -171,7 +171,7 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
HeapFree(GetProcessHeap(), 0, pname);
memset(&Connection->ovl, 0, sizeof(Connection->ovl));
Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
if (!ConnectNamedPipe(Connection->conn, &Connection->ovl)) {
WARN("Couldn't ConnectNamedPipe (error was %ld)\n", GetLastError());
if (GetLastError() == ERROR_PIPE_CONNECTED) {
@ -223,7 +223,7 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
/* pipe is connected; change to message-read mode. */
dwMode = PIPE_READMODE_MESSAGE;
SetNamedPipeHandleState(conn, &dwMode, NULL, NULL);
Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
Connection->conn = conn;
}
/* protseq=ncacn_np: named pipes */
@ -257,7 +257,7 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
/* pipe is connected; change to message-read mode. */
dwMode = PIPE_READMODE_MESSAGE;
SetNamedPipeHandleState(conn, &dwMode, NULL, NULL);
Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
Connection->conn = conn;
} else {
ERR("protseq %s not supported\n", Connection->Protseq);

View file

@ -447,7 +447,6 @@ RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
* it, we'll leave deallocating the original buffer to the RPC server */
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
} else {
if (pMsg->Buffer)
HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
}
@ -463,9 +462,7 @@ RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
{
TRACE("(%p) Buffer=%p\n", pMsg, pMsg->Buffer);
/* FIXME: pfnFree? */
if (pMsg->Buffer != NULL) {
HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
}
pMsg->Buffer = NULL;
return S_OK;
}

View file

@ -434,7 +434,7 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
#endif
msg = NULL;
}
if (msg) HeapFree(GetProcessHeap(), 0, msg);
HeapFree(GetProcessHeap(), 0, msg);
RPCRT4_DestroyConnection(conn);
return 0;
}
@ -554,8 +554,8 @@ static void RPCRT4_start_listen(void)
EnterCriticalSection(&listen_cs);
if (! ++listen_count) {
if (!mgr_event) mgr_event = CreateEventA(NULL, TRUE, FALSE, NULL);
if (!server_sem) server_sem = CreateSemaphoreA(NULL, 0, MAX_THREADS, NULL);
if (!mgr_event) mgr_event = CreateEventW(NULL, TRUE, FALSE, NULL);
if (!server_sem) server_sem = CreateSemaphoreW(NULL, 0, MAX_THREADS, NULL);
if (!worker_tls) worker_tls = TlsAlloc();
std_listen = TRUE;
server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, NULL, 0, NULL);

View file

@ -1,5 +1,5 @@
@ stub DceErrorInqTextA
@ stub DceErrorInqTextW
@ stdcall DceErrorInqTextA (long ptr)
@ stdcall DceErrorInqTextW (long ptr)
@ stdcall -private DllRegisterServer() RPCRT4_DllRegisterServer
@ stub MesBufferHandleReset

View file

@ -748,3 +748,53 @@ BOOL RPCRT4_RPCSSOnDemandCall(PRPCSS_NP_MESSAGE msg, char *vardata_payload, PRPC
return TRUE;
}
/* DceErrorInqText
*
* Notes
* 1. On passing a NULL pointer the code does bomb out.
* 2. The size of the required buffer is not defined in the documentation.
* It appears to be 256.
* 3. The function is defined to return RPC_S_INVALID_ARG but I don't know
* of any value for which it does.
* 4. The MSDN documentation currently declares that the second argument is
* unsigned char *, even for the W version. I don't believe it.
*/
#define MAX_RPC_ERROR_TEXT 256
RPC_STATUS RPC_ENTRY DceErrorInqTextW (RPC_STATUS e, unsigned short *buffer)
{
DWORD count;
count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, e, 0, buffer, MAX_RPC_ERROR_TEXT, NULL);
if (!count)
{
count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, RPC_S_NOT_RPC_ERROR, 0, buffer, MAX_RPC_ERROR_TEXT, NULL);
if (!count)
{
ERR ("Failed to translate error");
return RPC_S_INVALID_ARG;
}
}
return RPC_S_OK;
}
RPC_STATUS RPC_ENTRY DceErrorInqTextA (RPC_STATUS e, unsigned char *buffer)
{
RPC_STATUS status;
WCHAR bufferW [MAX_RPC_ERROR_TEXT];
if ((status = DceErrorInqTextW (e, bufferW)) == RPC_S_OK)
{
if (!WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_RPC_ERROR_TEXT,
NULL, NULL))
{
ERR ("Failed to translate error");
status = RPC_S_INVALID_ARG;
}
}
return status;
}