LoadLibrary('winhttp.dll') causes access violation

delphi package - automated exception handling
Post Reply
anders
Posts: 7
Joined: Wed Oct 05, 2016 1:54 pm

LoadLibrary('winhttp.dll') causes access violation

Post by anders »

I've found that posting bug reports via http consistently causes an access violation in TWinHttp.Create's call to LoadLibrary('winhttp.dll').

It's been a while since I researched the cause but AFAIR the library needs to be loaded from the main thread in order to avoid the problem.
Consequently I have the following work around in my applications:

Code: Select all

initialization
  (*
  ** We need to load winhttp.dll before the MadExcept thread needs it to avoid an exception in MadExcept's call to
  ** LoadLibrary.
  *)
  LoadLibrary('winhttp.dll');
finalization
  ...
end.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: LoadLibrary('winhttp.dll') causes access violation

Post by madshi »

That sounds weird, I've never had this problem myself. Can you share a crash report? Does it only occur on older OSs?
anders
Posts: 7
Joined: Wed Oct 05, 2016 1:54 pm

Re: LoadLibrary('winhttp.dll') causes access violation

Post by anders »

Reproduced on Win7SP1 and Win10r1607

It appears that the problem is caused by BitDefender anti-virus.

The exception occurs inside kernel32.LoadLibrary but the stack reveals that BitDefender has hooked into it.

The exception is caught and handled before LoadLibrary returns so it doesn't appear to cause any visible damage. In any case I think it safest that I keep my work around in place since there's no way to know what the side effects of an access violation in the kernel are.

Code: Select all

:74d4c8ba ; C:\Program Files\Bitdefender\Antivirus Free Edition\avc3\avc3_sig_369\avcuf32.dll
:74d4cfd9 ; C:\Program Files\Bitdefender\Antivirus Free Edition\avc3\avc3_sig_369\avcuf32.dll
:74dbe447 ; C:\Program Files\Bitdefender\Antivirus Free Edition\avc3\avc3_sig_369\avcuf32.dll
:74d4c453 ; C:\Program Files\Bitdefender\Antivirus Free Edition\avc3\avc3_sig_369\avcuf32.dll
:00030115 
:77c9c644 ; ntdll.dll
:77c9d435 ; ntdll.dll
:77c9d139 ; ntdll.dll
:77cddd1f ; ntdll.dll
:76ed2e0f ; C:\Windows\syswow64\KERNELBASE.dll
:74dbe49f ; C:\Program Files\Bitdefender\Antivirus Free Edition\avc3\avc3_sig_369\avcuf32.dll
:74d4c35c ; C:\Program Files\Bitdefender\Antivirus Free Edition\avc3\avc3_sig_369\avcuf32.dll
:00030115
:77204904 kernel32.LoadLibraryW + 0x11
madExcept.TWinHttp.Create(???,False,80,False,'','','','','','','','',TIMEException($A637DDC) as IMESettings,TIProgressAlert($1C92D094) as IProgressAlert)
madExcept.SendBugReportEx('...
madExcept.TIMEException.SendBugReport(0)
UMain.TFMain.MadExceptHandler(TIMEException($A637FF0) as IMEException,False)
madExcept.FireHandlers((0, eaSendBugReport, TIMEException($A637FF0) as IMEException, False, False, False))
madExcept.DoFireHandlers(0,0,eaSendBugReport,TIMEException($A637FF0) as IMEException,False)
madExcept.ReceiveHandleException($A7BFEF4)
madExcept.HandleExceptionThread(nil)
:7720338a kernel32.BaseThreadInitThunk + 0x12
:77c9a242 ntdll.RtlInitializeExceptionChain + 0x63
:77c9a215 ntdll.RtlInitializeExceptionChain + 0x36
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: LoadLibrary('winhttp.dll') causes access violation

Post by madshi »

Interesting! But yeah, I agree that keeping the workaround should at least not harm.
Post Reply