Author Topic: Unexplained application crashes when using uncom  (Read 518 times)

Quin

  • Full Member
  • ***
  • Posts: 113
    • View Profile
    • Quin's site
Re: Unexplained application crashes when using uncom
« Reply #15 on: October 11, 2024, 11:33:02 AM »
The Voice Object is already a global.

Going back to your original code, I tried this:

Code: [Select]
        Case ID_MenuExit
            If IsObject(Voice) Then UNCOM(Voice)
            PostMessage(hWnd, WM_QUIT, 0, 0)
            Exit Function

And the crashing went away...

AIR.
Very interesting! I have utterly no idea why that would be, but thanks for your help! I wonder if the same thing would apply to the update hiding utility?
Unfortunately, long-covid currently has me firmly in its grasps and so probably no coding for the next couple days :( once I'm back in the game though this looks quite promising.
Thanks again for all your help!

airr

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #16 on: October 11, 2024, 11:34:46 AM »
Dangling Reference (typical C)?

Hope you feel better soon, Quin!

AIR.

Quin

  • Full Member
  • ***
  • Posts: 113
    • View Profile
    • Quin's site
Re: Unexplained application crashes when using uncom
« Reply #17 on: October 16, 2024, 06:09:23 PM »
Airr,
I can confirm that this did in fact fix the crash in the battery utility. Thanks for all your help!
I'll do more testing with that update utility and see what I can find.

Robert

  • Hero Member
  • *****
  • Posts: 1245
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #18 on: October 17, 2024, 04:55:06 AM »
Airr,
I can confirm that this did in fact fix the crash in the battery utility. Thanks for all your help!
I'll do more testing with that update utility and see what I can find.

Hi Quin:

Each COMSET object must be terminated with an UNCOM before an END statement.

In your original post updates code change from
 
Code: [Select]
If NumUpdates = 0 Then
    Print "No updates were found."
    End
End If

to

Code: [Select]
IF NumUpdates = 0 THEN
  PRINT "No updates were found."
  UNCOM(SearchResult)
  UNCOM(Searcher)
  UNCOM(Session)
  END
END IF

and change

Code: [Select]
If Input$ = "" Then End
to

Code: [Select]
IF UpdatesToHide$ = "" THEN
  UNCOM(Updates)
  UNCOM(SearchResult)
  UNCOM(Searcher)
  UNCOM(Session)
  END
END IF

And at the end of your updates program reorder the UNCOM statements to: first COMSET object in, last matching UNCOM out

Code: [Select]
UNCOM(Update)
UNCOM(Updates)
UNCOM(SearchResult)
UNCOM(Searcher)
UNCOM(Session)

Quin

  • Full Member
  • ***
  • Posts: 113
    • View Profile
    • Quin's site
Re: Unexplained application crashes when using uncom
« Reply #19 on: October 18, 2024, 08:40:46 AM »
Robert,
Thanks for all your help! Unfortunately though, that doesn't seem to have fixed it. If I don't type anything and let those uncom statements run there's no crash, it's only after I've successfully hidden at least one update that it crashes.
Latest code for reference:
Code: [Select]
#include <wuapi.h>

BCX_Show_COM_Errors(True)

Dim As Object Session, Searcher, SearchResult, Update, Updates
Dim NumUpdates, I
Comset Session = Com("Microsoft.Update.Session")
Comset Searcher = Session.CreateupdateSearcher()
Searcher.ClientApplicationID = "uphide"
Print "Checking for updates..."
Comset SearchResult = Searcher.Search("IsInstalled=0 And IsHidden=0")
NumUpdates = SearchResult.Updates.Count
If NumUpdates = 0 Then
    Print "No updates were found."
    Uncom(SearchResult)
    Uncom(Searcher)
    Uncom(Session)
    End
End If
Print "Enter the numbers of the updates you want to hide, seperated by spaces, and press enter. Leave blank to exit."
Dim Index = 1
Comset Updates = SearchResult.Updates
For Each Item In Updates
    Dim Title$
    Title$ = Item.Title
    Print Str$(Index, 1) & ": " & Title$
    Index++
Next
Dim Input$
Input Input$
If Input$ = "" Then
    Uncom(Updates)
    Uncom(SearchResult)
    Uncom(Searcher)
    Uncom(Session)
    End
End If
Dim NumSelections
Dim ToHide[100] As String
NumSelections = Split(ToHide, Input$, " ", 0)
For I = 0 To NumSelections - 1
    Dim CurIndex
    CurIndex = Val(ToHide[I])
    If CurIndex <= 0 Or CurIndex > NumUpdates Then Continue
    Comset Update = Updates.Item(CurIndex - 1)
    Dim Title$
    Title$ = Update.Title
    Update.Ishidden = True
    Print "Hid " & Title$
Next
Pause
Uncom(Update)
Uncom(Updates)
Uncom(SearchResult)
Uncom(Searcher)
Uncom(Session)
Did I miss something?'Thanks,
Quin.

airr

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #20 on: October 18, 2024, 07:27:16 PM »
Try "UCOM(Update)" in the loop after you've set the ".IsHidden" property? Also, is the property name case-sensitive?

AIR.

nagrom

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #21 on: October 20, 2024, 01:03:51 AM »
Try "UCOM(Update)" in the loop

AIR.
absolutly a must.

airr

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #22 on: October 21, 2024, 02:17:31 AM »
Hi, nagrom, I just wanted to welcome you to the forum!

AIR.

Edit:  I see what you did there!

Quin

  • Full Member
  • ***
  • Posts: 113
    • View Profile
    • Quin's site
Re: Unexplained application crashes when using uncom
« Reply #23 on: October 21, 2024, 08:34:58 AM »
I completely expected this to fix it, but it actually didn't, bafflingly enough. All I did was move the Uncom(Update) line to right after the Update.IsHidden = True line, and I fixed the case on that line too. The same crash occurs, only after successfully hiding at least one update.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2330
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #24 on: October 21, 2024, 08:56:55 AM »
I completely expected this to fix it, but it actually didn't, bafflingly enough. All I did was move the Uncom(Update) line to right after the Update.IsHidden = True line, and I fixed the case on that line too. The same crash occurs, only after successfully hiding at least one update.

I'm curious whether you've tried doing this in vbscript or powershell. 

That might help isolate the root cause of this stubbornness.

Quin

  • Full Member
  • ***
  • Posts: 113
    • View Profile
    • Quin's site
Re: Unexplained application crashes when using uncom
« Reply #25 on: October 21, 2024, 11:08:07 AM »
Kevin,
Yes, I've tried it in powershell, and it works perfectly fine. Just to be clear, it works perfectly fine here, too, the updates get hidden and don't show up again, but it's crashing somewhere after hiding all of them on exit.

airr

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #26 on: October 23, 2024, 05:11:21 AM »
Hi, Quin.

I tried this:
Code: [Select]
For I = 0 To NumSelections - 1
    Dim CurIndex
    CurIndex = Val(ToHide[I])
    If CurIndex <= 0 Or CurIndex > NumUpdates Then Continue
    Comset Update = Updates.Item(CurIndex - 1)
    If IsObject(Update) Then
        Dim Title$
        Title$ = Update.Title
        Update.IsHidden = True
        Print "Hid " & Title$
        Uncom(Update)
    End If
Next

And it successfully executed with no issue.  I ran the resulting binary as Admin (I didn't include the .res file that configures the .exe for elevation, for testing purposes).

AIR.

Edit:  Compiled with the UAC res file, no apparent issues.  Ran it through WinDBG, no crashes.
« Last Edit: October 23, 2024, 05:47:37 AM by airr »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2330
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #27 on: October 23, 2024, 10:32:35 AM »

AIR.

Edit:  Compiled with the UAC res file, no apparent issues.


Can someone share the "UAC res file" ?

Inquiring minds and all that ...

airr

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #28 on: October 23, 2024, 11:42:21 AM »

AIR.

Edit:  Compiled with the UAC res file, no apparent issues.


Can someone share the "UAC res file" ?

Inquiring minds and all that ...

See attachment...

AIR.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2330
    • View Profile
Re: Unexplained application crashes when using uncom
« Reply #29 on: October 23, 2024, 12:22:40 PM »
I found the earlier error of my ways ( see screenshot )

If compiling with BED, need to uncheck the default manifest inclusion.

Now it compiles, executes, and closes as it should. -- No issues.