Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. ndisapi.c
  5. Abstract:
  6. Since we cannot include windows.h and ntos.h in the same C file. Sigh !!!
  7. Author:
  8. JameelH
  9. Environment:
  10. Kernel mode, FSD
  11. Revision History:
  12. Aug 1997 JameelH Initial version
  13. --*/
  14. #include <ntosp.h>
  15. extern
  16. VOID
  17. XSetLastError(
  18. IN ULONG Error
  19. );
  20. VOID
  21. InitUnicodeString(
  22. IN PUNICODE_STRING DestinationString,
  23. IN PCWSTR SourceString
  24. )
  25. {
  26. RtlInitUnicodeString(DestinationString, SourceString);
  27. }
  28. NTSTATUS
  29. AppendUnicodeStringToString(
  30. IN PUNICODE_STRING Destination,
  31. IN PUNICODE_STRING Source
  32. )
  33. {
  34. return (RtlAppendUnicodeStringToString(Destination, Source));
  35. }
  36. HANDLE
  37. OpenDevice(
  38. IN PUNICODE_STRING DeviceName
  39. )
  40. {
  41. OBJECT_ATTRIBUTES ObjAttr;
  42. NTSTATUS Status;
  43. IO_STATUS_BLOCK IoStsBlk;
  44. HANDLE Handle = NULL;
  45. InitializeObjectAttributes(&ObjAttr,
  46. DeviceName,
  47. OBJ_CASE_INSENSITIVE,
  48. NULL,
  49. NULL);
  50. Status = NtOpenFile(&Handle,
  51. FILE_GENERIC_READ | FILE_GENERIC_WRITE,
  52. &ObjAttr,
  53. &IoStsBlk,
  54. FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  55. FILE_SYNCHRONOUS_IO_NONALERT);
  56. if (Status != STATUS_SUCCESS)
  57. {
  58. XSetLastError(RtlNtStatusToDosError(Status));
  59. }
  60. return(Handle);
  61. }