ReactOS  0.4.15-dev-3302-ga37d9a4
api.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 CSR_API (BaseSrvCheckApplicationCompatibility)
 
VOID BaseInitDefineDosDevice (VOID)
 
VOID BaseCleanupDefineDosDevice (VOID)
 
 CSR_API (BaseSrvDefineDosDevice)
 
 CSR_API (BaseSrvGetTempFile)
 
 CSR_API (BaseSrvCreateProcess)
 
 CSR_API (BaseSrvCreateThread)
 
 CSR_API (BaseSrvExitProcess)
 
 CSR_API (BaseSrvGetProcessShutdownParam)
 
 CSR_API (BaseSrvSetProcessShutdownParam)
 
 CSR_API (BaseSrvDebugProcess)
 
 CSR_API (BaseSrvRegisterThread)
 
 CSR_API (BaseSrvSxsCreateActivationContext)
 
 CSR_API (BaseSrvSetTermsrvAppInstallMode)
 
 CSR_API (BaseSrvSetTermsrvClientTimeZone)
 
 CSR_API (BaseSrvSoundSentryNotification)
 
 CSR_API (BaseSrvCheckVDM)
 
 CSR_API (BaseSrvUpdateVDMEntry)
 
 CSR_API (BaseSrvGetNextVDMCommand)
 
 CSR_API (BaseSrvExitVDM)
 
 CSR_API (BaseSrvIsFirstVDM)
 
 CSR_API (BaseSrvGetVDMExitCode)
 
 CSR_API (BaseSrvSetReenterCount)
 
 CSR_API (BaseSrvSetVDMCurDirs)
 
 CSR_API (BaseSrvGetVDMCurDirs)
 
 CSR_API (BaseSrvBatNotification)
 
 CSR_API (BaseSrvRegisterWowExec)
 
 CSR_API (BaseSrvRefreshIniFileMapping)
 
VOID NTAPI BaseSrvNLSInit (IN PBASE_STATIC_SERVER_DATA StaticData)
 
NTSTATUS NTAPI BaseSrvNlsConnect (IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
 
 CSR_API (BaseSrvNlsSetUserInfo)
 
 CSR_API (BaseSrvNlsSetMultipleUserInfo)
 
 CSR_API (BaseSrvNlsCreateSection)
 
 CSR_API (BaseSrvNlsUpdateCacheCount)
 
 CSR_API (BaseSrvNlsGetUserInfo)
 

Function Documentation

◆ BaseCleanupDefineDosDevice()

VOID BaseCleanupDefineDosDevice ( VOID  )

Definition at line 39 of file dosdev.c.

40 {
42 }
static RTL_CRITICAL_SECTION BaseDefineDosDeviceCritSec
Definition: dosdev.c:26
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by DllMain().

◆ BaseInitDefineDosDevice()

VOID BaseInitDefineDosDevice ( VOID  )

Definition at line 34 of file dosdev.c.

35 {
37 }
static RTL_CRITICAL_SECTION BaseDefineDosDeviceCritSec
Definition: dosdev.c:26
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by CSR_SERVER_DLL_INIT().

◆ BaseSrvNlsConnect()

NTSTATUS NTAPI BaseSrvNlsConnect ( IN PCSR_PROCESS  CsrProcess,
IN OUT PVOID  ConnectionInfo,
IN OUT PULONG  ConnectionInfoLength 
)

Definition at line 135 of file nls.c.

138 {
139  /* Does nothing */
140  return STATUS_SUCCESS;
141 }
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by BaseClientConnectRoutine().

◆ BaseSrvNLSInit()

VOID NTAPI BaseSrvNLSInit ( IN PBASE_STATIC_SERVER_DATA  StaticData)

Definition at line 112 of file nls.c.

113 {
114  /* Initialize the lock */
116 
117  /* Initialize the data with all F's */
118  pNlsRegUserInfo = &StaticData->NlsUserInfo;
119  RtlFillMemory(&StaticData->NlsUserInfo, sizeof(StaticData->NlsUserInfo), 0xFF);
120 
121  /* Set empty LCID */
123 
124  /* Reset the cache update counter */
128 
129  /* Get the LCID */
131 }
ULONG ulCacheUpdateCount
Definition: base.h:69
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION NlsCacheCriticalSection
Definition: nls.c:20
LCID UserLocaleId
Definition: base.h:67
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
PNLS_USER_INFO pNlsRegUserInfo
Definition: nls.c:21
NTSTATUS NTAPI NtQueryDefaultLocale(IN BOOLEAN UserProfile, OUT PLCID DefaultLocaleId)
Definition: locale.c:162

Referenced by BaseInitializeStaticServerData().

◆ CSR_API() [1/31]

CSR_API ( BaseSrvCheckApplicationCompatibility  )

Definition at line 56 of file appcompat.c.

57 {
58  PBASE_APP_COMPAT_DATA AppCompatData = (PBASE_APP_COMPAT_DATA)&ApiMessage->Data;
59  DPRINT1("BASESRV: BaseSrvCheckApplicationCompatibility(%wZ)\n",
60  AppCompatData->FileName);
61 
62  AppCompatData->CheckRunAppResult = FALSE;
63 
64  return STATUS_SUCCESS;
65 }
struct _BASE_APP_COMPAT_DATA * PBASE_APP_COMPAT_DATA
#define FALSE
Definition: types.h:117
UNICODE_STRING FileName
Definition: appcompat.c:39
#define DPRINT1
Definition: precomp.h:8
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ CSR_API() [2/31]

CSR_API ( BaseSrvDefineDosDevice  )

Definition at line 474 of file dosdev.c.

475 {
477  PBASE_DEFINE_DOS_DEVICE DefineDosDeviceRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.DefineDosDeviceRequest;
479  HANDLE LinkHandle;
482  ULONG Length;
485  PSID SystemSid;
486  PSID WorldSid;
487  PWSTR lpBuffer;
488  WCHAR Letter;
489  SHORT AbsLetter;
490  BOOLEAN DriveLetter = FALSE;
491  BOOLEAN RemoveDefinition;
492  BOOLEAN HandleTarget;
493  BOOLEAN Broadcast = FALSE;
494  BOOLEAN IsGlobal = FALSE;
495  ULONG CchLengthLeft;
496  ULONG CchLength;
497  ULONG TargetLength;
498  PWSTR TargetBuffer;
500  /* We store them on the stack, they are known in advance */
501  union {
503  UCHAR Buffer[20];
505  union {
506  ACL Dacl;
507  UCHAR Buffer[256];
508  } Dacl;
510  LUID CallerLuid;
511  WCHAR * CurrentPtr;
512  WCHAR CurrentChar;
513  PWSTR OrigPtr;
514  PWSTR InterPtr;
515  BOOLEAN RemoveFound;
516 
517  if (!CsrValidateMessageBuffer(ApiMessage,
518  (PVOID*)&DefineDosDeviceRequest->DeviceName.Buffer,
519  DefineDosDeviceRequest->DeviceName.Length,
520  sizeof(BYTE)) ||
521  (DefineDosDeviceRequest->DeviceName.Length & 1) != 0 ||
522  !CsrValidateMessageBuffer(ApiMessage,
523  (PVOID*)&DefineDosDeviceRequest->TargetPath.Buffer,
524  DefineDosDeviceRequest->TargetPath.Length +
525  (DefineDosDeviceRequest->TargetPath.Length != 0
526  ? sizeof(UNICODE_NULL) : 0),
527  sizeof(BYTE)) ||
528  (DefineDosDeviceRequest->TargetPath.Length & 1) != 0)
529  {
531  }
532 
533  DPRINT("BaseSrvDefineDosDevice entered, Flags:%d, DeviceName:%wZ (%d), TargetPath:%wZ (%d)\n",
534  DefineDosDeviceRequest->Flags,
535  &DefineDosDeviceRequest->DeviceName,
536  DefineDosDeviceRequest->DeviceName.Length,
537  &DefineDosDeviceRequest->TargetPath,
538  DefineDosDeviceRequest->TargetPath.Length);
539 
540  /*
541  * Allocate a buffer big enough to contain:
542  * - device name
543  * - targets
544  */
545  lpBuffer = RtlAllocateHeap(BaseSrvHeap, 0, 0x2000);
546  if (lpBuffer == NULL)
547  {
548  return STATUS_NO_MEMORY;
549  }
550 
551  /* Enter our critical section */
553  if (!NT_SUCCESS(Status))
554  {
555  DPRINT1("RtlEnterCriticalSection() failed (Status %lx)\n",
556  Status);
558  return Status;
559  }
560 
561  LinkHandle = 0;
562  /* Does the caller wants to remove definition? */
563  RemoveDefinition = !!(DefineDosDeviceRequest->Flags & DDD_REMOVE_DEFINITION);
564  _SEH2_TRY
565  {
566  /* First of all, check if that's a drive letter device amongst LUID mappings */
567  if (BaseStaticServerData->LUIDDeviceMapsEnabled && !(DefineDosDeviceRequest->Flags & DDD_NO_BROADCAST_SYSTEM))
568  {
569  if (DefineDosDeviceRequest->DeviceName.Buffer != NULL &&
570  DefineDosDeviceRequest->DeviceName.Length == 2 * sizeof(WCHAR) &&
571  DefineDosDeviceRequest->DeviceName.Buffer[1] == L':')
572  {
573  Letter = DefineDosDeviceRequest->DeviceName.Buffer[0];
574 
575  /* Handle both lower cases and upper cases */
576  AbsLetter = Letter - L'a';
577  if (AbsLetter < 26 && AbsLetter >= 0)
578  {
580  }
581 
582  AbsLetter = Letter - L'A';
583  if (AbsLetter < 26)
584  {
585  /* That's a letter! */
586  DriveLetter = TRUE;
587  }
588  }
589  }
590 
591  /* We can only broadcast drive letters in case of LUID mappings */
592  if (DefineDosDeviceRequest->Flags & DDD_LUID_BROADCAST_DRIVE &&
593  !DriveLetter)
594  {
596  _SEH2_LEAVE;
597  }
598 
599  /* First usage of our buffer: create device name */
600  CchLength = _snwprintf(lpBuffer, 0x1000, L"\\??\\%wZ", &DefineDosDeviceRequest->DeviceName);
601  CchLengthLeft = 0x1000 - 1 - CchLength; /* UNICODE_NULL */
602  CurrentBuffer = lpBuffer + CchLength + 1; /* UNICODE_NULL */
604 
605  /* And prepare to open it */
607  &DeviceName,
609  NULL,
610  NULL);
611 
612  /* Assume it's OK and has a target to deal with */
613  HandleTarget = TRUE;
614 
615  /* Move to the client context if the mapping was local */
617  {
619  _SEH2_LEAVE;
620  }
621 
622  /*
623  * While impersonating the caller, also get its LUID.
624  * This is mandatory in case we have a driver letter,
625  * Because we're in the case we've got LUID mapping
626  * enabled and broadcasting enabled. LUID will be required
627  * for the latter
628  */
629  if (DriveLetter)
630  {
631  Status = GetCallerLuid(&CallerLuid);
632  if (NT_SUCCESS(Status))
633  {
634  Broadcast = TRUE;
635  }
636  }
637 
638  /* Now, open the device */
639  Status = NtOpenSymbolicLinkObject(&LinkHandle,
642 
643  /* And get back to our context */
644  CsrRevertToSelf();
645 
646  /* In case of LUID broadcast, do nothing but return to trigger broadcast */
647  if (DefineDosDeviceRequest->Flags & DDD_LUID_BROADCAST_DRIVE)
648  {
649  /* Zero handle in case of a failure */
650  if (!NT_SUCCESS(Status))
651  {
652  LinkHandle = 0;
653  }
654 
655  /* If removal was asked, and no object found: the remval was successful */
656  if (RemoveDefinition && Status == STATUS_OBJECT_NAME_NOT_FOUND)
657  {
659  }
660 
661  /* We're done here, nothing more to do */
662  _SEH2_LEAVE;
663  }
664 
665  /* If device was not found */
667  {
668  /* No handle */
669  LinkHandle = 0;
670 
671  /* If we were asked to remove... */
672  if (RemoveDefinition)
673  {
674  /*
675  * If caller asked to pop first entry, nothing specific,
676  * then, we can consider this as a success
677  */
678  if (DefineDosDeviceRequest->TargetPath.Length == 0)
679  {
681  }
682 
683  /* We're done, nothing to change */
684  _SEH2_LEAVE;
685  }
686 
687  /* There's no target to handle */
688  HandleTarget = FALSE;
689 
690  /*
691  * We'll consider, that's a success
692  * Failing to open the device doesn't prevent
693  * from creating it later on to create
694  * the linking.
695  */
697  }
698  else
699  {
700  /* Unexpected failure, forward to caller */
701  if (!NT_SUCCESS(Status))
702  {
703  _SEH2_LEAVE;
704  }
705 
706  /* If LUID mapping enabled */
708  {
709  /* Check if that's global link */
710  Status = IsGlobalSymbolicLink(LinkHandle, &IsGlobal);
711  if (!NT_SUCCESS(Status))
712  {
713  _SEH2_LEAVE;
714  }
715 
716  /* If so, change our device name namespace to GLOBAL?? for link creation */
717  if (IsGlobal)
718  {
719  CchLength = _snwprintf(lpBuffer, 0x1000, L"\\GLOBAL??\\%wZ", &DefineDosDeviceRequest->DeviceName);
720  CchLengthLeft = 0x1000 - 1 - CchLength; /* UNICODE_NULL */
721  CurrentBuffer = lpBuffer + CchLength + 1; /* UNICODE_NULL */
722 
723  DeviceName.Length = CchLength * sizeof(WCHAR);
724  DeviceName.MaximumLength = CchLength * sizeof(WCHAR) + sizeof(UNICODE_NULL);
725  }
726  }
727  }
728 
729  /* If caller provided a target */
730  if (DefineDosDeviceRequest->TargetPath.Length != 0)
731  {
732  /* Make sure it's null terminated */
733  DefineDosDeviceRequest->TargetPath.Buffer[DefineDosDeviceRequest->TargetPath.Length / sizeof(WCHAR)] = UNICODE_NULL;
734 
735  /* Compute its size */
736  TargetLength = wcslen(DefineDosDeviceRequest->TargetPath.Buffer);
737 
738  /* And make sure it fits our buffer */
739  if (TargetLength + 1 >= CchLengthLeft)
740  {
742  _SEH2_LEAVE;
743  }
744 
745  /* Copy it to our internal buffer */
746  RtlMoveMemory(CurrentBuffer, DefineDosDeviceRequest->TargetPath.Buffer, TargetLength * sizeof(WCHAR) + sizeof(UNICODE_NULL));
747  TargetBuffer = CurrentBuffer;
748 
749  /* Update our buffer status */
750  CchLengthLeft -= (TargetLength + 1);
751  CurrentBuffer += (TargetLength + 1);
752  }
753  /* Otherwise, zero everything */
754  else
755  {
756  TargetBuffer = NULL;
757  TargetLength = 0;
758  }
759 
760  /* If we opened the device, then, handle its current target */
761  if (HandleTarget)
762  {
763  /* Query it with our internal buffer */
764  LinkTarget.Length = 0;
765  LinkTarget.MaximumLength = CchLengthLeft * sizeof(WCHAR);
767 
768  Status = NtQuerySymbolicLinkObject(LinkHandle,
769  &LinkTarget,
770  &Length);
771  /* If we overflow, give up */
773  {
775  }
776  /* In case of a failure, bye bye */
777  if (!NT_SUCCESS(Status))
778  {
779  _SEH2_LEAVE;
780  }
781 
782  /*
783  * Properly null it for MULTI_SZ if needed
784  * Always update max length with
785  * the need size
786  * This is needed to hand relatively "small"
787  * strings to Ob and avoid killing ourselves
788  * on the next query
789  */
790  CchLength = Length / sizeof(WCHAR);
791  if (CchLength < 2 ||
792  CurrentBuffer[CchLength - 2] != UNICODE_NULL ||
793  CurrentBuffer[CchLength - 1] != UNICODE_NULL)
794  {
795  CurrentBuffer[CchLength] = UNICODE_NULL;
797  }
798  else
799  {
801  }
802  }
803  /* There's no target, and we're asked to remove, so null target */
804  else if (RemoveDefinition)
805  {
807  }
808  /* There's a target provided - new device, update buffer */
809  else
810  {
811  RtlInitUnicodeString(&LinkTarget, CurrentBuffer - TargetLength - 1);
812  }
813 
814  /*
815  * We no longer need old symlink, just drop it, we'll recreate it now
816  * with updated target.
817  * The benefit of it is that if caller asked us to drop last target, then
818  * the device is removed and not dangling
819  */
820  if (LinkHandle != 0)
821  {
822  Status = NtMakeTemporaryObject(LinkHandle);
823  NtClose(LinkHandle);
824  LinkHandle = 0;
825  }
826 
827  /* At this point, we must have no failure */
828  if (!NT_SUCCESS(Status))
829  {
830  _SEH2_LEAVE;
831  }
832 
833  /*
834  * If we have to remove definition, let's start to browse our
835  * target to actually drop it.
836  */
837  if (RemoveDefinition)
838  {
839  /* We'll browse our multi sz string */
840  RemoveFound = FALSE;
841  CurrentPtr = LinkTarget.Buffer;
842  InterPtr = LinkTarget.Buffer;
843  while (*CurrentPtr != UNICODE_NULL)
844  {
845  CchLength = 0;
846  OrigPtr = CurrentPtr;
847  /* First, find next string */
848  while (TRUE)
849  {
850  CurrentChar = *CurrentPtr;
851  ++CurrentPtr;
852 
853  if (CurrentChar == UNICODE_NULL)
854  {
855  break;
856  }
857 
858  ++CchLength;
859  }
860 
861  /* This check is a bit tricky, but dead useful:
862  * If on the previous loop, we found the caller provided target
863  * in our list, then, we'll move current entry over the found one
864  * So that, it gets deleted.
865  * Also, if we don't find caller entry in our entries, then move
866  * current entry in the string if a previous one got deleted
867  */
868  if (RemoveFound ||
869  ((!(DefineDosDeviceRequest->Flags & DDD_EXACT_MATCH_ON_REMOVE) ||
870  TargetLength != CchLength || _wcsicmp(OrigPtr, TargetBuffer) != 0) &&
871  ((DefineDosDeviceRequest->Flags & DDD_EXACT_MATCH_ON_REMOVE) ||
872  (TargetLength != 0 && _wcsnicmp(OrigPtr, TargetBuffer, TargetLength) != 0))))
873  {
874  if (InterPtr != OrigPtr)
875  {
876  RtlMoveMemory(InterPtr, OrigPtr, sizeof(WCHAR) * CchLength + sizeof(UNICODE_NULL));
877  }
878 
879  InterPtr += (CchLength + 1);
880  }
881  else
882  {
883  /* Match case! Remember for next loop turn and to delete it */
884  RemoveFound = TRUE;
885  }
886  }
887 
888  /*
889  * Drop last entry, as required (pop)
890  * If there was a match previously, everything
891  * is already moved, so we're just nulling
892  * the end of the string
893  * If there was no match, this is the pop
894  */
895  *InterPtr = UNICODE_NULL;
896  ++InterPtr;
897 
898  /* Compute new target length */
899  TargetLength = wcslen(LinkTarget.Buffer) * sizeof(WCHAR);
900  /*
901  * If it's empty, quit
902  * Beware, here, we quit with STATUS_SUCCESS, and that's expected!
903  * In case we dropped last target entry, then, it's empty
904  * and there's no need to recreate the device we deleted previously
905  */
906  if (TargetLength == 0)
907  {
908  _SEH2_LEAVE;
909  }
910 
911  /* Update our target string */
912  LinkTarget.Length = TargetLength;
914  }
915  /* If that's not a removal, just update the target to include new target */
916  else if (HandleTarget)
917  {
918  LinkTarget.Buffer = LinkTarget.Buffer - TargetLength - 1;
919  LinkTarget.Length = TargetLength * sizeof(WCHAR);
920  LinkTarget.MaximumLength += (TargetLength * sizeof(WCHAR) + sizeof(UNICODE_NULL));
921  TargetLength *= sizeof(WCHAR);
922  }
923  /* No changes */
924  else
925  {
926  TargetLength = LinkTarget.Length;
927  }
928 
929  /* Make sure we don't create empty symlink */
930  if (TargetLength == 0)
931  {
932  _SEH2_LEAVE;
933  }
934 
935  /* Initialize our SIDs for symlink ACLs */
937  1,
946  &WorldSid);
947  if (!NT_SUCCESS(Status))
948  {
949  _SEH2_LEAVE;
950  }
951 
953  1,
962  &SystemSid);
963  if (!NT_SUCCESS(Status))
964  {
966  _SEH2_LEAVE;
967  }
968 
969  /* Initialize our SD (on stack) */
972 
973  /* And our ACL (still on stack) */
974  RtlCreateAcl(&Dacl.Dacl, sizeof(Dacl), ACL_REVISION);
975 
976  /*
977  * For access mask, if we have no session ID, or if
978  * protection mode is disabled, make them wide open
979  */
980  if (SessionId == 0 ||
981  (ProtectionMode & 3) == 0)
982  {
984  }
985  else
986  {
988  }
989 
990  /* Setup the ACL */
993 
994  /* Drop SIDs */
996  RtlFreeSid(SystemSid);
997 
998  /* Link DACL to the SD */
1000 
1001  /* And set it in the OA used for creation */
1002  ObjectAttributes.SecurityDescriptor = &SecurityDescriptor;
1003 
1004  /*
1005  * If LUID and not global, we need to impersonate the caller
1006  * to make it local.
1007  */
1009  {
1010  if (!IsGlobal)
1011  {
1012  if (!CsrImpersonateClient(NULL))
1013  {
1015  _SEH2_LEAVE;
1016  }
1017  }
1018  }
1019  /* The object will be permanent */
1020  else
1021  {
1022  ObjectAttributes.Attributes |= OBJ_PERMANENT;
1023  }
1024 
1025  /* (Re)Create the symbolic link/device */
1026  Status = NtCreateSymbolicLinkObject(&LinkHandle,
1029  &LinkTarget);
1030 
1031  /* Revert to self if required */
1032  if (BaseStaticServerData->LUIDDeviceMapsEnabled && !IsGlobal)
1033  {
1034  CsrRevertToSelf();
1035  }
1036 
1037  /* In case of a success, make object permanent for LUID links */
1038  if (NT_SUCCESS(Status))
1039  {
1041  {
1042  Status = NtMakePermanentObject(LinkHandle);
1043  }
1044 
1045  /* Close the link */
1046  NtClose(LinkHandle);
1047 
1048  /*
1049  * Specific failure case here:
1050  * We were asked to remove something
1051  * but we didn't find the something
1052  * (we recreated the symlink hence the fail here!)
1053  * so fail with appropriate status
1054  */
1055  if (RemoveDefinition && !RemoveFound)
1056  {
1058  }
1059  }
1060 
1061  /* We closed link, don't double close */
1062  LinkHandle = 0;
1063  }
1065  {
1066  /* If we need to close the link, do it now */
1067  if (LinkHandle != 0)
1068  {
1069  NtClose(LinkHandle);
1070  }
1071 
1072  /* Free our internal buffer */
1074 
1075  /* Broadcast drive letter creation */
1076  if (DriveLetter && Status == STATUS_SUCCESS && Broadcast)
1077  {
1078  LUID SystemLuid = SYSTEM_LUID;
1079 
1080  /* If that's a global drive, broadcast as system */
1081  if (IsGlobal)
1082  {
1083  RtlCopyLuid(&CallerLuid, &SystemLuid);
1084  }
1085 
1086  /* Broadcast the event */
1087  AddBSMRequest(AbsLetter, RemoveDefinition, &CallerLuid);
1088 
1089  /*
1090  * If we removed drive, and the drive was shadowing a global one
1091  * broadcast the arrival of the global drive (as system - global)
1092  */
1093  if (RemoveDefinition && !RtlEqualLuid(&CallerLuid, &SystemLuid))
1094  {
1095  if (CheckForGlobalDriveLetter(AbsLetter))
1096  {
1097  AddBSMRequest(AbsLetter, FALSE, &CallerLuid);
1098  }
1099  }
1100  }
1101 
1102  /* Done! */
1104  }
1105  _SEH2_END;
1106 
1107  return Status;
1108 }
static ACPI_BUFFER CurrentBuffer
UNICODE_STRING TargetPath
Definition: basemsg.h:257
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_BAD_IMPERSONATION_LEVEL
Definition: ntstatus.h:401
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TRUE
Definition: types.h:120
_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
Definition: wsk.h:182
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:521
uint16_t * PWSTR
Definition: typedefs.h:56
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
ULONG SessionId
Definition: dllmain.c:28
LONG NTSTATUS
Definition: precomp.h:26
#define DDD_NO_BROADCAST_SYSTEM
Definition: winbase.h:523
static SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: security.c:14
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
_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)
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1057
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSTATUS AddBSMRequest(LONG DriveLetter, BOOLEAN RemoveDefinition, PLUID BroadcastLuid)
Definition: dosdev.c:391
NTSTATUS NTAPI NtMakeTemporaryObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1385
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
NTSYSAPI WCHAR NTAPI RtlUpcaseUnicodeChar(WCHAR Source)
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)
Definition: sid.c:290
#define SYMBOLIC_LINK_ALL_ACCESS
Definition: nt_native.h:1267
NTSTATUS NTAPI NtMakePermanentObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1422
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_SEH2_TRY
Definition: create.c:4226
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
static RTL_CRITICAL_SECTION BaseDefineDosDeviceCritSec
Definition: dosdev.c:26
_Inout_ PUNICODE_STRING LinkTarget
Definition: zwfuncs.h:292
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
short SHORT
Definition: pedump.c:59
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
UNICODE_STRING DeviceName
Definition: basemsg.h:256
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
unsigned char BOOLEAN
BOOLEAN LUIDDeviceMapsEnabled
Definition: base.h:133
#define ACL_REVISION2
Definition: setypes.h:43
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
Definition: bufpool.h:45
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:541
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SECURITY_WORLD_SID_AUTHORITY
Definition: setypes.h:514
_In_ ACCESS_MASK AccessMask
Definition: exfuncs.h:186
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
#define SECURITY_NULL_RID
Definition: setypes.h:527
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1552
unsigned char UCHAR
Definition: xmlstorage.h:181
ULONG ProtectionMode
Definition: init.c:34
NTSTATUS IsGlobalSymbolicLink(HANDLE LinkHandle, PBOOLEAN IsGlobal)
Definition: dosdev.c:96
static const WCHAR L[]
Definition: oid.c:1250
WCHAR Letter
PSID WorldSid
Definition: globals.c:15
#define OBJ_PERMANENT
Definition: winternl.h:226
unsigned char BYTE
Definition: xxhash.c:193
#define SYSTEM_LUID
Definition: setypes.h:687
HANDLE BaseSrvHeap
Definition: init.c:29
_SEH2_END
Definition: create.c:4400
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
_SEH2_FINALLY
Definition: create.c:4371
#define DDD_LUID_BROADCAST_DRIVE
Definition: winbase.h:524
#define SECURITY_RESTRICTED_CODE_RID
Definition: setypes.h:556
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
#define ACL_REVISION
Definition: setypes.h:39
NTSYSAPI void WINAPI RtlCopyLuid(PLUID, const LUID *)
unsigned int ULONG
Definition: retypes.h:1
#define SYMBOLIC_LINK_QUERY
Definition: nt_native.h:1265
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:932
#define ULONG_PTR
Definition: config.h:101
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_LEAVE
Definition: filesup.c:20
#define DPRINT
Definition: sndvol32.h:71
BOOLEAN CheckForGlobalDriveLetter(SHORT DriveLetter)
Definition: dosdev.c:162
NTSTATUS GetCallerLuid(PLUID CallerLuid)
Definition: dosdev.c:45
ULONG ACCESS_MASK
Definition: nt_native.h:40
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define DELETE
Definition: nt_native.h:57
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:522
static SID_IDENTIFIER_AUTHORITY SystemAuthority
Definition: msgina.c:38

◆ CSR_API() [3/31]

CSR_API ( BaseSrvGetTempFile  )

Definition at line 54 of file proc.c.

55 {
56  static UINT BaseGetTempFileUnique = 0;
57  PBASE_GET_TEMP_FILE GetTempFile = &((PBASE_API_MESSAGE)ApiMessage)->Data.GetTempFileRequest;
58 
59  /* Return 16-bits ID */
60  GetTempFile->UniqueID = (++BaseGetTempFileUnique & 0xFFFF);
61 
62  DPRINT("Returning: %u\n", GetTempFile->UniqueID);
63 
64  return GetTempFile->UniqueID;
65 }
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
unsigned int UINT
Definition: ndis.h:50
#define DPRINT
Definition: sndvol32.h:71

◆ CSR_API() [4/31]

CSR_API ( BaseSrvCreateProcess  )

Definition at line 67 of file proc.c.

68 {
70  PBASE_CREATE_PROCESS CreateProcessRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CreateProcessRequest;
71  HANDLE ProcessHandle, ThreadHandle;
72  PCSR_THREAD CsrThread;
74  ULONG Flags = 0, DebugFlags = 0, VdmPower = 0;
75 
76  /* Get the current client thread */
77  CsrThread = CsrGetClientThread();
78  ASSERT(CsrThread != NULL);
79 
80  Process = CsrThread->Process;
81 
82  /* Extract the flags out of the process handle */
83  Flags = (ULONG_PTR)CreateProcessRequest->ProcessHandle & 3;
84  CreateProcessRequest->ProcessHandle = (HANDLE)((ULONG_PTR)CreateProcessRequest->ProcessHandle & ~3);
85 
86  /* Some things should be done if this is a VDM process */
87  if (CreateProcessRequest->VdmBinaryType)
88  {
89  /* We need to set the VDM power later on */
90  VdmPower = 1;
91  }
92 
93  /* Duplicate the process handle */
94  Status = NtDuplicateObject(Process->ProcessHandle,
95  CreateProcessRequest->ProcessHandle,
98  0,
99  0,
101  if (!NT_SUCCESS(Status))
102  {
103  DPRINT1("Failed to duplicate process handle: %lx\n", Status);
104  return Status;
105  }
106 
107  /* Duplicate the thread handle */
108  Status = NtDuplicateObject(Process->ProcessHandle,
109  CreateProcessRequest->ThreadHandle,
111  &ThreadHandle,
112  0,
113  0,
115  if (!NT_SUCCESS(Status))
116  {
117  DPRINT1("Failed to duplicate thread handle: %lx\n", Status);
119  return Status;
120  }
121 
122  /* If this is a VDM process, request VDM power */
123  if (VdmPower)
124  {
127  &VdmPower,
128  sizeof(VdmPower));
129  if (!NT_SUCCESS(Status))
130  {
131  DPRINT1("Failed to get VDM powers\n");
133  NtClose(ThreadHandle);
134  return Status;
135  }
136  }
137 
138  /* Flags conversion. FIXME: More need conversion */
139  if (CreateProcessRequest->CreationFlags & CREATE_NEW_PROCESS_GROUP)
140  {
141  DebugFlags |= CsrProcessCreateNewGroup;
142  }
143  if ((Flags & 2) == 0)
144  {
145  /* We are launching a console process */
146  DebugFlags |= CsrProcessIsConsoleApp;
147  }
148 
149  /* FIXME: SxS Stuff */
150 
151  /* Call CSRSRV to create the CSR_PROCESS structure and the first CSR_THREAD */
153  ThreadHandle,
154  &CreateProcessRequest->ClientId,
155  Process->NtSession,
156  DebugFlags,
157  NULL);
159  {
160  DPRINT1("Thread already dead\n");
161 
162  /* Set the special reply value so we don't reply this message back */
163  *ReplyCode = CsrReplyDeadClient;
164 
165  return Status;
166  }
167 
168  /* Check for other failures */
169  if (!NT_SUCCESS(Status))
170  {
171  DPRINT1("Failed to create process/thread structures: %lx\n", Status);
172  return Status;
173  }
174 
175  /* Call the user notification procedure */
177  {
178  UserNotifyProcessCreate(CreateProcessRequest->ClientId.UniqueProcess,
179  Process->ClientId.UniqueThread,
180  0,
181  Flags);
182  }
183 
184  /* Check if this is a VDM process */
185  if (CreateProcessRequest->VdmBinaryType)
186  {
187  PVDM_CONSOLE_RECORD ConsoleRecord;
188 
189  if (CreateProcessRequest->VdmTask != 0)
190  {
191  /* Get the console record using the task ID */
192  Status = GetConsoleRecordBySessionId(CreateProcessRequest->VdmTask,
193  &ConsoleRecord);
194  }
195  else
196  {
197  /* Get the console record using the console handle */
198  Status = BaseSrvGetConsoleRecord(CreateProcessRequest->hVDM,
199  &ConsoleRecord);
200  }
201 
202  /* Check if it failed */
203  if (!NT_SUCCESS(Status)) return Status;
204 
205  /* Store the process ID of the VDM in the console record */
206  ConsoleRecord->ProcessId = HandleToUlong(CreateProcessRequest->ClientId.UniqueProcess);
207  }
208 
209  /* Return the result of this operation */
210  return Status;
211 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
#define STATUS_THREAD_IS_TERMINATING
Definition: ntstatus.h:311
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
HANDLE UniqueProcess
Definition: compat.h:684
#define CREATE_NEW_PROCESS_GROUP
Definition: winbase.h:185
static BASE_PROCESS_CREATE_NOTIFY_ROUTINE UserNotifyProcessCreate
Definition: proc.c:20
HANDLE ThreadHandle
Definition: basemsg.h:90
PCSR_PROCESS Process
Definition: csrsrv.h:69
#define DUPLICATE_SAME_ACCESS
NTSTATUS GetConsoleRecordBySessionId(ULONG TaskId, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:95
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG ProcessId
Definition: vdm.h:26
HANDLE ProcessHandle
Definition: basemsg.h:89
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1105
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3406
CLIENT_ID ClientId
Definition: basemsg.h:91
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
NTSTATUS NTAPI CsrCreateProcess(IN HANDLE hProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId, IN PCSR_NT_SESSION NtSession, IN ULONG Flags, IN PCLIENT_ID DebugCid)
Definition: procsup.c:422

◆ CSR_API() [5/31]

CSR_API ( BaseSrvCreateThread  )

Definition at line 213 of file proc.c.

214 {
216  PBASE_CREATE_THREAD CreateThreadRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CreateThreadRequest;
217  PCSR_THREAD CurrentThread;
218  HANDLE ThreadHandle;
220 
221  /* Get the current CSR thread */
222  CurrentThread = CsrGetClientThread();
223  if (!CurrentThread)
224  {
225  DPRINT1("Server Thread TID: [%lx.%lx]\n",
226  CreateThreadRequest->ClientId.UniqueProcess,
227  CreateThreadRequest->ClientId.UniqueThread);
228  return STATUS_SUCCESS; // server-to-server
229  }
230 
231  /* Get the CSR Process for this request */
232  CsrProcess = CurrentThread->Process;
233  if (CsrProcess->ClientId.UniqueProcess !=
234  CreateThreadRequest->ClientId.UniqueProcess)
235  {
236  /* This is a remote thread request -- is it within the server itself? */
237  if (CreateThreadRequest->ClientId.UniqueProcess == NtCurrentTeb()->ClientId.UniqueProcess)
238  {
239  /* Accept this without any further work */
240  return STATUS_SUCCESS;
241  }
242 
243  /* Get the real CSR Process for the remote thread's process */
244  Status = CsrLockProcessByClientId(CreateThreadRequest->ClientId.UniqueProcess,
245  &CsrProcess);
246  if (!NT_SUCCESS(Status)) return Status;
247  }
248 
249  /* Duplicate the thread handle so we can own it */
250  Status = NtDuplicateObject(CurrentThread->Process->ProcessHandle,
251  CreateThreadRequest->ThreadHandle,
253  &ThreadHandle,
254  0,
255  0,
257  if (NT_SUCCESS(Status))
258  {
259  /* Call CSRSRV to tell it about the new thread */
261  ThreadHandle,
262  &CreateThreadRequest->ClientId,
263  TRUE);
264  }
265 
266  /* Unlock the process and return */
267  if (CsrProcess != CurrentThread->Process) CsrUnlockProcess(CsrProcess);
268  return Status;
269 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PKPROCESS CsrProcess
Definition: videoprt.c:39
HANDLE UniqueProcess
Definition: compat.h:684
PCSR_PROCESS Process
Definition: csrsrv.h:69
#define DUPLICATE_SAME_ACCESS
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
HANDLE ProcessHandle
Definition: csrsrv.h:46
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL)
HANDLE ThreadHandle
Definition: basemsg.h:104
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1163
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CLIENT_ID ClientId
Definition: basemsg.h:105
NTSTATUS NTAPI CsrCreateThread(IN PCSR_PROCESS CsrProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId, IN BOOLEAN HaveClient)
Definition: thredsup.c:678
HANDLE UniqueThread
Definition: compat.h:685
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3406
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1410

◆ CSR_API() [6/31]

CSR_API ( BaseSrvExitProcess  )

Definition at line 271 of file proc.c.

272 {
273  PCSR_THREAD CsrThread = CsrGetClientThread();
274  ASSERT(CsrThread != NULL);
275 
276  /* Set the special reply value so we don't reply this message back */
277  *ReplyCode = CsrReplyDeadClient;
278 
279  /* Remove the CSR_THREADs and CSR_PROCESS */
280  return CsrDestroyProcess(&CsrThread->ClientId,
281  (NTSTATUS)((PBASE_API_MESSAGE)ApiMessage)->Data.ExitProcessRequest.uExitCode);
282 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI CsrDestroyProcess(IN PCLIENT_ID Cid, IN NTSTATUS ExitStatus)
Definition: procsup.c:735
#define ASSERT(a)
Definition: mode.c:44
CLIENT_ID ClientId
Definition: csrsrv.h:68
#define NULL
Definition: types.h:112

◆ CSR_API() [7/31]

CSR_API ( BaseSrvGetProcessShutdownParam  )

Definition at line 284 of file proc.c.

285 {
286  PBASE_GETSET_PROCESS_SHUTDOWN_PARAMS ShutdownParametersRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ShutdownParametersRequest;
287  PCSR_THREAD CsrThread = CsrGetClientThread();
288  ASSERT(CsrThread);
289 
290  ShutdownParametersRequest->ShutdownLevel = CsrThread->Process->ShutdownLevel;
291  /* Only SHUTDOWN_NORETRY flag is valid for this API. The other private flags are for CSRSRV/WINSRV only. */
292  ShutdownParametersRequest->ShutdownFlags = CsrThread->Process->ShutdownFlags & SHUTDOWN_NORETRY;
293 
294  return STATUS_SUCCESS;
295 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
ULONG ShutdownFlags
Definition: csrsrv.h:59
PCSR_PROCESS Process
Definition: csrsrv.h:69
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define ASSERT(a)
Definition: mode.c:44
#define SHUTDOWN_NORETRY
Definition: winbase.h:445
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG ShutdownLevel
Definition: csrsrv.h:58

◆ CSR_API() [8/31]

CSR_API ( BaseSrvSetProcessShutdownParam  )

Definition at line 297 of file proc.c.

298 {
299  PBASE_GETSET_PROCESS_SHUTDOWN_PARAMS ShutdownParametersRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ShutdownParametersRequest;
300  PCSR_THREAD CsrThread = CsrGetClientThread();
301  ASSERT(CsrThread);
302 
303  /* Only SHUTDOWN_NORETRY flag is valid for this API. The other private flags are for CSRSRV/WINSRV only. */
304  if (ShutdownParametersRequest->ShutdownFlags & ~SHUTDOWN_NORETRY)
305  {
306  /* If there were other flags specified, fail the call */
308  }
309 
310  CsrThread->Process->ShutdownLevel = ShutdownParametersRequest->ShutdownLevel;
311  /* Notice that all the possible other private flags are reinitialized here */
312  CsrThread->Process->ShutdownFlags = ShutdownParametersRequest->ShutdownFlags;
313 
314  return STATUS_SUCCESS;
315 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
ULONG ShutdownFlags
Definition: csrsrv.h:59
PCSR_PROCESS Process
Definition: csrsrv.h:69
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define ASSERT(a)
Definition: mode.c:44
#define SHUTDOWN_NORETRY
Definition: winbase.h:445
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG ShutdownLevel
Definition: csrsrv.h:58

◆ CSR_API() [9/31]

CSR_API ( BaseSrvDebugProcess  )

Definition at line 24 of file proc.c.

25 {
26  /* Deprecated */
27  return STATUS_UNSUCCESSFUL;
28 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ CSR_API() [10/31]

CSR_API ( BaseSrvRegisterThread  )

Definition at line 30 of file proc.c.

31 {
32  DPRINT1("%s not yet implemented\n", __FUNCTION__);
34 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [11/31]

CSR_API ( BaseSrvSxsCreateActivationContext  )

Definition at line 36 of file proc.c.

37 {
38  DPRINT1("%s not yet implemented\n", __FUNCTION__);
40 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [12/31]

CSR_API ( BaseSrvSetTermsrvAppInstallMode  )

Definition at line 42 of file proc.c.

43 {
44  DPRINT1("%s not yet implemented\n", __FUNCTION__);
46 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [13/31]

CSR_API ( BaseSrvSetTermsrvClientTimeZone  )

Definition at line 48 of file proc.c.

49 {
50  DPRINT1("%s not yet implemented\n", __FUNCTION__);
52 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [14/31]

CSR_API ( BaseSrvSoundSentryNotification  )

Definition at line 61 of file sndsntry.c.

62 {
63  /* Call the API and see if it succeeds */
65 }
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
static PUSER_SOUND_SENTRY _UserSoundSentry
Definition: sndsntry.c:21
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ CSR_API() [15/31]

CSR_API ( BaseSrvCheckVDM  )

Definition at line 600 of file vdm.c.

601 {
603  PBASE_CHECK_VDM CheckVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CheckVDMRequest;
605  PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
606  PVDM_DOS_RECORD DosRecord = NULL;
607  BOOLEAN NewConsoleRecord = FALSE;
608  BOOLEAN NewDosRecord = FALSE;
609 
610  /* Don't do anything if the VDM has been disabled in the registry */
612 
613  /* Validate the message buffers */
614  if (!CsrValidateMessageBuffer(ApiMessage,
615  (PVOID*)&CheckVdmRequest->CmdLine,
616  CheckVdmRequest->CmdLen,
617  sizeof(*CheckVdmRequest->CmdLine))
618  || !CsrValidateMessageBuffer(ApiMessage,
619  (PVOID*)&CheckVdmRequest->AppName,
620  CheckVdmRequest->AppLen,
621  sizeof(*CheckVdmRequest->AppName))
622  || !CsrValidateMessageBuffer(ApiMessage,
623  (PVOID*)&CheckVdmRequest->PifFile,
624  CheckVdmRequest->PifLen,
625  sizeof(*CheckVdmRequest->PifFile))
626  || !CsrValidateMessageBuffer(ApiMessage,
627  (PVOID*)&CheckVdmRequest->CurDirectory,
628  CheckVdmRequest->CurDirectoryLen,
629  sizeof(*CheckVdmRequest->CurDirectory))
630  || !CsrValidateMessageBuffer(ApiMessage,
631  (PVOID*)&CheckVdmRequest->Desktop,
632  CheckVdmRequest->DesktopLen,
633  sizeof(*CheckVdmRequest->Desktop))
634  || !CsrValidateMessageBuffer(ApiMessage,
635  (PVOID*)&CheckVdmRequest->Title,
636  CheckVdmRequest->TitleLen,
637  sizeof(*CheckVdmRequest->Title))
638  || !CsrValidateMessageBuffer(ApiMessage,
639  (PVOID*)&CheckVdmRequest->Reserved,
640  CheckVdmRequest->ReservedLen,
641  sizeof(*CheckVdmRequest->Reserved)))
642  {
644  }
645 
646  CriticalSection = (CheckVdmRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
649 
650  /* Enter the critical section */
652 
653  /* Check if this is a DOS or WOW VDM */
654  if (CheckVdmRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
655  {
656  /* Get the console record */
657  Status = BaseSrvGetConsoleRecord(CheckVdmRequest->ConsoleHandle,
658  &ConsoleRecord);
659  if (!NT_SUCCESS(Status))
660  {
661  /* Allocate a new console record */
662  ConsoleRecord = BaseSrvCreateConsoleRecord();
663  if (ConsoleRecord == NULL)
664  {
666  goto Cleanup;
667  }
668 
669  /* Initialize the console record */
670  ConsoleRecord->ConsoleHandle = CheckVdmRequest->ConsoleHandle;
671  if (ConsoleRecord->ConsoleHandle == NULL)
672  {
673  /* The parent doesn't have a console, get a new session ID */
674  ConsoleRecord->SessionId = GetNextDosSesId();
675  }
676  else
677  {
678  /* No session ID is needed */
679  ConsoleRecord->SessionId = 0;
680  }
681 
682  /* Remember that the console record was allocated here */
683  NewConsoleRecord = TRUE;
684  }
685 
686  if (!NewConsoleRecord)
687  {
688  /* Get the primary DOS record */
689  DosRecord = (PVDM_DOS_RECORD)CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
691 
692  if (DosRecord->State != VDM_READY) // == VDM_NOT_READY
693  {
694  /* Allocate a new DOS record */
697  sizeof(VDM_DOS_RECORD));
698  if (DosRecord == NULL)
699  {
701  goto Cleanup;
702  }
703 
704  /* Remember that the DOS record was allocated here */
705  NewDosRecord = TRUE;
706  }
707  }
708  else
709  {
710  /* Allocate a new DOS record */
713  sizeof(VDM_DOS_RECORD));
714  if (DosRecord == NULL)
715  {
717  goto Cleanup;
718  }
719 
720  /* Remember that the DOS record was allocated here */
721  NewDosRecord = TRUE;
722  }
723 
724  /* Initialize the DOS record */
725  DosRecord->State = VDM_NOT_READY;
726  DosRecord->ExitCode = 0;
727 
728  /* Translate the input structure into a VDM command structure and set it in the DOS record */
729  if (!BaseSrvCopyCommand(CheckVdmRequest, DosRecord))
730  {
731  /* The only possibility is that an allocation failure occurred */
733  goto Cleanup;
734  }
735 
736  if (NewDosRecord)
737  {
738  /* Add the DOS record */
739  InsertHeadList(&ConsoleRecord->DosListHead, &DosRecord->Entry);
740  }
741 
742  if (!NewConsoleRecord)
743  {
744  Status = BaseSrvCreatePairWaitHandles(&DosRecord->ServerEvent, &DosRecord->ClientEvent);
745  if (!NT_SUCCESS(Status)) goto Cleanup;
746 
747  /* Return the client event handle */
748  CheckVdmRequest->WaitObjectForParent = DosRecord->ClientEvent;
749  }
750 
751  // FIXME: We may notify ONLY if ConsoleRecord->nReEntrancy is > 0
752  // in case NewConsoleRecord == FALSE AND NewDosRecord == TRUE.
753  if (ConsoleRecord->ServerEvent)
754  {
755  /* Signal the session event */
756  NtSetEvent(ConsoleRecord->ServerEvent, NULL);
757  }
758 
759  if (NewConsoleRecord)
760  {
761  /* Add the console record */
762  InsertTailList(&VDMConsoleListHead, &ConsoleRecord->Entry);
763  }
764 
765  CheckVdmRequest->iTask = ConsoleRecord->SessionId;
766  CheckVdmRequest->VDMState = NewConsoleRecord ? VDM_NOT_LOADED : VDM_READY;
768  }
769  else
770  {
771  // TODO: NOT IMPLEMENTED
774  }
775 
776 Cleanup:
777  /* Check if it failed */
778  if (!NT_SUCCESS(Status))
779  {
780  /* Free the DOS record if it was allocated here */
781  if (NewDosRecord)
782  {
783  ASSERT(DosRecord != NULL);
784 
786  DosRecord->ClientEvent);
787 
788  RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
789  DosRecord = NULL;
790  }
791 
792  /* Free the console record if it was allocated here */
793  if (NewConsoleRecord)
794  {
795  ASSERT(ConsoleRecord != NULL);
796 
797  RtlFreeHeap(BaseSrvHeap, 0, ConsoleRecord);
798  ConsoleRecord = NULL;
799  }
800  }
801 
802  /* Leave the critical section */
804 
805  return Status;
806 }
USHORT State
Definition: vdm.h:37
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
PCHAR AppName
Definition: basemsg.h:130
PCHAR CmdLine
Definition: basemsg.h:129
struct _VDM_DOS_RECORD * PVDM_DOS_RECORD
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
ULONG DesktopLen
Definition: basemsg.h:137
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
PCHAR CurDirectory
Definition: basemsg.h:132
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
USHORT PifLen
Definition: basemsg.h:144
#define InsertTailList(ListHead, Entry)
#define STATUS_VDM_DISALLOWED
Definition: ntstatus.h:957
HANDLE ServerEvent
Definition: vdm.h:39
ULONG TitleLen
Definition: basemsg.h:139
#define VDM_READY
Definition: vdm.h:48
return STATUS_NOT_IMPLEMENTED
ULONG ExitCode
Definition: vdm.h:38
#define FALSE
Definition: types.h:117
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION WowCriticalSection
Definition: vdm.c:23
HANDLE WaitObjectForParent
Definition: basemsg.h:123
CRITICAL_SECTION CriticalSection
Definition: iprtprio.c:40
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
unsigned char BOOLEAN
LIST_ENTRY VDMConsoleListHead
Definition: vdm.c:21
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
USHORT CmdLen
Definition: basemsg.h:142
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN BaseSrvIsVdmAllowed(VOID)
Definition: vdm.c:143
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG SessionId
Definition: vdm.h:30
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define BINARY_TYPE_SEPARATE_WOW
Definition: vdm.h:39
HANDLE ConsoleHandle
Definition: vdm.h:22
PCHAR PifFile
Definition: basemsg.h:131
LIST_ENTRY DosListHead
Definition: vdm.h:31
static const WCHAR Cleanup[]
Definition: register.c:80
ULONG GetNextDosSesId(VOID)
Definition: vdm.c:114
HANDLE ClientEvent
Definition: vdm.h:40
HANDLE BaseSrvHeap
Definition: init.c:29
PVDM_CONSOLE_RECORD BaseSrvCreateConsoleRecord(VOID)
Definition: vdm.c:27
ULONG BinaryType
Definition: basemsg.h:122
PCHAR Desktop
Definition: basemsg.h:136
#define VDM_NOT_LOADED
Definition: vdm.h:46
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define VDM_NOT_READY
Definition: vdm.h:47
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
NTSTATUS BaseSrvCreatePairWaitHandles(PHANDLE ServerEvent, PHANDLE ClientEvent)
Definition: vdm.c:240
USHORT VDMState
Definition: basemsg.h:147
#define UNIMPLEMENTED
Definition: debug.h:115
USHORT CurDirectoryLen
Definition: basemsg.h:145
ULONG ReservedLen
Definition: basemsg.h:141
#define STATUS_SUCCESS
Definition: shellext.h:65
LIST_ENTRY Entry
Definition: vdm.h:21
PCHAR Reserved
Definition: basemsg.h:140
LIST_ENTRY Entry
Definition: vdm.h:36
HANDLE ServerEvent
Definition: vdm.h:24
base of all file and directory entries
Definition: entries.h:82
USHORT AppLen
Definition: basemsg.h:143
BOOLEAN BaseSrvCopyCommand(PBASE_CHECK_VDM CheckVdmRequest, PVDM_DOS_RECORD DosRecord)
Definition: vdm.c:352
VOID BaseSrvDestroyPairWaitHandles(HANDLE ServerEvent, HANDLE ClientEvent)
Definition: vdm.c:261
HANDLE ConsoleHandle
Definition: basemsg.h:121

◆ CSR_API() [16/31]

CSR_API ( BaseSrvUpdateVDMEntry  )

Definition at line 808 of file vdm.c.

809 {
811  PBASE_UPDATE_VDM_ENTRY UpdateVdmEntryRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.UpdateVDMEntryRequest;
813  PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
814  PVDM_DOS_RECORD DosRecord = NULL;
815 
816  CriticalSection = (UpdateVdmEntryRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
819 
820  /* Enter the critical section */
822 
823  /* Check if this is a DOS or WOW VDM */
824  if (UpdateVdmEntryRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
825  {
826  if (UpdateVdmEntryRequest->iTask != 0)
827  {
828  /* Get the console record using the task ID */
829  Status = GetConsoleRecordBySessionId(UpdateVdmEntryRequest->iTask,
830  &ConsoleRecord);
831  }
832  else
833  {
834  /* Get the console record using the console handle */
835  Status = BaseSrvGetConsoleRecord(UpdateVdmEntryRequest->ConsoleHandle,
836  &ConsoleRecord);
837  }
838 
839  if (!NT_SUCCESS(Status)) goto Cleanup;
840 
841  /* Get the primary DOS record */
842  DosRecord = (PVDM_DOS_RECORD)CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
844 
845  switch (UpdateVdmEntryRequest->EntryIndex)
846  {
847  case VdmEntryUndo:
848  {
849  /* Close the server event handle, the client will close the client handle */
850  NtClose(DosRecord->ServerEvent);
851  DosRecord->ServerEvent = DosRecord->ClientEvent = NULL;
852 
853  if (UpdateVdmEntryRequest->VDMCreationState & (VDM_UNDO_PARTIAL | VDM_UNDO_FULL))
854  {
855  /* Remove the DOS record */
856  if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
857  RemoveEntryList(&DosRecord->Entry);
858  RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
859 
860  /*
861  * Since this is an undo, if that was the only DOS record the VDM
862  * won't even start, so the console record should be removed too.
863  */
864  if (ConsoleRecord->DosListHead.Flink == &ConsoleRecord->DosListHead)
865  {
866  RemoveEntryList(&ConsoleRecord->Entry);
867  BaseSrvDestroyConsoleRecord(ConsoleRecord);
868  }
869  }
870 
871  /* It was successful */
873 
874  break;
875  }
876 
878  {
879  /* Duplicate the VDM process handle */
881  UpdateVdmEntryRequest->VDMProcessHandle,
883  &ConsoleRecord->ProcessHandle,
884  0,
885  0,
887  if (!NT_SUCCESS(Status)) goto Cleanup;
888 
889  //
890  // FIXME! Should we always do the following??
891  //
892 
893  /* Create a pair of handles to one event object */
895  &DosRecord->ClientEvent);
896  if (!NT_SUCCESS(Status)) goto Cleanup;
897 
898  /* Return the client event handle */
899  UpdateVdmEntryRequest->WaitObjectForParent = DosRecord->ClientEvent;
900 
901  break;
902  }
903 
905  {
906  // TODO: NOT IMPLEMENTED
907  DPRINT1("BaseSrvUpdateVDMEntry: VdmEntryUpdateControlCHandler not implemented!");
909 
910  break;
911  }
912 
913  default:
914  {
915  /* Invalid */
917  }
918  }
919  }
920  else
921  {
922  // TODO: NOT IMPLEMENTED
925  }
926 
927 Cleanup:
928  /* Leave the critical section */
930 
931  return Status;
932 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
Definition: basemsg.h:150
struct _VDM_DOS_RECORD * PVDM_DOS_RECORD
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID BaseSrvFreeVDMInfo(PVDM_COMMAND_INFO CommandInfo)
Definition: vdm.c:281
HANDLE ServerEvent
Definition: vdm.h:39
ULONG BinaryType
Definition: basemsg.h:153
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
return STATUS_NOT_IMPLEMENTED
HANDLE ProcessHandle
Definition: vdm.h:23
#define DUPLICATE_SAME_ACCESS
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION WowCriticalSection
Definition: vdm.c:23
NTSTATUS GetConsoleRecordBySessionId(ULONG TaskId, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:95
CRITICAL_SECTION CriticalSection
Definition: iprtprio.c:40
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
HANDLE WaitObjectForParent
Definition: basemsg.h:156
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define VDM_UNDO_FULL
Definition: vdm.h:28
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PVDM_COMMAND_INFO CommandInfo
Definition: vdm.h:41
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG iTask
Definition: basemsg.h:152
#define BINARY_TYPE_SEPARATE_WOW
Definition: vdm.h:39
VOID BaseSrvDestroyConsoleRecord(PVDM_CONSOLE_RECORD ConsoleRecord)
Definition: vdm.c:71
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
LIST_ENTRY DosListHead
Definition: vdm.h:31
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE ClientEvent
Definition: vdm.h:40
USHORT EntryIndex
Definition: basemsg.h:157
HANDLE BaseSrvHeap
Definition: init.c:29
USHORT VDMCreationState
Definition: basemsg.h:158
#define DUPLICATE_SAME_ATTRIBUTES
Definition: obtypes.h:153
HANDLE VDMProcessHandle
Definition: basemsg.h:155
#define VDM_UNDO_PARTIAL
Definition: vdm.h:27
#define NULL
Definition: types.h:112
HANDLE ConsoleHandle
Definition: basemsg.h:154
NTSTATUS BaseSrvCreatePairWaitHandles(PHANDLE ServerEvent, PHANDLE ClientEvent)
Definition: vdm.c:240
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3406
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_SUCCESS
Definition: shellext.h:65
LIST_ENTRY Entry
Definition: vdm.h:21
LIST_ENTRY Entry
Definition: vdm.h:36
base of all file and directory entries
Definition: entries.h:82

◆ CSR_API() [17/31]

CSR_API ( BaseSrvGetNextVDMCommand  )

Definition at line 934 of file vdm.c.

935 {
937  PBASE_GET_NEXT_VDM_COMMAND GetNextVdmCommandRequest =
938  &((PBASE_API_MESSAGE)ApiMessage)->Data.GetNextVDMCommandRequest;
940  PLIST_ENTRY i = NULL;
941  PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
942  PVDM_DOS_RECORD DosRecord = NULL;
943 
944  /* Validate the message buffers */
945  if (!CsrValidateMessageBuffer(ApiMessage,
946  (PVOID*)&GetNextVdmCommandRequest->CmdLine,
947  GetNextVdmCommandRequest->CmdLen,
948  sizeof(*GetNextVdmCommandRequest->CmdLine))
949  || !CsrValidateMessageBuffer(ApiMessage,
950  (PVOID*)&GetNextVdmCommandRequest->AppName,
951  GetNextVdmCommandRequest->AppLen,
952  sizeof(*GetNextVdmCommandRequest->AppName))
953  || !CsrValidateMessageBuffer(ApiMessage,
954  (PVOID*)&GetNextVdmCommandRequest->PifFile,
955  GetNextVdmCommandRequest->PifLen,
956  sizeof(*GetNextVdmCommandRequest->PifFile))
957  || !CsrValidateMessageBuffer(ApiMessage,
958  (PVOID*)&GetNextVdmCommandRequest->CurDirectory,
959  GetNextVdmCommandRequest->CurDirectoryLen,
960  sizeof(*GetNextVdmCommandRequest->CurDirectory))
961  || !CsrValidateMessageBuffer(ApiMessage,
962  (PVOID*)&GetNextVdmCommandRequest->Env,
963  GetNextVdmCommandRequest->EnvLen,
964  sizeof(*GetNextVdmCommandRequest->Env))
965  || !CsrValidateMessageBuffer(ApiMessage,
966  (PVOID*)&GetNextVdmCommandRequest->Desktop,
967  GetNextVdmCommandRequest->DesktopLen,
968  sizeof(*GetNextVdmCommandRequest->Desktop))
969  || !CsrValidateMessageBuffer(ApiMessage,
970  (PVOID*)&GetNextVdmCommandRequest->Title,
971  GetNextVdmCommandRequest->TitleLen,
972  sizeof(*GetNextVdmCommandRequest->Title))
973  || !CsrValidateMessageBuffer(ApiMessage,
974  (PVOID*)&GetNextVdmCommandRequest->Reserved,
975  GetNextVdmCommandRequest->ReservedLen,
976  sizeof(*GetNextVdmCommandRequest->Reserved))
977  || !CsrValidateMessageBuffer(ApiMessage,
978  (PVOID*)&GetNextVdmCommandRequest->StartupInfo,
979  1,
980  sizeof(STARTUPINFOA)))
981  {
983  }
984 
985  CriticalSection = (GetNextVdmCommandRequest->VDMState & VDM_FLAG_WOW)
988 
989  /* Enter the critical section */
991 
992  if (GetNextVdmCommandRequest->VDMState & VDM_FLAG_WOW)
993  {
994  // TODO: WOW SUPPORT NOT IMPLEMENTED
997  goto Cleanup;
998  }
999  // else if (!(GetNextVdmCommandRequest->VDMState & VDM_FLAG_WOW))
1000  {
1001  if (GetNextVdmCommandRequest->iTask != 0)
1002  {
1003  /* Get the console record using the task ID */
1004  Status = GetConsoleRecordBySessionId(GetNextVdmCommandRequest->iTask,
1005  &ConsoleRecord);
1006  }
1007  else
1008  {
1009  /* Get the console record using the console handle */
1010  Status = BaseSrvGetConsoleRecord(GetNextVdmCommandRequest->ConsoleHandle,
1011  &ConsoleRecord);
1012  }
1013 
1014  /* Make sure we found the console record */
1015  if (!NT_SUCCESS(Status)) goto Cleanup;
1016 
1017  /* Return the session ID */
1018  GetNextVdmCommandRequest->iTask = ConsoleRecord->SessionId;
1019  GetNextVdmCommandRequest->WaitObjectForVDM = NULL;
1020 
1021  if (GetNextVdmCommandRequest->VDMState & VDM_GET_FIRST_COMMAND)
1022  {
1023  /* Check if the DOS record list is empty */
1024  if (ConsoleRecord->DosListHead.Flink == &ConsoleRecord->DosListHead)
1025  {
1027  goto Cleanup;
1028  }
1029 
1030  /* Get the first DOS record */
1031  DosRecord = CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink, VDM_DOS_RECORD, Entry);
1032 
1033  /* Make sure its command information is still there */
1034  if (DosRecord->CommandInfo == NULL)
1035  {
1037  goto Cleanup;
1038  }
1039 
1040  /* Check if the console handle hasn't been set yet */
1041  if (ConsoleRecord->ConsoleHandle == NULL)
1042  {
1043  /* Set it now */
1044  ConsoleRecord->ConsoleHandle = GetNextVdmCommandRequest->ConsoleHandle;
1045  }
1046 
1047  /* Fill the command information */
1048  Status = BaseSrvFillCommandInfo(DosRecord->CommandInfo, GetNextVdmCommandRequest);
1049  goto Cleanup;
1050  }
1051 
1052  /* Check if we should set the state of a running DOS record to ready */
1053  if (!(GetNextVdmCommandRequest->VDMState
1055  {
1056  /* Search for a DOS record that is currently running */
1057  for (i = ConsoleRecord->DosListHead.Flink; i != &ConsoleRecord->DosListHead; i = i->Flink)
1058  {
1059  DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
1060  if (DosRecord->State == VDM_NOT_READY) break;
1061  }
1062 
1063  /* Check if we found any */
1064  if (i == &ConsoleRecord->DosListHead)
1065  {
1067  goto Cleanup;
1068  }
1069 
1070  /* Set the exit code */
1071  DosRecord->ExitCode = GetNextVdmCommandRequest->ExitCode;
1072 
1073  /* Update the VDM state */
1074  DosRecord->State = VDM_READY;
1075 
1076  /* Notify all waiting threads that the task is finished */
1077  NtSetEvent(DosRecord->ServerEvent, NULL);
1078  NtClose(DosRecord->ServerEvent);
1079  DosRecord->ServerEvent = NULL;
1080  }
1081 
1082  /* Search for a DOS record that is currently running and has command information */
1083  for (i = ConsoleRecord->DosListHead.Flink; i != &ConsoleRecord->DosListHead; i = i->Flink)
1084  {
1085  DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
1086  if ((DosRecord->State == VDM_NOT_READY) && (DosRecord->CommandInfo != NULL)) break;
1087  }
1088 
1089  /* Check if we found any */
1090  if (i != &ConsoleRecord->DosListHead)
1091  {
1092  ASSERT(DosRecord->CommandInfo != NULL);
1093 
1094  /* Check if the caller only wants environment data */
1095  if (GetNextVdmCommandRequest->VDMState & VDM_GET_ENVIRONMENT)
1096  {
1097  if (GetNextVdmCommandRequest->EnvLen < DosRecord->CommandInfo->EnvLen)
1098  {
1099  /* Not enough space was reserved */
1100  GetNextVdmCommandRequest->EnvLen = DosRecord->CommandInfo->EnvLen;
1102  goto Cleanup;
1103  }
1104 
1105  /* Copy the environment data */
1106  RtlMoveMemory(GetNextVdmCommandRequest->Env,
1107  DosRecord->CommandInfo->Env,
1108  DosRecord->CommandInfo->EnvLen);
1109 
1110  /* Return the actual size to the caller */
1111  GetNextVdmCommandRequest->EnvLen = DosRecord->CommandInfo->EnvLen;
1112  }
1113  else
1114  {
1115  /* Fill the command information */
1116  Status = BaseSrvFillCommandInfo(DosRecord->CommandInfo, GetNextVdmCommandRequest);
1117  if (!NT_SUCCESS(Status)) goto Cleanup;
1118 
1119  /* Free the command information, it's no longer needed */
1120  BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1121  DosRecord->CommandInfo = NULL;
1122 
1123  /* Update the VDM state */
1124  DosRecord->State = VDM_NOT_READY;
1125  }
1126 
1128  goto Cleanup;
1129  }
1130  }
1131 
1132  GetNextVdmCommandRequest->WaitObjectForVDM = NULL;
1133 
1134  /*
1135  * There is no command yet. Prepare for waiting if we asked so,
1136  * and if we were not retrying a request.
1137  */
1138  if (!(GetNextVdmCommandRequest->VDMState & VDM_FLAG_DONT_WAIT) ||
1139  !(GetNextVdmCommandRequest->VDMState & VDM_FLAG_RETRY))
1140  {
1141  if (ConsoleRecord->ServerEvent)
1142  {
1143  /* Reset the event */
1144  NtResetEvent(ConsoleRecord->ServerEvent, NULL);
1145  }
1146  else
1147  {
1148  /* Create a pair of wait handles */
1150  &ConsoleRecord->ClientEvent);
1151  if (!NT_SUCCESS(Status)) goto Cleanup;
1152  }
1153 
1154  /* Return the client event handle */
1155  GetNextVdmCommandRequest->WaitObjectForVDM = ConsoleRecord->ClientEvent;
1156  }
1157 
1158 Cleanup:
1159  /* Leave the critical section */
1161 
1162  return Status;
1163 }
USHORT State
Definition: vdm.h:37
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
HANDLE ClientEvent
Definition: vdm.h:25
#define VDM_FLAG_WOW
Definition: vdm.h:54
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID BaseSrvFreeVDMInfo(PVDM_COMMAND_INFO CommandInfo)
Definition: vdm.c:281
HANDLE ServerEvent
Definition: vdm.h:39
NTSTATUS NTAPI NtResetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:386
NTSTATUS BaseSrvFillCommandInfo(PVDM_COMMAND_INFO CommandInfo, PBASE_GET_NEXT_VDM_COMMAND Message)
Definition: vdm.c:499
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define VDM_GET_ENVIRONMENT
Definition: vdm.h:62
#define VDM_READY
Definition: vdm.h:48
return STATUS_NOT_IMPLEMENTED
ULONG ExitCode
Definition: vdm.h:38
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION WowCriticalSection
Definition: vdm.c:23
NTSTATUS GetConsoleRecordBySessionId(ULONG TaskId, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:95
CRITICAL_SECTION CriticalSection
Definition: iprtprio.c:40
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define VDM_GET_FIRST_COMMAND
Definition: vdm.h:61
#define VDM_FLAG_RETRY
Definition: vdm.h:56
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define VDM_FLAG_NESTED_TASK
Definition: vdm.h:59
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LPSTARTUPINFOA StartupInfo
Definition: basemsg.h:178
PVDM_COMMAND_INFO CommandInfo
Definition: vdm.h:41
ULONG SessionId
Definition: vdm.h:30
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LPSTR Env
Definition: vdm.h:81
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
HANDLE ConsoleHandle
Definition: vdm.h:22
Definition: typedefs.h:119
LIST_ENTRY DosListHead
Definition: vdm.h:31
static const WCHAR Cleanup[]
Definition: register.c:80
ULONG EnvLen
Definition: vdm.h:82
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define VDM_NOT_READY
Definition: vdm.h:47
#define NULL
Definition: types.h:112
NTSTATUS BaseSrvCreatePairWaitHandles(PHANDLE ServerEvent, PHANDLE ClientEvent)
Definition: vdm.c:240
#define VDM_FLAG_FIRST_TASK
Definition: vdm.h:53
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE ServerEvent
Definition: vdm.h:24
base of all file and directory entries
Definition: entries.h:82
#define VDM_FLAG_DONT_WAIT
Definition: vdm.h:60

◆ CSR_API() [18/31]

CSR_API ( BaseSrvExitVDM  )

Definition at line 1165 of file vdm.c.

1166 {
1167  NTSTATUS Status;
1168  PBASE_EXIT_VDM ExitVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ExitVDMRequest;
1170  PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
1171  PVDM_DOS_RECORD DosRecord;
1172 
1173  CriticalSection = (ExitVdmRequest->iWowTask == 0)
1175  : &WowCriticalSection;
1176 
1177  /* Enter the critical section */
1179 
1180  if (ExitVdmRequest->iWowTask == 0)
1181  {
1182  /* Get the console record */
1183  Status = BaseSrvGetConsoleRecord(ExitVdmRequest->ConsoleHandle, &ConsoleRecord);
1184  if (!NT_SUCCESS(Status)) goto Cleanup;
1185 
1186  if (ConsoleRecord->ServerEvent)
1187  ExitVdmRequest->WaitObjectForVDM = ConsoleRecord->ClientEvent;
1188 
1189  // NOTE: The following is the same as in BaseSrvCleanupVDMResources.
1190 
1191  if (ConsoleRecord->ServerEvent)
1192  {
1193  NtClose(ConsoleRecord->ServerEvent);
1194  ConsoleRecord->ServerEvent = NULL;
1195  }
1196 
1197  /* Cleanup the DOS records */
1198  while (!IsListEmpty(&ConsoleRecord->DosListHead))
1199  {
1200  DosRecord = CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
1202 
1203  /* Set the event and close it */
1204  if (DosRecord->ServerEvent)
1205  {
1206  NtSetEvent(DosRecord->ServerEvent, NULL);
1207  NtClose(DosRecord->ServerEvent);
1208  DosRecord->ServerEvent = NULL;
1209  }
1210 
1211  /* Remove the DOS entry */
1212  if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1213  RemoveEntryList(&DosRecord->Entry);
1214  RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
1215  }
1216 
1217  /* Remove the console record */
1218  RemoveEntryList(&ConsoleRecord->Entry);
1219  BaseSrvDestroyConsoleRecord(ConsoleRecord);
1220  }
1221  else
1222  {
1223  // TODO: NOT IMPLEMENTED
1224  UNIMPLEMENTED;
1226  }
1227 
1228 Cleanup:
1229  /* Leave the critical section */
1231 
1232  return Status;
1233 }
HANDLE WaitObjectForVDM
Definition: basemsg.h:198
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
HANDLE ClientEvent
Definition: vdm.h:25
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID BaseSrvFreeVDMInfo(PVDM_COMMAND_INFO CommandInfo)
Definition: vdm.c:281
HANDLE ServerEvent
Definition: vdm.h:39
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
return STATUS_NOT_IMPLEMENTED
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION WowCriticalSection
Definition: vdm.c:23
CRITICAL_SECTION CriticalSection
Definition: iprtprio.c:40
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PVDM_COMMAND_INFO CommandInfo
Definition: vdm.h:41
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
ULONG iWowTask
Definition: basemsg.h:197
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID BaseSrvDestroyConsoleRecord(PVDM_CONSOLE_RECORD ConsoleRecord)
Definition: vdm.c:71
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
LIST_ENTRY DosListHead
Definition: vdm.h:31
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE BaseSrvHeap
Definition: init.c:29
#define NULL
Definition: types.h:112
HANDLE ConsoleHandle
Definition: basemsg.h:196
#define UNIMPLEMENTED
Definition: debug.h:115
LIST_ENTRY Entry
Definition: vdm.h:21
LIST_ENTRY Entry
Definition: vdm.h:36
HANDLE ServerEvent
Definition: vdm.h:24
base of all file and directory entries
Definition: entries.h:82

◆ CSR_API() [19/31]

CSR_API ( BaseSrvIsFirstVDM  )

Definition at line 1235 of file vdm.c.

1236 {
1237  PBASE_IS_FIRST_VDM IsFirstVDMRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.IsFirstVDMRequest;
1238 
1239  /* Return the result */
1240  IsFirstVDMRequest->FirstVDM = FirstVDM;
1241 
1242  /* Clear the first VDM flag */
1243  FirstVDM = FALSE;
1244 
1245  return STATUS_SUCCESS;
1246 }
BOOLEAN FirstVDM
Definition: vdm.c:20
#define FALSE
Definition: types.h:117
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ CSR_API() [20/31]

CSR_API ( BaseSrvGetVDMExitCode  )

Definition at line 1248 of file vdm.c.

1249 {
1250  NTSTATUS Status;
1251  PBASE_GET_VDM_EXIT_CODE GetVDMExitCodeRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.GetVDMExitCodeRequest;
1252  PLIST_ENTRY i = NULL;
1253  PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
1254  PVDM_DOS_RECORD DosRecord = NULL;
1255 
1256  /* Enter the critical section */
1258 
1259  /* Get the console record */
1260  Status = BaseSrvGetConsoleRecord(GetVDMExitCodeRequest->ConsoleHandle, &ConsoleRecord);
1261  if (!NT_SUCCESS(Status)) goto Cleanup;
1262 
1263  /* Search for a DOS record that has the same parent process handle */
1264  for (i = ConsoleRecord->DosListHead.Flink; i != &ConsoleRecord->DosListHead; i = i->Flink)
1265  {
1266  DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
1267  if (DosRecord->ClientEvent == GetVDMExitCodeRequest->hParent) break;
1268  }
1269 
1270  /* Check if no DOS record was found */
1271  if (i == &ConsoleRecord->DosListHead)
1272  {
1274  goto Cleanup;
1275  }
1276 
1277  /* Check if this task is still running */
1278  if (DosRecord->State != VDM_READY)
1279  {
1280  GetVDMExitCodeRequest->ExitCode = STATUS_PENDING;
1281  goto Cleanup;
1282  }
1283 
1284  /* Return the exit code */
1285  GetVDMExitCodeRequest->ExitCode = DosRecord->ExitCode;
1286 
1287  // FIXME: We may just change DosRecord->State to VDM_READY in some cases...
1288 
1289  /* Since this is a zombie task record, remove it */
1290  if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1291  RemoveEntryList(&DosRecord->Entry);
1292  RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
1293 
1294 Cleanup:
1295  /* Leave the critical section */
1297 
1298  return Status;
1299 }
USHORT State
Definition: vdm.h:37
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID BaseSrvFreeVDMInfo(PVDM_COMMAND_INFO CommandInfo)
Definition: vdm.c:281
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define VDM_READY
Definition: vdm.h:48
ULONG ExitCode
Definition: vdm.h:38
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_NOT_FOUND
Definition: shellext.h:72
PVDM_COMMAND_INFO CommandInfo
Definition: vdm.h:41
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
Definition: typedefs.h:119
LIST_ENTRY DosListHead
Definition: vdm.h:31
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE ClientEvent
Definition: vdm.h:40
HANDLE BaseSrvHeap
Definition: init.c:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
LIST_ENTRY Entry
Definition: vdm.h:36
base of all file and directory entries
Definition: entries.h:82

◆ CSR_API() [21/31]

CSR_API ( BaseSrvSetReenterCount  )

Definition at line 1301 of file vdm.c.

1302 {
1304  PBASE_SET_REENTER_COUNT SetReenterCountRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.SetReenterCountRequest;
1305  PVDM_CONSOLE_RECORD ConsoleRecord;
1306 
1307  /* Enter the critical section */
1309 
1310  /* Get the console record */
1311  Status = BaseSrvGetConsoleRecord(SetReenterCountRequest->ConsoleHandle, &ConsoleRecord);
1312  if (!NT_SUCCESS(Status)) goto Cleanup;
1313 
1314  if (SetReenterCountRequest->fIncDec == VDM_INC_REENTER_COUNT)
1315  {
1316  ConsoleRecord->ReenterCount++;
1317  }
1318  else if (SetReenterCountRequest->fIncDec == VDM_DEC_REENTER_COUNT)
1319  {
1320  ConsoleRecord->ReenterCount--;
1321  if (ConsoleRecord->ServerEvent)
1322  NtSetEvent(ConsoleRecord->ServerEvent, NULL);
1323  }
1324  else
1325  {
1327  }
1328 
1329 Cleanup:
1330  /* Leave the critical section */
1332 
1333  return Status;
1334 }
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
ULONG ReenterCount
Definition: vdm.h:27
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define VDM_DEC_REENTER_COUNT
Definition: vdm.h:58
Status
Definition: gdiplustypes.h:24
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR Cleanup[]
Definition: register.c:80
#define NULL
Definition: types.h:112
#define VDM_INC_REENTER_COUNT
Definition: vdm.h:57
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE ServerEvent
Definition: vdm.h:24

◆ CSR_API() [22/31]

CSR_API ( BaseSrvSetVDMCurDirs  )

Definition at line 1336 of file vdm.c.

1337 {
1338  NTSTATUS Status;
1339  PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest;
1340  PVDM_CONSOLE_RECORD ConsoleRecord;
1341  PCHAR Buffer = NULL;
1342 
1343  /* Validate the input buffer */
1344  if (!CsrValidateMessageBuffer(ApiMessage,
1345  (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs,
1346  VDMCurrentDirsRequest->cchCurDirs,
1347  sizeof(*VDMCurrentDirsRequest->lpszzCurDirs)))
1348  {
1349  return STATUS_INVALID_PARAMETER;
1350  }
1351 
1352  /* Enter the critical section */
1354 
1355  /* Find the console record */
1356  Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord);
1357  if (!NT_SUCCESS(Status)) goto Cleanup;
1358 
1359  if (ConsoleRecord->CurrentDirs == NULL)
1360  {
1361  /* Allocate memory for the current directory information */
1364  VDMCurrentDirsRequest->cchCurDirs);
1365  }
1366  else
1367  {
1368  /* Resize the amount of allocated memory */
1371  ConsoleRecord->CurrentDirs,
1372  VDMCurrentDirsRequest->cchCurDirs);
1373  }
1374 
1375  if (Buffer == NULL)
1376  {
1377  /* Allocation failed */
1379  goto Cleanup;
1380  }
1381 
1382  /* Update the console record */
1383  ConsoleRecord->CurrentDirs = Buffer;
1384  ConsoleRecord->CurDirsLength = VDMCurrentDirsRequest->cchCurDirs;
1385 
1386  /* Copy the data */
1387  RtlMoveMemory(ConsoleRecord->CurrentDirs,
1388  VDMCurrentDirsRequest->lpszzCurDirs,
1389  VDMCurrentDirsRequest->cchCurDirs);
1390 
1391 Cleanup:
1392  /* Leave the critical section */
1394 
1395  return Status;
1396 }
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
ULONG CurDirsLength
Definition: vdm.h:29
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCHAR CurrentDirs
Definition: vdm.h:28
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE BaseSrvHeap
Definition: init.c:29
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2667

◆ CSR_API() [23/31]

CSR_API ( BaseSrvGetVDMCurDirs  )

Definition at line 1398 of file vdm.c.

1399 {
1400  NTSTATUS Status;
1401  PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest;
1402  PVDM_CONSOLE_RECORD ConsoleRecord;
1403 
1404  /* Validate the output buffer */
1405  if (!CsrValidateMessageBuffer(ApiMessage,
1406  (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs,
1407  VDMCurrentDirsRequest->cchCurDirs,
1408  sizeof(*VDMCurrentDirsRequest->lpszzCurDirs)))
1409  {
1410  return STATUS_INVALID_PARAMETER;
1411  }
1412 
1413  /* Enter the critical section */
1415 
1416  /* Find the console record */
1417  Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord);
1418  if (!NT_SUCCESS(Status)) goto Cleanup;
1419 
1420  /* Return the actual size of the current directory information */
1421  VDMCurrentDirsRequest->cchCurDirs = ConsoleRecord->CurDirsLength;
1422 
1423  /* Check if the buffer is large enough */
1424  if (VDMCurrentDirsRequest->cchCurDirs < ConsoleRecord->CurDirsLength)
1425  {
1427  goto Cleanup;
1428  }
1429 
1430  /* Copy the data */
1431  RtlMoveMemory(VDMCurrentDirsRequest->lpszzCurDirs,
1432  ConsoleRecord->CurrentDirs,
1433  ConsoleRecord->CurDirsLength);
1434 
1435 Cleanup:
1436  /* Leave the critical section */
1438 
1439  return Status;
1440 }
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
ULONG CurDirsLength
Definition: vdm.h:29
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
Status
Definition: gdiplustypes.h:24
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCHAR CurrentDirs
Definition: vdm.h:28
static const WCHAR Cleanup[]
Definition: register.c:80

◆ CSR_API() [24/31]

CSR_API ( BaseSrvBatNotification  )

Definition at line 1442 of file vdm.c.

1443 {
1444  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1445  return STATUS_NOT_IMPLEMENTED;
1446 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [25/31]

CSR_API ( BaseSrvRegisterWowExec  )

Definition at line 1448 of file vdm.c.

1449 {
1450  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1451  return STATUS_NOT_IMPLEMENTED;
1452 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [26/31]

CSR_API ( BaseSrvRefreshIniFileMapping  )

Definition at line 1454 of file vdm.c.

1455 {
1456  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1457  return STATUS_NOT_IMPLEMENTED;
1458 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [27/31]

CSR_API ( BaseSrvNlsSetUserInfo  )

Definition at line 145 of file nls.c.

146 {
147  DPRINT1("%s not yet implemented\n", __FUNCTION__);
148  return STATUS_NOT_IMPLEMENTED;
149 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [28/31]

CSR_API ( BaseSrvNlsSetMultipleUserInfo  )

Definition at line 151 of file nls.c.

152 {
153  DPRINT1("%s not yet implemented\n", __FUNCTION__);
154  return STATUS_NOT_IMPLEMENTED;
155 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [29/31]

CSR_API ( BaseSrvNlsCreateSection  )

Definition at line 157 of file nls.c.

158 {
160  HANDLE SectionHandle, ProcessHandle, FileHandle;
161  ULONG LocaleId;
162  UNICODE_STRING NlsSectionName;
163  PWCHAR NlsFileName;
166  WCHAR FileNameBuffer[32];
167  WCHAR NlsSectionNameBuffer[32];
168  PBASE_NLS_CREATE_SECTION NlsMsg = &((PBASE_API_MESSAGE)ApiMessage)->Data.NlsCreateSection;
169 
170  /* Load kernel32 first and import the NLS routines */
172  if (!NT_SUCCESS(Status)) return Status;
173 
174  /* Assume failure */
175  NlsMsg->SectionHandle = NULL;
176 
177  /* Check and validate the locale ID, if one is present */
178  LocaleId = NlsMsg->LocaleId;
179  DPRINT1("NLS: Create Section with LCID: %lx for Type: %d\n", LocaleId, NlsMsg->Type);
180  if (LocaleId)
181  {
183  }
184 
185  /* Check which NLS section is being created */
186  switch (NlsMsg->Type)
187  {
188  /* For each one, set the correct filename and object name */
189  case 1:
190  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionUnicode");
191  NlsFileName = L"unicode.nls";
192  break;
193  case 2:
194  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionLocale");
195  NlsFileName = L"locale.nls";
196  break;
197  case 3:
198  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionCType");
199  NlsFileName = L"ctype.nls";
200  break;
201  case 4:
202  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionSortkey");
203  NlsFileName = L"sortkey.nls";
204  break;
205  case 5:
206  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionSortTbls");
207  NlsFileName = L"sorttbls.nls";
208  break;
209  case 6:
210  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionCP437");
211  NlsFileName = L"c_437.nls";
212  break;
213  case 7:
214  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionCP1252");
215  NlsFileName = L"c_1252.nls";
216  break;
217  case 8:
218  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionLANG_EXCEPT");
219  NlsFileName = L"l_except.nls";
220  break;
221  case 9:
222  DPRINT1("This type not yet supported\n");
223  return STATUS_NOT_IMPLEMENTED;
224  case 10:
225  DPRINT1("This type not yet supported\n");
226  return STATUS_NOT_IMPLEMENTED;
227  case 11:
228  /* Get the filename for this locale */
232  {
233  DPRINT1("File name query failed\n");
235  }
236 
237  /* Get the name of the section for this locale */
238  DPRINT1("File name: %S\n", FileNameBuffer);
240  10,
241  0,
242  L"\\NLS\\NlsSectionCP",
243  NlsSectionNameBuffer,
244  RTL_NUMBER_OF(NlsSectionNameBuffer));
245  if (!NT_SUCCESS(Status))
246  {
247  DPRINT1("Section name query failed: %lx\n", Status);
248  return Status;
249  }
250 
251  /* Setup the name and go open it */
252  NlsFileName = FileNameBuffer;
253  DPRINT1("Section name: %S\n", NlsSectionNameBuffer);
254  RtlInitUnicodeString(&NlsSectionName, NlsSectionNameBuffer);
255  break;
256  case 12:
257  RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionGeo");
258  NlsFileName = L"geo.nls";
259  break;
260  default:
261  DPRINT1("NLS: Invalid NLS type!\n");
263  }
264 
265  /* Open the specified NLS file */
266  Status = pOpenDataFile(&FileHandle, NlsFileName);
267  if (Status != STATUS_SUCCESS)
268  {
269  DPRINT1("NLS: Failed to open file: %lx\n", Status);
270  return Status;
271  }
272 
273  /* Create an SD for the section object */
275  sizeof(SecurityDescriptor),
276  0x80000000);
277  if (!NT_SUCCESS(Status))
278  {
279  DPRINT1("NLS: CreateNlsSecurityDescriptor FAILED!: %lx\n", Status);
281  return Status;
282  }
283 
284  /* Create the section object proper */
286  &NlsSectionName,
288  NULL,
290  Status = NtCreateSection(&SectionHandle,
293  0,
295  SEC_COMMIT,
296  FileHandle);
298  if (!NT_SUCCESS(Status))
299  {
300  DPRINT1("NLS: Failed to create section! %lx\n", Status);
301  return Status;
302  }
303 
304  /* Open a handle to the calling process */
309  &ApiMessage->Header.ClientId);
310  if (!NT_SUCCESS(Status))
311  {
312  DPRINT1("NLS: Failed to open process! %lx\n", Status);
313  NtClose(SectionHandle);
314  return Status;
315  }
316 
317  /* Duplicate the handle to the section object into it */
319  SectionHandle,
321  &NlsMsg->SectionHandle,
322  0,
323  0,
324  3);
326  return Status;
327 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
PGET_NLS_SECTION_NAME pGetNlsSectionName
Definition: nls.c:33
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3433
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_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
Definition: wsk.h:182
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
PCREATE_NLS_SECURTY_DESCRIPTOR pCreateNlsSecurityDescriptor
Definition: nls.c:36
uint16_t * PWCHAR
Definition: typedefs.h:56
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
#define OBJ_OPENIF
Definition: winternl.h:229
NTSTATUS NTAPI BaseSrvDelayLoadKernel32(VOID)
Definition: nls.c:56
HANDLE FileHandle
Definition: stats.c:38
return STATUS_NOT_IMPLEMENTED
#define SEC_COMMIT
Definition: mmtypes.h:99
#define PROCESS_DUP_HANDLE
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING _In_ LCID LocaleId
Definition: wdfpdo.h:430
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define SECTION_MAP_READ
Definition: compat.h:139
#define OBJ_PERMANENT
Definition: winternl.h:226
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
POPEN_DATA_FILE pOpenDataFile
Definition: nls.c:27
PVALIDATE_LOCALE pValidateLocale
Definition: nls.c:32
#define DPRINT1
Definition: precomp.h:8
WCHAR FileNameBuffer[_MAX_PATH]
Definition: framewnd.c:240
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3406
PGET_CP_FILE_NAME_FROM_REGISTRY pGetCPFileNameFromRegistry
Definition: nls.c:35
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403

◆ CSR_API() [30/31]

CSR_API ( BaseSrvNlsUpdateCacheCount  )

Definition at line 329 of file nls.c.

330 {
331  DPRINT1("%s not yet implemented\n", __FUNCTION__);
332  return STATUS_NOT_IMPLEMENTED;
333 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [31/31]

CSR_API ( BaseSrvNlsGetUserInfo  )

Definition at line 335 of file nls.c.

336 {
338  PBASE_NLS_GET_USER_INFO NlsMsg = &((PBASE_API_MESSAGE)ApiMessage)->Data.NlsGetUserInfo;
339 
340  /* Make sure the buffer is valid and of the right size */
341  if ((CsrValidateMessageBuffer(ApiMessage, &NlsMsg->NlsUserInfo, NlsMsg->Size, sizeof(BYTE))) &&
342  (NlsMsg->Size == sizeof(NLS_USER_INFO)))
343  {
344  /* Acquire the lock to prevent updates while we copy */
346  if (NT_SUCCESS(Status))
347  {
348  /* Do the copy now, then drop the lock */
349  RtlCopyMemory(NlsMsg->NlsUserInfo, pNlsRegUserInfo, NlsMsg->Size);
350  DPRINT1("NLS Data copy complete\n");
352  }
353  }
354  else
355  {
356  /* The data was invalid, bail out */
357  DPRINT1("NLS: Size of info is invalid: %lx vs %lx\n", NlsMsg->Size, sizeof(NLS_USER_INFO));
359  }
360 
361  /* All done */
362  return Status;
363 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
RTL_CRITICAL_SECTION NlsCacheCriticalSection
Definition: nls.c:20
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PNLS_USER_INFO pNlsRegUserInfo
Definition: nls.c:21
unsigned char BYTE
Definition: xxhash.c:193
#define DPRINT1
Definition: precomp.h:8
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263