[PATCH] ole32/clipboard: Handle CF_HDROP format.

Huw Davies huw at codeweavers.com
Tue Mar 9 06:48:26 CST 2021


On Tue, Mar 09, 2021 at 11:57:01AM +0800, Jactry Zeng wrote:
> +static HDROP create_dropped_file(void)
> +{
> +    WCHAR path[] = L"C:\testfile1";

You need to escape the backslash.  Also, it would most likely be easier to
include the second \0 in the string ie. L"C:\\testfile1\0" and then use
memcpy to copy it.

> +    DROPFILES *dropfiles;
> +    DWORD size, offset;
> +    HDROP hdrop;
> +
> +    size = sizeof(DROPFILES) + (sizeof(path) + 1) * sizeof(WCHAR);

This is wrong.

> +    offset = sizeof(DROPFILES);
> +    hdrop = GlobalAlloc(GHND, size);
> +    dropfiles = GlobalLock(hdrop);
> +    dropfiles->pFiles = offset;
> +    dropfiles->fWide = TRUE;
> +    lstrcpyW(((WCHAR *)dropfiles) + offset, path);

As is this - offset is a byte offset...

> +    offset += lstrlenW(path) + 1;

...which seems to turn into a WCHAR offset.

> +    ((WCHAR *)dropfiles)[offset] = 0;
> +    GlobalUnlock(hdrop);
> +
> +    return hdrop;
> +}
> +



More information about the wine-devel mailing list