Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2006 Apr : Access violation in InternetReadFileEx

www.cryer.info
Managed Newsgroup Archive

Access violation in InternetReadFileEx

Subject:Access violation in InternetReadFileEx
Posted by:"Theo Carr-Brion" (theo.carrbri..@mitrefinch.deleteme.co.uk)
Date:Thu, 13 Apr 2006 09:19:08

I am the following error:
Access violation at address 7C80979D in module 'kernel32.dll'. Write of
address 00000014.

It occurs in InterlockedDecrement called from InternetReadFileEx. I am doing
an asynchronous http post of a text file. The data is sucessfully sent but
it crashes reading the response. The error only occurs on a few computers
(all XP SP2) and I am unable to reproduce the problem here and it works
every time.

This is how I am calling the functions. I have left out all the error
checking and use of the call back function which all appears to be working.

  lNetHandle:=InternetOpen('Application name', INTERNET_OPEN_TYPE_PRECONFIG,
                           nil, nil, INTERNET_FLAG_ASYNC);
  if lNetHandle<>nil then
  begin
      InternetSetStatusCallback(lNetHandle, @InternetCallbackFunction);
      gUrlHandle:=InternetConnect(lNetHandle, fUrlComponents.lpszHostName,
                                  INTERNET_DEFAULT_HTTPS_PORT,
                                  nil, nil, INTERNET_SERVICE_HTTP, 0,
                                  HttpConnectContext);
      gRequestHandle:=HttpOpenRequest(gUrlHandle, 'POST',
fUrlComponents.lpszUrlPath,
                         'HTTP/1.1', '', nil, INTERNET_FLAG_NO_CACHE_WRITE
or
                         INTERNET_FLAG_SECURE or INTERNET_FLAG_NO_UI or
                         INTERNET_FLAG_PRAGMA_NOCACHE, HttpRequestContext);
      lHeader:='Content-Type: text/xml'+#13+#10;
      HttpAddRequestHeaders(gRequestHandle, PChar(lHeader), Length(lHeader),
                                            HTTP_ADDREQ_FLAG_ADD
                                            or HTTP_ADDREQ_FLAG_REPLACE);
    FillChar(fBufferIn, SizeOf(INTERNET_BUFFERS), 0);
    fBufferIn.dwStructSize:=sizeof(INTERNET_BUFFERS);
    fBufferIn.dwBufferTotal:=Length(aMessage);
    HttpSendRequestEx(aRequestHandle, @fBufferIn, nil, 0,
HttpRequestContext)
    repeat
       InternetWriteFile(aRequestHandle, @fBuffer[1], K, lBytesWritten);
    until AllGone;
       repeat
          FillChar(fBufferIn, SizeOf(INTERNET_BUFFERS), 0);
          fBufferIn.dwStructSize:=SizeOf(INTERNET_BUFFERS);
          fBufferIn.lpvBuffer:=@fBuffer[1];
          fBufferIn.dwBufferLength:=1024;
          if not InternetReadFileEx(gRequestHandle, @fBufferIn, IRF_ASYNC,
                                             HttpRequestContext) then
          lBytesRead:=fBufferIn.dwBufferLength;
          if lBytesRead>0 then
                        //Save it
       until lBytesRead=0;
       InternetCloseHandle(gRequestHandle);
       InternetCloseHandle(gUrlHandle);
       InternetCloseHandle(lNetHandle);


Is anyone able to help?

Thank you

Theo Carr-Brion

Replies:

www.cryer.info
Managed Newsgroup Archive