Add PhCreateDialog, PhLoadResourceCopy and update PhLoadResource

This commit is contained in:
dmex
2021-03-16 15:43:27 +11:00
parent 37dc3d8171
commit 22516ed570
6 changed files with 79 additions and 16 deletions
-3
View File
@@ -812,9 +812,6 @@ CleanupExit:
if (wicFactory)
IWICImagingFactory_Release(wicFactory);
if (resourceBuffer)
PhFree(resourceBuffer);
if (success)
return bitmapHandle;
+26 -1
View File
@@ -960,7 +960,7 @@ HWND PhCreateDialogFromTemplate(
PDLGTEMPLATEEX dialogTemplate;
HWND dialogHandle;
if (!PhLoadResource(Instance, Template, RT_DIALOG, NULL, &dialogTemplate))
if (!PhLoadResourceCopy(Instance, Template, RT_DIALOG, NULL, &dialogTemplate))
return NULL;
if (dialogTemplate->signature == USHRT_MAX)
@@ -985,6 +985,31 @@ HWND PhCreateDialogFromTemplate(
return dialogHandle;
}
HWND PhCreateDialog(
_In_ PVOID Instance,
_In_ PWSTR Template,
_In_ HWND ParentWindow,
_In_ DLGPROC DialogProc,
_In_opt_ PVOID Parameter
)
{
PDLGTEMPLATEEX dialogTemplate;
HWND dialogHandle;
if (!PhLoadResource(Instance, Template, RT_DIALOG, NULL, &dialogTemplate))
return NULL;
dialogHandle = CreateDialogIndirectParam(
Instance,
(LPDLGTEMPLATE)dialogTemplate,
ParentWindow,
DialogProc,
(LPARAM)Parameter
);
return dialogHandle;
}
BOOLEAN PhModalPropertySheet(
_Inout_ PROPSHEETHEADER *Header
)
+11
View File
@@ -420,6 +420,17 @@ HWND PhCreateDialogFromTemplate(
_In_ PVOID Parameter
);
PHLIBAPI
HWND
NTAPI
PhCreateDialog(
_In_ PVOID Instance,
_In_ PWSTR Template,
_In_ HWND ParentWindow,
_In_ DLGPROC DialogProc,
_In_opt_ PVOID Parameter
);
PHLIBAPI
BOOLEAN PhModalPropertySheet(
_Inout_ PROPSHEETHEADER *Header
+13 -1
View File
@@ -1252,7 +1252,19 @@ PhLoadResource(
_In_ PCWSTR Name,
_In_ PCWSTR Type,
_Out_opt_ ULONG *ResourceLength,
_Out_ PVOID *ResourceBuffer
_Out_opt_ PVOID *ResourceBuffer
);
_Success_(return)
PHLIBAPI
BOOLEAN
NTAPI
PhLoadResourceCopy(
_In_ PVOID DllBase,
_In_ PCWSTR Name,
_In_ PCWSTR Type,
_Out_opt_ ULONG * ResourceLength,
_Out_opt_ PVOID * ResourceBuffer
);
PHLIBAPI
+28 -7
View File
@@ -3,7 +3,7 @@
* general support functions
*
* Copyright (C) 2009-2016 wj32
* Copyright (C) 2017-2020 dmex
* Copyright (C) 2017-2021 dmex
*
* This file is part of Process Hacker.
*
@@ -1742,7 +1742,7 @@ PVOID PhGetFileVersionInfo(
if (!libraryModule)
return NULL;
if (PhLoadResource(
if (PhLoadResourceCopy(
libraryModule,
MAKEINTRESOURCE(VS_VERSION_INFO),
VS_FILE_INFO,
@@ -6024,7 +6024,7 @@ BOOLEAN PhLoadResource(
_In_ PCWSTR Name,
_In_ PCWSTR Type,
_Out_opt_ ULONG *ResourceLength,
_Out_ PVOID *ResourceBuffer
_Out_opt_ PVOID *ResourceBuffer
)
{
LDR_RESOURCE_INFO resourceInfo;
@@ -6044,7 +6044,31 @@ BOOLEAN PhLoadResource(
if (ResourceLength)
*ResourceLength = resourceLength;
*ResourceBuffer = PhAllocateCopy(resourceBuffer, resourceLength);
if (ResourceBuffer)
*ResourceBuffer = resourceBuffer;
return TRUE;
}
_Success_(return)
BOOLEAN PhLoadResourceCopy(
_In_ PVOID DllBase,
_In_ PCWSTR Name,
_In_ PCWSTR Type,
_Out_opt_ ULONG *ResourceLength,
_Out_opt_ PVOID *ResourceBuffer
)
{
ULONG resourceLength;
PVOID resourceBuffer;
if (!PhLoadResource(DllBase, Name, Type, &resourceLength, &resourceBuffer))
return FALSE;
if (ResourceLength)
*ResourceLength = resourceLength;
if (ResourceBuffer)
*ResourceBuffer = PhAllocateCopy(resourceBuffer, resourceLength);
return TRUE;
}
@@ -6091,7 +6115,6 @@ PPH_STRING PhLoadString(
);
}
PhFree(resourceBuffer);
return string;
}
@@ -6113,8 +6136,6 @@ HMENU PhLoadMenu(
))
{
menuHandle = LoadMenuIndirect(templateBuffer);
PhFree(templateBuffer);
}
return menuHandle;
+1 -4
View File
@@ -213,7 +213,7 @@ HBITMAP PhLoadPngImageFromResource(
NULL,
0.0,
WICBitmapPaletteTypeCustom
)))
)))
{
IWICFormatConverter_Release(wicFormatConverter);
goto CleanupExit;
@@ -274,9 +274,6 @@ CleanupExit:
if (wicFactory)
IWICImagingFactory_Release(wicFactory);
if (resourceBuffer)
PhFree(resourceBuffer);
if (success)
{
return bitmapHandle;