-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
NativeMemory.Alloc allocates a byte count so you should pass half the buffer's size to Shell APIs which are expecting unicode-sized buffers.
Typically, this crashes on my PC:
public static byte[]? GetThumbnail(IShellLinkW* pShellLink, int size = 32)
{
...
pwszIconLocation = (char*)NativeMemory.Alloc(256);
hr = pShellLink->GetIconLocation(pwszIconLocation, 256, &nIconIndex);
...
It should be
hr = pShellLink->GetIconLocation(pwszIconLocation, 128, &nIconIndex);
And in fact IMHO, you should pass bigger buffers to avoid truncation, at least 512 but it can be more (not everything is under the MAX_PATH rule, Microsoft is very unclear about this).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels