Page 2 of 2

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Wed Mar 06, 2024 6:40 am
by juergenkulow
Error Code : 0x2147483651
Your error code is a decimal value, but is marked as a hexidecimal value (0x). The test should output 0x80000003 and appear in the NTSTATUS Values table.
Whether these links from Microsoft will help, who knows:
Tips for software engineers
Bug check 0x1E: KMODE_EXCEPTION_NOT_HANDLED with more

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Wed Mar 06, 2024 10:08 am
by BarryG
@normeus: Yes, my app is indeed loading "oleacc.dll" but without a direct path. Currently like this:

Code: Select all

Global oleacc=OpenLibrary(#PB_Any,"oleacc.dll")
This was because I used this code -> https://www.purebasic.fr/english/viewto ... 29#p495029

So basically are you saying I should be hard-coding all system OpenLibrary() commands now with their full path?

@skywalk: I was able to finally ditch the last ASM code I had, so I'll try compiling with the C backend instead of ASM.

@tored: I will try that for a few days and see how it goes. No threads read the same memory; they only manipulate their own local protected variables. No GUI updates in those threads.

@juergenkulow: The decimal error value is because I was using this code -> https://www.purebasic.fr/english/viewto ... 92#p491192

It has these lines, but I changed "Exception" to "Error Code":

Code: Select all

Procedure.s DecodeException(e.i)
[...]
sCode.s = "Exception 0x" + Hex(e) + " (" + Str(e)+") <undefined>"

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Wed Mar 06, 2024 2:01 pm
by tored
BarryG wrote: Wed Mar 06, 2024 10:08 am So basically are you saying I should be hard-coding all system OpenLibrary() commands now with their full path?
Yes, that is also to prevent what is called DLL hijacking.

https://stackoverflow.com/questions/352 ... -hijacking

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 1:35 am
by BarryG
Doesn't the new compiler option to prevent DLL hijacking do that? I guess I can hard-code the path anyway.

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 2:21 am
by normeus
BarryG,
At least Hard code oleacc.dll:

Code: Select all

Global oleacc=OpenLibrary(#PB_Any,"C:\Windows\System32\oleacc.dll")
I have 29 different instances of "oleacc.dll" at least 6 of those in "C:\Windows\" under different folders on one of my computers. I think part of it might be from upgrading from Windows 7 to Windows 10. Some of your customer computers could've been upgraded that way, so the dll from microsoft gets loaded, but it might not respond the way you expect it because it is an older version.

Norm.

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 3:07 am
by BarryG
Thanks for the info, Norm. I had no idea that DLL could be in so many places. I will hard-code all system DLLs to use the "System32" folder.

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 8:11 am
by juergenkulow
Is there any experience to get the current lines of the threads and the main program and to save them by another program not simultaneously terminated by the operating system by redefining DBG_Check?

Code: Select all

!#define DBG_Check(n) 

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 9:40 am
by tored
Does the Event log in Windows say anything?

Does it depend on Windows version?

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 9:58 am
by tored
Turn on auditing of processes in Windows to get event logs when processes starts and ends with error code.

https://superuser.com/a/964667

Re: Finding a bug when Purifier and line numbering doesn't help?

Posted: Thu Mar 07, 2024 5:43 pm
by mk-soft
Smal Helpcode for Memory functions ...

Code: Select all

;-TOP
;
; Memory Debugging v0.4

CompilerIf #PB_Compiler_Debugger
  
  #MemoryStop = 1
  
  Global NewMap MemID()
  
  Procedure MyAllocateMemory(Size, Flags, Proc.s)
    Protected *mem
    *mem = AllocateMemory(Size, Flags)
    If *mem
      MemID(Hex(*mem)) = *mem
    Else
      DebuggerWarning("AllocateMemory: Out Of Memory : Proc /" + Proc)
      CompilerIf #MemoryStop : CallDebugger : CompilerEndIf
      ProcedureReturn #False
    EndIf
    ProcedureReturn *mem
  EndProcedure
  
  Procedure MyFreeMemory(Memory, Proc.s)
    If FindMapElement(MemID(), Hex(Memory))
      FreeMemory(Memory)
      DeleteMapElement(MemID())
      ProcedureReturn #True
    Else
      DebuggerWarning("FreeMemory: Memory not exists : Proc /" + Proc)
      CompilerIf #MemoryStop : CallDebugger : CompilerEndIf
      ProcedureReturn #False
    EndIf
  EndProcedure
  
  Procedure MyMemorySize(Memory, Proc.s)
    If FindMapElement(MemID(), Hex(Memory))
      ProcedureReturn MemorySize(Memory)
    Else
      DebuggerWarning("MemorySize: Memory not exists : Proc /" + Proc)
      CompilerIf #MemoryStop : CallDebugger : CompilerEndIf
      ProcedureReturn 0
    EndIf
  EndProcedure
  
  Macro AllocateMemory(Size, Flags=0)
    MyAllocateMemory(Size, Flags, #PB_Compiler_Module + "/" + #PB_Compiler_Procedure + "() - Line " + #PB_Compiler_Line)
  EndMacro
  
  Macro FreeMemory(Memory)
    MyFreeMemory(Memory, #PB_Compiler_Module + "/" + #PB_Compiler_Procedure + "() - Line " + #PB_Compiler_Line)
  EndMacro
  
  Macro MemorySize(Memory)
    MyMemorySize(Memory, #PB_Compiler_Module + "/" + #PB_Compiler_Procedure + "() - Line " + #PB_Compiler_Line)
  EndMacro
  
CompilerEndIf

;- test

CompilerIf #PB_Compiler_IsMainFile
  
  Procedure Main()
    *mem1 = AllocateMemory(1024)
    ;*mem2 = AllocateMemory(2048)
    
    Debug "Size 1: " + MemorySize(*mem1)
    Debug "Size 2: " + MemorySize(*mem2)
    
    Debug "Free 1: " + FreeMemory(*mem1)
    Debug "Free 2: " + FreeMemory(*mem2)
  EndProcedure : main()
  
CompilerEndIf