0

I write driver . Creates an Device Object (name = ICOCTL_1) when the service starts but getlastError function return not_foun_file(code 2)

enter image description here

 void CUserAppDlg::OnBnClickedbtncreate(){


deviceHandle =  CreateFile(L"\\\\.\\IOCTL_1", GENERIC_ALL, 0, 0, OPEN_EXISTING, 
 FILE_ATTRIBUTE_SYSTEM, 0);

 DWORD data = GetLastError();

  TCHAR s[100];

 _stprintf_s(s, _T("%X"), data);



 MessageBox(s);}
MDev
  • 3
  • 2
  • Why do you call `GetLastError`? You don't even check if the function call succeeded. – Gerhardh May 26 '22 at 15:48
  • I checked that the handle is returning invalid status – MDev May 26 '22 at 15:57
  • \Device\xyz are not exposed to Win32, they are internal NT paths. If there's a symlink to \??\ you will be able to access them through \\.\ BUT the NT namespace root is exposed via global root. so you can use \\.\GLOBALROOT\Device\IOCTL_1 – Leberecht Reinhold May 27 '22 at 08:57
  • You already asked the question about the very similar code: https://stackoverflow.com/questions/72374167/why-not-found-my-device-but-exist-in-winobj. If you want to incorporate additional information to the question, then just edit it. Re-asking the same question is very discouraged on Stack Overflow. – Tsyvarev May 27 '22 at 09:09
  • Does this answer your question? [why not found my device but exist in winObj](https://stackoverflow.com/questions/72374167/why-not-found-my-device-but-exist-in-winobj) – Tsyvarev May 27 '22 at 09:09

0 Answers0