ReactOS 0.4.16-dev-732-g2d1144a
corecrt_internal_lowio.h File Reference
#include <fcntl.h>
#include <io.h>
#include <corecrt_internal_traits.h>
#include <share.h>
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for corecrt_internal_lowio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  __crt_lowio_handle_data
 

Macros

#define LF   10 /* line feed */
 
#define CR   13 /* carriage return */
 
#define CTRLZ   26 /* ctrl-z means eof for text */
 
#define _INTERNAL_BUFSIZ   4096
 
#define _SMALL_BUFSIZ   512
 
#define _msbit(c)   ((c) & 0x80)
 
#define _utf8_is_independent(c)   (_msbit(c) == 0)
 
#define _utf8_is_leadbyte(c)   (_utf8_no_of_trailbytes(static_cast<const unsigned char>(c)) != 0)
 
#define IOINFO_L2E   6
 
#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)
 
#define IOINFO_ARRAYS   128
 
#define _NHANDLE_   (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
 
#define STDIO_HANDLES_COUNT   3
 
#define _pioinfo(i)   (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
 
#define _osfhnd(i)   (_pioinfo(i)->osfhnd)
 
#define _osfile(i)   (_pioinfo(i)->osfile)
 
#define _pipe_lookahead(i)   (_pioinfo(i)->_pipe_lookahead)
 
#define _textmode(i)   (_pioinfo(i)->textmode)
 
#define _tm_unicode(i)   (_pioinfo(i)->unicode)
 
#define _startpos(i)   (_pioinfo(i)->startpos)
 
#define _utf8translations(i)   (_pioinfo(i)->utf8translations)
 
#define _mbBuffer(i)   (_pioinfo(i)->mbBuffer)
 
#define _dbcsBuffer(i)   (_pioinfo(i)->mbBuffer[0])
 
#define _dbcsBufferUsed(i)   (_pioinfo(i)->dbcsBufferUsed)
 
#define _pioinfo_safe(i)   ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)
 
#define _osfile_safe(i)   (_pioinfo_safe(i)->osfile)
 
#define _textmode_safe(i)   (_pioinfo_safe(i)->textmode)
 
#define _tm_unicode_safe(i)   (_pioinfo_safe(i)->unicode)
 
#define _NO_CONSOLE_FILENO   ((intptr_t)-2)
 

Typedefs

typedef char __crt_lowio_pipe_lookahead[3]
 
typedef __crt_lowio_handle_data__crt_lowio_handle_data_array[IOINFO_ARRAYS]
 

Enumerations

enum class  __crt_lowio_text_mode : char { ansi = 0 , utf8 = 1 , utf16le = 2 }
 
enum  : unsigned char {
  FOPEN = 0x01 , FEOFLAG = 0x02 , FCRLF = 0x04 , FPIPE = 0x08 ,
  FNOINHERIT = 0x10 , FAPPEND = 0x20 , FDEV = 0x40 , FTEXT = 0x80
}
 

Functions

__inline char _utf8_no_of_trailbytes (const unsigned char c)
 
int __cdecl _alloc_osfhnd (void)
 
int __cdecl _free_osfhnd (int)
 
int __cdecl __acrt_lowio_set_os_handle (int, intptr_t)
 
 _Success_ (return==0) errno_t __cdecl _sopen_nolock(_Out_ int *_UnlockFlag
 Deletes the virtual mapping and optionally gives back the page & dirty bit.
 
_Check_return_ __crt_lowio_handle_data *__cdecl __acrt_lowio_create_handle_array ()
 
void __cdecl __acrt_lowio_destroy_handle_array (_Pre_maybenull_ _Post_invalid_ _In_reads_opt_(IOINFO_ARRAY_ELTS) __crt_lowio_handle_data *_Array)
 
_Check_return_opt_ errno_t __cdecl __acrt_lowio_ensure_fh_exists (_In_ int _FileHandle)
 
void __cdecl __acrt_lowio_lock_fh (_In_ int _FileHandle)
 
void __cdecl __acrt_lowio_unlock_fh (_In_ int _FileHandle)
 
template<typename Action >
auto __acrt_lowio_lock_fh_and_call (int const fh, Action &&action) -> decltype(action()) throw ()
 
BOOL __cdecl __dcrt_lowio_ensure_console_input_initialized (void)
 
BOOL __cdecl __dcrt_read_console_input (_Out_ PINPUT_RECORD lpBuffer, _In_ DWORD nLength, _Out_ LPDWORD lpNumberOfEventsRead)
 
BOOL __cdecl __dcrt_read_console (_Out_ LPVOID lpBuffer, _In_ DWORD nNumberOfCharsToRead, _Out_ LPDWORD lpNumberOfCharsRead)
 
BOOL __cdecl __dcrt_get_number_of_console_input_events (_Out_ LPDWORD lpcNumberOfEvents)
 
BOOL __cdecl __dcrt_peek_console_input_a (_Out_ PINPUT_RECORD lpBuffer, _In_ DWORD nLength, _Out_ LPDWORD lpNumberOfEventsRead)
 
BOOL __cdecl __dcrt_get_input_console_mode (_Out_ LPDWORD lpMode)
 
BOOL __cdecl __dcrt_set_input_console_mode (_In_ DWORD dwMode)
 
BOOL __cdecl __dcrt_lowio_ensure_console_output_initialized (void)
 
BOOL __cdecl __dcrt_write_console (_In_ void const *lpBuffer, _In_ DWORD nNumberOfCharsToWrite, _Out_ LPDWORD lpNumberOfCharsWritten)
 
_Check_return_ int __cdecl _chsize_nolock (_In_ int _FileHandle, _In_ __int64 _Size)
 
_Check_return_opt_ int __cdecl _close_nolock (_In_ int _FileHandle)
 
_Check_return_opt_ long __cdecl _lseek_nolock (_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin)
 
_Check_return_ int __cdecl _setmode_nolock (_In_ int _FileHandle, _In_ int _Mode)
 
_Check_return_ _Success_ (return >=0 &&return<=_MaxCharCount) int __cdecl _read_nolock(_In_ int _FileHandle
 
_Check_return_ _Out_writes_bytes_ (_MaxCharCount) void *_DstBuf
 
_Check_return_ int __cdecl _write_nolock (_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) const void *_Buf, _In_ unsigned int _MaxCharCount, __crt_cached_ptd_host &_Ptd)
 
_Check_return_opt_ __int64 __cdecl _lseeki64_nolock (_In_ int _FileHandle, _In_ __int64 _Offset, _In_ int _Origin)
 
_Check_return_ int __cdecl _chsize_nolock_internal (_In_ int _FileHandle, _In_ __int64 _Size, _Inout_ __crt_cached_ptd_host &_Ptd)
 
_Check_return_opt_ __int64 __cdecl _lseeki64_nolock_internal (_In_ int _FileHandle, _In_ __int64 _Offset, _In_ int _Origin, _Inout_ __crt_cached_ptd_host &_Ptd)
 
_Check_return_opt_ int __cdecl _close_nolock_internal (_In_ int _FileHandle, _Inout_ __crt_cached_ptd_host &_Ptd)
 
_Check_return_opt_ int __cdecl _close_internal (_In_ int _FileHandle, _Inout_ __crt_cached_ptd_host &_Ptd)
 
_Check_return_opt_ long __cdecl _lseek_internal (_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin, _Inout_ __crt_cached_ptd_host &_Ptd)
 
_Check_return_opt_ __int64 __cdecl _lseeki64_internal (_In_ int _FileHandle, _In_ __int64 _Offset, _In_ int _Origin, _Inout_ __crt_cached_ptd_host &_Ptd)
 
int __cdecl _write_internal (_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) void const *_Buf, _In_ unsigned int _MaxCharCount, _Inout_ __crt_cached_ptd_host &_Ptd)
 

Variables

char _lookuptrailbytes [256]
 
__crt_lowio_handle_data __badioinfo
 
int _umaskval
 
__crt_lowio_handle_data_array __pioinfo
 
int _nhandle
 
_Out_ int_FileHandle
 
_Out_ int _In_z_ char const_FileName
 
_Out_ int _In_z_ char const _In_ int _OpenFlag
 
_Out_ int _In_z_ char const _In_ int _In_ int _ShareFlag
 
_Out_ int _In_z_ char const _In_ int _In_ int _In_ int _PermissionFlag
 
_Out_ int _In_z_ char const _In_ int _In_ int _In_ int _In_ int _SecureFlag
 
const HANDLE _console_invalid_handle = reinterpret_cast<HANDLE>(-1)
 
const HANDLE _console_uninitialized_handle = reinterpret_cast<HANDLE>(-2)
 
_Check_return_ _In_ unsigned int _MaxCharCount
 

Macro Definition Documentation

◆ _dbcsBuffer

#define _dbcsBuffer (   i)    (_pioinfo(i)->mbBuffer[0])

Definition at line 138 of file corecrt_internal_lowio.h.

◆ _dbcsBufferUsed

#define _dbcsBufferUsed (   i)    (_pioinfo(i)->dbcsBufferUsed)

Definition at line 139 of file corecrt_internal_lowio.h.

◆ _INTERNAL_BUFSIZ

#define _INTERNAL_BUFSIZ   4096

Definition at line 27 of file corecrt_internal_lowio.h.

◆ _mbBuffer

#define _mbBuffer (   i)    (_pioinfo(i)->mbBuffer)

Definition at line 137 of file corecrt_internal_lowio.h.

◆ _msbit

#define _msbit (   c)    ((c) & 0x80)

Definition at line 31 of file corecrt_internal_lowio.h.

◆ _NHANDLE_

#define _NHANDLE_   (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)

Definition at line 120 of file corecrt_internal_lowio.h.

◆ _NO_CONSOLE_FILENO

#define _NO_CONSOLE_FILENO   ((intptr_t)-2)

Definition at line 325 of file corecrt_internal_lowio.h.

◆ _osfhnd

#define _osfhnd (   i)    (_pioinfo(i)->osfhnd)

Definition at line 130 of file corecrt_internal_lowio.h.

◆ _osfile

#define _osfile (   i)    (_pioinfo(i)->osfile)

Definition at line 131 of file corecrt_internal_lowio.h.

◆ _osfile_safe

#define _osfile_safe (   i)    (_pioinfo_safe(i)->osfile)

Definition at line 146 of file corecrt_internal_lowio.h.

◆ _pioinfo

#define _pioinfo (   i)    (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))

Definition at line 129 of file corecrt_internal_lowio.h.

◆ _pioinfo_safe

#define _pioinfo_safe (   i)    ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)

Definition at line 145 of file corecrt_internal_lowio.h.

◆ _pipe_lookahead

#define _pipe_lookahead (   i)    (_pioinfo(i)->_pipe_lookahead)

Definition at line 132 of file corecrt_internal_lowio.h.

◆ _SMALL_BUFSIZ

#define _SMALL_BUFSIZ   512

Definition at line 28 of file corecrt_internal_lowio.h.

◆ _startpos

#define _startpos (   i)    (_pioinfo(i)->startpos)

Definition at line 135 of file corecrt_internal_lowio.h.

◆ _textmode

#define _textmode (   i)    (_pioinfo(i)->textmode)

Definition at line 133 of file corecrt_internal_lowio.h.

◆ _textmode_safe

#define _textmode_safe (   i)    (_pioinfo_safe(i)->textmode)

Definition at line 147 of file corecrt_internal_lowio.h.

◆ _tm_unicode

#define _tm_unicode (   i)    (_pioinfo(i)->unicode)

Definition at line 134 of file corecrt_internal_lowio.h.

◆ _tm_unicode_safe

#define _tm_unicode_safe (   i)    (_pioinfo_safe(i)->unicode)

Definition at line 148 of file corecrt_internal_lowio.h.

◆ _utf8_is_independent

#define _utf8_is_independent (   c)    (_msbit(c) == 0)

Definition at line 34 of file corecrt_internal_lowio.h.

◆ _utf8_is_leadbyte

#define _utf8_is_leadbyte (   c)    (_utf8_no_of_trailbytes(static_cast<const unsigned char>(c)) != 0)

Definition at line 67 of file corecrt_internal_lowio.h.

◆ _utf8translations

#define _utf8translations (   i)    (_pioinfo(i)->utf8translations)

Definition at line 136 of file corecrt_internal_lowio.h.

◆ CR

#define CR   13 /* carriage return */

Definition at line 23 of file corecrt_internal_lowio.h.

◆ CTRLZ

#define CTRLZ   26 /* ctrl-z means eof for text */

Definition at line 24 of file corecrt_internal_lowio.h.

◆ IOINFO_ARRAY_ELTS

#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)

Definition at line 114 of file corecrt_internal_lowio.h.

◆ IOINFO_ARRAYS

#define IOINFO_ARRAYS   128

Definition at line 117 of file corecrt_internal_lowio.h.

◆ IOINFO_L2E

#define IOINFO_L2E   6

Definition at line 111 of file corecrt_internal_lowio.h.

◆ LF

#define LF   10 /* line feed */

Definition at line 22 of file corecrt_internal_lowio.h.

◆ STDIO_HANDLES_COUNT

#define STDIO_HANDLES_COUNT   3

Definition at line 124 of file corecrt_internal_lowio.h.

Typedef Documentation

◆ __crt_lowio_handle_data_array

typedef __crt_lowio_handle_data* __crt_lowio_handle_data_array[IOINFO_ARRAYS]

Definition at line 150 of file corecrt_internal_lowio.h.

◆ __crt_lowio_pipe_lookahead

typedef char __crt_lowio_pipe_lookahead[3]

Definition at line 89 of file corecrt_internal_lowio.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : unsigned char
Enumerator
FOPEN 
FEOFLAG 
FCRLF 
FPIPE 
FNOINHERIT 
FAPPEND 
FDEV 
FTEXT 

Definition at line 77 of file corecrt_internal_lowio.h.

78{
79 FOPEN = 0x01, // file handle open
80 FEOFLAG = 0x02, // end of file has been encountered
81 FCRLF = 0x04, // CR-LF across read buffer (in text mode)
82 FPIPE = 0x08, // file handle refers to a pipe
83 FNOINHERIT = 0x10, // file handle opened _O_NOINHERIT
84 FAPPEND = 0x20, // file handle opened O_APPEND
85 FDEV = 0x40, // file handle refers to device
86 FTEXT = 0x80, // file handle is in text mode
87};

◆ __crt_lowio_text_mode

Enumerator
ansi 
utf8 
utf16le 

Definition at line 69 of file corecrt_internal_lowio.h.

70{
71 ansi = 0, // Regular text
72 utf8 = 1, // UTF-8 encoded
73 utf16le = 2, // UTF-16LE encoded
74};

Function Documentation

◆ __acrt_lowio_create_handle_array()

_Check_return_ __crt_lowio_handle_data *__cdecl __acrt_lowio_create_handle_array ( )

Definition at line 13 of file osfinfo.cpp.

14{
15 __crt_unique_heap_ptr<__crt_lowio_handle_data> array(_calloc_crt_t(
18
19 if (!array)
20 return nullptr;
21
22 __crt_lowio_handle_data* const first = array.get();
24 for (auto it = first; it != last; ++it)
25 {
27 it->osfhnd = reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE);
28 it->startpos = 0;
29 it->osfile = 0;
30 it->textmode = __crt_lowio_text_mode::ansi;
31 it->_pipe_lookahead[0] = LF;
32 it->_pipe_lookahead[1] = LF;
33 it->_pipe_lookahead[2] = LF;
34 it->unicode = false;
35 it->utf8translations = false;
36 it->dbcsBufferUsed = false;
37 for (int i = 0; i < sizeof(it->mbBuffer); ++i)
38 {
39 it->mbBuffer[i] = '\0';
40 }
41 }
42
43 return array.detach();
44}
#define _CORECRT_SPINCOUNT
BOOL WINAPI __acrt_InitializeCriticalSectionEx(_Out_ LPCRITICAL_SECTION critical_section, _In_ DWORD spin_count, _In_ DWORD flags)
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
const GLint * first
Definition: glext.h:5794
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
static UINT UINT last
Definition: font.c:45
#define IOINFO_ARRAY_ELTS
Definition: internal.h:69
#define LF
Definition: telnetd.h:24
int intptr_t
Definition: vcruntime.h:134

Referenced by __acrt_lowio_ensure_fh_exists(), and _alloc_osfhnd().

◆ __acrt_lowio_destroy_handle_array()

◆ __acrt_lowio_ensure_fh_exists()

◆ __acrt_lowio_lock_fh()

◆ __acrt_lowio_lock_fh_and_call()

template<typename Action >
auto __acrt_lowio_lock_fh_and_call ( int const  fh,
Action &&  action 
) -> decltype(action())
throw (
)

Definition at line 221 of file corecrt_internal_lowio.h.

223 {
224 return __crt_seh_guarded_call<decltype(action())>()(
225 [fh]() { __acrt_lowio_lock_fh(fh); },
226 action,
227 [fh]() { __acrt_lowio_unlock_fh(fh); });
228 }
void __cdecl __acrt_lowio_lock_fh(_In_ int _FileHandle)
void __cdecl __acrt_lowio_unlock_fh(_In_ int _FileHandle)
const WCHAR * action
Definition: action.c:7509

Referenced by _chsize_s_internal(), _close_internal(), _commit(), _dup_internal(), _eof(), and common_fstat().

◆ __acrt_lowio_set_os_handle()

int __cdecl __acrt_lowio_set_os_handle ( int  fh,
intptr_t  value 
)

Definition at line 195 of file osfinfo.cpp.

196{
197 if (fh >= 0 &&
198 static_cast<unsigned>(fh) < static_cast<unsigned>(_nhandle) &&
199 _osfhnd(fh) == reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE))
200 {
202 {
203 HANDLE const handle_value = reinterpret_cast<HANDLE>(value);
204 switch (fh)
205 {
206 case 0: SetStdHandle(STD_INPUT_HANDLE, handle_value); break;
207 case 1: SetStdHandle(STD_OUTPUT_HANDLE, handle_value); break;
208 case 2: SetStdHandle(STD_ERROR_HANDLE, handle_value); break;
209 }
210 }
211
212 _osfhnd(fh) = value;
213 return 0 ;
214 }
215 else
216 {
217 errno = EBADF; // Bad handle
218 _doserrno = 0; // This is not an OS error
219 return -1;
220 }
221}
#define EBADF
Definition: acclib.h:82
#define _osfhnd(i)
int _nhandle
Definition: ioinit.cpp:34
@ _crt_console_app
_ACRTIMP _crt_app_type __cdecl _query_app_type(void)
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
Definition: console.c:1213
#define _doserrno
Definition: stdlib.h:131
#define errno
Definition: errno.h:18
Definition: pdh_main.c:94
#define STD_OUTPUT_HANDLE
Definition: winbase.h:294
#define STD_INPUT_HANDLE
Definition: winbase.h:293
#define STD_ERROR_HANDLE
Definition: winbase.h:295

Referenced by _dup2_nolock_internal(), _open_osfhandle(), _pipe(), _wsopen_nolock(), and duplicate_osfhnd().

◆ __acrt_lowio_unlock_fh()

◆ __dcrt_get_input_console_mode()

BOOL __cdecl __dcrt_get_input_console_mode ( _Out_ LPDWORD  lpMode)

Definition at line 136 of file initconin.cpp.

139{
141 [lpMode]()
142 {
143 return ::GetConsoleMode(
145 lpMode
146 );
147 });
148}
static BOOL console_input_reopen_and_retry(Func const &fp)
Definition: initconin.cpp:56
static HANDLE __dcrt_lowio_console_input_handle
Definition: initconin.cpp:16

Referenced by _cgetws_s(), _getch_nolock(), and _getwch_nolock().

◆ __dcrt_get_number_of_console_input_events()

BOOL __cdecl __dcrt_get_number_of_console_input_events ( _Out_ LPDWORD  lpcNumberOfEvents)

Definition at line 104 of file initconin.cpp.

107{
109 [lpcNumberOfEvents]()
110 {
111 return ::GetNumberOfConsoleInputEvents(
113 lpcNumberOfEvents
114 );
115 });
116}

Referenced by _kbhit_nolock().

◆ __dcrt_lowio_ensure_console_input_initialized()

BOOL __cdecl __dcrt_lowio_ensure_console_input_initialized ( void  )

Definition at line 31 of file initconin.cpp.

32{
34 {
36 }
37
39 {
40 return FALSE;
41 }
42 return TRUE;
43}
const HANDLE _console_invalid_handle
const HANDLE _console_uninitialized_handle
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static void __dcrt_lowio_initialize_console_input()
Definition: initconin.cpp:19

Referenced by _cgetws_s(), _getch_nolock(), _getwch_nolock(), and _kbhit_nolock().

◆ __dcrt_lowio_ensure_console_output_initialized()

BOOL __cdecl __dcrt_lowio_ensure_console_output_initialized ( void  )

Definition at line 31 of file initcon.cpp.

32{
34 {
36 }
37
39 {
40 return FALSE;
41 }
42 return TRUE;
43}
static void __dcrt_lowio_initialize_console_output()
Definition: initcon.cpp:19
static HANDLE __dcrt_lowio_console_output_handle
Definition: initcon.cpp:16

Referenced by _cputws(), and _putwch_nolock().

◆ __dcrt_peek_console_input_a()

BOOL __cdecl __dcrt_peek_console_input_a ( _Out_ PINPUT_RECORD  lpBuffer,
_In_ DWORD  nLength,
_Out_ LPDWORD  lpNumberOfEventsRead 
)

Definition at line 118 of file initconin.cpp.

123{
126 {
127 return ::PeekConsoleInputA(
129 lpBuffer,
130 nLength,
132 );
133 });
134}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
_In_ DWORD _Out_ LPDWORD lpNumberOfEventsRead
Definition: wincon.h:474
_In_ DWORD nLength
Definition: wincon.h:473

Referenced by _kbhit_nolock().

◆ __dcrt_read_console()

BOOL __cdecl __dcrt_read_console ( _Out_ LPVOID  lpBuffer,
_In_ DWORD  nNumberOfCharsToRead,
_Out_ LPDWORD  lpNumberOfCharsRead 
)

Definition at line 85 of file initconin.cpp.

90{
92 [lpBuffer, nNumberOfCharsToRead, lpNumberOfCharsRead]()
93 {
94 return ::ReadConsoleW(
98 lpNumberOfCharsRead,
99 nullptr
100 );
101 });
102}
_In_ DWORD nNumberOfCharsToRead
Definition: wincon.h:491

Referenced by _cgetws_s().

◆ __dcrt_read_console_input()

BOOL __cdecl __dcrt_read_console_input ( _Out_ PINPUT_RECORD  lpBuffer,
_In_ DWORD  nLength,
_Out_ LPDWORD  lpNumberOfEventsRead 
)

Definition at line 67 of file initconin.cpp.

72{
75 {
76 return ::ReadConsoleInputW(
79 nLength,
81 );
82 });
83}

Referenced by _getch_nolock(), and _getwch_nolock().

◆ __dcrt_set_input_console_mode()

BOOL __cdecl __dcrt_set_input_console_mode ( _In_ DWORD  dwMode)

Definition at line 150 of file initconin.cpp.

153{
155 [dwMode]()
156 {
157 return ::SetConsoleMode(
159 dwMode
160 );
161 });
162}

Referenced by _cgetws_s(), _getch_nolock(), and _getwch_nolock().

◆ __dcrt_write_console()

BOOL __cdecl __dcrt_write_console ( _In_ void const lpBuffer,
_In_ DWORD  nNumberOfCharsToWrite,
_Out_ LPDWORD  lpNumberOfCharsWritten 
)

Definition at line 67 of file initcon.cpp.

72{
74 [lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten]()
75 {
76 return ::WriteConsoleW(
79 nNumberOfCharsToWrite,
80 lpNumberOfCharsWritten,
81 nullptr);
82 });
83}
static BOOL console_output_reopen_and_retry(Func const &fp)
Definition: initcon.cpp:56

Referenced by _cputws(), and _putwch_nolock().

◆ _alloc_osfhnd()

int __cdecl _alloc_osfhnd ( void  )

Definition at line 116 of file osfinfo.cpp.

117{
119 int result = -1;
120 __try
121 {
122 // Search the arrays of file objects, in order, looking for the first
123 // free entry. The compound index of this free entry is the return
124 // value.
125 //
126 // The compound index of the file object entry *(__pioinfo[i] + j) is
127 // k = i * IOINFO_ARRAY_ELTS + j.
128 for (int i = 0; i < IOINFO_ARRAYS; ++i)
129 {
130 // If this __crt_lowio_handle_data array does not yet exist, create a new one:
131 if (!__pioinfo[i])
132 {
134 if (!__pioinfo[i])
135 __leave;
136
138
139 // The first element of the newly allocated array of handle data
140 // objects is our first free entry. Note that since we hold the
141 // index lock, no one else can allocate this handle.
142 int const fh = i * IOINFO_ARRAY_ELTS;
143
145 _osfile(fh) = FOPEN;
146 result = fh;
147 __leave;
148 }
149
150 // Otherwise, this file object array already exists. Search it looking
151 // for the first free entry:
154 for (__crt_lowio_handle_data* pio = first; pio != last; ++pio)
155 {
156 if (pio->osfile & FOPEN)
157 continue;
158
159 // Another thread may have grabbed this file handle out from
160 // under us while we waited for the lock. If so, continue on
161 // searching through the array.
162 //
163 // CRT_REFACTOR TODO: Resolve lowio synchronization issues.
164 EnterCriticalSection(&pio->lock);
165 if ((pio->osfile & FOPEN) != 0)
166 {
167 LeaveCriticalSection(&pio->lock);
168 continue;
169 }
170
171 // Otherwise, this entry is ours: we hold the lock, so we can
172 // initialize it and return its handle:
173 int const fh = i * IOINFO_ARRAY_ELTS + static_cast<int>(pio - first);
174 _osfile(fh) = FOPEN;
175 _osfhnd(fh) = reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE);
176 result = fh;
177 __leave;
178 }
179 }
180
181 // All entries are in use if we fall out of the loop. return -1 in this case (which result is already set to)
182 }
184 {
186 }
188 return result;
189}
void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock)
Definition: locks.cpp:57
@ __acrt_lowio_index_lock
#define IOINFO_ARRAYS
__acrt_lock(__acrt_heap_lock)
#define FOPEN
GLuint64EXT * result
Definition: glext.h:11304
static ioinfo ** __pioinfo
Definition: file.c:47
void __cdecl __acrt_lowio_lock_fh(int const fh)
Definition: osfinfo.cpp:340
__crt_lowio_handle_data *__cdecl __acrt_lowio_create_handle_array()
Definition: osfinfo.cpp:13
#define __try
Definition: pseh2_64.h:172
#define __leave
Definition: pseh2_64.h:176
#define __endtry
Definition: pseh2_64.h:175
#define __finally
Definition: pseh2_64.h:174
#define _osfile(i)
Definition: internal.h:72
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by _dup_nolock_internal(), _open_osfhandle(), _pipe(), and _wsopen_nolock().

◆ _chsize_nolock()

_Check_return_ int __cdecl _chsize_nolock ( _In_ int  _FileHandle,
_In_ __int64  _Size 
)

◆ _chsize_nolock_internal()

_Check_return_ int __cdecl _chsize_nolock_internal ( _In_ int  _FileHandle,
_In_ __int64  _Size,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

◆ _close_internal()

_Check_return_opt_ int __cdecl _close_internal ( _In_ int  _FileHandle,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

Referenced by _fclose_nolock_internal().

◆ _close_nolock()

_Check_return_opt_ int __cdecl _close_nolock ( _In_ int  _FileHandle)

Referenced by _wsopen_nolock().

◆ _close_nolock_internal()

_Check_return_opt_ int __cdecl _close_nolock_internal ( _In_ int  _FileHandle,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

Referenced by _dup2_nolock_internal().

◆ _free_osfhnd()

int __cdecl _free_osfhnd ( int  fh)

Definition at line 227 of file osfinfo.cpp.

228{
229 if (fh >= 0 &&
230 static_cast<unsigned>(fh) < static_cast<unsigned>(_nhandle) &&
231 (_osfile(fh) & FOPEN) &&
232 _osfhnd(fh) != reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE))
233 {
235 {
236 switch (fh)
237 {
238 case 0: SetStdHandle(STD_INPUT_HANDLE, nullptr); break;
239 case 1: SetStdHandle(STD_OUTPUT_HANDLE, nullptr); break;
240 case 2: SetStdHandle(STD_ERROR_HANDLE, nullptr); break;
241 }
242 }
243
244 _osfhnd(fh) = reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE);
245 return 0;
246 }
247 else
248 {
249 errno = EBADF; // Bad handle
250 _doserrno = 0; // This is not an OS error
251 return -1;
252 }
253}

Referenced by _close_nolock_internal(), and _wsopen_nolock().

◆ _lseek_internal()

_Check_return_opt_ long __cdecl _lseek_internal ( _In_ int  _FileHandle,
_In_ long  _Offset,
_In_ int  _Origin,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

Referenced by _rewind_internal().

◆ _lseek_nolock()

_Check_return_opt_ long __cdecl _lseek_nolock ( _In_ int  _FileHandle,
_In_ long  _Offset,
_In_ int  _Origin 
)

◆ _lseeki64_internal()

_Check_return_opt_ __int64 __cdecl _lseeki64_internal ( _In_ int  _FileHandle,
_In_ __int64  _Offset,
_In_ int  _Origin,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

◆ _lseeki64_nolock()

◆ _lseeki64_nolock_internal()

_Check_return_opt_ __int64 __cdecl _lseeki64_nolock_internal ( _In_ int  _FileHandle,
_In_ __int64  _Offset,
_In_ int  _Origin,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

◆ _Out_writes_bytes_()

_Check_return_ _Out_writes_bytes_ ( _MaxCharCount  )

◆ _setmode_nolock()

_Check_return_ int __cdecl _setmode_nolock ( _In_ int  _FileHandle,
_In_ int  _Mode 
)

Referenced by _chsize_nolock_internal().

◆ _Success_() [1/2]

_Check_return_ _Success_ ( return >=0 &&return<=  _MaxCharCount)

◆ _Success_() [2/2]

_Success_ ( return  = = 0)

Deletes the virtual mapping and optionally gives back the page & dirty bit.

Parameters
Process- The process this address belongs to, or NULL if system address.
Address- The address to unmap.
WasDirty- Optional param receiving the dirty bit of the PTE.
Page- Optional param receiving the page number previously mapped to this address.
Returns
Whether there was actually a page mapped at the given address.

Definition at line 57 of file firmware.c.

207{
210
211 /* Check input parameters */
212 if (FirmwareType == NULL)
213 {
215 return FALSE;
216 }
217
218 /* Query firmware type */
220 &BootInfo,
221 sizeof(BootInfo),
222 0);
223 if (!NT_SUCCESS(Status))
224 {
226 return FALSE;
227 }
228
229 *FirmwareType = BootInfo.FirmwareType;
230 return TRUE;
231}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
Status
Definition: gdiplustypes.h:25
@ SystemBootEnvironmentInformation
Definition: extypes.h:307
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)

◆ _utf8_no_of_trailbytes()

__inline char _utf8_no_of_trailbytes ( const unsigned char  c)

Definition at line 45 of file corecrt_internal_lowio.h.

46{
47 return _lookuptrailbytes[c];
48}
char _lookuptrailbytes[256]
Definition: read.cpp:20
#define c
Definition: ke_i.h:80

Referenced by common_ftell_translated_utf8_nolock(), throw(), and write_double_translated_ansi_nolock().

◆ _write_internal()

int __cdecl _write_internal ( _In_ int  _FileHandle,
_In_reads_bytes_(_MaxCharCount) void const _Buf,
_In_ unsigned int  _MaxCharCount,
_Inout_ __crt_cached_ptd_host &  _Ptd 
)

◆ _write_nolock()

_Check_return_ int __cdecl _write_nolock ( _In_ int  _FileHandle,
_In_reads_bytes_(_MaxCharCount) const void _Buf,
_In_ unsigned int  _MaxCharCount,
__crt_cached_ptd_host &  _Ptd 
)

Variable Documentation

◆ __badioinfo

◆ __pioinfo

Definition at line 121 of file file.c.

Referenced by __acrt_uninitialize_lowio().

◆ _console_invalid_handle

◆ _console_uninitialized_handle

◆ _FileHandle

_Out_ int * _FileHandle

Definition at line 183 of file corecrt_internal_lowio.h.

Referenced by _futime(), and _wsopen_dispatch().

◆ _FileName

◆ _lookuptrailbytes

char _lookuptrailbytes[256]
extern

Definition at line 20 of file read.cpp.

Referenced by _utf8_no_of_trailbytes().

◆ _MaxCharCount

Definition at line 280 of file corecrt_internal_lowio.h.

◆ _nhandle

◆ _OpenFlag

Definition at line 185 of file corecrt_internal_lowio.h.

◆ _PermissionFlag

Definition at line 187 of file corecrt_internal_lowio.h.

◆ _SecureFlag

Definition at line 188 of file corecrt_internal_lowio.h.

◆ _ShareFlag

Definition at line 186 of file corecrt_internal_lowio.h.

◆ _umaskval

int _umaskval
extern

Definition at line 15 of file umask.cpp.

Referenced by _umask_s(), and decode_options().