* exceptions.cc (windows_system_directory): Make static.  Convert to
	WCHAR.
	(_cygtls::inside_kernel): Accommodate above change.  Check module
	path name for leading \\?\ and skip, if so.
	(try_to_debug): Call GetEnvironmentStringsW and convert evaluation to
	WCHAR to avoid truncated environment problem.
	(has_visible_window_station): Call GetUserObjectInformationW.
	(events_init): Accommodate above conversion of windows_system_directory.
	* init.cc (respawn_wow64_process): Use WCHAR functions to start new
	process.
	* net.cc (__dup_ent): Drop Windows 9x consideration.
	(load_ipv6_funcs): Use WCHAR functions to load IPv6 libs.
	* syscalls.cc (syscalls.cc): Remove call to GetDiskFreeSpace.
This commit is contained in:
Corinna Vinschen 2008-04-03 15:28:03 +00:00
parent f47b47fb18
commit ba047ace14
5 changed files with 60 additions and 45 deletions

View File

@ -1,3 +1,20 @@
2008-04-03 Corinna Vinschen <corinna@vinschen.de>
Cleanup.
* exceptions.cc (windows_system_directory): Make static. Convert to
WCHAR.
(_cygtls::inside_kernel): Accommodate above change. Check module
path name for leading \\?\ and skip, if so.
(try_to_debug): Call GetEnvironmentStringsW and convert evaluation to
WCHAR to avoid truncated environment problem.
(has_visible_window_station): Call GetUserObjectInformationW.
(events_init): Accommodate above conversion of windows_system_directory.
* init.cc (respawn_wow64_process): Use WCHAR functions to start new
process.
* net.cc (__dup_ent): Drop Windows 9x consideration.
(load_ipv6_funcs): Use WCHAR functions to load IPv6 libs.
* syscalls.cc (syscalls.cc): Remove call to GetDiskFreeSpace.
2008-04-02 Corinna Vinschen <corinna@vinschen.de>
* path.cc (mount_info::init): First try to fetch mount points from

View File

@ -17,6 +17,7 @@ details. */
#include <setjmp.h>
#include <assert.h>
#include <syslog.h>
#include <wchar.h>
#include "exceptions.h"
#include "sync.h"
@ -46,7 +47,7 @@ extern child_info_spawn *chExeced;
int NO_COPY sigExeced;
static BOOL WINAPI ctrl_c_handler (DWORD);
char windows_system_directory[1024];
static WCHAR windows_system_directory[1024];
static size_t windows_system_directory_length;
/* This is set to indicate that we have already exited. */
@ -327,8 +328,9 @@ _cygtls::inside_kernel (CONTEXT *cx)
if (!VirtualQuery ((LPCVOID) cx->Eip, &m, sizeof m))
sigproc_printf ("couldn't get memory info, pc %p, %E", cx->Eip);
char *checkdir = (char *) alloca (windows_system_directory_length + 4);
memset (checkdir, 0, sizeof (checkdir));
size_t size = (windows_system_directory_length + 6) * sizeof (WCHAR);
PWCHAR checkdir = (PWCHAR) alloca (size);
memset (checkdir, 0, size);
# define h ((HMODULE) m.AllocationBase)
/* Apparently Windows 95 can sometimes return bogus addresses from
@ -338,11 +340,16 @@ _cygtls::inside_kernel (CONTEXT *cx)
res = true;
else if (h == user_data->hmodule)
res = false;
else if (!GetModuleFileName (h, checkdir, windows_system_directory_length + 2))
else if (!GetModuleFileNameW (h, checkdir, windows_system_directory_length + 6))
res = false;
else
res = strncasematch (windows_system_directory, checkdir,
windows_system_directory_length);
{
/* Skip potential long path prefix. */
if (!wcsncmp (checkdir, L"\\\\?\\", 4))
checkdir += 4;
res = !wcsncasecmp (windows_system_directory, checkdir,
windows_system_directory_length);
}
sigproc_printf ("pc %p, h %p, inside_kernel %d", cx->Eip, h, res);
# undef h
return res;
@ -397,17 +404,17 @@ try_to_debug (bool waitloop)
lock_ttys::release ();
/* prevent recursive exception handling */
char* rawenv = GetEnvironmentStrings () ;
for (char* p = rawenv; *p != '\0'; p = strchr (p, '\0') + 1)
PWCHAR rawenv = GetEnvironmentStringsW () ;
for (PWCHAR p = rawenv; *p != L'\0'; p = wcschr (p, L'\0') + 1)
{
if (strncmp (p, "CYGWIN=", strlen ("CYGWIN=")) == 0)
if (wcsncmp (p, L"CYGWIN=", wcslen (L"CYGWIN=")) == 0)
{
char* q = strstr (p, "error_start") ;
PWCHAR q = wcsstr (p, L"error_start") ;
/* replace 'error_start=...' with '_rror_start=...' */
if (q)
{
*q = '_' ;
SetEnvironmentVariable ("CYGWIN", p + strlen ("CYGWIN=")) ;
*q = L'_' ;
SetEnvironmentVariableW (L"CYGWIN", p + wcslen (L"CYGWIN=")) ;
}
break ;
}
@ -917,7 +924,7 @@ has_visible_window_station ()
with the desktop (using the "Allow service to interact with desktop"
property) are running in an invisible window station. */
if ((station_hdl = GetProcessWindowStation ())
&& GetUserObjectInformationA (station_hdl, UOI_FLAGS, &uof,
&& GetUserObjectInformationW (station_hdl, UOI_FLAGS, &uof,
sizeof uof, &len)
&& (uof.dwFlags & WSF_VISIBLE))
return true;
@ -1339,18 +1346,18 @@ void
events_init ()
{
mask_sync.init ("mask_sync");
windows_system_directory[0] = '\0';
GetSystemDirectory (windows_system_directory, sizeof (windows_system_directory) - 2);
char *end = strchr (windows_system_directory, '\0');
windows_system_directory[0] = L'\0';
GetSystemDirectoryW (windows_system_directory, sizeof (windows_system_directory) / sizeof (WCHAR) - 2);
PWCHAR end = wcschr (windows_system_directory, L'\0');
if (end == windows_system_directory)
api_fatal ("can't find windows system directory");
if (end[-1] != '\\')
if (end[-1] != L'\\')
{
*end++ = '\\';
*end = '\0';
*end++ = L'\\';
*end = L'\0';
}
windows_system_directory_length = end - windows_system_directory;
debug_printf ("windows_system_directory '%s', windows_system_directory_length %d",
debug_printf ("windows_system_directory '%W', windows_system_directory_length %d",
windows_system_directory, windows_system_directory_length);
}

View File

@ -97,11 +97,11 @@ respawn_wow64_process ()
if (!is_wow64_proc)
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
STARTUPINFOW si;
DWORD ret = 0;
GetStartupInfo (&si);
if (!CreateProcessA (NULL, GetCommandLineA (), NULL, NULL, TRUE,
GetStartupInfoW (&si);
if (!CreateProcessW (NULL, GetCommandLineW (), NULL, NULL, TRUE,
CREATE_DEFAULT_ERROR_MODE
| GetPriorityClass (GetCurrentProcess ()),
NULL, NULL, &si, &pi))

View File

@ -15,6 +15,7 @@ details. */
#include "winsup.h"
#include <ctype.h>
#include <wchar.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <syslog.h>
@ -42,6 +43,7 @@ details. */
#include "cygtls.h"
#include "cygwin/in6.h"
#include "ifaddrs.h"
#include "tls_pbuf.h"
extern "C"
{
@ -385,19 +387,10 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
/* Do servent/hostent specific processing */
int protolen = 0;
int addr_list_len = 0;
char *s_proto = NULL;
if (type == t_servent)
{
if (src->s_proto)
{
/* Windows 95 idiocy. Structure is misaligned on Windows 95.
Kludge around this by trying a different pointer alignment. */
if (!IsBadStringPtr (src->s_proto, INT32_MAX))
s_proto = src->s_proto;
else if (!IsBadStringPtr (((pservent *) src)->s_proto, INT32_MAX))
s_proto = ((pservent *) src)->s_proto;
sz += (protolen = strlen_round (s_proto));
}
sz += (protolen = strlen_round (src->s_proto));
}
else if (type == t_hostent)
{
@ -456,9 +449,9 @@ __dup_ent (unionent *&dst, unionent *src, struct_type type)
debug_printf ("protoent %s %x %x", dst->name, dst->list, dst->port_proto_addrtype);
else if (type == t_servent)
{
if (s_proto)
if (src->s_proto)
{
strcpy (dst->s_proto = dp, s_proto);
strcpy (dst->s_proto = dp, src->s_proto);
dp += protolen;
}
}
@ -3832,8 +3825,8 @@ static bool ipv6_inited = false;
static void
load_ipv6_funcs ()
{
char lib_name[MAX_PATH];
tmp_pathbuf tp;
PWCHAR lib_name = tp.w_get ();
size_t len;
HMODULE lib;
@ -3841,18 +3834,18 @@ load_ipv6_funcs ()
if (ipv6_inited)
goto out;
WSAGetLastError (); /* Kludge. Enforce WSAStartup call. */
if (GetSystemDirectory (lib_name, MAX_PATH))
if (GetSystemDirectoryW (lib_name, NT_MAX_PATH))
{
len = strlen (lib_name);
strcpy (lib_name + len, "\\ws2_32.dll");
if ((lib = LoadLibrary (lib_name)))
len = wcslen (lib_name);
wcpcpy (lib_name + len, L"\\ws2_32.dll");
if ((lib = LoadLibraryW (lib_name)))
{
if (get_ipv6_funcs (lib))
goto out;
FreeLibrary (lib);
}
strcpy (lib_name + len, "\\wship6.dll");
if ((lib = LoadLibrary (lib_name)))
wcpcpy (lib_name + len, L"\\wship6.dll");
if ((lib = LoadLibraryW (lib_name)))
{
if (get_ipv6_funcs (lib))
goto out;

View File

@ -3299,8 +3299,6 @@ long gethostid (void)
or a STATUS_ACCESS_VIOLATION is generated */
ULARGE_INTEGER availb;
GetDiskFreeSpaceEx ("C:\\", &availb, (PULARGE_INTEGER) &data[11], NULL);
if (GetLastError () == ERROR_PROC_NOT_FOUND)
GetDiskFreeSpace ("C:\\", NULL, NULL, NULL, (DWORD *)&data[11]);
debug_printf ("hostid entropy: %08x %08x %08x %08x "
"%08x %08x %08x %08x "