// // FUNCTION: FileContextMenuExt::QueryContextMenu // // PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the // context menu handler to add its menu items to the menu. It // passes in the HMENU handle in the hmenu parameter. The // indexMenu parameter is set to the index to be used for the // first menu item that is to be added. // IFACEMETHODIMP FileContextMenuExt::QueryContextMenu( HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything. if (CMF_DEFAULTONLY & uFlags) { return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); } // Use either InsertMenu or InsertMenuItem to add menu items. // Learn how to add sub-menu from: // http://www.codeproject.com/KB/shell/ctxextsubmenu.aspx UINT uID = idCmdFirst; MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE; mii.wID = uID++; mii.fType = MFT_STRING; mii.dwTypeData = m_pszMenuText; mii.fState = MFS_ENABLED; mii.hbmpItem = static_cast<HBITMAP>(m_hMenuBmp); if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii)) { return HRESULT_FROM_WIN32(GetLastError()); } HMENU hSubmenu = CreatePopupMenu(); InsertMenu ( hSubmenu, 0, MF_BYPOSITION, uID++, L"&Shred Quick" ); InsertMenu ( hSubmenu, 1, MF_BYPOSITION, uID++, L"&Shred Safe" ); InsertMenu ( hSubmenu, 1, MF_BYPOSITION, uID++, L"&Shred Through" ); MENUITEMINFO mii2 = { sizeof(mii2) }; mii2.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_SUBMENU | MIIM_STATE; mii2.fType = MFT_STRING; mii2.wID = IDM_SHRED; mii2.dwTypeData = m_pszMenuText2; mii2.hbmpItem = static_cast<HBITMAP>(m_hMenuBmp); mii.fState = MFS_ENABLED; mii2.hSubMenu = hSubmenu; if (!InsertMenuItem(hMenu, indexMenu + 1, TRUE, &mii2)) { return HRESULT_FROM_WIN32(GetLastError()); } // Add a separator. MENUITEMINFO sep = { sizeof(sep) }; sep.fMask = MIIM_TYPE; sep.fType = MFT_SEPARATOR; if (!InsertMenuItem(hMenu, indexMenu + 2, TRUE, &sep)) { return HRESULT_FROM_WIN32(GetLastError()); } // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. // Set the code value to the offset of the largest command identifier // that was assigned, plus one (1). return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(5)); }
// // FUNCTION: CDrmShlExt::QueryContextMenu(HMENU, UINT, UINT, UINT, // UINT) // // PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the // context menu handler to add its menu items to the menu. It // passes in the HMENU handle in the hmenu parameter. The // indexMenu parameter is set to the index to be used for the // first menu item that is to be added. // IFACEMETHODIMP CDrmShlExt::QueryContextMenu( HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything if (CMF_DEFAULTONLY & uFlags) { return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); } //unsigned long originalFirst = idCmdFirst; //we'll compute how many items we added from this. HBITMAP hBitmap = (HBITMAP)LoadImage((HMODULE)_AtlBaseModule.m_hInst, MAKEINTRESOURCE(IDB_PAGE_UNLOCK) , IMAGE_BITMAP, 16, 16, 0); InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_DECRYPT, _T("&Decrypt")); SetMenuItemBitmaps(hMenu, indexMenu, MF_BITMAP | MF_BYPOSITION, hBitmap, NULL); indexMenu++; //this corresponds to the top-level menu index // Use either InsertMenu or InsertMenuItem tSo add menu items to the list //InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + // IDM_DECRYPT, _T("&Decrypt")); // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. // Set the code value to the offset of the largest command identifier // that was assigned, plus one (1) return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_DECRYPT + 1)); }
STDMETHODIMP ContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { //HRESULT hr; if (!(CMF_DEFAULTONLY & uFlags)) { InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHAREWITHBOX, MENU_A); if (m_hbmp) { SetMenuItemBitmaps( hMenu, indexMenu, MF_STRING | MF_BYPOSITION, m_hbmp, m_hbmp); } // TODO: Add error handling to verify HRESULT return values. return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_SHAREWITHBOX + 1)); } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); }
// // FUNCTION: ContextMenuExt::QueryContextMenu // // PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the // context menu handler to add its menu items to the menu. It // passes in the HMENU handle in the hmenu parameter. The // indexMenu parameter is set to the index to be used for the // first menu item that is to be added. // // doc about MENUITEMINFO: // http://msdn.microsoft.com/en-us/library/windows/desktop/ms647578(v=vs.85).aspx // // doc about InsertMenuItem: // http://msdn.microsoft.com/en-us/library/windows/desktop/ms647988(v=vs.85).aspx // IFACEMETHODIMP ContextMenuExt::QueryContextMenu( HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything. if (CMF_DEFAULTONLY & uFlags) { return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); } // context menu menu handle m_hTopMenu = hMenu; // position index m_topMenuIndex = indexMenu; m_subMenuIndex = 0; // command id m_firstCmdId = idCmdFirst; m_currentCmdId = idCmdFirst; m_cmdIdToCommand.clear(); // create and populate the submenu. if (!CreateSubMenu()) { return HRESULT_FROM_WIN32(GetLastError()); } // create and populate top level menu if (!CreateTopMenu()) { return HRESULT_FROM_WIN32(GetLastError()); } // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. // Set the code value to the offset of the largest command identifier // that was assigned, plus one (1). return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(m_currentCmdId - idCmdFirst + 1)); }
UCHAR DbImplementation::backwardCompatibleImplementation() const { if (di_cpu >= FB_NELEM(hardware) || di_os >= FB_NELEM(operatingSystem)) { return 0; } return backwardTable[USHORT(di_os) * FB_NELEM(hardware) + USHORT(di_cpu)]; }
//IContextMenu HRESULT FileKeeperStuff::QueryContextMenu( /* [in] */ HMENU hmenu, /* [in] */ UINT indexMenu, /* [in] */ UINT idCmdFirst, /* [in] */ UINT idCmdLast, /* [in] */ UINT uFlags) { if (!(uFlags & CMF_DEFAULTONLY)) { ModuleContex* pCtx = ModuleContex::GetInstPtr(); HMODULE hInst = pCtx->GetModuleHandle(); int nCmdID = idCmdFirst; TCHAR szBuf[MAX_PATH] = _T(""); int nLen = 0; int nSubItemIndex = 0; HMENU hFKMenu = CreatePopupMenu(); MENUITEMINFO mii = {sizeof(mii)}; nLen = LoadString(hInst, IDS_STRING_ABOUT, szBuf, MAX_PATH) + 1; mii.fMask = MIIM_STRING | MIIM_ID; //MIIM_BITMAP mii.wID = nCmdID++; mii.dwTypeData = szBuf; mii.cch = nLen; InsertMenuItem(hFKMenu, nSubItemIndex, TRUE, &mii); LoadString(hInst, IDS_STRING_ABOUT_HS, szBuf, MAX_PATH); pCtx->AddCommandString(nSubItemIndex, szBuf); pCtx->AddCommandHandler(nSubItemIndex, &FileKeeperStuff::OnAbout); nSubItemIndex++; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); nLen = LoadString(hInst, IDS_STRING_FILEKEEPER, szBuf, MAX_PATH) + 1; mii.fMask = MIIM_SUBMENU | MIIM_STRING | MIIM_ID; mii.hSubMenu = hFKMenu; mii.wID = nCmdID++; mii.dwTypeData = szBuf; mii.cch = nLen; InsertMenuItem(hmenu, indexMenu, TRUE, &mii); return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(nCmdID - idCmdFirst)); } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); }
Time::Time(time_t unixTime) { PCHAR ct = ctime(&unixTime) + 11; USHORT hours, mins, secs; hours = USHORT(atoi(&ct[0])); mins = USHORT(atoi(&ct[3])); secs = USHORT(atoi(&ct[6])); *this = Time(hours, mins, secs); }
const Date& Dirent::date() const { MStackCall(__FILE__,__LINE__); if (!fileDate) { (*(Date**)&fileDate) = new Date( USHORT(fDate.day), USHORT(fDate.month), USHORT(fDate.year+1980)); } return *fileDate; }
const Time& Dirent::time() const { MStackCall(__FILE__,__LINE__); if (!fileTime) { (*(Time**)&fileTime) = new Time( USHORT(fTime.hours), USHORT(fTime.minutes), USHORT(fTime.twosecs*2)); } return *fileTime; }
//--------------------------------------------------------------------------- USHORT CalcCRC(USHORT crc, BYTE c) { int i; crc = USHORT(crc ^ (c << 8)); for( i = 0; i < 8; i++ ){ if( crc & 0x8000 ){ crc = USHORT((crc << 1) ^ 0x1021); } else { crc = USHORT(crc << 1); } } return crc; }
HRESULT STDMETHODCALLTYPE CRenameExtImpl::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { if((CMF_CANRENAME & uFlags)) { InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_DISPLAY, _T("&Change File Extention")); return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_DISPLAY + 1)); } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); }
STDMETHODIMP CWorkshareMenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { RighClickMenuManger rcm(m_vSelectedDocuments); if (((!(CMF_DEFAULTONLY & indexMenu)) && (rcm.IsAtLeastOneMenuItemVisible()))) { ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_SEPARATOR, NULL, NULL ); if (rcm.ShowCompareInDeltaView()) ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + COMPARE_WITH_DELTAVIEW_MENU_OFFSET, (LPCTSTR)COMPARE_WITH_DELTAVIEW_MENU_OFFSET ); if (rcm.ShowConvertToPdf()) ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + CONVERT_TO_PDF_OFFSET, (LPCTSTR)CONVERT_TO_PDF_OFFSET ); if (rcm.ShowOpenPdfInWord()) ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + OPEN_PDF_IN_WORD_OFFSET, (LPCTSTR)OPEN_PDF_IN_WORD_OFFSET ); if (rcm.ShowCombineToPdf()) ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + COMBINE_PDF_OFFSET, (LPCTSTR)COMBINE_PDF_OFFSET); ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_SEPARATOR, NULL, NULL ); return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, COMBINE_PDF_OFFSET + 1 ); } return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, USHORT(0)); }
IFACEMETHODIMP OCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici) { if (pici->cbSize == sizeof(CMINVOKECOMMANDINFOEX) && (pici->fMask & CMIC_MASK_UNICODE)) { return E_FAIL; } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); if (HIWORD(((CMINVOKECOMMANDINFOEX *)pici)->lpVerbW)) { if (StrCmpIW(((CMINVOKECOMMANDINFOEX *)pici)->lpVerbW, m_pwszVerb)) { return E_FAIL; } } if (LOWORD(pici->lpVerb) != IDM_SHARE) { return E_FAIL; } MessageBox(pici->hwnd, L"ownCloud was here", L"ownCloud was here", MB_OK | MB_ICONINFORMATION); }
IFACEMETHODIMP ComposerShellMenu::QueryContextMenu( HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // Do nothing if uFlags include CMF_DEFAULTONLY. if (CMF_DEFAULTONLY & uFlags) return S_OK; // See if we have already written the menu. if (MenuExists(hMenu)) return S_OK; // Get the target directory and status HRESULT hr = GetTargetData(); if (SUCCEEDED(hr)) { DWORD result = 0; if (!MenuBuild(hMenu, indexMenu, idCmdFirst, &result)) { hr = HRESULT_FROM_WIN32(result); } else { hr = MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(result)); } } return hr; }
// // Routine Description: // // PL011EvtInterruptIsr is the interrupt service routine for // ARM PL011 UART. PL011EvtInterruptIsr calls PL011pInterruptIsr to do // incoming events ISR level processing, and schedules a DPC level // processing PL011EvtInterruptDpc if our device generated the interrupt. // // Arguments: // // WdfInterrupt - The WDF interrupt object the created for the ARM PL011 // interrupt. // // MessageID - The message ID, in case the device is using MSIs, otherwise 0. // // Return Value: // // TRUE if the interrupt originated from the PL011 device and was serviced, // otherwise FALSE. // _Use_decl_annotations_ BOOLEAN PL011EvtInterruptIsr( WDFINTERRUPT WdfInterrupt, ULONG MessageID ) { UNREFERENCED_PARAMETER(MessageID); WDFDEVICE wdfDevice = WdfInterruptGetDevice(WdfInterrupt); PL011_DEVICE_EXTENSION* devExtPtr = PL011DeviceGetExtension(wdfDevice); // // Get and process UART events (ISR level) // BOOLEAN isUartInterrupt = PL011pInterruptIsr(devExtPtr); if (!isUartInterrupt) { return FALSE; } PL011_ASSERT(WdfInterrupt == devExtPtr->WdfUartInterrupt); WdfInterruptQueueDpcForIsr(devExtPtr->WdfUartInterrupt); PL011_LOG_TRACE( "UART ISR, status 0x%04X", USHORT(devExtPtr->IntEventsForDpc) ); return TRUE; }
DbImplementation DbImplementation::fromBackwardCompatibleByte(UCHAR bcImpl) { for (UCHAR os = 0; os < FB_NELEM(operatingSystem); ++os) { for (UCHAR hw = 0; hw < FB_NELEM(hardware); ++hw) { USHORT ind = USHORT(os) * FB_NELEM(hardware) + USHORT(hw); if (backwardTable[ind] == bcImpl) { return DbImplementation(hw, os, 0xFF, backEndianess[hw] ? EndianBig : EndianLittle); } } } return DbImplementation(0xFF, 0xFF, 0xFF, 0x80); }
DateTime::DateTime(unsigned int uiYear, unsigned int uiMonth, unsigned int uiDay, unsigned int uiHour, unsigned int uiMinute, unsigned int uiSecond, unsigned int uiMillisecond) :m_spImpl(new DateTimeImpl) { try { m_spImpl->m_dt = boost::posix_time::ptime( boost::gregorian::date(USHORT(uiYear), USHORT(uiMonth), USHORT(uiDay)), boost::posix_time::time_duration(uiHour, uiMinute, uiSecond, uiMillisecond*1000)); } catch(...) { // illegal date/time value(s) m_spImpl->m_dt = boost::date_time::not_a_date_time; } }
virtual void Write(JLSOutputStream* pstream) { pstream->WriteByte(0xFF); pstream->WriteByte(_marker); pstream->WriteWord(USHORT(_vecbyte.size() + 2)); pstream->WriteBytes(_vecbyte); }
void DateTime::SetDateTime(unsigned int uiYear, unsigned int uiMonth, unsigned int uiDay, unsigned int uiHour, unsigned int uiMinute, unsigned int uiSecond, unsigned int uiMillisecond) throw() { PrepareCopy(); try { m_spImpl->m_dt = boost::posix_time::ptime( boost::gregorian::date(USHORT(uiYear), USHORT(uiMonth), USHORT(uiDay)), boost::posix_time::time_duration(uiHour, uiMinute, uiSecond, uiMillisecond*1000)); } catch(...) { // illegal date/time span value m_spImpl->m_dt = boost::date_time::not_a_date_time; } }
STDMETHODIMP CDeskBand::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { if (!(CMF_DEFAULTONLY & uFlags)) { InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_COMMAND, L"Assistive Touch Tool"); return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_COMMAND + 1)); } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); }
IOResult RigidBodyWorldDesc::Save(ISave* isave) { IOResult ret = ClassDesc2::Save(isave); ULONG retVal; isave->BeginChunk(USHORT (ClassID().PartB())); isave->Write((const char*)&m_gravity, sizeof (m_gravity), &retVal); isave->Write((const char*)&m_minFps, sizeof (m_minFps), &retVal); isave->EndChunk(); return ret; }
HRESULT CShellMenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { //if(!(uFlags & CMF_DEFAULTONLY)) if(!m_bMultiFile) { HBITMAP hBmp = NULL; ::InsertMenu(hmenu, indexMenu, MF_BYPOSITION, idCmdFirst++, _T("&Register")); hBmp = ::LoadBitmap(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDB_BITMAP_UNREGISTER)); if(m_hUnRegisterBmp != NULL) SetMenuItemBitmaps(hmenu, indexMenu, MF_BYPOSITION, m_hUnRegisterBmp, NULL); indexMenu++; ::InsertMenu(hmenu, indexMenu, MF_BYPOSITION, idCmdFirst++, _T("&UnRegister")); if(m_hRegisterBmp != NULL) SetMenuItemBitmaps(hmenu, indexMenu, MF_BYPOSITION, m_hRegisterBmp, NULL); return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(2)); } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); }
IFACEMETHODIMP CContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything. if (CMF_DEFAULTONLY & uFlags) return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_STRING | MIIM_ID | MIIM_SUBMENU; mii.wID = idCmdFirst + curid; mii.dwTypeData = L"KENSSharp"; mii.hSubMenu = ProcessSubMenu(rootmenu, idCmdFirst); if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii)) { return HRESULT_FROM_WIN32(GetLastError()); } // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. // Set the code value to the offset of the largest command identifier // that was assigned, plus one (1). return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(curid + 1)); }
IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { HRESULT hr; if (!(CMF_DEFAULTONLY & uFlags)) { InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHARE, L"&Share with ownCloud"); } hr = StringCbCopyW(m_pwszVerb, sizeof(m_pwszVerb), L"ownCloudShare"); return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_SHARE + 1)); }
// // FUNCTION: FileContextMenuExt::QueryContextMenu // // PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the // context menu handler to add its menu items to the menu. It // passes in the HMENU handle in the hmenu parameter. The // indexMenu parameter is set to the index to be used for the // first menu item that is to be added. // IFACEMETHODIMP FileContextMenuExt::QueryContextMenu( HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything. if (CMF_DEFAULTONLY & uFlags) { return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); } // Use either InsertMenu or InsertMenuItem to add menu items. MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE; mii.wID = idCmdFirst + IDM_DISPLAY; mii.fType = MFT_STRING; mii.dwTypeData = m_pszMenuText; mii.fState = MFS_ENABLED; mii.hbmpItem = static_cast<HBITMAP>(m_hMenuBmp); if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii)) { return HRESULT_FROM_WIN32(GetLastError()); } // Add a separator. MENUITEMINFO sep = { sizeof(sep) }; sep.fMask = MIIM_TYPE; sep.fType = MFT_SEPARATOR; if (!InsertMenuItem(hMenu, indexMenu + 1, TRUE, &sep)) { return HRESULT_FROM_WIN32(GetLastError()); } // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. // Set the code value to the offset of the largest command identifier // that was assigned, plus one (1). return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_DISPLAY + 1)); }
HRESULT STDMETHODCALLTYPE CBandSiteMenu::QueryContextMenu( HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { CComPtr<IPersist> pBand; CLSID BandCLSID; DWORD dwBandID; UINT idMax; TRACE("CBandSiteMenu::QueryContextMenu(%p, %p, %u, %u, %u, 0x%x)\n", this, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags); /* First Merge the menu with the available bands */ idMax = Shell_MergeMenus(hmenu, m_hmenu, indexMenu, idCmdFirst, idCmdLast, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS); HMENU hmenuToolbars = GetSubMenu(hmenu, indexMenu); /* Enumerate all present bands and mark them as checked in the menu */ for (UINT uBand = 0; SUCCEEDED(m_BandSite->EnumBands(uBand, &dwBandID)); uBand++) { if (FAILED(m_BandSite->GetBandObject(dwBandID, IID_PPV_ARG(IPersist, &pBand)))) continue; if (FAILED_UNEXPECTEDLY(pBand->GetClassID(&BandCLSID))) continue; UINT menuID; if (IsEqualGUID(BandCLSID, CLSID_ISFBand)) { menuID = _GetMenuIdFromISFBand(pBand); if (menuID == UINT_MAX) { HRESULT hr; hr = _AddISFBandToMenu(hmenuToolbars, 0, idCmdFirst, idCmdLast, pBand, dwBandID, &menuID); if (SUCCEEDED(hr) && menuID > idMax) idMax = menuID; menuID -= idCmdFirst; } } else { int i = m_ComCatGuids.Find(BandCLSID); menuID = (i == -1 ? UINT_MAX : i + FIRST_COMCAT_MENU_ID); } if (menuID != UINT_MAX) CheckMenuItem(hmenuToolbars, menuID + idCmdFirst, MF_CHECKED); } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(idMax - idCmdFirst +1)); }
ResourceString :: ResourceString (ULONG Id) : psz ("(string load error)") { SavedId = Id; if (DosGetResource (Module(), RT_STRING, Id/16+1, &BlockPointer)) return; psz = PSZ (BlockPointer) + sizeof(USHORT); USHORT Index = USHORT (Id % 16); while (Index--) { psz += * PUCHAR (psz); psz ++; } psz ++; }
static PDDESTRUCT MakeDDEObject ( HWND Destination, // -> Destination window PSZ Item, // -> Item name or NULL. USHORT Status, // Status flags. USHORT Format, // Data format PVOID Data, // -> Data or NULL. ULONG DataLen // Data length in bytes. ) { ULONG ItemLen = Item ? strlen(PCHAR(Item))+1 : 1 ; PDDESTRUCT pBlock ; if ( DosAllocSharedMem ( PPVOID(&pBlock), 0, sizeof(DDESTRUCT) + ItemLen + DataLen, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE ) ) return ( 0 ) ; pBlock->cbData = DataLen ; pBlock->fsStatus = Status ; pBlock->usFormat = Format ; pBlock->offszItemName = sizeof(DDESTRUCT) ; if ( DataLen AND Data ) pBlock->offabData = USHORT ( sizeof(DDESTRUCT) + ItemLen ) ; else pBlock->offabData = 0 ; if ( Item ) strcpy ( PCHAR(DDES_PSZITEMNAME(pBlock)), PCHAR(Item) ) ; else strcpy ( PCHAR(DDES_PSZITEMNAME(pBlock)), "" ) ; if ( Data ) memcpy ( DDES_PABDATA(pBlock), Data, size_t(DataLen) ) ; PID pid ; TID tid ; WinQueryWindowProcess ( Destination, &pid, &tid ) ; DosGiveSharedMem( (PVOID)pBlock, pid, PAG_READ | PAG_WRITE) ; return ( pBlock ) ; }
static void test_slist(void) { struct item { SLIST_ENTRY entry; int value; } item1, item2, item3, *pitem; SLIST_HEADER slist_header, test_header; PSLIST_ENTRY entry; USHORT size; VOID (WINAPI *pInitializeSListHead)(PSLIST_HEADER); USHORT (WINAPI *pQueryDepthSList)(PSLIST_HEADER); PSLIST_ENTRY (WINAPI *pInterlockedFlushSList)(PSLIST_HEADER); PSLIST_ENTRY (WINAPI *pInterlockedPopEntrySList)(PSLIST_HEADER); PSLIST_ENTRY (WINAPI *pInterlockedPushEntrySList)(PSLIST_HEADER,PSLIST_ENTRY); HMODULE kernel32; kernel32 = GetModuleHandle("KERNEL32.DLL"); pInitializeSListHead = (void*) GetProcAddress(kernel32, "InitializeSListHead"); pQueryDepthSList = (void*) GetProcAddress(kernel32, "QueryDepthSList"); pInterlockedFlushSList = (void*) GetProcAddress(kernel32, "InterlockedFlushSList"); pInterlockedPopEntrySList = (void*) GetProcAddress(kernel32, "InterlockedPopEntrySList"); pInterlockedPushEntrySList = (void*) GetProcAddress(kernel32, "InterlockedPushEntrySList"); if (pInitializeSListHead == NULL || pQueryDepthSList == NULL || pInterlockedFlushSList == NULL || pInterlockedPopEntrySList == NULL || pInterlockedPushEntrySList == NULL) { skip("some required slist entrypoints were not found, skipping tests\n"); return; } memset(&test_header, 0, sizeof(test_header)); memset(&slist_header, 0xFF, sizeof(slist_header)); pInitializeSListHead(&slist_header); ok(memcmp(&test_header, &slist_header, sizeof(SLIST_HEADER)) == 0, "InitializeSListHead didn't zero-fill list header\n"); size = pQueryDepthSList(&slist_header); ok(size == 0, "initially created slist has size %d, expected 0\n", size); item1.value = 1; ok(pInterlockedPushEntrySList(&slist_header, &item1.entry) == NULL, "previous entry in empty slist wasn't NULL\n"); size = pQueryDepthSList(&slist_header); ok(size == 1, "slist with 1 item has size %d\n", size); item2.value = 2; entry = pInterlockedPushEntrySList(&slist_header, &item2.entry); ok(entry != NULL, "previous entry in non-empty slist was NULL\n"); if (entry != NULL) { pitem = (struct item*) entry; ok(pitem->value == 1, "previous entry in slist wasn't the one added\n"); } size = pQueryDepthSList(&slist_header); ok(size == 2, "slist with 2 items has size %d\n", size); item3.value = 3; entry = pInterlockedPushEntrySList(&slist_header, &item3.entry); ok(entry != NULL, "previous entry in non-empty slist was NULL\n"); if (entry != NULL) { pitem = (struct item*) entry; ok(pitem->value == 2, "previous entry in slist wasn't the one added\n"); } size = pQueryDepthSList(&slist_header); ok(size == 3, "slist with 3 items has size %d\n", size); entry = pInterlockedPopEntrySList(&slist_header); ok(entry != NULL, "entry shouldn't be NULL\n"); if (entry != NULL) { pitem = (struct item*) entry; ok(pitem->value == 3, "unexpected entry removed\n"); } size = pQueryDepthSList(&slist_header); ok(size == 2, "slist with 2 items has size %d\n", size); entry = pInterlockedFlushSList(&slist_header); size = pQueryDepthSList(&slist_header); ok(size == 0, "flushed slist should be empty, size is %d\n", size); if (size == 0) { ok(pInterlockedPopEntrySList(&slist_header) == NULL, "popping empty slist didn't return NULL\n"); } ok(((struct item*)entry)->value == 2, "item 2 not in front of list\n"); ok(((struct item*)entry->Next)->value == 1, "item 1 not at the back of list\n"); }
void diskdump_display_regs(int cpu, FILE *ofp) { Elf32_Nhdr *note32; Elf64_Nhdr *note64; char *user_regs; size_t len; if (cpu >= NR_CPUS || dd->nt_prstatus_percpu[cpu] == NULL) { error(INFO, "registers not collected for cpu %d\n", cpu); return; } if (machine_type("X86_64")) { note64 = dd->nt_prstatus_percpu[cpu]; len = sizeof(Elf64_Nhdr); len = roundup(len + note64->n_namesz, 4); len = roundup(len + note64->n_descsz, 4); user_regs = (char *)note64 + len - SIZE(user_regs_struct) - sizeof(long); fprintf(ofp, " RIP: %016llx RSP: %016llx RFLAGS: %08llx\n" " RAX: %016llx RBX: %016llx RCX: %016llx\n" " RDX: %016llx RSI: %016llx RDI: %016llx\n" " RBP: %016llx R8: %016llx R9: %016llx\n" " R10: %016llx R11: %016llx R12: %016llx\n" " R13: %016llx R14: %016llx R15: %016llx\n" " CS: %04x SS: %04x\n", ULONGLONG(user_regs + OFFSET(user_regs_struct_rip)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rsp)), ULONGLONG(user_regs + OFFSET(user_regs_struct_eflags)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rax)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rbx)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rcx)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rdx)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rsi)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rdi)), ULONGLONG(user_regs + OFFSET(user_regs_struct_rbp)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r8)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r9)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r10)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r11)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r12)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r13)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r14)), ULONGLONG(user_regs + OFFSET(user_regs_struct_r15)), USHORT(user_regs + OFFSET(user_regs_struct_cs)), USHORT(user_regs + OFFSET(user_regs_struct_ss)) ); } if (machine_type("X86")) { note32 = dd->nt_prstatus_percpu[cpu]; len = sizeof(Elf32_Nhdr); len = roundup(len + note32->n_namesz, 4); len = roundup(len + note32->n_descsz, 4); user_regs = (char *)note32 + len - SIZE(user_regs_struct) - sizeof(int); fprintf(ofp, " EAX: %08x EBX: %08x ECX: %08x EDX: %08x\n" " ESP: %08x EIP: %08x ESI: %08x EDI: %08x\n" " CS: %04x DS: %04x ES: %04x FS: %04x\n" " GS: %04x SS: %04x\n" " EBP: %08x EFLAGS: %08x\n", UINT(user_regs + OFFSET(user_regs_struct_eax)), UINT(user_regs + OFFSET(user_regs_struct_ebx)), UINT(user_regs + OFFSET(user_regs_struct_ecx)), UINT(user_regs + OFFSET(user_regs_struct_edx)), UINT(user_regs + OFFSET(user_regs_struct_esp)), UINT(user_regs + OFFSET(user_regs_struct_eip)), UINT(user_regs + OFFSET(user_regs_struct_esi)), UINT(user_regs + OFFSET(user_regs_struct_edi)), USHORT(user_regs + OFFSET(user_regs_struct_cs)), USHORT(user_regs + OFFSET(user_regs_struct_ds)), USHORT(user_regs + OFFSET(user_regs_struct_es)), USHORT(user_regs + OFFSET(user_regs_struct_fs)), USHORT(user_regs + OFFSET(user_regs_struct_gs)), USHORT(user_regs + OFFSET(user_regs_struct_ss)), UINT(user_regs + OFFSET(user_regs_struct_ebp)), UINT(user_regs + OFFSET(user_regs_struct_eflags)) ); } }