Overwrite existing file - AES Crypt Error

Discussion related to AES Crypt, the file encryption software for Windows, Linux, Mac, and Java.
Post Reply
franc
Posts: 7
Joined: Fri Dec 04, 2020 10:23 am

Overwrite existing file - AES Crypt Error

Post by franc »

Hallo

I use AES Crypt on PC (W10) and Mac (10.11) for some sensible files I have in some subversion repo.
The textfiles are encrypted in this repo. e.g. passwords.txt.aes.

On PC I can use the context menu to decrypt them, but when I want to encrypt them again, I have to first delete the aes file, because it says (see also attached Screenshot):
AES Crypt Error
Unable to open output file C:\path\to\passwords.txt.aes:
Die Datei ist vorhanden
Is there a way to tell AES Crypt by default to overwrite the files if existing? Or at least ask if can do?
On Mac I have the same problem, but here there are even no context handlers, so I use the toolbar and drag and drop the files on a AES Crypt icon.

Thank for hint.

frank
Attachments
AESCryptOverwrite.jpg
AESCryptOverwrite.jpg (8.09 KiB) Viewed 24095 times
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: Overwrite existing file - AES Crypt Error

Post by paulej »

Not on Windows, no. The Mac and Linux versions rely on the users to not make a mistake and will write over old files. The Windows version assumes the user might have made a mistake and refuses to overwrite existing files. (The command-line version might, but I cannot recall off-hand. It should also complain, just for consistency.)

Which way is better? I don't know. Some people appreciate the fact there is an error to prevent mistakes and some people don't like it. I have requests on the Mac / Linux side to behave like Windows, and some on Windows who want it like is is on Linux.

Allowing it to overwrite files is easy to do, but the problem is that it's very clear that there will be people unhappy with the result, regardless of which approach is taken. For the GUI versions, I could change the software to ask "do you want to overwrite the file?" That adds another step, but it is less intrusive than having to cancel and start over.

This is definitely on my to-do list, but I'm not sure when I'll get a chance to get to the to-do list. I have a lot of enhancements planned and have an ever-growing list.
franc
Posts: 7
Joined: Fri Dec 04, 2020 10:23 am

Re: Overwrite existing file - AES Crypt Error

Post by franc »

Thanks again!
I stumbled on this question of mine again, still having that same issue.

I would love to have a CheckBox to accept overwrite on encrypt, e.g.:

The file exists, do you want to overwrite it?
Yes / No

At the moment I have to do it manually, but this is annoying with the totalcmd comments, I have to copy them manually as well.
Thanks
frank
franc
Posts: 7
Joined: Fri Dec 04, 2020 10:23 am

Re: Overwrite existing file - AES Crypt Error

Post by franc »

Or, is there a How-To for compiling AESCrypt for Windows W11?
I found the source code but I read Visual Studio 2010, I have 2022, Build Tools does not fit etc.
If I could compile it by myself then I could create a Dialog for "Overwrite? Yes/No" or just hardcode overwriting (which I only need).

Thanks for hints. But I begin to doubt that this code and forum is still active :(
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: Overwrite existing file - AES Crypt Error

Post by paulej »

Honestly, I still go back to using VS 2010. The reason is the integrated installer.

What I need to do is update the code to use a newer installer.

All in due time, but for now I just use the older compiler.

That said, if you want to just build and not create an install package, I suspect it would. You might need to remove the installer project.
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: Overwrite existing file - AES Crypt Error

Post by paulej »

franc wrote: Sun Nov 19, 2023 1:25 pm The file exists, do you want to overwrite it?
Yes / No
Yeah, that's on my list. It's risky, though, as I know someone will accidentally delete a file. But, it would be a good addition.
franc
Posts: 7
Joined: Fri Dec 04, 2020 10:23 am

Re: Overwrite existing file - AES Crypt Error

Post by franc »

OK, I installed Visual Studio 2010 C++ Express from Visual Studio Subscriptions and still I get an error about Setup.vdproj, as if even 2010 seems too new :)
Error on Setup.vdproj
Error on Setup.vdproj
2023-11-21_11-33-02.png (9.91 KiB) Viewed 11633 times
But I didnt install then 2008 Express, unsure if it would work anyway.

I tried to compile then (with VS 2010 or 2022) any of the other projects, and only the Console project compiles, but none of the other projects, I get e.g. this error with VS2010:
"error MSB8008: Specified platform toolset (v143) is not installed or invalid" - do I need for that the Visual Studio 2010 Software Development Kit (SDK)?
With VS2022 I get a bunch of errors, see above.

The code is from 2015, by the way. That "to-do list" must be really huge ;)

I give up here. Without any compiling how-to (what exactly is needed, which version exactly, etc.) I guess I will spend the other half day without any guarantee of success.

So if you really re-start to code that project one day, I think the first thing should be to make it possible to compile it with the actual Visual Studio Community 2022 - or 2025 at this time then, I guess ;)
Thanks anyway!

Addendum: Errors at compiling the project with VS2022:

Code: Select all

Build started at 13:12...
1>------ Build started: Project: AESCryptPS, Configuration: Debug x64 ------
2>------ Build started: Project: AESCrypt, Configuration: Debug x64 ------
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: The intermediate directory (x64\Debug\) contains files shared from another project (AESCrypt.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>Checking for required files
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: The intermediate directory (x64\Debug\) contains files shared from another project (AESCryptPS.vcxproj).  This can lead to incorrect clean and rebuild behavior.
2>cl : command line  warning D9035: option 'Gm' has been deprecated and will be removed in a future release
1>LINK : fatal error LNK1104: cannot open file 'rpcndr.lib'
1>Done building project "AESCryptPS.vcxproj" -- FAILED.
2>stdafx.cpp
2>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt\stdafx.h(44,25): error C2039: 'basic_string': is not a member of 'std'
2>(compiling source file 'stdafx.cpp')
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\list(23,1):
2>see declaration of 'std'
2>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt\stdafx.h(44,25): error C2065: 'basic_string': undeclared identifier
2>(compiling source file 'stdafx.cpp')
2>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt\stdafx.h(44,38): error C2275: 'TCHAR': expected an expression instead of a type
2>(compiling source file 'stdafx.cpp')
2>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt\stdafx.h(44,14): error C2974: 'std::list': invalid template argument for '_Ty', type expected
2>(compiling source file 'stdafx.cpp')
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\list(755,12):
2>see declaration of 'std::list'
2>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt\stdafx.h(44,14): error C2976: 'std::list': too few template arguments
2>(compiling source file 'stdafx.cpp')
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\list(755,12):
2>see declaration of 'std::list'
2>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt\stdafx.h(44,45): error C2059: syntax error: '>'
2>(compiling source file 'stdafx.cpp')
2>Done building project "AESCrypt.vcxproj" -- FAILED.
3>------ Build started: Project: AESCrypt32, Configuration: Debug x64 ------
3>cl : command line  warning D9035: option 'Gm' has been deprecated and will be removed in a future release
3>stdafx.cpp
3>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt32\stdafx.h(45,25): error C2039: 'basic_string': is not a member of 'std'
3>(compiling source file 'stdafx.cpp')
3>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\list(23,1):
3>see declaration of 'std'
3>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt32\stdafx.h(45,25): error C2065: 'basic_string': undeclared identifier
3>(compiling source file 'stdafx.cpp')
3>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt32\stdafx.h(45,38): error C2275: 'TCHAR': expected an expression instead of a type
3>(compiling source file 'stdafx.cpp')
3>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt32\stdafx.h(45,14): error C2974: 'std::list': invalid template argument for '_Ty', type expected
3>(compiling source file 'stdafx.cpp')
3>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\list(755,12):
3>see declaration of 'std::list'
3>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt32\stdafx.h(45,14): error C2976: 'std::list': too few template arguments
3>(compiling source file 'stdafx.cpp')
3>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\list(755,12):
3>see declaration of 'std::list'
3>D:\Projekte\AESCrypt\AESCrypt_source_v310\AESCrypt32\stdafx.h(45,45): error C2059: syntax error: '>'
3>(compiling source file 'stdafx.cpp')
3>Done building project "AESCrypt32.vcxproj" -- FAILED.
========== Build: 0 succeeded, 3 failed, 1 up-to-date, 0 skipped ==========
========== Build completed at 13:12 and took 02,706 seconds ==========
franc
Posts: 7
Joined: Fri Dec 04, 2020 10:23 am

Re: Overwrite existing file - AES Crypt Error

Post by franc »

OK, got it :)
I had to switch all projects to 2012 Tools (or 2010 Tools):
AESCrypt Property Pages - Platform Toolset
AESCrypt Property Pages - Platform Toolset
AESCrypt Property Pages.png (36.54 KiB) Viewed 11621 times
And I just deleted in some project file the rpcndr.lib and now I can compile it with VS2022 :)
Now lets see how I can handle the CREATE_ALWAYS instead of CREATE_NEW as dwCreationDisposition in OpenFile aka CreateFileW...

EDIT: by the way, when I switch to EN as VS2022 language (instead of the system language), the Property Pages dialog is crippled, showing only Code Analysis, this is a wellknown (and never fixed) bug of VS, e.g.: Empty property page when in different languages
Last edited by franc on Tue Nov 21, 2023 6:04 pm, edited 1 time in total.
franc
Posts: 7
Joined: Fri Dec 04, 2020 10:23 am

Re: Overwrite existing file - AES Crypt Error

Post by franc »

OK, done!
The crucial function is indeed that CreateFileW (fom Windows API) and the param dwCreationDisposition
I changed the code as this: In AESCryptWorkerThreads.cpp I changed in line 392 CREATE_NEW to CREATE_ALWAYS:

Code: Select all

            result_code = out_buffered_file.OpenFile(
                                    out_file.c_str(),
                                    true,
                                    CREATE_ALWAYS);
and in line 986 same, from CREATE_NEW to CREATE_ALWAYS:

Code: Select all

            result_code = out_buffered_file.OpenFile(   out_file,
                                                        true,
                                                        CREATE_ALWAYS);
(One is for overwrite existing aes on crypt, one is to overwrite existing file on decrypt)
Then I compiled it, AESCrypt (the DLL), AESCrypt32 (the GUI) and Console (exe).
Deleted prefetch and voila, works flawless :)

What the heck this AESCryptPS is, I dont know, cannot compile it, I guess it is ARM stuff. Never mind.
Thanks.
User avatar
paulej
Posts: 595
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: Overwrite existing file - AES Crypt Error

Post by paulej »

Sounds like you got it all working! Congratulations!
Post Reply