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