std::string createGUID32()
        {
            UUID guid;
            std::memset( &guid, 0, sizeof( UUID ) );

            RPC_STATUS status = UuidCreateSequential( &guid );
            if( RPC_S_OK != status )
            {
                throw E_UNEXPECTED;
            }

            //m_guid = guid;

            //UUID m_guid;
            WCHAR* wzGuid;
            HRESULT hr = StringFromCLSID( guid, &wzGuid );
            if( FAILED( hr ) )
            {
                throw hr;
            }

            std::wstring guid_wstr( wzGuid );
            guid_wstr = guid_wstr.substr( 1, guid_wstr.length() - 2 );
            std::string guid_str( guid_wstr.begin(), guid_wstr.end() );
            return guid_str;
        }
示例#2
0
void uuid_generate_time_safe(uuid_t out){
	UUID uuid;
	UuidCreateNil(&uuid);
	UuidCreateSequential(&uuid);
	uuid.Data1 = htonl(uuid.Data1);
	uuid.Data2 = htons(uuid.Data2);
	uuid.Data3 = htons(uuid.Data3);
	memcpy(out, &uuid, UUID_T_LENGTH);
}
示例#3
0
文件: uuid.cpp 项目: alyst/zorba
void uuid::create( uuid *result ) {
#if defined( __APPLE__ )
  CFUUIDRef uuid_ref = CFUUIDCreate( NULL );
  CFUUIDBytes uuid_bytes = CFUUIDGetUUIDBytes( uuid_ref );
  CFRelease( uuid_ref );
  ::memcpy( result->data, &uuid_bytes, sizeof result->data );
#elif defined( ZORBA_HAVE_UUID_H )
  uuid_generate( result->data );
#elif defined( _WIN32 )
  UuidCreateSequential( (UUID*)result->data );
#endif /* _WIN32 */
}
示例#4
0
static void custom_generate_uuid(uuid_t *uuid) {
#ifdef __MINGW32__
  RPC_STATUS retval = UuidCreateSequential(uuid);
  switch (retval) {
  case RPC_S_OK:
    printd("uuid created successfully\n");
    break;
  case RPC_S_UUID_LOCAL_ONLY:
    printd("uuid created computer unique\n");
    break;
  case RPC_S_UUID_NO_ADDRESS:
    printd("uuid not created\n");
    break;
  }
#elif __linux__
  uuid_generate(*uuid);
#endif
}
inline long MACAddressUtility::GetMACAddressMSW(unsigned char * result)
{

#if defined(UNDER_CE)
	IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information
	DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
	if(GetAdaptersInfo(AdapterInfo, &dwBufLen) == ERROR_SUCCESS)
	{
		memcpy(result, AdapterInfo->Address, 6);
	}
	else return -1;
#else
	UUID uuid;
	if(UuidCreateSequential(&uuid) == RPC_S_UUID_NO_ADDRESS) return -1;
	memcpy(result, (char*)(uuid.Data4+2), 6);
#endif
	return 0;
}
示例#6
0
bool CheckMAC()
{
	unsigned char MACData[6];
	UUID uuid;
	UuidCreateSequential( &uuid ); 

	for (int i=2; i<8; i++) 
		MACData[i - 2] = uuid.Data4[i];

	
	sprintf(MACADDR, "%02X-%02X-%02X-%02X-%02X-%02X", MACData[0], MACData[1], MACData[2], MACData[3], MACData[4], MACData[5]);

	if(CheckingMAC(MACADDR))
	{
		return true;
	}

	else
	{
		MessageBoxA(NULL,"You don't have license to use these files!","Error!",MB_OK);
		::ExitProcess(0);
	}
	return false;
}
示例#7
0
//----------------------------------------------------------------//
void MOAIEnvironment::DetectEnvironment () {

	RTTI_SINGLE ( MOAIGlobalEventSource )
	
	#if defined( MOAI_OS_WINDOWS )
	
		//printf ( "Env Windows\n" );
		this->SetValue ( MOAI_ENV_osBrand, "Windows" );
		
		UUID uuid;
		UuidCreateSequential ( &uuid );
		
		// For now, we'll just use the MAC address which is the last 6 bytes of the uuid.
		char buf[13];
		sprintf ( buf, "%02X%02X%02X%02X%02X%02X", uuid.Data4[2], uuid.Data4[3], uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]);
		this->SetValue ( MOAI_ENV_udid, buf );
		
		char path[MAX_PATH];
		//HRESULT hr = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path);
		SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path);
		this->SetValue ( MOAI_ENV_documentDirectory, path );
		
		const int BUFSIZE = 256;
		TCHAR pszOS[BUFSIZE];

		OSVERSIONINFOEX osvi;
		SYSTEM_INFO si;
		PGNSI pGNSI;				

		ZeroMemory(&si, sizeof(SYSTEM_INFO));
		ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

		osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
		GetVersionEx((OSVERSIONINFO*) &osvi);
		
		pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
		if(NULL != pGNSI) {
			pGNSI(&si);
		}
		else {
			GetSystemInfo(&si);
		}

		if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion > 4 ) {
		
			strcpy ( pszOS, TEXT ( "Win" ));			
			if ( osvi.dwMajorVersion == 6 ) {
				if ( osvi.dwMinorVersion == 1 ) {
					if( osvi.wProductType == VER_NT_WORKSTATION )
						strcat(pszOS, TEXT("7"));
					else strcat(pszOS, TEXT("2008R2" ));
				}
				else if( osvi.dwMinorVersion == 0 ) {
					if( osvi.wProductType == VER_NT_WORKSTATION )
						strcat(pszOS, TEXT("Vista"));
					else strcat(pszOS, TEXT("Server2008" ));
				}
			}
			else if ( osvi.dwMajorVersion == 5 ) {
				if (osvi.dwMinorVersion == 2) {				
					if( osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) {
						strcat(pszOS, TEXT( "XPx64"));
					}
					else {
						strcat(pszOS, TEXT("Server2003"));
					}
				}
				else if ( osvi.dwMinorVersion == 1 ) {
					strcat(pszOS, TEXT("XP"));					
				}
				else if ( osvi.dwMinorVersion == 0 ) {
					strcat(pszOS, TEXT("2000"));
				}
			}
			
			this->SetValue ( MOAI_ENV_osVersion, pszOS );
		}
		else {
			this->SetValue ( MOAI_ENV_osVersion, "WinUnknown" );
		}
		
	#elif defined( MOAI_OS_LINUX )
	
		//printf ( "Env Linux\n" );
		this->SetValue ( MOAI_ENV_osBrand, "Linux" );

	#elif defined ( MOAI_OS_OSX )
	
		//printf ( "Env OSX\n" );
		this->SetValue ( MOAI_ENV_osBrand, "OSX" );
	  #if 0 /* doesn't compile yet */
		// OS Version
		SInt32 majorVersion,minorVersion,bugFixVersion;

		Gestalt(gestaltSystemVersionMajor, &majorVersion);
		Gestalt(gestaltSystemVersionMinor, &minorVersion);
		Gestalt(gestaltSystemVersionBugFix, &bugFixVersion);

		char buffer[256];
		sprintf(buffer, "%d.%d.%d",majorVersion,minorVersion,bugFixVersion);
		this->SetValue ( MOAI_ENV_osVersion, buffer );
	  #endif
	#else
		//printf ( "No environment detected\n" );
	#endif
}
示例#8
0
/* Determines the GUID
 * Returns 1 if successful or -1 on error
 */
int guid_generate(
     uint8_t *guid,
     size_t guid_size,
     uint8_t guid_type,
     liberror_error_t **error )
{
#if defined( WINAPI )
	UUID uuid             = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
#endif

	static char *function = "guid_generate";

	if( guid == NULL )
	{
		liberror_error_set(
		 error,
		 LIBERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBERROR_ARGUMENT_ERROR_INVALID_VALUE,
		 "%s: invalid GUID.",
		 function );

		return( -1 );
	}
	if( guid_size < GUID_SIZE )
	{
		liberror_error_set(
		 error,
		 LIBERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
		 "%s: GUID too small.",
		 function );

		return( -1 );
	}
	if( guid_size > (size_t) SSIZE_MAX )
	{
		liberror_error_set(
		 error,
		 LIBERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
		 "%s: invalid GUID size value exceeds maximum.",
		 function );

		return( -1 );
	}
	if( ( guid_type != GUID_TYPE_RANDOM )
	 && ( guid_type != GUID_TYPE_TIME ) )
	{
		liberror_error_set(
		 error,
		 LIBERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
		 "%s: unsupported GUID type.",
		 function );

		return( -1 );
	}
	if( guid_type == GUID_TYPE_RANDOM )
	{
#if defined( WINAPI )
		UuidCreate(
		 &uuid );

#elif defined( HAVE_UUID_GENERATE_RANDOM )
		uuid_generate_random(
		 guid );
#endif
	}
	if( guid_type == GUID_TYPE_TIME )
	{
#if defined( __BORLANDC__ ) && __BORLANDC__ <= 0x0520
		/* No support for the time type GUID */

#elif defined( WINAPI ) && _WIN32_WINNT >= 0x0500
		UuidCreateSequential(
		 &uuid );

#elif defined( HAVE_UUID_GENERATE_TIME )
		uuid_generate_time(
		 guid );
#endif
	}
#if defined( WINAPI )
	byte_stream_copy_from_uint32_little_endian(
	 guid,
	 uuid.Data1 );

	guid += 4;

	byte_stream_copy_from_uint16_little_endian(
	 guid,
	 uuid.Data2 );

	guid += 2;

	byte_stream_copy_from_uint16_little_endian(
	 guid,
	 uuid.Data3 );

	guid += 2;

	guid[ 0 ] = uuid.Data4[ 0 ];
	guid[ 1 ] = uuid.Data4[ 1 ];
	guid[ 2 ] = uuid.Data4[ 2 ];
	guid[ 3 ] = uuid.Data4[ 3 ];
	guid[ 4 ] = uuid.Data4[ 4 ];
	guid[ 5 ] = uuid.Data4[ 5 ];
	guid[ 6 ] = uuid.Data4[ 6 ];
	guid[ 7 ] = uuid.Data4[ 7 ];
#endif
	return( 1 );
}
示例#9
0
/*************************************************************************
 *           I_UuidCreate   [RPCRT4.@]
 *
 * See UuidCreateSequential()
 */
RPC_STATUS WINAPI I_UuidCreate(UUID *Uuid)
{
    return UuidCreateSequential(Uuid);
}