HRESULT hr;\r
\r
TRACE("(%p,%p)\n", This, pStubMsg);\r
+\r
+ if (!pStubMsg->pRpcChannelBuffer)\r
+ {\r
+ WARN("Trying to use disconnected proxy %p\n", This);\r
+ RpcRaiseException(RPC_E_DISCONNECTED);\r
+ }\r
+\r
pStubMsg->dwStubPhase = PROXY_SENDRECEIVE;\r
hr = IRpcChannelBuffer_SendReceive(pStubMsg->pRpcChannelBuffer,\r
(RPCOLEMESSAGE*)pStubMsg->RpcMsg,\r
\r
void RPCRT4_strfree(LPSTR src)\r
{\r
- if (src) HeapFree(GetProcessHeap(), 0, src);\r
+ HeapFree(GetProcessHeap(), 0, src);\r
}\r
\r
RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPSTR Protseq, LPSTR NetworkAddr, LPSTR Endpoint, LPSTR NetworkOptions, RpcBinding* Binding)\r
RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);\r
HeapFree(GetProcessHeap(), 0, pname);\r
memset(&Connection->ovl, 0, sizeof(Connection->ovl));\r
- Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);\r
+ Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);\r
if (!ConnectNamedPipe(Connection->conn, &Connection->ovl)) {\r
WARN("Couldn't ConnectNamedPipe (error was %ld)\n", GetLastError());\r
if (GetLastError() == ERROR_PIPE_CONNECTED) {\r
RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);\r
HeapFree(GetProcessHeap(), 0, pname);\r
memset(&Connection->ovl, 0, sizeof(Connection->ovl));\r
- Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);\r
+ Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);\r
if (!ConnectNamedPipe(Connection->conn, &Connection->ovl)) {\r
WARN("Couldn't ConnectNamedPipe (error was %ld)\n", GetLastError());\r
if (GetLastError() == ERROR_PIPE_CONNECTED) {\r
/* pipe is connected; change to message-read mode. */\r
dwMode = PIPE_READMODE_MESSAGE; \r
SetNamedPipeHandleState(conn, &dwMode, NULL, NULL);\r
- Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);\r
+ Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);\r
Connection->conn = conn;\r
}\r
/* protseq=ncacn_np: named pipes */\r
/* pipe is connected; change to message-read mode. */\r
dwMode = PIPE_READMODE_MESSAGE;\r
SetNamedPipeHandleState(conn, &dwMode, NULL, NULL);\r
- Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);\r
+ Connection->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);\r
Connection->conn = conn;\r
} else {\r
ERR("protseq %s not supported\n", Connection->Protseq);\r
* it, we'll leave deallocating the original buffer to the RPC server */\r
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);\r
} else {\r
- if (pMsg->Buffer)\r
- HeapFree(GetProcessHeap(), 0, pMsg->Buffer);\r
+ HeapFree(GetProcessHeap(), 0, pMsg->Buffer);\r
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);\r
}\r
TRACE("Buffer=%p\n", pMsg->Buffer);\r
{\r
TRACE("(%p) Buffer=%p\n", pMsg, pMsg->Buffer);\r
/* FIXME: pfnFree? */\r
- if (pMsg->Buffer != NULL) {\r
- HeapFree(GetProcessHeap(), 0, pMsg->Buffer);\r
- }\r
+ HeapFree(GetProcessHeap(), 0, pMsg->Buffer);\r
pMsg->Buffer = NULL;\r
return S_OK;\r
}\r
#endif\r
msg = NULL;\r
}\r
- if (msg) HeapFree(GetProcessHeap(), 0, msg);\r
+ HeapFree(GetProcessHeap(), 0, msg);\r
RPCRT4_DestroyConnection(conn);\r
return 0;\r
}\r
\r
EnterCriticalSection(&listen_cs);\r
if (! ++listen_count) {\r
- if (!mgr_event) mgr_event = CreateEventA(NULL, TRUE, FALSE, NULL);\r
- if (!server_sem) server_sem = CreateSemaphoreA(NULL, 0, MAX_THREADS, NULL);\r
+ if (!mgr_event) mgr_event = CreateEventW(NULL, TRUE, FALSE, NULL);\r
+ if (!server_sem) server_sem = CreateSemaphoreW(NULL, 0, MAX_THREADS, NULL);\r
if (!worker_tls) worker_tls = TlsAlloc();\r
std_listen = TRUE;\r
server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, NULL, 0, NULL);\r
-@ stub DceErrorInqTextA\r
-@ stub DceErrorInqTextW\r
+@ stdcall DceErrorInqTextA (long ptr)\r
+@ stdcall DceErrorInqTextW (long ptr)\r
@ stdcall -private DllRegisterServer() RPCRT4_DllRegisterServer\r
\r
@ stub MesBufferHandleReset\r
\r
return TRUE;\r
}\r
+\r
+/* DceErrorInqText\r
+ *\r
+ * Notes\r
+ * 1. On passing a NULL pointer the code does bomb out.\r
+ * 2. The size of the required buffer is not defined in the documentation.\r
+ * It appears to be 256.\r
+ * 3. The function is defined to return RPC_S_INVALID_ARG but I don't know\r
+ * of any value for which it does.\r
+ * 4. The MSDN documentation currently declares that the second argument is\r
+ * unsigned char *, even for the W version. I don't believe it.\r
+ */\r
+\r
+#define MAX_RPC_ERROR_TEXT 256\r
+\r
+RPC_STATUS RPC_ENTRY DceErrorInqTextW (RPC_STATUS e, unsigned short *buffer)\r
+{\r
+ DWORD count;\r
+ count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |\r
+ FORMAT_MESSAGE_IGNORE_INSERTS,\r
+ NULL, e, 0, buffer, MAX_RPC_ERROR_TEXT, NULL);\r
+ if (!count)\r
+ {\r
+ count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |\r
+ FORMAT_MESSAGE_IGNORE_INSERTS,\r
+ NULL, RPC_S_NOT_RPC_ERROR, 0, buffer, MAX_RPC_ERROR_TEXT, NULL);\r
+ if (!count)\r
+ {\r
+ ERR ("Failed to translate error");\r
+ return RPC_S_INVALID_ARG;\r
+ }\r
+ }\r
+ return RPC_S_OK;\r
+}\r
+\r
+RPC_STATUS RPC_ENTRY DceErrorInqTextA (RPC_STATUS e, unsigned char *buffer)\r
+{\r
+ RPC_STATUS status;\r
+ WCHAR bufferW [MAX_RPC_ERROR_TEXT];\r
+ if ((status = DceErrorInqTextW (e, bufferW)) == RPC_S_OK)\r
+ {\r
+ if (!WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_RPC_ERROR_TEXT,\r
+ NULL, NULL))\r
+ {\r
+ ERR ("Failed to translate error");\r
+ status = RPC_S_INVALID_ARG;\r
+ }\r
+ }\r
+ return status;\r
+}\r