* autoload.cc (GetModuleFileNameExW): Replace definition of

GetModuleFileNameExA.
	* fhandler_process.cc (format_process_maps): Change modname type to
	WCHAR.  Set buffer sizes to PATH_MAX.  Call GetModuleFileNameExW
	instead of GetModuleFileNameExA.  Call mount_info::conv_to_posix_path
	instead of cygwin_conv_to_full_posix_path.  Set posix_modname to
	modname if that call fails.
	(format_process_stat): Set cmd buffer size to NAME_MAX + 1.  Simplify
	setting cmd to process name.
	(format_process_status): Ditto.
	* path.cc (mount_info::conv_to_posix_path): Call sys_wcstombs
	correctly.
This commit is contained in:
Corinna Vinschen
2007-12-03 14:13:03 +00:00
parent 268e8d00e9
commit 814066b912
4 changed files with 28 additions and 16 deletions

View File

@ -524,8 +524,8 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
DWORD_PTR wset_size;
DWORD_PTR *workingset = NULL;
MODULEINFO info;
char modname[CYG_MAX_PATH];
char posix_modname[CYG_MAX_PATH];
WCHAR modname[PATH_MAX];
char posix_modname[PATH_MAX];
if (!EnumProcessModules (proc, NULL, 0, &needed))
{
@ -551,12 +551,13 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
}
for (i = 0; i < needed / sizeof (HMODULE); i++)
if (GetModuleInformation (proc, modules[i], &info, sizeof info)
&& GetModuleFileNameEx (proc, modules[i], modname, sizeof modname))
&& GetModuleFileNameExW (proc, modules[i], modname, sizeof modname))
{
char access[5];
strcpy (access, "r--p");
struct __stat64 st;
cygwin_conv_to_full_posix_path (modname, posix_modname);
if (mount_table->conv_to_posix_path (modname, posix_modname, 0))
sys_wcstombs (posix_modname, PATH_MAX, modname);
if (stat64 (posix_modname, &st))
{
st.st_dev = 0;
@ -600,7 +601,7 @@ out:
static _off64_t
format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
{
char cmd[CYG_MAX_PATH];
char cmd[NAME_MAX + 1];
int state = 'R';
unsigned long fault_count = 0UL,
utime = 0UL, stime = 0UL,
@ -611,10 +612,8 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
strcpy (cmd, "<defunct>");
else
{
strcpy (cmd, p->progname);
char *last_slash = strrchr (cmd, '\\');
if (last_slash != NULL)
strcpy (cmd, last_slash + 1);
char *last_slash = strrchr (p->progname, '\\');
strcpy (cmd, last_slash ? last_slash + 1 : p->progname);
int len = strlen (cmd);
if (len > 4)
{
@ -730,7 +729,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
static _off64_t
format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
{
char cmd[CYG_MAX_PATH];
char cmd[NAME_MAX + 1];
int state = 'R';
const char *state_str = "unknown";
unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL,
@ -739,10 +738,8 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
strcpy (cmd, "<defunct>");
else
{
strcpy (cmd, p->progname);
char *last_slash = strrchr (cmd, '\\');
if (last_slash != NULL)
strcpy (cmd, last_slash + 1);
char *last_slash = strrchr (p->progname, '\\');
strcpy (cmd, last_slash ? last_slash + 1 : p->progname);
int len = strlen (cmd);
if (len > 4)
{