mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:26:17 +00:00
[USER32] Support loading icons from data file module (#6065)
GetModuleFileName() fails on LOAD_LIBRARY_AS_DATAFILE causing LoadImage to fail. Use a fake filename for LR_SHARED (with same format as Windows). This may not be a good design, but it does match Windows' behaviour. + Added test.
This commit is contained in:
parent
8f349ab3c2
commit
82c07abf1a
2 changed files with 62 additions and 1 deletions
|
@ -1454,7 +1454,21 @@ CURSORICON_LoadImageW(
|
|||
RtlInitUnicodeString(&ustrRsrc, lpszName);
|
||||
}
|
||||
|
||||
if(hinst)
|
||||
if(LDR_IS_RESOURCE(hinst))
|
||||
{
|
||||
/* We don't have a real module for GetModuleFileName, construct a fake name instead.
|
||||
* GetIconInfoEx reveals the name used by Windows. */
|
||||
LPCWSTR fakeNameFmt = sizeof(void*) > 4 ? L"\x01%016IX" : L"\x01%08IX";
|
||||
ustrModule.MaximumLength = 18 * sizeof(WCHAR);
|
||||
ustrModule.Buffer = HeapAlloc(GetProcessHeap(), 0, ustrModule.MaximumLength);
|
||||
if (!ustrModule.Buffer)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
ustrModule.Length = wsprintfW(ustrModule.Buffer, fakeNameFmt, hinst) * sizeof(WCHAR);
|
||||
}
|
||||
else if(hinst)
|
||||
{
|
||||
DWORD size = MAX_PATH;
|
||||
/* Get the module name string */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue