ReactOS  0.4.14-dev-337-gf981a68
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());
109  if (!SfcIsFileProtected)
110  return;
111 
112  RtlGetVersion(&rtlinfo);
113  g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
114 
116 }
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
BOOL WINAPI SfcIsFileProtected(HANDLE RpcHandle, LPCWSTR ProtFileName)
Definition: sfc_os.c:83
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
ULONG dwMajorVersion
Definition: rtltypes.h:243
static void Test_ProtectedFiles()
static DWORD g_WinVersion
#define ok(value,...)
Definition: atltest.h:57
ULONG dwMinorVersion
Definition: rtltypes.h:244
#define GetProcAddress(x, y)
Definition: compat.h:418
static int mod
Definition: i386-dis.c:1273

◆ Test_ProtectedFiles()

static void Test_ProtectedFiles ( )
static

Definition at line 70 of file SfcIsFileProtected.c.

71 {
72  ULONG n;
73  BOOL Protected;
74  WCHAR Buffer[MAX_PATH * 3];
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 }
static testdata tests[]
BOOL WINAPI SfcIsFileProtected(HANDLE RpcHandle, LPCWSTR ProtFileName)
Definition: sfc_os.c:83
#define _countof(array)
Definition: fontsub.cpp:30
GLdouble n
Definition: glext.h:7729
unsigned int BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static DWORD g_WinVersion
PRTL_UNICODE_STRING_BUFFER Path
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
unsigned int ULONG
Definition: retypes.h:1

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 TRUE
Definition: types.h:120
#define PASS(from, to)
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 38 of file SfcIsFileProtected.c.

Referenced by Test_ProtectedFiles().