🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13237

Re: Unexpected Access Violation when calling WriteFile()

#13237
From: Remy Lebeau (TeamB)
Date: Tue, 21 Oct 2003 17:40
23 lines
1778 bytes
"Fernando" <frr@easyjob.net> wrote in message
news:7bhapvkde568fjnf10ruf9t114kirltdr5@4ax.com...

>     LPDWORD bytesWritten;

That is wrong.  Anything in the Win32 API that starts with "LP" is a pointer
(formerly known as "long pointer", hense "LP").  So, essentially what is
happening is that you are declaring an uninitialized pointer and then
passing it to WriteFile() to fill in, but you did not allocate any actual
storage space for the value, thus the AV.  You need to change the
declaration to not use a pointer, and then use the '&' address operator when
passing it to WriteFile(), ie:

    bool writeToFile( HANDLE aFileHandle, void * data,  DWORD numOfBytes )
    {
        DWORD bytesWritten;
        return ::WriteFile( aFileHandle, data, numOfBytes, &bytesWritten,
NULL );
    }


Gambit
Technical Details
Message-ID: <3f956f17@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <7bhapvkde568fjnf10ruf9t114kirltdr5@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,6fe7d1767c79674a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-21 10:44:39 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <7bhapvkde568fjnf10ruf9t114kirltdr5@4ax.com>
Subject: Re: Unexpected Access Violation when calling WriteFile()
Date: Tue, 21 Oct 2003 10:40:57 -0700
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.75
Message-ID: <3f956f17@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066757911 67.22.137.75 (21 Oct 2003 10:38:31 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail