Synchronize with trunk r58606.
[reactos.git] / dll / win32 / sfc_os / sfc_os.c
1 /*
2 * System File Checker (Windows File Protection)
3 *
4 * Copyright 2008 Pierre Schweitzer
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "precomp.h"
22 #include <debug.h>
23
24 HINSTANCE hLibModule;
25
26 typedef struct _PROTECTED_FILE_DATA
27 {
28 WCHAR FileName[MAX_PATH];
29 DWORD FileNumber;
30 } PROTECTED_FILE_DATA, *PPROTECTED_FILE_DATA;
31
32
33 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
34 {
35 switch (fdwReason)
36 {
37 case DLL_PROCESS_ATTACH:
38 {
39 DisableThreadLibraryCalls(hinstDLL);
40 hLibModule = hinstDLL;
41 break;
42 }
43 case DLL_PROCESS_DETACH:
44 {
45 break;
46 }
47 }
48
49 return TRUE;
50 }
51
52
53 /******************************************************************
54 * SfcIsFileProtected [sfc_os.@]
55 *
56 * Check, if the given File is protected by the System
57 *
58 * PARAMS
59 * RpcHandle [I] This must be NULL
60 * ProtFileName [I] Filename with Path to check
61 *
62 * RETURNS
63 * Failure: FALSE with GetLastError() != ERROR_FILE_NOT_FOUND
64 * Success: TRUE, when the File is Protected
65 * FALSE with GetLastError() == ERROR_FILE_NOT_FOUND,
66 * when the File is not Protected
67 *
68 *
69 * BUGS
70 * We return always the Result for: "File is not Protected"
71 *
72 */
73 BOOL WINAPI SfcIsFileProtected(HANDLE RpcHandle, LPCWSTR ProtFileName)
74 {
75 static BOOL reported = FALSE;
76
77 if (reported) {
78 DPRINT("(%p, %S) stub\n", RpcHandle, ProtFileName);
79 }
80 else
81 {
82 DPRINT1("(%p, %S) stub\n", RpcHandle, ProtFileName);
83 reported = TRUE;
84 }
85
86 SetLastError(ERROR_FILE_NOT_FOUND);
87 return FALSE;
88 }
89
90 /******************************************************************
91 * SfcIsKeyProtected [sfc_os.@]
92 *
93 * Check, if the given Registry Key is protected by the System
94 *
95 * PARAMS
96 * hKey [I] Handle to the root registry key
97 * lpSubKey [I] Name of the subkey to check
98 * samDesired [I] The Registry View to Examine (32 or 64 bit)
99 *
100 * RETURNS
101 * Failure: FALSE with GetLastError() != ERROR_FILE_NOT_FOUND
102 * Success: TRUE, when the Key is Protected
103 * FALSE with GetLastError() == ERROR_FILE_NOT_FOUND,
104 * when the Key is not Protected
105 *
106 */
107 BOOL WINAPI SfcIsKeyProtected(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired)
108 {
109 static BOOL reported = FALSE;
110
111 if (reported) {
112 DPRINT("(%p, %S) stub\n", hKey, lpSubKey);
113 }
114 else
115 {
116 DPRINT1("(%p, %S) stub\n", hKey, lpSubKey);
117 reported = TRUE;
118 }
119
120 if( !hKey ) {
121 SetLastError(ERROR_INVALID_HANDLE);
122 return FALSE;
123 }
124
125 SetLastError(ERROR_FILE_NOT_FOUND);
126 return FALSE;
127 }
128
129 /******************************************************************
130 * SfcGetNextProtectedFile [sfc_os.@]
131 */
132 BOOL WINAPI SfcGetNextProtectedFile(HANDLE RpcHandle, PPROTECTED_FILE_DATA ProtFileData)
133 {
134 if (!ProtFileData)
135 {
136 SetLastError(ERROR_INVALID_PARAMETER);
137 return FALSE;
138 }
139
140 UNIMPLEMENTED;
141 SetLastError(ERROR_NO_MORE_FILES);
142 return FALSE;
143 }
144
145 /******************************************************************
146 * SfcFileException [sfc_os.@]
147 *
148 * Disable the protection for the given file during one minute
149 *
150 * PARAMS
151 * dwUnknown0 [I] Set to 0
152 * pwszFile [I] Name of the file to unprotect
153 * dwUnknown1 [I] Set to -1
154 *
155 * RETURNS
156 * Failure: 1;
157 * Success: 0;
158 *
159 */
160 DWORD WINAPI SfcFileException(DWORD dwUnknown0, PWCHAR pwszFile, DWORD dwUnknown1)
161 {
162 UNIMPLEMENTED;
163 /* Always return success */
164 return 0;
165 }