Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] Strip \\?\ prefix from Perl path in win32/win32.c:set_w32_module_name()

2 views
Skip to first unread message

Jan Dubois

unread,
Jun 16, 2005, 2:43:15 PM6/16/05
to perl5-...@perl.org
Windows supports the \\?\ prefix to pass filenames longer than MAX_PATH
directly to the underlying file system functions without going through
the normal Win32 preprocessing (making file names absolute, turning
slashes into backslashes etc). Perl doesn't deal will these long
filenames as file/path buffers are allocated with MAX_PATH+1 bytes
almost everywhere. Besides, \\?\ should really only be used with Unicode
APIs anyways.

However, when Perl is started through a \\?\ prefixed path, e.g. with

start \\?\c:\perl\bin\perl -e"print qq($_\n) for @INC;<>"

then Win32 reports the module filename as \\?\c:\perl\bin\perl58.dll,
which in turn leads Perl to add //?/c:/perl/lib and //?/c:/perl/site/lib
to @INC which are now invalid names because you can't use forward slashes
with the \\?\ prefix.

The easiest way around this is to just strip the prefix from the module
filename. We'll immediately pass it to win32_longpath(), which only
supports MAX_PATH characters anyways.

Cheers,
-Jan

PS: In case you really want to know, I ran into this issue with a DLL
having a dependency on perl58.dll and being loaded by IIS. :)

--- win32/win32.c.~1~ Thu Jun 16 11:27:57 2005
+++ win32/win32.c Thu Jun 16 11:27:57 2005
@@ -138,6 +138,10 @@
: w32_perldll_handle),
w32_module_name, sizeof(w32_module_name));

+ /* remove \\?\ prefix */
+ if (memcmp(w32_module_name, "\\\\?\\", 4) == 0)
+ memmove(w32_module_name, w32_module_name+4, strlen(w32_module_name+4)+1);
+
/* try to get full path to binary (which may be mangled when perl is
* run from a 16-bit app) */
/*PerlIO_printf(Perl_debug_log, "Before %s\n", w32_module_name);*/
End of Patch.


Steve Hay

unread,
Jun 17, 2005, 4:56:04 AM6/17/05
to Jan Dubois, perl5-...@perl.org
Jan Dubois wrote:

>The easiest way around this is to just strip the prefix from the module
>filename. We'll immediately pass it to win32_longpath(), which only
>supports MAX_PATH characters anyways.
>
>

Thanks, applied to bleadperl as #24880.

>Cheers,
>-Jan
>
>PS: In case you really want to know, I ran into this issue with a DLL
> having a dependency on perl58.dll and being loaded by IIS. :)
>
>--- win32/win32.c.~1~ Thu Jun 16 11:27:57 2005
>+++ win32/win32.c Thu Jun 16 11:27:57 2005
>@@ -138,6 +138,10 @@
> : w32_perldll_handle),
> w32_module_name, sizeof(w32_module_name));
>
>+ /* remove \\?\ prefix */
>+ if (memcmp(w32_module_name, "\\\\?\\", 4) == 0)
>+ memmove(w32_module_name, w32_module_name+4, strlen(w32_module_name+4)+1);
>+
> /* try to get full path to binary (which may be mangled when perl is
> * run from a 16-bit app) */
> /*PerlIO_printf(Perl_debug_log, "Before %s\n", w32_module_name);*/
>End of Patch.
>

------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

0 new messages