diff --git a/src/Thunks/api-ms-win-core-file.hpp b/src/Thunks/api-ms-win-core-file.hpp index 64c8996..c863d44 100644 --- a/src/Thunks/api-ms-win-core-file.hpp +++ b/src/Thunks/api-ms-win-core-file.hpp @@ -533,14 +533,16 @@ namespace YY goto __Exit; } - const auto _uNewLength = pObjectName->Name.Length - pFileNameInfo->FileNameLength + sizeof(wchar_t); - if (_uNewLength > MAXUINT16) { - lStatus = ERROR_BAD_PATHNAME; - goto __Exit; + const auto _uNewLength = pObjectName->Name.Length - pFileNameInfo->FileNameLength + sizeof(wchar_t); + if (_uNewLength > MAXUINT16) + { + lStatus = ERROR_BAD_PATHNAME; + goto __Exit; + } + VolumeNtName.Buffer = pObjectName->Name.Buffer; + VolumeNtName.Length = VolumeNtName.MaximumLength = static_cast(_uNewLength); } - VolumeNtName.Buffer = pObjectName->Name.Buffer; - VolumeNtName.Length = VolumeNtName.MaximumLength = static_cast(_uNewLength); if (VOLUME_NAME_NT & dwFlags) diff --git a/src/YY-Thunks.UnitTest/bcrypt.UnitTest.cpp b/src/YY-Thunks.UnitTest/bcrypt.UnitTest.cpp index fd184c6..a4309a4 100644 --- a/src/YY-Thunks.UnitTest/bcrypt.UnitTest.cpp +++ b/src/YY-Thunks.UnitTest/bcrypt.UnitTest.cpp @@ -72,7 +72,7 @@ namespace bcrypt Assert::IsTrue(_Status >= 0); Assert::IsNotNull(_hHash); - _Status = ::BCryptHashData(_hHash, reinterpret_cast("123"), 3, 0); + _Status = ::BCryptHashData(_hHash, (PUCHAR)"123", 3, 0); Assert::IsTrue(_Status >= 0); byte _ShaCurrent[kTargetShaLength] = {};