Implement DceErrorInqText (take 2)
Bill Medland
billmedland at mercuryspeed.com
Wed Dec 22 09:30:20 CST 2004
Bill Medland (billmedland at mercuryspeed.com)
Implement DceErrorInqText
Index: wine/dlls/rpcrt4/rpcrt4.spec
===================================================================
RCS file: /home/wine/wine/dlls/rpcrt4/rpcrt4.spec,v
retrieving revision 1.50
diff -u -r1.50 rpcrt4.spec
--- wine/dlls/rpcrt4/rpcrt4.spec 18 Oct 2004 19:37:42 -0000 1.50
+++ wine/dlls/rpcrt4/rpcrt4.spec 22 Dec 2004 16:16:51 -0000
@@ -1,5 +1,5 @@
-@ stub DceErrorInqTextA
-@ stub DceErrorInqTextW
+@ stdcall DceErrorInqTextA (long ptr)
+@ stdcall DceErrorInqTextW (long ptr)
@ stdcall -private DllRegisterServer() RPCRT4_DllRegisterServer
@ stub MesBufferHandleReset
Index: wine/dlls/rpcrt4/rpcrt4_main.c
===================================================================
RCS file: /home/wine/wine/dlls/rpcrt4/rpcrt4_main.c,v
retrieving revision 1.50
diff -u -r1.50 rpcrt4_main.c
--- wine/dlls/rpcrt4/rpcrt4_main.c 22 Sep 2004 02:46:39 -0000 1.50
+++ wine/dlls/rpcrt4/rpcrt4_main.c 22 Dec 2004 16:16:52 -0000
@@ -748,3 +748,75 @@
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.
+ * 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.
+ */
+
+/* This is the list of codes for which FormatMessage returns a valid string
+ * but DceErrorInqText returns the RPC_S_NOT_RPC_ERROR message
+ */
+static int unacceptable_formatable_rpc_code (unsigned long e)
+{
+ return (e == 1642 ||
+ e == 3227 ||
+ e == 3814 ||
+ e == 5507 ||
+ e == 5770 ||
+ e == 5780 ||
+ e == ERROR_CTX_SHADOW_INVALID /* 7050 */ ||
+ e == ERROR_CTX_CLIENT_LICENSE_IN_USE /* 7052 */ ||
+ e == ERROR_CTX_CLIENT_LICENSE_NOT_SET /* 7053 */ ||
+ e == ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE /* 8495 */ ||
+ e == ERROR_DS_NONSAFE_SCHEMA_CHANGE /* 8508 */);
+}
+
+RPC_STATUS RPC_ENTRY DceErrorInqTextW (unsigned long e, unsigned short *b)
+{
+ DWORD count;
+ if (unacceptable_formatable_rpc_code (e))
+ count = 0;
+ else
+ {
+ count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, e, 0, b, /* I don't know!!! */ 65535, NULL);
+ }
+ if (!count)
+ {
+ count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, RPC_S_NOT_RPC_ERROR, 0, b,
+ /* I don't know!!! */ 65535, NULL);
+ }
+ return RPC_S_OK;
+}
+
+RPC_STATUS RPC_ENTRY DceErrorInqTextA (unsigned long e, unsigned char *b)
+{
+ DWORD count;
+ if (unacceptable_formatable_rpc_code (e))
+ count = 0;
+ else
+ {
+ count = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, e, 0, b, /* I don't know!!! */ 65535, NULL);
+ }
+ if (!count)
+ {
+ count = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, RPC_S_NOT_RPC_ERROR, 0, b,
+ /* I don't know!!! */ 65535, NULL);
+ }
+ return RPC_S_OK;
+}
+
Index: wine/dlls/rpcrt4/tests/rpc.c
===================================================================
RCS file: /home/wine/wine/dlls/rpcrt4/tests/rpc.c,v
retrieving revision 1.5
diff -u -r1.5 rpc.c
--- wine/dlls/rpcrt4/tests/rpc.c 26 Jan 2004 20:23:34 -0000 1.5
+++ wine/dlls/rpcrt4/tests/rpc.c 22 Dec 2004 16:16:52 -0000
@@ -28,6 +28,7 @@
#include "wine/unicode.h"
#include "rpc.h"
+#include "rpcdce.h"
static UUID Uuid_Table[10] = {
{ 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, /* 0 (null) */
@@ -122,8 +123,49 @@
}
}
+void TestDceErrorInqText (void)
+{
+ char bufferInvalid [1024];
+ char buffer [1024 /* The required size is not documented */];
+ DWORD dwCount;
+
+ dwCount = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, RPC_S_NOT_RPC_ERROR, 0, bufferInvalid,
+ sizeof(bufferInvalid)/sizeof(bufferInvalid[0]), NULL);
+
+ /* A random sample of DceErrorInqText */
+ /* 0 is success */
+ ok ((DceErrorInqTextA (0, buffer) == RPC_S_OK),
+ "DceErrorInqTextA(0...)\n");
+ /* A real RPC_S error */
+ ok ((DceErrorInqTextA (RPC_S_INVALID_STRING_UUID, buffer) == RPC_S_OK),
+ "DceErrorInqTextA(valid...)\n");
+
+ if (dwCount)
+ {
+ /* A message for which FormatMessage should fail
+ * which should return RPC_S_OK and the
+ * fixed "not valid" message
+ */
+ ok ((DceErrorInqTextA (35, buffer) == RPC_S_OK &&
+ strcmp (buffer, bufferInvalid) == 0),
+ "DceErrorInqTextA(unformattable...)\n");
+ /* One for which FormatMessage should succeed but
+ * DceErrorInqText should "fail"
+ */
+ ok ((DceErrorInqTextA (5507, buffer) == RPC_S_OK &&
+ strcmp (buffer, bufferInvalid) == 0),
+ "DceErrorInqTextA(deviation...)\n");
+ }
+ else
+ ok (0, "Cannot set up for DceErrorInqText\n");
+}
+
START_TEST( rpc )
{
trace ( " ** Uuid Conversion and Comparison Tests **\n" );
UuidConversionAndComparison();
+ trace ( " ** DceErrorInqText **\n");
+ TestDceErrorInqText();
}
More information about the wine-patches
mailing list