X-Spam-Check-By: sourceware.org Message-ID: <44544896.10E80D75@dessent.net> Date: Sat, 29 Apr 2006 22:18:14 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Truncated Environment Variables? - using Cygwin + GetEnvironmentStrings() WIN32 API References: <44542B34 DOT 9000907 AT arkasoft DOT com> <44543FE2 DOT 5070208 AT arkasoft DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Kaveh Goudarzi wrote: > 1. is it possible to somehow force cygwin to always sync > the env with windows prior to spawning a child process (any > child process)? Well, you could always patch the DLL to not perform this optimization. I'm not sure if it's possible to do this in any other way. > 2. How does cygwin work out if it's spawning a cygwin or > non-cygwin binary? (is it based on refs to cygwin1.dll?) > (is it the loader that does this?) I think it looks at the PE headers of the file for a record referring to cygwin1.dll in the import section. Or, if the path is mounted cygexec this check is skipped and all binaries are assumed to be Cygwin binaries, so you might be able to invert the sense of this somehow. Also, there was some recent discussion about whether this optimization was worth the headaches (in the context of programs that included WinMain() failing when calling GetEnvironmentString()) and I think the result was that the optimization was dropped... so I don't know what the current state of this in CVS is. I think cgf or Corinna (if she wasn't away on vacation right now) would have to clarify here. > 3. Brian mentioned a call to cygwin_internal(CW_SYNC_WINENV) > In my scenario (see below) I'd have to work out if the target > process was a cygwin proc or not before I tried to invoke this > method ... is there a painless way of working out if a process > is cygwin or not e.g. one that would give me a response whether > the process I'm querying is a cygwin or a native win app? #include #include int main() { HMODULE hm = GetModuleHandle ("cygwin1.dll"); if (hm && GetProcAddress (hm, "cygwin_internal")) puts ("I appear to be a cygwin binary."); else puts ("Nope, no Cygwin here."); } Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/