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 X-Info: This message was accepted for relay by smtp03.mrf.mail.rcn.net as the sender used SMTP authentication X-Trace: UmFuZG9tSVaGrBiz2ccOZoLy8tvQJwKIfBxdOFlL33jHjVZfgWh3L8d9kdpFLGTO Message-ID: <3EC55CDF.2050708@rfk.com> Date: Fri, 16 May 2003 17:49:19 -0400 From: "Larry Hall (RFK Partners, Inc.)" Reply-To: lhall AT rfk DOT com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sebastian Miele CC: cygwin AT cygwin DOT com Subject: Re: loading cygwin1.dll at runtime References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sebastian Miele wrote: > Hi, > > I want to add the following feature to an application compiled with > -mno-cygwin: > > Every time the application is about to make a system call with a > pathname as argument the application should convert the (possibly > cygwin/unix) path to the corresponding windows path using > cygwin_conv_to_full_win32_path provided by cygwin1.dll, but only if > cygwin1.dll is present on the current host. > > In order to do that I need to link cygwin1.dll at runtime and get a > pointer to cygwin_conv_to_full_win32_path. I tried to do this by just > using LoadLibrary/GetProcAddress/FreeLibrary provided by Windows. > However, the application crashes. Gdb tells: > > Program received signal SIGSEGV, Segmentation fault. > 0x61051931 in getpass () > (gdb) bt > #0 0x61051931 in getpass () > #1 0x6104f268 in getpass () > #2 0x61056629 in cygwin_conv_to_full_win32_path () > #3 0x00401423 in main (argc=2, argv=0x3f24e8) at t.c:21 > > Maybe I am missing a call to an initialization routine. Here is a > complete compilable example: > > #include > #include > > typedef void (*conv_fun_t) (const char*, char*); > > int main(int argc, char* argv[]) > { > if (argc!=2) { fprintf(stderr,"fucking arguments\n"); return 1; } > const char* input_path= argv[1]; > > HMODULE libcygwin; > conv_fun_t cygwin_conv_to_full_win32_path; > libcygwin= LoadLibrary("cygwin1.dll"); > if (libcygwin==NULL) { fprintf(stderr,"fuck1\n"); return 1; } > cygwin_conv_to_full_win32_path= > (conv_fun_t)(GetProcAddress(libcygwin,"cygwin_conv_to_full_win32_path")); > if (cygwin_conv_to_full_win32_path==NULL) { fprintf(stderr,"fuck2\n"); return 1; }; > > char *windows_path= malloc(sizeof(char)*(MAX_PATH+1)); > fprintf(stderr,"calling cygwin-conv on '%s'\n", input_path); > cygwin_conv_to_full_win32_path(input_path,windows_path); > printf(windows_path); > > FreeLibrary(libcygwin); > return 0; > } > > I compiled the program with > > gcc -mno-cygwin -g -o t t.c > > Any ideas? Yeah, use cygpath instead. Dynamic loading of the Cygwin DLL is broken and has been for some time now. PTC. :-) -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- 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/