Article View: borland.public.cppbuilder.nativeapi
Article #11064Re: Problems writing boot record to removable media under WinME
From: Bob Gonder
Date: Tue, 02 Mar 2004 03:01
Date: Tue, 02 Mar 2004 03:01
63 lines
3191 bytes
3191 bytes
Walt Morrey wrote:
> reg1.reg_EAX = 0x440D;
> reg1.reg_EBX = drive + 1; // 1 = A, 2 = B, etc
> reg1.reg_ECX = 0x4848; // try upper=48 for FAT32
> reg1.reg_EDX = (DWORD)&ParamBlock;
> fResult = DeviceIoControl ( hDevice, VWIN32_DIOC_DOS_IOCTL,
> &(reg1), sizeof (reg1),
> &(reg1), sizeof (reg1),
> &cb, 0);
> if ( !fResult )
> {
> reg1.reg_ECX = 0x0848; // try FAT16, or 12 & Lock/Unlock - 0x48
Is it written somewhere that the registers remain unchanged?
Especially when the same registers are used for return values?
> fResult = DeviceIoControl ( hDevice, VWIN32_DIOC_DOS_IOCTL,
> &(reg1), sizeof (reg1),
> &(reg1), sizeof (reg1),
> &cb, 0);
>BOOL WriteSectors(int drive, DWORD startinglogicalsector, int numberofsectors, char*buffer)
>{
> char _devicename[] = "\\\\.\\A:";
> _devicename[4] += drive;
_devicename[4] = 'A' + drive;
> hDevice = CreateFile(_devicename,
> GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
> NULL, OPEN_EXISTING, 0, NULL);
Are you going to write it or just read it?
> SetFilePointer (hDevice, (startinglogicalsector*512), NULL, FILE_BEGIN);
> if (!WriteFile (hDevice, buffer, 512*numberofsectors, &bytesread, NULL) )
Is this kosher? Thought you were supposed to use
DeviceIoControl.
> else
> {
> // code for win 95/98
>// Creating handle to vwin32.vxd (win 9x)
> if ( !fResult )
> {
> SetLock( 1, hDevice, drive ); // 0 to Lock
> CloseHandle(hDevice);
> return FALSE;
> }
> SetLock( 1, hDevice, drive ); // 0 to Lock
> CloseHandle(hDevice);
> return TRUE;
That looks redundant to me....
SetLock( 1, hDevice, drive ); // 0 to Lock
CloseHandle(hDevice);
return fResult;
Technical Details
Message-ID:
<kbs7409ien56crro53tr9i26s1p6n3cv44@4ax.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-mailReferences:
<40437604@newsgroups.borland.com> <404380f3$1@newsgroups.borland.com> <40439482$1@newsgroups.borland.com> <40439fa5$1@newsgroups.borland.com> <4043a4e7$1@newsgroups.borland.com> <4043ae8f$2@newsgroups.borland.com> <4043b610@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5a57fca3b977b3f5 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-01 19:09:57 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Problems writing boot record to removable media under WinME Date: Mon, 01 Mar 2004 19:01:05 -0800 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <kbs7409ien56crro53tr9i26s1p6n3cv44@4ax.com> References: <40437604@newsgroups.borland.com> <404380f3$1@newsgroups.borland.com> <40439482$1@newsgroups.borland.com> <40439fa5$1@newsgroups.borland.com> <4043a4e7$1@newsgroups.borland.com> <4043ae8f$2@newsgroups.borland.com> <4043b610@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.31.165.176 X-Trace: newsgroups.borland.com 1078196463 67.31.165.176 (1 Mar 2004 19:01:03 -0800) Lines: 66 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