ReactOS  0.4.14-dev-49-gfb4591c
sfc_os.c
Go to the documentation of this file.
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 <stdarg.h>
22 
23 #define WIN32_NO_STATUS
24 
25 #include <windef.h>
26 #include <winbase.h>
27 #include <winreg.h>
28 #include <winuser.h>
29 #include <winwlx.h>
30 
31 #define NDEBUG
32 #include <debug.h>
33 
35 
36 typedef struct _PROTECTED_FILE_DATA
37 {
41 
42 
44 {
45  switch (fdwReason)
46  {
47  case DLL_PROCESS_ATTACH:
48  {
49  DisableThreadLibraryCalls(hinstDLL);
50  hLibModule = hinstDLL;
51  break;
52  }
53  case DLL_PROCESS_DETACH:
54  {
55  break;
56  }
57  }
58 
59  return TRUE;
60 }
61 
62 
63 /******************************************************************
64  * SfcIsFileProtected [sfc_os.@]
65  *
66  * Check, if the given File is protected by the System
67  *
68  * PARAMS
69  * RpcHandle [I] This must be NULL
70  * ProtFileName [I] Filename with Path to check
71  *
72  * RETURNS
73  * Failure: FALSE with GetLastError() != ERROR_FILE_NOT_FOUND
74  * Success: TRUE, when the File is Protected
75  * FALSE with GetLastError() == ERROR_FILE_NOT_FOUND,
76  * when the File is not Protected
77  *
78  *
79  * BUGS
80  * We return always the Result for: "File is not Protected"
81  *
82  */
84 {
85  static BOOL reported = FALSE;
86 
87  if (reported) {
88  DPRINT("(%p, %S) stub\n", RpcHandle, ProtFileName);
89  }
90  else
91  {
92  DPRINT1("(%p, %S) stub\n", RpcHandle, ProtFileName);
93  reported = TRUE;
94  }
95 
97  return FALSE;
98 }
99 
100 /******************************************************************
101  * SfcIsKeyProtected [sfc_os.@]
102  *
103  * Check, if the given Registry Key is protected by the System
104  *
105  * PARAMS
106  * hKey [I] Handle to the root registry key
107  * lpSubKey [I] Name of the subkey to check
108  * samDesired [I] The Registry View to Examine (32 or 64 bit)
109  *
110  * RETURNS
111  * Failure: FALSE with GetLastError() != ERROR_FILE_NOT_FOUND
112  * Success: TRUE, when the Key is Protected
113  * FALSE with GetLastError() == ERROR_FILE_NOT_FOUND,
114  * when the Key is not Protected
115  *
116  */
117 BOOL WINAPI SfcIsKeyProtected(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired)
118 {
119  static BOOL reported = FALSE;
120 
121  if (reported) {
122  DPRINT("(%p, %S) stub\n", hKey, lpSubKey);
123  }
124  else
125  {
126  DPRINT1("(%p, %S) stub\n", hKey, lpSubKey);
127  reported = TRUE;
128  }
129 
130  if( !hKey ) {
132  return FALSE;
133  }
134 
136  return FALSE;
137 }
138 
139 /******************************************************************
140  * SfcGetNextProtectedFile [sfc_os.@]
141  */
143 {
144  if (!ProtFileData)
145  {
147  return FALSE;
148  }
149 
152  return FALSE;
153 }
154 
155 /******************************************************************
156  * SfcFileException [sfc_os.@]
157  *
158  * Disable the protection for the given file during one minute
159  *
160  * PARAMS
161  * dwUnknown0 [I] Set to 0
162  * pwszFile [I] Name of the file to unprotect
163  * dwUnknown1 [I] Set to -1
164  *
165  * RETURNS
166  * Failure: 1;
167  * Success: 0;
168  *
169  */
170 DWORD WINAPI SfcFileException(DWORD dwUnknown0, PWCHAR pwszFile, DWORD dwUnknown1)
171 {
173  /* Always return success */
174  return 0;
175 }
176 
177 /******************************************************************
178  * SfcWLEventLogoff [sfc_os.@]
179  *
180  * Logoff notification function
181  *
182  * PARAMS
183  * pInfo [I] Pointer to logoff notification information
184  *
185  * RETURNS
186  * nothing
187  *
188  */
189 VOID
190 WINAPI
193 {
195 }
196 
197 /******************************************************************
198  * SfcWLEventLogon [sfc_os.@]
199  *
200  * Logon notification function
201  *
202  * PARAMS
203  * pInfo [I] Pointer to logon notification information
204  *
205  * RETURNS
206  * nothing
207  *
208  */
209 VOID
210 WINAPI
213 {
215 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI SfcIsFileProtected(HANDLE RpcHandle, LPCWSTR ProtFileName)
Definition: sfc_os.c:83
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
HINSTANCE hLibModule
Definition: sfc_os.c:34
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
uint16_t * PWCHAR
Definition: typedefs.h:54
DWORD WINAPI SfcFileException(DWORD dwUnknown0, PWCHAR pwszFile, DWORD dwUnknown1)
Definition: sfc_os.c:170
static IN DWORD IN LPVOID lpvReserved
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: sfc_os.c:43
void DPRINT(...)
Definition: polytest.cpp:61
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define DLL_PROCESS_DETACH
Definition: compat.h:119
struct _PROTECTED_FILE_DATA PROTECTED_FILE_DATA
struct _PROTECTED_FILE_DATA * PPROTECTED_FILE_DATA
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
LPCWSTR ProtFileName
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI SfcIsKeyProtected(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired)
Definition: sfc_os.c:117
ACCESS_MASK REGSAM
Definition: winreg.h:69
BOOL WINAPI SfcGetNextProtectedFile(HANDLE RpcHandle, PPROTECTED_FILE_DATA ProtFileData)
Definition: sfc_os.c:142
#define DPRINT1
Definition: precomp.h:8
VOID WINAPI SfcWLEventLogoff(PWLX_NOTIFICATION_INFO pInfo)
Definition: sfc_os.c:191
#define UNIMPLEMENTED
Definition: debug.h:114
VOID WINAPI SfcWLEventLogon(PWLX_NOTIFICATION_INFO pInfo)
Definition: sfc_os.c:211