2 * "The Road goes ever on and on, down from the door where it began."
15 # define EXTERN_C extern "C"
17 # define EXTERN_C extern
20 static void xs_init _((void));
22 __declspec(dllexport) int
23 RunPerl(int argc, char **argv, char **env, void *iosubsystem)
26 PerlInterpreter *my_perl;
27 void *pOldIOSubsystem;
29 pOldIOSubsystem = SetIOSubSystem(iosubsystem);
31 PERL_SYS_INIT(&argc,&argv);
33 perl_init_i18nl10n(1);
35 if (!(my_perl = perl_alloc()))
37 perl_construct( my_perl );
38 perl_destruct_level = 0;
40 exitstatus = perl_parse( my_perl, xs_init, argc, argv, env);
42 exitstatus = perl_run( my_perl );
45 perl_destruct( my_perl );
50 SetIOSubSystem(pOldIOSubsystem);
55 /* Register any extra external extensions */
57 char *staticlinkmodules[] = {
62 EXTERN_C void boot_DynaLoader _((CV* cv));
65 XS(w32_GetCurrentDirectory)
68 SV *sv = sv_newmortal();
69 /* Make one call with zero size - return value is required size */
70 DWORD len = GetCurrentDirectory((DWORD)0,NULL);
73 SvCUR(sv) = GetCurrentDirectory((DWORD) SvLEN(sv), SvPVX(sv));
76 * then it worked, set PV valid,
77 * else leave it 'undef'
89 char *file = __FILE__;
91 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
92 newXS("Win32::GetCurrentDirectory", w32_GetCurrentDirectory, file);
95 extern HANDLE PerlDllHandle;
98 DllMain(HANDLE hModule, /* DLL module handle */
99 DWORD fdwReason, /* reason called */
100 LPVOID lpvReserved) /* reserved */
103 /* The DLL is attaching to a process due to process
104 * initialization or a call to LoadLibrary.
106 case DLL_PROCESS_ATTACH:
107 /* #define DEFAULT_BINMODE */
108 #ifdef DEFAULT_BINMODE
109 _setmode( _fileno( stdin ), _O_BINARY );
110 _setmode( _fileno( stdout ), _O_BINARY );
111 _setmode( _fileno( stderr ), _O_BINARY );
114 PerlDllHandle = hModule;
117 /* The DLL is detaching from a process due to
118 * process termination or call to FreeLibrary.
120 case DLL_PROCESS_DETACH:
123 /* The attached process creates a new thread. */
124 case DLL_THREAD_ATTACH:
127 /* The thread of the attached process terminates. */
128 case DLL_THREAD_DETACH: