X-Spam-Check-By: sourceware.org Message-ID: <44542B34.9000907@arkasoft.com> Date: Sun, 30 Apr 2006 04:12:52 +0100 From: Kaveh Goudarzi User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Truncated Environment Variables? - using Cygwin + GetEnvironmentStrings() WIN32 API Content-Type: multipart/mixed; boundary="------------080007020004040909010406" X-DSPAM-Result: Spam X-DSPAM-Processed: Sun Apr 30 04:13:04 2006 X-DSPAM-Confidence: 0.4946 X-DSPAM-Probability: 0.9999 X-DSPAM-Signature: 44542b40293627852419847 X-DSPAM-Factors: 15, X-Spam-Score: 1.723 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 --------------080007020004040909010406 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I'm working on an app which attempts to get the environment of running cygwin apps. It does this by running the GetEnvironmentStrings() win32 api call in the context of the running cygwin app (code injection). However the result that comes back as a truncated version of the environment - only 4 values PATH, SYSTEMDRIVE, SYSTEMROOT, WINDIR. You can reproduce this by compiling envs.c attached. (gcc -o envs-gcc.exe envs-gcc.c). If you run the resulting exe in cmd.exe (win xp) you get the full env in both cases but if you run it under bash then the windows version is truncated. I saw the article below which seems relevant but I was confused because my understanding of it would mean that the call using win32 api should fail when run under both cmd.exe and bash.exe which is not the case. http://cygwin.com/ml/cygwin/2006-01/msg00938.html I would be most grateful if someone could tell me why this might be happening and what possible alternative paths I could follow. thanks in advance + kind regards, Kaveh. PS. I've attached the output of "cygcheck -s -v -r > cygcheck.out" and am running Windows XP Professional SP2 --------------080007020004040909010406 Content-Type: text/plain; name="cygcheck.out" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cygcheck.out" cygcheck -s -v -r --------------080007020004040909010406 Content-Type: text/plain; name="envs-gcc.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="envs-gcc.c" #include #include #include int main ( int argc, char * argv[] , char *envp[] ) { int i = 0 ; int j = 0 ; char * envw = NULL ; printf ("====================== GCC Environment ==============\n") ; i = 0 ; while ( envp[i] != NULL ) { printf ("%s\n", envp[i++] ) ; } // printf ("&argv=0x%x 0x%x, &environ=0x%x\n", argv, argv, environ ) ; printf ("\n\n====================== Windows GetEnvironmentStrings Environment ==============\n") ; envw = GetEnvironmentStrings(); while ( strlen (envw) > 0 ) { j++ ; printf ("%s\n",envw); envw += strlen(envw) + 1; } printf ("\n\nWindows Env Strings: %d, Cygwin Env Strings Count: %d\n\n", j, i) ; } --------------080007020004040909010406 Content-Type: text/plain; charset=us-ascii -- 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/ --------------080007020004040909010406--