Parameters for CreateFile (Driver Development)

Status
Not open for further replies.

Zhou He

Level 1
Thread author
Mar 13, 2017
7
I'm trying to write IOCTL example based on samples from Microsoft's Github repo: Windows-driver-samples/testapp.c at master · Microsoft/Windows-driver-samples · GitHub

The sample is relatively easy but while creating user mode application they use "CREATE_ALWAYS" flag for CreateFile function.
create.png


Other samples from different sources use "OPEN_EXISTING" flag:
Open.png

and as MSDN says: "For devices other than files, this parameter is usually set to OPEN_EXISTING."


I think the second approach is more intuitive than the first one, but both works for me.

We just trying to open device not create, why they use "CREATE_ALWAYS" flag?
I don't know, maybe I'm wrong, just confused.

P.S. They check if last error is "ERROR_FILE_NOT_FOUND", it this possible to get this error when using "CREATE_ALWAYS"? I don't think so, but it's possible when using "OPEN_EXISTING".
 
Last edited:
  • Like
Reactions: XhenEd
Status
Not open for further replies.

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top