ReactOS 0.4.15-dev-5666-gc548b97
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;
53
54 hMod = LoadLibraryW(DllFile);
55 if (!hMod)
56 goto cleanup;
57
59 + FileSystem->Length + sizeof(UNICODE_NULL);
61 RtlGetProcessHeap(),
62 0,
64 if (!Provider)
65 goto cleanup;
67
68 /* Get function pointers */
69 Provider->Chkdsk = (PULIB_CHKDSK)GetProcAddress(hMod, "Chkdsk");
70 //Provider->ChkdskEx = (PULIB_CHKDSKEX)GetProcAddress(hMod, "ChkdskEx");
71 //Provider->Extend = (PULIB_EXTEND)GetProcAddress(hMod, "Extend");
72 Provider->Format = (PULIB_FORMAT)GetProcAddress(hMod, "Format");
73 //Provider->FormatEx = (PULIB_FORMATEX)GetProcAddress(hMod, "FormatEx");
74
75 RtlCopyMemory(Provider->Name, FileSystem->Buffer, FileSystem->Length);
76
78 ret = TRUE;
79
81 if (!ret)
82 {
83 if (hMod)
84 FreeLibrary(hMod);
85 if (Provider)
86 RtlFreeHeap(RtlGetProcessHeap(), 0, Provider);
87 }
88 return ret;
89}
unsigned char BOOLEAN
PWCHAR FileSystem
Definition: format.c:72
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
LIST_ENTRY ProviderListHead
Definition: init.c:20
struct _IFS_PROVIDER * PIFS_PROVIDER
static void cleanup(void)
Definition: main.c:1335
#define InsertTailList(ListHead, Entry)
BOOLEAN(NTAPI * PULIB_FORMAT)(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN QuickFormat, IN BOOLEAN BackwardCompatible, IN MEDIA_TYPE MediaType, IN PUNICODE_STRING Label, IN ULONG ClusterSize)
Definition: fmifs.h:217
BOOLEAN(NTAPI * PULIB_CHKDSK)(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
Definition: fmifs.h:201
unsigned int ULONG
Definition: retypes.h:1
#define UNICODE_NULL
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439

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}
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ InitializeFmIfs()

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

Definition at line 161 of file init.c.

165{
166 switch (dwReason)
167 {
169 if (FmIfsInitialized == FALSE)
170 {
171 if (InitializeFmIfsOnce() == FALSE)
172 return FALSE;
173
175 }
176 break;
177
179 break;
180
182 break;
183
185 break;
186 }
187
188 return TRUE;
189}
DWORD dwReason
Definition: misc.cpp:154
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define DLL_THREAD_ATTACH
Definition: compat.h:132
static BOOLEAN FmIfsInitialized
Definition: init.c:19
static BOOLEAN InitializeFmIfsOnce(VOID)
Definition: init.c:93

◆ InitializeFmIfsOnce()

static BOOLEAN InitializeFmIfsOnce ( VOID  )
static

Definition at line 93 of file init.c.

94{
97 = RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\SOFTWARE\\ReactOS\\ReactOS\\CurrentVersion\\IFS");
102 ULONG i = 0;
106
108
109 /* Read IFS providers from HKLM\SOFTWARE\ReactOS\ReactOS\CurrentVersion\IFS */
113 return TRUE;
114 else if (!NT_SUCCESS(Status))
115 return FALSE;
116
118 RtlGetProcessHeap(),
119 0,
120 BufferSize);
121 if (!Buffer)
122 {
123 NtClose(hKey);
124 return FALSE;
125 }
126
127 while (TRUE)
128 {
130 hKey,
131 i++,
133 Buffer,
135 &RequiredSize);
137 continue;
138 else if (!NT_SUCCESS(Status))
139 break;
140 else if (Buffer->Type != REG_SZ)
141 continue;
142
143 Name.Length = Name.MaximumLength = Buffer->NameLength;
144 Name.Buffer = Buffer->Name;
145 Data.Length = Data.MaximumLength = Buffer->DataLength;
146 Data.Buffer = (PWCHAR)((ULONG_PTR)Buffer + Buffer->DataOffset);
147 if (Data.Length > sizeof(WCHAR) && Data.Buffer[Data.Length / sizeof(WCHAR) - 1] == UNICODE_NULL)
148 Data.Length -= sizeof(WCHAR);
149
150 AddProvider(&Name, Data.Buffer);
151 }
152
153 NtClose(hKey);
154 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
155 return TRUE;
156}
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define BufferSize
Definition: mmc.h:75
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:34
static BOOLEAN AddProvider(IN PCUNICODE_STRING FileSystem, IN PWCHAR DllFile)
Definition: init.c:45
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
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 REG_SZ
Definition: layer.c:22
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
struct _KEY_VALUE_FULL_INFORMATION KEY_VALUE_FULL_INFORMATION
@ KeyValueFullInformation
Definition: nt_native.h:1181
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
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
#define L(x)
Definition: ntvdm.h:50
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
__wchar_t WCHAR
Definition: xmlstorage.h:180

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