Invalid access to memory - TSessionData::GetProtocolUrl AND "!" DOES NOT RESOLVE TO FILE NAME

Advertisement

mphinney08@...
Guest

Invalid access to memory - TSessionData::GetProtocolUrl AND "!" DOES NOT RESOLVE TO FILE NAME

----------------------------------------------------------------------------------------
SUMMARY:
A) ONE MAJOR issue in resolving the file name which kills usability.
B) There is also some minor issues with resolving system variables but that can be gotten around.
C) Also ran into memory error which generated the report
----------------------------------------------------------------------------------------

[[ YOUR EXAMPLE: "%ProgramFiles%\PuTTY\putty.exe" -t -m "%TEMP%\putty.txt" !`cmd.exe /c echo cd "!/" ; /bin/bash -login > "%TEMP%\putty.txt"` ]]

Using your example I created this custom command and I called it PUTTY.

"C:\Program Files (x86)\Putty\putty.exe" -t -m "C:\Users\User\AppData\Local\Temp\putty.txt" !@ -l !U -pw !P -P !# !`cmd.exe /c echo cd "!/" ; /bin/bash ; "!" > "%TEMP%\putty.txt"`

(1) %ProgramFiles% will not resolve. (MINOR ISSUE)
(2) The first %TEMP%\putty.txt will not resolve but the second one does. (MINOR ISSUE)
The fact that it resolves the second and not the first is fascinating and should illuminate something for us.

Inside the putty.txt file we find:

C:\Users\User\AppData\Local\Temp>type putty.txt
cd "/root/bin/" ; /bin/bash ; ""

(3) But "!" is supposed to resolve to the file name. (MAJOR ISSUE) It does not.
I tried "./!" but that only does more strange things. "./!" appears to trigger some advanced functionality.

I have tried everything I can think of short of going through the code. I will if I have to I guess... ooof.
"!" gives nothing but other variables work great: !@ resolves address and !U !P !# work fine.

Not surprising the native existing &Execute command with "./!" works. You have some other functionality connected with this and
I will assume this is intertwined with this issue.

My instinct is that it has something to do with the fact that you are only using a single character "!" to resolve to the filename
and at the same time it is a trigger for the next character. ¿Maybe an additional two character code could be used such as "!F",
if that is not taken, to resolve to file name? That way you may not have to touch the "./!" which is doing its own very interesting thing.

(4) As a side note in my attempt to try everything I also ran into this "!S" issue this generated this report.

In the above command REPLACING "!" > "%TEMP%\putty.txt"` with "!S" > "%TEMP%\putty.txt"` throws INVALID ACCESS TO MEMORY. This is not connected with my needs but interesting nevertheless. Another minor issue in an otherwise very power and wonderful program.


WinSCP 5.9.5

Error message:
Invalid access to memory.

Stack trace:
(0071FF03) TSessionData::GetProtocolUrl
(0086700E) C5073_3
(00869076) ____ExceptionHandler
(00865E30) __ExceptionHandler
(0005A5DA) ntdll.dll
(0000F12E) ntdll.dll.KiUserExceptionDispatcher
(0072008E) TSessionData::GenerateSessionUrl
(00691FE9) TFileCustomCommand::PatternReplacement
(000743E1) TLocalCustomCommand::PatternReplacement
(00690F5F) TCustomCommand::Complete
(00691909) TInteractiveCustomCommand::PatternReplacement
(00690F5F) TCustomCommand::Complete
(007B2B3F) TCustomCommandDialog::UpdateControls
(007B3018) TCustomCommandDialog::ControlChange
(003F2769) Historycombobox::THistoryComboBox::Change
(001B575A) Vcl::Stdctrls::TCustomCombo::CNCommand
(0024A765) Vcl::Controls::TControl::WndProc
(0024F2A9) Vcl::Controls::TWinControl::WndProc
(001B56E7) Vcl::Stdctrls::TCustomCombo::WndProc
(0024A3A0) Vcl::Controls::TControl::Perform
(0024F40F) Vcl::Controls::_17076
(0024F2A9) Vcl::Controls::TWinControl::WndProc
(0024E8F0) Vcl::Controls::TWinControl::MainWndProc
(0037326C) System::Classes::_18201
(000152F7) USER32.dll
(00015D35) USER32.dll
(00015DE3) USER32.dll
(00015E41) USER32.dll
(0000F107) ntdll.dll.KiUserCallbackDispatcher
(000186C0) USER32.dll.SendMessageW
(00096880) COMCTL32.DLL
(000976A9) COMCTL32.DLL
(0009764E) COMCTL32.DLL
(000152F7) USER32.dll
(00015D35) USER32.dll
(0001FD22) USER32.dll
(0001FD48) USER32.dll.CallWindowProcW
(0024F3BA) Vcl::Controls

I know how to reproduce the problem or the problem happens frequently enough. I wish to be contacted by the WinSCP team to help resolving the problem.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Invalid access to memory - TSessionData::GetProtocolUrl AND "!" DOES NOT RESOLVE TO FILE NAME

Thanks for your report.

mphinney08@... wrote:

(1) %ProgramFiles% will not resolve. (MINOR ISSUE)
Environment variables resolve in PuTTY command, but not in custom commands.
We never claimed that they do resolve in custom commands.
But you can do !`cmd.exe /c echo %VARIABLE%` as a workaround.
See https://winscp.net/tracker/636

(2) The first %TEMP%\putty.txt will not resolve but the second one does. (MINOR ISSUE)
The fact that it resolves the second and not the first is fascinating and should illuminate something for us.
As shown above, the second %TEMP% is resolved by the cmd.exe.

(3) But "!" is supposed to resolve to the file name. (MAJOR ISSUE) It does not.
I tried "./!" but that only does more strange things. "./!" appears to trigger some advanced functionality.
Actually, the fact that "some" patterns can even be resolved within the !`...` pattern is undocumented.
Particularly the ! pattern cannot be resolved.
I've documented this now:
https://winscp.net/eng/docs/custom_command#patterns

Not surprising the native existing &Execute command with "./!" works. You have some other functionality connected with this and
I will assume this is intertwined with this issue.
There's really no magic behind the ./!. It's a simple ! pattern.

(4) As a side note in my attempt to try everything I also ran into this "!S" issue this generated this report.

In the above command REPLACING "!" > "%TEMP%\putty.txt"` with "!S" > "%TEMP%\putty.txt"` throws INVALID ACCESS TO MEMORY. This is not connected with my needs but interesting nevertheless.
I cannot reproduce this.
I have sent you an email with a debug version of WinSCP to the address you have used to register on this forum.

---

Anyway, to implement, what you are trying to do (executing selected file in PuTTY), you can use an external script file (e.g. PowerShell).
Start here: https://winscp.net/eng/docs/guide_custom_commands_automation

Reply with quote

Advertisement

You can post new topics in this forum