-
Notifications
You must be signed in to change notification settings - Fork 1
/
manifest.c
60 lines (44 loc) · 2.48 KB
/
manifest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
Copyright (C) 2003-2009 Toby Thain, [email protected]
Copyright (C) 2018-2024 Daniel Marschall, ViaThinkSoft
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include "manifest.h"
BOOL ActivateManifest(HMODULE hModule, int manifestResourceID, PManifestActivationCtx vars) {
f_ActivateActCtx fActivateActCtx;
f_CreateActCtxA fCreateActCtxA;
if (!(vars->hKernel32 = LoadLibrary(TEXT("KERNEL32.DLL")))) return FALSE;
if (!(fActivateActCtx = (f_ActivateActCtx)(void*)GetProcAddress(vars->hKernel32, "ActivateActCtx"))) { FreeLibrary(vars->hKernel32); return FALSE; }
if (!(fCreateActCtxA = (f_CreateActCtxA)(void*)GetProcAddress(vars->hKernel32, "CreateActCtxA"))) { FreeLibrary(vars->hKernel32); return FALSE; }
ZeroMemory(&vars->actCtx, sizeof(vars->actCtx));
vars->actCtx.cbSize = sizeof(vars->actCtx);
vars->actCtx.hModule = hModule;
vars->actCtx.lpResourceName = MAKEINTRESOURCEA(manifestResourceID);
vars->actCtx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID;
vars->hActCtx = fCreateActCtxA(&vars->actCtx);
if (vars->hActCtx == INVALID_HANDLE_VALUE) { FreeLibrary(vars->hKernel32); return FALSE; }
fActivateActCtx(vars->hActCtx, &vars->cookie);
return TRUE;
}
BOOL DeactivateManifest(PManifestActivationCtx vars) {
f_DeactivateActCtx fDeactivateActCtx;
f_ReleaseActCtx fReleaseActCtx;
if (!(fDeactivateActCtx = (f_DeactivateActCtx)(void*)GetProcAddress(vars->hKernel32, "DeactivateActCtx"))) return FALSE;
if (!(fReleaseActCtx = (f_ReleaseActCtx)(void*)GetProcAddress(vars->hKernel32, "ReleaseActCtx"))) return FALSE;
fDeactivateActCtx(0, vars->cookie);
fReleaseActCtx(vars->hActCtx);
FreeLibrary(vars->hKernel32);
return TRUE;
}