3 * Platform: Win32 (Windows NT/Windows 95)
4 * Author: Wei-Yuen Tan (wyt@hip.com)
5 * Created: A warm day in June, 1995
8 * August 23rd 1995 - rewritten after losing everything when I
9 * wiped off my NT partition (eek!)
11 /* Modified from the original dl_win32.xs to work with cygwin32
16 I merely took Paul's dl_dlopen.xs, took out extraneous stuff and
17 replaced the appropriate SunOS calls with the corresponding Win32
22 #define WIN32_LEAN_AND_MEAN
23 // Defines from windows needed for this function only. Can't include full
24 // Cygwin32 windows headers because of problems with CONTEXT redefinition
25 // Removed logic to tell not dynamically load static modules. It is assumed that all
26 // modules are dynamically built. This should be similar to the behavoir on sunOS.
27 // Leaving in the logic would have required changes to the standard perlmain.c code
29 // // Includes call a dll function to initialize it's impure_ptr.
31 void (*impure_setupptr)(struct _reent *); // pointer to the impure_setup routine
33 //#include <windows.h>
34 #define LOAD_WITH_ALTERED_SEARCH_PATH (8)
36 typedef HANDLE HINSTANCE;
37 #define STDCALL __attribute__ ((stdcall))
38 typedef int STDCALL (*FARPROC)();
65 #include "dlutils.c" /* SaveError() etc */
70 (void)dl_generic_private_init();
74 MODULE = DynaLoader PACKAGE = DynaLoader
77 (void)dl_private_init();
80 dl_load_file(filename,flags=0)
85 DLDEBUG(1,fprintf(stderr,"dl_load_file(%s):\n", filename));
87 RETVAL = (void*) LoadLibraryExA(filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) ;
89 DLDEBUG(2,fprintf(stderr," libref=%x\n", RETVAL));
90 ST(0) = sv_newmortal() ;
92 SaveError("%d",GetLastError()) ;
95 // setup the dll's impure_ptr:
96 impure_setupptr = GetProcAddress(RETVAL, "impure_setup");
97 if( impure_setupptr == NULL){
99 "Cygwin32 dynaloader error: could not load impure_setup symbol\n");
103 // setup the DLLs impure_ptr:
104 (*impure_setupptr)(_impure_ptr);
105 sv_setiv( ST(0), (IV)RETVAL);
112 dl_find_symbol(libhandle, symbolname)
116 DLDEBUG(2,fprintf(stderr,"dl_find_symbol(handle=%x, symbol=%s)\n",
117 libhandle, symbolname));
118 RETVAL = (void*) GetProcAddress((HINSTANCE) libhandle, symbolname);
119 DLDEBUG(2,fprintf(stderr," symbolref = %x\n", RETVAL));
120 ST(0) = sv_newmortal() ;
122 SaveError("%d",GetLastError()) ;
124 sv_setiv( ST(0), (IV)RETVAL);
133 # These functions should not need changing on any platform:
136 dl_install_xsub(perl_name, symref, filename="$Package")
141 DLDEBUG(2,fprintf(stderr,"dl_install_xsub(name=%s, symref=%x)\n",
143 ST(0)=sv_2mortal(newRV((SV*)newXS(perl_name, (void(*)())symref, filename)));