ReactOS  0.4.14-dev-55-g2da92ac
internal.h File Reference
#include <crtdefs.h>
#include <stdarg.h>
#include <limits.h>
#include <windef.h>
#include <winbase.h>
#include <crtdbg.h>
#include <errno.h>
Include dependency graph for internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ioinfo
 
struct  _iobuf
 
struct  _startupinfo
 

Macros

#define __INTERNAL_FUNC_DEFINED
 
#define __IOINFO_TM_ANSI   0
 
#define __IOINFO_TM_UTF8   1
 
#define __IOINFO_TM_UTF16LE   2
 
#define IOINFO_ARRAY_ELTS   (1 << 5)
 
#define _pioinfo(i)   (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
 
#define _osfile(i)   (_pioinfo(i)->osfile)
 
#define _pipech2(i)   (_pioinfo(i)->pipech2)
 
#define _textmode(i)   (_pioinfo(i)->textmode)
 
#define _tm_unicode(i)   (_pioinfo(i)->unicode)
 
#define _pioinfo_safe(i)   ((((i) != -1) && ((i) != -2)) ? _pioinfo(i) : &__badioinfo)
 
#define _osfhnd_safe(i)   (_pioinfo_safe(i)->osfhnd)
 
#define _osfile_safe(i)   (_pioinfo_safe(i)->osfile)
 
#define _pipech_safe(i)   (_pioinfo_safe(i)->pipech)
 
#define _pipech2_safe(i)   (_pioinfo_safe(i)->pipech2)
 
#define _textmode_safe(i)   (_pioinfo_safe(i)->textmode)
 
#define _tm_unicode_safe(i)   (_pioinfo_safe(i)->unicode)
 
#define __badioinfo   (* __MINGW_IMP_SYMBOL(__badioinfo))
 
#define __pioinfo   (* __MINGW_IMP_SYMBOL(__pioinfo))
 
#define _NO_CONSOLE_FILENO   (intptr_t)-2
 
#define _FILE_DEFINED
 
#define __winitenv   (* __MINGW_IMP_SYMBOL(__winitenv))
 
#define __initenv   (* __MINGW_IMP_SYMBOL(__initenv))
 
#define _acmdln   (* __MINGW_IMP_SYMBOL(_acmdln))
 
#define _wcmdln   (* __MINGW_IMP_SYMBOL(_wcmdln))
 
#define _STARTUP_INFO_DEFINED
 
#define _CONSOLE_APP   1
 
#define _GUI_APP   2
 

Typedefs

typedef void(__cdecl_PVFV) (void)
 
typedef int(__cdecl_PIFV) (void)
 
typedef void(__cdecl_PVFI) (int)
 
typedef struct _iobuf FILE
 
typedef enum __enative_startup_state __enative_startup_state
 
typedef LONG NTSTATUS
 

Enumerations

enum  __enative_startup_state { __uninitialized = 0, __initializing, __initialized }
 

Functions

ioinfo ** __MINGW_IMP_SYMBOL (__badioinfo)[]
 
ioinfo ** __MINGW_IMP_SYMBOL (__pioinfo)[]
 
wchar_t *** __MINGW_IMP_SYMBOL (__winitenv)
 
char *** __MINGW_IMP_SYMBOL (__initenv)
 
char ** __MINGW_IMP_SYMBOL (_acmdln)
 
char ** __MINGW_IMP_SYMBOL (_wcmdln)
 
_CRTIMP __declspec (noreturn) void __cdecl _amsg_exit(int)
 
int __CRTDECL _setargv (void)
 
int __CRTDECL __setargv (void)
 
int __CRTDECL _wsetargv (void)
 
int __CRTDECL __wsetargv (void)
 
int __CRTDECL main (int _Argc, char **_Argv, char **_Env)
 
int __CRTDECL wmain (int _Argc, wchar_t **_Argv, wchar_t **_Env)
 
_CRTIMP int __cdecl __getmainargs (int *_Argc, char ***_Argv, char ***_Env, int _DoWildCard, _startupinfo *_StartInfo)
 
_CRTIMP int __cdecl __wgetmainargs (int *_Argc, wchar_t ***_Argv, wchar_t ***_Env, int _DoWildCard, _startupinfo *_StartInfo)
 
_CRTIMP void __cdecl __set_app_type (int)
 
void *__cdecl _encode_pointer (void *)
 
void *__cdecl _encoded_null ()
 
void *__cdecl _decode_pointer (void *)
 
BOOL __cdecl _ValidateImageBase (PBYTE pImageBase)
 
PIMAGE_SECTION_HEADER __cdecl _FindPESection (PBYTE pImageBase, DWORD_PTR rva)
 
BOOL __cdecl _IsNonwritableInCurrentImage (PBYTE pTarget)
 

Variables

_CRTIMP int _commode
 
int _dowildcard
 
int _newmode
 
volatile __enative_startup_state __native_startup_state
 
volatile void__native_startup_lock
 
volatile unsigned int __native_dllmain_reason
 
volatile unsigned int __native_vcclrit_reason
 

Macro Definition Documentation

◆ __badioinfo

#define __badioinfo   (* __MINGW_IMP_SYMBOL(__badioinfo))

Definition at line 86 of file internal.h.

◆ __initenv

#define __initenv   (* __MINGW_IMP_SYMBOL(__initenv))

Definition at line 129 of file internal.h.

◆ __INTERNAL_FUNC_DEFINED

#define __INTERNAL_FUNC_DEFINED

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 32 of file internal.h.

◆ __IOINFO_TM_ANSI

#define __IOINFO_TM_ANSI   0

Definition at line 44 of file internal.h.

◆ __IOINFO_TM_UTF16LE

#define __IOINFO_TM_UTF16LE   2

Definition at line 46 of file internal.h.

◆ __IOINFO_TM_UTF8

#define __IOINFO_TM_UTF8   1

Definition at line 45 of file internal.h.

◆ __pioinfo

#define __pioinfo   (* __MINGW_IMP_SYMBOL(__pioinfo))

Definition at line 91 of file internal.h.

◆ __winitenv

#define __winitenv   (* __MINGW_IMP_SYMBOL(__winitenv))

Definition at line 124 of file internal.h.

◆ _acmdln

#define _acmdln   (* __MINGW_IMP_SYMBOL(_acmdln))

Definition at line 134 of file internal.h.

◆ _CONSOLE_APP

#define _CONSOLE_APP   1

Definition at line 164 of file internal.h.

◆ _FILE_DEFINED

#define _FILE_DEFINED

Definition at line 97 of file internal.h.

◆ _GUI_APP

#define _GUI_APP   2

Definition at line 165 of file internal.h.

◆ _NO_CONSOLE_FILENO

#define _NO_CONSOLE_FILENO   (intptr_t)-2

Definition at line 94 of file internal.h.

◆ _osfhnd_safe

#define _osfhnd_safe (   i)    (_pioinfo_safe(i)->osfhnd)

Definition at line 77 of file internal.h.

◆ _osfile

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

Definition at line 72 of file internal.h.

◆ _osfile_safe

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

Definition at line 78 of file internal.h.

◆ _pioinfo

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

Definition at line 71 of file internal.h.

◆ _pioinfo_safe

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

Definition at line 76 of file internal.h.

◆ _pipech2

#define _pipech2 (   i)    (_pioinfo(i)->pipech2)

Definition at line 73 of file internal.h.

◆ _pipech2_safe

#define _pipech2_safe (   i)    (_pioinfo_safe(i)->pipech2)

Definition at line 80 of file internal.h.

◆ _pipech_safe

#define _pipech_safe (   i)    (_pioinfo_safe(i)->pipech)

Definition at line 79 of file internal.h.

◆ _STARTUP_INFO_DEFINED

#define _STARTUP_INFO_DEFINED

Definition at line 155 of file internal.h.

◆ _textmode

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

Definition at line 74 of file internal.h.

◆ _textmode_safe

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

Definition at line 81 of file internal.h.

◆ _tm_unicode

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

Definition at line 75 of file internal.h.

◆ _tm_unicode_safe

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

Definition at line 82 of file internal.h.

◆ _wcmdln

#define _wcmdln   (* __MINGW_IMP_SYMBOL(_wcmdln))

Definition at line 140 of file internal.h.

◆ IOINFO_ARRAY_ELTS

#define IOINFO_ARRAY_ELTS   (1 << 5)

Definition at line 69 of file internal.h.

Typedef Documentation

◆ __enative_startup_state

◆ _PIFV

typedef int(__cdecl * _PIFV) (void)

Definition at line 34 of file internal.h.

◆ _PVFI

typedef void(__cdecl * _PVFI) (int)

Definition at line 35 of file internal.h.

◆ _PVFV

typedef void(__cdecl * _PVFV) (void)

Definition at line 33 of file internal.h.

◆ FILE

typedef struct _iobuf FILE

Definition at line 108 of file internal.h.

◆ NTSTATUS

typedef LONG NTSTATUS

Definition at line 179 of file internal.h.

Enumeration Type Documentation

◆ __enative_startup_state

Enumerator
__uninitialized 
__initializing 
__initialized 

Definition at line 167 of file internal.h.

Function Documentation

◆ __declspec()

_CRTIMP __declspec ( noreturn  )

Definition at line 53 of file thread.c.

58 {
59  /* Attempt to call the Thread Start Address */
60  _SEH2_TRY
61  {
62  /* Legacy check which is still used today for Win32 threads */
63  if (NtCurrentTeb()->NtTib.Version == (30 << 8)) // OS/2 V3.0 ("Cruiser")
64  {
65  /* This registers the termination port with CSRSS */
67  }
68 
69  /* Get the exit code from the Thread Start */
70  ExitThread((lpStartAddress)((PVOID)lpParameter));
71  }
73  {
74  /* Get the Exit code from the SEH Handler */
76  {
77  /* Kill the whole process, usually */
79  }
80  else
81  {
82  /* If running inside CSRSS, kill just this thread */
84  }
85  }
86  _SEH2_END;
87 }
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
_SEH2_TRY
Definition: create.c:4250
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:262
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:364
BOOLEAN BaseRunningInServerProcess
Definition: dllmain.c:20
LPVOID lpParameter
Definition: kernel32.h:241
NTSTATUS NTAPI CsrNewThread(VOID)
Definition: api.c:27
_SEH2_END
Definition: create.c:4424
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

◆ __getmainargs()

_CRTIMP int __cdecl __getmainargs ( int _Argc,
char ***  _Argv,
char ***  _Env,
int  _DoWildCard,
_startupinfo _StartInfo 
)

◆ __MINGW_IMP_SYMBOL() [1/6]

ioinfo** __MINGW_IMP_SYMBOL ( __badioinfo  )

◆ __MINGW_IMP_SYMBOL() [2/6]

ioinfo** __MINGW_IMP_SYMBOL ( __pioinfo  )

◆ __MINGW_IMP_SYMBOL() [3/6]

wchar_t*** __MINGW_IMP_SYMBOL ( __winitenv  )

◆ __MINGW_IMP_SYMBOL() [4/6]

char*** __MINGW_IMP_SYMBOL ( __initenv  )

◆ __MINGW_IMP_SYMBOL() [5/6]

char** __MINGW_IMP_SYMBOL ( _acmdln  )

◆ __MINGW_IMP_SYMBOL() [6/6]

char** __MINGW_IMP_SYMBOL ( _wcmdln  )

◆ __set_app_type()

_CRTIMP void __cdecl __set_app_type ( int  )

Definition at line 360 of file environ.c.

361 {
362  __app_type = app_type;
363 }
int __app_type
Definition: environ.c:30

◆ __setargv()

int __CRTDECL __setargv ( void  )

Definition at line 20 of file dll_argv.c.

22 {
23  _dowildcard = 1;
24  return 0;
25 }
int _dowildcard
Definition: wildcard.c:32

◆ __wgetmainargs()

_CRTIMP int __cdecl __wgetmainargs ( int _Argc,
wchar_t ***  _Argv,
wchar_t ***  _Env,
int  _DoWildCard,
_startupinfo _StartInfo 
)

◆ __wsetargv()

int __CRTDECL __wsetargv ( void  )

◆ _decode_pointer()

void* __cdecl _decode_pointer ( void )

Definition at line 19 of file mingw_helpers.c.

20 {
21  return (void *) codedptr;
22 }

Referenced by mingw_onexit().

◆ _encode_pointer()

void* __cdecl _encode_pointer ( void )

Definition at line 25 of file mingw_helpers.c.

26 {
27  return ptr;
28 }
static PVOID ptr
Definition: dispmode.c:27

Referenced by mingw_onexit().

◆ _encoded_null()

void* __cdecl _encoded_null ( )

◆ _FindPESection()

PIMAGE_SECTION_HEADER _FindPESection ( PBYTE  pImageBase,
DWORD_PTR  rva 
)

Definition at line 48 of file pesect.c.

49 {
50  PIMAGE_NT_HEADERS pNTHeader;
51  PIMAGE_SECTION_HEADER pSection;
52  unsigned int iSection;
53 
54  pNTHeader = (PIMAGE_NT_HEADERS) (pImageBase + ((PIMAGE_DOS_HEADER) pImageBase)->e_lfanew);
55 
56  for (iSection = 0, pSection = IMAGE_FIRST_SECTION (pNTHeader);
57  iSection < pNTHeader->FileHeader.NumberOfSections;
58  ++iSection,++pSection)
59  {
60  if (rva >= pSection->VirtualAddress
61  && rva < pSection->VirtualAddress + pSection->Misc.VirtualSize)
62  return pSection;
63  }
64  return NULL;
65 }
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
smooth NULL
Definition: ftsmooth.c:416
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
union _IMAGE_SECTION_HEADER::@1528 Misc

Referenced by __mingw_enum_import_library_names(), __mingw_GetSectionForAddress(), and _IsNonwritableInCurrentImage().

◆ _IsNonwritableInCurrentImage()

WINBOOL _IsNonwritableInCurrentImage ( PBYTE  pTarget)

Definition at line 175 of file pesect.c.

176 {
177  PBYTE pImageBase;
178  DWORD_PTR rvaTarget;
179  PIMAGE_SECTION_HEADER pSection;
180 
181  pImageBase = (PBYTE) &__ImageBase;
182  if (! _ValidateImageBase (pImageBase))
183  return FALSE;
184  rvaTarget = pTarget - pImageBase;
185  pSection = _FindPESection (pImageBase, rvaTarget);
186  if (pSection == NULL)
187  return FALSE;
188  return (pSection->Characteristics & IMAGE_SCN_MEM_WRITE) == 0;
189 }
WINBOOL _ValidateImageBase(PBYTE)
Definition: pesect.c:27
smooth NULL
Definition: ftsmooth.c:416
#define IMAGE_SCN_MEM_WRITE
Definition: ntimage.h:241
uint32_t DWORD_PTR
Definition: typedefs.h:63
PIMAGE_SECTION_HEADER _FindPESection(PBYTE, DWORD_PTR)
Definition: pesect.c:48
IMAGE_DOS_HEADER __ImageBase
Definition: mstscax.cpp:17
BYTE * PBYTE
Definition: pedump.c:66

◆ _setargv()

int __CRTDECL _setargv ( void  )

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 18 of file dllargv.c.

20 {
21  return 0;
22 }

◆ _ValidateImageBase()

WINBOOL _ValidateImageBase ( PBYTE  pImageBase)

Definition at line 27 of file pesect.c.

28 {
29  PIMAGE_DOS_HEADER pDOSHeader;
30  PIMAGE_NT_HEADERS pNTHeader;
31  PIMAGE_OPTIONAL_HEADER pOptHeader;
32 
33  pDOSHeader = (PIMAGE_DOS_HEADER) pImageBase;
34  if (pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE)
35  return FALSE;
36  pNTHeader = (PIMAGE_NT_HEADERS) ((PBYTE) pDOSHeader + pDOSHeader->e_lfanew);
37  if (pNTHeader->Signature != IMAGE_NT_SIGNATURE)
38  return FALSE;
39  pOptHeader = (PIMAGE_OPTIONAL_HEADER) &pNTHeader->OptionalHeader;
40  if (pOptHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)
41  return FALSE;
42  return TRUE;
43 }
#define TRUE
Definition: types.h:120
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
struct _IMAGE_OPTIONAL_HEADER * PIMAGE_OPTIONAL_HEADER
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define IMAGE_NT_OPTIONAL_HDR_MAGIC
Definition: ntimage.h:387
BYTE * PBYTE
Definition: pedump.c:66

Referenced by __mingw_enum_import_library_names(), __mingw_GetSectionCount(), __mingw_GetSectionForAddress(), _FindPESectionByName(), _FindPESectionExec(), _GetPEImageBase(), and _IsNonwritableInCurrentImage().

◆ _wsetargv()

int __CRTDECL _wsetargv ( void  )

◆ main()

int __CRTDECL main ( int  _Argc,
char **  _Argv,
char **  _Env 
)

Definition at line 5 of file TestTimer.c.

6 {
7  LARGE_INTEGER liFrequency;
8  LARGE_INTEGER liStartTime;
9  LARGE_INTEGER liCurrentTime;
10 
11  QueryPerformanceFrequency ( &liFrequency );
12  printf ( "HIGH RESOLUTION PERFOMANCE COUNTER Frequency = %I64d CLOCKS IN SECOND\n",
13  liFrequency.QuadPart );
14 
15 
16  if (liFrequency.QuadPart == 0)
17  {
18  printf("Your computer does not support High Resolution Performance counter\n");
19  return;
20  }
21 
22  printf ( "Press <ENTER> to start test...\n" );
23  getchar();
24 
25  printf ( "\nPress any key to quit test\n\n" );
26  QueryPerformanceCounter ( &liStartTime );
27  for (;;)
28  {
29  QueryPerformanceCounter ( &liCurrentTime );
30  printf("Elapsed Time : %8.6f mSec\r",
31  ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart )) );
32  if (_kbhit())
33  break;
34  }
35 
36 
37 }
_CRTIMP int __cdecl _kbhit(void)
Definition: kbhit.c:21
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
_Check_return_ _CRTIMP int __cdecl getchar(void)
Definition: file.c:3627
LONGLONG QuadPart
Definition: typedefs.h:112
#define printf
Definition: config.h:203

◆ wmain()

int __CRTDECL wmain ( int  _Argc,
wchar_t **  _Argv,
wchar_t **  _Env 
)

Variable Documentation

◆ __native_dllmain_reason

volatile unsigned int __native_dllmain_reason

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 11 of file natstart.c.

◆ __native_startup_lock

volatile void* __native_startup_lock

Definition at line 14 of file natstart.c.

Referenced by __declspec().

◆ __native_startup_state

volatile __enative_startup_state __native_startup_state

Definition at line 13 of file natstart.c.

Referenced by __declspec().

◆ __native_vcclrit_reason

volatile unsigned int __native_vcclrit_reason

Definition at line 12 of file natstart.c.

◆ _commode

_CRTIMP int _commode

Definition at line 31 of file environ.c.

◆ _dowildcard

int _dowildcard

Definition at line 32 of file wildcard.c.

◆ _newmode

int _newmode

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 7 of file _newmode.c.

Referenced by pre_cpp_init().