Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f7193f8
CreateProperties.
nbb1967 Jan 22, 2026
9bca422
FsInfoDialog
nbb1967 Jan 23, 2026
0e7e60a
MountPropertyPage
nbb1967 Jan 24, 2026
6b69a26
CryptPropertySheet
nbb1967 Jan 24, 2026
1756a51
Refactoring
nbb1967 Jan 27, 2026
98eea70
Licenses to RCDATA. Folder lic for licenses.txt. CryptAboutPropertyPage
nbb1967 Jan 30, 2026
aa29978
SettingsPropertyPage
nbb1967 Jan 31, 2026
359ccf9
rename en_secure.txt
nbb1967 Jan 31, 2026
70bd032
cryptdokan. GetStringFromResources() ALT edition
nbb1967 Feb 5, 2026
d69ccc5
simplification
nbb1967 Feb 5, 2026
5431c4f
correct, additions
nbb1967 Feb 6, 2026
31a6dc5
minor edits
nbb1967 Feb 6, 2026
58f7387
debugging
nbb1967 Feb 6, 2026
49664bd
renaming
nbb1967 Feb 8, 2026
305b75d
lic
nbb1967 Feb 10, 2026
94ad2fa
refactoring2
nbb1967 Feb 11, 2026
2a47678
format
nbb1967 Feb 11, 2026
f8446dd
localization-independent text in registry
nbb1967 Feb 14, 2026
6985444
spelling
nbb1967 Feb 18, 2026
f9c577b
formatting
nbb1967 Feb 18, 2026
87e8206
frm
nbb1967 Feb 18, 2026
07b2de8
frm2
nbb1967 Feb 18, 2026
f72712e
Splitting RC. MUI
nbb1967 Feb 23, 2026
b755229
Reminder
nbb1967 Feb 24, 2026
b2da6db
Cleaning. Fix for Includes
nbb1967 Mar 3, 2026
00abb69
Language controls. UI Polishing
nbb1967 Mar 1, 2026
4078e43
Implementation. Moving arrays.
nbb1967 Mar 3, 2026
26885db
Include cleanup from remove-unused-rc
nbb1967 Mar 4, 2026
3e57205
Merge hardcoded-str-to-rc into splitting-rc (resolved binary RC confl…
nbb1967 Mar 4, 2026
a2e14fb
Merge branch 'splitting-rc' into lang-switch
nbb1967 Mar 4, 2026
c22b8d7
text msgBox
nbb1967 Mar 4, 2026
4e1103b
Apply button
nbb1967 Mar 4, 2026
1739458
removed localized license files. changed resource loading (skip over …
bailey27 Mar 17, 2026
49d4aaa
removed localized license files. changed resource loading (skip over …
bailey27 Mar 17, 2026
a202890
use different version of GetStringForLang
bailey27 Mar 17, 2026
a507565
make main prog copyright English only. Make some static CStrings const.
bailey27 Mar 19, 2026
f4167c2
remove deleted files
bailey27 Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Release/
cppcryptfs/Debug/
cppcryptfs/Release/
cppcryptfs/cppcryptfs.aps
cppcryptfs/res/ru/Resources_RU.aps
cppcryptfs/res/en/Resources_EN.aps
Report*.vspx
Report*.diagsession
enc_temp_folder/
Expand Down
126 changes: 123 additions & 3 deletions cppcryptfs/cppcryptfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ THE SOFTWARE.
#include "ui/uiutil.h"
#include "../libipc/server.h"
#include "../libipc/client.h"
#include "ui/locutils.h"


#ifdef _DEBUG
Expand Down Expand Up @@ -85,6 +86,114 @@ CcppcryptfsApp::CcppcryptfsApp()
auto context = get_crypt_context(BLOCK_IV_LEN, AES_MODE_GCM);
}

// Callback function for searching language sections in the EXE string block
BOOL CALLBACK EnumLangsCallback(HMODULE hModule, LPCTSTR lpType, LPCTSTR lpName, WORD wLang, LONG_PTR lParam) {
auto* pList = reinterpret_cast<std::vector<LanguageOption>*>(lParam);

// Exclude duplicates when scanning String Table blocks
for (const auto& item : *pList) {
if (item.langID == wLang) return TRUE;
}

LanguageOption opt;
opt.langID = wLang;
// Extract language names
opt.name = theApp.GetStringForLang(hModule, IDS_LANGUAGE_NAME, wLang);

if (!opt.name.IsEmpty()) {
pList->push_back(opt);
}
return TRUE;
}

// Scan EXE resources for translated sections
void CcppcryptfsApp::ScanResourcesForLanguages() {
m_vAvailableLangs.clear();
// (IDS_LANGUAGE_NAME >> 4) + 1 - formula for calculating the block number in String Table
EnumResourceLanguages(NULL, RT_STRING, MAKEINTRESOURCE((IDS_LANGUAGE_NAME >> 4) + 1),
EnumLangsCallback, (LONG_PTR)&m_vAvailableLangs);
}

// Direct reading of a string from a specific language section (bypassing the current thread locale)
CString CcppcryptfsApp::GetStringForLang(HMODULE hInst, UINT nID, WORD wLang)
{
HRSRC hRes = ::FindResourceExW(
hInst,
RT_STRING,
MAKEINTRESOURCEW((nID >> 4) + 1),
wLang);

if (!hRes)
return CString();

HGLOBAL hGlobal = ::LoadResource(hInst, hRes);
if (!hGlobal)
return CString();

DWORD resourceSizeBytes = ::SizeofResource(hInst, hRes);
if (resourceSizeBytes < sizeof(WORD) || (resourceSizeBytes % sizeof(WORD)) != 0)
return CString();

const WORD* pWords = static_cast<const WORD*>(::LockResource(hGlobal));
if (!pWords)
return CString();

const size_t wordCount = resourceSizeBytes / sizeof(WORD);
size_t pos = 0;

const int index = nID & 0x000F;

for (int i = 0; i < index; ++i)
{
if (pos >= wordCount)
return CString();

const size_t len = pWords[pos];
++pos; // skip length word

if (len > wordCount - pos)
return CString();

pos += len; // skip string data
}

if (pos >= wordCount)
return CString();

const size_t finalLen = pWords[pos];
++pos; // move to first character

if (finalLen == 0)
return CString();

if (finalLen > wordCount - pos)
return CString();

if (finalLen > static_cast<size_t>(INT_MAX))
return CString();

return CString(reinterpret_cast<const WCHAR*>(pWords + pos),
static_cast<int>(finalLen));
}

// Check: does this language exist in the resources (protection against outdated registry entries)
bool CcppcryptfsApp::IsLanguageAvailable(WORD wLangID) {
for (const auto& opt : m_vAvailableLangs) {
if (opt.langID == wLangID) return true;
}
return false;
}

// Saving user selection to the registry
void CcppcryptfsApp::SaveLanguageToRegistry(WORD wLangID) {
WriteProfileInt(_T("Settings"), _T("LanguageID"), (int)wLangID);
}

// Reading the selection from the registry (0 - if the entry does not exist)
WORD CcppcryptfsApp::LoadLanguageFromRegistry() {
return (WORD)GetProfileInt(_T("Settings"), _T("LanguageID"), 0);
}


// The one and only CcppcryptfsApp object

Expand Down Expand Up @@ -119,7 +228,7 @@ static bool StartNamedPipeServer()


BOOL CcppcryptfsApp::InitInstance()
{
{

const WCHAR *szUniqueNamedMutex = L"cppcryptfs-A7DDB0CF-A856-4E8A-A4E9-722473FB5E49";

Expand Down Expand Up @@ -186,15 +295,15 @@ BOOL CcppcryptfsApp::InitInstance()
ShowWindow(hWnd, SW_SHOWNORMAL);
}
} else {
::MessageBox(NULL, L"cppcryptfs is already running, but window not found!", L"cppcryptfs", MB_OK | MB_ICONERROR);
::MessageBox(NULL, LocUtils::GetStringFromResources(IDS_RUN_WINDOW_NOT_FOUND).c_str(), L"cppcryptfs", MB_OK | MB_ICONERROR);
}

return FALSE;
} else {
wstring mes;
bool dokVerCheck = check_dokany_version(mes);
if (!dokVerCheck && mes.length() < 1) {
mes = L"problem with Dokany version";
mes = LocUtils::GetStringFromResources(IDS_PROBLEM_DOKANY_VERSION);
}
if (mes.length()) {
::MessageBox(NULL, mes.c_str(), L"cppcryptfs", MB_OK | (dokVerCheck ? MB_ICONEXCLAMATION : MB_ICONERROR));
Expand Down Expand Up @@ -236,6 +345,17 @@ BOOL CcppcryptfsApp::InitInstance()
// such as the name of your company or organization
SetRegistryKey(_T("cppcryptfs"));

ScanResourcesForLanguages();
WORD wSavedID = LoadLanguageFromRegistry();

// Apply the language only if it is found in the EXE (protection against "junk" in the registry)
if (wSavedID != 0 && IsLanguageAvailable(wSavedID)) {
SetThreadUILanguage(wSavedID);
SetThreadLocale(MAKELCID(wSavedID, SORT_DEFAULT));
}
// for FindResource to work correctly in MFC
AfxSetResourceHandle(GetModuleHandle(NULL));

CCryptPropertySheet dlg(L"cppcryptfs");

CMountPropertyPage mount;
Expand Down
22 changes: 21 additions & 1 deletion cppcryptfs/cppcryptfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ THE SOFTWARE.
#include <string>
#include <memory>
#include "crypt/cryptdefs.h"
#include <vector>

using namespace std;

Expand All @@ -68,8 +69,27 @@ typedef struct struct_CopyDataCmdLine {

class CMenuTrayIcon;

// Structure for linking the system language ID and its text name
struct LanguageOption {
WORD langID;
CString name;
};

class CcppcryptfsApp : public CWinApp
{
public:
// List of all languages found in EXE resources
std::vector<LanguageOption> m_vAvailableLangs;

// Localization management methods
void ScanResourcesForLanguages();
bool IsLanguageAvailable(WORD wLangID);
CString GetStringForLang(HMODULE hInst, UINT nID, WORD wLang);

// Working with the registry
void SaveLanguageToRegistry(WORD wLangID);
WORD LoadLanguageFromRegistry();

private:
bool m_bIsRunningAsAdministrator = false;
bool m_bIsReallyAdministrator = false;
Expand Down Expand Up @@ -97,4 +117,4 @@ class CcppcryptfsApp : public CWinApp
DECLARE_MESSAGE_MAP()
};

extern CcppcryptfsApp theApp;
extern CcppcryptfsApp theApp;
Binary file modified cppcryptfs/cppcryptfs.rc
Binary file not shown.
37 changes: 32 additions & 5 deletions cppcryptfs/cppcryptfs.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(IntDir);$(ProjectDir);$(ProjectDir)res\en;$(ProjectDir)res\ru;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down Expand Up @@ -148,7 +148,7 @@
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(IntDir);$(ProjectDir);$(ProjectDir)res\en;$(ProjectDir)res\ru;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -181,7 +181,7 @@
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(IntDir);$(ProjectDir);$(ProjectDir)res\en;$(ProjectDir)res\ru;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PreBuildEvent>
<Command>for /f %%i in ('git rev-parse --short HEAD') do (echo VALUE "FileDescription", "cppcryptfs build %%i" &gt; "$(ProjectDir)gitversion.rc2")</Command>
Expand Down Expand Up @@ -218,7 +218,7 @@
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(IntDir);$(ProjectDir);$(ProjectDir)res\en;$(ProjectDir)res\ru;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PreBuildEvent>
<Command>for /f %%i in ('git rev-parse --short HEAD') do (echo VALUE "FileDescription", "cppcryptfs build %%i" &gt; "$(ProjectDir)gitversion.rc2")</Command>
Expand All @@ -227,6 +227,7 @@
<ItemGroup>
<ClInclude Include="ui\CryptSetting.h" />
<ClInclude Include="ui\CryptSettings.h" />
<ClInclude Include="ui\locutils.h" />
<ClInclude Include="ui\MoreSettingsPropertyPage.h" />
<ClInclude Include="config\cryptconfig.h" />
<ClInclude Include="context\cryptcontext.h" />
Expand Down Expand Up @@ -260,6 +261,10 @@
<ItemGroup>
<ClCompile Include="ui\CryptSetting.cpp" />
<ClCompile Include="ui\CryptSettings.cpp" />
<ClCompile Include="ui\locutils.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ui\MoreSettingsPropertyPage.cpp" />
<ClCompile Include="cppcryptfs.cpp" />
<ClCompile Include="dokan\cryptdokan.cpp">
Expand Down Expand Up @@ -308,6 +313,18 @@
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="cppcryptfs.rc" />
<ResourceCompile Include="res\en\Resources_EN.rc">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ResourceCompile>
<ResourceCompile Include="res\ru\Resources_RU.rc">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\cppcryptfs.rc2" />
Expand All @@ -316,6 +333,16 @@
<Image Include="res\cppcryptfs.ico" />
<Image Include="res\drive.ico" />
</ItemGroup>
<ItemGroup>
<Text Include="res\lic\aessiv_en.txt" />
<Text Include="res\lic\cppcryptfs_en.txt" />
<Text Include="res\lic\dokany_lib_en.txt" />
<Text Include="res\lic\dokany_mir_en.txt" />
<Text Include="res\lic\getopt_en.txt" />
<Text Include="res\lic\openssl_en.txt" />
<Text Include="res\lic\rapidjson_en.txt" />
<Text Include="res\lic\secure_edit_en.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand All @@ -324,4 +351,4 @@
<UserProperties RESOURCE_FILE="cppcryptfs.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>
Loading