Exemple #1
0
static void test_UuidCreate(void)
{
    UUID guid;
    BYTE version;

    UuidCreate(&guid);
    version = (guid.Data3 & 0xf000) >> 12;
    ok(version == 4 || broken(version == 1), "unexpected version %d\n",
       version);
    if (version == 4)
    {
        static UUID v4and = { 0, 0, 0x4000, { 0x80,0,0,0,0,0,0,0 } };
        static UUID v4or = { 0xffffffff, 0xffff, 0x4fff,
           { 0xbf,0xff,0xff,0xff,0xff,0xff,0xff,0xff } };
        UUID and, or;
        RPC_STATUS rslt;
        int i;
        char buf[39];

        and = guid;
        or = guid;
        /* Generate a bunch of UUIDs and mask them.  By the end, we expect
         * every randomly generated bit to have been zero at least once,
         * resulting in no bits set in the and mask except those which are not
         * randomly generated:  the version number and the topmost bits of the
         * Data4 field (treated as big-endian.)  Similarly, we expect only
         * the bits which are not randomly set to be cleared in the or mask.
         */
        for (i = 0; i < 1000; i++)
        {
            LPBYTE src, dst;

            UuidCreate(&guid);
            for (src = (LPBYTE)&guid, dst = (LPBYTE)&and;
             src - (LPBYTE)&guid < sizeof(guid); src++, dst++)
                *dst &= *src;
            for (src = (LPBYTE)&guid, dst = (LPBYTE)&or;
             src - (LPBYTE)&guid < sizeof(guid); src++, dst++)
                *dst |= *src;
        }
        ok(UuidEqual(&and, &v4and, &rslt),
           "unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &and));
        ok(UuidEqual(&or, &v4or, &rslt),
           "unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &or));
    }
    else
    {
        /* Older versions of Windows generate V1 UUIDs.  For these, there are
         * many stable bits, including at least the MAC address if one is
         * present.  Just check that Data4[0]'s most significant bits are
         * set as expected.
         */
        ok((guid.Data4[0] & 0xc0) == 0x80,
           "unexpected value in Data4[0]: %02x\n", guid.Data4[0] & 0xc0);
    }
}
Exemple #2
0
static RpcServerInterface* RPCRT4_find_interface(UUID* object, UUID* if_id)
{
  UUID* MgrType = NULL;
  RpcServerInterface* cif = NULL;
  RPC_STATUS status;

  /* FIXME: object -> MgrType */
  EnterCriticalSection(&server_cs);
  cif = ifs;
  while (cif) {
    if (UuidEqual(if_id, &cif->If->InterfaceId.SyntaxGUID, &status) &&
       UuidEqual(MgrType, &cif->MgrTypeUuid, &status) &&
       (std_listen || (cif->Flags & RPC_IF_AUTOLISTEN))) break;
    cif = cif->Next;
  }
  LeaveCriticalSection(&server_cs);
  return cif;
}
Exemple #3
0
/*
 * Find a uuid on the list.  If it is there, copy the session key and
 * destroy the entry, since it is only used once.
 *
 * Return TRUE if found, FALSE if not found
 */
BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8])
{
    RPC_STATUS status;
    tokenEvent_t *te;
    tokenEvent_t **ltep;

    lock_ObtainMutex(&tokenEventLock);
    te = tokenEvents;
    ltep = &tokenEvents;
    while (te) {
        if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) {
            *ltep = te->next;
            lock_ReleaseMutex(&tokenEventLock);
            memcpy(sessionKey, te->sessionKey,
                    sizeof(te->sessionKey));
            free(te);
            return TRUE;
        }
        ltep = &te->next;
        te = te->next;
    }
    lock_ReleaseMutex(&tokenEventLock);
    return FALSE;
}
Exemple #4
0
static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryPublisherNotify *This, const WSD_SOAP_MESSAGE *pSoap, IWSDMessageParameters *pMessageParameters)
{
    trace("IWSDiscoveryPublisherNotifyImpl_ProbeHandler called (%p, %p, %p)\n", This, pSoap, pMessageParameters);

    if (probe_event == NULL)
    {
        /* We may have received an unrelated probe on the network */
        return S_OK;
    }

    ok(pSoap != NULL, "pSoap == NULL\n");
    ok(pMessageParameters != NULL, "pMessageParameters == NULL\n");

    if (pSoap != NULL)
    {
        static const WCHAR perry[] = {'P','e','r','r','y',0};
        static const WCHAR extra_info[] = {'E','x','t','r','a','I','n','f','o',0};
        WSD_PROBE *probe_msg = (WSD_PROBE *) pSoap->Body;

        ok(pSoap->Body != NULL, "pSoap->Body == NULL\n");
        ok(pSoap->Header.To != NULL && lstrcmpW(pSoap->Header.To, discoveryTo) == 0,
            "pSoap->Header.To == '%s'\n", wine_dbgstr_w(pSoap->Header.To));
        ok(pSoap->Header.Action != NULL && lstrcmpW(pSoap->Header.Action, actionProbe) == 0,
            "pSoap->Header.Action == '%s'\n", wine_dbgstr_w(pSoap->Header.Action));

        ok(pSoap->Header.MessageID != NULL, "pSoap->Header.MessageID == NULL\n");

        /* Ensure the message ID is at least 9 characters long (to skip past the 'urn:uuid:' prefix) */
        if ((pSoap->Header.MessageID != NULL) && (lstrlenW(pSoap->Header.MessageID) > 9))
        {
            UUID uuid;
            RPC_STATUS ret = UuidFromStringW((LPWSTR)pSoap->Header.MessageID + 9, &uuid);

            trace("Received message with UUID '%s' (expected UUID '%s')\n", wine_dbgstr_guid(&uuid),
                wine_dbgstr_guid(&probe_message_id));

            /* Check if we've either received a message without a UUID, or the UUID isn't the one we sent. If so,
               ignore it and wait for another message. */
            if ((ret != RPC_S_OK) || (UuidEqual(&uuid, &probe_message_id, &ret) == FALSE)) return S_OK;
        }

        verify_wsdxml_any_text("pSoap->Header.AnyHeaders", pSoap->Header.AnyHeaders, uri_more_tests_no_slash,
            prefix_grog, perry, extra_info);

        if (probe_msg != NULL)
        {
            static const WCHAR lager[] = {'L','a','g','e','r',0};
            static const WCHAR more_info[] = {'M','o','r','e','I','n','f','o',0};

            ok(probe_msg->Types != NULL, "Probe message Types == NULL\n");

            if (probe_msg->Types != NULL)
            {
                verify_wsdxml_name("probe_msg->Types->Element", probe_msg->Types->Element, uri_more_tests_no_slash,
                    prefix_grog, name_cider);
                ok(probe_msg->Types->Next == NULL, "probe_msg->Types->Next == %p\n", probe_msg->Types->Next);
            }

            ok(probe_msg->Scopes == NULL, "Probe message Scopes != NULL\n");
            verify_wsdxml_any_text("probe_msg->Any", probe_msg->Any, uri_more_tests_no_slash, prefix_grog, lager, more_info);
        }
    }

    SetEvent(probe_event);
    return S_OK;
}
Exemple #5
0
int UuidIsNil(UUID* Uuid, RPC_STATUS* Status)
{
	return UuidEqual(Uuid, &UUID_NIL, Status);
}
Exemple #6
0
static void UuidConversionAndComparison(void) {
    CHAR strx[100], x;
    LPSTR str = strx;
    WCHAR wstrx[100], wx;
    LPWSTR wstr = wstrx;

    UUID Uuid1, Uuid2, *PUuid1, *PUuid2;
    RPC_STATUS rslt;

    int i1,i2;

    /* Uuid Equality */
    for (i1 = 0; i1 < 11; i1++)
        for (i2 = 0; i2 < 11; i2++) {
	    if (i1 < 10) {
	        Uuid1 = Uuid_Table[i1]; 
		PUuid1 = &Uuid1;
            } else {
	        PUuid1 = NULL;
	    }        
	    if (i2 < 10) {
	        Uuid2 = Uuid_Table[i2];
		PUuid2 = &Uuid2;
            } else {
	        PUuid2 = NULL;
	    }
	    ok( (UuidEqual(PUuid1, PUuid2, &rslt) == Uuid_Comparison_Grid[i1][i2]), "UUID Equality\n" );
        }

    /* Uuid to String to Uuid (char) */
    for (i1 = 0; i1 < 10; i1++) {
        Uuid1 = Uuid_Table[i1];
	ok( (UuidToStringA(&Uuid1, (unsigned char**)&str) == RPC_S_OK), "Simple UUID->String copy\n" );
	ok( (UuidFromStringA((unsigned char*)str, &Uuid2) == RPC_S_OK), "Simple String->UUID copy from generated UUID String\n" );
	ok( UuidEqual(&Uuid1, &Uuid2, &rslt), "Uuid -> String -> Uuid transform\n" );
	/* invalid uuid tests  -- size of valid UUID string=36 */
	for (i2 = 0; i2 < 36; i2++) {
	    x = str[i2];
	    str[i2] = 'g'; /* whatever, but "g" is a good boundary condition */
	    ok( (UuidFromStringA((unsigned char*)str, &Uuid1) == RPC_S_INVALID_STRING_UUID), "Invalid UUID String\n" );
	    str[i2] = x; /* change it back so remaining tests are interesting. */
	}
	RpcStringFreeA((unsigned char **)&str);
    }

    /* Uuid to String to Uuid (wchar) */
    for (i1 = 0; i1 < 10; i1++) {
        Uuid1 = Uuid_Table[i1];
        rslt=UuidToStringW(&Uuid1, &wstr);
        ok( (rslt == RPC_S_OK), "Simple UUID->WString copy\n" );
        ok( (UuidFromStringW(wstr, &Uuid2) == RPC_S_OK), "Simple WString->UUID copy from generated UUID String\n" );
        ok( UuidEqual(&Uuid1, &Uuid2, &rslt), "Uuid -> WString -> Uuid transform\n" );
	/* invalid uuid tests  -- size of valid UUID string=36 */
	for (i2 = 0; i2 < 36; i2++) {
	    wx = wstr[i2];
	    wstr[i2] = 'g'; /* whatever, but "g" is a good boundary condition */
	    ok( (UuidFromStringW(wstr, &Uuid1) == RPC_S_INVALID_STRING_UUID), "Invalid UUID WString\n" );
	    wstr[i2] = wx; /* change it back so remaining tests are interesting. */
	}
	RpcStringFreeW(&wstr);
    }
}
Exemple #7
0
int uuid_compare (const uuid_t a, const uuid_t b) {
    RPC_STATUS unused;
    return !UuidEqual((UUID*)a, (UUID*)b, &unused);
}