void ScrolledListView::Draw(BRect updateRect) { // figure out which items we're drawing float itemHeight = ItemHeight(); int32 firstItem = (int) (updateRect.top / itemHeight); if (firstItem < 0) firstItem = 0; int32 lastItem = (int) ((updateRect.bottom + itemHeight - 1) / itemHeight); int32 numItems = NumItems(); if (lastItem >= numItems) lastItem = numItems - 1; // draw BRect itemRect = Bounds(); itemRect.top = firstItem * itemHeight; itemRect.bottom = itemRect.top + itemHeight - 1; for (int32 i=firstItem; i <= lastItem; i++) { // draw item DrawItem(i, itemRect, i == selection); // bump itemRect itemRect.top = itemRect.bottom + 1; itemRect.bottom = itemRect.top + itemHeight - 1; } // clear any left-over area if (itemRect.top < updateRect.bottom) { itemRect.bottom = updateRect.bottom; FillRect(itemRect, B_SOLID_LOW); } }
/*************************************************************************************** * Method: * * * Purpose: * * * Parameters: * * * Return value: * * * Notes: * ***************************************************************************************/ STDAPI DllRegisterServer() { HRESULT hr = S_OK; char rcModule[_MAX_PATH]; const COCLASS_REGISTER *pCoClass; DllUnregisterServer(); GetModuleFileNameA( GetModuleInst(), rcModule, NumItems( rcModule ) ); // for each item in the coclass list, register it for ( pCoClass = g_CoClasses; (SUCCEEDED( hr ) && (pCoClass->pClsid != NULL)); pCoClass++ ) { // register the class with default values hr = REGUTIL::RegisterCOMClass( *pCoClass->pClsid, g_szCoclassDesc, g_szProgIDPrefix, g_iVersion, pCoClass->szProgID, g_szThreadingModel, rcModule ); } // for if ( FAILED( hr ) ) DllUnregisterServer(); return hr; } // DllRegisterServer
void ScrolledListView::NumItemsChanged() { UpdateScrollBar(); if (selection >= NumItems()) selection = -1; Invalidate(); }
/* static public */ HRESULT REGUTIL::UnregisterCOMClass( REFCLSID rclsid, const char *szProgIDPrefix, int iVersion, const char *szClassProgID ) { char szID[64]; // the class ID to unregister. char rcCLSID[64]; // CLSID\\szID. OLECHAR szWID[64]; // helper for the class ID to unregister. char rcProgID[128]; // szProgIDPrefix.szClassProgID char rcIndProgID[128]; // rcProgID.iVersion // format the prog ID values. sprintf( rcProgID, "%s.%s", szProgIDPrefix, szClassProgID ); sprintf( rcIndProgID, "%s.%d", rcProgID, iVersion ); REGUTIL::_UnregisterClassBase( rclsid, rcProgID, rcIndProgID, rcCLSID ); DeleteKey( rcCLSID, "InprocServer32" ); StringFromGUID2(rclsid, szWID, NumItems( szWID ) ); WideCharToMultiByte( CP_ACP, 0, szWID, -1, szID, sizeof( szID ), NULL, NULL ); DeleteKey( "CLSID", rcCLSID ); return S_OK; } // REGUTIL::UnregisterCOMClass
/* PHName: parse hname and return list of matching models */ static void PHName(ILink *models,HMMSet *hset) { if (trace & T_ITM) printf(" Models \n "); SkipSpaces(); if (ch == '(') { ReadCh(); PHIdent(models,hset); SkipSpaces(); while(ch == ',') { ReadCh(); PHIdent(models,hset); SkipSpaces(); } if (ch != ')') EdError(") expected"); ReadCh(); } else PHIdent(models,hset); if (trace & T_ITM) { printf("\n %d models in itemlist\n",NumItems(*models)); fflush(stdout); } }
void scTypeSpecList::Insert( TypeSpec& ts ) { for ( int i = 0; i < NumItems(); i++ ) { if ( ts.ptr() == (*this)[i].ptr() ) return; } Append( ts ); }
TypeSpec scSpecLocList::GetNthValidSpec( int nth ) const { for ( int i = 0; i < NumItems(); i++ ) { if ( (*this)[i].spec().ptr() && --nth == 0 ) return (*this)[i].spec(); } return 0; }
TypeSpec scSpecLocList::GetLastValidSpec( void ) const { for ( int i = NumItems() - 1; i >= 0; i-- ) { if ( (*this)[i].spec().ptr() ) return (*this)[i].spec(); } return 0; }
TypeSpec scSpecLocList::GetFirstValidSpec( void ) const { for ( int i = 0; i < NumItems(); i++ ) { if ( (*this)[i].spec().ptr() ) return (*this)[i].spec(); } return 0; }
int ScrolledListView::TrackInsertionStep(BPoint point, int prevInsertionIndex) { BRect bounds = Bounds(); float itemHeight = ItemHeight(); int32 numItems = NumItems(); // autoscroll if (point.y < bounds.top) { if (bounds.top > 0) { ScrollBy(0, -itemHeight); bounds.OffsetBy(0, -itemHeight); } point.y = bounds.top; } else if (point.y > bounds.bottom) { if (bounds.bottom < numItems * itemHeight - 1) { ScrollBy(0, itemHeight); bounds.OffsetBy(0, itemHeight); } point.y = bounds.bottom + 1; // need the +1 to let it get beyond the last item } // figure out where it is now int32 curInsertionIndex = (int) (point.y / itemHeight); if (curInsertionIndex < 0) curInsertionIndex = 0; else if (curInsertionIndex > numItems) // can move beyond the last item curInsertionIndex = numItems; // draw if (curInsertionIndex != prevInsertionIndex) { // redraw items bordering old indicator, to clear it if (prevInsertionIndex >= 0) { if (prevInsertionIndex > 0) DrawItemAt(prevInsertionIndex - 1); if (prevInsertionIndex < numItems) DrawItemAt(prevInsertionIndex); else { // need to clean up bottom BRect bottomRect = bounds; bottomRect.top = prevInsertionIndex * itemHeight; FillRect(bottomRect, B_SOLID_LOW); } } // draw new indicator SetHighColor(insertionIndicatorColor); SetPenSize(2.0); float indicatorY = curInsertionIndex * itemHeight; StrokeLine(BPoint(bounds.left, indicatorY), BPoint(bounds.right, indicatorY)); SetPenSize(1.0); } Flush(); return curInsertionIndex; }
void DumpMD_DumpRawHeaps( RegMeta *pMD) // The scope to dump. { HRESULT hr; // A result. ULONG ulSize; // Bytes in a heap. const BYTE *pData; // Pointer to a blob. ULONG cbData; // Size of a blob. ULONG oData; // Offset of current blob. char rcPrefix[30]; // To format line prefix. pMD->GetBlobHeapSize(&ulSize); DumpMD_VWriteLine(""); DumpMD_VWriteLine("Blob Heap: %d(%#x) bytes", ulSize,ulSize); oData = 0; do { pMD->GetBlob(oData, &cbData, (const void**)&pData); sprintf_s(rcPrefix, NumItems(rcPrefix), "%5x,%-2x", oData, cbData); DumpMD_DumpHex(rcPrefix, pData, cbData); hr = pMD->GetNextBlob(oData, &oData); } while (hr == S_OK); pMD->GetStringHeapSize(&ulSize); DumpMD_VWriteLine(""); DumpMD_VWriteLine("String Heap: %d(%#x) bytes", ulSize,ulSize); oData = 0; const char *pString; do { pMD->GetString(oData, &pString); sprintf_s(rcPrefix, NumItems(rcPrefix), "%08x", oData); DumpMD_DumpHex(rcPrefix, pString, (ULONG)strlen(pString)+1); if (*pString != 0) DumpMD_VWrite("%08x: %s\n", oData, pString); hr = pMD->GetNextString(oData, &oData); } while (hr == S_OK); DumpMD_VWriteLine(""); DumpMD_DisplayUserStrings(pMD); } // void DumpMD_DumpRawHeaps()
void ScrolledListView::Select(int32 index) { int32 newSelection = index; if (newSelection < 0 || newSelection >= NumItems()) newSelection = -1; if (selection != newSelection) { SelectionChanging(newSelection, selection); selection = newSelection; Invalidate(); } }
std::vector< T > PopNOrLess( const unsigned N ) { std::vector< T > items; unsigned itemsAvailable = std::min( N, NumItems() ); unsigned i = 0; while( i++ < itemsAvailable ) { items.push_back( queue[ frontOfQueue ] ); frontOfQueue = ( frontOfQueue + 1 ) % capacity; numItems = std::max( numItems - 1, static_cast< unsigned >( 0 ) ); } return items; }
void scSpecLocList::DbgPrint( void ) const { SCDebugTrace( 0, scString( "\nSCSPECLOCLIST\n" ) ); for ( int i = 0; i < NumItems(); i++ ) { SCDebugTrace( 0, scString( "\tscCharSpecLoc ( %d %d ) 0x%08x\n" ), (*this)[i].offset().fParaOffset, (*this)[i].offset().fCharOffset, (*this)[i].spec() ); } SCDebugTrace( 0, scString( "SCSPECLOCLIST\n" ) ); }
HRESULT CLRTestHookManager::AddTestHook(ICLRTestHook* hook) { WRAPPER_NO_CONTRACT; DWORD newidx=FastInterlockIncrement(&m_nHooks); if (newidx>=NumItems(m_pHooks)) { FastInterlockDecrement(&m_nHooks); return DISP_E_OVERFLOW; } m_pHooks[newidx-1].Set(hook); return S_OK; }
void ScrolledListView::UpdateScrollBar() { // sanity clause if (scroller == NULL) return; BScrollBar* scrollBar = scroller->ScrollBar(B_VERTICAL); float itemHeight = ItemHeight(); float visibleHeight = Bounds().Height() + 1; float dataHeight = NumItems() * itemHeight; float scrollMax = dataHeight - visibleHeight; if (scrollMax < 0) scrollMax = 0; scrollBar->SetRange(0, scrollMax); scrollBar->SetSteps(itemHeight, visibleHeight - itemHeight); }
const char *DumpMD_DumpRawNameOfType(RegMeta *pMD, ULONG iType) { if (iType <= iRidMax) { const char *pNameTable; pMD->GetTableInfo(iType, 0,0,0,0, &pNameTable); return pNameTable; } else // Is the field a coded token? if (iType <= iCodedTokenMax) { int iCdTkn = iType - iCodedToken; const char *pNameCdTkn; pMD->GetCodedTokenInfo(iCdTkn, 0,0, &pNameCdTkn); return pNameCdTkn; } // Fixed type. switch (iType) { case iBYTE: return "BYTE"; case iSHORT: return "short"; case iUSHORT: return "USHORT"; case iLONG: return "long"; case iULONG: return "ULONG"; case iSTRING: return "string"; case iGUID: return "GUID"; case iBLOB: return "blob"; } // default: static char buf[30]; sprintf_s(buf, NumItems(buf), "unknown type 0x%02x", iType); return buf; } // const char *DumpMD_DumpRawNameOfType()
/* static private */ HRESULT REGUTIL::_RegisterClassBase( REFCLSID rclsid, const char *szDesc, const char *szProgID, const char *szIndepProgID, char *szOutCLSID ) { char szID[64]; // the class ID to register. OLECHAR szWID[64]; // helper for the class ID to register. StringFromGUID2( rclsid, szWID, NumItems( szWID ) ); WideCharToMultiByte( CP_ACP, 0, szWID, -1, szID, sizeof( szID ), NULL, NULL ); strcpy( szOutCLSID, "CLSID\\" ); strcat( szOutCLSID, szID ); // create ProgID keys. SetKeyAndValue( szProgID, NULL, szDesc ); SetKeyAndValue( szProgID, "CLSID", szID ); // create VersionIndependentProgID keys. SetKeyAndValue( szIndepProgID, NULL, szDesc ); SetKeyAndValue( szIndepProgID, "CurVer", szProgID ); SetKeyAndValue( szIndepProgID, "CLSID", szID ); // create entries under CLSID. SetKeyAndValue( szOutCLSID, NULL, szDesc ); SetKeyAndValue( szOutCLSID, "ProgID", szProgID ); SetKeyAndValue( szOutCLSID, "VersionIndependentProgID", szIndepProgID ); SetKeyAndValue( szOutCLSID, "NotInsertable", NULL ); return S_OK; } // REGUTIL::_RegisterClassBase
/* static private */ HRESULT REGUTIL::_UnregisterClassBase( REFCLSID rclsid, const char *szProgID, const char *szIndepProgID, char *szOutCLSID ) { char szID[64]; // the class ID to register. OLECHAR szWID[64]; // helper for the class ID to register. StringFromGUID2( rclsid, szWID, NumItems( szWID ) ); WideCharToMultiByte( CP_ACP, 0, szWID, -1, szID, sizeof( szID ), NULL, NULL ); strcpy( szOutCLSID, "CLSID\\" ); strcat( szOutCLSID, szID ); // delete the version independant prog ID settings. DeleteKey( szIndepProgID, "CurVer" ); DeleteKey( szIndepProgID, "CLSID" ); RegDeleteKeyA( HKEY_CLASSES_ROOT, szIndepProgID ); // delete the prog ID settings. DeleteKey( szProgID, "CLSID" ); RegDeleteKeyA( HKEY_CLASSES_ROOT, szProgID ); // delete the class ID settings. DeleteKey( szOutCLSID, "ProgID" ); DeleteKey( szOutCLSID, "VersionIndependentProgID" ); DeleteKey( szOutCLSID, "NotInsertable" ); RegDeleteKeyA( HKEY_CLASSES_ROOT, szOutCLSID ); return S_OK; } // REGUTIL::_UnregisterClassBase
void ScrolledListView::MouseDown(BPoint point) { int32 clicks; Window()->CurrentMessage()->FindInt32("clicks", &clicks); Activate(); if (!IsFocus()) MakeFocus(); int32 newSelection = (int) (point.y / ItemHeight()); if (newSelection < 0 || newSelection >= NumItems()) newSelection = -1; // double-click opens if (selection == newSelection && selection >= 0 && clicks > 1) OpenSelectedItem(selection); // first click selects, maybe moves else { Select(newSelection); if (CanRearrange()) TrackRearrangement(point); } }
//***************************************************************************** // This function will handle ignore codes and tell the user what is happening. //***************************************************************************** int _DbgBreakCheck( LPCSTR szFile, int iLine, LPCSTR szExpr) { TCHAR rcBuff[1024+_MAX_PATH]; TCHAR rcPath[_MAX_PATH]; TCHAR rcTitle[64]; _DBGIGNOREDATA *psData; long i; if (DebugBreakOnAssert()) { DebugBreak(); } DBGIGNORE* pDBGIFNORE = GetDBGIGNORE(); // Check for ignore all. for (i=0, psData = pDBGIFNORE->Ptr(); i<pDBGIFNORE->Count(); i++, psData++) { if (psData->iLine == iLine && _stricmp(psData->rcFile, szFile) == 0 && psData->bIgnore == true) return (false); } // Give assert in output for easy access. WszGetModuleFileName(0, rcPath, NumItems(rcPath)); swprintf(rcBuff, L"Assert failure(PID %d [0x%08x], Thread: %d [0x%x]): %hs\n" L" File: %hs, Line: %d Image:\n%s\n", GetCurrentProcessId(), GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId(), szExpr, szFile, iLine, rcPath); WszOutputDebugString(rcBuff); // Write out the error to the console printf("%S\n", rcBuff); LogAssert(szFile, iLine, szExpr); FlushLogging(); // make certain we get the last part of the log fflush(stdout); if (NoGuiOnAssert()) { TerminateOnAssert(); } if (DebugBreakOnAssert()) { return(true); // like a retry } // Change format for message box. The extra spaces in the title // are there to get around format truncation. swprintf(rcBuff, L"%hs\n\n%hs, Line: %d\n\nAbort - Kill program\nRetry - Debug\nIgnore - Keep running\n" L"\n\nImage:\n%s\n", szExpr, szFile, iLine, rcPath); swprintf(rcTitle, L"Assert Failure (PID %d, Thread %d/%x) ", GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId()); // Tell user there was an error. _DbgBreakCount++; int ret = WszMessageBoxInternal(NULL, rcBuff, rcTitle, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION | COMPLUS_MB_SERVICE_NOTIFICATION); --_DbgBreakCount; HMODULE hKrnl32; switch(ret) { // For abort, just quit the app. case IDABORT: TerminateProcess(GetCurrentProcess(), 1); // WszFatalAppExit(0, L"Shutting down"); break; // Tell caller to break at the correct loction. case IDRETRY: hKrnl32 = WszLoadLibrary(L"kernel32.dll"); _ASSERTE(hKrnl32 != NULL); if(hKrnl32) { typedef BOOL (WINAPI *t_pDbgPres)(); t_pDbgPres pFcn = (t_pDbgPres) GetProcAddress(hKrnl32, "IsDebuggerPresent"); // If this function is available, use it. if (pFcn) { if (pFcn()) { SetErrorMode(0); } else LaunchJITDebugger(); } FreeLibrary(hKrnl32); } return (true); // If we want to ignore the assert, find out if this is forever. case IDIGNORE: swprintf(rcBuff, L"Ignore the assert for the rest of this run?\nYes - Assert will never fire again.\nNo - Assert will continue to fire.\n\n%hs\nLine: %d\n", szFile, iLine); if (WszMessageBoxInternal(NULL, rcBuff, L"Ignore Assert Forever?", MB_ICONQUESTION | MB_YESNO | COMPLUS_MB_SERVICE_NOTIFICATION) != IDYES) break; if ((psData = pDBGIFNORE->Append()) == 0) return (false); psData->bIgnore = true; psData->iLine = iLine; strcpy(psData->rcFile, szFile); break; } return (false); }
HRESULT CoCreateInstanceWithoutModel( REFCLSID rclsid, REFIID riid, void **ppv ) { HKEY key; DWORD len; LONG result; HRESULT hr = S_OK; OLECHAR guidString[128]; wchar_t keyString[1024]; wchar_t dllName[MAX_PATH]; StringFromGUID2( rclsid, guidString, NumItems( guidString ) ); #ifndef _UNICODE wchar_t szID[64]; // the class ID to register. WideCharToMultiByte( CP_ACP, 0, guidString, -1, szID, sizeof( szID ), NULL, NULL ); _stprintf_s( keyString, 1024, _T("CLSID\\%s\\InprocServer32"), szID ); #else _stprintf_s( keyString, 1024, _T("CLSID\\%s\\InprocServer32"), guidString ); #endif // Lets grab the DLL name now. result = RegOpenKeyEx( HKEY_CLASSES_ROOT, keyString, 0, KEY_READ, &key ); if ( result == ERROR_SUCCESS ) { DWORD type; result = RegQueryValueEx( key, NULL, NULL, &type, NULL, &len ); if ((result == ERROR_SUCCESS) && ((type == REG_SZ) || (type == REG_EXPAND_SZ))) { result = RegQueryValueEx( key, NULL, NULL, &type, (BYTE*) dllName, &len ); if (result == ERROR_SUCCESS) { // We've got the name of the DLL to load, so load it. HINSTANCE dll; dll = LoadLibraryEx( dllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); if ( dll != NULL ) { // We've loaded the DLL, so find the DllGetClassObject function. FARPROC func; func = GetProcAddress( dll, "DllGetClassObject" ); if ( func != NULL ) { // Cool, lets call the function to get a class factory for // the rclsid passed in. IClassFactory *classFactory; DLLGETCLASSOBJECT *dllGetClassObject = (DLLGETCLASSOBJECT*)func; hr = dllGetClassObject( rclsid, IID_ICF, (void**)&classFactory ); if ( SUCCEEDED( hr ) ) { // // Ask the class factory to create an instance of the // necessary object. // hr = classFactory->CreateInstance( NULL, riid, ppv ); // Release that class factory! classFactory->Release(); } } else hr = HRESULT_FROM_WIN32( GetLastError() ); } else hr = HRESULT_FROM_WIN32( GetLastError() ); } else hr = HRESULT_FROM_WIN32( GetLastError() ); } else hr = HRESULT_FROM_WIN32( GetLastError() ); RegCloseKey( key ); } else hr = HRESULT_FROM_WIN32( GetLastError() ); return hr; }
HRESULT LoadDataAccessDll(HINSTANCE mscorModule, REFIID ifaceId, ICLRDataTarget* target, HMODULE* dllHandle, void** iface) { HRESULT status; WCHAR accessDllPath[MAX_PATH]; HMODULE accessDll; // // Load the access DLL from the same directory // as the runtime DLL. // if (!WszGetModuleFileName(mscorModule, accessDllPath, NumItems(accessDllPath))) { return HRESULT_FROM_GetLastError(); } PWSTR pathTail = wcsrchr(accessDllPath, '\\'); if (!pathTail) { return E_INVALIDARG; } pathTail++; PWSTR eeFlavor = L"wks"; if (_snwprintf_s(pathTail, _countof(accessDllPath) + (accessDllPath - pathTail), NumItems(accessDllPath) - (pathTail - accessDllPath), MAKEDLLNAME_W(L"mscordac%s"), eeFlavor) <= 0) { return E_INVALIDARG; } accessDll = WszLoadLibrary(accessDllPath); if (!accessDll) { return HRESULT_FROM_GetLastError(); } // // Get the access interface and have it // enumerate the interesting memory in the target process. // void* ifacePtr; PFN_CLRDataCreateInstance entry = (PFN_CLRDataCreateInstance) GetProcAddress(accessDll, "CLRDataCreateInstance"); if (!entry) { status = HRESULT_FROM_GetLastError(); FreeLibrary(accessDll); } else if ((status = entry(ifaceId, target, &ifacePtr)) != S_OK) { FreeLibrary(accessDll); } else { *dllHandle = accessDll; *iface = ifacePtr; } return status; }
/// Sets the samples of this chunk. /// @param samples the samples of this chunk. /// @throws std::length_error Too many samples. void set_samples(const std::vector<std::shared_ptr<SFSample>> & samples) { samples_ = &samples; size_ = kItemSize * NumItems(); }
} #endif // defined(FEATURE_DBGIPC_TRANSPORT_VM) || defined(FEATURE_DBGIPC_TRANSPORT_DI) //----------------------------------------------------------------------------- // Helper to get the proper decorated name // Caller ensures that pBufSize is large enough. We'll assert just to check, // but no runtime failure. // pBuf - the output buffer to write the decorated name in // cBufSizeInChars - the size of the buffer in characters, including the null. // pPrefx - The undecorated name of the event. //----------------------------------------------------------------------------- void GetPidDecoratedName(__out_z __out_ecount(cBufSizeInChars) WCHAR * pBuf, int cBufSizeInChars, const WCHAR * pPrefix, DWORD pid) { const WCHAR szGlobal[] = W("Global\\"); int szGlobalLen; szGlobalLen = NumItems(szGlobal) - 1; // Caller should always give us a big enough buffer. _ASSERTE(cBufSizeInChars > (int) wcslen(pPrefix) + szGlobalLen); // PERF: We are no longer calling GetSystemMetrics in an effort to prevent // superfluous DLL loading on startup. Instead, we're prepending // "Global\" to named kernel objects if we are on NT5 or above. The // only bad thing that results from this is that you can't debug // cross-session on NT4. Big bloody deal. wcscpy_s(pBuf, cBufSizeInChars, szGlobal); pBuf += szGlobalLen; cBufSizeInChars -= szGlobalLen; int ret; ret = _snwprintf_s(pBuf, cBufSizeInChars, _TRUNCATE, pPrefix, pid);
LPSTR FillSymbolSearchPathThrows(CQuickBytes &qb) { STATIC_CONTRACT_GC_NOTRIGGER; STATIC_CONTRACT_CANNOT_TAKE_LOCK; SCAN_IGNORE_FAULT; // Faults from Wsz funcs are handled. #ifndef DACCESS_COMPILE // not allowed to do allocation if current thread suspends EE. if (IsSuspendEEThread ()) return NULL; #endif InlineSString<MAX_SYM_PATH> rcBuff ; // Working buffer WCHAR rcVerString[64]; // Extension for install directory. int chTotal = 0; // How full is working buffer. int ch; // If the NT symbol server path vars are there, then use those. chTotal = WszGetEnvironmentVariable(W("_NT_SYMBOL_PATH"), rcBuff); if (chTotal + 1 < MAX_SYM_PATH) rcBuff.Append(W(';')); // Copy the defacto NT symbol path as well. size_t sympathLength = chTotal + NumItems(DEFAULT_SYM_PATH) + 1; // integer overflow occurred if (sympathLength < (size_t)chTotal || sympathLength < NumItems(DEFAULT_SYM_PATH)) { return NULL; } if (sympathLength < MAX_SYM_PATH) { rcBuff.Append(DEFAULT_SYM_PATH); chTotal = rcBuff.GetCount(); } // Next, if there is a URTTARGET, add that since that is where ndpsetup places // your symobls on an install. PathString rcBuffTemp; ch = WszGetEnvironmentVariable(W("URTTARGET"), rcBuffTemp); rcBuff.Append(rcBuffTemp); if (ch != 0 && (chTotal + ch + 1 < MAX_SYM_PATH)) { size_t chNewTotal = chTotal + ch; if (chNewTotal < (size_t)chTotal || chNewTotal < (size_t)ch) { // integer overflow occurred return NULL; } chTotal += ch; rcBuff.Append(W(';')); } #ifndef SELF_NO_HOST // Fetch the path location of the engine dll and add that path as well, just // in case URTARGET didn't cut it either. // For no-host builds of utilcode, we don't necessarily have an engine DLL in the // process, so skip this part. ch = WszGetModuleFileName(GetCLRModuleHack(), rcBuffTemp); size_t pathLocationLength = chTotal + ch + 1; // integer overflow occurred if (pathLocationLength < (size_t)chTotal || pathLocationLength < (size_t)ch) { return NULL; } if (ch != 0 && (pathLocationLength < MAX_SYM_PATH)) { chTotal = chTotal + ch - NumItems(STR_ENGINE_NAME); rcBuff.Append(W(';')); } #endif // Now we have a working buffer with a bunch of interesting stuff. Time // to convert it back to ansi for the imagehlp api's. Allocate the buffer // 2x bigger to handle worst case for MBCS. ch = ::WszWideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, rcBuff, -1, 0, 0, 0, 0); LPSTR szRtn = (LPSTR) qb.AllocNoThrow(ch + 1); if (!szRtn) return NULL; WszWideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, rcBuff, -1, szRtn, ch+1, 0, 0); return (szRtn); }
void ScrolledListView::KeyDown(const char* bytes, int32 numBytes) { switch (bytes[0]) { case B_ENTER: case ' ': if (selection >= 0) OpenSelectedItem(selection); break; case B_UP_ARROW: int32 newSelection; if (selection < 0) newSelection = NumItems() - 1; else if (selection > 0) newSelection = selection - 1; else newSelection = selection; Select(newSelection); ScrollToSelection(); break; case B_DOWN_ARROW: if (selection < NumItems() - 1) Select(selection + 1); ScrollToSelection(); break; case B_PAGE_UP: { float itemHeight = ItemHeight(); float visibleHeight = Bounds().Height() + 1; ScrollBy(0, -(visibleHeight - itemHeight)); } break; case B_PAGE_DOWN: { float itemHeight = ItemHeight(); float visibleHeight = Bounds().Height() + 1; ScrollBy(0, visibleHeight - itemHeight); } break; case B_HOME: ScrollTo(0, 0); break; case B_END: { float visibleHeight = Bounds().Height(); ScrollTo(0, NumItems() * ItemHeight() - visibleHeight); } break; case B_BACKSPACE: case B_DELETE: if (selection >= 0) RemoveSelectedItem(selection); break; default: BView::KeyDown(bytes, numBytes); break; } }
/// Sets the presets of this chunk. /// @param presets the presets of this chunk. /// @throws std::length_error Too many preset zones. void set_presets( const std::vector<std::shared_ptr<SFPreset>> & presets) { presets_ = &presets; size_ = kItemSize * NumItems(); }
void DumpMD_DisplayUserStrings( RegMeta *pMD) // The scope to dump. { HCORENUM stringEnum = NULL; // string enumerator. mdString Strings[ENUM_BUFFER_SIZE]; // String tokens from enumerator. CQuickArray<WCHAR> rUserString; // Buffer to receive string. WCHAR *szUserString; // Working pointer into buffer. ULONG chUserString; // Size of user string. CQuickArray<char> rcBuf; // Buffer to hold the BLOB version of the string. char *szBuf; // Working pointer into buffer. ULONG chBuf; // Saved size of the user string. ULONG count; // Items returned from enumerator. ULONG totalCount = 1; // Running count of strings. bool bUnprint = false; // Is an unprintable character found? HRESULT hr; // A result. while (SUCCEEDED(hr = pMD->EnumUserStrings( &stringEnum, Strings, NumItems(Strings), &count)) && count > 0) { if (totalCount == 1) { // If only one, it is the NULL string, so don't print it. DumpMD_WriteLine("User Strings"); DumpMD_WriteLine("-------------------------------------------------------"); } for (ULONG i = 0; i < count; i++, totalCount++) { do { // Try to get the string into the existing buffer. hr = pMD->GetUserString( Strings[i], rUserString.Ptr(),(ULONG32)rUserString.MaxSize(), &chUserString); if (hr == CLDB_S_TRUNCATION) { // Buffer wasn't big enough, try to enlarge it. if (FAILED(rUserString.ReSizeNoThrow(chUserString))) DumpMD_VWriteLine("malloc failed: %#8x.", E_OUTOFMEMORY); continue; } } while (0); if (FAILED(hr)) DumpMD_VWriteLine("GetUserString failed: %#8x.", hr); szUserString = rUserString.Ptr(); chBuf = chUserString; DumpMD_VWrite("%08x : (%2d) L\"", Strings[i], chUserString); while (chUserString) { switch (*szUserString) { case 0: DumpMD_Write("\\0"); break; case W('\r'): DumpMD_Write("\\r"); break; case W('\n'): DumpMD_Write("\\n"); break; case W('\t'): DumpMD_Write("\\t"); break; default: if (iswprint(*szUserString)) DumpMD_VWrite("%lc", *szUserString); else { bUnprint = true; DumpMD_Write("."); } break; } ++szUserString; --chUserString; } DumpMD_WriteLine("\""); // Print the user string as a blob if an unprintable character is found. if (bUnprint) { bUnprint = false; szUserString = rUserString.Ptr(); // REVISIT_TODO: ReSizeNoThrow can fail. Check its return value and add an error path. rcBuf.ReSizeNoThrow(81); //(chBuf * 5 + 1); szBuf = rcBuf.Ptr(); ULONG j,k; DumpMD_WriteLine("\t\tUser string has unprintables, hex format below:"); for (j = 0,k=0; j < chBuf; j++) { // See rcBuf.ResSizeNoThrow(81) above sprintf_s (&szBuf[k*5],81-(k*5), "%04x ", szUserString[j]); k++; if((k==16)||(j == (chBuf-1))) { szBuf[k*5] = '\0'; DumpMD_VWriteLine("\t\t%s", szBuf); k=0; } } } } } if (stringEnum) pMD->CloseEnum(stringEnum); } // void MDInfo::DisplayUserStrings()