ReactOS  0.4.13-dev-259-g5ca9c9c
init.c File Reference
#include "precomp.h"
#include <winreg.h>
#include <ndk/cmfuncs.h>
#include <ndk/obfuncs.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define NTOS_MODE_USER
 

Functions

PIFS_PROVIDER GetProvider (IN PWCHAR FileSystem)
 
static BOOLEAN AddProvider (IN PCUNICODE_STRING FileSystem, IN PWCHAR DllFile)
 
static BOOLEAN InitializeFmIfsOnce (VOID)
 
BOOLEAN NTAPI InitializeFmIfs (IN PVOID hinstDll, IN DWORD dwReason, IN PVOID reserved)
 

Variables

static BOOLEAN FmIfsInitialized = FALSE
 
LIST_ENTRY ProviderListHead
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 15 of file init.c.

Function Documentation

◆ AddProvider()

static BOOLEAN AddProvider ( IN PCUNICODE_STRING  FileSystem,
IN PWCHAR  DllFile 
)
static

Definition at line 45 of file init.c.

48 {
51  HMODULE hMod = NULL;
52  BOOLEAN ret = FALSE;
53 
54  hMod = LoadLibraryW(DllFile);
55  if (!hMod)
56  goto cleanup;
57 
59  + FileSystem->Length + sizeof(UNICODE_NULL);
61  RtlGetProcessHeap(),
62  0,
63  RequiredSize);
64  if (!Provider)
65  goto cleanup;
67 
68  /* Get function pointers */
69  Provider->ChkdskEx = (CHKDSKEX)GetProcAddress(hMod, "ChkdskEx");
70  //Provider->Extend = (EXTEND)GetProcAddress(hMod, "Extend");
71  Provider->FormatEx = (FORMATEX)GetProcAddress(hMod, "FormatEx");
72 
73  RtlCopyMemory(Provider->Name, FileSystem->Buffer, FileSystem->Length);
74 
76  ret = TRUE;
77 
78 cleanup:
79  if (!ret)
80  {
81  if (hMod)
82  FreeLibrary(hMod);
83  if (Provider)
84  RtlFreeHeap(RtlGetProcessHeap(), 0, Provider);
85  }
86  return ret;
87 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PWCHAR FileSystem
Definition: format.c:72
NTSTATUS(NTAPI * CHKDSKEX)(IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
Definition: fmifs.h:207
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
NTSTATUS(NTAPI * FORMATEX)(IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: fmifs.h:198
struct _IFS_PROVIDER * PIFS_PROVIDER
#define InsertTailList(ListHead, Entry)
#define UNICODE_NULL
unsigned char BOOLEAN
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define FreeLibrary(x)
Definition: compat.h:405
LIST_ENTRY ProviderListHead
Definition: init.c:20
int ret
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
char * cleanup(char *str)
Definition: wpickclick.c:99
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by InitializeFmIfsOnce().

◆ GetProvider()

PIFS_PROVIDER GetProvider ( IN PWCHAR  FileSystem)

Definition at line 23 of file init.c.

25 {
26  PLIST_ENTRY ListEntry;
28 
29  ListEntry = ProviderListHead.Flink;
30  while (ListEntry != &ProviderListHead)
31  {
32  Provider = CONTAINING_RECORD(ListEntry, IFS_PROVIDER, ListEntry);
33  if (_wcsicmp(Provider->Name, FileSystem) == 0)
34  return Provider;
35  ListEntry = ListEntry->Flink;
36  }
37 
38  /* Provider not found */
39  return NULL;
40 }
PWCHAR FileSystem
Definition: format.c:72
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY ProviderListHead
Definition: init.c:20
Definition: typedefs.h:117
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by Chkdsk(), and FormatEx().

◆ InitializeFmIfs()

BOOLEAN NTAPI InitializeFmIfs ( IN PVOID  hinstDll,
IN DWORD  dwReason,
IN PVOID  reserved 
)

Definition at line 159 of file init.c.

163 {
164  switch (dwReason)
165  {
166  case DLL_PROCESS_ATTACH:
167  if (FmIfsInitialized == FALSE)
168  {
169  if (InitializeFmIfsOnce() == FALSE)
170  return FALSE;
171 
173  }
174  break;
175 
176  case DLL_THREAD_ATTACH:
177  break;
178 
179  case DLL_THREAD_DETACH:
180  break;
181 
182  case DLL_PROCESS_DETACH:
183  break;
184  }
185 
186  return TRUE;
187 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:121
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define DLL_THREAD_DETACH
Definition: compat.h:122
DWORD dwReason
Definition: misc.cpp:154
#define DLL_PROCESS_DETACH
Definition: compat.h:119
static BOOLEAN InitializeFmIfsOnce(VOID)
Definition: init.c:91
static BOOLEAN FmIfsInitialized
Definition: init.c:19

◆ InitializeFmIfsOnce()

static BOOLEAN InitializeFmIfsOnce ( VOID  )
static

Definition at line 91 of file init.c.

92 {
95  = RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\SOFTWARE\\ReactOS\\ReactOS\\CurrentVersion\\IFS");
96  HANDLE hKey = NULL;
100  ULONG i = 0;
104 
106 
107  /* Read IFS providers from HKLM\SOFTWARE\ReactOS\ReactOS\CurrentVersion\IFS */
111  return TRUE;
112  else if (!NT_SUCCESS(Status))
113  return FALSE;
114 
116  RtlGetProcessHeap(),
117  0,
118  BufferSize);
119  if (!Buffer)
120  {
121  NtClose(hKey);
122  return FALSE;
123  }
124 
125  while (TRUE)
126  {
128  hKey,
129  i++,
131  Buffer,
132  BufferSize,
133  &RequiredSize);
135  continue;
136  else if (!NT_SUCCESS(Status))
137  break;
138  else if (Buffer->Type != REG_SZ)
139  continue;
140 
141  Name.Length = Name.MaximumLength = Buffer->NameLength;
142  Name.Buffer = Buffer->Name;
143  Data.Length = Data.MaximumLength = Buffer->DataLength;
144  Data.Buffer = (PWCHAR)((ULONG_PTR)Buffer + Buffer->DataOffset);
145  if (Data.Length > sizeof(WCHAR) && Data.Buffer[Data.Length / sizeof(WCHAR) - 1] == UNICODE_NULL)
146  Data.Length -= sizeof(WCHAR);
147 
148  AddProvider(&Name, Data.Buffer);
149  }
150 
151  NtClose(hKey);
152  RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
153  return TRUE;
154 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
struct _KEY_VALUE_FULL_INFORMATION KEY_VALUE_FULL_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
uint16_t * PWCHAR
Definition: typedefs.h:54
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define UNICODE_NULL
struct NameRec_ * Name
Definition: cdprocs.h:464
static BOOLEAN AddProvider(IN PCUNICODE_STRING FileSystem, IN PWCHAR DllFile)
Definition: init.c:45
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
Definition: bufpool.h:45
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
#define BufferSize
Definition: classpnp.h:419
LIST_ENTRY ProviderListHead
Definition: init.c:20
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI NtEnumerateValueKey(IN HANDLE KeyHandle, IN ULONG Index, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, OUT PVOID KeyValueInformation, IN ULONG Length, OUT PULONG ResultLength)
Definition: ntapi.c:542
Status
Definition: gdiplustypes.h:24
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define REG_SZ
Definition: layer.c:22

Referenced by InitializeFmIfs().

Variable Documentation

◆ FmIfsInitialized

BOOLEAN FmIfsInitialized = FALSE
static

Definition at line 19 of file init.c.

Referenced by InitializeFmIfs().

◆ ProviderListHead

LIST_ENTRY ProviderListHead