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-Injected-Via-Gmane: http://gmane.org/ To: cygwin AT cygwin DOT com From: Sebastian Miele Subject: loading cygwin1.dll at runtime Date: 16 May 2003 23:14:48 +0200 Lines: 62 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet AT main DOT gmane DOT org User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 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? Thank's in advance & Best wishes Sebastian -- 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/