* NT-based native rpcrt4's. Commonly-used transport for self-to-self RPC's.
*/
-#include "config.h"
+#include <config.h>
#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+//#include <stdlib.h>
+//#include <string.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
-#include "windef.h"
-#include "winerror.h"
-#include "winbase.h"
-#include "winuser.h"
-#include "winnt.h"
-#include "winternl.h"
-#include "iptypes.h"
-#include "iphlpapi.h"
-#include "wine/unicode.h"
-#include "rpc.h"
-
-#include "ole2.h"
-#include "rpcndr.h"
-#include "rpcproxy.h"
-
-#include "rpc_binding.h"
-
-#include "wine/debug.h"
+#define _INC_WINDOWS
+#include <windef.h>
+//#include "winerror.h"
+#include <winbase.h>
+//#include "winuser.h"
+//#include "winnt.h"
+#include <winternl.h>
+#include <ntsecapi.h>
+//#include "iptypes.h"
+#include <iphlpapi.h>
+#include <wine/unicode.h>
+#include <rpc.h>
+
+//#include "ole2.h"
+//#include "rpcndr.h"
+//#include "rpcproxy.h"
+
+//#include "rpc_binding.h"
+#include "rpc_server.h"
+
+#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
break;
case DLL_PROCESS_DETACH:
+ RPCRT4_destroy_all_protseqs();
+ RPCRT4_ServerFreeAllRegisteredAuthInfo();
break;
}
return RPC_S_OK;
}
+/*************************************************************************
+ * UuidCreate [RPCRT4.@]
+ *
+ * Creates a 128bit UUID.
+ *
+ * RETURNS
+ *
+ * RPC_S_OK if successful.
+ * RPC_S_UUID_LOCAL_ONLY if UUID is only locally unique.
+ *
+ * NOTES
+ *
+ * Follows RFC 4122, section 4.4 (Algorithms for Creating a UUID from
+ * Truly Random or Pseudo-Random Numbers)
+ */
+RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
+{
+ RtlGenRandom(Uuid, sizeof(*Uuid));
+ /* Clear the version bits and set the version (4) */
+ Uuid->Data3 &= 0x0fff;
+ Uuid->Data3 |= (4 << 12);
+ /* Set the topmost bits of Data4 (clock_seq_hi_and_reserved) as
+ * specified in RFC 4122, section 4.4.
+ */
+ Uuid->Data4[0] &= 0x3f;
+ Uuid->Data4[0] |= 0x80;
+
+ TRACE("%s\n", debugstr_guid(Uuid));
+
+ return RPC_S_OK;
+}
+
/* Number of 100ns ticks per clock tick. To be safe, assume that the clock
resolution is at least 1000 * 100 * (1/1000000) = 1/10 of a second */
#define TICKS_PER_CLOCK_TICK 1000
*time += TICKS_15_OCT_1582_TO_1601;
}
-/* Assume that a hardware address is at least 6 bytes long */
+/* Assume that a hardware address is at least 6 bytes long */
#define ADDRESS_BYTES_NEEDED 6
static RPC_STATUS RPC_UuidGetNodeAddress(BYTE *address)
/* We can't get a hardware address, just use random numbers.
Set the multicast bit to prevent conflicts with real cards. */
else {
- for (i = 0; i < ADDRESS_BYTES_NEEDED; i++) {
- address[i] = rand() & 0xff;
- }
-
+ RtlGenRandom(address, ADDRESS_BYTES_NEEDED);
address[0] |= 0x01;
status = RPC_S_UUID_LOCAL_ONLY;
}
}
/*************************************************************************
- * UuidCreate [RPCRT4.@]
+ * UuidCreateSequential [RPCRT4.@]
*
* Creates a 128bit UUID.
*
* RPC_S_UUID_LOCAL_ONLY if UUID is only locally unique.
*
* FIXME: No compensation for changes across reloading
- * this dll or across reboots (e.g. clock going
+ * this dll or across reboots (e.g. clock going
* backwards and swapped network cards). The RFC
- * suggests using NVRAM for storing persistent
+ * suggests using NVRAM for storing persistent
* values.
*/
-RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
+RPC_STATUS WINAPI UuidCreateSequential(UUID *Uuid)
{
static int initialised, count;
/* Pack the information into the UUID structure. */
- Uuid->Data1 = (unsigned long)(time & 0xffffffff);
+ Uuid->Data1 = (ULONG)(time & 0xffffffff);
Uuid->Data2 = (unsigned short)((time >> 32) & 0xffff);
Uuid->Data3 = (unsigned short)((time >> 48) & 0x0fff);
Uuid->Data4[0] = sequence & 0xff;
Uuid->Data4[1] = (sequence & 0x3f00) >> 8;
Uuid->Data4[1] |= 0x80;
-
- Uuid->Data4[2] = address[0];
- Uuid->Data4[3] = address[1];
- Uuid->Data4[4] = address[2];
- Uuid->Data4[5] = address[3];
- Uuid->Data4[6] = address[4];
- Uuid->Data4[7] = address[5];
+ memcpy(&Uuid->Data4[2], address, ADDRESS_BYTES_NEEDED);
LeaveCriticalSection(&uuid_cs);
return status;
}
-/*************************************************************************
- * UuidCreateSequential [RPCRT4.@]
- *
- * Creates a 128bit UUID.
- *
- * RETURNS
- *
- * RPC_S_OK if successful.
- * RPC_S_UUID_LOCAL_ONLY if UUID is only locally unique.
- *
- */
-RPC_STATUS WINAPI UuidCreateSequential(UUID *Uuid)
-{
- return UuidCreate(Uuid);
-}
-
/*************************************************************************
* UuidHash [RPCRT4.@]