Archived

This topic is now archived and is closed to further replies.

Problems using FindFirstFile in NT

This topic is 5978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to read in the contents of a directory on an NTFS volume, but I always get an access violation in ntdll.dll. It''s trying to reference 0x00000000. Any ideas as to what might be causing this? Eric

Share this post


Link to post
Share on other sites
It''s the first thing that gets called after my window creation section. The call is:

WIN32_FIND_DATA data;
FindFirstFile("C:\\*", data);

It crashes while attempting to complete this function.

I''m using VC++ 5.0 SP3

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
WIN32_FIND_DATA * data;
FindFirstFile("C:\\*", data);

Here''s the problem; data is a pointer to somewhere in memory at random. In a debug release it may be NULL, but the point is you need to pass in a pointer to some memory that FindFirstFile can fill out. So create a WIN32_FIND_DATA structure on the stack using :

WIN32_FIND_DATA data;

then tell the function where the data is on the stack using

FindFirstFile( "C:\\*", &data );

Share this post


Link to post
Share on other sites
Your code would cause an error like that, like Anon said. But I''m assuming you would know to initialize the pointer before something like that, so I''m guessing you just didn''t include the pointer being initialized in the code in your post. If that''s the case, I have no idea what''s wrong. But, if you didn''t initialize the pointer, then definately fix that, or just don''t use a pointer at all and pass the structure itself by reference.

Share this post


Link to post
Share on other sites