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)
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)

View file

@ -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);

View file

@ -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,7 +917,13 @@ HWND TegraRcm::find_main_window(unsigned long process_id)
TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
{
//
//
BOOL PORTABLE = FALSE;
//
//
if (PORTABLE) {
// Get current directory
CString csPath;
TCHAR szPath[_MAX_PATH];
@ -908,12 +937,11 @@ TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
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"));
@ -921,7 +949,7 @@ TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
return _tcsdup(szPath);
}
return _T("");
*/
}
}

View file

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

View file

@ -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;
}

View file

@ -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();