void ItemIDList::Copy(LPCITEMIDLIST pidl) { std::size_t n = ILGetSize(pidl); pidl_ = static_cast<LPITEMIDLIST>(::CoTaskMemAlloc(n)); assert(pidl_); std::memcpy(pidl_, pidl, n); }
std::size_t ItemIDList::GetSize() const { std::size_t n = 0; if (pidl_) n = ILGetSize(pidl_); return n; }
HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) { UINT i; int offset = 0, sizePidl, size; HGLOBAL hGlobal; LPIDA pcida; TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); /* get the size needed */ size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */ size += ILGetSize (pidlRoot); /* root pidl */ for(i=0; i<cidl; i++) { size += ILGetSize(apidl[i]); /* child pidls */ } /* fill the structure */ hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); if(!hGlobal) return hGlobal; pcida = GlobalLock (hGlobal); pcida->cidl = cidl; /* root pidl */ offset = sizeof(CIDA) + sizeof (UINT)*(cidl); pcida->aoffset[0] = offset; /* first element */ sizePidl = ILGetSize (pidlRoot); memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl); offset += sizePidl; for(i=0; i<cidl; i++) /* child pidls */ { pcida->aoffset[i+1] = offset; sizePidl = ILGetSize(apidl[i]); memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl); offset += sizePidl; } GlobalUnlock(hGlobal); return hGlobal; }
static ULONG copy_pidls(struct menu_item* item, LPITEMIDLIST dest) { ULONG item_size; ULONG bytes_copied = 2; if (item->parent->pidl) { bytes_copied = copy_pidls(item->parent, dest); } item_size = ILGetSize(item->pidl); if (dest) memcpy(((char*)dest) + bytes_copied - 2, item->pidl, item_size); return bytes_copied + item_size - 2; }
HRESULT STDMETHODCALLTYPE CBandProxy::NavigateToPIDL(LPCITEMIDLIST pidl) { CComPtr<IOleWindow> oleWindow; CComPtr<IServiceProvider> serviceProvider; CComPtr<IUnknown> webBrowserUnknown; CComPtr<IWebBrowser2> webBrowser; HWND browserWindow; CComVariant args; CComVariant emptyVariant; unsigned int arraySize; HRESULT hResult; hResult = FindBrowserWindow(&webBrowserUnknown); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; hResult = webBrowserUnknown->QueryInterface(IID_PPV_ARG(IWebBrowser2, &webBrowser)); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; hResult = webBrowser->put_Visible(TRUE); hResult = webBrowser->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider)); if (SUCCEEDED(hResult)) { hResult = serviceProvider->QueryService(SID_STopLevelBrowser, IID_PPV_ARG(IOleWindow, &oleWindow)); if (SUCCEEDED(hResult)) { hResult = oleWindow->GetWindow(&browserWindow); if (IsIconic(browserWindow)) ShowWindow(browserWindow, SW_RESTORE); } } arraySize = ILGetSize(pidl); V_VT(&args) = VT_ARRAY | VT_UI1; V_ARRAY(&args) = SafeArrayCreateVector(VT_UI1, 0, arraySize); if (V_ARRAY(&args) == NULL) return E_OUTOFMEMORY; memcpy(V_ARRAY(&args)->pvData, pidl, arraySize); hResult = webBrowser->Navigate2(&args, &emptyVariant, &emptyVariant, &emptyVariant, &emptyVariant); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; return S_OK; }
HANDLE MakeSharedPacket(IEThreadParamBlock * threadParams, LPCWSTR strPath, int dwProcessId) { HNFBlock* hnfData; UINT sharedBlockSize = sizeof(*hnfData); UINT directoryPidlLength = 0; UINT pidlSize7C = 0; UINT pidlSize80 = 0; UINT pathLength = 0; LPITEMIDLIST pidl80 = threadParams->offset80; // Count the total length of the message packet // directory PIDL if (threadParams->directoryPIDL) { directoryPidlLength = ILGetSize(threadParams->directoryPIDL); sharedBlockSize += directoryPidlLength; DbgPrint("directoryPidlLength=%d\n", directoryPidlLength); } // another PIDL if (threadParams->offset7C) { pidlSize7C = ILGetSize(threadParams->offset7C); sharedBlockSize += pidlSize7C; DbgPrint("pidlSize7C=%d\n", pidlSize7C); } // This flag indicates the presence of another pidl? if (!(threadParams->offset84 & 0x8000)) { if (pidl80) { pidlSize80 = ILGetSize(pidl80); sharedBlockSize += pidlSize80; DbgPrint("pidlSize80=%d\n", pidlSize7C); } } else { DbgPrint("pidl80 sent by value = %p\n", pidl80); pidlSize80 = 4; sharedBlockSize += pidlSize80; } // The path string if (strPath) { pathLength = 2 * lstrlenW(strPath) + 2; sharedBlockSize += pathLength; DbgPrint("pathLength=%d\n", pidlSize7C); } DbgPrint("sharedBlockSize=%d\n", sharedBlockSize); // Allocate and fill the shared section HANDLE hShared = SHAllocShared(0, sharedBlockSize, dwProcessId); if (!hShared) { DbgPrint("Shared section alloc error.\n"); return 0; } PBYTE target = (PBYTE) SHLockShared(hShared, dwProcessId); if (!target) { DbgPrint("Shared section lock error. %d\n", GetLastError()); SHFreeShared(hShared, dwProcessId); return 0; } // Basic information hnfData = (HNFBlock*) target; hnfData->cbSize = sharedBlockSize; hnfData->offset4 = (DWORD) (threadParams->dwFlags); hnfData->offset8 = (DWORD) (threadParams->offset8); hnfData->offsetC = (DWORD) (threadParams->offset74); hnfData->offset10 = (DWORD) (threadParams->offsetD8); hnfData->offset14 = (DWORD) (threadParams->offset84); hnfData->offset18 = (DWORD) (threadParams->offset88); hnfData->offset1C = (DWORD) (threadParams->offset8C); hnfData->offset20 = (DWORD) (threadParams->offset90); hnfData->offset24 = (DWORD) (threadParams->offset94); hnfData->offset28 = (DWORD) (threadParams->offset98); hnfData->offset2C = (DWORD) (threadParams->offset9C); hnfData->offset30 = (DWORD) (threadParams->offsetA0); hnfData->directoryPidlLength = 0; hnfData->pidlSize7C = 0; hnfData->pidlSize80 = 0; hnfData->pathLength = 0; target += sizeof(*hnfData); // Copy the directory pidl contents if (threadParams->directoryPIDL) { memcpy(target, threadParams->directoryPIDL, directoryPidlLength); target += directoryPidlLength; hnfData->directoryPidlLength = directoryPidlLength; } // Copy the other pidl contents if (threadParams->offset7C) { memcpy(target, threadParams->offset7C, pidlSize7C); target += pidlSize7C; hnfData->pidlSize7C = pidlSize7C; } // copy the third pidl if (threadParams->offset84 & 0x8000) { *(LPITEMIDLIST*) target = pidl80; target += pidlSize80; hnfData->pidlSize80 = pidlSize80; } else if (pidl80) { memcpy(target, pidl80, pidlSize80); target += pidlSize80; hnfData->pidlSize80 = pidlSize80; } // and finally the path string if (strPath) { memcpy(target, strPath, pathLength); hnfData->pathLength = pathLength; } SHUnlockShared(hnfData); return hShared; }
Path::size_type Path::size () const { return (ILGetSize(myBackend)); }