Calling RegisterServiceProcess from setsid ?

Pierre A. Humblet Pierre.Humblet@ieee.org
Sat Jun 7 01:45:00 GMT 2003


At 12:16 AM 6/4/2003 -0400, Christopher Faylor wrote:
> How about doing a:
> 
> display /i $pc
> stepi
> 
> into main?  That might be instructive (to me at least).

Here you go. Something to do with auto-imported ___progname

Pierre

Breakpoint 1, main (ac=1, av=0xaf18f8) at sshd.c:807
807             int opt, sock_in = 0, sock_out = 0, newsock, j, i, fdsetsz,
on = 1;
(gdb) n
819             int startups = 0;
(gdb) n
822             int ret, key_used = 0;
(gdb) n
827             __progname = get_progname(av[0]);
(gdb) s
get_progname (argv0=0x8bfc90 "/c/sshdd") at bsd-misc.c:39
39              return xstrdup(__progname);
(gdb) display /i $pc
1: x/i $pc  0x43d59a <get_progname+6>:  mov    0x610e9674,%eax
(gdb) stepi
0x0043d59f      39              return xstrdup(__progname);
1: x/i $pc  0x43d59f <_fu9____progname+4>:      sub    %ch,%al
(gdb) stepi
0x0043d5a1      39              return xstrdup(__progname);
1: x/i $pc  0x43d5a1 <_fu9____progname+6>:      
    and    0xc98422e8(%eax,%edi,1),%al
(gdb) stepi

Program received signal SIGSEGV, Segmentation fault.
0x0043d5a1 in _fu9____progname () at bsd-misc.c:39
39              return xstrdup(__progname);
1: x/i $pc  0x43d5a1 <_fu9____progname+6>:      
    and    0xc98422e8(%eax,%edi,1),%al

and for your convenience

	.stabs	"get_progname:F(11,50)",36,0,35,_get_progname
	.stabs	"argv0:p(11,50)",160,0,34,8
.globl _get_progname
	.def	_get_progname;	.scl	2;	.type	32;	.endef
_get_progname:
.stabn 68,0,35,LM1-_get_progname
LM1:
LBB2:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
.stabn 68,0,39,LM2-_get_progname
LM2:
	movl	___progname, %eax
	movl	%eax, (%esp)
	call	_xstrdup
LBE2:
.stabn 68,0,53,LM3-_get_progname
LM3:
	leave
	ret

and

char *get_progname(char *argv0)
{
#ifdef HAVE___PROGNAME
	extern char *__progname;

	return xstrdup(__progname);
#else
	char *p;

	if (argv0 == NULL)
		return "unknown";	/* XXX */
	p = strrchr(argv0, '/');
	if (p == NULL)
		p = argv0;
	else
		p++;

	return xstrdup(p);
#endif
}



More information about the Cygwin-developers mailing list