From: Bu on
Hello,

Some time ago i sucseeded with the aid of readers from these
newsgroups, in reading and writing raw to a sector on a USB stick
under VB6.
The solution was to us the following calls: Private Declare Function
ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal
nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal
lpOverlapped As Any) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As
Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long,
lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long

However the problem with this is that you can only access the sectors
in a volume of the memory stick. You are not able to read/write the
really first sector on the stick (the MBR).

Does anybody know how you can read and write to the first sector
(sector 0) on a USB stick under VB6 (and Windows XP)?
Bu
From: Mark Pryor on
On Fri, 15 Jan 2010 23:19:16 +0100, Bu wrote:

> Hello,
>
> Some time ago i sucseeded with the aid of readers from these newsgroups,
> in reading and writing raw to a sector on a USB stick under VB6.
> The solution was to us the following calls: Private Declare Function
> ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal
> nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal
> lpOverlapped As Any) As Long
> Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long,
> lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long,
> lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
>
> However the problem with this is that you can only access the sectors in
> a volume of the memory stick. You are not able to read/write the really
> first sector on the stick (the MBR).
>
> Does anybody know how you can read and write to the first sector (sector
> 0) on a USB stick under VB6 (and Windows XP)? Bu

go here:
http://unxutils.sourceforge.net/

the 'dd' utility will do it (read and write). Use the shell or
shellexecute to call it. Write or find a Hex2String/HexFromString method
to convert to and from the binary buffer.

--
Mark
From: Auric__ on
On Wed, 20 Jan 2010 08:06:59 GMT, Mark Pryor wrote:

> On Fri, 15 Jan 2010 23:19:16 +0100, Bu wrote:
>
>> Hello,
>>
>> Some time ago i sucseeded with the aid of readers from these newsgroups,
>> in reading and writing raw to a sector on a USB stick under VB6.
>> The solution was to us the following calls: Private Declare Function
>> ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal
>> nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal
>> lpOverlapped As Any) As Long
>> Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long,
>> lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long,
>> lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
>>
>> However the problem with this is that you can only access the sectors in
>> a volume of the memory stick. You are not able to read/write the really
>> first sector on the stick (the MBR).
>>
>> Does anybody know how you can read and write to the first sector (sector
>> 0) on a USB stick under VB6 (and Windows XP)? Bu
>
> go here:
> http://unxutils.sourceforge.net/
>
> the 'dd' utility will do it (read and write). Use the shell or
> shellexecute to call it. Write or find a Hex2String/HexFromString method
> to convert to and from the binary buffer.

If you're going to go this route, GnuWin32 is a bit more up-to-date. dd is
part of the coreutils package (last updated 2005, vs 2003 for unxutils),
available here:
http://gnuwin32.sourceforge.net/packages/coreutils.htm

For this, you should get the "Complete package, except sources" package, or
the sources zip to see how it's done.

--
You can't uninstall evil.
From: Bu on
On Wed, 20 Jan 2010 15:00:37 GMT, "Auric__"
<not.my.real(a)email.address> wrote:

>On Wed, 20 Jan 2010 08:06:59 GMT, Mark Pryor wrote:
>
>> On Fri, 15 Jan 2010 23:19:16 +0100, Bu wrote:
>>
>>> Hello,
>>>
>>> Some time ago i sucseeded with the aid of readers from these newsgroups,
>>> in reading and writing raw to a sector on a USB stick under VB6.
>>> The solution was to us the following calls: Private Declare Function
>>> ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal
>>> nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal
>>> lpOverlapped As Any) As Long
>>> Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long,
>>> lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long,
>>> lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
>>>
>>> However the problem with this is that you can only access the sectors in
>>> a volume of the memory stick. You are not able to read/write the really
>>> first sector on the stick (the MBR).
>>>
>>> Does anybody know how you can read and write to the first sector (sector
>>> 0) on a USB stick under VB6 (and Windows XP)? Bu
>>
>> go here:
>> http://unxutils.sourceforge.net/
>>
>> the 'dd' utility will do it (read and write). Use the shell or
>> shellexecute to call it. Write or find a Hex2String/HexFromString method
>> to convert to and from the binary buffer.
>
>If you're going to go this route, GnuWin32 is a bit more up-to-date. dd is
>part of the coreutils package (last updated 2005, vs 2003 for unxutils),
>available here:
> http://gnuwin32.sourceforge.net/packages/coreutils.htm
>
>For this, you should get the "Complete package, except sources" package, or
>the sources zip to see how it's done.

Marc Auric thanks for the responses
Bu