Recent

Author Topic: application crashes on startup, related to SendMessage  (Read 683 times)

guitarbug

  • Newbie
  • Posts: 2
application crashes on startup, related to SendMessage
« on: November 09, 2025, 05:57:57 am »
Subject: Help: Double Commander crashes on startup on some PCs, related to SendMessage in TWin32WSCustomForm.CreateHandle

the original issue ticket on doublecmd GitHub: https://github.com/doublecmd/doublecmd/issues/2445

Message:

Dear Lazarus community,

I'm not a Double Commander developer nor a Pascal expert, but as a user who loves Double Commander , and now I can't use this software on the corporate PC for work , and now I'm trying to troubleshoot this startup crash issue.

Problem Description:
Double Commander fails to start on some specific PCs(the corporate PC for work ). Through adding debug information, I've located the crash to occur in the TWin32WSCustomForm.CreateHandle method in win32wsforms.pp, specifically at this line:

Code: Pascal  [Select][+][-]
  1. pascal
  2. Windows.SendMessage(Result, WM_CHANGEUISTATE,
  3.   MakeWParam(UIS_INITIALIZE, UISF_HIDEFOCUS or UISF_HIDEACCEL), 0);
  4.  

Debugging Findings:   please see the attached debug code.
1. The window handle Result is valid (IsWindow(Result) returns True)
2. PostMessage works successfully, but SendMessage causes a crash
3. Even a simple Windows.SendMessage(Result, WM_NULL, 0, 0) crashes
4. The crash cannot be caught by Pascal exception handling (try..except doesn't execute)
ps, I can't install Lazarus on the corporate PC for work as the limited of company policy, so I need to build double commander in my own PC, then transfer to the corporate PC to run..

Environment Information:
- Operating System: Windows 11
- Lazarus Version: 4.2 with FPC 3.2.2

Attempted Solutions:
- Replaced SendMessage with PostMessage - program continues but eventually crashes later
- Added window validity checks
- Verified that process and thread IDs match

Questions:
1. Under what circumstances would a valid window handle crash with SendMessage but work with PostMessage?
2. Could this be related to window creation timing or message loop state?
3. In LCL, is there a safer alternative approach for handling such window initialization messages?
4. Are there any other debugging methods I might have overlooked?

As I'm not very familiar with Pascal and LCL internals, any guidance would be greatly appreciated. I'm happy to provide more debug information if needed.

Thank you for your time and assistance!


----------updated on 2025/11/11--------------

Additional Important Finding:

I checked the Windows Event Viewer and discovered that the Double Commander crash is related to a module called dgapi64.dll. This appears to be a security component. and I confirmed it with IT dept. they will not set whitelist for doublecmd.exe :(

The crash occurs when Double Commander (through LCL's window creation process) interacts with this DLL, particularly during the SendMessage call for UI state initialization.

My Questions:
1. Has anyone encountered similar issues with some security software interfering with LCL applications?
2. Are there known workarounds for such third-party DLL conflicts in Lazarus applications?
3. Could there be a way to make the window creation more robust against such external interference?

« Last Edit: November 11, 2025, 01:03:56 am by guitarbug »

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: application crashes on startup, related to SendMessage
« Reply #1 on: November 09, 2025, 12:12:10 pm »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

jamie

  • Hero Member
  • *****
  • Posts: 7488
Re: application crashes on startup, related to SendMessage
« Reply #2 on: November 09, 2025, 03:22:59 pm »
I guess a good question is, does a basic single form with a few buttons doing something also fail that way on the corporate computers?
 
 There could be some security issues brewing.

The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: application crashes on startup, related to SendMessage
« Reply #3 on: November 09, 2025, 03:29:34 pm »
Best to leave it to Alex: if it is not his bug, he will report it.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

paweld

  • Hero Member
  • *****
  • Posts: 1561
Re: application crashes on startup, related to SendMessage
« Reply #4 on: November 09, 2025, 04:14:52 pm »
@Thaddy: The link to a bug report is in the post.
TS is looking for ideas on what might be causing this error, as Alex was unable to reproduce it.
Best regards / Pozdrawiam
paweld

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: application crashes on startup, related to SendMessage
« Reply #5 on: November 09, 2025, 04:17:28 pm »
Nor did I.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

guitarbug

  • Newbie
  • Posts: 2
Re: application crashes on startup, related to SendMessage
« Reply #6 on: November 11, 2025, 01:02:51 am »
Additional Important Finding:

I checked the Windows Event Viewer and discovered that the Double Commander crash is related to a module called dgapi64.dll. This appears to be a security component. and I confirmed it with IT dept. they will not set whitelist for doublecmd.exe :(

The crash occurs when Double Commander (through LCL's window creation process) interacts with this DLL, particularly during the SendMessage call for UI state initialization.

My Questions:
1. Has anyone encountered similar issues with some security software interfering with LCL applications?
2. Are there known workarounds for such third-party DLL conflicts in Lazarus applications?
3. Could there be a way to make the window creation more robust against such external interference?


Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: application crashes on startup, related to SendMessage
« Reply #7 on: November 11, 2025, 08:30:33 am »
The dll belongs to Digital Guardian which is enterprise level security. If that is the cause you need to obtain information from them why it interfears with DoubleCommander. They are likely hooking into the OS in userspace, which in itself is regarded by many as a security threat. (technique is called a Trampoline)
Without cooperation from IT dept. whitelisting it, there is not much you can do about that.
All you can do from the side of Doublecommander is make sure all components (shared libraries, dll's) are compiled with the proper settings for e.g. ASLR and hope for the best.
It is almost impossible to make your code robust against badly written intrusive security software that does not operate on driver level but in userspace. Just like with some other anti-virus software, it is impossible to work around their heuristics if they do not want to change their footprint for FPC compiled programs.

I have no objection if you show this analyses to a) your it dept. - who should scratch their heads! - and b) the makers of Digital Guardian.

« Last Edit: November 11, 2025, 08:40:19 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018