already_AddRefed<IDBFileRequest> IDBFileHandle::GetMetadata(const IDBFileMetadataParameters& aParameters, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); // Common state checking if (!CheckState(aRv)) { return nullptr; } // Do nothing if the window is closed if (!CheckWindow()) { return nullptr; } nsRefPtr<MetadataParameters> params = new MetadataParameters(aParameters.mSize, aParameters.mLastModified); if (!params->IsConfigured()) { aRv.ThrowTypeError(MSG_METADATA_NOT_CONFIGURED); return nullptr; } nsRefPtr<FileRequestBase> fileRequest = GenerateFileRequest(); nsRefPtr<MetadataHelper> helper = new MetadataHelper(this, fileRequest, params); if (NS_WARN_IF(NS_FAILED(helper->Enqueue()))) { aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); return nullptr; } return fileRequest.forget().downcast<IDBFileRequest>(); }
/***************************** * * Routine to add an item to the dialog box * The pointer to the item is copied to the dlg struct, * the item itself may not be freed until the dlg is done with * ****************************/ void DoCreateDlg(t_dlg *dlg) { XSizeHints hints; XSetWindowAttributes attr; unsigned long Val; attr.border_pixel=dlg->x11->fg; attr.background_pixel=dlg->bg; attr.override_redirect=False; attr.save_under=True; attr.cursor=XCreateFontCursor(dlg->x11->disp,XC_hand2); Val=CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWSaveUnder | CWCursor; dlg->win.self=XCreateWindow(dlg->x11->disp,dlg->wDad, dlg->win.x,dlg->win.y, dlg->win.width,dlg->win.height, dlg->win.bwidth,CopyFromParent, InputOutput,CopyFromParent, Val,&attr); dlg->x11->RegisterCallback(dlg->x11,dlg->win.self,dlg->wDad, DlgCB,dlg); dlg->x11->SetInputMask(dlg->x11,dlg->win.self, ExposureMask | ButtonPressMask | KeyPressMask); if (!CheckWindow(dlg->win.self)) exit(1); hints.x=dlg->win.x; hints.y=dlg->win.y; hints.flags=PPosition; XSetStandardProperties(dlg->x11->disp,dlg->win.self,dlg->title, dlg->title,None,NULL,0,&hints); }
nsresult FileHandleBase::OpenInputStream(bool aWholeFile, uint64_t aStart, uint64_t aLength, nsIInputStream** aResult) { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); MOZ_ASSERT(mRequestMode == PARALLEL, "Don't call me in other than parallel mode!"); // Common state checking ErrorResult error; if (!CheckState(error)) { return error.StealNSResult(); } // Do nothing if the window is closed if (!CheckWindow()) { return NS_OK; } nsRefPtr<OpenStreamHelper> helper = new OpenStreamHelper(this, aWholeFile, aStart, aLength); nsresult rv = helper->Enqueue(); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); nsCOMPtr<nsIInputStream>& result = helper->Result(); NS_ENSURE_TRUE(result, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); result.forget(aResult); return NS_OK; }
static PyObject * WindowGetattro(PyObject *self, PyObject *nameobj) { WindowObject *this = (WindowObject *)(self); char *name = ""; if (PyUnicode_Check(nameobj)) name = _PyUnicode_AsString(nameobj); if (CheckWindow(this)) return NULL; if (strcmp(name, "buffer") == 0) return (PyObject *)BufferNew(this->win->w_buffer); else if (strcmp(name, "cursor") == 0) { pos_T *pos = &this->win->w_cursor; return Py_BuildValue("(ll)", (long)(pos->lnum), (long)(pos->col)); } else if (strcmp(name, "height") == 0) return Py_BuildValue("l", (long)(this->win->w_height)); #ifdef FEAT_VERTSPLIT else if (strcmp(name, "width") == 0) return Py_BuildValue("l", (long)(W_WIDTH(this->win))); #endif else if (strcmp(name,"__members__") == 0) return Py_BuildValue("[sss]", "buffer", "cursor", "height"); else return PyObject_GenericGetAttr(self, nameobj); }
already_AddRefed<FileRequestBase> FileHandleBase::WriteInternal(nsIInputStream* aInputStream, uint64_t aInputLength, bool aAppend, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); DebugOnly<ErrorResult> error; MOZ_ASSERT(CheckStateForWrite(error)); MOZ_ASSERT_IF(!aAppend, mLocation != UINT64_MAX); MOZ_ASSERT(aInputStream); MOZ_ASSERT(aInputLength); MOZ_ASSERT(CheckWindow()); nsRefPtr<FileRequestBase> fileRequest = GenerateFileRequest(); uint64_t location = aAppend ? UINT64_MAX : mLocation; nsRefPtr<WriteHelper> helper = new WriteHelper(this, fileRequest, location, aInputStream, aInputLength); if (NS_WARN_IF(NS_FAILED(helper->Enqueue()))) { aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); return nullptr; } if (aAppend) { mLocation = UINT64_MAX; } else { mLocation += aInputLength; } return fileRequest.forget(); }
already_AddRefed<FileRequestBase> FileHandleBase::Flush(ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); // State checking for write if (!CheckStateForWrite(aRv)) { return nullptr; } // Do nothing if the window is closed if (!CheckWindow()) { return nullptr; } nsRefPtr<FileRequestBase> fileRequest = GenerateFileRequest(); nsRefPtr<FlushHelper> helper = new FlushHelper(this, fileRequest); if (NS_WARN_IF(NS_FAILED(helper->Enqueue()))) { aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); return nullptr; } return fileRequest.forget(); }
already_AddRefed<FileRequestBase> FileHandleBase::Read(uint64_t aSize, bool aHasEncoding, const nsAString& aEncoding, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); // State and argument checking for read if (!CheckStateAndArgumentsForRead(aSize, aRv)) { return nullptr; } // Do nothing if the window is closed if (!CheckWindow()) { return nullptr; } nsRefPtr<FileRequestBase> fileRequest = GenerateFileRequest(); nsRefPtr<ReadHelper> helper; if (aHasEncoding) { helper = new ReadTextHelper(this, fileRequest, mLocation, aSize, aEncoding); } else { helper = new ReadHelper(this, fileRequest, mLocation, aSize); } if (NS_WARN_IF(NS_FAILED(helper->Init())) || NS_WARN_IF(NS_FAILED(helper->Enqueue()))) { aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); return nullptr; } mLocation += aSize; return fileRequest.forget(); }
static PyObject * WindowGetattr(PyObject *self, char *name) { WindowObject *this = (WindowObject *)(self); if (CheckWindow(this)) return NULL; if (strcmp(name, "buffer") == 0) return (PyObject *)BufferNew(this->win->w_buffer); else if (strcmp(name, "cursor") == 0) { pos_T *pos = &this->win->w_cursor; return Py_BuildValue("(ll)", (long)(pos->lnum), (long)(pos->col)); } else if (strcmp(name, "height") == 0) return Py_BuildValue("l", (long)(this->win->w_height)); #ifdef FEAT_VERTSPLIT else if (strcmp(name, "width") == 0) return Py_BuildValue("l", (long)(W_WIDTH(this->win))); #endif else if (strcmp(name,"__members__") == 0) return Py_BuildValue("[sss]", "buffer", "cursor", "height"); else return Py_FindMethod(WindowMethods, self, name); }
/* ** Called during each update of the main measure. ** */ void PlayerITunes::UpdateData() { if ((m_Initialized || CheckWindow()) && m_State != STATE_STOPPED) { long position = 0; m_iTunes->get_PlayerPosition(&position); m_Position = (UINT)position; } }
bool ventrilo_chat::Send(const std::string&strText) { #ifdef OS_WINDOWS_ if (CheckWindow()) { if (!bMumble) { SendMessage(hwndMessage,WM_SETTEXT,0,(LPARAM)strText.c_str()); SendMessage(hwndSend,BM_CLICK,0,0); } else { // To the start of the box //SetForegroundWindow(hwndMessage); SendMessage(hwndMessage, WM_LBUTTONDOWN, 0, (LPARAM)0); SendMessage(hwndMessage, WM_ACTIVATE, WA_ACTIVE, (LPARAM)hwndMessage); SendMessage(hwndMessage, WM_KEYDOWN, VK_HOME, (LPARAM)0); SendMessage(hwndMessage, WM_KEYUP, VK_HOME, (LPARAM)0); for (unsigned int i=0;i<500;++i) { // Delete everything SendMessage(hwndMessage, WM_KEYDOWN, VK_DELETE, (LPARAM)0); SendMessage(hwndMessage, WM_KEYUP, VK_DELETE, (LPARAM)0); } for (std::string::const_iterator it=strText.begin();it!=strText.end();++it) { SendMessage(hwndMessage, WM_CHAR, *it, (LPARAM)0); } SendMessage(hwndMessage, WM_KEYDOWN, VK_RETURN, (LPARAM)0); SendMessage(hwndMessage, WM_KEYUP, VK_RETURN, (LPARAM)0); } } std::cout << "Sending Text: " << strText << std::endl; #endif std::string::size_type posStart=0; std::string::size_type posEnd; std::string strEscapedText; while(true) { posEnd=strText.find('"',posStart); if (posEnd == std::string::npos) strEscapedText += strText.substr(posStart); else strEscapedText += strText.substr(posStart,posEnd-posStart); if (posEnd == std::string::npos) break; strEscapedText += "\\\""; posStart=posEnd+1; } std::string strOutput=std::string("./scripts/send_voice_message.sh \"") + strEscapedText + "\""; // security issue if this text can have ; and such system(strOutput.c_str()); std::cout << strEscapedText << std::endl; return true; }
static PyObject * WindowGetattr(PyObject *self, char *name) { PyObject *r; if (CheckWindow((WindowObject *)(self))) return NULL; r = WindowAttr((WindowObject *)(self), name); if (r || PyErr_Occurred()) return r; else return Py_FindMethod(WindowMethods, self, name); }
void AddDlgItem(t_dlg *dlg, t_dlgitem *item) { #define EnterLeaveMask (EnterWindowMask | LeaveWindowMask) #define UserMask (ButtonPressMask | KeyPressMask) static unsigned long InputMask[edlgNR] = { ExposureMask | UserMask | EnterLeaveMask, /* edlgBN */ ExposureMask | UserMask | EnterLeaveMask, /* edlgRB */ ExposureMask, /* edlgGB */ ExposureMask | UserMask | EnterLeaveMask, /* edlgCB */ 0, /* edlgPM */ ExposureMask, /* edlgST */ ExposureMask | UserMask | EnterLeaveMask /* edlgET */ }; if (!dlg->win.self) { DoCreateDlg(dlg); } srenew(dlg->dlgitem, dlg->nitem+1); if (!item) { gmx_fatal(FARGS, "dlgitem not allocated"); } item->win.self = XCreateSimpleWindow(dlg->x11->disp, dlg->win.self, item->win.x, item->win.y, item->win.width, item->win.height, item->win.bwidth, dlg->x11->fg, dlg->x11->bg); CheckWindow(item->win.self); dlg->x11->RegisterCallback(dlg->x11, item->win.self, dlg->win.self, DlgCB, dlg); dlg->x11->SetInputMask(dlg->x11, item->win.self, InputMask[item->type]); switch (item->type) { case edlgPM: XSetWindowBackgroundPixmap(dlg->x11->disp, item->win.self, item->u.pixmap.pm); break; default: break; } dlg->dlgitem[dlg->nitem] = item; dlg->nitem++; }
already_AddRefed<FileRequestBase> FileHandleBase::Truncate(const Optional<uint64_t>& aSize, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); // State checking for write if (!CheckStateForWrite(aRv)) { return nullptr; } // Getting location and additional state checking for truncate uint64_t location; if (aSize.WasPassed()) { // Just in case someone calls us from C++ MOZ_ASSERT(aSize.Value() != UINT64_MAX, "Passed wrong size!"); location = aSize.Value(); } else { if (mLocation == UINT64_MAX) { aRv.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR); return nullptr; } location = mLocation; } // Do nothing if the window is closed if (!CheckWindow()) { return nullptr; } nsRefPtr<FileRequestBase> fileRequest = GenerateFileRequest(); nsRefPtr<TruncateHelper> helper = new TruncateHelper(this, fileRequest, location); if (NS_WARN_IF(NS_FAILED(helper->Enqueue()))) { aRv.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); return nullptr; } if (aSize.WasPassed()) { mLocation = aSize.Value(); } return fileRequest.forget(); }
/* ** Called during each update of the main measure. ** */ void PlayerSpotify::UpdateData() { if (m_Initialized || CheckWindow()) { // Parse title and artist from window title WCHAR buffer[256]; if (GetWindowText(m_Window, buffer, 256) > 10) { std::wstring title = &buffer[10]; // Skip "Spotify - " std::wstring::size_type pos = title.find(L" \u2013 "); if (pos != std::wstring::npos) { std::wstring artist(title, 0, pos); pos += 3; // Skip " - " std::wstring track(title, pos); if (track != m_Title || artist != m_Artist) { m_State = STATE_PLAYING; m_Title = track; m_Artist = artist; ++m_TrackCount; if (m_Measures & MEASURE_LYRICS) { FindLyrics(); } } return; } } else if (IsWindow(m_Window)) { m_State = STATE_PAUSED; } else { ClearData(); m_Initialized = false; } } }
static PyObject * WindowGetattro(PyObject *self, PyObject *nameobj) { PyObject *r; GET_ATTR_STRING(name, nameobj); if ((r = WindowAttrValid((WindowObject *)(self), name))) return r; if (CheckWindow((WindowObject *)(self))) return NULL; r = WindowAttr((WindowObject *)(self), name); if (r || PyErr_Occurred()) return r; else return PyObject_GenericGetAttr(self, nameobj); }
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: CheckWindow(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: UnHook(); break; } return TRUE; }
bool ventrilo_chat::GetText() { #ifdef OS_WINDOWS_ if (!bMumble) { if (CheckWindow()) { unsigned int uLength=SendMessage(hwndChat,WM_GETTEXTLENGTH,0,0); ++uLength; if (uLength > vcBuffer.capacity()) vcBuffer.reserve(uLength); vcBuffer.resize(uLength); if (!vcBuffer.empty()) vcBuffer.resize(SendMessage(hwndChat,WM_GETTEXT,(WPARAM)uLength,(LPARAM)&vcBuffer[0])); return true; } } #endif return false; }
/* ** Called during each update of the main measure. ** */ void CPlayerAIMP::UpdateData() { if (!m_Initialized) { if (m_LastTitleSize != 0) { m_LastFileSize = 0; m_LastTitleSize = 0; } if (!CheckWindow()) return; } // If initialized m_State = (StateType)SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_Player); if (m_State == STATE_STOPPED) { // Make sure AIMP is still active if (!IsWindow(m_Window)) { m_Initialized = false; ClearData(); if (m_FileMap) UnmapViewOfFile(m_FileMap); if (m_FileMapHandle) CloseHandle(m_FileMapHandle); } else if (m_State != STATE_STOPPED) { ClearData(false); m_LastFileSize = 0; m_LastTitleSize = 0; } // Don't continue if AIMP has quit or is stopped return; } m_Position = SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_POS); m_Volume = SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_VOLUME); AIMP2FileInfo* info = (AIMP2FileInfo*)m_FileMap; if (info->cbSizeOf > 0 && info->nFileSize != m_LastFileSize || // Avoid reading the same file info->nTitleLen != m_LastTitleSize) { m_LastFileSize = info->nFileSize; m_LastTitleSize = info->nTitleLen; // 44 is sizeof(AIMP2FileInfo) / 2 (due to WCHAR being 16-bit). // Written explicitly due to size differences in 32bit/64bit. LPCTSTR stringData = (LPCTSTR)m_FileMap; stringData += 44; m_Album.assign(stringData, info->nAlbumLen); stringData += info->nAlbumLen; m_Artist.assign(stringData, info->nArtistLen); stringData += info->nArtistLen; stringData += info->nDateLen; std::wstring filepath(stringData, info->nFileNameLen); stringData += info->nFileNameLen; stringData += info->nGenreLen; m_Title.assign(stringData, info->nTitleLen); m_Duration = info->nDuration / 1000; m_Number = (UINT)info->nTrackID; m_Shuffle = (bool)SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_SHUFFLE); m_Repeat = (bool)SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_REPEAT); // Get rating through the AIMP Winamp API m_Rating = SendMessage(m_WinampWindow, WM_WA_IPC, 0, IPC_GETRATING); if (filepath != m_FilePath) { m_FilePath = filepath; ++m_TrackCount; if (m_Measures & MEASURE_COVER) FindCover(); if (m_Measures & MEASURE_LYRICS) FindLyrics(); } } }
/* ** Called during each update of the main measure. ** */ void CPlayerWinamp::UpdateData() { if (m_Initialized || CheckWindow()) { int playing = SendMessage(m_Window, WM_WA_IPC, 0, IPC_ISPLAYING); if (playing == 0) { // Make sure Winamp is still active if (!IsWindow(m_Window)) { m_Initialized = false; ClearData(); if (m_WinampHandle) CloseHandle(m_WinampHandle); } else if (m_State != STATE_STOPPED) { ClearData(false); } // Don't continue if Winamp has quit or is stopped return; } else { m_State = (playing == 1) ? STATE_PLAYING : STATE_PAUSED; m_Position = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETOUTPUTTIME) / 1000; // ms to secs m_Volume = (SendMessage(m_Window, WM_WA_IPC, -666, IPC_SETVOLUME) * 100) / 255; // 0 - 255 to 0 - 100 } WCHAR wBuffer[MAX_PATH]; char cBuffer[MAX_PATH]; if (m_UseUnicodeAPI) { if (!ReadProcessMemory(m_WinampHandle, m_WinampAddress, &wBuffer, sizeof(wBuffer), NULL)) { // Failed to read memory return; } } else { // MediaMonkey doesn't support wide IPC messages int pos = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETLISTPOS); LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, pos, IPC_GETPLAYLISTFILE); if (!ReadProcessMemory(m_WinampHandle, address, &cBuffer, sizeof(cBuffer), NULL)) { // Failed to read memory return; } mbstowcs(wBuffer, cBuffer, MAX_PATH); } if (wcscmp(wBuffer, m_FilePath.c_str()) != 0) { ++m_TrackCount; m_FilePath = wBuffer; m_PlayingStream = (m_FilePath.find(L"://") != std::wstring::npos); if (!m_PlayingStream) { int duration = SendMessage(m_Window, WM_WA_IPC, 1, IPC_GETOUTPUTTIME); m_Duration = (duration != -1) ? duration : 0; m_Rating = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETRATING); m_Shuffle = (bool)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_SHUFFLE); m_Repeat = (bool)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_REPEAT); TagLib::FileRef fr(wBuffer, false); TagLib::Tag* tag = fr.tag(); if (tag) { m_Artist = tag->artist().toWString(); m_Album = tag->album().toWString(); m_Title = tag->title().toWString(); m_Number = tag->track(); m_Year = tag->year(); if (m_Measures & MEASURE_LYRICS) { FindLyrics(); } } else if (m_Measures & MEASURE_LYRICS) { m_Lyrics.clear(); } // Find cover if needed if (m_Measures & MEASURE_COVER) { if (tag && CCover::GetEmbedded(fr, m_TempCoverPath)) { // Got everything, return m_CoverPath = m_TempCoverPath; return; } std::wstring trackFolder = CCover::GetFileFolder(m_FilePath); if (tag && !m_Album.empty()) { // Winamp stores covers usually as %album%.jpg std::wstring file = m_Album; std::wstring::size_type end = file.length(); for (std::wstring::size_type pos = 0; pos < end; ++pos) { // Replace reserved chars according to Winamp specs switch (file[pos]) { case L'?': case L'*': case L'|': file[pos] = L'_'; break; case L'/': case L'\\': case L':': file[pos] = L'-'; break; case L'\"': file[pos] = L'\''; break; case L'<': file[pos] = L'('; break; case L'>': file[pos] = L')'; break; } } if (CCover::GetLocal(file, trackFolder, m_CoverPath)) { // %album% art file found return; } } if (!CCover::GetLocal(L"cover", trackFolder, m_CoverPath) && !CCover::GetLocal(L"folder", trackFolder, m_CoverPath)) { // Nothing found m_CoverPath.clear(); } } if (tag) { return; } } else { m_Rating = 0; m_Duration = 0; m_CoverPath.clear(); } } else if (!m_PlayingStream) { if (m_Duration == 0) { int duration = SendMessage(m_Window, WM_WA_IPC, 1, IPC_GETOUTPUTTIME); m_Duration = (duration != -1) ? duration : 0; } return; } // TagLib couldn't parse the file or Winamp is playing a stream, try to get title if (m_UseUnicodeAPI) { LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE); ReadProcessMemory(m_WinampHandle, address, &wBuffer, sizeof(wBuffer), NULL); } else { int pos = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETLISTPOS); LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, pos, IPC_GETPLAYLISTTITLE); ReadProcessMemory(m_WinampHandle, address, &cBuffer, sizeof(cBuffer), NULL); mbstowcs(wBuffer, cBuffer, MAX_PATH); } std::wstring title = wBuffer; std::wstring::size_type pos = title.find(L" - "); if (pos != std::wstring::npos) { m_Artist.assign(title, 0, pos); pos += 3; // Skip " - " m_Title.assign(title, pos, title.length() - pos); m_Album.clear(); if (m_PlayingStream) { // Remove crap from title if playing radio pos = m_Title.find(L" ("); if (pos != std::wstring::npos) { m_Title.resize(pos); } } } else { m_Title = title; m_Artist.clear(); m_Album.clear(); } } }
Window XRemoteClient::FindBestWindow(const char *aProgram, const char *aUsername, const char *aProfile) { Window root = RootWindowOfScreen(DefaultScreenOfDisplay(mDisplay)); Window bestWindow = 0; Window root2, parent, *kids; unsigned int nkids; // Get a list of the children of the root window, walk the list // looking for the best window that fits the criteria. if (!XQueryTree(mDisplay, root, &root2, &parent, &kids, &nkids)) { PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XQueryTree failed in XRemoteClient::FindBestWindow")); return 0; } if (!(kids && nkids)) { PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("root window has no children")); return 0; } // We'll walk the list of windows looking for a window that best // fits the criteria here. for (unsigned int i = 0; i < nkids; i++) { Atom type; int format; unsigned long nitems, bytesafter; unsigned char *data_return = 0; Window w; w = kids[i]; // find the inner window with WM_STATE on it w = CheckWindow(w); int status = XGetWindowProperty(mDisplay, w, mMozVersionAtom, 0, (65536 / sizeof (long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); if (!data_return) continue; double version = PR_strtod((char*) data_return, nullptr); XFree(data_return); if (!(version >= 5.1 && version < 6)) continue; data_return = 0; if (status != Success || type == None) continue; // If someone passed in a program name, check it against this one // unless it's "any" in which case, we don't care. If someone did // pass in a program name and this window doesn't support that // protocol, we don't include it in our list. if (aProgram && strcmp(aProgram, "any")) { status = XGetWindowProperty(mDisplay, w, mMozProgramAtom, 0, (65536 / sizeof(long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); // If the return name is not the same as what someone passed in, // we don't want this window. if (data_return) { if (strcmp(aProgram, (const char *)data_return)) { XFree(data_return); continue; } // This is actually the success condition. XFree(data_return); } else { // Doesn't support the protocol, even though the user // requested it. So we're not going to use this window. continue; } } // Check to see if it has the user atom on that window. If there // is then we need to make sure that it matches what we have. const char *username; if (aUsername) { username = aUsername; } else { username = PR_GetEnv("LOGNAME"); } if (username) { status = XGetWindowProperty(mDisplay, w, mMozUserAtom, 0, (65536 / sizeof(long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); // if there's a username compare it with what we have if (data_return) { // If the IDs aren't equal, we don't want this window. if (strcmp(username, (const char *)data_return)) { XFree(data_return); continue; } XFree(data_return); } } // Check to see if there's a profile name on this window. If // there is, then we need to make sure it matches what someone // passed in. if (aProfile) { status = XGetWindowProperty(mDisplay, w, mMozProfileAtom, 0, (65536 / sizeof(long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); // If there's a profile compare it with what we have if (data_return) { // If the profiles aren't equal, we don't want this window. if (strcmp(aProfile, (const char *)data_return)) { XFree(data_return); continue; } XFree(data_return); } } // Check to see if the window supports the new command-line passing // protocol, if that is requested. // If we got this far, this is the best window. It passed // all the tests. bestWindow = w; break; } if (kids) XFree((char *) kids); return bestWindow; }
void InjectorProc(void *injectorModule, unsigned int dataSize, const void *data) { util::dcout << "In inject proc." << std::endl; #if 0 util::dcout << "Waiting for debugger ..." << std::endl; if(IsDebuggerPresent() == FALSE) { while(IsDebuggerPresent() == FALSE) { Sleep(100); } DebugBreak(); } util::dcout << "Debugger attached." << std::endl; #endif HWND targetWindow = GetTargetWindow(); if(targetWindow == NULL) { util::dcout << "Cannot find window !" << std::endl; return; } CheckWindow(targetWindow); OpenGLDrawData oglData; oglData.window = targetWindow; if(!InitOpenGLContext(oglData)) { return; } InitOpenGL(oglData); MemoryDC memoryDC(oglData.width, oglData.height); oglData.memoryDC = &memoryDC; Init(oglData); wglMakeCurrent(NULL, NULL); g_oglData = &oglData; //MakeWindowFullyTransparent(targetWindow); WNDPROC originalWndProc = (WNDPROC)GetWindowLongPtr(targetWindow, GWLP_WNDPROC); g_originalWndProc = originalWndProc; SetWindowLongPtr(targetWindow, GWLP_WNDPROC, (LONG_PTR)HookWndProc); InvalidateRect(targetWindow, NULL, TRUE); //DrawLoop(oglData); //DrawFrame(oglData); Sleep(30000); wglMakeCurrent(oglData.oglDC, oglData.oglContext); DeInit(oglData); FreeOpenGLContext(oglData); SetWindowLongPtr(targetWindow, GWLP_WNDPROC, (LONG_PTR)originalWndProc); //MakeWindowUndo(targetWindow); InvalidateRect(targetWindow, NULL, TRUE); util::dcout << "Exiting inject proc." << std::endl; }
JSBool WrapObject(JSContext *cx, JSObject *scope, jsval v, jsval *vp) { // This might be redundant if called from XPC_SJOW_Construct, but it should // be cheap in that case. JSObject *objToWrap = UnsafeUnwrapSecurityWrapper(cx, JSVAL_TO_OBJECT(v)); if (!objToWrap || JS_TypeOfValue(cx, OBJECT_TO_JSVAL(objToWrap)) == JSTYPE_XML) { return ThrowException(NS_ERROR_INVALID_ARG, cx); } // Prevent script created Script objects from ever being wrapped // with XPCSafeJSObjectWrapper, and never let the eval function // object be directly wrapped. if (objToWrap->getClass() == &js_ScriptClass || (JS_ObjectIsFunction(cx, objToWrap) && JS_GetFunctionFastNative(cx, JS_ValueToFunction(cx, v)) == XPCWrapper::sEvalNative)) { return ThrowException(NS_ERROR_INVALID_ARG, cx); } XPCWrappedNativeScope *xpcscope = XPCWrappedNativeScope::FindInJSObjectScope(cx, scope); NS_ASSERTION(xpcscope, "what crazy scope are we in?"); XPCWrappedNative *wrappedNative; WrapperType type = xpcscope->GetWrapperFor(cx, objToWrap, SJOW, &wrappedNative); // NB: We allow XOW here because we're as restrictive as it is (and we know // we're same origin here). if (type != NONE && type != XOW && !(type & SJOW)) { return ThrowException(NS_ERROR_INVALID_ARG, cx); } SLIM_LOG_WILL_MORPH(cx, objToWrap); if (IS_SLIM_WRAPPER(objToWrap) && !MorphSlimWrapper(cx, objToWrap)) { return ThrowException(NS_ERROR_FAILURE, cx); } XPCWrappedNative *wn = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, objToWrap); if (wn) { CheckWindow(wn); } JSObject *wrapperObj = JS_NewObjectWithGivenProto(cx, js::Jsvalify(&SJOWClass), nsnull, scope); if (!wrapperObj) { // JS_NewObjectWithGivenProto already threw. return JS_FALSE; } *vp = OBJECT_TO_JSVAL(wrapperObj); if (!JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sWrappedObjSlot, OBJECT_TO_JSVAL(objToWrap)) || !JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sFlagsSlot, JSVAL_ZERO)) { return JS_FALSE; } return JS_TRUE; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { nCurAppRunMode=afxAppRunMode; if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; CExtCmdManager::g_bDisableCmdIfNoHandler=0; UINT nMainToolBarID=IDR_MAINFRAME; if(nCurAppRunMode==CONFIG_MODE) { SetTitle("2—: онфигуратор"); nMainToolBarID=IDR_CONFIGTOOLBAR; } csProfileName=GetTitle()+"N05"; #ifdef _DEBUG csProfileName+="D"; #endif CWinApp * pApp = ::AfxGetApp(); g_CmdManager->ProfileSetup( csProfileName, GetSafeHwnd() ); //ћеню /* m_wndMenuBar.SetMdiWindowPopupName( _T("Window") ); if( !m_wndMenuBar.Create("√лавное меню", this, IDC_MAIN_MENU)) { TRACE0( _T( "Failed to create menubar\n" ) ); return -1; } */ if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } pStatusBar=&m_wndStatusBar; //√лавна¤ панель if( !m_ToolMain.Create( _T("ќбща¤ панель инструментов"), this, IDR_MAIN_TOOLBAR ) || !m_ToolMain.LoadToolBar(nMainToolBarID) ) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } //ѕанель инструментов модул¤ if( !m_ToolModule.Create( _T("ѕанель инструментов модул¤"), this, IDR_MODULE ) || !m_ToolModule.LoadToolBar(IDR_MODULE) ) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } //ѕанель инструментов формы if(nCurAppRunMode==CONFIG_MODE) { if( !m_ToolEdit.Create( _T("ѕанель инструментов формы"), this, IDR_EDITBAR ) || !m_ToolEdit.LoadToolBar(IDR_EDITBAR) ) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } } //—оздаем контейнер окна сообщений if( !m_ParentMessageBar.Create( _T("ќкно сообщений"), this, ID_VIEWMESSAGEWINDOW ) ) { TRACE0("Failed to create m_ParentMessageBar\n"); return -1; // fail to create } //—оздаем само окно сообщений if( !m_MessageBar.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL |ES_MULTILINE|ES_LEFT|ES_WANTRETURN, CRect(0,0,0,0), &m_ParentMessageBar, m_ParentMessageBar.GetDlgCtrlID() ) ) { TRACE0("Failed to create m_MessageBar\n"); return -1; // fail to create } m_MessageBar.Init(); if(nCurAppRunMode==CONFIG_MODE) { //—оздаем контейнер отладочного окна if( !m_ParentDebugMessageBar.Create( _T("ќкно отладки"), this, ID_VIEWDEBUGMESSAGEWINDOW ) ) { TRACE0("Failed to create m_ParentDebugMessageBar\n"); return -1; // fail to create } if( !m_DebugMessageBar.Create( WS_VISIBLE|WS_CHILD|LVS_SHAREIMAGELISTS, CRect(0,50,50,200), &m_ParentDebugMessageBar, m_ParentDebugMessageBar.GetDlgCtrlID() ) ) { TRACE0("Failed to create m_DebugMessageBar\n"); return -1; // fail to create } m_DebugMessageBar.Init(); pDebugMessageBar=&m_DebugMessageBar; //—оздаем контейнер окна стека вызова if( !m_ParentStackBar.Create( _T("—тек вызова"), this, ID_VIEW_STACK ) ) { TRACE0("Failed to create m_ParentStackBar\n"); return -1; // fail to create } if( !m_StackBar.Create( WS_VISIBLE|WS_CHILD|LVS_SHAREIMAGELISTS, CRect(0,0,50,200), &m_ParentStackBar, m_ParentStackBar.GetDlgCtrlID() ) ) { TRACE0("Failed to create m_StackBar\n"); return -1; // fail to create } m_StackBar.Init(); pDebugStackBar=&m_StackBar; //—оздаем контейнер окна свойств if( !m_ParentPropertyBar.Create( _T("ќкно свойств"), this, ID_PROPERTYBAR ) ) { TRACE0("Failed to create m_ParentPropertyBar\n"); return -1; // fail to create } //—оздаем окно свойств if( !m_PropertyBar.Create( CRect(0,0,50,50), &m_ParentPropertyBar, IDC_OI, 0x50010000 ) ) { TRACE0("Failed to create m_PropertyBar\n"); return -1; // fail to create } m_PropertyBar.SetBorderStyle(CObjectInspector::bsSingle); m_PropertyBar.SetImageList(GetImageList()); } if( !m_ComboHelpSearch.Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWN, CRect( 0, 0, 200, 480 ), &m_ToolMain, ID_HELP_SEARCH_COMBO) || !m_ToolMain.SetButtonCtrl( m_ToolMain.CommandToIndex( m_ComboHelpSearch.GetDlgCtrlID()) , &m_ComboHelpSearch) ) { TRACE0( "Failed to create help search combobox\n" ); return -1; } m_ComboHelpSearch.SetItemHeight( -1, 16 ); m_ComboHelpSearch.SetFont( &g_PaintManager->m_FontNormal ); g_CmdManager->CmdGetPtr(csProfileName,m_ComboHelpSearch.GetDlgCtrlID())-> m_sMenuText = _T( "Search help system" ); m_wndDocSelector.Create(NULL, "ѕанель окон", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | CBRS_TOP, CRect(0,0,0,0), this, IDS_DOC_SELECTOR); m_wndDocSelector.SetBarStyle( CBRS_ALIGN_BOTTOM); //m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_ToolMain.EnableDocking(CBRS_ALIGN_ANY); m_ToolModule.EnableDocking(CBRS_ALIGN_ANY); if(nCurAppRunMode==CONFIG_MODE) m_ToolEdit.EnableDocking(CBRS_ALIGN_ANY); m_ParentMessageBar.EnableDocking(CBRS_ALIGN_ANY); if(nCurAppRunMode==CONFIG_MODE) { m_ParentDebugMessageBar.EnableDocking(CBRS_ALIGN_ANY); m_ParentStackBar.EnableDocking(CBRS_ALIGN_ANY); m_ParentPropertyBar.EnableDocking(CBRS_ALIGN_ANY); } if( !CExtControlBar::FrameEnableDocking(this) ) { ASSERT( FALSE ); return -1; } //DockControlBar(&m_wndMenuBar,AFX_IDW_DOCKBAR_TOP); DockControlBar(&m_ToolMain); DockControlBar(&m_ToolModule,AFX_IDW_DOCKBAR_BOTTOM); if(nCurAppRunMode==CONFIG_MODE) DockControlBar(&m_ToolEdit,AFX_IDW_DOCKBAR_BOTTOM); RecalcLayout(); m_ParentMessageBar.SetInitDesiredSizeHorizontal( CSize(80,80) ); m_ParentMessageBar.DockControlBar(AFX_IDW_DOCKBAR_BOTTOM,1,this,false); if(nCurAppRunMode==CONFIG_MODE) { m_ParentDebugMessageBar.SetInitDesiredSizeHorizontal( CSize(80,80) ); m_ParentDebugMessageBar.DockControlBar(AFX_IDW_DOCKBAR_BOTTOM,2,this,false); m_ParentStackBar.SetInitDesiredSizeHorizontal( CSize(80,80) ); m_ParentStackBar.DockControlBar(AFX_IDW_DOCKBAR_RIGHT,1,this,false); m_ParentPropertyBar.SetInitDesiredSizeVertical( CSize(180,80) ); m_ParentPropertyBar.DockControlBar(AFX_IDW_DOCKBAR_RIGHT,1,this,false); // m_ParentPropertyBar.SetInitDesiredSizeHorizontal( CSize(180,80) ); // m_ParentPropertyBar.SetInitDesiredSizeFloating( CSize(380,380) ); // m_ParentPropertyBar.FloatControlBar(); // m_ParentPropertyBar.AutoHideModeGet(); } /* g_CmdManager->SetBasicCommands( csProfileName, g_statBasicCommands); */ RecalcLayout(); CExtControlBar::ProfileBarStateLoad( this, pApp->m_pszRegistryKey, csProfileName, "Save", &m_dataFrameWP ); //¬осстанавливаем стиль CString csStyle=AfxGetApp()->GetProfileString(csProfileName, "Style"); //if(csStyle!="XP") // OnViewLikeOffice2k(); OnViewLikeOffice2k(); //передача ошибок в окно сообщений конфигуратора //if(nCurAppRunMode==CONFIG_MODE) //или отладка MyDDE.Create(MAKEINTRESOURCE(IDD_MYDATAEXCHANGE_DIALOG),this); CheckWindow(m_ToolMain); CheckWindow(m_ToolModule); if(nCurAppRunMode==CONFIG_MODE) { CheckWindow(m_ToolEdit); CheckWindow(m_ParentDebugMessageBar); CheckWindow(m_ParentStackBar); CheckWindow(m_ParentPropertyBar); } CheckWindow(m_ParentMessageBar); //************************** // Install the tab view here //VERIFY(m_MDIClient.SubclassMDIClient(this)); // m_ToolMain.InsertButton(); return 0; }
JSBool WrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn) { NS_ASSERTION(XPCPerThreadData::IsMainThread(cx), "Can't do this off the main thread!"); // Our argument should be a wrapped native object, but the caller may have // passed it in as an optimization. JSObject *wrappedObj; if (JSVAL_IS_PRIMITIVE(*vp) || !(wrappedObj = JSVAL_TO_OBJECT(*vp)) || wrappedObj->getClass() == &XOWClass) { return JS_TRUE; } if (!wn && !(wn = XPCWrappedNative::GetAndMorphWrappedNativeOfJSObject(cx, wrappedObj))) { return JS_TRUE; } CheckWindow(wn); // The parent must be the inner global object for its scope. parent = JS_GetGlobalForObject(cx, parent); OBJ_TO_INNER_OBJECT(cx, parent); if (!parent) { return JS_FALSE; } XPCWrappedNativeWithXOW *wnxow = nsnull; if (wn->NeedsXOW()) { JSObject *innerWrappedObj = wrappedObj; OBJ_TO_INNER_OBJECT(cx, innerWrappedObj); if (!innerWrappedObj) { return JS_FALSE; } if (innerWrappedObj == parent) { wnxow = static_cast<XPCWrappedNativeWithXOW *>(wn); JSObject *xow = wnxow->GetXOW(); if (xow) { *vp = OBJECT_TO_JSVAL(xow); return JS_TRUE; } } } XPCWrappedNative *parentwn = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, parent); XPCWrappedNativeScope *parentScope; if (NS_LIKELY(parentwn)) { parentScope = parentwn->GetScope(); } else { parentScope = XPCWrappedNativeScope::FindInJSObjectScope(cx, parent); } JSObject *outerObj = nsnull; WrappedNative2WrapperMap *map = parentScope->GetWrapperMap(); outerObj = map->Find(wrappedObj); if (outerObj) { NS_ASSERTION(outerObj->getClass() == &XOWClass, "What crazy object are we getting here?"); *vp = OBJECT_TO_JSVAL(outerObj); if (wnxow) { // NB: wnxow->GetXOW() must have returned false. SetFlags(cx, outerObj, AddFlags(GetFlags(cx, outerObj), FLAG_IS_CACHED)); wnxow->SetXOW(outerObj); } return JS_TRUE; } outerObj = JS_NewObjectWithGivenProto(cx, js::Jsvalify(&XOWClass), nsnull, parent); if (!outerObj) { return JS_FALSE; } jsval flags = INT_TO_JSVAL(wnxow ? FLAG_IS_CACHED : 0); if (!JS_SetReservedSlot(cx, outerObj, sWrappedObjSlot, *vp) || !JS_SetReservedSlot(cx, outerObj, sFlagsSlot, flags) || !JS_SetReservedSlot(cx, outerObj, XPC_XOW_ScopeSlot, PRIVATE_TO_JSVAL(parentScope))) { return JS_FALSE; } *vp = OBJECT_TO_JSVAL(outerObj); map->Add(wn->GetScope()->GetWrapperMap(), wrappedObj, outerObj); if(wnxow) { wnxow->SetXOW(outerObj); } return JS_TRUE; }