Alaska Software Inc. - Crash in Activex's modal dialog
Username: Password:
AuthorTopic: Crash in Activex's modal dialog
Peter NagyCrash in Activex's modal dialog
on Fri, 31 May 2019 13:19:26 +0200
Hello,

I implemented a PDF Reader Activex in my Xbase++ program and I created a 
toolbar for that. If I want find text in the PDF document, I need to call 
the PDF Reader Activex's Find  function, this funcion create and show a 
Search dialog (It has a textbox, 2 buttons called Search and Cancel). If I 
click on the Cancel button, it close, and I can show again the search 
dialog. But, If I click on the Search button the program freeze for 2-3 
seconds and the entire program exit (no error message, no error log).

So the Activex itself create the search dialog not me from Xbase++.

The creator of the PDF Reader Activex said about this problem: maybe the 
parent window style is the problem (I tried oXbpWindow:seVisualStyle=false 
and XbpApplication():enableVisualStyle=false, the visual style changed but 
the crash still happening).

How I do it:
oSorax := XbpActiveXControl():new(oDlg:drawingArea, oDlg,{0,25},
{nWidth,nHeight} )
oSorax:CLSID := "Sorax.Pdf Control.2"
oSorax:create(oDlg:drawingArea, oDlg ,,,nil,.F.)
wDocHandle := oSorax:CallMethod("OpenDoc", cPdf, "", "")
wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, 
oDlg:drawingArea:getHWND(), 1523) //1523 window uID
oSorax:CallMethod("AttachDoc", wViewHandle, wDocHandle)
wSorax:CallMethod("SetViewLayout", wViewHandle, iif(wsorax_siglepage, 1, 
2)+4+iif(wsorax_hgap, 16, 0)+iif(wsorax_vgap, 32, 0))
wSorax:CallMethod("ShowPage", wViewHandle, wsorax_pagenumber, wsorax_size)

wsorax:CallMethod("Find", wViewHandle) //It Shows the search dialog, and I 
click on the Search it crash

There is a C# example 
(http://www.soraxsoft.com/pdf/sdk/activex.php#sdk_activex), there the 
parent window of the PDF Reader Activex uses .NET framework's 
System.Windows.Forms.UserControl object. 

I tried run my XbpDialog in a separate thread
I tried oSorax:create(oDlg, ,,,nil,.F.)
I tried wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, 
oDlg:getHWND(), 1523) //1523 window uID
I tried wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, 
AppDesktop():getHWND(), 1523) //1523 window uID
I tried oSorax:UseGuiThread:= .F.
I tried oSorax:UseGuiThread:= .T.

I tried logging the event loop's events, but after the activex shows the 
search dialog my program cant get any event (the AppEvents() function just 
wait).

I attached the C# source code of the Pdf reader Activex sample.
Can you help me solve this problem?
Thank you!

Ervin



C# source code.rar
Andreas Gehrs-Pahl
Re: Crash in Activex's modal dialog
on Fri, 31 May 2019 18:54:36 -0400
Ervin,

>I tried oSorax:create(oDlg, ,,,nil,.F.)

Did you also try:

oSorax := XbpActiveXControl():New(oDlg:DrawingArea, , aPos, aSize, , .f.)
oSorax:CLSID := "Sorax.Pdf Control.2"
oSorax:Create()    or oSorax:Create(, , , , , .f.)

The above uses the DrawingArea as oParent (and also as oOwner). Using "oDlg" 
as oParent will not work, and using "oDlg" as oOwner doesn't make sense, 
either.

I know I mentioned this before, but I wanted to make sure the above isn't 
just a typo, and you actually used "oDlg:DrawingArea" as oParent (and left 
oOwner empty, which then defaults to oParent).

>I tried wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, 
>oDlg:getHWND(), 1523) //1523 window uID

The documentation says that the first parameter of the CreateView method is 
the Document Handle (wDocHandle), so it should probably be:

wViewHandle := oSorax:CallMethod("CreateView", wDocHandle, nLeft, nTop, 
nRight, nBottom, oDlg:GetHWND(), nID)

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Peter NagyRe: Crash in Activex's modal dialog
on Mon, 03 Jun 2019 10:57:39 +0200
Adreas,

Yes I tried also that way, now I use that way, I just copied my old message.

">The documentation says that the first parameter of the CreateView method 
is 
>the Document Handle (wDocHandle), so it should probably be:"

Maybe Did You watch the DLL Documentation? Because The Activex documentation 
says: "OLE_HANDLE CreateView(OLE_HANDLE hDoc,
LONG nLeft, LONG nTop, LONG nRight, LONG nBottom,
OLE_HANDLE hParentWnd,
UINT uID)".
And it is true, because if I add more parameter I get an error because the 
parameters dont match.

I attached my code (just the core part, cant be compiled because functions 
missing), maybe this is help.



sorax.prg
Andreas Gehrs-Pahl
Re: Crash in Activex's modal dialog
on Mon, 03 Jun 2019 07:24:26 -0400
Peter,

>Because The Activex documentation says: 
>"OLE_HANDLE CreateView(OLE_HANDLE hDoc,
>LONG nLeft, LONG nTop, LONG nRight, LONG nBottom,
>OLE_HANDLE hParentWnd,
>UINT uID)".

Exactly. It goes on to explain:

>Parameters
>hDoc
>Handle of document.

>nLeft, nTop, nRight, nBottom
>Specifies the size and the position of the window.

>hParentWnd
>Handle of parent window.

>nID
>Identifier of the window.

>Return value
>Handle of the created window, or NULL, in case of error. Error code is 
>accessible with GetLastError().

So, there are 7 parameters, the first of which is the document handle.
The last and 7th parameter is an ID for the Window, but there is no 
indication what this parameter is used for or where the value comes from.

>And it is true, because if I add more parameter I get an error because the 
>parameters dont match.

Your code only supplies six parameters, and omits the "hDoc" value. If 
supplying seven parameters gives you a runtime error, then it is either 
because one of the parameters is wrong, or the documentation is wrong.

Actually, the entire documentation is rather thin and besides listing the 
methods, doesn't explain their purpose or their use anywhere, so it isn't 
of much help in my opinion.

Maybe the MS SDK OLE-Viewer will give you more accurate information?

Sorry, if that doesn't help you much.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Peter NagyRe: Crash in Activex's modal dialog
on Mon, 03 Jun 2019 14:31:59 +0200
Adreas,

Sorry I was incorrect. In this case the documentation bad, because I must 
give 6 parameters. I figured out when I watched the C# example (in the C# 
example the search is working).
The OLE viewer also say:
"OLE_HANDLE CreateView(
                long nLeft, 
                long nTop, 
                long nRight, 
                long nBottom, 
                OLE_HANDLE hParentWnd, 
                long nID);"

So sadly the documentation not the best. Thank you, with OLE viewer I double 
checked my function calls, but everything is ok.
Peter NagyRe: Crash in Activex's modal dialog
on Mon, 03 Jun 2019 16:10:31 +0200
I attached a picture from an open source Windows debugger software. Maybe 
this can help any way?

Acces Violation exception.  As far I can tell the problem occur in 
xpprt1.dll.

When the error occur, last satus is STATUS_INVALID_PARAMETER.

If i go up in the assembly code, I found Alaska codeblocks:
{|o| break(o)}
ERRORBLOCK

If I go up more:
603291D0:"ConRefNumeric::writeLock(ContainerHandle)"
603291A8:"U:\\source\\xpp\\rtla\\cont\\con_numref.cc"
6032917C:"ConRefNumeric::readLock(ContainerHandle)"
60329154:"U:\\source\\xpp\\rtla\\cont\\con_numref.cc"
__conCharsetIsOEM
__coNCharsetIsAnsi
__conGetObjHandle
__conPutObjHandle
{|o| break(o)}
ERRORBLOCK

LOG:
Thread 1DF8 created, Entry: spdf.0B392E40
EXCEPTION_DEBUG_INFO:
           dwFirstChance: 1
           ExceptionCode: C0000005 (EXCEPTION_ACCESS_VIOLATION)
          ExceptionFlags: 00000000
        ExceptionAddress: 60175114 xpprt1.60175114
        NumberParameters: 2
ExceptionInformation[00]: 00000000 Read
ExceptionInformation[01]: 00000000 Inaccessible Address
First chance exception on 60175114 (C0000005, EXCEPTION_ACCESS_VIOLATION)!
Thread 1C0C created, Entry: ntdll.7780E230
Thread 266C created, Entry: ntdll.7780E230

Other interesting log:
DLL Loaded: 0B390000 C:\Users\Ervin.PETI\Documents\Sorax\PDF SDK 2.2 - 
ActiveX Demo\SPdf.ocx
DLL Unloaded: 0B390000 spdf.ocx
DLL Loaded: 0B390000 C:\Users\Ervin.PETI\Documents\Sorax\PDF SDK 2.2 - 
ActiveX Demo\SPdf.ocx

In ntdll occured an error ERROR_INVALID_PARAMETER, 
STATUS_INVALID_PARAMETER (its a suspended separate thread, last error 57).