KP_SHARE BOOL PE_SetPasswordAndLock(void *pMgr, PW_ENTRY *pEntry, LPCTSTR lpPassword) { ASSERT(pEntry != NULL); if(pEntry == NULL) return FALSE; CPwManager *p = (CPwManager *)pMgr; ASSERT(p != NULL); if(p == NULL) return FALSE; p->UnlockEntryPassword(pEntry); SAFE_DELETE_ARRAY(pEntry->pszPassword); pEntry->pszPassword = _TcsCryptDupAlloc(lpPassword); p->LockEntryPassword(pEntry); return TRUE; }
BOOL CPwUtil::MemAllocCopyEntry(_In_ const PW_ENTRY *pExisting, _Out_ PW_ENTRY *pDestination) { ASSERT_ENTRY(pExisting); ASSERT(pDestination != NULL); if((pExisting == NULL) || (pDestination == NULL)) return FALSE; ZeroMemory(pDestination, sizeof(PW_ENTRY)); pDestination->uBinaryDataLen = pExisting->uBinaryDataLen; if(pExisting->pBinaryData != NULL) { pDestination->pBinaryData = new BYTE[pExisting->uBinaryDataLen + 1]; ASSERT(pDestination->pBinaryData != NULL); if(pDestination->pBinaryData == NULL) return FALSE; pDestination->pBinaryData[pExisting->uBinaryDataLen] = 0; memcpy(pDestination->pBinaryData, pExisting->pBinaryData, pExisting->uBinaryDataLen); } pDestination->pszAdditional = _TcsSafeDupAlloc(pExisting->pszAdditional); pDestination->pszBinaryDesc = _TcsSafeDupAlloc(pExisting->pszBinaryDesc); pDestination->pszPassword = _TcsCryptDupAlloc(pExisting->pszPassword); pDestination->pszTitle = _TcsSafeDupAlloc(pExisting->pszTitle); pDestination->pszURL = _TcsSafeDupAlloc(pExisting->pszURL); pDestination->pszUserName = _TcsSafeDupAlloc(pExisting->pszUserName); pDestination->tCreation = pExisting->tCreation; pDestination->tExpire = pExisting->tExpire; pDestination->tLastAccess = pExisting->tLastAccess; pDestination->tLastMod = pExisting->tLastMod; pDestination->uGroupId = pExisting->uGroupId; pDestination->uImageId = pExisting->uImageId; pDestination->uPasswordLen = pExisting->uPasswordLen; memcpy(pDestination->uuid, pExisting->uuid, 16); return TRUE; }