string uuid() { string result; #ifdef _WIN32 #ifndef _UNICODE UUID uid; auto status = UuidCreate(&uid); ASSERT(status == RPC_S_OK, "Failed to create UUID"); char* str; auto res = UuidToStringA(&uid, reinterpret_cast<RPC_CSTR*>(&str)); ASSERT(res == RPC_S_OK, "Failed to create string from UUID"); result = reinterpret_cast<const char*>(str); RpcStringFreeA(reinterpret_cast<RPC_CSTR*>(&str)); #else UUID uid; auto status = UuidCreate(&uid); ASSERT(status == RPC_S_OK, "Failed to create UUID"); wchar_t* str; auto res = UuidToStringW(&uid, reinterpret_cast<RPC_WSTR*>(&str)); ASSERT(res == RPC_S_OK, "Failed to create string from UUID"); wstring wideRes = reinterpret_cast<const wchar_t*>(str); result = engine::toUtf8String(wideRes); RpcStringFreeW(reinterpret_cast<RPC_WSTR*>(&str)); #endif #endif return result; }
__entry_point__() { (save)ebx; (save)edi; (save)esi; eax = GetCommandLineA(); (save)0; eax = RpcStringFreeW() - 87; edi = eax + 0x4017c2; (save)0; (save)esp; (save)64; (save)1856; eax = L00401740(0x401000); esi = 0x401000; ebx = 1856 >> 2; goto ( *edi); asm("lodsd"); *(esi - 4) = eax + 2051536744 ^ 2051536744; if(!(ebx = ebx - 1)) { goto ( *edi); } (restore)esi; (restore)edi; (restore)ebx; goto L00401003; }
/* * implemented */ DWORD WINAPI pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen) { RPC_STATUS Status; RPC_WSTR rpcBuffer; WCHAR szBuffer[39]; if (dwStringLen < 39) { return ERROR_INSUFFICIENT_BUFFER; } Status = UuidToStringW(lpGUID, &rpcBuffer); if (Status != RPC_S_OK) { return Status; } wcscpy(szBuffer, L"{"); wcscat(szBuffer, rpcBuffer); wcscat(szBuffer, L"}"); wcscpy(pString, szBuffer); RpcStringFreeW(&rpcBuffer); return NO_ERROR; }
static PyObject* uuidcreate(PyObject* obj, PyObject*args) { UUID result; wchar_t *cresult; PyObject *oresult; /* May return ok, local only, and no address. For local only, the documentation says we still get a uuid. For RPC_S_UUID_NO_ADDRESS, it's not clear whether we can use the result. */ if (UuidCreate(&result) == RPC_S_UUID_NO_ADDRESS) { PyErr_SetString(PyExc_NotImplementedError, "processing 'no address' result"); return NULL; } if (UuidToStringW(&result, &cresult) == RPC_S_OUT_OF_MEMORY) { PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen"); return NULL; } oresult = PyUnicode_FromWideChar(cresult, wcslen(cresult)); RpcStringFreeW(&cresult); return oresult; }
void ff_arch_misc_delete_guid_cstr(const wchar_t *guid_cstr) { RPC_STATUS status; status = RpcStringFreeW((RPC_WSTR *) &guid_cstr); ff_assert(status == RPC_S_OK); }
/* 010509 Carl Corcoran */ HRESULT CCString::FromGuid(GUID* pGuid) { WCHAR* wsz; UuidToStringW(pGuid, &wsz); this->_CreateFromW(wsz); RpcStringFreeW(&wsz); return S_OK; }
static RPC_STATUS DsSetupBind( LPWSTR lpServerName, handle_t *hBinding) { LPWSTR pszStringBinding; RPC_STATUS status; TRACE("DsSetupBind() called\n"); *hBinding = NULL; status = RpcStringBindingComposeW(NULL, L"ncacn_np", lpServerName, L"\\pipe\\lsarpc", NULL, &pszStringBinding); if (status) { TRACE("RpcStringBindingCompose returned 0x%x\n", status); return status; } /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingW(pszStringBinding, hBinding); if (status) { TRACE("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeW(&pszStringBinding); if (status) { TRACE("RpcStringFree returned 0x%x\n", status); } return status; }
static IrotHandle get_irot_handle(void) { if (!irot_handle) { RPC_STATUS status; RPC_WSTR binding; IrotHandle new_handle; unsigned short ncacn_np[] = IROT_PROTSEQ; unsigned short endpoint[] = IROT_ENDPOINT; status = RpcStringBindingComposeW(NULL, ncacn_np, NULL, endpoint, NULL, &binding); if (status == RPC_S_OK) { status = RpcBindingFromStringBindingW(binding, &new_handle); RpcStringFreeW(&binding); } if (status != RPC_S_OK) return NULL; if (InterlockedCompareExchangePointer(&irot_handle, new_handle, NULL)) /* another thread beat us to it */ RpcBindingFree(&new_handle); } return irot_handle; }
handle_t __RPC_USER WKSSVC_IMPERSONATE_HANDLE_bind(WKSSVC_IMPERSONATE_HANDLE pszSystemName) { handle_t hBinding = NULL; LPWSTR pszStringBinding; RPC_STATUS status; TRACE("WKSSVC_IMPERSONATE_HANDLE_bind() called\n"); status = RpcStringBindingComposeW(NULL, L"ncacn_np", pszSystemName, L"\\pipe\\wkssvc", NULL, &pszStringBinding); if (status) { TRACE("RpcStringBindingCompose returned 0x%x\n", status); return NULL; } /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding); if (status) { TRACE("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeW(&pszStringBinding); if (status) { // TRACE("RpcStringFree returned 0x%x\n", status); } return hBinding; }
handle_t __RPC_USER EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName) { handle_t hBinding = NULL; LPWSTR pszStringBinding; RPC_STATUS status; TRACE("EVENTLOG_HANDLE_W_bind() called\n"); status = RpcStringBindingComposeW(NULL, L"ncacn_np", (LPWSTR)UNCServerName, L"\\pipe\\EventLog", NULL, &pszStringBinding); if (status) { ERR("RpcStringBindingCompose returned 0x%x\n", status); return NULL; } /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding); if (status) { ERR("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeW(&pszStringBinding); if (status) { ERR("RpcStringFree returned 0x%x\n", status); } return hBinding; }
handle_t __RPC_USER PLSAPR_SERVER_NAME_bind(PLSAPR_SERVER_NAME pszSystemName) { handle_t hBinding = NULL; LPWSTR pszStringBinding; RPC_STATUS status; TRACE("PLSAPR_SERVER_NAME_bind() called\n"); status = RpcStringBindingComposeW(NULL, L"ncacn_np", pszSystemName, L"\\pipe\\lsarpc", NULL, &pszStringBinding); if (status) { TRACE("RpcStringBindingCompose returned 0x%x\n", status); return NULL; } /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding); if (status) { TRACE("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeW(&pszStringBinding); if (status) { TRACE("RpcStringFree returned 0x%x\n", status); } return hBinding; }
handle_t __RPC_USER WLANSVC_HANDLE_bind(WLANSVC_HANDLE szMachineName) { handle_t hBinding = NULL; LPWSTR pszStringBinding; RPC_STATUS Status; TRACE("RPC_SERVICE_STATUS_HANDLE_bind() called\n"); Status = RpcStringBindingComposeW(NULL, L"ncalrpc", szMachineName, L"wlansvc", NULL, &pszStringBinding); if (Status != RPC_S_OK) { ERR("RpcStringBindingCompose returned 0x%x\n", Status); return NULL; } /* Set the binding handle that will be used to bind to the server. */ Status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding); if (Status != RPC_S_OK) { ERR("RpcBindingFromStringBinding returned 0x%x\n", Status); } Status = RpcStringFreeW(&pszStringBinding); if (Status != RPC_S_OK) { ERR("RpcStringFree returned 0x%x\n", Status); } return hBinding; }
static RPC_STATUS ScCreateStatusBinding(VOID) { LPWSTR pszStringBinding; RPC_STATUS status; TRACE("ScCreateStatusBinding() called\n"); status = RpcStringBindingComposeW(NULL, L"ncacn_np", NULL, L"\\pipe\\ntsvcs", NULL, &pszStringBinding); if (status != RPC_S_OK) { ERR("RpcStringBindingCompose returned 0x%x\n", status); return status; } /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingW(pszStringBinding, &hStatusBinding); if (status != RPC_S_OK) { ERR("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeW(&pszStringBinding); if (status != RPC_S_OK) { ERR("RpcStringFree returned 0x%x\n", status); } return status; }
void fn00401750() { GetCommandLineA(); RpcStringFreeW(null); VirtualProtect(0x00401000, 0x0000073E, 0x00000040, fp - 0x00000014); }
DWORD WINAPI NetClassInstaller( IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL) { SP_DRVINFO_DATA_W DriverInfoData; SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail; WCHAR SectionName[LINE_LEN]; HINF hInf = INVALID_HANDLE_VALUE; INFCONTEXT InfContext; UINT ErrorLine; INT CharacteristicsInt; DWORD Characteristics; LPWSTR BusType = NULL; RPC_STATUS RpcStatus; UUID Uuid; LPWSTR UuidRpcString = NULL; LPWSTR UuidString = NULL; LONG rc; DWORD dwLength; if (InstallFunction != DIF_INSTALLDEVICE) return ERROR_DI_DO_DEFAULT; DPRINT("%lu %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData); /* Get driver info details */ DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W); if (!SetupDiGetSelectedDriverW(DeviceInfoSet, DeviceInfoData, &DriverInfoData)) { rc = GetLastError(); DPRINT("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc); goto cleanup; } DriverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W); if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet, DeviceInfoData, &DriverInfoData, &DriverInfoDetail, sizeof(DriverInfoDetail), NULL) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { rc = GetLastError(); DPRINT("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc); goto cleanup; } hInf = SetupOpenInfFileW(DriverInfoDetail.InfFileName, NULL, INF_STYLE_WIN4, &ErrorLine); if (hInf == INVALID_HANDLE_VALUE) { rc = GetLastError(); DPRINT("SetupOpenInfFileW() failed with error 0x%lx\n", rc); goto cleanup; } if (!SetupDiGetActualSectionToInstallW(hInf, DriverInfoDetail.SectionName, SectionName, LINE_LEN, NULL, NULL)) { rc = GetLastError(); DPRINT("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc); goto cleanup; } /* Get Characteristics and BusType (optional) from .inf file */ if (!SetupFindFirstLineW(hInf, SectionName, L"Characteristics", &InfContext)) { rc = GetLastError(); DPRINT("Unable to find key %S in section %S of file %S (error 0x%lx)\n", L"Characteristics", SectionName, DriverInfoDetail.InfFileName, rc); goto cleanup; } if (!SetupGetIntField(&InfContext, 1, &CharacteristicsInt)) { rc = GetLastError(); DPRINT("SetupGetIntField() failed with error 0x%lx\n", rc); goto cleanup; } Characteristics = (DWORD)CharacteristicsInt; if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET)) { if (SetupFindFirstLineW(hInf, SectionName, L"BusType", &InfContext)) { if (!SetupGetStringFieldW(&InfContext, 1, NULL, 0, &dwLength)) { rc = GetLastError(); DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc); goto cleanup; } BusType = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR)); if (!BusType) { DPRINT("HeapAlloc() failed\n"); rc = ERROR_NOT_ENOUGH_MEMORY; goto cleanup; } if (!SetupGetStringFieldW(&InfContext, 1, BusType, dwLength, NULL)) { rc = GetLastError(); DPRINT("SetupGetStringFieldW() failed with error 0x%lx\n", rc); goto cleanup; } } } /* Create a new UUID */ RpcStatus = UuidCreate(&Uuid); if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY) { DPRINT("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus); rc = ERROR_GEN_FAILURE; goto cleanup; } RpcStatus = UuidToStringW(&Uuid, &UuidRpcString); if (RpcStatus != RPC_S_OK) { DPRINT("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus); rc = ERROR_GEN_FAILURE; goto cleanup; } /* Add curly braces around Uuid */ UuidString = HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL)); if (!UuidString) { DPRINT("HeapAlloc() failed\n"); rc = ERROR_NOT_ENOUGH_MEMORY; goto cleanup; } wcscpy(UuidString, L"{"); wcscat(UuidString, UuidRpcString); wcscat(UuidString, L"}"); if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET)) rc = InstallNetDevice(DeviceInfoSet, DeviceInfoData, UuidString, Characteristics, BusType); else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETCLIENT)) rc = InstallNetClient(); else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETSERVICE)) rc = InstallNetService(); else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETTRANS)) rc = InstallNetTransport(); else { DPRINT("Invalid class guid\n"); rc = ERROR_GEN_FAILURE; } cleanup: if (hInf != INVALID_HANDLE_VALUE) SetupCloseInfFile(hInf); if (UuidRpcString != NULL) RpcStringFreeW(&UuidRpcString); HeapFree(GetProcessHeap(), 0, BusType); HeapFree(GetProcessHeap(), 0, UuidString); if (rc == ERROR_SUCCESS) rc = ERROR_DI_DO_DEFAULT; DPRINT("Returning 0x%lx\n", rc); return rc; }
/****************************************************************************++ Routine Description: Creates a handle to the CSP Arguments: pwzContainerName - name of the container to be created. if NULL, GUID is generated for the name of the container fCreateNewKeys - forces new keys to be created phCryptProv - pointer to the location, where handle should be returned Notes: - Return Value: - S_OK - or - - CAPI error returned by CryptAcquireContextW --*****************************************************************************/ HRESULT CreateCryptProv( IN PCWSTR pwzContainerName, IN BOOL fCreateNewKeys, OUT HCRYPTPROV* phCryptProv) { HRESULT hr = S_OK; HCRYPTKEY hKey = NULL; RPC_STATUS status = RPC_S_OK; BOOL fCreatedContainer = FALSE; WCHAR* pwzNewContainerName = NULL; *phCryptProv = NULL; if (NULL == pwzContainerName) { UUID uuid; BOOL fServiceAccount = FALSE; // // generate container name from the UUID // status = UuidCreate(&uuid); hr = HRESULT_FROM_RPCSTATUS(status); if (FAILED(hr)) { goto Cleanup; } status = UuidToStringW(&uuid, (unsigned short**)&pwzNewContainerName); hr = HRESULT_FROM_RPCSTATUS(status); if (FAILED(hr)) { goto Cleanup; } pwzContainerName = pwzNewContainerName; hr = IsServiceAccount(&fServiceAccount); if (FAILED(hr)) { goto Cleanup; } // // open the clean key container // // note: CRYPT_NEW_KEYSET is not creating new keys, it just // creates new key container. duh. // if (!CryptAcquireContextW(phCryptProv, pwzNewContainerName, NULL, // default provider name DEFAULT_PROV_TYPE, fServiceAccount ? (CRYPT_SILENT | CRYPT_NEWKEYSET | CRYPT_MACHINE_KEYSET) : (CRYPT_SILENT | CRYPT_NEWKEYSET))) { hr = HRESULT_FROM_WIN32(GetLastError()); // // we are seeing that CryptAcquireContextW returns NTE_FAIL under low // memory condition, so we just mask the error // if (NTE_FAIL == hr) { hr = E_OUTOFMEMORY; } goto Cleanup; } fCreatedContainer = TRUE; } else { BOOL fServiceAccount = FALSE; hr = IsServiceAccount(&fServiceAccount); if (FAILED(hr)) { goto Cleanup; } // // open the provider first, create the keys too // if (!CryptAcquireContextW(phCryptProv, pwzContainerName, NULL, // default provider name DEFAULT_PROV_TYPE, fServiceAccount ? (CRYPT_SILENT | CRYPT_MACHINE_KEYSET) : (CRYPT_SILENT))) { hr = HRESULT_FROM_WIN32(GetLastError()); // // we are seeing that CryptAcquireContextW returns NTE_FAIL under low // memory condition, so we just mask the error // if (NTE_FAIL == hr) { hr = E_OUTOFMEMORY; } goto Cleanup; } } if (fCreateNewKeys) { // // make sure keys exist // if (!CryptGetUserKey(*phCryptProv, DEFAULT_KEY_SPEC, &hKey)) { hr = HRESULT_FROM_WIN32(GetLastError()); // if key does not exist, create it if (HRESULT_FROM_WIN32((unsigned long)NTE_NO_KEY) == hr) { hr = S_OK; if (!CryptGenKey(*phCryptProv, DEFAULT_KEY_SPEC, CRYPT_EXPORTABLE, &hKey)) { hr = HRESULT_FROM_WIN32(GetLastError()); // // we are seeing that CryptGenKey returns ERROR_CANTOPEN under low // memory condition, so we just mask the error // if (HRESULT_FROM_WIN32(ERROR_CANTOPEN) == hr) { hr = E_OUTOFMEMORY; } goto Cleanup; } } else { // failed to get user key by some misterious reason, so bail out goto Cleanup; } } } Cleanup: DestroyKey(hKey); if (FAILED(hr)) { // // release the context // ReleaseCryptProv(*phCryptProv); *phCryptProv = NULL; // // delete the keys, if we created them // if (fCreatedContainer) { DeleteKeys(pwzContainerName); } } if (NULL != pwzNewContainerName) { // this always returns RPC_S_OK status = RpcStringFreeW((unsigned short**)&pwzNewContainerName); USES(status); } return hr; }
DWORD WINAPI CreateJob(PLOCAL_PRINTER_HANDLE pPrinterHandle) { const WCHAR wszDoubleBackslash[] = L"\\"; const DWORD cchDoubleBackslash = _countof(wszDoubleBackslash) - 1; DWORD cchMachineName; DWORD cchUserName; DWORD dwErrorCode; PLOCAL_JOB pJob; RPC_BINDING_HANDLE hServerBinding = NULL; RPC_WSTR pwszBinding = NULL; RPC_WSTR pwszMachineName = NULL; // Create a new job. pJob = DllAllocSplMem(sizeof(LOCAL_JOB)); if (!pJob) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; ERR("DllAllocSplMem failed with error %lu!\n", GetLastError()); goto Cleanup; } // Reserve an ID for this job. if (!_GetNextJobID(&pJob->dwJobID)) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; goto Cleanup; } // Copy over defaults to the LOCAL_JOB structure. pJob->pPrinter = pPrinterHandle->pPrinter; pJob->pPrintProcessor = pPrinterHandle->pPrinter->pPrintProcessor; pJob->dwPriority = DEF_PRIORITY; pJob->dwStatus = JOB_STATUS_SPOOLING; pJob->pwszDatatype = AllocSplStr(pPrinterHandle->pwszDatatype); pJob->pwszDocumentName = AllocSplStr(wszDefaultDocumentName); pJob->pDevMode = DuplicateDevMode(pPrinterHandle->pDevMode); GetSystemTime(&pJob->stSubmitted); // Get the user name for the Job. cchUserName = UNLEN + 1; pJob->pwszUserName = DllAllocSplMem(cchUserName * sizeof(WCHAR)); if (!GetUserNameW(pJob->pwszUserName, &cchUserName)) { dwErrorCode = GetLastError(); ERR("GetUserNameW failed with error %lu!\n", dwErrorCode); goto Cleanup; } // FIXME: For now, pwszNotifyName equals pwszUserName. pJob->pwszNotifyName = AllocSplStr(pJob->pwszUserName); // Get the name of the machine that submitted the Job over RPC. dwErrorCode = RpcBindingServerFromClient(NULL, &hServerBinding); if (dwErrorCode != RPC_S_OK) { ERR("RpcBindingServerFromClient failed with status %lu!\n", dwErrorCode); goto Cleanup; } dwErrorCode = RpcBindingToStringBindingW(hServerBinding, &pwszBinding); if (dwErrorCode != RPC_S_OK) { ERR("RpcBindingToStringBindingW failed with status %lu!\n", dwErrorCode); goto Cleanup; } dwErrorCode = RpcStringBindingParseW(pwszBinding, NULL, NULL, &pwszMachineName, NULL, NULL); if (dwErrorCode != RPC_S_OK) { ERR("RpcStringBindingParseW failed with status %lu!\n", dwErrorCode); goto Cleanup; } cchMachineName = wcslen(pwszMachineName); pJob->pwszMachineName = DllAllocSplMem((cchMachineName + cchDoubleBackslash + 1) * sizeof(WCHAR)); CopyMemory(pJob->pwszMachineName, wszDoubleBackslash, cchDoubleBackslash * sizeof(WCHAR)); CopyMemory(&pJob->pwszMachineName[cchDoubleBackslash], pwszMachineName, (cchMachineName + 1) * sizeof(WCHAR)); // Add the job to the Global Job List. if (!InsertElementSkiplist(&GlobalJobList, pJob)) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; ERR("InsertElementSkiplist failed for job %lu for the GlobalJobList!\n", pJob->dwJobID); goto Cleanup; } // Add the job at the end of the Printer's Job List. // As all new jobs are created with default priority, we can be sure that it would always be inserted at the end. if (!InsertTailElementSkiplist(&pJob->pPrinter->JobList, pJob)) { dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; ERR("InsertTailElementSkiplist failed for job %lu for the Printer's Job List!\n", pJob->dwJobID); goto Cleanup; } // We were successful! pPrinterHandle->bStartedDoc = TRUE; pPrinterHandle->pJob = pJob; dwErrorCode = ERROR_SUCCESS; // Don't let the cleanup routine free this. pJob = NULL; Cleanup: if (pJob) DllFreeSplMem(pJob); if (pwszMachineName) RpcStringFreeW(&pwszMachineName); if (pwszBinding) RpcStringFreeW(&pwszBinding); if (hServerBinding) RpcBindingFree(&hServerBinding); return dwErrorCode; }
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); } }