1
0
Fork 0
mirror of https://github.com/eliboa/TegraRcmGUI.git synced 2024-12-28 02:56:02 +00:00

Fixed : RC=-50 bug (at last, hope so :\)

This commit is contained in:
eliboa 2018-09-11 21:31:12 +02:00
parent 74fa514608
commit 65f1d80cda
6 changed files with 91 additions and 39 deletions

View file

@ -142,7 +142,6 @@ BOOL DialogTab01::OnInitDialog()
BEGIN_MESSAGE_MAP(DialogTab01, CDialog) BEGIN_MESSAGE_MAP(DialogTab01, CDialog)
ON_BN_CLICKED(IDC_BROWSE, &DialogTab01::OnBnClickedBrowse) ON_BN_CLICKED(IDC_BROWSE, &DialogTab01::OnBnClickedBrowse)
ON_EN_CHANGE(PAYLOAD_PATH, &CTegraRcmGUIDlg::OnEnChangePath)
ON_BN_CLICKED(IDC_INJECT, &DialogTab01::InjectPayload) ON_BN_CLICKED(IDC_INJECT, &DialogTab01::InjectPayload)
ON_BN_CLICKED(ID_ADD_FAV, &DialogTab01::OnBnClickedAddFav) ON_BN_CLICKED(ID_ADD_FAV, &DialogTab01::OnBnClickedAddFav)
ON_BN_CLICKED(ID_DEL_FAV, &DialogTab01::OnBnClickedDelFav) ON_BN_CLICKED(ID_DEL_FAV, &DialogTab01::OnBnClickedDelFav)

View file

@ -163,10 +163,19 @@ void DialogTab03::CreateLink()
IPersistFile* ppf; IPersistFile* ppf;
// Set the path to the shortcut target and add the description. // 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->SetPath(szAppPath);
psl->SetArguments(_T("/autostart"));
psl->SetDescription(L"TegraRcmGUI"); psl->SetDescription(L"TegraRcmGUI");
psl->SetIconLocation(szAppPath, 0); 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); hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres)) { if (SUCCEEDED(hres)) {
hres = ppf->Save(szPath, TRUE); hres = ppf->Save(szPath, TRUE);

View file

@ -453,7 +453,7 @@ void TegraRcm::AppendLog(string message)
{ {
// DISABLED // DISABLED
//return; return;
// Get time // Get time
@ -761,13 +761,23 @@ int TegraRcm::Smasher(TCHAR args[])
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
si.dwFlags |= STARTF_USESTDHANDLES; si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdInput = NULL; 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); 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; int rc = -50;
if (NULL != ret) if (NULL != ret)
{ {
AppendLog("Ret is not null");
WaitForSingleObject(pi.hProcess, INFINITE); WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exit_code; DWORD exit_code;
if (FALSE != GetExitCodeProcess(pi.hProcess, &exit_code)) if (FALSE != GetExitCodeProcess(pi.hProcess, &exit_code))
@ -776,7 +786,6 @@ int TegraRcm::Smasher(TCHAR args[])
if (STILL_ACTIVE != exit_code) if (STILL_ACTIVE != exit_code)
{ {
rc = exit_code; rc = exit_code;
AppendLog("Real exit code");
} }
else else
{ {
@ -793,7 +802,21 @@ int TegraRcm::Smasher(TCHAR args[])
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
} }
else { 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; return rc;
} }
@ -894,34 +917,39 @@ HWND TegraRcm::find_main_window(unsigned long process_id)
TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags) TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
{ {
//
// Get current directory //
CString csPath; BOOL PORTABLE = FALSE;
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
TCHAR szPath[MAX_PATH]; if (PORTABLE) {
// Get current directory
if (SUCCEEDED(SHGetFolderPath(NULL, dwFlags, NULL, SHGFP_TYPE_CURRENT, szPath))) CString csPath;
{ TCHAR szPath[_MAX_PATH];
if (dwFlags == CSIDL_APPDATA) PathAppend(szPath, _T("\\TegraRcmGUI")); VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
PathAppend(szPath, relative_path); CString csPathf(szPath);
return _tcsdup(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("");
*/
} }

View file

@ -156,6 +156,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(LIBUSBK_DIR)\bin\lib\$(PlatformShortName.Replace('x64','amd64'))\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Version.lib;libusbK.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>Version.lib;libusbK.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>AsInvoker</UACExecutionLevel>
<EnableUAC>true</EnableUAC>
<UACUIAccess>false</UACUIAccess>
</Link> </Link>
<Midl> <Midl>
<MkTypLibCompatible>false</MkTypLibCompatible> <MkTypLibCompatible>false</MkTypLibCompatible>

View file

@ -93,6 +93,7 @@ BEGIN_MESSAGE_MAP(CTegraRcmGUIDlg, CDialog)
ON_COMMAND(SWM_FAV09, InjectFav09Command) ON_COMMAND(SWM_FAV09, InjectFav09Command)
ON_COMMAND(SWM_FAV10, InjectFav10Command) ON_COMMAND(SWM_FAV10, InjectFav10Command)
ON_COMMAND(SWM_AUTOINJECT, AutoInjectCommand) ON_COMMAND(SWM_AUTOINJECT, AutoInjectCommand)
ON_MESSAGE(WM_QUERYENDSESSION, OnQueryEndSession)
END_MESSAGE_MAP() END_MESSAGE_MAP()
// //
@ -109,14 +110,16 @@ BOOL CTegraRcmGUIDlg::OnInitDialog()
TCHAR szPath[_MAX_PATH]; TCHAR szPath[_MAX_PATH];
VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH)); VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szPath, _MAX_PATH));
CString csPathf(szPath); 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('\\')); int nIndex = csPathf.ReverseFind(_T('\\'));
if (nIndex > 0) csPath = csPathf.Left(nIndex); if (nIndex > 0) csPath = csPathf.Left(nIndex);
else csPath.Empty(); else csPath.Empty();
// Initialize bitmap // Initialize bitmap
CRect rc; CRect rc;
AfxGetMainWnd()->GetWindowRect(rc); AfxGetMainWnd()->GetWindowRect(rc);
int width = rc.Width(); int width = rc.Width();
@ -165,6 +168,12 @@ BOOL CTegraRcmGUIDlg::OnInitDialog()
SetIcon(m_hIcon, FALSE); // Set small icon SetIcon(m_hIcon, FALSE); // Set small icon
m_TegraRcm = new TegraRcm(this); 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); m_tbCtrl.InitDialogs(m_TegraRcm);
TCITEM tcItem1; 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;
} }

View file

@ -92,6 +92,7 @@ protected:
afx_msg void OnDestroy(); afx_msg void OnDestroy();
afx_msg LRESULT OnTrayIconEvent(UINT wParam, LPARAM lParam); afx_msg LRESULT OnTrayIconEvent(UINT wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
afx_msg LRESULT OnQueryEndSession(WPARAM wParm, LPARAM lParm);
public: public:
void StartTimer(); void StartTimer();
@ -99,7 +100,7 @@ public:
void OnTimer(UINT nIDEvent); void OnTimer(UINT nIDEvent);
int STATUS; int STATUS;
afx_msg void BitmapDisplay(int IMG); afx_msg void BitmapDisplay(int IMG);
afx_msg void OnEnChangePath();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor); afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd *pWnd, UINT nCtlColor);
void ShowWindowCommand(); void ShowWindowCommand();
void HideWindowCommand(); void HideWindowCommand();