/** * @param eNumFormat - numeric format. */ void CNumEdit::SetNumFormat(NUM_FORMAT eNumFormat) { if (m_eNumFormat == eNumFormat) return; if (m_hWnd == NULL) { m_eNumFormat = eNumFormat; return; } TCHAR szValue[64]; GetWindowText(szValue, countof(szValue)); if (*szValue) { switch (m_eNumFormat) { case NF_HEX: { UINT64 uValue = _tcstoui64(szValue, NULL, 16); _ui64tot_s(uValue, szValue, countof(szValue), 10); } break; case NF_DEC: { bool bNegative = false; for (int i = 0; ; ++i) { if (szValue[i] != _T(' ')) { if (szValue[i] == _T('-')) bNegative = true; break; } } if (bNegative) { INT64 iValue = _tcstoi64(szValue, NULL, 10); _i64tot_s(iValue, szValue, countof(szValue), 16); } else { UINT64 uValue = _tcstoui64(szValue, NULL, 10); _ui64tot_s(uValue, szValue, countof(szValue), 16); } } break; default: *szValue = _T('\0'); } SetValue(szValue, countof(szValue)); } m_eNumFormat = eNumFormat; UpdateRadixTitle(); }
void CPlugin::IENewTab(ULONG_PTR ulId, const CString& strURL, bool bShift, bool bCtrl) { CString strEventType = _T("IENewTab"); CString strDetail; TCHAR szId[32] = { 0 }; _ui64tot_s(ulId, szId, 32, 10); CString strId = szId; // Retrieve additional info for cursor & keyboard state CString strShift = bShift ? _T("true") : _T("false"); CString strCtrl = bCtrl ? _T("true") : _T("false"); strDetail.Format(_T("{\"id\": \"%s\", \"url\": \"%s\", \"shift\": %s, \"ctrl\": %s}"), strId, strURL, strShift, strCtrl); FireEvent(strEventType, strDetail); }
/** * @param uValue - new field value. */ void CNumEdit::SetValue(UINT64 uValue) { TCHAR szValue[64]; _ui64tot_s(uValue, szValue, countof(szValue), m_eNumFormat); SetValue(szValue, countof(szValue)); }
bool UInt64ToString(ULONGLONG Value,LPTSTR pszString,int MaxLength,int Radix) { return _ui64tot_s(Value,pszString,MaxLength,Radix)==0; }
void CDialogProcSelect::ListRunningProcs( ) { if (m_bLoadingProcesses) return; m_ProcessIcons.DeleteImageList( ); m_ProcessIcons.Create( 15, 15, ILC_COLOR32, 1, 1 ); m_ProcessIcons.SetBkColor( RGB( 255, 255, 255 ) ); m_ProcessList.SetImageList( &m_ProcessIcons, LVSIL_SMALL ); m_ProcessList.DeleteAllItems( ); m_ProcessInfos.clear( ); PSYSTEM_PROCESS_INFORMATION ProcessInfo = NULL; std::unique_ptr<uint8_t[]> BufferArray; ULONG BufferSize = 0; NTSTATUS status; status = ntdll::NtQuerySystemInformation( SystemProcessInformation, NULL, NULL, &BufferSize ); if (status != STATUS_SUCCESS && status != STATUS_INFO_LENGTH_MISMATCH) { #ifdef _DEBUG PrintOut( _T( "[CDialogProcSelect::RefreshRunningProcesses] Failed to get size for system process list from ProcessBasicInformation" ) ); #endif return; } BufferArray = std::make_unique<uint8_t[]>( BufferSize + 1 ); if (NT_SUCCESS( ntdll::NtQuerySystemInformation( SystemProcessInformation, (PVOID)BufferArray.get( ), BufferSize, &BufferSize ) )) { int CurrentProcessIndex = 0; m_bLoadingProcesses = TRUE; ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)BufferArray.get( ); while (ProcessInfo) { if (ProcessInfo->ImageName.Buffer && ProcessInfo->ImageName.Length > 0) { if (m_FilterCheck.GetCheck( ) != BST_CHECKED || CommonProcesses.end( ) == std::find_if( CommonProcesses.begin( ), CommonProcesses.end( ), [ProcessInfo] ( const wchar_t* proc ) { return _wcsnicmp( proc, ProcessInfo->ImageName.Buffer, ProcessInfo->ImageName.MaximumLength / sizeof(wchar_t) ) == 0; } ) ) { HANDLE hProcess = ReClassOpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, (DWORD)ProcessInfo->UniqueProcessId ); #ifdef _WIN64 if (hProcess && Utils::GetProcessPlatform( hProcess ) == Utils::ProcessPlatformX64) #else if (hProcess && Utils::GetProcessPlatform( hProcess ) == Utils::ProcessPlatformX86) #endif { ProcessInfoStack Info = { 0 }; TCHAR tcsProcessId[16] = { 0 }; TCHAR tcsProcessPath[MAX_PATH] = { 0 }; SHFILEINFO FileInfo = { 0 }; LVITEM lvi = { 0 }; int pos; Info.dwProcessId = (DWORD)ProcessInfo->UniqueProcessId; #ifdef UNICODE Info.strProcessName = ProcessInfo->ImageName.Buffer; #else Info.strProcessName = CW2A( ProcessInfo->ImageName.Buffer ); #endif GetModuleFileNameEx( hProcess, NULL, tcsProcessPath, MAX_PATH ); SHGetFileInfo( tcsProcessPath, NULL, &FileInfo, sizeof( SHFILEINFO ), SHGFI_ICON ); m_ProcessIcons.Add( FileInfo.hIcon ); lvi.mask = LVIF_TEXT | LVIF_IMAGE; lvi.pszText = Info.strProcessName.GetBuffer( ); lvi.cchTextMax = Info.strProcessName.GetLength( ); lvi.iImage = CurrentProcessIndex++; lvi.iItem = m_ProcessList.GetItemCount( ); pos = m_ProcessList.InsertItem( &lvi ); _ui64tot_s( Info.dwProcessId, tcsProcessId, 16, 10 ); m_ProcessList.SetItemText( pos, COLUMN_PROCESSID, (LPTSTR)tcsProcessId ); m_ProcessInfos.push_back( Info ); } CloseHandle( hProcess ); } } // Make sure not to loop infinitely (Fix for issue where refresh wasnt updating closed applications) if (ProcessInfo->NextEntryOffset == 0) break; ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)((uint8_t*)ProcessInfo + ProcessInfo->NextEntryOffset); } } m_bLoadingProcesses = FALSE; }