-
-
Notifications
You must be signed in to change notification settings - Fork 945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build and run/debug VeraCrypt on Visual Studio 2010 #1413
Comments
For now, debugging can be done by opening the Regarding printing to the console, this is not possible by default because the VeraCrypt executable is a WIN32 GUI application that is not attached to a console. Therefore, However, you can programmatically allocate a console window for your WIN32 GUI application and redirect the standard I/O streams ( Here is a function that creates a console and attaches it to the process: #include <stdio.h>
#include <fcntl.h>
#include <io.h>
void CreateConsole()
{
// Allocate a console for this app
if (!AllocConsole()) {
MessageBox(NULL, "Failed to allocate console!", "Error", MB_OK | MB_ICONERROR);
return;
}
FILE* fp;
// Redirect stdout to console
if (_wfreopen_s(&fp, L"CONOUT$", L"w", stdout) != 0) {
MessageBox(NULL, "Failed to redirect stdout!", "Error", MB_OK | MB_ICONERROR);
return;
}
// Redirect stdin to console
if (_wfreopen_s(&fp, L"CONIN$", L"r", stdin) != 0) {
MessageBox(NULL, "Failed to redirect stdin!", "Error", MB_OK | MB_ICONERROR);
return;
}
// Redirect stderr to console
if (_wfreopen_s(&fp, L"CONOUT$", L"w", stderr) != 0) {
MessageBox(NULL, "Failed to redirect stderr!", "Error", MB_OK | MB_ICONERROR);
return;
}
// Set console mode to support Unicode output
SetConsoleOutputCP(CP_UTF8);
SetConsoleCP(CP_UTF8);
// Optionally, change the console mode to make it more usable for input
HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
if (GetConsoleMode(hConsole, &mode)) {
// Disable Quick Edit mode if needed
SetConsoleMode(hConsole, mode & ~(ENABLE_QUICK_EDIT_MODE));
}
// Ensure std::wcout works correctly
std::ios::sync_with_stdio(true);
std::wcout.clear();
std::wcin.clear();
std::wcerr.clear();
} You can then call void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine)
{
WNDCLASSW wc;
char langId[6];
SetDefaultDllDirectoriesPtr SetDefaultDllDirectoriesFn = NULL;
#if !defined(SETUP)
wchar_t modPath[MAX_PATH];
#endif
INITCOMMONCONTROLSEX InitCtrls;
InitOSVersionInfo();
CreateConsole(); // <-- Added
// ... rest of the code
} |
@idrassi Thank you very much for your very detail answer. I'll try as your guide. |
Hi @idrassi, I did it again but got the error as in the picture. I chose I want to run the VeraCrypt application in VisualStudio and if I changed any code, if it has any errors when running, it shows in output of Visual Studio. Could you please help me? |
In your screenshot, I see that the "Setup" project is in bold, which indicates that it is the default project when debugging. However, you cannot debug the Setup project this way because the final setup, which is distributed, must first be created from the setup generated using the To debug the setup installer, you need to build all binaries in debug mode (x86, x64, and ARM64), then run the batch file "Signing\sign_test_debug.bat". This batch file will sign the binaries using a test certificate and create a setup installer that can be debugged. You can read the batch file to get better understanding about the process. The generated debug installer can then be debugged (Note: Visual Studio must be run as Administrator to debug the setup). |
@idrassi Thank. you for your explanation. |
No, you don't need to boot Windows into test mode to use the test binaries. The only exception is if you rebuild the driver project, which is disabled by default. Officially signed drivers are included in the source code repository (under So, simply rebuild the solution in debug mode, run |
@idrassi Thank you very much. I'll try it again |
@idrassi Hello, could you help me with this? |
You can change it v100. It is not mandatory to use Windows SDK 7.1. |
@idrassi I installed and ran successfully all steps in Windows Build Guide including executing "sign_test.bat" and importing certificates but after that I sill couldn't install VeraCrypt by "VeraCrypt Setup 1.26.15.exe" file. The error when I clicked the setup file There was one step that I hadn't tried yet Could you explain how can I compute sha512 fingerprint of the test code signing certificate? |
Hi @idrassi, could I know how to build and run or debug the project on VS2010 or VS2019?
Because I want to change some code to print something when running the application that I can see in the console.
The text was updated successfully, but these errors were encountered: