- This topic has 10 replies, 2 voices, and was last updated 3 years, 4 months ago by Support.
-
AuthorPosts
-
June 16, 2021 at 5:27 pm #70113UniSoftParticipant
1. Create new Windows VCL Application – Delphi
2. Drop on form TsSkinManager, select any skin
3. Drop TsSaveDialog, and button in onclick: sSaveDialog.Execute;
4. Run under debugger
When you click on any button (Ok, Cancel) in dialog, you get exception “Access violation” and cannot continue.
But if you click on cross then the dialog closing without exception.it happens here: (actually inside System.Classes.StdWndProc(0,0,0,0);)
function TacMainWnd.CallPrevWndProc(const Handle: hwnd; const Msg: longint; const WParam: WPARAM; var LParam: LPARAM): LRESULT; begin --- else if Assigned(OldProc) then try // this try-except swallow exception, so without debugger can't see it Result := CallWindowProc(OldProc, Handle, Msg, WParam, LParam) // <<<< after call this function except Result := 0; end else Result := 0; end;
you can add a breakpoint
function TacMainWnd.CallPrevWndProc(const Handle: hwnd; const Msg: longint; const WParam: WPARAM; var LParam: LPARAM): LRESULT; begin --- else if Assigned(OldProc) then try // this try-except swallow exception, so without debugger can't see it // >>>>>> add this <<<<<<< if Message.Msg = 1046 then Result := 0; // <<<< put breakpoint on this line, so the next call of CallWindowProc() will give an exception Result := CallWindowProc(OldProc, Handle, Msg, WParam, LParam) // <<<< after call this function except Result := 0; end else Result := 0; end;
Still didn’t figure out what is message 1046
June 18, 2021 at 5:45 pm #70119SupportKeymasterHello!
I can’t repeat it unfortunately, maybe some another condition is required..
Is it possible to make a demo with this error?
Which Delphi version do you use?June 19, 2021 at 12:31 am #70124UniSoftParticipantWindows 7
RAD 10.4 with last 2 updatesBy the way, bug with GripPos is not fixed
function TsStatusBar.GripPos: TPoint; begin if FCommonData.SkinManager <> nil then with FCommonData.SkinManager, SkinData.CommonSkinData do if IsValidImgIndex(GripRightBottom) then begin Result := Point(Width - ma[GripRightBottom].Width - BorderWidth, Height - ma[GripRightBottom].Height - BorderWidth); Exit; end; Result := Point(Width - GetSystemMetrics(SM_CXSIZEFRAME), Height - GetSystemMetrics(SM_CYSIZEFRAME)); end;
June 19, 2021 at 12:58 am #70125UniSoftParticipantI tried to make demo, but it is crashed only under debugger
First I commented try..except
then compile release version…
if I run it from rad studio in debugger, then it crash…
If I open exe in any debugger (OllyDbg, x64dbg, …) they catch Access Violation…function TacMainWnd.CallPrevWndProc(const Handle: hwnd; const Msg: longint; const WParam: WPARAM; var LParam: LPARAM): LRESULT; var M: TMessage; begin if Assigned(OldWndProc) then begin M.Msg := Msg; M.WParam := WParam; M.LParam := LParam; M.Result := 0; OldWndProc(M); Result := M.Result; LParam := M.LParam; end else if Assigned(OldProc) then //try Result := CallWindowProc(OldProc, Handle, Msg, WParam, LParam) //except // Result := 0; //end else Result := 0; end;
Alternate link to demo (with compiled exe)
__https__://mega.nz/file/xO5BiQpJ#MRE7uX5rWFFbe1gKJ8snE1Fruj8XJiXfuKUqxXNcP_gAttachments:
You must be logged in to view attached files.June 20, 2021 at 10:33 am #70127UniSoftParticipantI found problem…
“AnVir Task Manager” adds an icon to the tool bar of open/save dialog and it is the reason why it crash.
But anyway strange, if to disable skinning, then there is no crash.
BTW, message 1046 – probably TB_DELETEBUTTON
shit.. and I had this problem before, just forgot :(.June 20, 2021 at 2:02 pm #70130UniSoftParticipantThis helps to solve that crash
comment WM_DESTROY
What for need to process both WM_DESTROY and WM_NCDESTROY?
WM_NCDESTROY is the last one, so should be enough.procedure TacDialogWnd.acWndProc(var Message: TMessage); var PS: TPaintStruct; X, Y, i: integer; cR, rClient: TRect; begin case Message.Msg of {WM_DESTROY,} WM_NCDESTROY: begin if SkinData.FCacheBmp <> nil then SkinData.FCacheBmp.Assign(nil); ... end;
June 20, 2021 at 3:06 pm #70132UniSoftParticipantjust some explain, what doing AnVir, now you can see why it cause crash
case Msg of WM_DESTROY, WM_CLOSE: begin // here is the problem!!! // this call should be after clean up, not before CallWindowProc(PrevWndFunc, ...); // !!! // After called Destructor all bottom crap can cause an error // this called on init time, then add custom buttons // so btncount cotaint number of buttons in toolbat before add new buttons //btncount := SendMessageA(Handle, TB_BUTTONCOUNT, 0, 0); // // restore previous WndProc SetWindowLong(Handle, GWLP_WNDPROC, PrevWndFunc); // delete custom buttons SendMessageA(Handle, TB_DELETEBUTTON, btncount + 1, 0); SendMessageA(Handle, TB_DELETEBUTTON, btncount , 0); end; end;
June 24, 2021 at 6:14 pm #70137SupportKeymasterHello!
I have found a potential reason of the problem there.
Plz, wait a new release and check it (v16.12).
Or, I can send you a patched unit if you have sources of the package.June 26, 2021 at 3:18 am #70140UniSoftParticipantUp to you
If you need I can check it before release…June 28, 2021 at 12:32 pm #70142UniSoftParticipantHello!
I Checked v16.12
still have the same crash… 🙁I can clearly see in the debugger what exactly is going on…
Look1. AC sets the new Window Pointer
InitializeACWnd OldProc := Pointer(GetWindowLong(CtrlHandle, GWL_WNDPROC)); NewWndProcInstance := {$IFDEF DELPHI6UP}Classes.{$ENDIF}MakeObjectInstance(acWndProc); SetWindowLong(CtrlHandle, GWL_WNDPROC, LONG_PTR(NewWndProcInstance));
2. Now AnVir do the same (and saves OldProc which is actually already = NewWndProcInstance)
3. Closing Dialog
4. Get message WM_DESTROY (Notice! it doesn’t get WM_CLOSE, at least I don’t see it in WinSpy)
Now the AnVir first pass processing to the old wndProc (what is actually = NewWndProcInstance!)
on process of WM_DESTROY – AC restores original OldProc, after that AC deletes NewWndProcInstance
FreeObjectInstance(ListSW.NewWndProcInstance);procedure UninitializeACWnd(... if Assigned(ListSW.OldProc) then begin SetWindowLong(Handle, GWL_WNDPROC, LONG_PTR(ListSW.OldProc)); ListSW.OldProc := nil; if Assigned(ListSW.NewWndProcInstance) then begin {$IFDEF DELPHI6UP}Classes.{$ENDIF}FreeObjectInstance(ListSW.NewWndProcInstance); ListSW.NewWndProcInstance := nil; end; end
5. process returns back to the AnVir, where this shit also thinking that restores old WndProc
SetWindowLong(Handle, GWLP_WNDPROC, PrevWndFunc);
BUT! it is a pointer to already deleted NewWndProcInstance
And follow send the messagesSendMessageA(Handle, TB_DELETEBUTTON, btncount + 1, 0); SendMessageA(Handle, TB_DELETEBUTTON, btncount , 0);
That is the actually reason!
—
BUG with StatusBar still not fixed as well 🙁
to see it:
1. Launch ASkinDemo.exe
2. Select skin: Standard theme
3. Move cursor over StatusBar
Fixed code is few posts up…July 1, 2021 at 6:00 pm #70168SupportKeymasterThanks for researching, I will check how to avoid this situation.
And StatusBar in standard non-skinned mode will be fixed in the nearest release. -
AuthorPosts
- You must be logged in to reply to this topic.