Mercurial > trustbridge
annotate packaging/desktopshellrun.cpp @ 1224:7e720a820e1f
Merged.
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Wed, 24 Sep 2014 14:54:26 +0200 |
parents | ffdc8cba139a |
children | 12ed0b72e9f5 |
rev | line source |
---|---|
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=2) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 * See LICENSE.txt for details. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
8 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
9 /** |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
10 * @file tasksched_run_as.cpp |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 * @brief Run a command with the Task Scheduler API |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
13 * This effectively starts a program as the user regardles of the current |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
14 * process token. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
15 */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
16 #include <windows.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
17 #include "logging.h" |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
18 #include "strhelp.h" |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 #ifndef INITGUID |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 #define INITGUID |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
22 #endif |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
23 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
24 #include <initguid.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 #include <mstask.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
26 #include <wchar.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 #include <ole2.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 #include <shldisp.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
29 #include <shobjidl.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
30 #include <exdisp.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
31 #include <shlguid.h> |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
32 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
33 /* Some declarations missing in mingw-w64 3.1.0 taken from msdn */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
34 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
35 __CRT_UUID_DECL(IShellWindows, 0x85CB6900, 0x4D95, 0x11CF, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
36 0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
37 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
38 DEFINE_GUID(IID_IShellWindows, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
39 0x85CB6900, 0x4D95, 0x11CF, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
40 0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
41 DEFINE_GUID(CLSID_ShellWindows, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
42 0x9BA05972, 0xF6A8, 0x11CF, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
43 0xA4, 0x42, 0x00, 0xA0, 0xC9, 0x0A, 0x8F, 0x39); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
44 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
45 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
46 __CRT_UUID_DECL(IShellDispatch2, 0xA4C6892C, 0x3BA9, 0x11d2, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
47 0x9D, 0xEA, 0x00, 0xC0, 0x4F, 0xB1, 0x61, 0x62); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
48 __CRT_UUID_DECL(IShellFolderViewDual, 0xe7a1af80, 0x4d96, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
49 0x11cf, 0x96, 0x0c, 0x00, 0x80, 0xc7, 0xf4, 0xee, 0x85); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
50 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
51 #ifndef SWC_DESKTOP /* Will probably be addedd in future mingw */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
52 #define SWC_DESKTOP 0x00000008 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
53 /* from http://msdn.microsoft.com/en-us/library/windows/desktop/cc836581%28v=vs.85%29.aspx */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
54 #endif |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
55 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
56 #undef INITGUID |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
57 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
58 #ifdef DO_RELEASE_BUILD |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
59 bool g_debug = false; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
60 #else |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
61 bool g_debug = true; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
62 #endif |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
63 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
64 typedef struct _stack_t |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
65 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
66 struct _stack_t *next; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
67 char text[1]; /* This should be the length of string_size. */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
68 } stack_t; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
69 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
70 static HINSTANCE g_hInstance; /* Our Instance. */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
71 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
72 #define UNUSED(x) (void)(x) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
73 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
74 /** @brief the actual execuation call on the shell dispatcher |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
75 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
76 * @param[in] disp The shell dispatcher to use for shell execute. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
77 * @param[in] fName The file that should be exectued. |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
78 * @param[in] param Optinal parameters to add. |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
79 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
80 * @returns true on success. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
81 */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
82 static bool |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
83 shellexecute(IShellDispatch2 *disp, wchar_t *fName, wchar_t *param) |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
84 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
85 BSTR bName = NULL, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
86 bParam = NULL, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
87 bDir = NULL, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
88 bOp = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
89 VARIANT vParams[4]; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
90 HRESULT hr; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
91 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
92 if (!fName || !disp) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
93 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
94 ERRORPRINTF ("Invalid call to shellexecute."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
95 return false; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
96 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
97 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
98 bName = SysAllocString(fName); |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
99 bParam = SysAllocString(param ? param : L""); |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
100 bDir = SysAllocString(L""); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
101 bOp = SysAllocString(L""); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
102 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
103 if (!bName || !bParam || !bDir || !bOp) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
104 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
105 /* Out of memory */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
106 ERRORPRINTF ("Failed to allocate bstr values "); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
107 return false; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
108 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
109 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
110 vParams[0].vt = VT_BSTR; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
111 vParams[0].bstrVal = bParam; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
112 vParams[1].vt = VT_BSTR; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
113 vParams[1].bstrVal = bDir; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
114 vParams[2].vt = VT_BSTR; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
115 vParams[2].bstrVal = bOp; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
116 vParams[3].vt = VT_INT; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
117 vParams[3].intVal = SW_SHOWNORMAL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
118 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
119 hr = disp->ShellExecute(bName, vParams[0], vParams[1], vParams[2], vParams[3]); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
120 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
121 SysFreeString(bName); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
122 SysFreeString(bParam); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
123 SysFreeString(bOp); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
124 SysFreeString(bDir); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
125 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
126 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
127 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
128 ERRORPRINTF ("Failed to execute."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
129 return false; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
130 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
131 return true; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
132 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
133 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
134 #ifdef __cplusplus |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
135 extern "C" { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
136 #endif |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
137 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
138 /* Standard entry point for DLLs. */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
139 int WINAPI |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
140 DllMain (HANDLE hinst, DWORD reason, LPVOID reserved) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
141 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
142 UNUSED(reserved); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
143 if (reason == DLL_PROCESS_ATTACH) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
144 g_hInstance = (HINSTANCE)hinst; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
145 return TRUE; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
146 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
147 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
148 /** @brief Execute a command with the current running shell. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
149 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
150 * This function is intended to be called when you want to |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
151 * make sure that your application is not executed with higher |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
152 * privileges then the normal desktop session. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
153 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
154 * The code is based on the idea: |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
155 * http://blogs.msdn.com/b/oldnewthing/archive/2013/11/18/10468726.aspx |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
156 * |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
157 * The function signature is explained by NSIS. |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
158 */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
159 void __declspec(dllexport) __cdecl Exec(HWND hwndParent, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
160 int string_size, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
161 char *variables, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
162 stack_t **stacktop) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
163 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
164 UNUSED(hwndParent); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
165 UNUSED(string_size); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
166 HRESULT hr; |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
167 wchar_t *wbuf = NULL, |
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
168 *params = NULL; |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
169 IShellWindows *shellWindows = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
170 IShellBrowser *shellBrowser = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
171 IShellView *shellView = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
172 IShellFolderViewDual *folderView = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
173 IShellDispatch2 *shellDispatch = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
174 IServiceProvider *serviceProv = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
175 HWND hwnd; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
176 IDispatch *disp = NULL, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
177 *bgDisp = NULL, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
178 *sDisp = NULL; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
179 VARIANT vEmpty = {}; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
180 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
181 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
182 if (!stacktop || !*stacktop || !(*stacktop)->text) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
183 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
184 ERRORPRINTF ("Invalid call to exec :"); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
185 return; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
186 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
187 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
188 /* Initialize com ctx */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
189 hr = CoInitialize(NULL); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
190 if(FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
191 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
192 ERRORPRINTF ("CoInitializeEx failed. error = 0x%lx.", hr); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
193 return; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
194 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
195 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
196 /* Get the shell interface */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
197 hr = CoCreateInstance(CLSID_ShellWindows, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
198 NULL, CLSCTX_LOCAL_SERVER, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
199 IID_PPV_ARGS(&shellWindows)); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
200 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
201 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
202 ERRORPRINTF ("Failed to get shell interface."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
203 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
204 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
205 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
206 /* Get the desktop shell window */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
207 hr = shellWindows->FindWindowSW(&vEmpty, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
208 &vEmpty, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
209 SWC_DESKTOP, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
210 (long*)&hwnd, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
211 SWFO_NEEDDISPATCH, |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
212 &disp); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
213 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
214 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
215 ERRORPRINTF ("Failed to find the desktop dispatcher."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
216 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
217 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
218 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
219 hr = disp->QueryInterface(IID_PPV_ARGS(&serviceProv)); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
220 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
221 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
222 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
223 ERRORPRINTF ("Failed to get the service provider."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
224 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
225 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
226 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
227 /* Get the shell browser */ |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
228 hr = serviceProv->QueryService(SID_STopLevelBrowser, IID_PPV_ARGS(&shellBrowser)); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
229 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
230 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
231 ERRORPRINTF ("Failed to find the top level browser."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
232 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
233 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
234 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
235 hr = shellBrowser->QueryActiveShellView(&shellView); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
236 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
237 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
238 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
239 ERRORPRINTF ("Failed to find the active view."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
240 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
241 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
242 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
243 hr = shellView->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&bgDisp)); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
244 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
245 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
246 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
247 ERRORPRINTF ("Failed to get the views background."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
248 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
249 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
250 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
251 hr = bgDisp->QueryInterface(IID_PPV_ARGS(&folderView)); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
252 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
253 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
254 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
255 ERRORPRINTF ("Failed to get the folder view."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
256 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
257 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
258 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
259 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
260 hr = folderView->get_Application(&sDisp); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
261 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
262 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
263 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
264 ERRORPRINTF ("Failed to get the shell dispatch."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
265 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
266 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
267 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
268 hr = sDisp->QueryInterface(IID_PPV_ARGS(&shellDispatch)); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
269 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
270 if (FAILED(hr)) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
271 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
272 ERRORPRINTF ("Failed to get the shell dispatch interface."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
273 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
274 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
275 |
1158
ffdc8cba139a
(issue36) Add acp_to_wchar based on utf8_to_wchar
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1122
diff
changeset
|
276 /* For unicodensis this has to be utf8 to wchar */ |
ffdc8cba139a
(issue36) Add acp_to_wchar based on utf8_to_wchar
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1122
diff
changeset
|
277 |
ffdc8cba139a
(issue36) Add acp_to_wchar based on utf8_to_wchar
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1122
diff
changeset
|
278 wbuf = acp_to_wchar((*stacktop)->text, strlen((*stacktop)->text)); |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
279 if (!wbuf) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
280 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
281 ERRORPRINTF ("Failed to convert argument to wchar. error = 0x%lx.", hr); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
282 goto done; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
283 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
284 |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
285 if ((*stacktop)->next && (*stacktop)->next->text) |
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
286 { |
1158
ffdc8cba139a
(issue36) Add acp_to_wchar based on utf8_to_wchar
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1122
diff
changeset
|
287 params = acp_to_wchar((*stacktop)->next->text, strlen((*stacktop)->next->text)); |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
288 } |
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
289 |
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
290 if (!shellexecute(shellDispatch, wbuf, params)) |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
291 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
292 ERRORPRINTF ("Failed to execute."); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
293 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
294 xfree (wbuf); |
1122
4a17c9f977d0
(issue54) Add parameter handling to desktopshellrun
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1118
diff
changeset
|
295 xfree (params); |
1118
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
296 done: |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
297 if (folderView) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
298 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
299 folderView->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
300 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
301 if (disp) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
302 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
303 disp->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
304 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
305 if (shellBrowser) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
306 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
307 shellBrowser->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
308 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
309 if (shellWindows) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
310 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
311 shellWindows->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
312 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
313 if (shellView) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
314 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
315 shellView->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
316 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
317 if (sDisp) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
318 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
319 sDisp->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
320 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
321 if (shellDispatch) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
322 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
323 shellDispatch->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
324 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
325 if (serviceProv) |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
326 { |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
327 serviceProv->Release(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
328 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
329 CoUninitialize(); |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
330 return; |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
331 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
332 #ifdef __cplusplus |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
333 } |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
334 #endif |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
335 |
fd85a02d771d
(issue54) Implement a privilege drop to execute the program after installation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
336 |