Exemplo n.º 1
0
/*****************************************************************************
 * LookupClassId()
 *****************************************************************************
 */
GUID
LookupClassId
(
	IN		LPTSTR	SymbolicLink
)
{
	GUID ClassId;

	HKEY EmuPublicKey = NULL;

	DWORD w32Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE, EMU_PUBLIC_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &EmuPublicKey, NULL);

	if (ERROR_SUCCESS == w32Error)
	{
		HKEY ClassKey = NULL;

		w32Error = RegCreateKeyEx(EmuPublicKey, "{EB5A82E1-B4E7-47e8-97B0-F0751F97C2D1}", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &ClassKey, NULL);

		if (ERROR_SUCCESS == w32Error)
		{
			TCHAR ValueName[MAX_PATH]; _tcscpy(ValueName, SymbolicLink);

			TCHAR * token = _tcschr(ValueName, '\\');

			while (token)
			{
				*token = '#';

				token = _tcschr(token+1, '\\');
			}
 
			ULONG Type = 0;
			ULONG Size = sizeof(ClassId);
						
			w32Error = RegQueryValueEx(ClassKey, ValueName, 0, &Type, PBYTE(&ClassId), &Size);

			if (ERROR_SUCCESS != w32Error)
			{
				CoCreateGuid(&ClassId);
				
				RegSetValueEx(ClassKey, ValueName, 0, REG_BINARY, (BYTE*)&ClassId, sizeof(ClassId));

				w32Error = ERROR_SUCCESS;
			}

			RegCloseKey(ClassKey);
		}

		RegCloseKey(EmuPublicKey);
	}
	
	if (ERROR_SUCCESS != w32Error)
	{
		CoCreateGuid(&ClassId);
	}

	return ClassId;
}
Exemplo n.º 2
0
/**
 * Generates a new UID in outlook format. Format is described in VConverter::HrMakeBinaryUID
 *
 * @param[out]	lpStrData	returned generated UID string
 * @return		MAPI error code
 */
HRESULT HrGenerateUid(std::string *lpStrData)
{
	HRESULT hr = hrSuccess;
	std::string strByteArrayID = "040000008200E00074C5B7101A82E008";
	std::string strBinUid;
	GUID sGuid;
	FILETIME ftNow;
	ULONG ulSize = 1;

	hr = CoCreateGuid(&sGuid);
	if (hr != hrSuccess)
		goto exit;

	hr = UnixTimeToFileTime(time(NULL), &ftNow);
	if (hr != hrSuccess)
		goto exit;

	strBinUid = strByteArrayID;	// Outlook Guid
	strBinUid += "00000000";	// InstanceDate
	strBinUid += bin2hex(sizeof(FILETIME), (LPBYTE)&ftNow);
	strBinUid += "0000000000000000"; // Padding
	strBinUid += bin2hex(sizeof(ULONG), (LPBYTE)&ulSize); // always 1
	strBinUid += bin2hex(sizeof(GUID), (LPBYTE)&sGuid);	// new guid

	lpStrData->swap(strBinUid);

exit:
	return hr;
}
Exemplo n.º 3
0
//
// guid ops
//
guid & generate(guid & v)
{
  HRESULT r;
  r = CoCreateGuid(&v);
  assert(r == S_OK);
  return v;
}
Exemplo n.º 4
0
void PrintDoc(seakgOutput *pOutput, UnicodeString filename, UnicodeString name, UnicodeString uuid, UnicodeString code) {
  filename = filename.SubString(rootPath.Length()+1, filename.Length() - rootPath.Length());
  UnicodeString id = "";
//  UnicodeString id = "";

  code = encoding_html(code);
  name = encoding_html(name);

  TGUID g;
  OleCheck(CoCreateGuid(&g));
  //Sysutils::GUIDToString(g);
  //id = Sysutils::GUIDToString(g);
  //id = id.SubString(2,37) + "[" + IntToStr(g_nInc++) + "]";

  id = IntToStr(g_nInc++);
  while (id.Length() < 6)
    id = "0" + id;

  id = prefixforid + id;

  pOutput->addline("\t<doc>");
  pOutput->addline("\t\t<field name=\"id\">" + id + "</field>");
  pOutput->addline("\t\t<field name=\"project\">" + projectName + "</field>");
  pOutput->addline("\t\t<field name=\"name\">" + name + "</field>");
  pOutput->addline("\t\t<field name=\"uuid\">" + uuid.UpperCase() + "</field>");
  pOutput->addline("\t\t<field name=\"source_filepath\">" + filename + "</field>");
  pOutput->addline("\t\t<field name=\"full_source_code\">\n" + code + "\n\t\t</field>");
  pOutput->addline("\t</doc>");
};
Exemplo n.º 5
0
int os_uuid(lua_State* L)
{
	unsigned char bytes[16];
	char uuid[38];

#if PLATFORM_WINDOWS
	CoCreateGuid((GUID*)bytes);
#else
	int result;

	/* not sure how to get a UUID here, so I fake it */
	FILE* rnd = fopen("/dev/urandom", "rb");
	result = fread(bytes, 16, 1, rnd);
	fclose(rnd);
	if (!result)
		return 0;
#endif

	sprintf(uuid, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
		bytes[0], bytes[1], bytes[2], bytes[3],
		bytes[4], bytes[5],
		bytes[6], bytes[7],
		bytes[8], bytes[9],
		bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]);

	lua_pushstring(L, uuid);
	return 1;
}
Exemplo n.º 6
0
HRESULT WpdObjectEnumerator::CreateEnumContext(
    __inout         ContextMap*         pContextMap,
    __in            LPCWSTR             pszParentID,
    __deref_out_opt LPWSTR*             ppszEnumContext)
{

    HRESULT         hr              = S_OK;
    GUID            guidContext     = GUID_NULL;
    CComBSTR        bstrContext;
    EnumContext*    pContext        = NULL;

    if((pContextMap     == NULL) ||
       (pszParentID     == NULL) ||
       (ppszEnumContext == NULL))
    {
        hr = E_POINTER;
        CHECK_HR(hr, "Cannot have NULL parameter");
        return hr;
    }

    *ppszEnumContext = NULL;

    hr = CoCreateGuid(&guidContext);
    if (hr == S_OK)
    {
        bstrContext = guidContext;
        if(bstrContext.Length() == 0)
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to create BSTR from GUID");
        }
    }

    if (hr == S_OK)
    {
        pContext = new EnumContext();
        if(pContext != NULL)
        {
            CAtlStringW strKey = bstrContext;
            pContext->ParentID = pszParentID;

            hr = pContextMap->Add(strKey, pContext);
            CHECK_HR(hr, "Failed to add enumeration context to client context map");

            pContext->Release();
        }
        else
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to allocate enumeration context");
        }
    }

    if (hr == S_OK)
    {
        *ppszEnumContext = AtlAllocTaskWideString(bstrContext);
    }

    return hr;
}
Exemplo n.º 7
0
wstring Archive::get_temp_file_name() const {
  GUID guid;
  CHECK_COM(CoCreateGuid(&guid));
  wchar_t guid_str[50];
  CHECK(StringFromGUID2(guid, guid_str, ARRAYSIZE(guid_str)));
  return add_trailing_slash(arc_dir()) + guid_str + L".tmp";
}
Exemplo n.º 8
0
std::string CreateTempDir()
{
#ifdef _WIN32
  TCHAR temp[MAX_PATH];
  if (!GetTempPath(MAX_PATH, temp))
    return "";

  GUID guid;
  CoCreateGuid(&guid);
  TCHAR tguid[40];
  StringFromGUID2(guid, tguid, 39);
  tguid[39] = 0;
  std::string dir = TStrToUTF8(temp) + "/" + TStrToUTF8(tguid);
  if (!CreateDir(dir))
    return "";
  dir = ReplaceAll(dir, "\\", DIR_SEP);
  return dir;
#else
  const char* base = getenv("TMPDIR") ?: "/tmp";
  std::string path = std::string(base) + "/DolphinWii.XXXXXX";
  if (!mkdtemp(&path[0]))
    return "";
  return path;
#endif
}
Exemplo n.º 9
0
HRESULT
CTraceSession::Create(_In_z_ LPWSTR TraceName,
                      _In_z_ LPWSTR TraceDirectory)
{
    // Copy the name and dir
    m_TraceName = TraceName;

    // Create a trace session guid
    CoInitialize(NULL);
    HRESULT hr = CoCreateGuid(&m_TraceSessionGuid);
    CoUninitialize();

    // Bail if we failed to create the guid
    if (FAILED(hr)) return hr;

    m_FileInformation.LogFileame = TraceName;
    m_FileInformation.LogFileDirectory = TraceDirectory;

    // Set the string sizes
    size_t LoggerNameSize = (m_TraceName.size() + 1) * sizeof(wchar_t);
    size_t LogFileNameSize = MAX_PATH * sizeof(wchar_t);

    // Allocate the memory
    size_t BufferSize;
    BufferSize = sizeof(EVENT_TRACE_PROPERTIES) + LoggerNameSize + LogFileNameSize;
    m_EventTraceProperties = (PEVENT_TRACE_PROPERTIES)new byte[BufferSize];
    if (m_EventTraceProperties == nullptr) return ERROR_NOT_ENOUGH_MEMORY;

    ZeroMemory(m_EventTraceProperties, BufferSize);

    // Setup the wnode header
    m_EventTraceProperties->Wnode.BufferSize = BufferSize;
    m_EventTraceProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
    m_EventTraceProperties->Wnode.ClientContext = 1; // consider using 2
    CopyMemory(&m_EventTraceProperties->Wnode.Guid, &m_TraceSessionGuid, sizeof(GUID));

    SYSTEMTIME SystemTime;
    GetSystemTime(&SystemTime);
    SystemTimeToFileTime(&SystemTime, (LPFILETIME)&m_EventTraceProperties->Wnode.TimeStamp);

    // Set the defaults
    m_EventTraceProperties->BufferSize = 8; //kb
    m_EventTraceProperties->LogFileMode = EVENT_TRACE_FILE_MODE_SEQUENTIAL;

    // Set the string offsets
    m_EventTraceProperties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
    m_EventTraceProperties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + LoggerNameSize;

    // Copy the trace name
    CopyMemory((LPWSTR)((byte *)m_EventTraceProperties + m_EventTraceProperties->LoggerNameOffset),
               m_TraceName.c_str(),
               LoggerNameSize);

    std::wstring LogFile = m_FileInformation.LogFileDirectory + L"\\" + m_FileInformation.LogFileame + L".etl";
    CopyMemory((LPWSTR)((byte *)m_EventTraceProperties + m_EventTraceProperties->LogFileNameOffset),
               LogFile.c_str(),
               LogFile.size() * sizeof(wchar_t));

    return S_OK;
}
Exemplo n.º 10
0
wstring create_guid() {
  GUID guid;
  CHECK_COM(CoCreateGuid(&guid));
  wchar_t guid_str[50];
  CHECK(StringFromGUID2(guid, guid_str, ARRAYSIZE(guid_str)));
  return guid_str;
}
Exemplo n.º 11
0
MeaGUID::MeaGUID()
{
    HRESULT hr = CoCreateGuid(&m_guid);
    if (FAILED(hr)) {
        AfxThrowOleException(hr);
    }
}
Exemplo n.º 12
0
int CPDObjectFrame::FinalConstruct()
{
	HRESULT hr;

	hr = CPDObjectImpl<IPDObjectFrame>::FinalConstruct();
	if (FAILED(hr)) return hr;

	hr = CPDObjectWrappableImpl<CPDObjectFrame>::FinalConstruct();
	if (FAILED(hr)) return hr;

	hr = CPDObjectTransformableImpl<CPDObjectFrame>::FinalConstruct();
	if (FAILED(hr)) return hr;

	hr = CPDObjectWithAppearanceAndStrokeFillImpl<CPDObjectFrame>::FinalConstruct();
	if (FAILED(hr)) return hr;

	hr = CoCreateGuid(&m_uniqId);
	if (FAILED(hr)) return hr;

	DWORD cookie;

	hr = CComObject<CPDPath>::CreateInstance(&m_path);
	if (FAILED(hr)) return hr;
	m_path->AddRef();
	m_path->Advise(this, &cookie);

	return S_OK;
}
Exemplo n.º 13
0
void aafCreateGUID( GUID *p_guid )
{
#if defined( OS_WINDOWS )

    assert( p_guid );
    CoCreateGuid( p_guid );

#else

    // {1994bd00-69de-11d2-b6bc-fcab70ff7331}
    static GUID	sTemplate = { 0x1994bd00,  0x69de,  0x11d2,
			{ 0xb6, 0xbc, 0xfc, 0xab, 0x70, 0xff, 0x73, 0x31 } };
    static int	sInitializedTemplate = 0;


    assert( p_guid );

    if( !sInitializedTemplate )
    {
	aafUInt32	ticks = aafGetTickCount();

	time_t		timer = time( NULL );
	sTemplate.Data1 += timer + ticks;
	sInitializedTemplate = 1;
    }

    // Just bump the first member of the guid to emulate GUIDGEN behavior.
    ++sTemplate.Data1;
    *p_guid = sTemplate;

#endif    // OS_*
}
Exemplo n.º 14
0
/*******************************************************************************
 *  GAMEUX_RegisterGame
 *
 * Internal helper function. Registers game associated with given GDF binary in
 * Game Explorer. Implemented in gameexplorer.c
 *
 * Parameters:
 *  sGDFBinaryPath                  [I]     path to binary containing GDF file in
 *                                          resources
 *  sGameInstallDirectory           [I]     path to directory, where game installed
 *                                          it's files.
 *  installScope                    [I]     scope of game installation
 *  pInstanceID                     [I/O]   pointer to game instance identifier.
 *                                          If pointing to GUID_NULL, then new
 *                                          identifier will be generated automatically
 *                                          and returned via this parameter
 */
static HRESULT GAMEUX_RegisterGame(LPCWSTR sGDFBinaryPath,
        LPCWSTR sGameInstallDirectory,
        GAME_INSTALL_SCOPE installScope,
        GUID *pInstanceID)
{
    HRESULT hr = S_OK;
    struct GAMEUX_GAME_DATA GameData;

    TRACE("(%s, %s, 0x%x, %s)\n", debugstr_w(sGDFBinaryPath), debugstr_w(sGameInstallDirectory), installScope, debugstr_guid(pInstanceID));

    GAMEUX_initGameData(&GameData);
    GameData.sGDFBinaryPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(sGDFBinaryPath)+1)*sizeof(WCHAR));
    lstrcpyW(GameData.sGDFBinaryPath, sGDFBinaryPath);
    GameData.sGameInstallDirectory = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(sGameInstallDirectory)+1)*sizeof(WCHAR));
    lstrcpyW(GameData.sGameInstallDirectory, sGameInstallDirectory);
    GameData.installScope = installScope;

    /* generate GUID if it was not provided by user */
    if(IsEqualGUID(pInstanceID, &GUID_NULL))
        hr = CoCreateGuid(pInstanceID);

    GameData.guidInstanceId = *pInstanceID;

    /* load data from GDF binary */
    if(SUCCEEDED(hr))
        hr = GAMEUX_ParseGDFBinary(&GameData);

    /* save data to registry */
    if(SUCCEEDED(hr))
        hr = GAMEUX_WriteRegistryRecord(&GameData);

    GAMEUX_uninitGameData(&GameData);
    TRACE("returning 0x%08x\n", hr);
    return hr;
}
Exemplo n.º 15
0
HRESULT WpdObjectResources::CreateResourceContext(
    __inout         ContextMap*     pContextMap,
    __in            LPCWSTR         pszObjectID,
    __in            REFPROPERTYKEY  ResourceKey,
    __in            BOOL            bCreateRequest,
    __deref_out_opt LPWSTR*         ppszResourceContext)
{

    HRESULT         hr              = S_OK;
    GUID            guidContext     = GUID_NULL;
    ResourceContext* pContext       = NULL;

    if((pContextMap         == NULL) ||
       (pszObjectID         == NULL) ||
       (ppszResourceContext == NULL))
    {
        hr = E_POINTER;
        CHECK_HR(hr, "Cannot have NULL parameter");
        return hr;
    }

    *ppszResourceContext = NULL;

    if (hr == S_OK)
    {
        hr = CoCreateGuid(&guidContext);
        CHECK_HR(hr, "Failed to CoCreateGuid used for identifying the resource context");
    }

    if (hr == S_OK)
    {
        pContext = new ResourceContext();
        if(pContext == NULL)
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to allocate new resource context");
        }
    }

    if (hr == S_OK)
    {
        pContext->ObjectID      = pszObjectID;
        pContext->Key           = ResourceKey;
        pContext->CreateRequest = bCreateRequest;

        CAtlStringW strKey = CComBSTR(guidContext);
        hr = pContextMap->Add(strKey, pContext);
        CHECK_HR(hr, "Failed to insert bulk property operation context into our context Map");
    }

    if (hr == S_OK)
    {
        hr = StringFromCLSID(guidContext, ppszResourceContext);
        CHECK_HR(hr, "Failed to allocate string from GUID for resource context");
    }

    SAFE_RELEASE(pContext);

    return hr;
}
Exemplo n.º 16
0
int Utility::GenerateGUID(CString& sGUID)
{
    int status = 1;
    sGUID.Empty();

    strconv_t strconv;

    // Create GUID

    UCHAR *pszUuid = 0; 
    GUID *pguid = NULL;
    pguid = new GUID;
    if(pguid!=NULL)
    {
        HRESULT hr = CoCreateGuid(pguid);
        if(SUCCEEDED(hr))
        {
            // Convert the GUID to a string
            hr = UuidToStringA(pguid, &pszUuid);
            if(SUCCEEDED(hr) && pszUuid!=NULL)
            { 
                status = 0;
                sGUID = strconv.a2t((char*)pszUuid);
                RpcStringFreeA(&pszUuid);
            }
        }
        delete pguid; 
    }

    return status;
}
Exemplo n.º 17
0
int
MakeUUID(char *location) {
	if (CoCreateGuid((GUID*)location) == S_OK)
		return 1;
	FAIL();
	return 0;
}
Exemplo n.º 18
0
// ----------------
// Global routines
// ----------------
GUID CreateGUID()
{
	GUID Guid;
	DEBUG_EVALUATE_VERIFY(CoCreateGuid(&Guid) == S_OK);

	return Guid;
}
Exemplo n.º 19
0
Unique::Unique(void)
    :_id( GUID() )
{
    CoCreateGuid( &_id );

    _registry.insert(this);
}
Exemplo n.º 20
0
char* createGUID(char* uid){
	
#ifdef WIN32
	char buffer[GUID_LEN] = { 0 };
    GUID guid;
    if(CoCreateGuid(&guid))
    {
    	//printf(stderr, "create guid error\n");
    	return NULL;
    }
    _snprintf(buffer, sizeof(buffer),
    "%08X%04X%04x%02X%02X%02X%02X%02X%02X%02X%02X",
    guid.Data1, guid.Data2, guid.Data3,
    guid.Data4[0], guid.Data4[1], guid.Data4[2],
    guid.Data4[3], guid.Data4[4], guid.Data4[5],
    guid.Data4[6], guid.Data4[7]);
#endif
#ifndef CLIENTMAKE
	if(uid == NULL) return NULL;
	bzero(uid,32);
	uuid_t uu;
    uuid_generate(uu);
    //printf("{");
	int i = 0;
    for(i=0;i<15;i++)
        sprintf(uid,"%s%02X",uid,uu[i]);
	return uid;
	//TODO
    //printf("%02X}\n",uu[15]);
#endif	

}
Exemplo n.º 21
0
AnsiString CreateGuid(void) 
{ 
    System::TGUID g;

    OleCheck (CoCreateGuid (&g)); 
    return (Sysutils::GUIDToString (g)); 
} 
SystemTrayService::Handle SystemTrayServiceWindows::AddIcon(const RF_Draw::TrayIcon& Settings)
{
    // early exit if there are too many icons registered
    if(m_PImpl->m_IconData.Count() > MAX_WM_APP - WM_APP)
        return 0;

    RF_Mem::AutoPointer<NOTIFYICONDATA> notifyData(new NOTIFYICONDATA);

    RF_SysMem::Set(notifyData.Get(), 0, sizeof(NOTIFYICONDATA));
    notifyData->cbSize = sizeof(NOTIFYICONDATA);
    notifyData->hWnd = m_PImpl->m_HWND;
    notifyData->uVersion = NOTIFYICON_VERSION_4;
    notifyData->uFlags = NIF_GUID | NIF_MESSAGE;
    notifyData->uCallbackMessage = WM_APP + m_PImpl->m_IconData.Count();
    CoCreateGuid(&notifyData->guidItem);

    if(!Settings.Notification.IsEmpty())
    {
        notifyData->uFlags |= NIF_INFO | NIF_SHOWTIP;
        StringCchCopyA(notifyData->szInfo, ARRAYSIZE(notifyData->szInfo), Settings.Notification.c_str());
    }

    if(!Settings.Tooltip.IsEmpty())
    {
        notifyData->uFlags |= NIF_TIP;
        StringCchCopyA(notifyData->szTip, ARRAYSIZE(notifyData->szTip), Settings.Tooltip.c_str());
    }

    RF_IO::File icon;
    icon.SetLocation(Settings.Icon);
    if(icon.Exists())
    {
        RF_Type::String systemPath = Settings.Icon.GetComponents(RF_IO::UriComponents::Path);        
        int min = GetSystemMetrics(SM_CXSMICON);
        notifyData->hIcon = (HICON)LoadImage(NULL, systemPath.c_str(), IMAGE_ICON, 
                                             min, min, LR_LOADFROMFILE);
        if(notifyData->hIcon != 0)
        {
            notifyData->uFlags |= NIF_ICON;
        }
    }

    Handle handle = 0;
    SystemTrayService::Handle result = Shell_NotifyIcon(NIM_ADD, notifyData.Get());
    if(result)
    {
        handle = reinterpret_cast<Handle>(notifyData.Get());
        
        m_PImpl->m_IconData.Resize(m_PImpl->m_IconData.Count() + 1);
        auto& item = m_PImpl->m_IconData(m_PImpl->m_IconData.Count() - 1);
        m_PImpl->m_MessageLookup[notifyData->uCallbackMessage] = &item;
        m_PImpl->m_HandleLookup[handle] = &item;
        
        item.m_MenuHandle = m_PImpl->AddPopupMenu(Settings);
        item.m_NotificationData = notifyData;
    }

    return handle;
}
Exemplo n.º 23
0
// @pymethod <o PyIID>|pywintypes|CreateGuid|Creates a new, unique GUIID.
static PyObject *PyWin_CreateGuid(PyObject *self, PyObject *args)
{
	if (!PyArg_ParseTuple(args, ":CreateGuid"))
		return NULL;
	GUID guid;
	CoCreateGuid(&guid);
	return PyWinObject_FromIID(guid);
}
Exemplo n.º 24
0
// Generate a new guid
void DrGuid::Generate()
{
    HRESULT success = CoCreateGuid((GUID *)this);
    if (FAILED(success))
    {
        LogAssert("Fatal error, failed to create guid");
    }
}
Exemplo n.º 25
0
int main(int argc, char *argv[])
{
	GUID m_guid = GUID_NULL;
	int arg;
	HRESULT result;
	char *strfmt = "";
	if (argc < 2) {
		printf("usage: %s n\n",argv[0]);
		printf("n = format of output\n");
		printf("values are:\n");
		printf("1 = IMPLEMENT_OLECREATE defintion\n");
		printf("2 = DEFINE_GUID definition\n");
		printf("3 = static const GUID definition\n");
		printf("4 = registry format\n");
		printf("5 = uuidgen.exe format\n");
		return 1;
	}
	arg = atoi(argv[1]);
	if ((arg > 5) || (arg <= 0)) {
		printf("invalid argument\n");
		return 1;
	}
	if (CoInitialize(NULL) != S_OK)
	{
		printf("Unable to initialize OLE libraries\n");
		return 1;
	}
	result = CoCreateGuid(&m_guid);
	if (result != S_OK) {
		printf("Unable to create GUID\n");
		CoUninitialize();
		return 1;
	}
	switch (arg) {
	case 1:
	strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nIMPLEMENT_OLECREATE(<<class>>, <<external_name>>, \r\n0x%lx, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\r\n";
	break;
	case 2:
	strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nDEFINE_GUID(<<name>>, \r\n0x%lx, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\r\n";
	break;
	case 3:
	strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nstatic const GUID <<name>> = \r\n{ 0x%lx, 0x%x, 0x%x, { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x } };\r\n";
	break;
	case 4:
	strfmt = "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\n";
	break;
	case 5:
	strfmt = "%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X\r\n";
	break;
	}
	printf(strfmt,m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
	m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
	m_guid.Data4[6],m_guid.Data4[7],m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
	m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
	m_guid.Data4[6],m_guid.Data4[7]);
	CoUninitialize();
	return 0;
}
Exemplo n.º 26
0
    GUID createGUID() {
        GUID out;
#ifdef _WIN32
        if (FAILED(CoCreateGuid( & out ) ) ) crash();
#else
        pfc::nixGetRandomData( &out, sizeof(out) );
#endif
        return out;
    }
Exemplo n.º 27
0
/*******************************************************************************
 *  GAMEUX_RegisterGame
 *
 * Internal helper function. Registers game associated with given GDF binary in
 * Game Explorer. Implemented in gameexplorer.c
 *
 * Parameters:
 *  sGDFBinaryPath                  [I]     path to binary containing GDF file in
 *                                          resources
 *  sGameInstallDirectory           [I]     path to directory, where game installed
 *                                          it's files.
 *  installScope                    [I]     scope of game installation
 *  pInstanceID                     [I/O]   pointer to game instance identifier.
 *                                          If pointing to GUID_NULL, then new
 *                                          identifier will be generated automatically
 *                                          and returned via this parameter
 */
static HRESULT GAMEUX_RegisterGame(LPCWSTR sGDFBinaryPath,
        LPCWSTR sGameInstallDirectory,
        GAME_INSTALL_SCOPE installScope,
        GUID *pInstanceID)
{
    HRESULT hr = S_OK;
    struct GAMEUX_GAME_DATA GameData;

    TRACE("(%s, %s, 0x%x, %s)\n", debugstr_w(sGDFBinaryPath), debugstr_w(sGameInstallDirectory), installScope, debugstr_guid(pInstanceID));

    GAMEUX_initGameData(&GameData);
    GameData.sGDFBinaryPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(sGDFBinaryPath)+1)*sizeof(WCHAR));
    lstrcpyW(GameData.sGDFBinaryPath, sGDFBinaryPath);
    GameData.sGameInstallDirectory = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(sGameInstallDirectory)+1)*sizeof(WCHAR));
    lstrcpyW(GameData.sGameInstallDirectory, sGameInstallDirectory);
    GameData.installScope = installScope;

    /* generate GUID if it was not provided by user */
    if(IsEqualGUID(pInstanceID, &GUID_NULL))
        hr = CoCreateGuid(pInstanceID);

    GameData.guidInstanceId = *pInstanceID;

    /* load data from GDF binary */
    if(SUCCEEDED(hr))
    {
        struct parse_gdf_thread_param thread_param;
        HANDLE thread;
        DWORD ret;

        thread_param.GameData = &GameData;
        if(!(thread = CreateThread(NULL, 0, GAMEUX_ParseGDFBinary, &thread_param, 0, &ret)))
        {
            ERR("Failed to create thread.\n");
            hr = E_FAIL;
            goto done;
        }
        ret = WaitForSingleObject(thread, INFINITE);
        CloseHandle(thread);
        if(ret != WAIT_OBJECT_0)
        {
            ERR("Wait failed (%#x).\n", ret);
            hr = E_FAIL;
            goto done;
        }
        hr = thread_param.hr;
    }

    /* save data to registry */
    if(SUCCEEDED(hr))
        hr = GAMEUX_WriteRegistryRecord(&GameData);

done:
    GAMEUX_uninitGameData(&GameData);
    TRACE("returning 0x%08x\n", hr);
    return hr;
}
Exemplo n.º 28
0
HRESULT
primNewGUID (GUID* g1)
{
  if (g1 == NULL) {
    return E_FAIL;
  } else {
    return CoCreateGuid(g1);
  }
}
Exemplo n.º 29
0
// Creates a unique and unpredictable font name, in order to avoid collisions and to
// not allow access from CSS.
static String createUniqueFontName()
{
    GUID fontUuid;
    CoCreateGuid(&fontUuid);

    String fontName = base64Encode(reinterpret_cast<char*>(&fontUuid), sizeof(fontUuid));
    ASSERT(fontName.length() < LF_FACESIZE);
    return fontName;
}
Exemplo n.º 30
0
CBookmark::CBookmark(const std::wstring &strName,const std::wstring &strLocation,const std::wstring &strDescription) :
	m_strName(strName),
	m_strLocation(strLocation),
	m_strDescription(strDescription),
	m_iVisitCount(0)
{
	CoCreateGuid(&m_guid);
	GetSystemTimeAsFileTime(&m_ftCreated);
}