ReactOS 0.4.15-dev-8146-gdc0ed6d
SfcIsFileProtected.c File Reference
#include <apitest.h>
#include <strsafe.h>
#include <ndk/umtypes.h>
#include <ndk/rtlfuncs.h>
Include dependency graph for SfcIsFileProtected.c:

Go to the source code of this file.

Classes

struct  _osrange
 
struct  _testdata
 

Macros

#define _WIN32_WINNT_MINVER   0x0001
 
#define MAKERANGE(from, to)    { _WIN32_WINNT_ ## from, _WIN32_WINNT_ ## to }
 
#define PASS(from, to)    MAKERANGE(from, to)
 

Typedefs

typedef struct _osrange osrange
 
typedef struct _testdata testdata
 

Functions

 BOOL (WINAPI *SfcIsFileProtected)(HANDLE RpcHandle
 
static void Test_ProtectedFiles ()
 
 START_TEST (SfcIsFileProtected)
 

Variables

LPCWSTR ProtFileName
 
static DWORD g_WinVersion
 
static testdata tests []
 

Macro Definition Documentation

◆ _WIN32_WINNT_MINVER

#define _WIN32_WINNT_MINVER   0x0001

Definition at line 30 of file SfcIsFileProtected.c.

◆ MAKERANGE

#define MAKERANGE (   from,
  to 
)     { _WIN32_WINNT_ ## from, _WIN32_WINNT_ ## to }

Definition at line 32 of file SfcIsFileProtected.c.

◆ PASS

#define PASS (   from,
  to 
)     MAKERANGE(from, to)

Definition at line 35 of file SfcIsFileProtected.c.

Typedef Documentation

◆ osrange

◆ testdata

Function Documentation

◆ BOOL()

BOOL ( WINAPI SfcIsFileProtected)

◆ START_TEST()

START_TEST ( SfcIsFileProtected  )

Definition at line 97 of file SfcIsFileProtected.c.

98{
99 RTL_OSVERSIONINFOW rtlinfo = { sizeof(rtlinfo) };
100 HMODULE mod;
101
102 mod = LoadLibraryA("sfc_os.dll");
103 ok(mod != NULL, "Unable to load sfc_os: 0x%lu\n", GetLastError());
104 if (!mod)
105 return;
106
107 SfcIsFileProtected = (void*)GetProcAddress(mod, "SfcIsFileProtected");
108 ok(SfcIsFileProtected != NULL, "Unable to resolve SfcIsFileProtected: 0x%lu\n", GetLastError());
110 return;
111
112 RtlGetVersion(&rtlinfo);
113 g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
114
116}
static void Test_ProtectedFiles()
static DWORD g_WinVersion
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static int mod
Definition: i386-dis.c:1288
BOOL WINAPI SfcIsFileProtected(HANDLE RpcHandle, LPCWSTR ProtFileName)
Definition: sfc_os.c:83
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwMajorVersion
Definition: rtltypes.h:247
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ Test_ProtectedFiles()

static void Test_ProtectedFiles ( )
static

Definition at line 70 of file SfcIsFileProtected.c.

71{
72 ULONG n;
73 BOOL Protected;
75
76 for (n = 0; n < _countof(tests); ++n)
77 {
78 if (tests[n].Expand)
80 else
82
83 Protected = SfcIsFileProtected(NULL, Buffer);
84
86 {
87 ok(Protected, "[%lu,0x%04lx]: Failed: %S\n", n, g_WinVersion, Buffer);
88 }
89 else
90 {
91 ok(!Protected, "[%lu,0x%04lx]: Succeeded: %S\n", n, g_WinVersion, Buffer);
92 }
93 }
94}
PRTL_UNICODE_STRING_BUFFER Path
static testdata tests[]
Definition: bufpool.h:45
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble n
Definition: glext.h:7729
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
uint32_t ULONG
Definition: typedefs.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

Variable Documentation

◆ g_WinVersion

DWORD g_WinVersion
static

Definition at line 14 of file SfcIsFileProtected.c.

Referenced by START_TEST(), and Test_ProtectedFiles().

◆ ProtFileName

LPCWSTR ProtFileName

Definition at line 13 of file SfcIsFileProtected.c.

Referenced by SfcIsFileProtected().

◆ tests

testdata tests[]
static
Initial value:
=
{
{ L"%systemroot%\\system32\\kernel32.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%SYSTEMROOT%\\SYSTEM32\\KERNEL32.DLL", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%//system32\\kernel32.dll", TRUE, PASS(VISTA, WIN10) },
{ L"%systemroot%\\system32\\..\\system32\\kernel32.dll", TRUE, PASS(VISTA, WIN10) },
{ L"kernel32.dll", FALSE, PASS(MINVER, MINVER) },
{ L"%systemroot%//system32\\kernel32.dll", FALSE, PASS(MINVER, MINVER) },
{ L"%systemroot%\\system32\\kernel32.dll", FALSE, PASS(MINVER, WS03) },
{ L"%SYSTEMROOT%\\SYSTEM32\\KERNEL32.DLL", FALSE, PASS(MINVER, WS03) },
{ L"%systemroot%\\system32\\user32.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\shell32.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\browseui.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\apphelp.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\sfc.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\sfc_os.dll", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\sdbinst.exe", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\AppPatch\\sysmain.sdb", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\fonts\\tahoma.ttf", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\fonts\\tahomabd.ttf", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\ntoskrnl.exe", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\system32\\c_1252.nls", TRUE, PASS(MINVER, WIN10) },
{ L"%systemroot%\\NOTEPAD.EXE", TRUE, PASS(MINVER, WIN10) },
}
#define PASS(from, to)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define L(x)
Definition: ntvdm.h:50

Definition at line 38 of file SfcIsFileProtected.c.

Referenced by Test_ProtectedFiles().