
How the Clipboard Works, Part 1 - noselasd
https://blogs.msdn.microsoft.com/ntdebugging/2012/03/16/how-the-clipboard-works-part-1/
======
kazinator
> _hData is null! Why is that? It turns out that the clipboard allows an
> application to pass in null to SetClipboardData for a given format._

 _" Turns out"_? This is clearly spelled out in the MSDN API documentation,
which is all you need to understand all this. (No NotePad stack traces
required, let alone ones in a _proportional font_ ).

SetClipboard: [https://msdn.microsoft.com/en-
us/library/windows/desktop/ms6...](https://msdn.microsoft.com/en-
us/library/windows/desktop/ms649051\(v=vs.85\).aspx)

 _hMem_ [in, optional]

Type: HANDLE

A handle to the data in the specified format. This parameter can be NULL,
indicating that the window provides data in the specified clipboard format
(renders the format) upon request.

------
orf
Very interesting article. Can anyone comment on how this differs from
clipboard access in *nix land? One of the things I miss about Windows is that
copy+paste between applications is a lot more seamless.

~~~
teddyh
[https://www.jwz.org/doc/x-cut-and-paste.html](https://www.jwz.org/doc/x-cut-
and-paste.html)

~~~
comboy
Oh wow, nice referral based redirect. Why though? jwz.org has some great
articles, why the HN hate?

~~~
srpablo
Pretty sure it's set up by JWZ to redirect on links from HN, not by HN to
jwz.org links.

He's written pretty extensively (and in my opinion, not wholly incorrectly)
about why the types who frequent this community is not one whose members he
cares to appease.

------
xenadu02
> Since the clipboard is part of Win32k.sys, you’ll need to use a kernel
> debugger.

I'll never understand why they ruined the perfectly good design of Windows NT
3.x by moving everything + kitchen sink into the kernel.

A bug in the clipboard functions shouldn't be a kernel exploit vector.

~~~
digi_owl
My understanding, home desktop performance.

~~~
paulddraper
Even today you read articles like "SQlite 35% faster than the filesystem"[1],
which boil down to one idea: kernel-space<->user-space interaction is slow.

This fact forms the basis for almost evey FUSE optimization.

[1]
[https://www.sqlite.org/fasterthanfs.html](https://www.sqlite.org/fasterthanfs.html)

------
mofle
Here's a real world example: [https://github.com/sindresorhus/win-
clipboard/blob/218dcffb9...](https://github.com/sindresorhus/win-
clipboard/blob/218dcffb9ee5b4bed47bad42b0f1cde654b35781/copy.c)

------
passivepinetree
Should be marked with a [2012] tag.

Super interesting article though.

------
jelder
I will never understand people who publish technical articles with code
examples in variable width font.

