Esempio n. 1
0
static void
client(const char *test)
{
  if (strcmp(test, "tcp_basic") == 0)
  {
    static unsigned char iptcp[] = "ncacn_ip_tcp";
    static unsigned char address[] = "127.0.0.1";
    static unsigned char port[] = PORT;
    unsigned char *binding;

    ok(RPC_S_OK == RpcStringBindingCompose(NULL, iptcp, address, port, NULL, &binding), "RpcStringBindingCompose\n");
    ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");

    run_tests();

    ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
    ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
  }
  else if (strcmp(test, "np_basic") == 0)
  {
    static unsigned char np[] = "ncacn_np";
    static unsigned char address[] = "\\\\.";
    static unsigned char pipe[] = PIPE;
    unsigned char *binding;

    ok(RPC_S_OK == RpcStringBindingCompose(NULL, np, address, pipe, NULL, &binding), "RpcStringBindingCompose\n");
    ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");

    run_tests();
    stop();

    ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
    ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
  }
}
Esempio n. 2
0
File: rpc.c Progetto: Kelimion/wine
static void test_RpcStringBindingFromBinding(void)
{
    static unsigned char ncacn_np[] = "ncacn_np";
    static unsigned char address[] = ".";
    static unsigned char endpoint[] = "\\pipe\\wine_rpc_test";
    RPC_STATUS status;
    handle_t handle;
    RPC_CSTR binding;

    status = RpcStringBindingCompose(NULL, ncacn_np, address,
                                     endpoint, NULL, &binding);
    ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status);

    status = RpcBindingFromStringBinding(binding, &handle);
    ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", status);
    RpcStringFree(&binding);

    status = RpcBindingToStringBinding(handle, &binding);
    ok(status == RPC_S_OK, "RpcStringBindingFromBinding failed with error %u\n", status);

    ok(!strcmp((const char *)binding, "ncacn_np:.[\\\\pipe\\\\wine_rpc_test]"),
       "binding string didn't match what was expected: \"%s\"\n", binding);
    RpcStringFree(&binding);

    status = RpcBindingFree(&handle);
    ok(status == RPC_S_OK, "RpcBindingFree failed with error %u\n", status);
}
Esempio n. 3
0
	std::wstring Directory::CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot)
    {
        UUID uuid;
        RPC_WSTR str_uuid;
        UuidCreate (&uuid);
        UuidToString (&uuid, &str_uuid);
		std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
        pcTemplate += (TCHAR *) str_uuid;
        RpcStringFree (&str_uuid);

        int attemps = 10;
        while (!CreateDirectory(pcTemplate))
        {
            UuidCreate (&uuid);
            UuidToString (&uuid, &str_uuid);
            pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
            pcTemplate += (TCHAR *) str_uuid;
            RpcStringFree (&str_uuid);
            attemps--;

            if (0 == attemps)
            {
                pcTemplate = _T("");
            }
        }
        return pcTemplate;
    }
Esempio n. 4
0
COMError::COMError(HRESULT hr)
{
	_com_error e(hr);
	IErrorInfo *pIErrorInfo = NULL;
	GetErrorInfo(0, &pIErrorInfo);

	if (pIErrorInfo == NULL)
	{
		e = _com_error(hr);
		message = e.ErrorMessage();
	}
	else
	{
		e = _com_error(hr, pIErrorInfo);
		message = e.ErrorMessage();
		IErrorInfo *ptrIErrorInfo = e.ErrorInfo();
		if (ptrIErrorInfo != NULL)
		{
			// IErrorInfo Interface located
			description = (WCHAR *)e.Description();
			source = (WCHAR *)e.Source();
			GUID tmpGuid = e.GUID();
			RPC_WSTR guidStr = NULL;
			// must link in Rpcrt4.lib for UuidToString
			UuidToString(&tmpGuid, &guidStr);
			uuid = (WCHAR*)guidStr;
			RpcStringFree(&guidStr);

			ptrIErrorInfo->Release();
		}
	}
}
Esempio n. 5
0
BOOL InstallGUIDKey(GUID& guidKey, HKEY hkey, LPCTSTR strSubKey)
{
	HKEY hkeyNew, hKeySub;
	DWORD dwDisposition;
	LONG nReturn;
	BOOL b = FALSE;

	nReturn = RegCreateKeyEx(hkey,strSubKey,0,0,REG_OPTION_NON_VOLATILE,
		KEY_ALL_ACCESS,0,&hKeySub,&dwDisposition);
	if (ERROR_SUCCESS == nReturn)
	{
		UCHAR* wcs;
		char buf[1024];
		UuidToString(&guidKey,&wcs);
		sprintf(buf,"{%s}",wcs);
		strupr(buf);
		RpcStringFree(&wcs);
		nReturn = RegCreateKeyEx(hKeySub,buf,0,0,REG_OPTION_NON_VOLATILE,
			KEY_READ,0,&hkeyNew,&dwDisposition);
		if (ERROR_SUCCESS == nReturn)
		{
			RegCloseKey(hkeyNew);
			b = TRUE;
		}
		RegCloseKey(hKeySub);
	}
	return b;
}
Esempio n. 6
0
RPC_STATUS
GuidToString(
    UUID   *Uuid,
    LPTSTR StringGuid
)
{
    RPC_STATUS  Status;
    LPTSTR      pTempStringGuid;


    Status = UuidToString(Uuid, &pTempStringGuid);

    if (Status == RPC_S_OK) {
        //
        // the form we want is all uppercase and with curly brackets around,
        // like what OLE does
        //
        lstrcpy(StringGuid, TEXT("{"));
        lstrcat(StringGuid, pTempStringGuid);
        lstrcat(StringGuid, TEXT("}"));
        CharUpper(StringGuid);

        RpcStringFree(&pTempStringGuid);
    }

    return Status;

} // GuidToString
Esempio n. 7
0
// dtor
Uuid::~Uuid()
{
  // this string must be allocated by RPC!
  // (otherwise you get a debug breakpoint deep inside RPC DLL)
  if ( m_pszUuid )
#ifdef _UNICODE
    RpcStringFree((unsigned short **)&m_pszUuid);
#else
    RpcStringFree(&m_pszUuid);
#endif

  // perhaps we should just use a static buffer and not bother
  // with new and delete?
  if ( m_pszCForm )
    delete [] m_pszCForm;
}
Esempio n. 8
0
LRESULT
FilterOnInfoTip(
	IN HWND hWnd,
	IN HWND hWndTree,
	IN LPNMTVGETINFOTIP lp
	)
{
	HTREEITEM Parent;
	PBTR_FILTER Filter;
	PFILTER_NODE Node;
	RPC_WSTR Uuid = NULL;

	Parent = TreeView_GetParent(hWndTree, lp->hItem);

	if (!Parent) {

		Node = (PFILTER_NODE)lp->lParam;
		Filter = Node->Filter;

		UuidToString(&Filter->FilterGuid, &Uuid);
		StringCchPrintf(lp->pszText, lp->cchTextMax, FILTER_INFOTIP_FORMAT, 
						Filter->FilterName, Filter->Description, Uuid,
						Filter->MajorVersion, Filter->MinorVersion,
						Filter->Author );

		RpcStringFree(&Uuid);
	}

	return 0;	
}
Esempio n. 9
0
static int
PrintInterfaces(struct rx_connection *aconn)
{
    Capabilities caps;
    struct interfaceAddr addr;
#ifdef AFS_NT40_ENV
    char * p;
#else
    char uuidstr[128];
#endif
    int i, code;
    char hoststr[16];

    caps.Capabilities_val = NULL;
    caps.Capabilities_len = 0;

    code = RXAFSCB_TellMeAboutYourself(aconn, &addr, &caps);
    if (code == RXGEN_OPCODE)
        code = RXAFSCB_WhoAreYou(aconn, &addr);
    if (code) {
	printf("cmdebug: error checking interfaces: %s\n",
	       afs_error_message(code));
	return 0;
    }

#ifdef AFS_NT40_ENV
    UuidToString((UUID *)&addr.uuid, &p);
    printf("UUID: %s\n",p);
    RpcStringFree(&p);
#else
    afsUUID_to_string(&addr.uuid, uuidstr, sizeof(uuidstr));
    printf("UUID: %s\n",uuidstr);
#endif

    printf("Host interfaces:\n");
    for (i = 0; i < addr.numberOfInterfaces; i++) {
	printf("%s", afs_inet_ntoa_r(htonl(addr.addr_in[i]), hoststr));
	if (addr.subnetmask[i])
	    printf(", netmask %s", afs_inet_ntoa_r(htonl(addr.subnetmask[i]), hoststr));
	if (addr.mtu[i])
	    printf(", MTU %d", addr.mtu[i]);
	printf("\n");
    }

    if (caps.Capabilities_val) {
        printf("Capabilities:\n");
        if (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS) {
            printf("Error Translation\n");
        }
        printf("\n");
    }

    if (caps.Capabilities_val)
	free(caps.Capabilities_val);
    caps.Capabilities_val = NULL;
    caps.Capabilities_len = 0;

    return 0;
}
Esempio n. 10
0
char* pn_i_genuuid(void) {
    unsigned char *generated;
    UUID uuid;
    UuidCreate(&uuid);
    UuidToString(&uuid, &generated);
    char* r = pn_strdup((const char*)generated);
    RpcStringFree(&generated);
    return r;
}
Esempio n. 11
0
static void uuid_to_string(uuid_t *uuid, char *uuid_str) {
#ifdef __MINGW32__
  RPC_CSTR tmp;
  UuidToString(uuid, &tmp);
  strcpy(uuid_str, tmp);
  RpcStringFree(&tmp);
#elif __linux__
  uuid_unparse_lower(*uuid, uuid_str);
#endif
}
Esempio n. 12
0
void gen_uuid_inplace (char *buf)
{
    unsigned char *str = NULL;
    UUID uuid;

    UuidCreate(&uuid);
    UuidToString(&uuid, &str);
    memcpy(buf, str, 37);
    RpcStringFree(&str);
}
Esempio n. 13
0
SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
{
#ifndef WIN32
	apr_uuid_format(buffer, (const apr_uuid_t *) uuid);
#else
	RPC_CSTR buf;
	UuidToString((const UUID *) uuid, &buf);
	strcpy(buffer, (const char *) buf);
	RpcStringFree(&buf);
#endif
}
Esempio n. 14
0
void uuid_unparse (const uuid_t uu, char *out) {
    unsigned char *formatted;
    if (UuidToString((UUID*)uu, &formatted) == RPC_S_OK) {
#ifdef _MSC_VER
        strncpy_s (out, 36+1, (char*)formatted, _TRUNCATE);
#else
        strncpy (out, (char*)formatted, 36+1);
#endif
        RpcStringFree(&formatted);
    }
}
Esempio n. 15
0
int main(int argc, char* argv[])
{
    RPC_STATUS status;

    unsigned char * pszNetworkAddress = NULL;
    unsigned char * pszStringBinding = NULL;
    int i;

    for ( i = 1; i < argc; ++i )
    {
        if ( strcmp(argv[i], "-ip") == 0 )
        {
            pszNetworkAddress = (unsigned char *)argv[++i];
        }
    }

    status = RpcStringBindingCompose(
        NULL,
        (unsigned char *)"ncacn_np",
        pszNetworkAddress,
        (unsigned char *)"\\pipe\\{a5194558-21a6-4978-9610-2072fcf1dc6e}",
        NULL,
        &pszStringBinding );
    if ( status != 0 )
    {
        printf("RpcStringBindingCompose return  %d !\n", status);
        return 1;
    }

    printf("pszStringBinding = %s\n", pszStringBinding);

    status = RpcBindingFromStringBinding(
        pszStringBinding,
        &hello_Binding );
    if ( status != 0 )
    {
        printf("RpcBindingFromStringBinding return  %d !\n", status);
        return 1;
    }

    doRpcCall();

    status = RpcStringFree( &pszStringBinding );
    if ( status != 0 )
        printf("RpcStringFree return  %d !\n", status);

    status = RpcBindingFree( &hello_Binding );
    if ( status != 0 )
        printf("RpcBindingFree return  %d !\n", status);

    getchar();
    return 0;
}
Esempio n. 16
0
char* gen_uuid ()
{
    char *uuid_str = g_malloc (37);
    unsigned char *str = NULL;
    UUID uuid;

    UuidCreate(&uuid);
    UuidToString(&uuid, &str);
    memcpy(uuid_str, str, 37);
    RpcStringFree(&str);
    return uuid_str;
}
Esempio n. 17
0
void CedExporter::FillGuidString(CString& s) const
{
	// See http://forums.codeguru.com/showthread.php?t=379736
	GUID Guid;
	CoCreateGuid(&Guid);
	//RPC_WSTR str;
	unsigned char* str;
	UuidToString((UUID*)&Guid, &str);
	s = (LPTSTR)str;
	s.MakeUpper();

	RpcStringFree(&str);
}
Esempio n. 18
0
void Guid::_generate()
{
	GUID guid;
	RPC_WSTR pszUuid = 0;

	if (UuidCreate(&guid) == RPC_S_OK)
	{
		UuidToString(&guid, &pszUuid);
		m_guid = (wchar_t*) pszUuid;
		RpcStringFree(&pszUuid);
	}
	g_log.Log(L"Guid::_generate. Guid: '%s'", (wchar_t *) m_guid.c_str());
}
TFunctionInstanceInfo::~TFunctionInstanceInfo()
{
    if (m_pszDeviceId)
    {
        RpcStringFree((RPC_WSTR*) &m_pszDeviceId);
        m_pszDeviceId = NULL;
    }
    if (m_ppszDeviceCategories)
    {
        free(m_ppszDeviceCategories);
        m_ppszDeviceCategories = NULL;
    }
}  // TFunctionInstanceInfo::~TFunctionInstanceInfo
Esempio n. 20
0
void GenerateUUID(LPTSTR szUUID, int size) {
	UUID bUuid;
#ifdef UNICODE
	RPC_WSTR rstrUUID;
#else
	RPC_CSTR rstrUUID;
#endif

	UuidCreate(&bUuid);
	UuidToString(&bUuid, &rstrUUID);
	lstrcpyn(szUUID, (LPCTSTR) rstrUUID, size);
	RpcStringFree(&rstrUUID);
}
Esempio n. 21
0
int main()
{
	unsigned char *uuid_string;
	UUID my_uuid;
	RPC_STATUS status;
	
	status = UuidCreate(&my_uuid); 
	status = UuidToString(&my_uuid, &uuid_string);

	printf("%s", uuid_string);

	status = RpcStringFree(&uuid_string);

}
Esempio n. 22
0
void UUID_ToString(GUID *uuid,PSTR szUUID)
{
#ifdef WIN32
  PBYTE StringUuid;

  UuidToString(uuid,&StringUuid);
  strcpy(szUUID,StringUuid);
  RpcStringFree(&StringUuid);
#endif //WIN32
#ifdef HAVE_UUID_UNPARSE
  uuid_unparse(*uuid,szUUID);
#endif //HAVE_UUID_UNPARSE
  strupr(szUUID);
}
Esempio n. 23
0
static void guid_to_string(REFCLSID rclsid,std::wstring& v)
{
	HRESULT hr;
	RPC_WSTR lpolestr;
	if((hr=UuidToString(&rclsid,&lpolestr ))==S_OK)
	{
		v=(LPCWSTR)lpolestr;
		RpcStringFree (&lpolestr);
	}
	else
	{
		if(hr!=S_OK) throw _com_error(hr);
	}
}
Esempio n. 24
0
JNIEXPORT jstring JNICALL Java_org_eclipse_perfmsr_core_PerformanceMonitor_nativeGetUUID
  (JNIEnv * jniEnv, jclass jniClass)
{
	UUID				uuid;
	unsigned char*		uuidStr;
	jstring				result;

	UuidCreate(&uuid);
	UuidToString(&uuid, &uuidStr);

	result = (*jniEnv)->NewStringUTF(jniEnv, uuidStr); 
	RpcStringFree(&uuidStr);

	return result;
}
Esempio n. 25
0
wstring CMp4DownloadClient::GetUuid()
{
	USES_CONVERSION;
	wstring strUid;
	UUID uid;
	if(UuidCreate(&uid) == RPC_S_OK)
	{
		RPC_WSTR szUid = NULL;
		if(UuidToString(&uid,&szUid) == RPC_S_OK)
		{
			strUid = (wchar_t *)szUid;
			RpcStringFree(&szUid);
		}
	}
	return strUid;
}
Esempio n. 26
0
BOOL kull_m_rpc_createBinding(LPCWSTR ProtSeq, LPCWSTR NetworkAddr, LPCWSTR Endpoint, LPCWSTR Service, DWORD ImpersonationType, RPC_BINDING_HANDLE *hBinding, void (RPC_ENTRY * RpcSecurityCallback)(void *))
{
	BOOL status = FALSE;
	RPC_STATUS rpcStatus;
	RPC_WSTR StringBinding = NULL;
	RPC_SECURITY_QOS SecurityQOS = {RPC_C_SECURITY_QOS_VERSION, RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH, RPC_C_QOS_IDENTITY_STATIC, ImpersonationType};
	LPWSTR fullServer;
	DWORD szServer = (DWORD) (wcslen(NetworkAddr) * sizeof(wchar_t)), szPrefix = (DWORD) (wcslen(Service) * sizeof(wchar_t));

	*hBinding = NULL;
	rpcStatus = RpcStringBindingCompose(NULL, (RPC_WSTR) ProtSeq, (RPC_WSTR) NetworkAddr, (RPC_WSTR) Endpoint, NULL, &StringBinding);
	if(rpcStatus == RPC_S_OK)
	{
		rpcStatus = RpcBindingFromStringBinding(StringBinding, hBinding);
		if(rpcStatus == RPC_S_OK)
		{
			if(*hBinding)
			{
				if(fullServer = (LPWSTR) LocalAlloc(LPTR, szPrefix + sizeof(wchar_t) + szServer + sizeof(wchar_t)))
				{
					RtlCopyMemory(fullServer, Service, szPrefix);
					RtlCopyMemory((PBYTE) fullServer + szPrefix + sizeof(wchar_t), NetworkAddr, szServer);
					((PBYTE) fullServer)[szPrefix] = L'/';
					rpcStatus = RpcBindingSetAuthInfoEx(*hBinding, (RPC_WSTR) fullServer, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, (MIMIKATZ_NT_BUILD_NUMBER < KULL_M_WIN_BUILD_VISTA) ? RPC_C_AUTHN_GSS_KERBEROS : RPC_C_AUTHN_GSS_NEGOTIATE, NULL, 0, &SecurityQOS);
					if(rpcStatus == RPC_S_OK)
					{
						if(RpcSecurityCallback)
						{
							rpcStatus = RpcBindingSetOption(*hBinding, RPC_C_OPT_SECURITY_CALLBACK, (ULONG_PTR) RpcSecurityCallback);
							status = (rpcStatus == RPC_S_OK);
							if(!status)
								PRINT_ERROR(L"RpcBindingSetOption: 0x%08x (%u)\n", rpcStatus, rpcStatus);
						}
						else status = TRUE;
					}
					else PRINT_ERROR(L"RpcBindingSetAuthInfoEx: 0x%08x (%u)\n", rpcStatus, rpcStatus);
					LocalFree(fullServer);
				}
			}
			else PRINT_ERROR(L"No Binding!\n");
		}
		else PRINT_ERROR(L"RpcBindingFromStringBinding: 0x%08x (%u)\n", rpcStatus, rpcStatus);
		RpcStringFree(&StringBinding);
	}
	else PRINT_ERROR(L"RpcStringBindingCompose: 0x%08x (%u)\n", rpcStatus, rpcStatus);
	return status;
}
Esempio n. 27
0
string Bindable_t::CreateBinding()
{
	static int index = 0;
	static string seed;

	if ((index >= 1000000) || (seed.length() == 0)) {
		#ifdef OS_UNIX
		int fd = open (DEV_URANDOM, O_RDONLY);
		if (fd < 0)
			throw std::runtime_error ("No entropy device");

		unsigned char u[16];
		size_t r = read (fd, u, sizeof(u));
		if (r < sizeof(u))
			throw std::runtime_error ("Unable to read entropy device");

		unsigned char *u1 = (unsigned char*)u;
		char u2 [sizeof(u) * 2 + 1];

		for (size_t i=0; i < sizeof(u); i++)
			sprintf (u2 + (i * 2), "%02x", u1[i]);

		seed = string (u2);
		#endif


		#ifdef OS_WIN32
		UUID uuid;
		UuidCreate (&uuid);
		unsigned char *uuidstring = NULL;
		UuidToString (&uuid, &uuidstring);
		if (!uuidstring)
			throw std::runtime_error ("Unable to read uuid");
		seed = string ((const char*)uuidstring);

		RpcStringFree (&uuidstring);
		#endif

		index = 0;


	}

	stringstream ss;
	ss << seed << (++index);
	return ss.str();
}
Esempio n. 28
0
wstring GetTempFileName(wstring sExt)
{
  GUID* pGuid = new GUID; 

  CoCreateGuid(pGuid); 

  RPC_WSTR pGuidStr = NULL;
  UuidToString(pGuid, &pGuidStr);
  
  wstring sGuid = (wchar_t*)pGuidStr;
  
  RpcStringFree(&pGuidStr);

  delete pGuid;

  return sGuid + sExt;
}
Esempio n. 29
0
RTDECL(int)  RTUuidToStr(PCRTUUID pUuid, char *pszString, size_t cchString)
{
    /* check params */
    AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
    AssertPtrReturn(pszString, VERR_INVALID_POINTER);
    AssertReturn(cchString >= RTUUID_STR_LENGTH, VERR_INVALID_PARAMETER);

    /*
     * Try convert it.
     *
     * The API allocates a new string buffer for us, so we can do our own
     * buffer overflow handling.
     */
    RPC_STATUS Status;
    unsigned char *pszTmpStr = NULL;
#ifdef RPC_UNICODE_SUPPORTED
    /* always use ASCII version! */
    Status = UuidToStringA((UUID *)pUuid, &pszTmpStr);
#else
    Status = UuidToString((UUID *)pUuid, &pszTmpStr);
#endif
    if (Status != RPC_S_OK)
        return RTErrConvertFromWin32(Status);

    /* copy it. */
    int rc = VINF_SUCCESS;
    size_t cchTmpStr = strlen((char *)pszTmpStr);
    if (cchTmpStr < cchString)
        memcpy(pszString, pszTmpStr, cchTmpStr + 1);
    else
    {
        AssertFailed();
        rc = ERROR_BUFFER_OVERFLOW;
    }

    /* free buffer */
#ifdef RPC_UNICODE_SUPPORTED
    /* always use ASCII version! */
    RpcStringFreeA(&pszTmpStr);
#else
    RpcStringFree(&pszTmpStr);
#endif

    /* all done */
    return rc;
}
Esempio n. 30
0
char * Logger::formatUUID( int level, UUID *uuid ) {
	int ind = uuidBufInd++;

	if ( ind >= 60 )
		return NULL;

	if ( this->logMode == LOG_MODE_OFF ) 
		return NULL;
	if ( this->logLevel < level ) 
		return NULL;
	
	UuidToString( uuid, &rpc_wstr );
	sprintf_s( uuidBuf[ind], 40, "%ls", rpc_wstr );
	RpcStringFree( &rpc_wstr );

	return uuidBuf[ind];
}