|
From: Sebastian M. <sm...@ps...> - 2003-05-16 15:59:20
|
Hi,
in an application that may run on windows machines I want to add the
following feature:
Every time the application is about to make a system call with a
pathname as argument the application should convert every (maybe
cygwin/unix-like) path to a windows path using a conversion function
provided by cygwin1.dll, but only if cygwin1.dll is present on the
current host.
I tried to do this using LoadLibrary/GetProcAddress/FreeLibrary.
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
Here is the 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; }
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
|