This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add cygwin_internal CW_GET_MODULE_PATH_FOR_ADDR


On Oct 15 10:51, Corinna Vinschen wrote:
> On Oct 15 01:00, Charles Wilson wrote:
> > >tweak:
> > >
> > >- Call GetModuleFileNameW instead of GetModuleFileName.
> > 
> > After we told Bruno to not use any windowsisms?  Sure, it's a lot
> > simpler -- but it violates our recommendations for cygwin clients.
> 
> I don't think it makes sense to add a cygwin_internal call for this
> functionality.  The idea was to use the same code as Linux here and to
> avoid any Cygwinism.  If using /proc/$PID/maps is not enough, then
> that's not possible.  So in turn, there's no practical difference between
> 
>   #ifdef __CYGWIN__
>     cygwin_internal (CW_GET_MODULE_PATH_FOR_ADDR,
> 		     addr, buf, sizeof (buf))
>     shared_library_fullname = strdup (buf);
>   #endif
> 
> and
> 
>   #ifdef __CYGWIN__
>     GetModuleFileNameW (module_handle, buf, sizeof (buf)))
>     shared_library_fullname = (char *) cygwin_create_path (CCP_WIN_W_TO_POSIX,
> 							   buf);
>   #endif
> 
> In both cases you have to use a Cygwinism and you have to guard the
> code using #ifdef __CYGWIN__.

Btw., if you don't want to use /proc/$PID/maps, but still want to get rid
of DLLMain and do the job in the relocate function, then a fast Cygwinism
would be something like this:

  MEMORY_BASIC_INFORMATION mbi;
  wchar_t buf[PATH_MAX];

  VirtualQuery (&relocate, &mbi, sizeof mbi);
  GetModuleFileNameW (mbi.BaseAddress, buf, sizeof buf);
  shared_library_fullname = (char *) cygwin_create_path (CCP_WIN_W_TO_POSIX,
							 buf);

With code along these lines in the relocate function, Bruno should be
able to get rid of DllMain entirely since the code would work for Win32
as well, just without the cygwin_create_path call.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]