diff --git a/TegraRcmGUI/DialogTab01.cpp b/TegraRcmGUI/DialogTab01.cpp
index 7b39265..f360e9c 100644
--- a/TegraRcmGUI/DialogTab01.cpp
+++ b/TegraRcmGUI/DialogTab01.cpp
@@ -142,7 +142,6 @@ BOOL DialogTab01::OnInitDialog()
BEGIN_MESSAGE_MAP(DialogTab01, CDialog)
ON_BN_CLICKED(IDC_BROWSE, &DialogTab01::OnBnClickedBrowse)
- ON_EN_CHANGE(PAYLOAD_PATH, &CTegraRcmGUIDlg::OnEnChangePath)
ON_BN_CLICKED(IDC_INJECT, &DialogTab01::InjectPayload)
ON_BN_CLICKED(ID_ADD_FAV, &DialogTab01::OnBnClickedAddFav)
ON_BN_CLICKED(ID_DEL_FAV, &DialogTab01::OnBnClickedDelFav)
diff --git a/TegraRcmGUI/DialogTab03.cpp b/TegraRcmGUI/DialogTab03.cpp
index f3b0296..de3adca 100644
--- a/TegraRcmGUI/DialogTab03.cpp
+++ b/TegraRcmGUI/DialogTab03.cpp
@@ -163,10 +163,19 @@ void DialogTab03::CreateLink()
IPersistFile* ppf;
// Set the path to the shortcut target and add the description.
+ //PathAppend(szPath, _T("\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\TegraRcmGUI.lnk"));
+
psl->SetPath(szAppPath);
+ psl->SetArguments(_T("/autostart"));
psl->SetDescription(L"TegraRcmGUI");
psl->SetIconLocation(szAppPath, 0);
+ CString csPath, csPathf(szAppPath);
+ int nIndex = csPathf.ReverseFind(_T('\\'));
+ if (nIndex > 0) csPath = csPathf.Left(nIndex);
+ else csPath.Empty();
+ psl->SetWorkingDirectory(csPath);
+
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres)) {
hres = ppf->Save(szPath, TRUE);
diff --git a/TegraRcmGUI/TegraRcm.cpp b/TegraRcmGUI/TegraRcm.cpp
index 2df416a..0b1765a 100644
--- a/TegraRcmGUI/TegraRcm.cpp
+++ b/TegraRcmGUI/TegraRcm.cpp
@@ -453,7 +453,7 @@ void TegraRcm::AppendLog(string message)
{
// DISABLED
- //return;
+ return;
// Get time
@@ -761,13 +761,23 @@ int TegraRcm::Smasher(TCHAR args[])
si.cb = sizeof(STARTUPINFO);
si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdInput = NULL;
- TCHAR cmd[MAX_PATH] = TEXT(".\\TegraRcmSmash.exe ");
+
+ // This should fix RC-50 issue, ! At last.
+ TCHAR szPath[_MAX_PATH];
+ VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
+ CString csPathf(szPath);
+ int nIndex = csPathf.ReverseFind(_T('\\'));
+ if (nIndex > 0) csPath = csPathf.Left(nIndex);
+ else csPath.Empty();
+ csPath.Append(TEXT(".\\TegraRcmSmash.exe "));
+ TCHAR cmd[MAX_PATH];
+ _tcscpy_s(cmd, csPath);
lstrcat(cmd, args);
- ret = CreateProcess(NULL, cmd, NULL, NULL, TRUE, flags, NULL, NULL, &si, &pi);
+
+ ret = CreateProcess(NULL, cmd, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi);
int rc = -50;
if (NULL != ret)
{
- AppendLog("Ret is not null");
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exit_code;
if (FALSE != GetExitCodeProcess(pi.hProcess, &exit_code))
@@ -776,7 +786,6 @@ int TegraRcm::Smasher(TCHAR args[])
if (STILL_ACTIVE != exit_code)
{
rc = exit_code;
- AppendLog("Real exit code");
}
else
{
@@ -793,7 +802,21 @@ int TegraRcm::Smasher(TCHAR args[])
CloseHandle(pi.hThread);
}
else {
- AppendLog("Ret is null");
+
+ int lastErrorCode = GetLastError();
+ LPWSTR lpMsgBuf = NULL;
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL,
+ lastErrorCode,
+ 0,
+ (LPWSTR)&lpMsgBuf,
+ 0,
+ NULL);
+ std::string MyString = CW2A(lpMsgBuf);
+ std::string intStr = std::to_string(lastErrorCode);
+ AppendLog(intStr);
+ AppendLog(MyString);
+
}
return rc;
}
@@ -894,34 +917,39 @@ HWND TegraRcm::find_main_window(unsigned long process_id)
TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
{
-
- // Get current directory
- CString csPath;
- TCHAR szPath[_MAX_PATH];
- VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
- CString csPathf(szPath);
- int nIndex = csPathf.ReverseFind(_T('\\'));
- if (nIndex > 0) csPath = csPathf.Left(nIndex);
- else csPath.Empty();
- CString csPath2;
- csPath2 = csPath;
- csPath2 += TEXT("\\");
- csPath2 += relative_path;
- return _tcsdup(csPath2);
-
- /*
- // USE THIS INSTEAD TO BUILD FOR MSI PACKAGER
+ //
+ //
+ BOOL PORTABLE = FALSE;
+ //
+ //
- TCHAR szPath[MAX_PATH];
-
- if (SUCCEEDED(SHGetFolderPath(NULL, dwFlags, NULL, SHGFP_TYPE_CURRENT, szPath)))
- {
- if (dwFlags == CSIDL_APPDATA) PathAppend(szPath, _T("\\TegraRcmGUI"));
- PathAppend(szPath, relative_path);
- return _tcsdup(szPath);
+ if (PORTABLE) {
+ // Get current directory
+ CString csPath;
+ TCHAR szPath[_MAX_PATH];
+ VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
+ CString csPathf(szPath);
+ int nIndex = csPathf.ReverseFind(_T('\\'));
+ if (nIndex > 0) csPath = csPathf.Left(nIndex);
+ else csPath.Empty();
+ CString csPath2;
+ csPath2 = csPath;
+ csPath2 += TEXT("\\");
+ csPath2 += relative_path;
+ return _tcsdup(csPath2);
+ }
+ else
+ {
+ // USE THIS INSTEAD TO BUILD FOR MSI PACKAGER
+ TCHAR szPath[MAX_PATH];
+ if (SUCCEEDED(SHGetFolderPath(NULL, dwFlags, NULL, SHGFP_TYPE_CURRENT, szPath)))
+ {
+ if (dwFlags == CSIDL_APPDATA) PathAppend(szPath, _T("\\TegraRcmGUI"));
+ PathAppend(szPath, relative_path);
+ return _tcsdup(szPath);
+ }
+ return _T("");
}
- return _T("");
- */
}
diff --git a/TegraRcmGUI/TegraRcmGUI.vcxproj b/TegraRcmGUI/TegraRcmGUI.vcxproj
index 28ca1d5..7b6a52d 100644
--- a/TegraRcmGUI/TegraRcmGUI.vcxproj
+++ b/TegraRcmGUI/TegraRcmGUI.vcxproj
@@ -156,6 +156,9 @@
true
$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)
Version.lib;libusbK.lib;%(AdditionalDependencies)
+ AsInvoker
+ true
+ false
false
diff --git a/TegraRcmGUI/TegraRcmGUIDlg.cpp b/TegraRcmGUI/TegraRcmGUIDlg.cpp
index caa5438..24bf8bf 100644
--- a/TegraRcmGUI/TegraRcmGUIDlg.cpp
+++ b/TegraRcmGUI/TegraRcmGUIDlg.cpp
@@ -93,6 +93,7 @@ BEGIN_MESSAGE_MAP(CTegraRcmGUIDlg, CDialog)
ON_COMMAND(SWM_FAV09, InjectFav09Command)
ON_COMMAND(SWM_FAV10, InjectFav10Command)
ON_COMMAND(SWM_AUTOINJECT, AutoInjectCommand)
+ ON_MESSAGE(WM_QUERYENDSESSION, OnQueryEndSession)
END_MESSAGE_MAP()
//
@@ -109,14 +110,16 @@ BOOL CTegraRcmGUIDlg::OnInitDialog()
TCHAR szPath[_MAX_PATH];
VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
CString csPathf(szPath);
+ CT2CA pszConvertedAnsiString(csPathf);
+ std::string strStd(pszConvertedAnsiString);
+ m_TegraRcm->AppendLog("Module filename is : ");
+ m_TegraRcm->AppendLog(strStd);
+
int nIndex = csPathf.ReverseFind(_T('\\'));
if (nIndex > 0) csPath = csPathf.Left(nIndex);
else csPath.Empty();
// Initialize bitmap
-
-
-
CRect rc;
AfxGetMainWnd()->GetWindowRect(rc);
int width = rc.Width();
@@ -165,6 +168,12 @@ BOOL CTegraRcmGUIDlg::OnInitDialog()
SetIcon(m_hIcon, FALSE); // Set small icon
m_TegraRcm = new TegraRcm(this);
+
+ m_TegraRcm->AppendLog("new TegraRcm()");
+
+ // Kill other running process of app
+ m_TegraRcm->KillRunningProcess(TEXT("TegraRcmGUI.exe"));
+
m_tbCtrl.InitDialogs(m_TegraRcm);
TCITEM tcItem1;
@@ -422,7 +431,10 @@ void CTegraRcmGUIDlg::OnTimer(UINT nIDEvent)
}
}
-void CTegraRcmGUIDlg::OnEnChangePath()
+LRESULT CTegraRcmGUIDlg::OnQueryEndSession(WPARAM wParm, LPARAM lParm)
{
- int test = 1;
+ // This is not useful, exit is not needed in that case
+ m_TegraRcm->AppendLog("OnEndSession");
+ PostMessage(WM_QUIT);
+ return TRUE;
}
diff --git a/TegraRcmGUI/TegraRcmGUIDlg.h b/TegraRcmGUI/TegraRcmGUIDlg.h
index 8733ddf..00108e9 100644
--- a/TegraRcmGUI/TegraRcmGUIDlg.h
+++ b/TegraRcmGUI/TegraRcmGUIDlg.h
@@ -92,6 +92,7 @@ protected:
afx_msg void OnDestroy();
afx_msg LRESULT OnTrayIconEvent(UINT wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
+ afx_msg LRESULT OnQueryEndSession(WPARAM wParm, LPARAM lParm);
public:
void StartTimer();
@@ -99,7 +100,7 @@ public:
void OnTimer(UINT nIDEvent);
int STATUS;
afx_msg void BitmapDisplay(int IMG);
- afx_msg void OnEnChangePath();
+
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor);
void ShowWindowCommand();
void HideWindowCommand();