bool CheckAccess( void* pAddress, size_t nSize ) { if ( !pAddress || !nSize ) { return false; } MEMORY_BASIC_INFORMATION sMBI; bool bRet = false; UINT_PTR pCurrentAddress = UINT_PTR( pAddress ); UINT_PTR pEndAdress = pCurrentAddress + ( nSize - 1 ); do { ZeroMemory( &sMBI, sizeof( sMBI ) ); VirtualQuery( LPCVOID( pCurrentAddress ), &sMBI, sizeof( sMBI ) ); bRet = ( sMBI.State & MEM_COMMIT ) // memory allocated and && !( sMBI.Protect & dwForbiddenArea ) // access to page allowed and && ( sMBI.Protect & dwAccessRights ); // the required rights pCurrentAddress = ( UINT_PTR( sMBI.BaseAddress ) + sMBI.RegionSize ); } while ( bRet && pCurrentAddress <= pEndAdress ); return bRet; }
static HMENU menuFromJson(const Json::Value& menuInfo) { if (menuInfo.isArray()) { HMENU menu = ::CreatePopupMenu(); for (auto it = menuInfo.begin(); it != menuInfo.end(); ++it) { const Json::Value& item = *it; UINT id = item.get("id", 0).asUInt(); std::wstring text = utf8ToUtf16(item.get("text", "").asCString()); UINT flags = MF_STRING; if (id == 0 && text.empty()) flags = MF_SEPARATOR; else { if (item.get("checked", false).asBool()) flags |= MF_CHECKED; if (!item.get("enabled", true).asBool()) flags |= MF_GRAYED; const Json::Value& subMenuValue = item.get("submenu", Json::nullValue); if (subMenuValue.isArray()) { HMENU submenu = menuFromJson(subMenuValue); flags |= MF_POPUP; id = UINT_PTR(submenu); } } AppendMenu(menu, flags, id, text.c_str()); } return menu; } return NULL; }
NDASVOL_LINKAGE HRESULT NDASVOL_CALL NdasIsNdasPathA( IN LPCSTR FilePath) { if (IsBadStringPtrA(FilePath, UINT_PTR(-1))) { XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR, "Invalid path, path=%hs\n", FilePath); return E_INVALIDARG; } XTLTRACE2(NdasVolTrace, 4, "NdasIsNdasPathA(%hs)\n", FilePath); int nChars = MultiByteToWideChar(CP_ACP, 0, FilePath, -1, NULL, 0); ++nChars; // additional terminating NULL char XTL::AutoProcessHeapPtr<WCHAR> wszFilePath = reinterpret_cast<LPWSTR>( ::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, nChars * sizeof(WCHAR))); if (wszFilePath.IsInvalid()) { return E_OUTOFMEMORY; } nChars = MultiByteToWideChar(CP_ACP, 0, FilePath, -1, wszFilePath, nChars); XTLASSERT(nChars > 0); return NdasIsNdasPathW(wszFilePath); }
void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnumData *lParam) { mii.wID = lParam->idCmdFirst; lParam->idCmdFirst++; // get the heap object HANDLE hDllHeap = lParam->Self->hDllHeap; TMenuDrawInfo *psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo)); if (pct != NULL) { psd->cch = pct->cbStrSection - 1; // no null; psd->szText = (char*)HeapAlloc(hDllHeap, 0, pct->cbStrSection); lstrcpyA(psd->szText, (char*)pct + sizeof(TSlotIPC)); psd->hContact = pct->hContact; psd->fTypes = dtContact; // find the protocol icon array to use && which status UINT c = lParam->Self->ProtoIconsCount; TSlotProtoIcons *pp = lParam->Self->ProtoIcons; psd->hStatusIcon = 0; while (c > 0) { c--; if (pp[c].hProto == pct->hProto && pp[c].pid == lParam->pid) { psd->hStatusIcon = pp[c].hIcons[pct->Status - ID_STATUS_OFFLINE]; psd->hStatusBitmap = pp[c].hBitmaps[pct->Status - ID_STATUS_OFFLINE]; break; } } // while psd->pid = lParam->pid; } else if (pg != NULL) { // store the given ID pg->hMenuGroupID = mii.wID; // steal the pointer from the group node it should be on the heap psd->cch = pg->cchGroup; psd->szText = pg->szGroup; psd->fTypes = dtGroup; } // if psd->wID = mii.wID; psd->szProfile = NULL; // store mii.dwItemData = UINT_PTR(psd); if (lParam->bOwnerDrawSupported && lParam->bShouldOwnerDraw) { mii.fType = MFT_OWNERDRAW; mii.dwTypeData = (LPSTR)psd; } else { // normal menu mii.fType = MFT_STRING; if (pct != NULL) mii.dwTypeData = LPSTR(pct) + sizeof(TSlotIPC); else mii.dwTypeData = pg->szGroup; // For Vista + let the system draw the theme && icons, pct = contact associated data if (bIsVistaPlus && pct != NULL && psd != NULL) { mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID | MIIM_DATA | MIIM_STRING; // BuildSkinIcons() built an array of bitmaps which we can use here mii.hbmpItem = psd->hStatusBitmap; } } }
bool QWindowsAudioDeviceInfo::testSettings(const QAudioFormat& format) const { WAVEFORMATEXTENSIBLE wfx; if (qt_convertFormat(format, &wfx)) { // query only, do not open device if (mode == QAudio::AudioOutput) { return (waveOutOpen(NULL, UINT_PTR(devId), &wfx.Format, 0, 0, WAVE_FORMAT_QUERY) == MMSYSERR_NOERROR); } else { // AudioInput return (waveInOpen(NULL, UINT_PTR(devId), &wfx.Format, 0, 0, WAVE_FORMAT_QUERY) == MMSYSERR_NOERROR); } } return false; }
// adds a new group if it doesn't exist yet; returns its hItem HTREEITEM CCList::AddGroup(TCString GroupName) { if (GroupName == L"") return TVI_ROOT; MGROUP hGroupId = Clist_GroupExists(GroupName); if (hGroupId == NULL) return nullptr; MCONTACT hContact = UINT_PTR(hGroupId) - 1 + HCONTACT_ISGROUP; HTREEITEM hGroupItem = FindContact(hContact); if (hGroupItem) return hGroupItem; // exists already, just return its handle TVINSERTSTRUCT tvIns = {}; tvIns.hParent = TVI_ROOT; tvIns.item.pszText = wcsrchr(GroupName, '\\'); if (tvIns.item.pszText) { TCString ParentGroupName(L""); tvIns.hParent = AddGroup(ParentGroupName.DiffCat(GroupName, tvIns.item.pszText)); tvIns.item.pszText++; } else tvIns.item.pszText = GroupName; tvIns.hInsertAfter = TVI_ROOT; tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED; tvIns.item.iImage = tvIns.item.iSelectedImage = IMAGE_GROUPOPEN; tvIns.item.lParam = Items.AddElem(CCLItemData(hContact)); return TreeView_InsertItem(hTreeView, &tvIns); }
// Entry INT APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PTSTR ptzCmdLine, INT iCmdShow) { // Active previous instance HWND hWnd = FindWindow(STR_AppName, NULL); if (hWnd) { ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(HWND(UINT_PTR(hWnd) | 0x00000001)); return 0; } // Init library CoInitializeEx(NULL, COINIT_MULTITHREADED); InitCommonControls(); #ifdef WINCE SHInitExtraControls(); #endif // Set basic information g_hInst = hInstance; g_ptzAppName = TStrGet(IDS_AppName); // Run the main window CAppWnd aw; aw.Run(ptzCmdLine, iCmdShow); // Free library CoUninitialize(); return 0; }
void __cdecl IssueTransferThread(void *param) { THeaderIPC *pipch = (THeaderIPC *)param; HANDLE hMainThread = HANDLE(pipch->Param); char szBuf[MAX_PATH]; GetCurrentDirectoryA(sizeof(szBuf), szBuf); TAddArgList args; args.count = 0; args.files = NULL; TSlotIPC *pct = pipch->DataPtr; BOOL bQuit = false; while (pct != NULL) { if (pct->cbSize != sizeof(TSlotIPC)) break; args.szFile = LPSTR(UINT_PTR(pct) + sizeof(TSlotIPC)); args.hContact = pct->hContact; args.cch = pct->cbStrSection + 1; bQuit = AddToList(args); if (bQuit) break; pct = pct->Next; } // while if (args.files != NULL) { args.files = (LPSTR*)mir_realloc(args.files, (args.count + 1) * sizeof(LPSTR)); args.files[args.count] = NULL; args.count++; if (!bQuit) { args.hEvent = CreateEvent(NULL, true, false, NULL); QueueUserAPC(MainThreadIssueTransfer, hMainThread, UINT_PTR(&args)); while (true) { if (WaitForSingleObjectEx(args.hEvent, INFINITE, true) != WAIT_IO_COMPLETION) break; } CloseHandle(args.hEvent); } for (int j = 0; j < args.count; j++) mir_free(args.files[j]); mir_free(args.files); } SetCurrentDirectoryA(szBuf); mir_free(pipch); CloseHandle(hMainThread); }
void IEToolbar::subclassWindow(const HWND window) { const UINT_PTR subclassId = UINT_PTR(this); const DWORD refData = DWORD(this); const BOOL subclassingResult = SetWindowSubclass(window, subclassProcThunk, subclassId, refData); if (FALSE == subclassingResult) { throw Error("Failed to subclass site window\n"); } }
TSlotIPC* ipcAlloc(THeaderIPC *pipch, int nSize) { // nSize maybe zero, in that case there is no string section --- UINT_PTR PSP = UINT_PTR(pipch->DataFramePtr) + sizeof(TSlotIPC) + nSize; // is it past the end? if (PSP >= UINT_PTR(pipch->DataPtrEnd)) return NULL; // return the pointer TSlotIPC *p = (TSlotIPC*)pipch->DataFramePtr; // set up the item p->cbSize = sizeof(TSlotIPC); p->cbStrSection = nSize; // update the frame ptr pipch->DataFramePtr = (void*)PSP; // let this item jump to the next yet-to-be-allocated-item which should be null anyway p->Next = (TSlotIPC*)PSP; return p; }
LRESULT TflatButton::onMouseMove(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { if (!isMouse) { RECT rect; POINT pt; GetClientRect(hwnd,&rect); MapWindowPoints(hwnd,NULL,(LPPOINT)&rect,2); GetCursorPos(&pt); if (PtInRect(&rect,pt) && (WindowFromPoint(pt)==hwnd)) { isMouse=true; InvalidateRect(hwnd,NULL,FALSE); SetTimer(hwnd,UINT_PTR(hwnd),100,(TIMERPROC)trackMouseTimerProc); } } return TwindowWidget::onMouseMove(hwnd,uMsg,wParam,lParam); }
NDASVOL_LINKAGE BOOL NDASVOL_CALL NdasIsNdasPathW( IN LPCWSTR FilePath) { CPARAM(IsValidStringPtrW(FilePath, UINT_PTR(-1))); XTLTRACE2(NdasVolTrace, 4, "NdasIsNdasPathW(%ls)\n", FilePath); XTL::AutoProcessHeapPtr<TCHAR> mountPoint = pGetVolumeMountPointForPath(FilePath); if (mountPoint.IsInvalid()) { XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR, _T("pGetVolumeMountPointForPath(%s) failed, error=0x%X\n"), FilePath, GetLastError()); return FALSE; } XTL::AutoProcessHeapPtr<TCHAR> volumeName = pGetVolumeDeviceNameForMountPoint(mountPoint); if (volumeName.IsInvalid()) { XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR, _T("pGetVolumeDeviceNameForMountPoint(%s) failed, error=0x%X\n"), mountPoint, GetLastError()); return FALSE; } // Volume is a \\.\C: XTL::AutoFileHandle hVolume = ::CreateFileW( volumeName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hVolume.IsInvalid()) { return FALSE; } return NdasIsNdasVolume(hVolume); }
NDASVOL_LINKAGE BOOL NDASVOL_CALL NdasIsNdasPathA( IN LPCSTR FilePath) { CPARAM(IsValidStringPtrA(FilePath, UINT_PTR(-1))); XTLTRACE2(NdasVolTrace, 4, "NdasIsNdasPathA(%hs)\n", FilePath); int nChars = ::MultiByteToWideChar(CP_ACP, 0, FilePath, -1, NULL, 0); ++nChars; // additional terminating NULL char XTL::AutoProcessHeapPtr<WCHAR> wszFilePath = reinterpret_cast<LPWSTR>( ::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, nChars * sizeof(WCHAR))); if (wszFilePath.IsInvalid()) { ::SetLastError(ERROR_OUTOFMEMORY); return FALSE; } nChars = ::MultiByteToWideChar(CP_ACP, 0, FilePath, -1, wszFilePath, nChars); return NdasIsNdasPathW(wszFilePath); }
void ipcFixupAddresses(THeaderIPC *pipch) { if (pipch->pServerBaseAddress == pipch->pClientBaseAddress) return; INT_PTR diff = INT_PTR(pipch->pClientBaseAddress) - INT_PTR(pipch->pServerBaseAddress); // fix up all the pointers in the header if (pipch->IconsBegin != NULL) pipch->IconsBegin = (TSlotIPC*)(UINT_PTR(pipch->IconsBegin) + diff); if (pipch->ContactsBegin != NULL) pipch->ContactsBegin = (TSlotIPC*)(UINT_PTR(pipch->ContactsBegin) + diff); if (pipch->GroupsBegin != NULL) pipch->GroupsBegin = (TSlotIPC*)(UINT_PTR(pipch->GroupsBegin) + diff); if (pipch->NewIconsBegin != NULL) pipch->NewIconsBegin = (TSlotIPC*)(UINT_PTR(pipch->NewIconsBegin) + diff); pipch->DataPtr = (TSlotIPC*)(UINT_PTR(pipch->DataPtr) + diff); pipch->DataPtrEnd = (TSlotIPC*)(UINT_PTR(pipch->DataPtrEnd) + diff); pipch->DataFramePtr = (void*)(UINT_PTR(pipch->DataFramePtr) + diff); // and the link list TSlotIPC *pct = pipch->DataPtr; while (pct != NULL) { // the first pointer is already fixed up, have to get a pointer // to the next pointer and modify where it jumps to TSlotIPC **q = &pct->Next; if (*q != NULL) *q = (TSlotIPC*)(UINT_PTR(*q) + diff); pct = *q; } }
void IEToolbar::unsubclassWindow(const HWND window) { const UINT_PTR subclassId = UINT_PTR(this); RemoveWindowSubclass(window, subclassProcThunk, subclassId); }
void BuildContactTree(TGroupNode *group, TEnumData *lParam) { // set up the menu item MENUITEMINFOA mii = { sizeof(mii) }; mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; // go thru all the contacts TSlotIPC *pct = lParam->ipch->ContactsBegin; while (pct != NULL && pct->cbSize == sizeof(TSlotIPC) && pct->fType == REQUEST_CONTACTS) { if (pct->hGroup != 0) { // at the } of the slot header is the contact's display name // && after a double NULL char there is the group string, which has the full path of the group // this must be tokenised at '\' and we must walk the in memory group tree til we find our group // this is faster than the old version since we only ever walk one or at most two levels of the tree // per tokenised section, and it doesn't matter if two levels use the same group name (which is valid) // as the tokens processed is equatable to depth of the tree char *sz = strtok(LPSTR(UINT_PTR(pct) + sizeof(TSlotIPC) + UINT_PTR(pct->cbStrSection) + 1), "\\"); // restore the root TGroupNode *pg = group; int Depth = 0; while (sz != NULL) { UINT Hash = murmur_hash(sz); // find this node within while (pg != NULL) { // does this node have the right hash and the right depth? if (Hash == pg->Hash && Depth == pg->Depth) break; // each node may have a left pointer going to a sub tree // the path syntax doesn't know if a group is a group at the same level // or a nested one, which means the search node can be anywhere TGroupNode *px = pg->Left; if (px != NULL) { // keep searching this level while (px != NULL) { if (Hash == px->Hash && Depth == px->Depth) { // found the node we're looking for at the next level to pg, px is now pq for next time pg = px; goto grouploop; } px = px->Right; } } pg = pg->Right; } grouploop: Depth++; // process next token sz = strtok(NULL, "\\"); } // tokenisation finished, if pg != NULL the group is found if (pg != NULL) { DecideMenuItemInfo(pct, NULL, mii, lParam); BuildMRU(pct, mii, lParam); InsertMenuItemA(pg->hMenu, 0xFFFFFFFF, true, &mii); pg->dwItems++; } } pct = pct->Next; } }
NDASVOL_LINKAGE HRESULT NDASVOL_CALL NdasIsNdasPathW( __in LPCWSTR FilePath) { HRESULT hr; if (IsBadStringPtrW(FilePath, UINT_PTR(-1))) { return E_INVALIDARG; } XTLTRACE2(NdasVolTrace, 4, "NdasIsNdasPathW(%ls)\n", FilePath); LPWSTR mountPoint; hr = pGetVolumeMountPointForPathW(FilePath, &mountPoint); if (FAILED(hr)) { XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR, "pGetVolumeMountPointForPath(%ls) failed, hr=0x%X\n", FilePath, hr); return hr; } XTL::AutoProcessHeapPtr<WCHAR> mountPointPtr = mountPoint; LPWSTR deviceName; hr = pGetVolumeDeviceNameForMountPointW(mountPoint, &deviceName); if (FAILED(hr)) { XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR, "pGetVolumeDeviceNameForMountPoint(%ls) failed, hr=0x%X\n", mountPoint, hr); return hr; } XTL::AutoProcessHeapPtr<TCHAR> deviceNamePtr = deviceName; // Volume is a \\.\C: XTL::AutoFileHandle volumeHandle = CreateFileW( deviceName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (INVALID_HANDLE_VALUE == static_cast<HANDLE>(volumeHandle)) { hr = HRESULT_FROM_WIN32(GetLastError()); XTLTRACE2(NdasVolTrace, TRACE_LEVEL_ERROR, "CreateFile failed, path=%ls, hr=0x%X\n", deviceName, hr); return hr; } return NdasIsNdasVolume(volumeHandle); }
static void BuildMenus(TEnumData *lParam) { LPSTR Token; TMenuDrawInfo *psd; HANDLE hDllHeap = lParam->Self->hDllHeap; HMENU hBaseMenu = lParam->Self->hRootMenu; // build an in memory tree of the groups TGroupNodeList j = { 0, 0 }; TSlotIPC *pg = lParam->ipch->GroupsBegin; while (pg != NULL) { if (pg->cbSize != sizeof(TSlotIPC) || pg->fType != REQUEST_GROUPS) break; UINT Depth = 0; TGroupNode *p = j.First; // start at root again // get the group Token = strtok(LPSTR(pg) + sizeof(TSlotIPC), "\\"); while (Token != NULL) { UINT Hash = murmur_hash(Token); // if the (sub)group doesn't exist, create it. TGroupNode *q = FindGroupNode(p, Hash, Depth); if (q == NULL) { q = AllocGroupNode(&j, p, Depth); q->Depth = Depth; // this is the hash of this group node, but it can be anywhere // i.e. Foo\Foo this is because each node has a different depth // trouble is contacts don't come with depths! q->Hash = Hash; // don't assume that pg->hGroup's hash is valid for this token // since it maybe Miranda\Blah\Blah and we have created the first node // which maybe Miranda, thus giving the wrong hash // since "Miranda" can be a group of it's own and a full path q->cchGroup = lstrlenA(Token); q->szGroup = (LPSTR)HeapAlloc(hDllHeap, 0, q->cchGroup + 1); lstrcpyA(q->szGroup, Token); q->dwItems = 0; } p = q; Depth++; Token = strtok(NULL, "\\"); } pg = pg->Next; } // build the menus inserting into hGroupMenu which will be a submenu of // the instance menu item. e.g. Miranda -> [Groups ->] contacts HMENU hGroupMenu = CreatePopupMenu(); // allocate MRU menu, this will be associated with the higher up menu // so doesn't need to be freed (unless theres no MRUs items attached) // This menu is per process but the handle is stored globally (like a stack) lParam->Self->hRecentMenu = CreatePopupMenu(); lParam->Self->RecentCount = 0; // create group menus only if they exist! if (lParam->ipch->GroupsBegin != NULL) { BuildMenuGroupTree(j.First, lParam, hGroupMenu); // add contacts that have a group somewhere BuildContactTree(j.First, lParam); } MENUITEMINFOA mii = { 0 }; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; // add all the contacts that have no group (which maybe all of them) pg = lParam->ipch->ContactsBegin; while (pg != NULL) { if (pg->cbSize != sizeof(TSlotIPC) || pg->fType != REQUEST_CONTACTS) break; if (pg->hGroup == 0) { DecideMenuItemInfo(pg, NULL, mii, lParam); BuildMRU(pg, mii, lParam); InsertMenuItemA(hGroupMenu, 0xFFFFFFFF, true, &mii); } pg = pg->Next; } // insert MRU menu as a submenu of the contact menu only if // the MRU list has been created, the menu popup will be deleted by itself if (lParam->Self->RecentCount > 0) { // insert seperator and 'clear list' menu mii.fType = MFT_SEPARATOR; mii.fMask = MIIM_TYPE; InsertMenuItemA(lParam->Self->hRecentMenu, 0xFFFFFFFF, true, &mii); // insert 'clear MRU' item and setup callback mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_DATA; mii.wID = lParam->idCmdFirst; lParam->idCmdFirst++; mii.fType = MFT_STRING; mii.dwTypeData = lParam->ipch->ClearEntries; // "Clear entries" // allocate menu substructure psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo)); psd->fTypes = dtCommand; psd->MenuCommandCallback = &ClearMRUIPC; psd->wID = mii.wID; // this is needed because there is a clear list command per each process. psd->pid = lParam->pid; mii.dwItemData = (LPARAM)psd; InsertMenuItemA(lParam->Self->hRecentMenu, 0xFFFFFFFF, true, &mii); // insert MRU submenu into group menu (with) ownerdraw support as needed psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo)); psd->szProfile = "MRU"; psd->fTypes = dtGroup; // the IPC string pointer wont be around forever, must make a copy psd->cch = (int)strlen(lParam->ipch->MRUMenuName); psd->szText = (LPSTR)HeapAlloc(hDllHeap, 0, psd->cch + 1); lstrcpynA(psd->szText, lParam->ipch->MRUMenuName, sizeof(lParam->ipch->MRUMenuName) - 1); mii.dwItemData = (LPARAM)psd; if (lParam->bOwnerDrawSupported && lParam->bShouldOwnerDraw) { mii.fType = MFT_OWNERDRAW; mii.dwTypeData = (LPSTR)psd; } else mii.dwTypeData = lParam->ipch->MRUMenuName; // 'Recent'; mii.wID = lParam->idCmdFirst; lParam->idCmdFirst++; mii.fMask = MIIM_TYPE | MIIM_SUBMENU | MIIM_DATA | MIIM_ID; mii.hSubMenu = lParam->Self->hRecentMenu; InsertMenuItemA(hGroupMenu, 0, true, &mii); } else { // no items were attached to the MRU, delete the MRU menu DestroyMenu(lParam->Self->hRecentMenu); lParam->Self->hRecentMenu = 0; } // allocate display info/memory for "Miranda" string mii.cbSize = sizeof(mii); if (bIsVistaPlus) mii.fMask = MIIM_ID | MIIM_DATA | MIIM_FTYPE | MIIM_SUBMENU | MIIM_STRING | MIIM_BITMAP; else mii.fMask = MIIM_ID | MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU; mii.hSubMenu = hGroupMenu; // by default, the menu will have space for icons and checkmarks (on Vista+) && we don't need this RemoveCheckmarkSpace(hGroupMenu); psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo)); psd->cch = (int)strlen(lParam->ipch->MirandaName); psd->szText = (LPSTR)HeapAlloc(hDllHeap, 0, psd->cch + 1); lstrcpynA(psd->szText, lParam->ipch->MirandaName, sizeof(lParam->ipch->MirandaName) - 1); // there may not be a profile name pg = lParam->ipch->DataPtr; psd->szProfile = NULL; if (pg != NULL && pg->Status == STATUS_PROFILENAME) { psd->szProfile = (LPSTR)HeapAlloc(hDllHeap, 0, pg->cbStrSection); lstrcpyA(psd->szProfile, LPSTR(UINT_PTR(pg) + sizeof(TSlotIPC))); } // owner draw menus need ID's mii.wID = lParam->idCmdFirst; lParam->idCmdFirst++; psd->fTypes = dtEntry; psd->wID = mii.wID; psd->hContact = 0; // get Miranda's icon or bitmap UINT c = lParam->Self->ProtoIconsCount; TSlotProtoIcons *pp = lParam->Self->ProtoIcons; while (c > 0) { c--; if (pp[c].pid == lParam->pid && pp[c].hProto == 0) { // either of these can be 0 psd->hStatusIcon = pp[c].hIcons[0]; mii.hbmpItem = pp[c].hBitmaps[0]; break; } } mii.dwItemData = (UINT_PTR)psd; if (lParam->bOwnerDrawSupported && lParam->bShouldOwnerDraw) { mii.fType = MFT_OWNERDRAW; mii.dwTypeData = (LPSTR)psd; } else { mii.fType = MFT_STRING; mii.dwTypeData = lParam->ipch->MirandaName; mii.cch = sizeof(lParam->ipch->MirandaName) - 1; } // add it all InsertMenuItemA(hBaseMenu, 0, true, &mii); // free the group tree FreeGroupTreeAndEmptyGroups(hGroupMenu, NULL, j.First); }
// this function is called from an APC into the main thread void __stdcall ipcService(ULONG_PTR dwParam) { HANDLE hSignal; TSlotIPC *pct; LPSTR szBuf; char szGroupStr[32]; DBVARIANT dbv; LPSTR szMiranda; // try to open the file mapping object the caller must make sure no other // running instance is using this file HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, IPC_PACKET_NAME); if (hMap == 0) return; // map the file to this process THeaderIPC *pMMT = (THeaderIPC*)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); // if it fails the caller should of had some timeout in wait if (pMMT != NULL && pMMT->cbSize == sizeof(THeaderIPC) && pMMT->dwVersion == PLUGIN_MAKE_VERSION(2, 0, 1, 2)) { // toggle the right bits int *bits = &pMMT->fRequests; // jump right to a worker thread for file processing? if (*bits & REQUEST_XFRFILES) { THeaderIPC *cloned = (THeaderIPC*)mir_alloc(IPC_PACKET_SIZE); // translate from client space to cloned heap memory pMMT->pServerBaseAddress = pMMT->pClientBaseAddress; pMMT->pClientBaseAddress = cloned; CopyMemory(cloned, pMMT, IPC_PACKET_SIZE); ipcFixupAddresses(true, cloned); DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &cloned->Param, THREAD_SET_CONTEXT, false, 0); mir_forkthread(&IssueTransferThread, cloned); goto Reply; } // the request was to clear the MRU entries, we have no return data if (*bits & REQUEST_CLEARMRU) { mir_forkthread(&ClearMRUThread, NULL); goto Reply; } // the IPC header may have pointers that need to be translated // in either case the supplied data area pointers has to be // translated to this address space. // the server base address is always removed to get an offset // to which the client base is added, this is what ipcFixupAddresses() does pMMT->pServerBaseAddress = pMMT->pClientBaseAddress; pMMT->pClientBaseAddress = pMMT; // translate to the server space map ipcFixupAddresses(true, pMMT); // store the address map offset so the caller can retranslate pMMT->pServerBaseAddress = pMMT; // return some options to the client if (db_get_b(0, SHLExt_Name, SHLExt_ShowNoIcons, 0) != 0) pMMT->dwFlags = HIPC_NOICONS; // see if we have a custom string for 'Miranda' szMiranda = "Miranda"; lstrcpynA(pMMT->MirandaName, szMiranda, sizeof(pMMT->MirandaName) - 1); // for the MRU menu szBuf = Translate("Recently"); lstrcpynA(pMMT->MRUMenuName, szBuf, sizeof(pMMT->MRUMenuName) - 1); // and a custom string for "clear entries" szBuf = Translate("Clear entries"); lstrcpynA(pMMT->ClearEntries, szBuf, sizeof(pMMT->ClearEntries) - 1); // if the group mode is on, check if they want the CList setting bool bGroupMode = (BST_CHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseGroups, BST_UNCHECKED)); if (bGroupMode && BST_CHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseCListSetting, BST_UNCHECKED)) bGroupMode = db_get_b(0, "CList", "UseGroups", true) != 0; int iSlot = 0; // return profile if set if (BST_UNCHECKED == db_get_b(0, SHLExt_Name, SHLExt_ShowNoProfile, BST_UNCHECKED)) { pct = ipcAlloc(pMMT, 50); if (pct != NULL) { // will actually return with .dat if there's space for it, not what the docs say pct->Status = STATUS_PROFILENAME; CallService(MS_DB_GETPROFILENAME, 49, UINT_PTR(pct) + sizeof(TSlotIPC)); } } if (*bits & REQUEST_NEWICONS) ipcGetSkinIcons(pMMT); if (*bits & REQUEST_GROUPS) { // return contact's grouping if it's present while (bGroupMode) { _itoa(iSlot, szGroupStr, 10); if ( db_get_s(0, "CListGroups", szGroupStr, &dbv) != 0) break; pct = ipcAlloc(pMMT, lstrlenA(dbv.pszVal + 1) + 1); // first byte has flags, need null term if (pct != NULL) { if (pMMT->GroupsBegin == NULL) pMMT->GroupsBegin = pct; pct->fType = REQUEST_GROUPS; pct->hContact = 0; szBuf = LPSTR(pct) + sizeof(TSlotIPC); // get the end of the slot lstrcpyA(szBuf, dbv.pszVal + 1); pct->hGroup = 0; db_free(&dbv); // free the string } else { // outta space db_free(&dbv); break; } iSlot++; } // if there was no space left, it'll } on null if (pct == NULL) *bits = (*bits | GROUPS_NOTIMPL) & ~REQUEST_GROUPS; } // SHOULD check slot space. if (*bits & REQUEST_CONTACTS) { if (!ipcGetSortedContacts(pMMT, &iSlot, bGroupMode)) // fail if there were no contacts AT ALL *bits = (*bits | CONTACTS_NOTIMPL) & ~REQUEST_CONTACTS; } // store the number of slots allocated pMMT->Slots = iSlot; Reply: // get the handle the caller wants to be signalled on hSignal = OpenEventA(EVENT_ALL_ACCESS, false, pMMT->SignalEventName); if (hSignal != 0) { SetEvent(hSignal); CloseHandle(hSignal); } UnmapViewOfFile(pMMT); } CloseHandle(hMap); }
HRESULT TShellExt::InvokeCommand(CMINVOKECOMMANDINFO *pici) { return RequestTransfer(this, LOWORD(UINT_PTR(pici->lpVerb))); }
bool Columns::GetPopupMenu(CMenu& menu, std::vector<uint16>& selected_columns) const { Set groups[]= { COMMON, CANON, NIKON, FUJI, OLYMPUS, METADATA, CUSTOM }; static const TCHAR* group_names[]= { 0, _T("Canon"), _T("Nikon"), _T("Fuji"), _T("Olympus"), _T("File Info"), _T("Custom Columns") }; UniqueLetter ShortCutsMain; UniqueLetter ShortCutsPopup; UniqueLetter* short_cuts= &ShortCutsMain; int index= 0; int item= 0; for (int n= 0; n < sizeof(groups) / sizeof groups[0]; ++n) { CMenu popup; CMenu* insert= &menu; if (n > 0) { if (!popup.CreatePopupMenu()) return false; String name= group_names[n]; ShortCutsMain.SelectUniqueLetter(name); menu.AppendMenu(MF_POPUP | MF_STRING, UINT_PTR(popup.m_hMenu), name.c_str()); insert = &popup; index = 0; short_cuts = &ShortCutsPopup; ShortCutsPopup.Reset(); } int first_item= GetStart(groups[n]); int item= first_item; for (int i= 0; i < GetCount(groups[n]); ++i, ++index, ++item) { String item_name= Name(item, true); //item_name.Replace(_T("&"), _T("&&")); short_cuts->SelectUniqueLetter(item_name); insert->InsertMenu(index, MF_BYPOSITION | MF_STRING, item + 1, item_name.c_str()); } const size_t cols= selected_columns.size(); for (size_t col= 0; col < cols; ++col) { int selected= selected_columns[col]; if (selected >= first_item && selected < item) { insert->CheckMenuItem(selected + 1, MF_BYCOMMAND | MF_CHECKED); } } if (insert == &popup) popup.Detach(); if (n == 0) insert->AppendMenu(MF_BYPOSITION | MF_SEPARATOR); } return true; }
FARPROC WINAPI __delayLoadHelper2( PCImgDelayDescr pidd, FARPROC * ppfnIATEntry ) { // Set up some data we use for the hook procs but also useful for // our own use // InternalImgDelayDescr idd = { pidd->grAttrs, PFromRva<LPCSTR>(pidd->rvaDLLName), PFromRva<HMODULE*>(pidd->rvaHmod), PFromRva<PImgThunkData>(pidd->rvaIAT), PFromRva<PCImgThunkData>(pidd->rvaINT), PFromRva<PCImgThunkData>(pidd->rvaBoundIAT), PFromRva<PCImgThunkData>(pidd->rvaUnloadIAT), pidd->dwTimeStamp }; DelayLoadInfo dli = { sizeof DelayLoadInfo, pidd, ppfnIATEntry, idd.szName, { 0 }, 0, 0, 0 }; if (0 == (idd.grAttrs & dlattrRva)) { PDelayLoadInfo rgpdli[1] = { &dli }; RaiseException( VcppException(ERROR_SEVERITY_ERROR, ERROR_INVALID_PARAMETER), 0, 1, PULONG_PTR(rgpdli) ); return 0; } HMODULE hmod = *idd.phmod; // Calculate the index for the IAT entry in the import address table // N.B. The INT entries are ordered the same as the IAT entries so // the calculation can be done on the IAT side. // const unsigned iIAT = IndexFromPImgThunkData(PCImgThunkData(ppfnIATEntry), idd.pIAT); const unsigned iINT = iIAT; PCImgThunkData pitd = &(idd.pINT[iINT]); dli.dlp.fImportByName = !IMAGE_SNAP_BY_ORDINAL(pitd->u1.Ordinal); if (dli.dlp.fImportByName) { dli.dlp.szProcName = LPCSTR(PFromRva<PIMAGE_IMPORT_BY_NAME>(RVA(UINT_PTR(pitd->u1.AddressOfData)))->Name); } else { dli.dlp.dwOrdinal = DWORD(IMAGE_ORDINAL(pitd->u1.Ordinal)); } // Call the initial hook. If it exists and returns a function pointer, // abort the rest of the processing and just return it for the call. // FARPROC pfnRet = NULL; if (__pfnDliNotifyHook2) { pfnRet = ((*__pfnDliNotifyHook2)(dliStartProcessing, &dli)); if (pfnRet != NULL) { goto HookBypass; } } // Check to see if we need to try to load the library. // if (hmod == 0) { if (__pfnDliNotifyHook2) { hmod = HMODULE(((*__pfnDliNotifyHook2)(dliNotePreLoadLibrary, &dli))); } if (hmod == 0) { hmod = ::LoadLibraryEx(dli.szDll, NULL, 0); } if (hmod == 0) { dli.dwLastError = ::GetLastError(); if (__pfnDliFailureHook2) { // when the hook is called on LoadLibrary failure, it will // return 0 for failure and an hmod for the lib if it fixed // the problem. // hmod = HMODULE((*__pfnDliFailureHook2)(dliFailLoadLib, &dli)); } if (hmod == 0) { PDelayLoadInfo rgpdli[1] = { &dli }; RaiseException( VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND), 0, 1, PULONG_PTR(rgpdli) ); // If we get to here, we blindly assume that the handler of the exception // has magically fixed everything up and left the function pointer in // dli.pfnCur. // return dli.pfnCur; } } // Store the library handle. If it is already there, we infer // that another thread got there first, and we need to do a // FreeLibrary() to reduce the refcount // HMODULE hmodT = HMODULE(InterlockedExchangePointer((PVOID *) idd.phmod, PVOID(hmod))); if (hmodT == hmod) { ::FreeLibrary(hmod); } } // Go for the procedure now. // dli.hmodCur = hmod; if (__pfnDliNotifyHook2) { pfnRet = (*__pfnDliNotifyHook2)(dliNotePreGetProcAddress, &dli); } if (pfnRet == 0) { if (pidd->rvaBoundIAT && pidd->dwTimeStamp) { // bound imports exist...check the timestamp from the target image // PIMAGE_NT_HEADERS pinh(PinhFromImageBase(hmod)); if (pinh->Signature == IMAGE_NT_SIGNATURE && TimeStampOfImage(pinh) == idd.dwTimeStamp && FLoadedAtPreferredAddress(pinh, hmod)) { // Everything is good to go, if we have a decent address // in the bound IAT! // pfnRet = FARPROC(UINT_PTR(idd.pBoundIAT[iIAT].u1.Function)); if (pfnRet != 0) { goto SetEntryHookBypass; } } } pfnRet = ::GetProcAddress(hmod, dli.dlp.szProcName); } if (pfnRet == 0) { dli.dwLastError = ::GetLastError(); if (__pfnDliFailureHook2) { // when the hook is called on GetProcAddress failure, it will // return 0 on failure and a valid proc address on success // pfnRet = (*__pfnDliFailureHook2)(dliFailGetProc, &dli); } if (pfnRet == 0) { PDelayLoadInfo rgpdli[1] = { &dli }; RaiseException( VcppException(ERROR_SEVERITY_ERROR, ERROR_PROC_NOT_FOUND), 0, 1, PULONG_PTR(rgpdli) ); // If we get to here, we blindly assume that the handler of the exception // has magically fixed everything up and left the function pointer in // dli.pfnCur. // pfnRet = dli.pfnCur; } } SetEntryHookBypass: *ppfnIATEntry = pfnRet; HookBypass: if (__pfnDliNotifyHook2) { dli.dwLastError = 0; dli.hmodCur = hmod; dli.pfnCur = pfnRet; (*__pfnDliNotifyHook2)(dliNoteEndProcessing, &dli); } return pfnRet; }
static inline bool WINAPI FLoadedAtPreferredAddress(PIMAGE_NT_HEADERS pinh, HMODULE hmod) { return UINT_PTR(hmod) == pinh->OptionalHeader.ImageBase; }
// 右クリック LRESULT CDownloadedListView::OnListRClick(LPNMHDR pnmh) { LPNMITEMACTIVATE lp = (LPNMITEMACTIVATE)pnmh; if (lp->iItem != -1) { int nCount = GetItemCount(); for (int i = 0; i < nCount; ++i) { SetItemState(i, 0, LVIS_SELECTED); } SetItemState(lp->iItem, LVIS_SELECTED, LVIS_SELECTED); DLItem* pItem = ((DLItem*)GetItemData(lp->iItem)); const CString& path = pItem->strFilePath; const CString& strReferer = pItem->strReferer; CPoint pt; ::GetCursorPos(&pt); CMenu menu; menu.CreatePopupMenu(); enum { ID_OPEN_ITEMSAVEFOLDER = 1, ID_OPEN_REFERER_ = 2, ID_LAST }; menu.InsertMenu( 0, MF_BYPOSITION | MF_ENABLED, ID_OPEN_ITEMSAVEFOLDER, _T("保存先フォルダを開く") ); menu.InsertMenu( 1, MF_BYPOSITION | MF_ENABLED, ID_OPEN_REFERER_ , _T("ダウンロードしたページを表示する") ); auto funcExeCommand = [=](int commandID) -> bool { if (commandID == ID_OPEN_ITEMSAVEFOLDER) { OpenFolderAndSelectItem(path); } else if(commandID == ID_OPEN_REFERER_) { if (strReferer.IsEmpty()) return true; DonutOpenFile(g_pMainWnd->m_hWnd, strReferer, D_OPENFILE_ACTIVATE); } else { return false; } return true; }; if (pItem->bAbort || ::PathFileExists(path) == FALSE) { int nCmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, m_hWnd); funcExeCommand(nCmd); return 0; } LPITEMIDLIST pidl = ILCreateFromPath(path); if (pidl) { CComPtr<IShellItem> spShellItem; ::SHCreateShellItem(NULL, NULL, pidl, &spShellItem); if (spShellItem) { CComPtr<IContextMenu> spContextMenu; spShellItem->BindToHandler(NULL, BHID_SFUIObject, IID_IContextMenu, (void**)&spContextMenu); if (spContextMenu) { menu.AppendMenu(MF_BYPOSITION | MF_SEPARATOR, UINT_PTR(0), _T("\0")); HRESULT hr = spContextMenu->QueryContextMenu(menu, menu.GetMenuItemCount(), ID_LAST, 0xFFFF, CMF_NORMAL); if (SUCCEEDED(hr)) { int nCmd = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, m_hWnd); if (nCmd) { if (funcExeCommand(nCmd) == false) { CMINVOKECOMMANDINFO InvokeInfo= { sizeof (CMINVOKECOMMANDINFO) }; InvokeInfo.hwnd = m_hWnd; InvokeInfo.lpVerb = (LPCSTR) MAKEINTRESOURCE(nCmd - ID_LAST); InvokeInfo.nShow = SW_SHOWNORMAL; hr = spContextMenu->InvokeCommand(&InvokeInfo); } } } } } } } return 0; }
void CreateDiscussionGrpDialog::_AddToGroupMemberList(std::string sid) { if (sid.empty()) { return; } //确认没有重复的项 for (int n = 0; n < m_pListGroupMembers->GetCount();n++) { CControlUI* pItem = m_pListGroupMembers->GetItemAt(n); if (pItem) { CString strId = pItem->GetUserData(); if (!strId.IsEmpty()) { std::string sId = util::cStringToString(strId); if (sId == sid) { return; } } } } //插入ITEM module::UserInfoEntity userInfo; if (!module::getUserListModule()->getUserInfoBySId(sid, userInfo)) { LOG__(DEBG, _T("can't find the userInfo:%s"), util::stringToCString(sid)); return; } CDialogBuilder dlgBuilder; CListContainerElementUI* pListElement = (CListContainerElementUI*)dlgBuilder.Create(_T("CreateDiscussionGrpDialog\\ListGroupMembersItem.xml"), (UINT)0, NULL, &m_PaintManager); if (!pListElement) { LOG__(ERR, _T("群item创建失败")); return; } CControlUI* pLogo = static_cast<CControlUI*>(pListElement->FindSubControl(_T("AvatarInfo"))); if (!pLogo) { return; } pLogo->SetBkImage(util::stringToCString(userInfo.getAvatarPath())); CLabelUI* pNameLable = static_cast<CLabelUI*>(pListElement->FindSubControl(_T("nickname"))); if (!pNameLable) { return; } pNameLable->SetText(userInfo.getRealName()); CButtonUI* pRemoveBtn = static_cast<CButtonUI*>(pListElement->FindSubControl(_T("removebtn"))); if (pRemoveBtn) { //点击删除按钮的时候根据这个来判断是哪个项 pRemoveBtn->SetTag(UINT_PTR(pListElement)); } if (module::getSysConfigModule()->userID() == userInfo.sId)//自己不能删除 { pRemoveBtn->SetVisible(false); } pListElement->SetUserData(util::stringToCString(userInfo.sId)); m_pListGroupMembers->Add(pListElement); }
bool QAudioOutputPrivate::open() { #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()"; #endif period_size = 0; if (!settings.isValid()) { qWarning("QAudioOutput: open error, invalid format."); } else if (settings.channelCount() <= 0) { qWarning("QAudioOutput: open error, invalid number of channels (%d).", settings.channelCount()); } else if (settings.sampleSize() <= 0) { qWarning("QAudioOutput: open error, invalid sample size (%d).", settings.sampleSize()); } else if (settings.frequency() < 8000 || settings.frequency() > 96000) { qWarning("QAudioOutput: open error, frequency out of range (%d).", settings.frequency()); } else if (buffer_size == 0) { // Default buffer size, 200ms, default period size is 40ms buffer_size = (settings.frequency() * settings.channelCount() * settings.sampleSize() + 39) / 40; period_size = buffer_size / 5; } else { period_size = buffer_size / 5; } if (period_size == 0) { errorState = QAudio::OpenError; deviceState = QAudio::StoppedState; emit stateChanged(deviceState); return false; } waveBlocks = allocateBlocks(period_size, buffer_size/period_size); mutex.lock(); waveFreeBlockCount = buffer_size/period_size; mutex.unlock(); waveCurrentBlock = 0; if(audioBuffer == 0) audioBuffer = new char[buffer_size]; timeStamp.restart(); elapsedTimeOffset = 0; wfx.nSamplesPerSec = settings.frequency(); wfx.wBitsPerSample = settings.sampleSize(); wfx.nChannels = settings.channels(); wfx.cbSize = 0; bool surround = false; if (settings.channels() > 2) surround = true; wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; QDataStream ds(&m_device, QIODevice::ReadOnly); quint32 deviceId; ds >> deviceId; if (!surround) { if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfx, (DWORD_PTR)&waveOutProc, (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioOutput: open error"); return false; } } else { WAVEFORMATEXTENSIBLE wfex; wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfex.Format.nChannels = settings.channels(); wfex.Format.wBitsPerSample = settings.sampleSize(); wfex.Format.nSamplesPerSec = settings.frequency(); wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8; wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign; wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample; static const GUID _KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; wfex.SubFormat=_KSDATAFORMAT_SUBTYPE_PCM; wfex.Format.cbSize=22; wfex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; if (settings.channels() >= 4) wfex.dwChannelMask |= SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; if (settings.channels() >= 6) wfex.dwChannelMask |= SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; if (settings.channels() == 8) wfex.dwChannelMask |= SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfex.Format, (DWORD_PTR)&waveOutProc, (DWORD_PTR) this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { errorState = QAudio::OpenError; deviceState = QAudio::StoppedState; emit stateChanged(deviceState); qWarning("QAudioOutput: open error"); return false; } } totalTimeValue = 0; timeStampOpened.restart(); elapsedTimeOffset = 0; errorState = QAudio::NoError; if(pullMode) { deviceState = QAudio::ActiveState; QTimer::singleShot(10, this, SLOT(feedback())); } else deviceState = QAudio::IdleState; return true; }