Results 1 to 11 of 11

Thread: [RESOLVED] RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Resolved [RESOLVED] RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    Hi Olaf:

    I've successfully installed the VB6 IDE on Wine (Ubuntu) and are now testing jpbro's VbFCGI. When I execute RC5.FSO.ReadTextContent, the system prompts "Automation error":

    Code:
    '---libFso: vbRichClient5.cFactory.C.FSO
    if Not libFso.FileExists(p_FilePathOrContent) then
        '......
        '......
    else
        ' Slurp file
       m_Content = libFso.ReadTextContent(p_FilePathOrContent, l_Utf16NoBom, p_CodePage)
    end if
    I guess RC5.FSO.ReadTextContent calls one or several core DLLs of Windows, and the DLL version on Wine is inconsistent with the version required by RC5. So I'd like to know which windows DLLs are called by RC5.FSO.ReadTextContent. Thanks !
    Last edited by dreammanor; Aug 3rd, 2018 at 07:42 AM.

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,253

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    ReadTextContent is using a File-Stream-Instance, created within OleAut32.dll
    (and the "Automation-Error" when running under Wine - indicates that Wine is apparently not able to create this Stream-Object).

    Did you apply the override for OleAut32 already (using a native OleAut32.dll on Wine)?

    For that to work correctly, there has to be a "side-by-side-placement" in the Wine-System32 Folder of:
    - oleaut32.dll (the usually much smaller Wine-version, the FileName usually in lower-case-letters)
    - OleAut32.dll (a native Windows-Version of the Dll, just adapt this FileName to "CamelCase" - before copying it into the same Folder)

    Now that you have 2 different oleaut32-Dll-Binaries in your Wines \System32-Folder side-by-side (the "builtin" one and the "native" one) -
    what remains is, to tell Wine, which one of them to use.

    You can do that, by typing (in a Ubuntu User-Console):
    winecfg

    Which should start up a small GUI-Dialog, where you can define "Dll-Overrides".
    Make sure, that you define OleAut32, to use the "native" version.

    HTH

    Edit: Just looked it up - and what is used to create the IStream-interface sporting Stream-instance is not OleAut32.dll,
    but SHCreateStreamOnFileEx of Shlwapi.dll (not sure, whether Shlwapi.dll is making indirect calls to OleAut32.dll under the covers in turn)
    .

    If you isolate the call in a small Test-Project - and run the Test.exe via Ubuntus Commandline:
    wine test.exe

    You should get more output in the concole-window, where exactly Wine starts getting problems.

    Olaf
    Last edited by Schmidt; Aug 4th, 2018 at 11:30 AM.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    Olaf,
    I updated OleAut32.dll according to your method, and I also isolated the call in a small Test-Project - and ran the Test.exe via Ubuntus Commandline:
    wine test.exe

    Also tested the command:
    WINEDLLOVERRIDES="oleaut32=n" wine test.exe

    The system prompts as follows:
    0077:fixme:atl:AtlAxWinInit version 0300 semi-stub

    The source code of the test project is as follows:
    modMain.bas
    Code:
    Public Sub Main()
        Dim l_File As String
        Dim l_FSO As vbRichClient5.cFSO
        Dim p_CodePage As vbRichClient5.MSCodePages
        Dim l_Utf16NoBom As Boolean
        Dim l_Content As String
        
        On Error GoTo ErrTest
        
        l_File = "Z:\root\VbFcgi-master\bin\vbml\index.vbml"
        
        Set l_FSO = New_c.FSO
        
        If l_FSO.FileExists(l_File) = False Then
            MsgBox "The file '" & l_File & "' does not exist !"
        Else
            l_Content = l_FSO.ReadTextContent(l_File, l_Utf16NoBom, p_CodePage)
            MsgBox "Read the contents of the file successfully !"
        End If
        
        Exit Sub
        
    ErrTest:
        MsgBox "Failed to read the contents of the file !" & vbCrLf & vbCrLf & Error
    End Sub
    modFactory.bas
    Code:
    Option Explicit
    
    'Specifiy your Path for Regfree-Loading here in the following Const.
    'As long as you start with only a Backslash, then the App.Path is used
    'and e.g. a "\Bin\" would then resolve to App.Path\Bin\ and looks
    'for the Toolset-Dlls there - but you are also free, to specify an
    'absolute path as e.g. "\\NetworkShare\RichCient3\" or "c:\RichClient3\"
    'if you prefer to use it this way which could be useful for testing...
    Private Const ToolSetPath$ = "\" 'a single Backslash resolves to App.Path
    
    'this is basically a replacement to CreateObject(), but working regfree
    'and as said above, the same Call is also available from inside the
    '"Object-Model" per regfree.GetInstance(), once you have created the
    'EntryPoint-object of the Framework (the cFactory-Instance).
    'We therefore declare it here just as 'Private'
    Private Declare Function GetInstanceEx Lib "DirectCOM" _
                            (StrPtr_FName As Long, StrPtr_ClassName As Long, _
                             Optional ByVal UseAlteredSearchPath As Boolean = True) As Object
    Private Declare Function GetInstanceOld Lib "DirectCOM" Alias "GETINSTANCE" _
                            (FName As String, ClassName As String) As Object
    Private Declare Function GETINSTANCELASTERROR Lib "DirectCOM" () As String
    
    'used, to preload DirectCOM.dll from a given Path, before we try our calls
    Private Declare Function LoadLibraryW Lib "kernel32.dll" _
                            (ByVal LibFilePath As Long) As Long
    
    
    'deliver the constructor-helper from the factory
    Public Property Get New_c() As cConstructor
      Set New_c = dhF.C
    End Property
    
    'deliver the regfree-"namespace" from the factory
    Public Property Get regfree() As cRegFree
      Set regfree = dhF.regfree
    End Property
    
    Public Property Get dhF() As cFactory
    Static F As cFactory, hLib As Long
      'if we already have an instance, we pass it and return immediately
      If Not F Is Nothing Then
        Set dhF = F
        Exit Property
      End If
      
      On Error GoTo ErrHandler
    '
    '******* In this service-app, we always try to instantiate regfree ********
    '  If RunningInIde Then
    '    Set F = New cFactory '"normal" instancing, using VBs 'New'-Operator
    '    Set dhF = F
    '  Else 'try regfree factory-instancing
        Dim RegFreePath As String
        RegFreePath = ToolSetPath
        If Command = "Debug" Then
            RegFreePath = "E:\David_Work\vbForums_RC5\____RPC-Demos-New\RPC-Demos-New\ServerBin\"
        End If
        If Left$(RegFreePath, 1) = "\" And Left$(RegFreePath, 2) <> "\\" Then
          RegFreePath = App.Path & RegFreePath 'use expansion to the App.Path
        End If
        If Right$(RegFreePath, 1) <> "\" Then RegFreePath = RegFreePath & "\"
    
        If hLib = 0 Then
          If Not FileExists(RegFreePath & "DirectCOM.dll") Then
            Err.Raise vbObjectError, , "DirectCOM.dll not found in Folder:" _
                      & vbCrLf & RegFreePath
          End If
          hLib = LoadLibraryW(StrPtr(RegFreePath & "DirectCOM.dll")) '<-preload
        End If
        Set F = GetInstance(RegFreePath & "vbRichClient5.dll", "cFactory", True)
        Set dhF = F
    '  End If
    Exit Property
    
    ErrHandler:
      MsgBox Err.Description & vbCrLf & "This Application expects to be run from its compiled Binary (from inside ServerBin)"
    '  If MsgBox(Err.Description, vbYesNo, "Make an attempt with a registered Factory?") = vbYes Then
    '    Set F = New cFactory '"normal" instancing, using VBs 'New'-Operator
    '    Set dhF = F
    '  End If
    End Property
    
    Private Function RunningInIde() As Boolean
    Static Done As Boolean, Result As Boolean
      If Not Done Then
        Done = True
        On Error Resume Next
        Debug.Print 1 / 0
        Result = Err: Err.Clear
      End If
      RunningInIde = Result
    End Function
    
    Public Function FileExists(ByRef FileName As String) As Boolean
      On Error Resume Next
        FileExists = ((GetAttr(FileName) And vbDirectory) <> vbDirectory)
      Err.Clear
    End Function
    
    'The new GetInstance-Wrapper-Proc, which is using the new DirectCOM.dll (March 2009 and newer)
    'with the new Unicode-capable GetInstanceEx-Call (which now supports the AlteredSearchPath-Flag as well) -
    Private Function GetInstance(DllFileName As String, ClassName As String, Optional ByVal UseAlteredSearchPath As Boolean = True) As Object
      On Error Resume Next
        Set GetInstance = GetInstanceEx(StrPtr(DllFileName), StrPtr(ClassName), UseAlteredSearchPath)
      If Err.Number = 453 Then 'GetInstanceEx not available, probably an older DirectCOM.dll...
        Err.Clear
        Set GetInstance = GetInstanceOld(DllFileName, ClassName) 'so let's try the older GETINSTANCE-call
      End If
      If Err Then
        Dim Error As String
        Error = Err.Description
        On Error GoTo 0: Err.Raise vbObjectError, , Error
      Else
        If GetInstance Is Nothing Then
          On Error GoTo 0: Err.Raise vbObjectError, , GETINSTANCELASTERROR()
        End If
      End If
    End Function
    Last edited by dreammanor; Aug 8th, 2018 at 10:41 PM.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    I searched the keyword "fixme:atl:atlaxwininit" on the internet but didn't find any useful information. I want to go to https://forum.winehq.org/ to ask questions, but I can't open this URL.

  5. #5

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    Quote Originally Posted by wqweto View Post
    https://github.com/wine-mirror/wine/.../atl_ax.c#L109 -- this is harmless and certainly not the root cause of the problem.

    cheers,
    </wqw>
    Thank you, wqweto. The information you provide is very useful.

    Very strange, when I run "wine test.exe", Wine only shows one line of message "0077: fixme:atl:AtlAxWinInit version 0300 semi-stub". Under normal circumstances, Wine should give more hints. I don't know if there is something wrong with my test program (the source code of the test program is on #3)

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    I run "wine test.exe" via VNC (Virtual Network Console), the system has only one message:
    0077: fixme: atl: AtlAxWinInit version 0300 semi-stub

    Now I run "wine test.exe" via Ubuntu Commandline. The system prompts are as follows:

    Code:
    wine test.exe
    
    00a0:err:user:load_desktop_driver failed to load L"C:\\windows\\system32\\winex11.drv"
    
    00a0:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
    
    00a0:err:winediag:nodrv_CreateWindow The explorer process failed to start.
    
    wine: Unhandled stack overflow at address 0x7bc54c42 (thread 00a0), starting debugger...
    
    00a0:err:seh:setup_exception_record stack overflow 832 bytes in thread 00a0 eip b7597142 esp 00240ff0 stack 0x240000-0x241000-0x340000
    Last edited by dreammanor; Aug 8th, 2018 at 11:39 PM.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    Hi Olaf,

    I wrote a function instead of RC5.FSO.ReadTextContent. Now jpbro's software is working fine.

    Code:
    Public Function ReadTextFile(sFileName As String, Optional ByVal bUnicode As Boolean = False) As String
        Dim nFileNum As Long:           Dim nLen 'As Long
        Dim arrByte() As Byte:              Dim sText As String
        
        On Error GoTo ErrRead
                
        nFileNum = FreeFile
        
        Open sFileName For Binary As #nFileNum
            
        nLen = LOF(nFileNum)
        If nLen Then
            ReDim arrByte(0 To nLen - 1)
            Get #nFileNum, , arrByte
            If bUnicode = True Then
                sText = StrConv(arrByte, vbUnicode)
            Else
                sText = arrByte
            End If
        End If
        
        ReadTextFile = sText
        Close #nFileNum
        Exit Function
    
    ErrRead:
        MsgBox "Reading text file is unsuccessful !" & vbCrLf & vbCrLf & Error
        On Error GoTo 0
        Close #nFileNum
    End Function
    Note:
    The above function doesn't handle IsRaw16Bit and MSCodePages because I don't know what MSCodePages is.

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,253

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    My guess is, that the (File-)Stream-based stuff in Wine requires two "matching System32-Dlls", meaning:
    - either ensure a native override also for shlwapi.dll (so that it can work in conjunction with the native override for OleAut32.dll)
    - or use both Dlls (shlwapi.dll and oleaut32.dll) in their Wine-Versions (without any Overrides).

    Your above function might work Ok, as long as you don't need Unicode-support
    (which the RC5-FSO.ReadTextContent-function supports,e.g. via CP_UTF8)

    Olaf

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    Quote Originally Posted by Schmidt View Post
    My guess is, that the (File-)Stream-based stuff in Wine requires two "matching System32-Dlls", meaning:
    - either ensure a native override also for shlwapi.dll (so that it can work in conjunction with the native override for OleAut32.dll)
    - or use both Dlls (shlwapi.dll and oleaut32.dll) in their Wine-Versions (without any Overrides).

    Your above function might work Ok, as long as you don't need Unicode-support
    (which the RC5-FSO.ReadTextContent-function supports,e.g. via CP_UTF8)

    Olaf
    Ok, I'll try your method tomorrow. Thank you, Olaf.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: RC5.FSO.ReadTextContent on Wine(Ubuntu): Automation error

    Hi Olaf,

    After I used a native override of shlwapi.dll, RC5.FSO.ReadTextContent is now working fine. Thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width