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