0

I'm trying to open \\.\TCP device directly,

CreateFileA ("\\\\.\\Tcp", 
   FILE_SHARE_WRITE|FILE_SHARE_READ, 
   0, None, OPEN_EXISTING, 0, None)

With a normal user that does not belong to the administrators group, it fails with Access denied (GetLastError() returned 5)

So, I'm wondering what privilege is required? Adding that user to administrators group seems to be too much.

daisy
  • 22,498
  • 29
  • 129
  • 265
  • 1
    Using WinObj to read the ACL on the device object, Everyone and RESTRICTED have read access, and SYSTEM and Administrators have full access. So you should be able to open it for read access without any special privilege; for write access you must be in Administrators. (Oh, presumably backup/restore privilege would work, but that's equivalent to being an administrator anyway.) – Harry Johnston Jan 31 '15 at 02:21
  • PS: the `FILE_SHARE_READ` and `FILE_SHARE_WRITE` constants belong in the third argument to CreateFile, not the second argument. The constants for the second argument are `FILE_GENERIC_READ`, etc. – Harry Johnston Jan 31 '15 at 02:22

0 Answers0