Mercurial > trustbridge
annotate cinst/windowsstore.h @ 633:6c090638b2b4
Use static buffer for module file name.
According to the msdn examle the return value of getmodulefilename
should be used to indicate success and not the size. And according
to comments on that function on Windows 8.1 it does not return
the needed size. So better be more robust and just use max_path
as a limit.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 23 Jun 2014 15:29:48 +0200 |
parents | 17e1c8f37d72 |
children |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 #ifdef WIN32 |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 #ifndef WINDOWSSTORE_H |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 #define WINDOWSSTORE_H |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 |
219
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
12 #ifdef __cplusplus |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
13 extern "C" { |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
14 #endif |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
15 |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 #include <windows.h> |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 #include <wincrypt.h> |
161
a4b1c77f3e6a
Change install_certificates_win to generic write_stores_win
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
18 |
a4b1c77f3e6a
Change install_certificates_win to generic write_stores_win
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
19 #include <stdbool.h> |
a4b1c77f3e6a
Change install_certificates_win to generic write_stores_win
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
20 |
a4b1c77f3e6a
Change install_certificates_win to generic write_stores_win
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
21 /** @brief Access the Windows certificate store |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 * |
247
4de97f74d038
Check for process elevation and write into system store accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
219
diff
changeset
|
23 * If the process is running with elevated rights this function |
4de97f74d038
Check for process elevation and write into system store accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
219
diff
changeset
|
24 * will write into the system store. User store is written otherwise. |
4de97f74d038
Check for process elevation and write into system store accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
219
diff
changeset
|
25 * |
161
a4b1c77f3e6a
Change install_certificates_win to generic write_stores_win
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
26 * @param [in] to_install strv of DER encoded certificates to be added. |
a4b1c77f3e6a
Change install_certificates_win to generic write_stores_win
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
27 * @param [in] to_remove strv of DER encoded certificates to be remvoed. |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 * @returns 0 on success an errorcode otherwise. |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 */ |
247
4de97f74d038
Check for process elevation and write into system store accordingly
Andre Heinecke <aheinecke@intevation.de>
parents:
219
diff
changeset
|
30 int write_stores_win (char **to_install, char **to_remove); |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 |
219
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
32 /* The do_ functions are private helper functions and should not be used |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
33 * from other code. They are not static to allow it to use them directly |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
34 * in unit tests */ |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
35 void do_remove(HCERTSTORE hStore, char **to_remove); |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
36 void do_install(HCERTSTORE hStore, char **to_install); |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
37 |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
38 #ifdef __cplusplus |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
39 } |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
40 #endif |
57bef180d560
Add debug output and make windowsstore linkable from C++ code
Andre Heinecke <andre.heinecke@intevation.de>
parents:
161
diff
changeset
|
41 |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 #endif // WINDOWSSTORE_H |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 #endif // WIN32 |