MCPcopy Create free account
hub / github.com/Chuyu-Team/YY-Thunks / Create

Method Create

src/Thunks/bcrypt.hpp:726–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724 struct BCryptAlgorithmByCryptoAPI : BCryptAlgorithm
725 {
726 static NTSTATUS __fastcall Create(_In_ const BCryptMapItem* _pMapItem, _In_ ULONG _fOpenAlgorithmFlags, _Outptr_ BCryptAlgorithm** _ppAlgorithm)
727 {
728 *_ppAlgorithm = nullptr;
729
730 HCRYPTPROV _hProv;
731 do
732 {
733 if (_pMapItem->uProvType == PROV_RSA_FULL || _pMapItem->uProvType == PROV_RSA_AES)
734 {
735 // Windows XP SP3才支持 MS_ENH_RSA_AES_PROV_XP_W
736 const auto _szEnhRsaAesProvider = internal::GetSystemVersion() < internal::MakeVersion(6, 0) ? MS_ENH_RSA_AES_PROV_XP_W : MS_ENH_RSA_AES_PROV_W;
737 if (CryptAcquireContextW(&_hProv, nullptr, _szEnhRsaAesProvider, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
738 {
739 break;
740 }
741
742 if (CryptAcquireContextW(&_hProv, nullptr, _szEnhRsaAesProvider, PROV_RSA_AES, CRYPT_NEWKEYSET))
743 {
744 break;
745 }
746 }
747
748 if (CryptAcquireContextW(&_hProv, nullptr, _pMapItem->szProvider, _pMapItem->uProvType, CRYPT_VERIFYCONTEXT))
749 break;
750
751 if (CryptAcquireContextW(&_hProv, nullptr, _pMapItem->szProvider, _pMapItem->uProvType, CRYPT_NEWKEYSET))
752 break;
753
754 return STATUS_INVALID_PARAMETER;
755 } while (false);
756
757 const auto _hProcessHeap = ((TEB*)NtCurrentTeb())->ProcessEnvironmentBlock->ProcessHeap;
758 auto _pBCryptAlgorithm = (BCryptAlgorithmType*)HeapAlloc(_hProcessHeap, 0, sizeof(BCryptAlgorithmType));
759 if (!_pBCryptAlgorithm)
760 {
761 CryptReleaseContext(_hProv, 0);
762 return STATUS_NO_MEMORY;
763 }
764
765 new (_pBCryptAlgorithm) BCryptAlgorithmType();
766 _pBCryptAlgorithm->pMapItem = _pMapItem;
767 _pBCryptAlgorithm->hProv = _hProv;
768 _pBCryptAlgorithm->fOpenAlgorithmFlags = _fOpenAlgorithmFlags;
769 *_ppAlgorithm = _pBCryptAlgorithm;
770 return STATUS_SUCCESS;
771 }
772 };
773
774 struct BCryptHash : public BCryptObject

Callers

nothing calls this directly

Calls 2

GetSystemVersionFunction · 0.85
MakeVersionFunction · 0.70

Tested by

no test coverage detected