This is the mail archive of the 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: loading cygwin1.dll at runtime

Sebastian Miele wrote:

I want to add the following feature to an application compiled with

  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 <stdio.h>
#include <Windows.h>
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; }
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);
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 RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746

-- Unsubscribe info: Problem reports: Documentation: FAQ:

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