Read\write sector on Partition1?

I will read\write sector on Partition1.
OS - Windows NT 4.0.
Help me.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

From user mode - open “\.\C:” and use Read/WriteFile. Accessible for administrators only.
From kernel mode - build an IRP and send it down.

Max

----- Original Message -----
From:
To: “File Systems Developers”
Sent: Saturday, December 22, 2001 5:21 PM
Subject: [ntfsd] Read\write sector on Partition1?

> I will read\write sector on Partition1.
> OS - Windows NT 4.0.
> Help me.
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Thanks.
I make IRP.
My code work with Partition0, but with Partition1 dont work.

Code:
#define NT_TARGET_DEVICE_NAME L"\Device\Harddisk0\Partition0"

RtlInitUnicodeString(&uniTargetNameString, NT_TARGET_DEVICE_NAME);
ccode=IoGetDeviceObjectPointer(&uniTargetNameString,
FILE_READ_DATA&FILE_WRITE_DATA,
&FilePtr,
&DevicePtr);
if(!NT_SUCCESS(ccode)){
DbgPrint(“Error %xh(%d) getting device.\n”, ccode, ccode);
}else{
DbgPrint(“Get device successfully.\n”);
/*Make IRP for reading sector*/
SecNum.QuadPart=(LONGLONG) 0;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp=IoBuildSynchronousFsdRequest(IRP_MJ_READ,
DevicePtr,
Buffer,
512,
&SecNum,
&Event,
&IO);
if(!Irp){
DbgPrint(“Error making IRP.\n”);
ccode=STATUS_MEMORY_NOT_ALLOCATED;
}else{
ccode=IoCallDriver(DevicePtr, Irp);
if(ccode==STATUS_PENDING){
KeWaitForSingleObject(&Event,
Suspended,
KernelMode,
FALSE,
NULL);
ccode=IO.Status;
}
if(ccode==STATUS_SUCCESS){
for(i=0; i<512; i++){
DbgPrint(“%02x “, Buffer[i]);
}
DbgPrint(”\n”);
}
}
ObDereferenceObject(FilePtr);


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi,
I feel that the file system driver is up before your driver and hence you
may be facing this problem. On the similar lines, the success on the
partition0 is obvious as, at any point of time no file system will be
mounted on this. The solution to this would be to write a driver that comes
up much before the file system driver coming up.

Hope this helps…

Regards,
Prasanna.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@okbsapr.ru
Sent: Monday, December 24, 2001 3:42 AM
To: File Systems Developers
Subject: [ntfsd] Re: Read\write sector on Partition1?

Thanks.
I make IRP.
My code work with Partition0, but with Partition1 dont work.

Code:
#define NT_TARGET_DEVICE_NAME L"\Device\Harddisk0\Partition0"

RtlInitUnicodeString(&uniTargetNameString, NT_TARGET_DEVICE_NAME);
ccode=IoGetDeviceObjectPointer(&uniTargetNameString,
FILE_READ_DATA&FILE_WRITE_DATA,
&FilePtr,
&DevicePtr);
if(!NT_SUCCESS(ccode)){
DbgPrint(“Error %xh(%d) getting device.\n”, ccode, ccode);
}else{
DbgPrint(“Get device successfully.\n”);
/*Make IRP for reading sector*/
SecNum.QuadPart=(LONGLONG) 0;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp=IoBuildSynchronousFsdRequest(IRP_MJ_READ,
DevicePtr,
Buffer,
512,
&SecNum,
&Event,
&IO);

!Irp){

DbgPrint(“Error making IRP.\n”);
ccode=STATUS_MEMORY_NOT_ALLOCATED;
}else{
ccode=IoCallDriver(DevicePtr, Irp);
if(ccode==STATUS_PENDING){
KeWaitForSingleObject(&Event,
Suspended,
KernelMode,
FALSE,
NULL);
ccode=IO.Status;
}
if(ccode==STATUS_SUCCESS){
for(i=0; i<512; i++){
DbgPrint(“%02x “, Buffer[i]);
}
DbgPrint(”\n”);
}
}
ObDereferenceObject(FilePtr);


You are currently subscribed to ntfsd as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello,
Sorry I forgot to mention more info…
There is one more way
Don’t format the disk with any file system and I guess the code you have
given should work.
I mean, try this code on raw partition without any file system.

Regards,
Prasanna.

-----Original Message-----
From: Prasanna B R [mailto:xxxxx@tataelxsi.co.in]
Sent: Monday, December 24, 2001 2:28 PM
To: File Systems Developers
Subject: RE: [ntfsd] Re: Read\write sector on Partition1?

Hi,
I feel that the file system driver is up before your driver and
hence you may be facing this problem. On the similar lines, the
success on the partition0 is obvious as, at any point of time no
file system will be mounted on this. The solution to this would
be to write a driver that comes up much before the file system
driver coming up.

Hope this helps…

Regards,
Prasanna.

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@okbsapr.ru
> Sent: Monday, December 24, 2001 3:42 AM
> To: File Systems Developers
> Subject: [ntfsd] Re: Read\write sector on Partition1?
>
>
> Thanks.
> I make IRP.
> My code work with Partition0, but with Partition1 dont work.
>
> Code:
> #define NT_TARGET_DEVICE_NAME L"\Device\Harddisk0\Partition0"
> …
> RtlInitUnicodeString(&uniTargetNameString, NT_TARGET_DEVICE_NAME);
> ccode=IoGetDeviceObjectPointer(&uniTargetNameString,
> FILE_READ_DATA&FILE_WRITE_DATA,
> &FilePtr,
> &DevicePtr);
> if(!NT_SUCCESS(ccode)){
> DbgPrint(“Error %xh(%d) getting device.\n”, ccode, ccode);
> }else{
> DbgPrint(“Get device successfully.\n”);
> /*Make IRP for reading sector*/
> SecNum.QuadPart=(LONGLONG) 0;
> KeInitializeEvent(&Event, NotificationEvent, FALSE);
> Irp=IoBuildSynchronousFsdRequest(IRP_MJ_READ,
> DevicePtr,
> Buffer,
> 512,
> &SecNum,
> &Event,
> &IO);
>
!Irp){
> DbgPrint(“Error making IRP.\n”);
> ccode=STATUS_MEMORY_NOT_ALLOCATED;
> }else{
> ccode=IoCallDriver(DevicePtr, Irp);
> if(ccode==STATUS_PENDING){
> KeWaitForSingleObject(&Event,
> Suspended,
> KernelMode,
> FALSE,
> NULL);
> ccode=IO.Status;
> }
> if(ccode==STATUS_SUCCESS){
> for(i=0; i<512; i++){
> DbgPrint(“%02x “, Buffer[i]);
> }
> DbgPrint(”\n”);
> }
> }
> ObDereferenceObject(FilePtr);
> …
>
> —
> You are currently subscribed to ntfsd as: xxxxx@tataelxsi.co.in
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com