/* Called when thread terminates to allow release of clipboard */ void cleanup_clipboard_thread(struct w32thread *thread) { struct clipboard *clipboard; struct winstation *winstation = get_process_winstation(thread->process, WINSTA_ACCESSCLIPBOARD); if (!winstation) return; if ((clipboard = winstation->clipboard)) { if (thread == clipboard->open_thread) { clipboard->open_win = 0; clipboard->open_thread = NULL; } if (thread == clipboard->owner_thread) { clipboard->owner_win = 0; clipboard->owner_thread = NULL; } } release_object(winstation); }
/* retrieve the clipboard info for the current process, allocating it if needed */ static struct clipboard *get_process_clipboard(void) { NTSTATUS status; struct clipboard *clipboard; struct winstation *winstation = get_process_winstation(get_current_w32process(), WINSTA_ACCESSCLIPBOARD); if (!winstation) { ktrace("get_process_winstation return NULL!\n"); return NULL; } if (!(clipboard = winstation->clipboard)) { status = create_object(KernelMode, clipboard_object_type, NULL /* obj_attr*/, KernelMode, NULL, sizeof(struct clipboard), 0, 0, (PVOID *)&clipboard); if (NT_SUCCESS(status) && clipboard) { INIT_DISP_HEADER(&clipboard->obj.header, CLIPBOARD, sizeof(struct clipboard) / sizeof(ULONG), 0); BODY_TO_HEADER(&(clipboard->obj))->ops = &clipboard_ops; clipboard->open_thread = NULL; clipboard->open_win = 0; clipboard->owner_thread = NULL; clipboard->owner_win = 0; clipboard->viewer = 0; clipboard->seqno = 0; clipboard->seqno_timestamp = 0; winstation->clipboard = clipboard; } } release_object(winstation); return clipboard; }
/* retrieve the clipboard info for the current_thread process, allocating it if needed */ static struct clipboard *get_process_clipboard(void) { struct clipboard *clipboard; struct winstation *winstation = get_process_winstation( current_thread->process, WINSTA_ACCESSCLIPBOARD ); if (!winstation) return NULL; if (!(clipboard = winstation->clipboard)) { if ((clipboard = alloc_object( &clipboard_ops ))) { clipboard->open_thread = NULL; clipboard->open_win = 0; clipboard->owner_thread = NULL; clipboard->owner_win = 0; clipboard->viewer = 0; clipboard->seqno = 0; clipboard->seqno_timestamp = 0; winstation->clipboard = clipboard; } } release_object( winstation ); return clipboard; }