1 /* globals.cc - Define global variables here.
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
6 This file is part of Cygwin.
8 This software is a copyrighted work licensed under the terms of the
9 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 #include "perprocess.h"
19 #include <cygwin/version.h>
21 HANDLE NO_COPY hMainThread;
22 HANDLE NO_COPY hProcToken;
23 HANDLE NO_COPY hProcImpToken;
24 HMODULE NO_COPY cygwin_hmodule;
25 int NO_COPY sigExeced;
26 WCHAR NO_COPY windows_system_directory[MAX_PATH];
27 UINT NO_COPY windows_system_directory_length;
29 /* program exit the program */
47 exit_states NO_COPY exit_state;
49 /* Set in init.cc. Used to check if Cygwin DLL is dynamically loaded. */
50 int NO_COPY dynamically_loaded;
52 /* Some CYGWIN environment variable variables. */
53 bool allow_glob = true;
55 bool NO_COPY in_forkee;
61 vfork_save NO_COPY *main_vfork;
64 _cygtls NO_COPY *_main_tls /* !globals.h */;
66 bool NO_COPY cygwin_finished_initializing;
68 bool NO_COPY _cygwin_testing;
70 char NO_COPY almost_null[1];
72 /* Heavily-used const UNICODE_STRINGs are defined here once. The idea is a
73 speed improvement by not having to initialize a UNICODE_STRING every time
74 we make a string comparison. The strings are not defined as const,
75 because the respective NT functions are not taking const arguments
76 and doing so here results in lots of extra casts for no good reason.
77 Rather, the strings are placed in the R/O section .rdata, so we get
78 a SEGV if some code erroneously tries to overwrite these strings. */
80 { Length: sizeof (_s) - sizeof (WCHAR), \
81 MaximumLength: sizeof (_s), \
82 Buffer: (PWSTR) (_s) }
83 UNICODE_STRING _RDATA ro_u_empty = _ROU (L"");
84 UNICODE_STRING _RDATA ro_u_lnk = _ROU (L".lnk");
85 UNICODE_STRING _RDATA ro_u_exe = _ROU (L".exe");
86 UNICODE_STRING _RDATA ro_u_dll = _ROU (L".dll");
87 UNICODE_STRING _RDATA ro_u_com = _ROU (L".com");
88 UNICODE_STRING _RDATA ro_u_scr = _ROU (L".scr");
89 UNICODE_STRING _RDATA ro_u_sys = _ROU (L".sys");
90 UNICODE_STRING _RDATA ro_u_proc = _ROU (L"proc");
91 UNICODE_STRING _RDATA ro_u_pmem = _ROU (L"\\Device\\PhysicalMemory");
92 UNICODE_STRING _RDATA ro_u_natp = _ROU (L"\\??\\");
93 UNICODE_STRING _RDATA ro_u_uncp = _ROU (L"\\??\\UNC\\");
94 UNICODE_STRING _RDATA ro_u_mtx = _ROU (L"mtx");
95 UNICODE_STRING _RDATA ro_u_csc = _ROU (L"CSC-CACHE");
96 UNICODE_STRING _RDATA ro_u_fat = _ROU (L"FAT");
97 UNICODE_STRING _RDATA ro_u_mvfs = _ROU (L"MVFS");
98 UNICODE_STRING _RDATA ro_u_nfs = _ROU (L"NFS");
99 UNICODE_STRING _RDATA ro_u_ntfs = _ROU (L"NTFS");
100 UNICODE_STRING _RDATA ro_u_sunwnfs = _ROU (L"SUNWNFS");
101 UNICODE_STRING _RDATA ro_u_udf = _ROU (L"UDF");
102 UNICODE_STRING _RDATA ro_u_unixfs = _ROU (L"UNIXFS");
103 UNICODE_STRING _RDATA ro_u_nwfs = _ROU (L"NWFS");
104 UNICODE_STRING _RDATA ro_u_ncfsd = _ROU (L"NcFsd");
105 UNICODE_STRING _RDATA ro_u_volume = _ROU (L"\\??\\Volume{");
106 UNICODE_STRING _RDATA ro_u_pipedir = _ROU (L"\\\\?\\PIPE\\");
107 UNICODE_STRING _RDATA ro_u_globalroot = _ROU (L"\\\\.\\GLOBALROOT");
110 /* Cygwin properties are meant to be readonly data placed in the DLL, but
111 which can be changed by external tools to make adjustments to the
112 behaviour of a DLL based on the binary of the DLL itself. This is
113 different from $CYGWIN since it only affects that very DLL, not all
114 DLLs which have access to the $CYGWIN environment variable. */
115 cygwin_props_t _RDATA cygwin_props =
118 sizeof (cygwin_props_t),
124 /* This is an exported copy of environ which can be used by DLLs
125 which use cygwin.dll. */
126 char **__cygwin_environ;
127 char ***main_environ = &__cygwin_environ;
128 /* __progname used in getopt error message */
130 char *program_invocation_name;
131 char *program_invocation_short_name;
132 static MTinterface _mtinterf;
133 struct per_process __cygwin_user_data =
134 {/* initial_sp */ 0, /* magic_biscuit */ 0,
135 /* dll_major */ CYGWIN_VERSION_DLL_MAJOR,
136 /* dll_major */ CYGWIN_VERSION_DLL_MINOR,
137 /* impure_ptr_ptr */ NULL, /* envptr */ NULL,
138 /* malloc */ malloc, /* free */ free,
139 /* realloc */ realloc,
140 /* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL,
141 /* dtors */ NULL, /* data_start */ NULL, /* data_end */ NULL,
142 /* bss_start */ NULL, /* bss_end */ NULL,
144 /* premain */ {NULL, NULL, NULL, NULL},
147 /* cxx_malloc */ &default_cygwin_cxx_malloc,
152 /* pseudo_reloc_start */ NULL,
153 /* pseudo_reloc_end */ NULL,
154 /* image_base */ NULL,
155 /* threadinterface */ &_mtinterf,
156 /* impure_ptr */ _GLOBAL_REENT,
158 bool ignore_case_with_glob;
159 int _check_for_executable = true;
162 int NO_COPY __api_fatal_exit_val = 1;