475{
500
501 union {
505 union {
516
529 {
531 }
532
533 DPRINT(
"BaseSrvDefineDosDevice entered, Flags:%d, DeviceName:%wZ (%d), TargetPath:%wZ (%d)\n",
534 DefineDosDeviceRequest->
Flags,
539
540
541
542
543
544
547 {
549 }
550
551
554 {
555 DPRINT1(
"RtlEnterCriticalSection() failed (Status %lx)\n",
559 }
560
561 LinkHandle = 0;
562
565 {
566
568 {
572 {
574
575
577 if (AbsLetter < 26 && AbsLetter >= 0)
578 {
580 }
581
583 if (AbsLetter < 26)
584 {
585
587 }
588 }
589 }
590
591
593 !DriveLetter)
594 {
597 }
598
599
601 CchLengthLeft = 0x1000 - 1 - CchLength;
604
605
611
612
614
615
617 {
620 }
621
622
623
624
625
626
627
628
629 if (DriveLetter)
630 {
633 {
635 }
636 }
637
638
642
643
645
646
648 {
649
651 {
652 LinkHandle = 0;
653 }
654
655
657 {
659 }
660
661
663 }
664
665
667 {
668
669 LinkHandle = 0;
670
671
672 if (RemoveDefinition)
673 {
674
675
676
677
679 {
681 }
682
683
685 }
686
687
688 HandleTarget =
FALSE;
689
690
691
692
693
694
695
697 }
698 else
699 {
700
702 {
704 }
705
706
708 {
709
712 {
714 }
715
716
717 if (IsGlobal)
718 {
720 CchLengthLeft = 0x1000 - 1 - CchLength;
722
725 }
726 }
727 }
728
729
731 {
732
734
735
737
738
739 if (TargetLength + 1 >= CchLengthLeft)
740 {
743 }
744
745
748
749
750 CchLengthLeft -= (TargetLength + 1);
752 }
753
754 else
755 {
757 TargetLength = 0;
758 }
759
760
761 if (HandleTarget)
762 {
763
767
771
773 {
775 }
776
778 {
780 }
781
782
783
784
785
786
787
788
789
791 if (CchLength < 2 ||
794 {
797 }
798 else
799 {
801 }
802 }
803
804 else if (RemoveDefinition)
805 {
807 }
808
809 else
810 {
812 }
813
814
815
816
817
818
819
820 if (LinkHandle != 0)
821 {
824 LinkHandle = 0;
825 }
826
827
829 {
831 }
832
833
834
835
836
837 if (RemoveDefinition)
838 {
839
844 {
845 CchLength = 0;
846 OrigPtr = CurrentPtr;
847
849 {
850 CurrentChar = *CurrentPtr;
851 ++CurrentPtr;
852
854 {
855 break;
856 }
857
858 ++CchLength;
859 }
860
861
862
863
864
865
866
867
868 if (RemoveFound ||
870 TargetLength != CchLength ||
_wcsicmp(OrigPtr, TargetBuffer) != 0) &&
872 (TargetLength != 0 &&
_wcsnicmp(OrigPtr, TargetBuffer, TargetLength) != 0))))
873 {
874 if (InterPtr != OrigPtr)
875 {
877 }
878
879 InterPtr += (CchLength + 1);
880 }
881 else
882 {
883
885 }
886 }
887
888
889
890
891
892
893
894
896 ++InterPtr;
897
898
900
901
902
903
904
905
906 if (TargetLength == 0)
907 {
909 }
910
911
914 }
915
916 else if (HandleTarget)
917 {
921 TargetLength *=
sizeof(
WCHAR);
922 }
923
924 else
925 {
927 }
928
929
930 if (TargetLength == 0)
931 {
933 }
934
935
937 1,
948 {
950 }
951
953 1,
962 &SystemSid);
964 {
967 }
968
969
972
973
975
976
977
978
979
982 {
984 }
985 else
986 {
988 }
989
990
993
994
997
998
1000
1001
1003
1004
1005
1006
1007
1009 {
1010 if (!IsGlobal)
1011 {
1013 {
1016 }
1017 }
1018 }
1019
1020 else
1021 {
1023 }
1024
1025
1030
1031
1033 {
1035 }
1036
1037
1039 {
1041 {
1043 }
1044
1045
1047
1048
1049
1050
1051
1052
1053
1054
1055 if (RemoveDefinition && !RemoveFound)
1056 {
1058 }
1059 }
1060
1061
1062 LinkHandle = 0;
1063 }
1065 {
1066
1067 if (LinkHandle != 0)
1068 {
1070 }
1071
1072
1074
1075
1077 {
1079
1080
1081 if (IsGlobal)
1082 {
1084 }
1085
1086
1088
1089
1090
1091
1092
1093 if (RemoveDefinition && !
RtlEqualLuid(&CallerLuid, &SystemLuid))
1094 {
1096 {
1098 }
1099 }
1100 }
1101
1102
1104 }
1106
1108}
static ACPI_BUFFER CurrentBuffer
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
static SID_IDENTIFIER_AUTHORITY WorldAuthority
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
static SID_IDENTIFIER_AUTHORITY SystemAuthority
_In_ ACCESS_MASK AccessMask
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
WCHAR NTAPI RtlUpcaseUnicodeChar(_In_ WCHAR Source)
#define SYMBOLIC_LINK_ALL_ACCESS
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
#define STATUS_BAD_IMPERSONATION_LEVEL
NTSTATUS NTAPI NtMakePermanentObject(IN HANDLE ObjectHandle)
NTSTATUS NTAPI NtMakeTemporaryObject(IN HANDLE ObjectHandle)
NTSTATUS NTAPI NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, OUT PUNICODE_STRING LinkTarget, OUT PULONG ResultLength OPTIONAL)
NTSTATUS NTAPI NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PUNICODE_STRING LinkTarget)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define STATUS_BUFFER_OVERFLOW
UNICODE_STRING TargetPath
UNICODE_STRING DeviceName
NTSTATUS AddBSMRequest(LONG DriveLetter, BOOLEAN RemoveDefinition, PLUID BroadcastLuid)
BOOLEAN CheckForGlobalDriveLetter(SHORT DriveLetter)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_OBJECT_NAME_NOT_FOUND
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
#define DDD_NO_BROADCAST_SYSTEM
#define DDD_EXACT_MATCH_ON_REMOVE
#define DDD_LUID_BROADCAST_DRIVE
#define DDD_REMOVE_DEFINITION
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
#define SECURITY_WORLD_SID_AUTHORITY
#define SECURITY_NULL_RID
#define SECURITY_RESTRICTED_CODE_RID
#define SECURITY_NT_AUTHORITY
#define SECURITY_DESCRIPTOR_REVISION
_Inout_ PUNICODE_STRING LinkTarget