How to initialize OBJECT_ATTRIBUTES and IO_STATUS_BLOCK variable before use??

This is my source code: and the errors are the compile error in DDK
How to initialize them before use??

Thanks in advance!

POBJECT_ATTRIBUTES myObjectAttr;
PUNICODE_STRING myObjectName;
ULONG myAttr;
PIO_STATUS_BLOCK myIoStatus;
myObjectName=L"??\C:\CopyFile\test.txt";
//Initial object attributes
InitializeObjectAttributes(myObjectAttr,
myObjectName,
OBJ_KERNEL_HANDLE,
NULL,
NULL);
//here we create our file object
ZwCreateFile(FileCopy,GENERIC_READ|GENERIC_WRITE,
myObjectAttr,myIoStatus,NULL,FILE_ATTRIBUTE_NORMAL,
NULL,FILE_OPEN_IF,FILE_NO_INTERMEDIATE_BUFFERING,NULL,0);

error C4700: local variable ‘myObjectAttr’ used without havin
g been initialized
error C4700: local variable ‘myIoStatus’ used without having
been initialized

2 files compiled - 32 Warnings - 2 Errors


Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com

Your object_attrs and IO_ST_BLOCK must be allocated, either on the stack
or dynamically. You have only pointers…

Pete

Peter Scott
xxxxx@KernelDrivers.com
http://www.KernelDrivers.com

>-----Original Message-----
>From: xxxxx@lists.osr.com [mailto:bounce-ntfsd-
>xxxxx@lists.osr.com] On Behalf Of gaoren
>Sent: Tuesday, May 14, 2002 8:03 AM
>To: File Systems Developers
>Subject: [ntfsd] How to initialize OBJECT_ATTRIBUTES and
IO_STATUS_BLOCK
>variable before use??
>
>This is my source code: and the errors are the compile error in DDK
>How to initialize them before use??
>
>Thanks in advance!
>
> POBJECT_ATTRIBUTES myObjectAttr;
> PUNICODE_STRING myObjectName;
> ULONG myAttr;
> PIO_STATUS_BLOCK myIoStatus;
> myObjectName=L"??\C:\CopyFile\test.txt";
> //Initial object attributes
> InitializeObjectAttributes(myObjectAttr,
> myObjectName,
> OBJ_KERNEL_HANDLE,
> NULL,
> NULL);
> //here we create our file object
> ZwCreateFile(FileCopy,GENERIC_READ|GENERIC_WRITE,
>
> myObjectAttr,myIoStatus,NULL,FILE_ATTRIBUTE_NORMAL,
>
> NULL,FILE_OPEN_IF,FILE_NO_INTERMEDIATE_BUFFERING,NULL,0);
>
>
>error C4700: local variable ‘myObjectAttr’ used without havin
>g been initialized
>error C4700: local variable ‘myIoStatus’ used without having
>been initialized
>
> 2 files compiled - 32 Warnings - 2 Errors
>
>
>_________________________________________________________
>
>Do You Yahoo!?
>
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>
>—
>You are currently subscribed to ntfsd as: xxxxx@KernelDrivers.com
>To unsubscribe send a blank email to %%email.unsub%%

Too many errors to discuss anything, just the same with some fixes below:

OBJECT_ATTRIBUTES myObjectAttr;
UNICODE_STRING myObjectName;
ULONG myAttr;
IO_STATUS_BLOCK myIoStatus;

RtlInitUnicodeString(myObjectName, L"??\C:\CopyFile\test.txt");

//Initial object attributes
InitializeObjectAttributes(&myObjectAttr,
&myObjectName,
OBJ_KERNEL_HANDLE,
NULL,
NULL);

//here we create our file object
ZwCreateFile(FileCopy,GENERIC_READ|GENERIC_WRITE,
&myObjectAttr,&myIoStatus,NULL,FILE_ATTRIBUTE_NORMAL,
NULL,FILE_OPEN_IF,FILE_NO_INTERMEDIATE_BUFFERING,NULL,0);

BR,
Vadim

Just declare the variables on the stack like

OBJECT_ATTRIBUTES myObjectAttr;
IO_STATUS_BLOCK myIoStatus;

instead of pointers and pass their address to
the “InitializeObjectAttributes” macro. That
should do fine.

Sathish.

----- Original Message -----
From: “gaoren”
To: “File Systems Developers”
Sent: Tuesday, May 14, 2002 7:33 PM
Subject: [ntfsd] How to initialize OBJECT_ATTRIBUTES and IO_STATUS_BLOCK
variable before use??

> This is my source code: and the errors are the compile error in DDK
> How to initialize them before use??
>
> Thanks in advance!
>
> POBJECT_ATTRIBUTES myObjectAttr;
> PUNICODE_STRING myObjectName;
> ULONG myAttr;
> PIO_STATUS_BLOCK myIoStatus;
> myObjectName=L"??\C:\CopyFile\test.txt";
> //Initial object attributes
> InitializeObjectAttributes(myObjectAttr,
> myObjectName,
> OBJ_KERNEL_HANDLE,
> NULL,
> NULL);
> //here we create our file object
> ZwCreateFile(FileCopy,GENERIC_READ|GENERIC_WRITE,
> myObjectAttr,myIoStatus,NULL,FILE_ATTRIBUTE_NORMAL,
> NULL,FILE_OPEN_IF,FILE_NO_INTERMEDIATE_BUFFERING,NULL,0);
>
> error C4700: local variable ‘myObjectAttr’ used without havin
> g been initialized
> error C4700: local variable ‘myIoStatus’ used without having
> been initialized
>
> 2 files compiled - 32 Warnings - 2 Errors
>
>
> _________________________________________________________
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@srasys.co.in
> To unsubscribe send a blank email to %%email.unsub%%
>
>

Thanks all the replys.
I am more clear now.

newbie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Sathish Kumar
Sent: Tuesday, May 14, 2002 10:23 AM
To: File Systems Developers
Subject: [ntfsd] Re: How to initialize OBJECT_ATTRIBUTES and IO_STATUS_BLOCK
variable before use??

Just declare the variables on the stack like

OBJECT_ATTRIBUTES myObjectAttr;
IO_STATUS_BLOCK myIoStatus;

instead of pointers and pass their address to
the “InitializeObjectAttributes” macro. That
should do fine.

Sathish.

----- Original Message -----
From: “gaoren”
To: “File Systems Developers”
Sent: Tuesday, May 14, 2002 7:33 PM
Subject: [ntfsd] How to initialize OBJECT_ATTRIBUTES and IO_STATUS_BLOCK
variable before use??

> This is my source code: and the errors are the compile error in DDK
> How to initialize them before use??
>
> Thanks in advance!
>
> POBJECT_ATTRIBUTES myObjectAttr;
> PUNICODE_STRING myObjectName;
> ULONG myAttr;
> PIO_STATUS_BLOCK myIoStatus;
> myObjectName=L"??\C:\CopyFile\test.txt";
> //Initial object attributes
> InitializeObjectAttributes(myObjectAttr,
> myObjectName,
> OBJ_KERNEL_HANDLE,
> NULL,
> NULL);
> //here we create our file object
> ZwCreateFile(FileCopy,GENERIC_READ|GENERIC_WRITE,
> myObjectAttr,myIoStatus,NULL,FILE_ATTRIBUTE_NORMAL,
> NULL,FILE_OPEN_IF,FILE_NO_INTERMEDIATE_BUFFERING,NULL,0);
>
> error C4700: local variable ‘myObjectAttr’ used without havin
> g been initialized
> error C4700: local variable ‘myIoStatus’ used without having
> been initialized
>
> 2 files compiled - 32 Warnings - 2 Errors
>
>
>
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@srasys.co.in
> To unsubscribe send a blank email to %%email.unsub%%
>
>


You are currently subscribed to ntfsd as: xxxxx@yahoo.ca
To unsubscribe send a blank email to %%email.unsub%%



Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com