Modified: trunk/reactos/lib/rpcrt4/ndr_midl.c
Modified: trunk/reactos/lib/rpcrt4/rpc_binding.c
Modified: trunk/reactos/lib/rpcrt4/rpc_message.c
Modified: trunk/reactos/lib/rpcrt4/rpc_server.c
Modified: trunk/reactos/lib/rpcrt4/rpcrt4.spec
Modified: trunk/reactos/lib/rpcrt4/rpcrt4_main.c
--- trunk/reactos/lib/rpcrt4/ndr_midl.c 2005-01-12 20:18:57 UTC (rev 12990)
+++ trunk/reactos/lib/rpcrt4/ndr_midl.c 2005-01-12 20:23:51 UTC (rev 12991)
@@ -100,6 +100,13 @@
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,
--- trunk/reactos/lib/rpcrt4/rpc_binding.c 2005-01-12 20:18:57 UTC (rev 12990)
+++ trunk/reactos/lib/rpcrt4/rpc_binding.c 2005-01-12 20:23:51 UTC (rev 12991)
@@ -96,7 +96,7 @@
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_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_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 @@
/* 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 @@
/* 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);
--- trunk/reactos/lib/rpcrt4/rpc_message.c 2005-01-12 20:18:57 UTC (rev 12990)
+++ trunk/reactos/lib/rpcrt4/rpc_message.c 2005-01-12 20:23:51 UTC (rev 12991)
@@ -447,8 +447,7 @@
* 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);
+ HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
}
TRACE("Buffer=%p\n", pMsg->Buffer);
@@ -463,9 +462,7 @@
{
TRACE("(%p) Buffer=%p\n", pMsg, pMsg->Buffer);
/* FIXME: pfnFree? */
- if (pMsg->Buffer != NULL) {
- HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
- }
+ HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
pMsg->Buffer = NULL;
return S_OK;
}
--- trunk/reactos/lib/rpcrt4/rpc_server.c 2005-01-12 20:18:57 UTC (rev 12990)
+++ trunk/reactos/lib/rpcrt4/rpc_server.c 2005-01-12 20:23:51 UTC (rev 12991)
@@ -434,7 +434,7 @@
#endif
msg = NULL;
}
- if (msg) HeapFree(GetProcessHeap(), 0, msg);
+ HeapFree(GetProcessHeap(), 0, msg);
RPCRT4_DestroyConnection(conn);
return 0;
}
@@ -554,8 +554,8 @@
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);
--- trunk/reactos/lib/rpcrt4/rpcrt4.spec 2005-01-12 20:18:57 UTC (rev 12990)
+++ trunk/reactos/lib/rpcrt4/rpcrt4.spec 2005-01-12 20:23:51 UTC (rev 12991)
@@ -1,5 +1,5 @@
-@ stub DceErrorInqTextA
-@ stub DceErrorInqTextW
+@ stdcall DceErrorInqTextA (long ptr)
+@ stdcall DceErrorInqTextW (long ptr)
@ stdcall -private DllRegisterServer() RPCRT4_DllRegisterServer
@ stub MesBufferHandleReset
--- trunk/reactos/lib/rpcrt4/rpcrt4_main.c 2005-01-12 20:18:57 UTC (rev 12990)
+++ trunk/reactos/lib/rpcrt4/rpcrt4_main.c 2005-01-12 20:23:51 UTC (rev 12991)
@@ -748,3 +748,53 @@
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;
+}