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