ReactOS  0.4.14-dev-599-g2d4d3f5
misc.c File Reference
#include "rfsd.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

ULONG RfsdLog2 (ULONG Value)
 
LARGE_INTEGER RfsdSysTime (IN ULONG i_time)
 
ULONG RfsdInodeTime (IN LARGE_INTEGER SysTime)
 
ULONG RfsdMbsToUnicode (IN OUT PUNICODE_STRING Unicode, IN PANSI_STRING Mbs)
 
ULONG RfsdUnicodeToMbs (IN OUT PANSI_STRING Mbs, IN PUNICODE_STRING Unicode)
 
ULONG RfsdOEMToUnicodeSize (IN PANSI_STRING Oem)
 
NTSTATUS RfsdOEMToUnicode (IN OUT PUNICODE_STRING Unicode, IN POEM_STRING Oem)
 
ULONG RfsdUnicodeToOEMSize (IN PUNICODE_STRING Unicode)
 
NTSTATUS RfsdUnicodeToOEM (IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
 

Variables

PRFSD_GLOBAL RfsdGlobal
 

Function Documentation

◆ RfsdInodeTime()

ULONG RfsdInodeTime ( IN LARGE_INTEGER  SysTime)

Definition at line 59 of file misc.c.

60 {
61  ULONG RfsdTime;
62 
63  PAGED_CODE();
64 
65  RtlTimeToSecondsSince1970(&SysTime, &RfsdTime);
66 
67  return RfsdTime;
68 }
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)
#define PAGED_CODE()
Definition: video.h:57
unsigned int ULONG
Definition: retypes.h:1

Referenced by RfsdSetInformation(), and RfsdSupersedeOrOverWriteFile().

◆ RfsdLog2()

ULONG RfsdLog2 ( ULONG  Value)

Definition at line 30 of file misc.c.

31 {
32  ULONG Order = 0;
33 
34  PAGED_CODE();
35 
36  ASSERT(Value > 0);
37 
38  while (Value) {
39  Order++;
40  Value >>= 1;
41  }
42 
43  return (Order - 1);
44 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define PAGED_CODE()
Definition: video.h:57
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned int ULONG
Definition: retypes.h:1

◆ RfsdMbsToUnicode()

ULONG RfsdMbsToUnicode ( IN OUT PUNICODE_STRING  Unicode,
IN PANSI_STRING  Mbs 
)

Definition at line 71 of file misc.c.

74 {
75  ULONG Length = 0;
76  int i, mbc = 0;
77  WCHAR uc;
78 
79  /* Count the length of the resulting Unicode. */
80  for (i = 0; i < Mbs->Length; i += mbc) {
81 
82  mbc = PAGE_TABLE->char2uni(
83  (PUCHAR)&(Mbs->Buffer[i]),
84  Mbs->Length - i,
85  &uc
86  );
87 
88  if (mbc <= 0) {
89 
90  /* Invalid character. */
91  return 0;
92  }
93 
94  Length += 2;
95  }
96 
97  if (Unicode) {
98  if (Unicode->MaximumLength < Length) {
99 
100  DbgBreak();
101  return 0;
102  }
103 
104  Unicode->Length = 0;
105  mbc = 0;
106 
107  for (i = 0; i < Mbs->Length; i += mbc) {
108 
109  mbc = PAGE_TABLE->char2uni(
110  (PUCHAR)&(Mbs->Buffer[i]),
111  Mbs->Length - i,
112  &uc
113  );
114  Unicode->Buffer[Unicode->Length/2] = uc;
115 
116  Unicode->Length += 2;
117  }
118  }
119 
120  return Length;
121 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define PAGE_TABLE
Definition: rfsd.h:442
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
char mbc
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46

Referenced by RfsdOEMToUnicode(), and RfsdOEMToUnicodeSize().

◆ RfsdOEMToUnicode()

NTSTATUS RfsdOEMToUnicode ( IN OUT PUNICODE_STRING  Unicode,
IN POEM_STRING  Oem 
)

Definition at line 195 of file misc.c.

198 {
200 
201  PAGED_CODE();
202 
203  if (PAGE_TABLE) {
204  Status = RfsdMbsToUnicode(Unicode, Oem);
205 
206  if (Status == Unicode->Length) {
208  } else {
210  }
211 
212  goto errorout;
213  }
214 
215 
217  Unicode,
218  Oem,
219  FALSE );
220 
221  if (!NT_SUCCESS(Status))
222  {
223  DbgBreak();
224  goto errorout;
225  }
226 
227 errorout:
228 
229  return Status;
230 }
LONG NTSTATUS
Definition: precomp.h:26
#define PAGE_TABLE
Definition: rfsd.h:442
ULONG RfsdMbsToUnicode(IN OUT PUNICODE_STRING Unicode, IN PANSI_STRING Mbs)
Definition: misc.c:71
#define PAGED_CODE()
Definition: video.h:57
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
Status
Definition: gdiplustypes.h:24
#define DbgBreak()
Definition: ext2fs.h:46
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RfsdDirectoryCallback(), RfsdInitializeVcb(), and RfsdScanDirCallback().

◆ RfsdOEMToUnicodeSize()

ULONG RfsdOEMToUnicodeSize ( IN PANSI_STRING  Oem)

Definition at line 183 of file misc.c.

186 {
187  if (PAGE_TABLE) {
188  return RfsdMbsToUnicode(NULL, Oem);
189  }
190 
192 }
#define PAGE_TABLE
Definition: rfsd.h:442
ULONG RfsdMbsToUnicode(IN OUT PUNICODE_STRING Unicode, IN PANSI_STRING Mbs)
Definition: misc.c:71
smooth NULL
Definition: ftsmooth.c:416
#define RtlOemStringToCountedUnicodeSize(STRING)

Referenced by RfsdDirectoryCallback(), and RfsdScanDirCallback().

◆ RfsdSysTime()

LARGE_INTEGER RfsdSysTime ( IN ULONG  i_time)

Definition at line 47 of file misc.c.

48 {
49  LARGE_INTEGER SysTime;
50 
51  PAGED_CODE();
52 
53  RtlSecondsSince1970ToTime(i_time, &SysTime);
54 
55  return SysTime;
56 }
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define PAGED_CODE()
Definition: video.h:57

Referenced by RfsdFastIoQueryBasicInfo(), RfsdFastIoQueryNetworkOpenInfo(), RfsdProcessDirEntry(), and RfsdQueryInformation().

◆ RfsdUnicodeToMbs()

ULONG RfsdUnicodeToMbs ( IN OUT PANSI_STRING  Mbs,
IN PUNICODE_STRING  Unicode 
)

Definition at line 124 of file misc.c.

127 {
128  ULONG Length = 0;
129  UCHAR mbs[0x10];
130  int i, mbc;
131 
132  /* Count the length of the resulting mbc-8. */
133  for (i = 0; i < (Unicode->Length / 2); i++) {
134 
135  RtlZeroMemory(mbs, 0x10);
136  mbc = PAGE_TABLE->uni2char(
137  Unicode->Buffer[i],
138  mbs,
139  0x10
140  );
141 
142  if (mbc <= 0) {
143 
144  /* Invalid character. */
145  return 0;
146  }
147 
148  Length += mbc;
149  }
150 
151  if (Mbs) {
152 
153  if (Mbs->MaximumLength < Length) {
154 
155  DbgBreak();
156  return 0;
157  }
158 
159  Mbs->Length = 0;
160 
161  for (i = 0; i < (Unicode->Length / 2); i++) {
162 
163  mbc = PAGE_TABLE->uni2char(
164  Unicode->Buffer[i],
165  mbs,
166  0x10
167  );
168 
170  (PUCHAR)&(Mbs->Buffer[Mbs->Length]),
171  &mbs[0],
172  mbc
173  );
174 
175  Mbs->Length += (USHORT)mbc;
176  }
177  }
178 
179  return Length;
180 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned char * PUCHAR
Definition: retypes.h:3
#define PAGE_TABLE
Definition: rfsd.h:442
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
char mbc
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DbgBreak()
Definition: ext2fs.h:46
char mbs[5]

Referenced by RfsdUnicodeToOEM(), and RfsdUnicodeToOEMSize().

◆ RfsdUnicodeToOEM()

NTSTATUS RfsdUnicodeToOEM ( IN OUT POEM_STRING  Oem,
IN PUNICODE_STRING  Unicode 
)

Definition at line 246 of file misc.c.

249 {
251 
252  PAGED_CODE();
253 
254  if (PAGE_TABLE) {
255 
256  Status = RfsdUnicodeToMbs(Oem, Unicode);
257 
258  if (Status == Oem->Length) {
260  } else {
262  }
263 
264  goto errorout;
265  }
266 
268  Oem,
269  Unicode,
270  FALSE );
271 
272  if (!NT_SUCCESS(Status))
273  {
274  DbgBreak();
275  goto errorout;
276  }
277 
278 errorout:
279 
280  return Status;
281 }
LONG NTSTATUS
Definition: precomp.h:26
#define PAGE_TABLE
Definition: rfsd.h:442
#define PAGED_CODE()
Definition: video.h:57
ULONG RfsdUnicodeToMbs(IN OUT PANSI_STRING Mbs, IN PUNICODE_STRING Unicode)
Definition: misc.c:124
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
Status
Definition: gdiplustypes.h:24
#define DbgBreak()
Definition: ext2fs.h:46
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RfsdAllocateFcb(), RfsdSetRenameInfo(), and RfsdSetVolumeInformation().

◆ RfsdUnicodeToOEMSize()

ULONG RfsdUnicodeToOEMSize ( IN PUNICODE_STRING  Unicode)

Definition at line 233 of file misc.c.

236 {
237  if (PAGE_TABLE) {
238 
239  return RfsdUnicodeToMbs(NULL, Unicode);
240  }
241 
242  return RtlxUnicodeStringToOemSize(Unicode);
243 }
#define PAGE_TABLE
Definition: rfsd.h:442
ULONG RfsdUnicodeToMbs(IN OUT PANSI_STRING Mbs, IN PUNICODE_STRING Unicode)
Definition: misc.c:124
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI ULONG NTAPI RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString)
Definition: unicode.c:1080

Referenced by RfsdAllocateFcb(), and RfsdSetRenameInfo().

Variable Documentation

◆ RfsdGlobal

PRFSD_GLOBAL RfsdGlobal

Definition at line 17 of file init.c.