Пример #1
0
LONG CRegKey::RenameSubKey(HKEY hKey,LPCSTR szOldName,LPCSTR szNewName)
{
	HKEY hSource,hDestination;
	
	LONG lErr=RegOpenKeyEx(hKey,szOldName,0,KEY_READ,&hSource);
	if (lErr!=ERROR_SUCCESS)
		return lErr;
	DebugOpenHandle(dhtRegKey,hSource,szOldName);

	

	lErr=RegCreateKeyEx(hKey,szNewName,0,NULL,0,KEY_ALL_ACCESS,NULL,&hDestination,NULL);
	if (lErr!=ERROR_SUCCESS)
	{
		RegCloseKey(hSource);
		return lErr;
	}
	DebugOpenHandle(dhtRegKey,hDestination,szNewName);

	LONG lRet=CopyKey(hSource,hDestination);
	RegCloseKey(hSource);
	DebugCloseHandle(dhtRegKey,hSource,szOldName);
	RegCloseKey(hDestination);
	DebugCloseHandle(dhtRegKey,hDestination,szNewName);

    if (lRet==ERROR_SUCCESS)
	{
		RegDeleteKey(hKey,szOldName);
		return ERROR_SUCCESS;
	}
	return lRet;
}
Пример #2
0
bool DHWrapper::CopyPrivateKey(uint8_t *pDst, int32_t dstLength) {
	if (_pDH == NULL) {
		FATAL("DHWrapper not initialized");
		return false;
	}

	return CopyKey(_pDH->priv_key, pDst, dstLength);
}
Пример #3
0
BOOL
CreateUserHive (LPCWSTR lpKeyName,
                LPCWSTR lpProfilePath)
{
    HKEY hDefaultKey = NULL;
    HKEY hUserKey = NULL;
    LONG Error;
    BOOL Ret = FALSE;

    DPRINT ("CreateUserHive(%S) called\n", lpKeyName);

    Error = RegOpenKeyExW (HKEY_USERS,
                           L".Default",
                           0,
                           KEY_READ,
                           &hDefaultKey);
    if (Error != ERROR_SUCCESS)
    {
        SetLastError((DWORD)Error);
        goto Cleanup;
    }

    Error = RegOpenKeyExW (HKEY_USERS,
                           lpKeyName,
                           0,
                           KEY_ALL_ACCESS,
                           &hUserKey);
    if (Error != ERROR_SUCCESS)
    {
        SetLastError((DWORD)Error);
        goto Cleanup;
    }

    if (!CopyKey(hUserKey, hDefaultKey))
    {
        goto Cleanup;
    }

    if (!UpdateUsersShellFolderSettings(lpProfilePath,
                                        hUserKey))
    {
        goto Cleanup;
    }

    RegFlushKey (hUserKey);
    Ret = TRUE;

Cleanup:
    if (hUserKey != NULL)
        RegCloseKey (hUserKey);

    if (hDefaultKey != NULL)
        RegCloseKey (hDefaultKey);

    return Ret;
}
Пример #4
0
void TreeItemData::RenameKey(const Omega::string_t& strFrom, const Omega::string_t& strTo, TreeItemData* pItem)
{
	OTL::ObjectPtr<Omega::Registry::IKey> ptrNewKey = m_ptrKey->OpenSubKey(strTo,Omega::Registry::IKey::CreateNew);

	CopyKey(pItem->m_ptrKey,ptrNewKey);

	m_ptrKey->DeleteKey(strFrom);

	pItem->m_ptrKey = ptrNewKey;
}
Пример #5
0
static LONG MoveKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR lpSrcSubKey)
{
    LONG lResult;

    if (!lpSrcSubKey)
        return ERROR_INVALID_FUNCTION;

    lResult = CopyKey(hDestKey, lpDestSubKey, hSrcKey, lpSrcSubKey);
    if (lResult == ERROR_SUCCESS)
        SHDeleteKey(hSrcKey, lpSrcSubKey);

    return lResult;
}
Пример #6
0
void CDlgShowKey::OnCopyKey() 
{
	//In der Zwischen Ablage kopieren
	// TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
	CopyKey(strTitle, m_Key); 
///////////////////////////////////////////////
//	HENRIK KOY 06-08-2002
//  Das Einfügen des Schlüsselstrings in die Windows-Zwischenablage bewirkt, dass der vom User eventuell
//  dorthinein gespeicherte Inhalt überschrieben wird (verwirrt den User). -- deshalb auskommentiert
//	m_CtrlKey.SetSel(0,-1); 
//	m_CtrlKey.Copy();
	CDialog::OnOK();
}
Пример #7
0
static void PopulateDeviceTreeNode(TagPtr tag, Node * node)
{
    TagPtr next;
    uint32_t plen;
    void *pval;

    if (!(tag->type == kTagTypeDict))
        panic("tag is not dict");

    next = tag->tag;

    while (next) {
        /* next->tag has the value of the key */
        if (next->tag) {
            if (next->tag->type == kTagTypeArray) {
                if (next->string && next->string[0] == '@') {
                    /* @children */
                    WalkDeviceTreeNodeChildren(next->tag, node);
                } else {
                    /* Property array */
                    pval = ArrayToDeviceTreeData(next->tag, &plen);
                    DT__AddProperty(node, CopyKey(next), plen, pval);
                }
            } else if (next->tag->type == kTagTypeInteger) {
                pval = IntegerToDeviceTreeData((uint32_t)
                                               next->tag->string, &plen);
                DT__AddProperty(node, CopyKey(next), plen, pval);
            } else if (next->tag->type == kTagTypeString) {
                pval = StringToDeviceTreeData(next->tag->string, &plen);
                DT__AddProperty(node, CopyKey(next), plen, pval);
            }
        }

        next = next->tagNext;
    }
}
Пример #8
0
bool RegUtils::RecursiveCopyKey(const HKEY& hRootHive, const CStdString& sSourceKeyName, const CStdString& sTargetKeyName)
{
	HKEY hSourceKey = NULL;
	HKEY hTargetKey = NULL;
	long lRetVal	= 0;
	bool bRet		= true;

	if (sSourceKeyName.IsEmpty() || sTargetKeyName.IsEmpty())
	{
		LOG_WS_ERROR(_T("Empty source or target key specified"));
		return false;
	}

	if (((lRetVal = RegOpenKey(hRootHive, sSourceKeyName, &hSourceKey)) != ERROR_SUCCESS))
	{
		CStdString sErr;
		sErr.Format(_T("Failed to open source key %s, error %d"), sSourceKeyName.c_str(), lRetVal);
		LOG_WS_ERROR(sErr.c_str());
		return false;
	}

	CopyKey(hRootHive, hSourceKey, sTargetKeyName);

	TCHAR szKeyName[MAX_PATH];

	for (DWORD i = 0, retcode = ERROR_SUCCESS; retcode == ERROR_SUCCESS; ++i)
	{
		DWORD dwBuffSize = MAX_PATH;
		ZeroMemory(szKeyName, MAX_PATH);

		retcode = RegEnumKeyEx(hSourceKey, i, szKeyName, &dwBuffSize, NULL, NULL, NULL, NULL);
		if (retcode == ERROR_SUCCESS)
		{
			RecursiveCopyKey(hRootHive, sSourceKeyName + _T("\\") + szKeyName, sTargetKeyName + _T("\\") + szKeyName);
		}
		else if (retcode != ERROR_NO_MORE_ITEMS)
		{
			CStdString sErr;
			sErr.Format(_T("Failed to enumerate source key %s, error %d"), sSourceKeyName.c_str(), retcode);
			LOG_WS_ERROR(sErr.c_str());
			bRet = false;
		}
	}
	
	CloseKey(hSourceKey);

	return bRet;
}
Пример #9
0
void CDlgKeyHomophone::OnDecrypt() 
{
	// TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
	OnActualizeNoOfHomophones(); 
	m_crypt = 1;

	{ // Copy Homophone Parameter
		LoadString(AfxGetInstanceHandle(),IDS_PARAM_HOMOPHONE,pc_str,STR_LAENGE_STRING_TABLE);
		char tmpStr[6];
		sprintf(tmpStr, "%i", m_NoOfHomophones );
		CString Primes = CString("PARAMETER: ") + char(m_BaseHomophones + '0') + ' ' + char(m_ctrlEncryptFormatCharacters.GetCheck() + '0') +
			' ' + char(m_ctrlEncodeUmlauts.GetCheck() + '0') + 
			' ' + char(m_InputType + '0') + ' ' + CString( tmpStr );
		CopyKey ( pc_str, Primes );
	}
	OnOK();
}
Пример #10
0
void TreeItemData::CopyKey(OTL::ObjectPtr<Omega::Registry::IKey>& ptrOldKey, OTL::ObjectPtr<Omega::Registry::IKey>& ptrNewKey)
{
	std::set<Omega::string_t> values = ptrOldKey->EnumValues();
	for (std::set<Omega::string_t>::const_iterator i=values.begin();i!=values.end();++i)
	{
		ptrNewKey->SetValue(*i,ptrOldKey->GetValue(*i));
	}

	values = ptrOldKey->EnumSubKeys();
	for (std::set<Omega::string_t>::const_iterator i=values.begin();i!=values.end();++i)
	{
		OTL::ObjectPtr<Omega::Registry::IKey> ptrOldSub = ptrOldKey->OpenSubKey(*i,Omega::Registry::IKey::OpenExisting);
		OTL::ObjectPtr<Omega::Registry::IKey> ptrNewSub = ptrNewKey->OpenSubKey(*i,Omega::Registry::IKey::CreateNew);

		CopyKey(ptrOldSub,ptrNewSub);
	}
}
Пример #11
0
/*
 * CopySubkeys() -- copy subkeys from srcKey to dupKey
 *
 *     Note - srcName and dupName are the canonical path names of the
 *            open keys srcKey and dupKey, respectively.
 */
static long
CopySubkeys(const char *srcName, HKEY srcKey, const char *dupName, HKEY dupKey)
{
    long status;
    char *skEnum;

    status = RegEnumKeyAlt(srcKey, &skEnum);

    if (status == ERROR_SUCCESS && skEnum != NULL) {
	char *skEnumName, *skNameBuf;
	size_t skSrcNameMax, skDupNameMax, skNameMax;

	skNameMax = 0;
	skEnumName = skEnum;
	while (*skEnumName != '\0') {
	    size_t skNameLen = strlen(skEnumName);
	    skNameMax = max(skNameMax, skNameLen);

	    skEnumName += skNameLen + 1;
	}

	skSrcNameMax = strlen(srcName) + 1 + skNameMax + 1;
	skDupNameMax = strlen(dupName) + 1 + skNameMax + 1;

	skNameBuf = malloc(skSrcNameMax + skDupNameMax);
	if (skNameBuf == NULL) {
	    status = ERROR_NOT_ENOUGH_MEMORY;
	} else {
	    char *skSrcName = skNameBuf;
	    char *skDupName = skNameBuf + skSrcNameMax;

	    for (skEnumName = skEnum;
		 *skEnumName != '\0' && status == ERROR_SUCCESS;
		 skEnumName += strlen(skEnumName) + 1) {
		sprintf(skSrcName, "%s\\%s", srcName, skEnumName);
		sprintf(skDupName, "%s\\%s", dupName, skEnumName);

		status = CopyKey(skSrcName, skDupName);
	    }
	    free(skNameBuf);
	}
	free(skEnum);
    }
    return status;
}
Пример #12
0
/*
 * RegDupKeyAlt() -- duplicate sourceKey as targetKey; both sourceKey and
 *     targetKey must be in canonical path format.
 *
 *     NOTE: if targetKey already exists it will be replaced.
 */
long
RegDupKeyAlt(const char *sourceKey, const char *targetKey)
{
    long status;

    /* delete target key if extant */
    status = RegDeleteEntryAlt(targetKey, REGENTRY_KEY);

    if (status == ERROR_SUCCESS || status == ERROR_FILE_NOT_FOUND) {
	status = CopyKey(sourceKey, targetKey);

	if (status != ERROR_SUCCESS) {
	    /* clean-up partial duplication */
	    (void) RegDeleteEntryAlt(targetKey, REGENTRY_KEY);
	}
    }
    return status;
}
Пример #13
0
BOOL CIni::MoveKey(LPCTSTR lpSrcSection, LPCTSTR lpSrcKey, LPCTSTR lpDestSection, LPCTSTR lpDestKey, BOOL bFailIfExist) const
{
	return CopyKey(lpSrcSection, lpSrcKey, lpDestSection, lpDestKey, bFailIfExist)
		&& DeleteKey(lpSrcSection, lpSrcKey);
}
Пример #14
0
QString MenuCommands::Get(int ind, What w) const
{
    int cur = 0;

    if (cur++ == ind)
        return (w == Key ? FileKey() : (w == Title? FileTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportKey() : (w == Title? ImportTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts())));

    if (cur++ == ind)
        return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EditKey() : (w == Title? EditTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ViewKey() : (w == Title? ViewTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts())));

//  if (cur++ == ind)
//      return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts())));

    if (cur++ == ind)
        return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : ""));
    
    if (cur++ == ind)
        return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? CompatKey() : (w == Title? CompatTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts())));

    if (cur++ == ind)
        return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? WindowKey() : (w == Title? WindowTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts())));

    if (cur++ == ind)
        return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts())));

    return "";
}
Пример #15
0
static BOOL
CopyKey (HKEY hDstKey,
         HKEY hSrcKey)
{
    LONG Error;

#if (_WIN32_WINNT >= 0x0600)
    Error = RegCopyTreeW(hSrcKey,
                         NULL,
                         hDstKey);
    if (Error != ERROR_SUCCESS)
    {
        SetLastError((DWORD)Error);
        return FALSE;
    }

    return TRUE;

#else
    FILETIME LastWrite;
    DWORD dwSubKeys;
    DWORD dwValues;
    DWORD dwType;
    DWORD dwMaxSubKeyNameLength;
    DWORD dwSubKeyNameLength;
    DWORD dwMaxValueNameLength;
    DWORD dwValueNameLength;
    DWORD dwMaxValueLength;
    DWORD dwValueLength;
    DWORD dwDisposition;
    DWORD i;
    LPWSTR lpNameBuffer;
    LPBYTE lpDataBuffer;
    HKEY hDstSubKey;
    HKEY hSrcSubKey;

    DPRINT ("CopyKey() called \n");

    Error = RegQueryInfoKey (hSrcKey,
                             NULL,
                             NULL,
                             NULL,
                             &dwSubKeys,
                             &dwMaxSubKeyNameLength,
                             NULL,
                             &dwValues,
                             &dwMaxValueNameLength,
                             &dwMaxValueLength,
                             NULL,
                             NULL);
    if (Error != ERROR_SUCCESS)
    {
        DPRINT1 ("RegQueryInfoKey() failed (Error %lu)\n", Error);
        SetLastError((DWORD)Error);
        return FALSE;
    }

    DPRINT ("dwSubKeys %lu\n", dwSubKeys);
    DPRINT ("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength);
    DPRINT ("dwValues %lu\n", dwValues);
    DPRINT ("dwMaxValueNameLength %lu\n", dwMaxValueNameLength);
    DPRINT ("dwMaxValueLength %lu\n", dwMaxValueLength);

    /* Copy subkeys */
    if (dwSubKeys != 0)
    {
        lpNameBuffer = HeapAlloc (GetProcessHeap (),
                                  0,
                                  dwMaxSubKeyNameLength * sizeof(WCHAR));
        if (lpNameBuffer == NULL)
        {
            DPRINT1("Buffer allocation failed\n");
            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
            return FALSE;
        }

        for (i = 0; i < dwSubKeys; i++)
        {
            dwSubKeyNameLength = dwMaxSubKeyNameLength;
            Error = RegEnumKeyExW (hSrcKey,
                                   i,
                                   lpNameBuffer,
                                   &dwSubKeyNameLength,
                                   NULL,
                                   NULL,
                                   NULL,
                                   &LastWrite);
            if (Error != ERROR_SUCCESS)
            {
                DPRINT1 ("Subkey enumeration failed (Error %lu)\n", Error);
                HeapFree (GetProcessHeap (),
                          0,
                          lpNameBuffer);
                SetLastError((DWORD)Error);
                return FALSE;
            }

            Error = RegCreateKeyExW (hDstKey,
                                     lpNameBuffer,
                                     0,
                                     NULL,
                                     REG_OPTION_NON_VOLATILE,
                                     KEY_WRITE,
                                     NULL,
                                     &hDstSubKey,
                                     &dwDisposition);
            if (Error != ERROR_SUCCESS)
            {
                DPRINT1 ("Subkey creation failed (Error %lu)\n", Error);
                HeapFree (GetProcessHeap (),
                          0,
                          lpNameBuffer);
                SetLastError((DWORD)Error);
                return FALSE;
            }

            Error = RegOpenKeyExW (hSrcKey,
                                   lpNameBuffer,
                                   0,
                                   KEY_READ,
                                   &hSrcSubKey);
            if (Error != ERROR_SUCCESS)
            {
                DPRINT1 ("Error: %lu\n", Error);
                RegCloseKey (hDstSubKey);
                HeapFree (GetProcessHeap (),
                          0,
                          lpNameBuffer);
                SetLastError((DWORD)Error);
                return FALSE;
            }

            if (!CopyKey (hDstSubKey,
                          hSrcSubKey))
            {
                DPRINT1 ("Error: %lu\n", GetLastError());
                RegCloseKey (hSrcSubKey);
                RegCloseKey (hDstSubKey);
                HeapFree (GetProcessHeap (),
                          0,
                          lpNameBuffer);
                return FALSE;
            }

            RegCloseKey (hSrcSubKey);
            RegCloseKey (hDstSubKey);
        }

        HeapFree (GetProcessHeap (),
                  0,
                  lpNameBuffer);
    }

    /* Copy values */
    if (dwValues != 0)
    {
        lpNameBuffer = HeapAlloc (GetProcessHeap (),
                                  0,
                                  dwMaxValueNameLength * sizeof(WCHAR));
        if (lpNameBuffer == NULL)
        {
            DPRINT1 ("Buffer allocation failed\n");
            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
            return FALSE;
        }

        lpDataBuffer = HeapAlloc (GetProcessHeap (),
                                  0,
                                  dwMaxValueLength);
        if (lpDataBuffer == NULL)
        {
            DPRINT1 ("Buffer allocation failed\n");
            HeapFree (GetProcessHeap (),
                      0,
                      lpNameBuffer);
            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
            return FALSE;
        }

        for (i = 0; i < dwValues; i++)
        {
            dwValueNameLength = dwMaxValueNameLength;
            dwValueLength = dwMaxValueLength;
            Error = RegEnumValueW (hSrcKey,
                                   i,
                                   lpNameBuffer,
                                   &dwValueNameLength,
                                   NULL,
                                   &dwType,
                                   lpDataBuffer,
                                   &dwValueLength);
            if (Error != ERROR_SUCCESS)
            {
                DPRINT1("Error: %lu\n", Error);
                HeapFree (GetProcessHeap (),
                          0,
                          lpDataBuffer);
                HeapFree (GetProcessHeap (),
                          0,
                          lpNameBuffer);
                SetLastError((DWORD)Error);
                return FALSE;
            }

            Error = RegSetValueExW (hDstKey,
                                    lpNameBuffer,
                                    0,
                                    dwType,
                                    lpDataBuffer,
                                    dwValueLength);
            if (Error != ERROR_SUCCESS)
            {
                DPRINT1("Error: %lu\n", Error);
                HeapFree (GetProcessHeap (),
                          0,
                          lpDataBuffer);
                HeapFree (GetProcessHeap (),
                          0,
                          lpNameBuffer);
                SetLastError((DWORD)Error);
                return FALSE;
            }
        }

        HeapFree (GetProcessHeap (),
                  0,
                  lpDataBuffer);

        HeapFree (GetProcessHeap (),
                  0,
                  lpNameBuffer);
    }

    DPRINT ("CopyKey() done \n");

    return TRUE;
#endif
}
Пример #16
0
static LONG CopyKey(HKEY hDestKey, LPCTSTR lpDestSubKey, HKEY hSrcKey, LPCTSTR lpSrcSubKey)
{
    LONG lResult;
    DWORD dwDisposition;
    HKEY hDestSubKey = NULL;
    HKEY hSrcSubKey = NULL;
    DWORD dwIndex, dwType, cbName, cbData;
    TCHAR szSubKey[256];
    TCHAR szValueName[256];
    BYTE szValueData[512];

    FILETIME ft;

    /* open the source subkey, if specified */
    if (lpSrcSubKey)
    {
        lResult = RegOpenKeyEx(hSrcKey, lpSrcSubKey, 0, KEY_ALL_ACCESS, &hSrcSubKey);
        if (lResult)
            goto done;
        hSrcKey = hSrcSubKey;
    }

    /* create the destination subkey */
    lResult = RegCreateKeyEx(hDestKey, lpDestSubKey, 0, NULL, 0, KEY_WRITE, NULL,
                             &hDestSubKey, &dwDisposition);
    if (lResult)
        goto done;

    /* copy all subkeys */
    dwIndex = 0;
    do
    {
        cbName = sizeof(szSubKey) / sizeof(szSubKey[0]);
        lResult = RegEnumKeyEx(hSrcKey, dwIndex++, szSubKey, &cbName, NULL, NULL, NULL, &ft);
        if (lResult == ERROR_SUCCESS)
        {
            lResult = CopyKey(hDestSubKey, szSubKey, hSrcKey, szSubKey);
            if (lResult)
                goto done;
        }
    }
    while(lResult == ERROR_SUCCESS);

    /* copy all subvalues */
    dwIndex = 0;
    do
    {
        cbName = sizeof(szValueName) / sizeof(szValueName[0]);
        cbData = sizeof(szValueData) / sizeof(szValueData[0]);
        lResult = RegEnumValue(hSrcKey, dwIndex++, szValueName, &cbName, NULL, &dwType, szValueData, &cbData);
        if (lResult == ERROR_SUCCESS)
        {
            lResult = RegSetValueEx(hDestSubKey, szValueName, 0, dwType, szValueData, cbData);
            if (lResult)
                goto done;
        }
    }
    while(lResult == ERROR_SUCCESS);

    lResult = ERROR_SUCCESS;

done:
    if (hSrcSubKey)
        RegCloseKey(hSrcSubKey);
    if (hDestSubKey)
        RegCloseKey(hDestSubKey);
    if (lResult != ERROR_SUCCESS)
        SHDeleteKey(hDestKey, lpDestSubKey);
    return lResult;
}
Пример #17
0
// First, couple of registry extensions
LONG CRegKey::CopyKey(HKEY hSource,HKEY hDestination)
{
	LONG lRet=ERROR_SUCCESS;

	// First copy subkeys
	char szName[1000];
	DWORD cb,i;
	for (i=0;;i++)
	{
		char szClass[1000];
		DWORD cb2=1000;
		cb=1000;

		if (RegEnumKeyEx(hSource,i,szName,&cb,NULL,szClass,&cb2,NULL)!=ERROR_SUCCESS)
			break;

		HKEY hSubSource,hSubDestination;

		LONG lErr=RegOpenKeyEx(hSource,szName,0,KEY_READ,&hSubSource);
		if (lErr!=ERROR_SUCCESS)
		{
			lRet=lErr;
			continue;
		}
		DebugOpenHandle(dhtRegKey,hSubSource,szName);


		lErr=RegCreateKeyEx(hDestination,szName,0,szClass,0,KEY_ALL_ACCESS,NULL,&hSubDestination,NULL);
		if (lErr!=ERROR_SUCCESS)
		{
			RegCloseKey(hSubSource);
			lRet=lErr;
			continue;
		}
		DebugOpenHandle(dhtRegKey,hSubDestination,szName);


		if (CopyKey(hSubSource,hSubDestination)<=0)
			lRet=lErr;
			

		RegCloseKey(hSubSource);
		RegCloseKey(hSubDestination);
		DebugCloseRegKey(hSubSource);
		DebugCloseRegKey(hSubDestination);

		

	}

	// Now copying values
	for (i=0;;i++)
	{
		cb=1000;
		DWORD dwType,dwDataSize;
		if (RegEnumValue(hSource,i,szName,&cb,NULL,&dwType,NULL,&dwDataSize)!=ERROR_SUCCESS)
			break;

        BYTE* pData=new BYTE[dwDataSize+1];

		LONG lErr;
		if ((lErr=RegQueryValueEx(hSource,szName,NULL,NULL,pData,&dwDataSize))!=ERROR_SUCCESS)
			lRet=lErr;
		else if ((lErr=RegSetValueEx(hDestination,szName,NULL,dwType,pData,dwDataSize))!=ERROR_SUCCESS)
			lRet=lErr;

		delete[] pData;
	}

     return lRet;   
}