diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-12-08 22:51:49 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-12-08 23:42:47 +0100 |
commit | 5e96a5c44c3c78a901d77297517fa4842a297eb9 (patch) | |
tree | c96c1f8cfc13c9435d26d31d267a5a125493349d /src/Common/Password.c | |
parent | 7f1e21e6a1103fd4a488ddbe63571c6ffecb38ca (diff) | |
download | VeraCrypt-5e96a5c44c3c78a901d77297517fa4842a297eb9.tar.gz VeraCrypt-5e96a5c44c3c78a901d77297517fa4842a297eb9.zip |
Windows: enhancements to the mechanism preserving file timestamps, especially for keyfiles.
Diffstat (limited to 'src/Common/Password.c')
-rw-r--r-- | src/Common/Password.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Common/Password.c b/src/Common/Password.c index ca0dd468..f2413b6d 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -224,6 +224,19 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, if (dev == INVALID_HANDLE_VALUE) goto error; + else if (!bDevice && bPreserveTimestamp) + { + // ensure that Last Access and Last Write timestamps are not modified + ftLastAccessTime.dwHighDateTime = 0xFFFFFFFF; + ftLastAccessTime.dwLowDateTime = 0xFFFFFFFF; + + SetFileTime (dev, NULL, &ftLastAccessTime, NULL); + + if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) + bTimeStampValid = FALSE; + else + bTimeStampValid = TRUE; + } if (bDevice) { @@ -313,13 +326,6 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, SetRandomPoolEnrichedByUserStatus (FALSE); /* force the display of the random enriching dialog */ - if (!bDevice && bPreserveTimestamp) - { - if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) - bTimeStampValid = FALSE; - else - bTimeStampValid = TRUE; - } for (volumeType = TC_VOLUME_TYPE_NORMAL; volumeType < TC_VOLUME_TYPE_COUNT; volumeType++) { |