"The parameter is incorrect." when saving network file

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

"The parameter is incorrect." when saving network file

Post by VilleK »

Hi,

I'm using latest TextPad 8.11.0 64-bit version.

My problem can be reproduced as follows:
1. Activate File sharing in system settings on a Mac.
2. Open a text file in TextPad that is shared from the Mac. A typical file path will then be something like "\\192.168.0.14\Documents\somefile.txt".
(note: the file needs to be at least 25kb or so. Very small files seem to not show the problem.)
3. Make an edit, save. Make another edit, save again.

There will now be a "The parameter is incorrect" (or "Felaktig parameter" on my Swedish Windows) dialog and the file is not saved. Even worse, the file is often deleted. A third possibility that happens sometimes is that the text file has left over lines at the end when reopened.

It only happens in TextPad so it is definitely a problem in this editor. Any other editor including Notepad works fine.

I searched these forums and found this thread which seems to be the same problem but it was not resolved.

I've tried disabling the "Reload changed file" settings in TextPad but it does not help.

Is there a solution?

Let me also take the opportunity to say thanks for this software! I've been using it in my work daily for over 20 years and it is a very valuable tool for me.
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

The problem is very easy to reproduce. You just need a Mac to test with. I have tried with 4 different Mac with various OS versions and it happens with all of them.
User avatar
AmigoJack
Posts: 502
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Long story short: editing files on SMB shares is (still) bugged.

Unbound to Macs and MacOS. Go try it with a real Unix or Linux or any other Windows machine sharing via SMB - it should be the same issue.

Somehow TextPad must detect if it is operating on a network resource and in that case not perform any optimized actions, but instead only use the WinAPI to access the file. For the average programmer it is not even possible to reproduce this issue, because opening/writing/closing files is unbound to the underlying file system.

Detecting a network resource may happen by recognizing a UNC path, or by checking if the drive type of the file to open is a network drive.
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

I see, thanks for the explanation.

This is a very annoying problem for me because it is the only situation where I'm forced to use another editor.

If it is tricky to autodetect network resources then they could add an option "Use compatible file access" to avoid any optimized file operations. Any advanced file operations is probably overkill anyway and just something that was meaningful 20 years ago when computer were less powerful.

I hope this bug can be fixed.
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

In case it helps the developers, I made a capture using Process Monitor tool.

Here is the log: https://drive.google.com/file/d/10VzMpS ... sp=sharing

Here is a screenshot of the error as shown in Process Monitor: https://drive.google.com/file/d/1rDNaTB ... sp=sharing
User avatar
AmigoJack
Posts: 502
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Putting a text file (CSV) into the post with text:

Code: Select all

"Time of Day","Process Name","PID","Operation","Path","Result","Detail"
"14:41:07,5779970","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:07,5780245","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:08,8192852","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:08,8777758","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:08,9111157","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:08,9112711","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:08,9113053","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:08,9113242","TextPad.exe","876","FileSystemControl","\\192.168.1.2\ville\Documents\test.c","INVALID DEVICE REQUEST","Control: FSCTL_QUERY_FILE_REGIONS"
"14:41:08,9283714","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:08,9353558","TextPad.exe","876","FileSystemControl","\\192.168.1.2\ville\Documents\test.c","INVALID DEVICE REQUEST","Control: FSCTL_QUERY_FILE_REGIONS"
"14:41:08,9625984","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
"14:41:09,0090901","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:09,0091496","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 77 824, EndOfFile: 15 102, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:09,0091714","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,8613942","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,8615325","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,8615491","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,8715203","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,8716912","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,8717232","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 77 824, EndOfFile: 15 102, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:11,8717399","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,8910881","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,8911953","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,8912502","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,9208953","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,9210202","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,9210374","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,9302902","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Generic Read/Write, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,9356678","TextPad.exe","876","SetAllocationInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0"
"14:41:11,9398936","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,9458403","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:11,9702384","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,9703882","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,9704052","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,9705935","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,9706845","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:11,9894720","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:11,9896447","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:11,9896611","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:11,9897692","TextPad.exe","876","SetEndOfFileInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","EndOfFile: 0"
"14:41:11,9897901","TextPad.exe","876","SetAllocationInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0"
"14:41:11,9937283","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:12,0062038","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:12,0305809","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:12,0307158","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:12,0307326","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:12,0350422","TextPad.exe","876","WriteFile","\\192.168.1.2\ville\Documents\test.c","INVALID PARAMETER","Offset: 0, Length: 4 096, Priority: Normal"
"14:41:12,0403917","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:12,0442120","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:12,0669700","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:12,0671097","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:12,0671282","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:12,0673557","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,0673826","TextPad.exe","876","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace","SUCCESS","Desired Access: Query Value"
"14:41:12,0674113","TextPad.exe","876","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace\ValidateRegItems","NAME NOT FOUND","Length: 16"
"14:41:12,0674497","TextPad.exe","876","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace","SUCCESS",""
"14:41:12,0674688","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,0674872","TextPad.exe","876","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace","SUCCESS","Desired Access: Query Value"
"14:41:12,0675084","TextPad.exe","876","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace\MonitorRegistry","NAME NOT FOUND","Length: 16"
"14:41:12,0675271","TextPad.exe","876","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NetworkNeighborhood\NameSpace","SUCCESS",""
"14:41:12,0675942","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,0676124","TextPad.exe","876","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS","Desired Access: Query Value"
"14:41:12,0676337","TextPad.exe","876","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\ValidateRegItems","NAME NOT FOUND","Length: 16"
"14:41:12,0676519","TextPad.exe","876","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS",""
"14:41:12,0676682","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,0676852","TextPad.exe","876","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS","Desired Access: Query Value"
"14:41:12,0677033","TextPad.exe","876","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\MonitorRegistry","NAME NOT FOUND","Length: 16"
"14:41:12,0677206","TextPad.exe","876","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS",""
"14:41:12,0677737","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,0677917","TextPad.exe","876","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS","Desired Access: Query Value"
"14:41:12,0678107","TextPad.exe","876","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\ValidateRegItems","NAME NOT FOUND","Length: 16"
"14:41:12,0678292","TextPad.exe","876","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS",""
"14:41:12,0678452","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,0678622","TextPad.exe","876","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS","Desired Access: Query Value"
"14:41:12,0678815","TextPad.exe","876","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\MonitorRegistry","NAME NOT FOUND","Length: 16"
"14:41:12,0678988","TextPad.exe","876","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace","SUCCESS",""
"14:41:12,6685387","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:12,6685829","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:13,9171151","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:13,9977158","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:14,0263009","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"14:41:14,0264245","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:14,0264588","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:14,0264783","TextPad.exe","876","FileSystemControl","\\192.168.1.2\ville\Documents\test.c","INVALID DEVICE REQUEST","Control: FSCTL_QUERY_FILE_REGIONS"
"14:41:14,0357064","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:14,0405026","TextPad.exe","876","FileSystemControl","\\192.168.1.2\ville\Documents\test.c","INVALID DEVICE REQUEST","Control: FSCTL_QUERY_FILE_REGIONS"
"14:41:14,0592668","TextPad.exe","876","CreateFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened"
"14:41:14,0635654","TextPad.exe","876","QueryBasicInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","CreationTime: 2019-10-22 14:44:17, LastAccessTime: 2022-05-12 14:40:11, LastWriteTime: 2022-05-12 14:39:52, ChangeTime: 2022-05-12 14:39:52, FileAttributes: N"
"14:41:14,0685001","TextPad.exe","876","QueryStandardInformationFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: False"
"14:41:14,0685243","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:17,7377607","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:17,7377819","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:22,8153347","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:22,8153573","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:27,8904047","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:27,8904532","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:28,7305389","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:28,7305617","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:28,7305883","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:28,7306030","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
"14:41:28,7306200","TextPad.exe","876","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"14:41:28,7306346","TextPad.exe","876","RegOpenKey","HKLM\SOFTWARE\DigitalPersona\Tracing","NAME NOT FOUND","Desired Access: Read"
Using a picture hoster for the picture:
Image
User avatar
bbadmin
Site Admin
Posts: 821
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

I don't have access to a Mac, so tried using Windows 10 version 21H2, build 19044.1706 as a client, and a Raspberry Pi with Debian Linux 10, kernel version 5.15.32 and SAMBA version 4.13.13 as a server. Both devices are on the same LAN. I tried multiple files in sizes from 24 KB to 3.8 MB but could not reproduce this issue. I also tried it using the USB storage device on a tp-link router, which also uses SAMBA, without any problems.
User avatar
AmigoJack
Posts: 502
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Code: Select all

"14:41:12,0307326","TextPad.exe","876","CloseFile","\\192.168.1.2\ville\Documents\test.c","SUCCESS",""
"14:41:12,0350422","TextPad.exe","876","WriteFile","\\192.168.1.2\ville\Documents\test.c","INVALID PARAMETER","Offset: 0, Length: 4 096, Priority: Normal"
But you do see how this logically cannot work? Closing the file first and afterwards trying to write to it? Looks like a classic race condition.

I'm afraid you have to test other SMB share scenarios. Can't you set up two VMs with different OS versions or at least different SMB versions? Maybe even the TextPad version of 8.11.0 in 64 bit is relevant. I'm very confident that MacOS is not needed.
User avatar
bbadmin
Site Admin
Posts: 821
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

It looks like the Query... APIs have to be between matched pairs of CreateFile, and CloseFile. TextPad does not make those calls. None of the calls to CreateFile request write access, so the call that TextPad makes requesting write access must be before the first line of your log file. Obviously, the corresponding call it makes to CloseFile should be after the failing call to WriteFile, but I can't pair them up from that excerpt.

If WriteFile is called with the handle of a file that has been closed, it results in ERROR_INVALID_HANDLE, not INVALID PARAMETER.

My test was with the 64-bit edition of 8.11.0.
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

If you cannot reproduce it, could you perhaps give me a TextPad build that has extra debug handling or tests that I can run here and give you more information?

I can also make a complete Process Monitor log from the moment TextPad starts to exit.

Any info here maybe? https://support.microsoft.com/en-au/top ... 8374b99d56

And:
http://www.cplusplus.com/forum/windows/49003/

https://community.osr.com/discussion/29 ... sicaldrive
User avatar
bbadmin
Site Admin
Posts: 821
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

None of the documented causes of this that a search of "WriteFile and INVALID PARAMETER" reveals apply to TextPad. The only condition under which I could make WriteFile set that error is when the buffer containing the text to write is at an invalid address. If that was possible within TextPad, it should happen regardless of the destination drive type. Device drivers are supposed to insulate processes from such considerations.

Please try setting the option "When files are modified by another process" to Ignore, on Configure/Preferences/File. Also, if you have anti-virus apps running on your PC and Mac, try temporarily disabling them.
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

bbadmin wrote:None of the documented causes of this that a search of "WriteFile and INVALID PARAMETER" reveals apply to TextPad.
Ok thanks for checking.
bbadmin wrote:Please try setting the option "When files are modified by another process" to Ignore, on Configure/Preferences/File.
Already done.
bbadmin wrote:Also, if you have anti-virus apps running on your PC and Mac, try temporarily disabling them.
Both Mac and PC are minimally configured and do not have any extra software installed that could affect this. I tried disabling built-in Windows realtime protection but that did not help.

I understand the problem of fixing this issue when you cannot reproduce it.

After some more testing, I've noticed that with some files it works to save several times before the error happens.

Here is a file test.txt where it is enough to open, insert a character, and save to get the error. I've tried 10 times in a row and it happens every time. Please try it on your SMB share setups: https://drive.google.com/file/d/1WR2y5M ... sp=sharing
User avatar
bbadmin
Site Admin
Posts: 821
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

Thanks for the test file. I've tried it several times on my linux based Samba servers, without any problems.

It's a puzzle how it works for you the first time and then fails, as TextPad is executing exactly the same code each time. Which version of Windows are you using?
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

bbadmin wrote:Which version of Windows are you using?
I'm using Windows 10 but this has been happening since TextPad 4 so it was the same with previous Windows versions.

Is there any way you can check your source code repository if any change was done in file access handling between TextPad 4.5 to 4.7.2?

I tried using Process Monitor some more.

I saved the test.txt file first in Notepad (works) then in TextPad (fails) and extracted the relevant createfile and writefile calls.

Code: Select all

Notepad:

"CreateFile","Desired Access: Generic Read/Write, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: 0, OpenResult: Opened"
"WriteFile","Offset: 0, Length: 51 937, Priority: Normal"

TextPad:

"CreateFile","Desired Access: Generic Read/Write, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: n/a, OpenResult: Opened"
"WriteFile","Offset: 0, Length: 4 096, Priority: Normal" (returns "INVALID PARAMETER")
Some notable differences:
- TextPad pass the "Sequential Access" flag (I guess this is what Process Monitor calls the FILE_FLAG_SEQUENTIAL_SCAN flag)
- Notepad writes the whole file in one writefile call, while TextPad use a 4k block.
- AllocationSize is different but I'm not sure what this is from the msdn documents.

Maybe it is the sequential access flag. Would it be possible for you to send me a build with this flag removed so I can try it here?
VilleK
Posts: 8
Joined: Wed Apr 20, 2022 12:20 pm

Post by VilleK »

I was advised to try this setting:

Uncheck "overwrite original files directly, when saving changes" on Configure/Preferences/File.

And this seems to solve the issue! I'll update this thread again if anything changes.
Post Reply