* child_info.h (child_info::sync): Pass pid and HANDLE rather than using pinfo.

(child_info::child_info): Accept an argument controlling whether to create
proc_subproc.
(child_info_spawn::child_info_spawn): Ditto.
* sigproc.cc (child_info::child_info): Ditto.
(child_info_spawn::child_info_spawn): Ditto.
(child_info::sync): Use passed in pid and HANDLE.
* fork.cc (fork_parent): Reflect additional arguments required for
child_info::sync.
* hookapi.cc (hook_or_detect_cygwin): Rename.  Change so that NULL 'fn'
argument just returns "true", indicating that program uses cygwin1.dll.
* spawn.cc (av::win16_exe): New element.
* spawn.cc (av::iscygwin): New element.
(av::fixup): New function.
(spawn_guts): Protect against SEGV.  Use fixup function to detect when it is
safe to wait for a spawned (as opposed to an execed) program.  Reflect changes
in child_info::sync arguments.
* external.cc (cygwin_internal): Reflect function renaming to
hook_or_detect_cygwin.
* cygheap.cc (cygheap_fixup_in_child): Close handle after debug fixup has been
done to prevent false positives in handle collision.
* exceptions.cc (try_to_debug): Notify debugger if already being debugged.
This commit is contained in:
Christopher Faylor
2005-07-17 00:51:03 +00:00
parent cd929277d6
commit e8454a3400
10 changed files with 195 additions and 136 deletions

View File

@ -150,7 +150,7 @@ makename (const char *name, char *&buf, int& i, int inc)
// Top level routine to find the EXE's imports, and redirect them
void *
hook_cygwin (const char *name, const void *fn)
hook_or_detect_cygwin (const char *name, const void *fn)
{
HMODULE hm = GetModuleHandle (NULL);
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm);
@ -170,16 +170,19 @@ hook_cygwin (const char *name, const void *fn)
fh.origfn = NULL;
fh.hookfn = fn;
char *buf = (char *) alloca (strlen (name) + strlen ("64") + sizeof ("_"));
int i = -1;
while (!fh.origfn && (fh.name = makename (name, buf, i, 1)))
int i;
// Iterate through each import descriptor, and redirect if appropriate
for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
{
// Iterate through each import descriptor, and redirect if appropriate
for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
{
PSTR modname = rva (PSTR, hm, pd->Name);
if (strcasematch (modname, "cygwin1.dll"))
RedirectIAT (fh, pd, hm);
}
if (!strcasematch (rva (PSTR, hm, pd->Name), "cygwin1.dll"))
continue;
if (!fn)
return (void *) "found it"; // just checking if executable used cygwin1.dll
i = -1;
while (!fh.origfn && (fh.name = makename (name, buf, i, 1)))
RedirectIAT (fh, pd, hm);
if (fh.origfn)
break;
}
while (!fh.origfn && (fh.name = makename (name, buf, i, -1)))