Skip to content

Commit

Permalink
fix win7 start gui application error after installation
Browse files Browse the repository at this point in the history
  • Loading branch information
IluhaPuts committed Nov 15, 2018
1 parent 1c865b3 commit f99edfd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions keychain_service_win/src/SecurityManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "SecurityManager.h"
#include <ServiceLogger.h>

Expand All @@ -19,10 +18,16 @@ void SecurityManager::CreateSecureDesktop(const std::string& transId) {
TCHAR curDirectory[500];
GetCurrentDirectory(500, curDirectory);
LPCWSTR commandLine = GetCommandLine();
wchar_t* found = wcsstr((wchar_t*)commandLine, L"keychain_service_win.exe");
std::wstring rem(commandLine);
std::string::size_type fSymb = rem.find('\"');
while (fSymb != std::string::npos) {
rem.erase(fSymb, 1);
fSymb = rem.find('\"');
}
wchar_t* found = wcsstr((wchar_t*)rem.c_str(), L"keychain_service_win.exe");
wchar_t dst[400] = { 0 };
wchar_t args[400] = { 0 };
wcsncpy_s(dst, 400, commandLine, (found - (wchar_t*)commandLine));
wcsncpy_s(dst, 400, rem.c_str(), (found - (wchar_t*)rem.c_str()));
wcscat_s(dst, 400, L"keychain_pass_entry_app.exe");
wcscat_s(args, 400, L"-transId ");
std::wstring _tId(400, L'#');
Expand All @@ -32,10 +37,9 @@ void SecurityManager::CreateSecureDesktop(const std::string& transId) {
LPCWSTR appToStart = dst;
LPTSTR app_args = args;
ServiceLogger::getLogger().Log("CreateSecureDescktop function StartInteractiveClientProcess to enter credentials");

if (!StartInteractiveClientProcess(appToStart, (LPTSTR)app_args))
{
throw std::runtime_error("Could not create child client process");
}
if (!StartInteractiveClientProcess(appToStart, (LPTSTR)app_args))
{
throw std::runtime_error("Could not create child client process");
}
}

0 comments on commit f99edfd

Please sign in to comment.