Announcement

Collapse
No announcement yet.

Hung program.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hung program.

    I have extracted the following code from a program which
    cycles through the dll's on a system to see which support
    self registration. I noticed that the LoadLibrary API call
    never returned on certain dll's. The section of code in the

    If %False Then
    ...
    End If

    block below is an example. This code, when run on NT4 will
    never return from the LoadLibrary call, no error return, no
    return period. You cannot shut the program down from the task
    manager. It even survives a logoff and relogin. I suspect the
    framebuf.dll is running in a Ring 0 process and I am not allowed
    the module handle, but never returning is harsh. Anybody know a
    way to avoid such dll's?
    Code:
    #Compile Exe
    #Register None
    #Dim All
    $Include "win32Api.Inc"
    
    Function PbMain()
    Dim hMod As Long, ProcAddr As Long
    hMod = LoadLibrary("c:\winnt\system32\cryptui.dll") ' This works.
    MsgBox "hMod is " & Format$(hMod)
    If hMod <> 0 Then
      ProcAddr = GetProcAddress(hMod, "DllRegisterServer")
      MsgBox "ProcAddr is " & Format$(ProcAddr)
      FreeLibrary hMod
     Else
      MsgBox "LoadLibrary returned " & Format$(hMod)
    End If
    If %False Then ' If you change this you never return from LoadLibrary below.
      hMod = LoadLibrary("c:\winnt\system32\framebuf.dll") ' This never comes back.
      MsgBox "hMod is " & Format$(hMod)
      If hMod <> 0 Then
        ProcAddr = GetProcAddress(hMod, "DllRegisterServer")
        MsgBox "ProcAddr is " & Format$(ProcAddr)
        FreeLibrary hMod
       Else
        MsgBox "LoadLibrary returned " & Format$(hMod)
      End If
    End If
    End Function
    Thanks for looking, Chuck

  • #2
    When I run your code, I find that FRAMEBUF.DLL will not load (hMod = 0), and GetLastError() reports no error. So it seems your PC is locking up, but mine just returns 0. I'm running Win2000. Did you test for your problem on Win95/98, and do you have a list of other DLL's that gave you similar results? Also, did you try rebooting?

    -------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      I also find it works on W2000, but decidedly
      not on NT4. Another dll is VGA256.dll or any
      VGS???.dll on NT4.

      What do you think might be causing the hang?
      These seem to be deep level hardware driver
      dll's. I am concerned that any attempt to use
      LoadLibrary with these dll's will stop, absolutely
      stop your program. Also TaskManager on NT4 will
      not shut down this app. Nothing short of a full
      reboot seems to remove it from Memory. Microsoft
      Visual Basic has the same behavior.

      Chuck

      Comment


      • #4
        Have you tried performing this task in a separate thread (for each DLL you test), and use TerminateThread() if the thread does not respond in an appropriate time?

        I have no idea how much of a leak this may cause, but it may be worth a try.

        -------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X