ReactOS  0.4.13-dev-259-g5ca9c9c
util.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Drivers
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: drivers/sac/driver/util.c
5  * PURPOSE: Driver for the Server Administration Console (SAC) for EMS
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "sacdrv.h"
12 
13 #include <ndk/rtlfuncs.h>
14 
15 /* GLOBALS ********************************************************************/
16 
19 
21 
30 
33 
36 
37 /* FUNCTIONS ******************************************************************/
38 
39 BOOLEAN
40 NTAPI
42  IN PCHAR Utf8Buffer,
43  OUT PWCHAR Utf8Value)
44 {
45  ULONG i;
46 
47  /* Find out how many valid characters we have in the buffer */
48  i = 0;
49  while (Utf8Buffer[i++] && (i < 3));
50 
51  /* If we have at least 3, shift everything by a byte */
52  if (i >= 3)
53  {
54  /* The last input character goes at the end */
55  Utf8Buffer[0] = Utf8Buffer[1];
56  Utf8Buffer[1] = Utf8Buffer[2];
57  Utf8Buffer[2] = Utf8Char;
58  }
59  else
60  {
61  /* We don't have more than 3 characters, place the input at the index */
62  Utf8Buffer[i] = Utf8Char;
63  }
64 
65  /* Print to debugger */
66  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SacTranslateUtf8ToUnicode - About to decode the UTF8 buffer.\n");
67  SAC_DBG(SAC_DBG_ENTRY_EXIT, " UTF8[0]: 0x%02lx UTF8[1]: 0x%02lx UTF8[2]: 0x%02lx\n",
68  Utf8Buffer[0],
69  Utf8Buffer[1],
70  Utf8Buffer[2]);
71 
72  /* Is this a simple ANSI character? */
73  if (!(Utf8Char & 0x80))
74  {
75  /* Return it as Unicode, nothing left to do */
76  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SACDRV: SacTranslateUTf8ToUnicode - Case1\n");
77  *Utf8Value = (WCHAR)Utf8Char;
78  Utf8Buffer[0] = Utf8Buffer[1];
79  Utf8Buffer[1] = Utf8Buffer[2];
80  Utf8Buffer[2] = UNICODE_NULL;
81  return TRUE;
82  }
83 
84  /* Anything else is not yet supported */
85  ASSERT(FALSE);
86  return FALSE;
87 }
88 
89 BOOLEAN
90 NTAPI
92  IN ULONG SourceBufferLength,
93  OUT PCHAR DestinationBuffer,
95  OUT PULONG UTF8Count,
96  OUT PULONG ProcessedCount)
97 {
98  *UTF8Count = 0;
99  *ProcessedCount = 0;
100 
101  while ((*SourceBuffer) &&
102  (*UTF8Count < DestinationBufferSize) &&
103  (*ProcessedCount < SourceBufferLength))
104  {
105  if (*SourceBuffer & 0xFF80)
106  {
107  if (*SourceBuffer & 0xF800)
108  {
109  if ((*UTF8Count + 3) >= DestinationBufferSize) break;
110  DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 12) & 0xF) | 0xE0;
111  ++*UTF8Count;
112  DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 6) & 0x3F) | 0x80;
113  }
114  else
115  {
116  if ((*UTF8Count + 2) >= DestinationBufferSize) break;
117  DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 6) & 31) | 0xC0;
118  }
119  ++*UTF8Count;
120  DestinationBuffer[*UTF8Count] = (*SourceBuffer & 0x3F) | 0x80;
121  }
122  else
123  {
124  DestinationBuffer[*UTF8Count] = (*SourceBuffer & 0x7F);
125  }
126 
127  ++*UTF8Count;
128  ++*ProcessedCount;
129  ++SourceBuffer;
130  }
131 
132  ASSERT(*ProcessedCount <= SourceBufferLength);
133  ASSERT(*UTF8Count <= DestinationBufferSize);
134  return TRUE;
135 }
136 
137 PWCHAR
138 NTAPI
139 GetMessage(IN ULONG MessageIndex)
140 {
141  PSAC_MESSAGE_ENTRY MessageEntry;
142  ULONG i;
143  PWCHAR MessageData = NULL;
144 
145  /* Loop all cached messages */
146  for (i = 0; i < GlobalMessageTableCount; i++)
147  {
148  /* Check if this one matches the index */
149  MessageEntry = &GlobalMessageTable[i];
150  if (MessageEntry->Index == MessageIndex)
151  {
152  /* It does, return the buffer */
153  MessageData = MessageEntry->Buffer;
154  break;
155  }
156  }
157 
158  /* We should always find it */
159  if (!MessageData) ASSERT(FALSE);
160  return MessageData;
161 }
162 
163 NTSTATUS
164 NTAPI
166 {
167  ULONG ProcessedCount, Utf8Count, i;
169 
170  /* Call the translator routine */
172  wcslen(String),
175  &Utf8Count,
176  &ProcessedCount))
177  {
178  /* Loop every character */
179  for (i = 0; i < Utf8Count; i++)
180  {
181  /* Send it to the terminal */
184  sizeof(Utf8ConversionBuffer[i]),
185  NULL,
186  NULL);
187  if (!NT_SUCCESS(Status)) break;
188  }
189  }
190  else
191  {
192  /* Conversion failed */
194  }
195 
196  /* All done */
197  return Status;
198 }
199 
200 VOID
201 NTAPI
202 SacFormatMessage(IN PWCHAR FormattedString,
203  IN PWCHAR MessageString,
204  IN ULONG MessageSize)
205 {
206  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SacFormatMessage: Entering.\n");
207 
208  /* Check if any of the parameters are NULL or zero */
209  if (!(MessageString) || !(FormattedString) || !(MessageSize))
210  {
211  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SacFormatMessage: Exiting with invalid parameters.\n");
212  return;
213  }
214 
215  /* Keep going as long as there's still characters */
216  while ((MessageString[0]) && (MessageSize))
217  {
218  /* Is it a non-formatting character? */
219  if (MessageString[0] != L'%')
220  {
221  /* Just write it back into the buffer and keep going */
222  *FormattedString++ = MessageString[0];
223  MessageString++;
224  }
225  else
226  {
227  /* Go over the format characters we recognize */
228  switch (MessageString[1])
229  {
230  case L'0':
231  *FormattedString = UNICODE_NULL;
232  return;
233 
234  case L'%':
235  *FormattedString++ = L'%';
236  break;
237 
238  case L'\\':
239  *FormattedString++ = L'\r';
240  *FormattedString++ = L'\n';
241  break;
242 
243  case L'r':
244  *FormattedString++ = L'\r';
245  break;
246 
247  case L'b':
248  *FormattedString++ = L' ';
249  break;
250 
251  case L'.':
252  *FormattedString++ = L'.';
253  break;
254 
255  case L'!':
256  *FormattedString++ = L'!';
257  break;
258 
259  default:
260  /* Only move forward one character */
261  MessageString--;
262  break;
263  }
264 
265  /* Move forward two characters */
266  MessageString += 2;
267  }
268 
269  /* Move to the next character*/
270  MessageSize--;
271  }
272 
273  /* All done */
274  *FormattedString = UNICODE_NULL;
275  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SacFormatMessage: Exiting.\n");
276 }
277 
278 NTSTATUS
279 NTAPI
281 {
282  NTSTATUS Status, Status2;
283  ULONG MessageId, TotalLength, TextSize, i;
285  PMESSAGE_RESOURCE_ENTRY MessageEntry;
286  PAGED_CODE();
287  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC PreloadGlobalMessageTable: Entering.\n");
288 
289  /* Nothing to do if we already have a table */
291  if (GlobalMessageTable) goto Exit;
292 
293  /* Loop through up to 200 messages */
294  TotalLength = 0;
295  for (MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
296  {
297  /* Find this message ID in the string table*/
298  Status2 = RtlFindMessage(ImageBase,
299  11,
300  LANG_NEUTRAL,
301  MessageId,
302  &MessageEntry);
303  if (NT_SUCCESS(Status2))
304  {
305  /* Make sure it's Unicode */
306  ASSERT(MessageEntry->Flags & MESSAGE_RESOURCE_UNICODE);
307 
308  /* Remove the space taken up by the OS header, and add our own */
309  TotalLength += MessageEntry->Length -
311  sizeof(SAC_MESSAGE_ENTRY);
312 
313  /* One more in the table */
315  }
316  }
317 
318  /* We should've found at least one message... */
319  if (!TotalLength)
320  {
321  /* Bail out otherwise */
322  SAC_DBG(SAC_DBG_INIT, "SAC PreloadGlobalMessageTable: No Messages.\n");
324  goto Exit;
325  }
326 
327  /* Allocate space for the buffers and headers */
329  if (!GlobalMessageTable)
330  {
331  /* Bail out if we couldn't allocate it */
333  goto Exit;
334  }
335 
336  /* All the buffers are going to be at the end of the table */
338 
339  /* Now loop over our entries again */
340  for (i = 0, MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
341  {
342  /* Make sure the message is still there...! */
343  Status2 = RtlFindMessage(ImageBase,
344  11,
345  LANG_NEUTRAL,
346  MessageId,
347  &MessageEntry);
348  if (NT_SUCCESS(Status2))
349  {
350  /* Write the entry in the message table*/
351  GlobalMessageTable[i].Index = MessageId;
353 
354  /* The structure includes the size of the header, elide it */
355  TextSize = MessageEntry->Length -
357 
358  /* Format the message into the entry. It should be same or smaller */
359  SacFormatMessage(StringBuffer, (PWCHAR)MessageEntry->Text, TextSize);
360  ASSERT((ULONG)(wcslen(StringBuffer)*sizeof(WCHAR)) <= TextSize);
361 
362  /* Move to the next buffer space */
363  StringBuffer += (TextSize / sizeof(WCHAR));
364 
365  /* Move to the next entry, make sure the status is full success */
366  i++;
368  }
369  }
370 
371 Exit:
372  /* All done, return the status code */
373  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC TearDownGlobalMessageTable: Exiting with status 0x%0x\n", Status);
374  return Status;
375 }
376 
377 NTSTATUS
378 NTAPI
380 {
381  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC TearDownGlobalMessageTable: Entering.\n");
382 
383  /* Free the table if one existed */
385 
386  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC TearDownGlobalMessageTable: Exiting\n");
387  return STATUS_SUCCESS;
388 }
389 
390 NTSTATUS
391 NTAPI
395 {
399  HANDLE Handle;
400  ULONG ResultLength = 0;
401  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: Entering.\n");
404 
405  /* Open the specified key */
410  NULL,
411  NULL);
412  Status = ZwOpenKey(&Handle,
415  if (!NT_SUCCESS(Status))
416  {
417  /* Bail out on failure */
418  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed ZwOpenKey: %X.\n", Status);
419  return Status;
420  }
421 
422  /* Query the size of the key */
424  Status = ZwQueryValueKey(Handle,
427  NULL,
428  0,
429  &ResultLength);
430  if (!ResultLength) return Status;
431 
432  /* Allocate the buffer for the partial info structure and our integer data */
433  ResultLength += sizeof(ULONG);
435  if (!*Buffer)
436  {
437  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed allocation\n");
438  return Status;
439  }
440 
441  /* Now read the data */
442  Status = ZwQueryValueKey(Handle,
445  *Buffer,
446  ResultLength,
447  &ResultLength);
448  if (!NT_SUCCESS(Status))
449  {
450  /* Free the buffer if we couldn't read the data */
451  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed ZwQueryValueKey: %X.\n", Status);
453  }
454 
455  /* Return the result */
456  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Exiting.\n");
457  return Status;
458 }
459 
460 NTSTATUS
461 NTAPI
464  IN ULONG Type,
465  IN PVOID Data,
466  IN ULONG DataSize)
467 {
471  HANDLE Handle;
472  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Entering.\n");
476 
477  /* Open the specified key */
482  NULL,
483  NULL);
484  Status = ZwOpenKey(&Handle,
487  if (!NT_SUCCESS(Status))
488  {
489  /* Bail out on failure */
490  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: failed ZwOpenKey: %X.\n", Status);
491  return Status;
492  }
493 
494  /* Set the specified value */
496  Status = ZwSetValueKey(Handle, &DestinationString, 0, Type, Data, DataSize);
497  if (!NT_SUCCESS(Status))
498  {
499  /* Print error on failure */
500  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: failed ZwSetValueKey: %X.\n", Status);
501  }
502 
503  /* Close the handle and exit */
504  NtClose(Handle);
505  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Exiting.\n");
506  return Status;
507 }
508 
509 NTSTATUS
510 NTAPI
513 {
516  CHECK_PARAMETER2(PartialInfo);
517 
518  /* Allocate space for registry data */
519  *Buffer = SacAllocatePool(PartialInfo->DataLength, GLOBAL_BLOCK_TAG);
520  if (*Buffer)
521  {
522  /* Copy the data into the buffer */
523  RtlCopyMemory(*Buffer, PartialInfo->Data, PartialInfo->DataLength);
524  }
525  else
526  {
527  /* Set the correct error code */
528  SAC_DBG(SAC_DBG_UTIL, "SAC CopyRegistryValueBuffer: Failed ALLOCATE.\n");
530  }
531 
532  /* Return the result */
533  return Status;
534 }
535 
536 NTSTATUS
537 NTAPI
539  IN PWCHAR ExtraData)
540 {
542  SIZE_T Size;
543  PWCHAR p;
545 
546  /* Start by believing the world is beautiful */
548 
549  /* First, the header */
550  Size = wcslen(L"<machine-info>\r\n");
551 
552  /* Do we have a machine name? */
554  {
555  /* Go and add it in */
557  Size += wcslen(L"<name>%s</name>\r\n");
558  }
559 
560  /* Do we have a GUID? */
562  {
563  /* Go and add it in */
565  Size += wcslen(L"<guid>%s</guid>\r\n");
566  }
567 
568  /* Do we know the processor? */
570  {
571  /* Go and add it in */
573  Size += wcslen(L"<processor-architecture>%s</processor-architecture>\r\n");
574  }
575 
576  /* Do we have the version? */
578  {
579  /* Go and add it in */
581  Size += wcslen(L"<os-version>%s</os-version>\r\n");
582  }
583 
584  /* Do we have the build? */
586  {
587  /* Go and add it in */
589  Size += wcslen(L"<os-build-number>%s</os-build-number>\r\n");
590  }
591 
592  /* Do we have the product type? */
594  {
595  /* Go and add it in */
597  Size += wcslen(L"<os-product>%s</os-product>\r\n");
598  }
599 
600  /* Do we have a service pack? */
602  {
603  /* Go and add it in */
605  Size += wcslen(L"<os-service-pack>%s</os-service-pack>\r\n");
606  }
607 
608  /* Anything else we need to know? Add it in too */
609  if (ExtraData) Size += wcslen(ExtraData);
610 
611  /* Finally, add the footer */
612  Size += wcslen(L"</machine-info>\r\n");
613 
614  /* Convert to bytes and add a NULL */
615  Size += sizeof(ANSI_NULL);
616  Size *= sizeof(WCHAR);
617 
618  /* Allocate space for the buffer */
620  *Buffer = p;
621  if (!p) return STATUS_NO_MEMORY;
622 
623  wcscpy(p, L"<machine-info>\r\n");
624  p += wcslen(L"<machine-info>\r\n");
625 
627  {
628  p += swprintf(p,
629  L"<name>%s</name>\r\n",
631  }
632 
634  {
635  p += swprintf(p,
636  L"<guid>%s</guid>\r\n",
638  }
639 
641  {
642  p += swprintf(p,
643  L"<processor-architecture>%s</processor-architecture>\r\n",
645  }
646 
648  {
649  p += swprintf(p,
650  L"<os-version>%s</os-version>\r\n",
652  }
653 
655  {
656  p += swprintf(p,
657  L"<os-build-number>%s</os-build-number>\r\n",
659  }
660 
662  {
663  p += swprintf(p,
664  L"<os-product>%s</os-product>\r\n",
666  }
667 
669  {
670  p += swprintf(p,
671  L"<os-service-pack>%s</os-service-pack>\r\n",
673  }
674 
675  if (ExtraData)
676  {
677  wcscpy(p, ExtraData);
678  p += wcslen(ExtraData);
679  }
680 
681  wcscpy(p, L"</machine-info>\r\n");
682  SAC_DBG(SAC_DBG_ENTRY_EXIT, "MachineInformation: %S\n", *Buffer);
683  ASSERT((((ULONG)wcslen(*Buffer) + 1) * sizeof(WCHAR)) <= Size);
684  return Status;
685 }
686 
687 VOID
688 NTAPI
690 {
692  PWCHAR GuidString, MajorVersion, ServicePack, BuildNumber, MessageBuffer;
693  PWCHAR ProductType;
694  ULONG SuiteTypeMessage;
695  BOOLEAN SetupInProgress = FALSE;
696  GUID SystemGuid;
697  SIZE_T RealSize, Size, OutputSize;
698  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo;
699  RTL_OSVERSIONINFOEXW VersionInformation;
700  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Entering.\n");
701 
702  /* Don't do anything if we already queried this */
703  if (MachineInformation)
704  {
705  SAC_DBG(SAC_DBG_MACHINE, "SAC Initialize Machine Information:: MachineInformationBuffer already initialized.\n");
706  return;
707  }
708 
709  /* Allocate the machine information */
712  if (!MachineInformation)
713  {
714  goto Fail;
715  }
716 
717  /* Zero it out for now */
719 
720  /* Query OS version */
721  RtlZeroMemory(&VersionInformation, sizeof(VersionInformation));
722  VersionInformation.dwOSVersionInfoSize = sizeof(VersionInformation);
723  Status = RtlGetVersion((PRTL_OSVERSIONINFOW)&VersionInformation);
724  if (!NT_SUCCESS(Status))
725  {
726  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (2).\n");
727  goto Fail;
728  }
729 
730  /* Check if setup is in progress */
731  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\Setup",
732  L"SystemSetupInProgress",
733  &PartialInfo);
734  if (NT_SUCCESS(Status))
735  {
736  /* The key is there, is the value set? */
737  if (*(PULONG)PartialInfo->Data) SetupInProgress = TRUE;
738  SacFreePool(PartialInfo);
739  if (SetupInProgress)
740  {
741  /* Yes, so we'll use a special hostname to identify this */
742  MessageBuffer = GetMessage(SAC_UNINITIALIZED_MSG);
743  Size = wcslen(MessageBuffer);
744  ASSERT(Size > 0);
745  RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
746 
747  /* Make room for it and copy it in there */
751  {
752  wcscpy(MachineInformation->MachineName, MessageBuffer);
753  }
754  }
755  }
756 
757  /* If we are not in setup mode, or if we failed to check... */
758  if (!SetupInProgress)
759  {
760  /* Query the computer name */
761  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\"
762  L"CurrentControlSet\\Control\\"
763  L"ComputerName\\ComputerName",
764  L"ComputerName",
765  &PartialInfo);
766  if (!NT_SUCCESS(Status))
767  {
768  /* It's not critical, but we won't have it */
769  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Failed to get machine name.\n");
770  }
771  else
772  {
773  /* We have the name, copy it from the registry */
775  MachineName,
776  PartialInfo);
777  SacFreePool(PartialInfo);
778  if (!NT_SUCCESS(Status))
779  {
780  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (20).\n");
781  goto Fail;
782  }
783  }
784  }
785 
786  /* Next step, try to get the machine GUID */
787  RtlZeroMemory(&SystemGuid, sizeof(SystemGuid));
788  OutputSize = sizeof(SystemGuid);
790  NULL,
791  0,
792  &SystemGuid,
793  &OutputSize);
794  if (!NT_SUCCESS(Status))
795  {
796  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Failed to get Machine GUID.\n");
797  }
798  else
799  {
800  /* We have it -- make room for it */
802  if (!GuidString)
803  {
804  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (31).\n");
805  goto Fail;
806  }
807 
808  /* Build the string with the GUID in it, and save the ppointer to it */
810  L"%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
811  SystemGuid.Data1,
812  SystemGuid.Data2,
813  SystemGuid.Data3,
814  SystemGuid.Data4[0],
815  SystemGuid.Data4[1],
816  SystemGuid.Data4[2],
817  SystemGuid.Data4[3],
818  SystemGuid.Data4[4],
819  SystemGuid.Data4[5],
820  SystemGuid.Data4[6],
821  SystemGuid.Data4[7]);
823  }
824 
825  /* Next, query the processor architecture */
826  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\"
827  L"CurrentControlSet\\Control\\"
828  L"Session Manager\\Environment",
829  L"PROCESSOR_ARCHITECTURE",
830  &PartialInfo);
831  if (!NT_SUCCESS(Status))
832  {
833  /* It's not critical, but we won't have it */
834  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (30).\n");
835  }
836  else
837  {
838  /* We have it! Copy the value from the registry */
840  ProcessorArchitecture,
841  PartialInfo);
842  SacFreePool(PartialInfo);
843  if (!NT_SUCCESS(Status))
844  {
845  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (30).\n");
846  goto Fail;
847  }
848  }
849 
850  /* Now allocate a buffer for the OS version number */
852  if (!MajorVersion)
853  {
854  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (50).\n");
855  goto Fail;
856  }
857 
858  /* Build the buffer and set a pointer to it */
860  L"%d.%d",
861  VersionInformation.dwMajorVersion,
862  VersionInformation.dwMinorVersion);
864 
865  /* Now allocate a buffer for the OS build number */
867  if (!BuildNumber)
868  {
869  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (60).\n");
870  goto Fail;
871  }
872 
873  /* Build the buffer and set a pointer to it */
874  swprintf(BuildNumber, L"%d", VersionInformation.dwBuildNumber);
876 
877  /* Now check what kind of SKU this is */
879  {
880  SuiteTypeMessage = SAC_DATACENTER_SUITE_MSG;
881  }
882  else if (ExVerifySuite(EmbeddedNT))
883  {
884  SuiteTypeMessage = SAC_EMBEDDED_SUITE_MSG;
885  }
886  else if (ExVerifySuite(Enterprise))
887  {
888  SuiteTypeMessage = SAC_ENTERPRISE_SUITE_MSG;
889  }
890  else
891  {
892  /* Unknown or perhaps a client SKU */
893  SuiteTypeMessage = SAC_NO_SUITE_MSG;
894  }
895 
896  /* Get the string that corresponds to the SKU type */
897  MessageBuffer = GetMessage(SuiteTypeMessage);
898  if (!MessageBuffer)
899  {
900  /* We won't have it, but this isn't critical */
901  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed to get product type.\n");
902  }
903  else
904  {
905  /* Calculate the size we need to hold the string */
906  Size = wcslen(MessageBuffer);
907  ASSERT(Size > 0);
908  RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
909 
910  /* Allocate a buffer for it */
911  ProductType = SacAllocatePool(RealSize, GLOBAL_BLOCK_TAG);
912  if (!ProductType)
913  {
914  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed product type memory allocation.\n");
915  goto Fail;
916  }
917 
918  /* Copy the string and set the pointer */
919  RtlCopyMemory(ProductType, MessageBuffer, RealSize);
920  MachineInformation->ProductType = ProductType;
921  }
922 
923  /* Check if this is a SP version or RTM version */
924  if (VersionInformation.wServicePackMajor)
925  {
926  /* This is a service pack, allocate a buffer for the version */
927  ServicePack = SacAllocatePool(0x18, GLOBAL_BLOCK_TAG);
928  if (ServicePack)
929  {
930  /* Build the buffer and set a pointer to it */
931  swprintf(ServicePack,
932  L"%d.%d",
933  VersionInformation.wServicePackMajor,
934  VersionInformation.wServicePackMinor);
935  MachineInformation->ServicePack = ServicePack;
936 
937  /* We've collected all the machine info and are done! */
938  return;
939  }
940 
941  /* This is the failure path */
942  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed service pack memory allocation.\n");
943  }
944  else
945  {
946  /* Get a generic string that indicates there's no service pack */
947  MessageBuffer = GetMessage(SAC_NO_DATA_MSG);
948  Size = wcslen(MessageBuffer);
949  ASSERT(Size > 0);
950  RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
951 
952  /* Allocate memory for the "no service pack" string */
953  ServicePack = SacAllocatePool(RealSize, GLOBAL_BLOCK_TAG);
954  if (ServicePack)
955  {
956  /* Copy the buffer and set a pointer to it */
957  RtlCopyMemory(ServicePack, MessageBuffer, RealSize);
958  MachineInformation->ServicePack = ServicePack;
959 
960  /* We've collected all the machine info and are done! */
961  return;
962  }
963 
964  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed service pack memory allocation.\n");
965  }
966 
967 Fail:
968  /* In the failure path, always cleanup the machine information buffer */
969  if (MachineInformation)
970  {
972  }
973  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Exiting with error.\n");
974 }
975 
976 NTSTATUS
977 NTAPI
979 {
982 
983  /* Assume success and read the key */
984  *Permission = TRUE;
985  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacdrv",
986  L"DisableCmdSessions",
987  &Dummy);
989  {
990  /* The default is success */
992  }
993  else
994  {
995  /* Only if the key is present and set, do we disable permission */
996  if (NT_SUCCESS(Status)) *Permission = FALSE;
997  }
998 
999  /* Return status */
1000  return Status;
1001 }
1002 
1003 NTSTATUS
1004 NTAPI
1006 {
1007  NTSTATUS Status;
1009  PULONG Data;
1010 
1011  /* Read the service start type*/
1012  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacsvr",
1013  L"Start",
1014  &Buffer);
1015  if (!NT_SUCCESS(Status)) return Status;
1016 
1017  /* If there's no start type, fail, as this is unusual */
1018  if (!Buffer) return STATUS_UNSUCCESSFUL;
1019 
1020  /* Read the value */
1023  if (!NT_SUCCESS(Status)) return Status;
1024 
1025  /* Check what the current start type is */
1026  switch (*Data)
1027  {
1028  /* It's boot, system, or disabled */
1029  case 1:
1030  case 2:
1031  case 4:
1032  /* Leave it as is */
1033  return Status;
1034 
1035  case 3:
1036 
1037  /* It's set to automatic, set it to system instead */
1038  *Data = 2;
1039  Status = SetRegistryValue(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacsvr",
1040  L"Start",
1041  REG_DWORD,
1042  Data,
1043  sizeof(ULONG));
1044  if (!NT_SUCCESS(Status))
1045  {
1046  SAC_DBG(SAC_DBG_INIT, "SAC ImposeSacCmdServiceStartTypePolicy: Failed SetRegistryValue: %X\n", Status);
1047  }
1048  break;
1049 
1050  default:
1051  ASSERT(FALSE);
1052  }
1053 
1054  return Status;
1055 }
1056 
1057 VOID
1058 NTAPI
1060 {
1061  /* Check if we were already initialized */
1063  {
1064  /* Full state expected */
1068 
1069  /* Dereference each wait object in turn */
1071  {
1073  }
1074 
1076  {
1078  }
1079 
1081  {
1083  }
1084  }
1085 
1086  /* Claer everything */
1094 
1095  /* Reset state */
1097 }
1098 
1099 NTSTATUS
1100 NTAPI
1102 {
1103  PWCHAR XmlBuffer;
1105  SIZE_T Length, HeaderLength, TotalLength;
1106  NTSTATUS Status;
1107  ULONG i;
1108 
1109  /* Create the XML buffer and make sure it's OK */
1113 
1114  /* Compute the sizes and allocate a buffer for it */
1115  Length = wcslen(XmlBuffer);
1116  HeaderLength = strlen("MACHINEINFO");
1117  TotalLength = HeaderLength +
1118  Length +
1119  sizeof(*BsBuffer) +
1120  2 * sizeof(ANSI_NULL);
1123 
1124  /* Copy the XML property name */
1125  strcpy((PCHAR)BsBuffer->Data, "MACHINEINFO");
1126  BsBuffer->ValueIndex = HeaderLength + sizeof(ANSI_NULL);
1127 
1128  /* Copy the data and NULL-terminate it */
1129  for (i = 0; i < Length; i++)
1130  {
1131  BsBuffer->Data[BsBuffer->ValueIndex + i] = XmlBuffer[i];
1132  }
1133  BsBuffer->Data[BsBuffer->ValueIndex + i] = ANSI_NULL;
1134 
1135  /* Let the OS save the buffer for later */
1137  BsBuffer,
1138  TotalLength,
1139  NULL,
1140  NULL);
1141 
1142  /* Failure or not, we don't need this anymore */
1143  SacFreePool(BsBuffer);
1144  SacFreePool(XmlBuffer);
1145 
1146  /* Return the result */
1147  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information: Exiting.\n");
1148  return Status;
1149 }
1150 
1151 VOID
1152 NTAPI
1154 {
1156 
1157  /* Free every cached string of machine information */
1165 }
1166 
1167 BOOLEAN
1168 NTAPI
1170  OUT PVOID *WaitObject,
1171  OUT PVOID *ActualWaitObject)
1172 {
1173  PVOID Object;
1174  NTSTATUS Status;
1176 
1177  /* Reference the object */
1180  NULL,
1181  KernelMode,
1182  &Object,
1183  NULL);
1184  *WaitObject = Object;
1185  if (!NT_SUCCESS(Status))
1186  {
1187  SAC_DBG(SAC_DBG_INIT, "SAC VerifyEventWaitable: Unable to reference event object (%lx)\n", Status);
1188  return FALSE;
1189  }
1190 
1191  /* Check if the object itself is NOT being used */
1193  if (ObjectType->TypeInfo.UseDefaultObject == FALSE)
1194  {
1195  /* Get the actual object that's being used for the wait */
1196  *ActualWaitObject = (PVOID)((ULONG_PTR)Object +
1197  (ULONG_PTR)ObjectType->DefaultObject);
1198  return TRUE;
1199  }
1200 
1201  /* Drop the reference we took */
1202  SAC_DBG(SAC_DBG_INIT, "SAC VerifyEventWaitable: event object not waitable!\n");
1203  ObDereferenceObject(*WaitObject);
1204  return FALSE;
1205 }
1206 
1207 NTSTATUS
1208 NTAPI
1210 {
1211  /* Check if nothing's been produced yet */
1213  {
1214  return STATUS_NO_DATA_DETECTED;
1215  }
1216 
1217  /* Consume the produced character and clear it*/
1220 
1221  /* Advance the index and return success */
1223  (SerialPortConsumerIndex + 1) &
1225  return STATUS_SUCCESS;
1226 }
1227 
1228 ULONG
1229 NTAPI
1231 {
1232  ULONG LineCount = 0;
1233  PWCHAR Buffer;
1234 
1235  /* Get the message buffer */
1236  Buffer = GetMessage(MessageIndex);
1237  if (Buffer)
1238  {
1239  /* Scan it looking for new lines, and increment the count each time */
1240  while (*Buffer) if (*Buffer++ == L'\n') ++LineCount;
1241  }
1242 
1243  /* Return the line count */
1244  return LineCount;
1245 }
1246 
1247 ULONG
1249  IN PWCHAR pwch,
1250  IN PCHAR pch,
1251  IN ULONG length
1252  )
1253 {
1254  return STATUS_NOT_IMPLEMENTED;
1255 }
1256 
1257 BOOLEAN
1260  )
1261 {
1262  return FALSE;
1263 }
1264 
1265 NTSTATUS
1267  VOID
1268  )
1269 {
1270  return STATUS_NOT_IMPLEMENTED;
1271 }
1272 
1273 NTSTATUS
1275  IN PWCHAR Buffer)
1276 {
1277  return STATUS_NOT_IMPLEMENTED;
1278 }
1279 
1280 NTSTATUS
1282  IN PWCHAR SourceStr,
1283  IN ULONG Interval,
1284  IN PWCHAR InsertStr,
1285  OUT PWCHAR pDestStr
1286  )
1287 {
1288  return STATUS_NOT_IMPLEMENTED;
1289 }
1290 
1291 NTSTATUS
1293  IN PVOID Object,
1294  IN PKEVENT SetupCmdEvent[]
1295  )
1296 {
1297  return STATUS_NOT_IMPLEMENTED;
1298 }
1299 
1300 NTSTATUS
1303  )
1304 {
1305  return STATUS_NOT_IMPLEMENTED;
1306 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
struct _SAC_MESSAGE_ENTRY SAC_MESSAGE_ENTRY
signed char * PCHAR
Definition: retypes.h:7
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
PKEVENT RequestSacCmdFailureEventWaitObjectBody
Definition: util.c:27
ObjectType
Definition: metafile.c:80
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define MESSAGE_RESOURCE_UNICODE
Definition: rtltypes.h:354
static PWSTR GuidString
Definition: apphelp.c:91
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
PVOID RequestSacCmdSuccessEventObjectBody
Definition: util.c:24
Definition: rtltypes.h:1827
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG MajorVersion
Definition: ros_glue.cpp:4
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
NTSTATUS NTAPI TranslateMachineInformationXML(IN PWCHAR *Buffer, IN PWCHAR ExtraData)
Definition: util.c:538
Type
Definition: Type.h:6
NTSTATUS UnregisterSacCmdEvent(IN PFILE_OBJECT FileObject)
Definition: util.c:1301
Definition: sacdrv.h:204
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
NTSTATUS NTAPI UTF8EncodeAndSend(IN PWCHAR String)
Definition: util.c:165
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define KEY_READ
Definition: nt_native.h:1023
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define LANG_NEUTRAL
Definition: nls.h:22
PWCHAR BuildNumber
Definition: sacdrv.h:497
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
char CHAR
Definition: xmlstorage.h:175
ULONG NTAPI GetMessageLineCount(IN ULONG MessageIndex)
Definition: util.c:1230
NTSTATUS TranslateMachineInformationText(IN PWCHAR Buffer)
Definition: util.c:1274
LONG NTSTATUS
Definition: precomp.h:26
PSAC_MESSAGE_ENTRY GlobalMessageTable
Definition: util.c:31
ULONG GlobalMessageTableCount
Definition: util.c:32
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
PWCHAR ServicePack
Definition: sacdrv.h:499
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
static WCHAR String[]
Definition: stringtable.c:55
VOID NTAPI InitializeCmdEventInfo(VOID)
Definition: util.c:1059
PWCHAR Buffer
Definition: sacdrv.h:207
uint16_t * PWCHAR
Definition: typedefs.h:54
_In_ ULONG TotalLength
Definition: usbdlib.h:145
BOOLEAN NTAPI ExVerifySuite(SUITE_TYPE SuiteType)
Definition: sysinfo.c:377
USHORT Flags
Definition: rtltypes.h:1830
#define pch(ap)
Definition: match.c:418
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI HeadlessDispatch(IN HEADLESS_CMD Command, IN PVOID InputBuffer, IN SIZE_T InputBufferSize, OUT PVOID OutputBuffer, OUT PSIZE_T OutputBufferSize)
Definition: hdlsterm.c:570
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
PWCHAR ProcessorArchitecture
Definition: sacdrv.h:495
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define OBJECT_TO_OBJECT_HEADER(o)
Definition: obtypes.h:111
NTSTATUS NTAPI RegisterBlueScreenMachineInformation(VOID)
Definition: util.c:1101
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
PWCHAR MachineName
Definition: sacdrv.h:493
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
static ULONG
Definition: util.c:35
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define UNICODE_NULL
#define ANSI_NULL
long LONG
Definition: pedump.c:60
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
char Char
Definition: bzip2.c:161
unsigned char BOOLEAN
PWCHAR MajorVersion
Definition: sacdrv.h:496
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS RegisterSacCmdEvent(IN PVOID Object, IN PKEVENT SetupCmdEvent[])
Definition: util.c:1292
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
Definition: bufpool.h:45
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
void * PVOID
Definition: retypes.h:9
LONG SerialPortProducerIndex
Definition: util.c:34
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
NTSTATUS InvokeUserModeService(VOID)
Definition: util.c:1266
PCHAR Utf8ConversionBuffer
Definition: util.c:17
DWORD Interval
Definition: netstat.c:30
#define KEY_WRITE
Definition: nt_native.h:1031
_In_ HANDLE Handle
Definition: extypes.h:390
PFILE_OBJECT ServiceProcessFileObject
Definition: util.c:28
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1831
ULONG dwMajorVersion
Definition: rtltypes.h:243
NTSTATUS NTAPI PreloadGlobalMessageTable(IN PVOID ImageBase)
Definition: util.c:280
NTSTATUS NTAPI GetCommandConsoleLaunchingPermission(OUT PBOOLEAN Permission)
Definition: util.c:978
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy(VOID)
Definition: util.c:1005
BOOLEAN HaveUserModeServiceCmdEventInfo
Definition: util.c:29
ULONG Utf8ConversionBufferSize
Definition: util.c:18
NTSTATUS NTAPI SerialBufferGetChar(OUT PCHAR Char)
Definition: util.c:1209
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static void Exit(void)
Definition: sock.c:1331
NTSTATUS NTAPI CopyRegistryValueData(IN PVOID *Buffer, IN PKEY_VALUE_PARTIAL_INFORMATION PartialInfo)
Definition: util.c:511
PSAC_MACHINE_INFO MachineInformation
Definition: util.c:20
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
#define SAC_DBG_MACHINE
Definition: sacdrv.h:36
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PKEVENT RequestSacCmdSuccessEventWaitObjectBody
Definition: util.c:25
LONG SerialPortConsumerIndex
Definition: util.c:34
* PFILE_OBJECT
Definition: iotypes.h:1954
static IUnknown Object
Definition: main.c:512
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PKEVENT RequestSacCmdEventWaitObjectBody
Definition: util.c:23
ULONG dwBuildNumber
Definition: rtltypes.h:245
char * PBOOLEAN
Definition: retypes.h:11
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
NTSTATUS NTAPI GetRegistryValueBuffer(IN PCWSTR KeyName, IN PWCHAR ValueName, IN PKEY_VALUE_PARTIAL_INFORMATION *Buffer)
Definition: util.c:392
PWCHAR NTAPI GetMessage(IN ULONG MessageIndex)
Definition: util.c:139
#define PAGE_SIZE
Definition: env_spec_w32.h:49
USHORT Length
Definition: rtltypes.h:1829
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define SYNCHRONIZE
Definition: nt_native.h:61
PWCHAR MachineGuid
Definition: sacdrv.h:494
Status
Definition: gdiplustypes.h:24
ULONG Index
Definition: sacdrv.h:206
ULONG BuildNumber
Definition: ros_glue.cpp:6
PCHAR SerialPortBuffer
Definition: util.c:35
Definition: hiveinit.c:368
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define CHECK_PARAMETER4(x)
Definition: sacdrv.h:62
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
BOOLEAN IsCmdEventRegistrationProcess(IN PFILE_OBJECT FileObject)
Definition: util.c:1258
_In_ ULONG _In_ ULONG _In_ ULONG DestinationBufferSize
Definition: tdikrnl.h:1006
VOID NTAPI FreeMachineInformation(VOID)
Definition: util.c:1153
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define CHECK_PARAMETER_WITH_STATUS(Condition, Status)
Definition: sacdrv.h:47
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int * PULONG
Definition: retypes.h:1
PVOID RequestSacCmdEventObjectBody
Definition: util.c:22
BOOLEAN NTAPI SacTranslateUtf8ToUnicode(IN CHAR Utf8Char, IN PCHAR Utf8Buffer, OUT PWCHAR Utf8Value)
Definition: util.c:41
ULONG ConvertAnsiToUnicode(IN PWCHAR pwch, IN PCHAR pch, IN ULONG length)
Definition: util.c:1248
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
NTSTATUS NTAPI SetRegistryValue(IN PCWSTR KeyName, IN PWCHAR ValueName, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: util.c:462
#define SAC_SERIAL_PORT_BUFFER_SIZE
Definition: sacdrv.h:154
ULONG dwMinorVersion
Definition: rtltypes.h:244
VOID NTAPI SacFormatMessage(IN PWCHAR FormattedString, IN PWCHAR MessageString, IN ULONG MessageSize)
Definition: util.c:202
PWCHAR ProductType
Definition: sacdrv.h:498
#define OUT
Definition: typedefs.h:39
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
NTSTATUS NTAPI TearDownGlobalMessageTable(VOID)
Definition: util.c:379
NTSTATUS CopyAndInsertStringAtInterval(IN PWCHAR SourceStr, IN ULONG Interval, IN PWCHAR InsertStr, OUT PWCHAR pDestStr)
Definition: util.c:1281
PVOID RequestSacCmdFailureEventObjectBody
Definition: util.c:26
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
BOOLEAN NTAPI VerifyEventWaitable(IN HANDLE Handle, OUT PVOID *WaitObject, OUT PVOID *ActualWaitObject)
Definition: util.c:1169
VOID NTAPI InitializeMachineInformation(VOID)
Definition: util.c:689
#define SAC_DBG_UTIL
Definition: sacdrv.h:33
GLfloat GLfloat p
Definition: glext.h:8902
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define REG_DWORD
Definition: sdbapi.c:596
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
BOOLEAN NTAPI SacTranslateUnicodeToUtf8(IN PWCHAR SourceBuffer, IN ULONG SourceBufferLength, OUT PCHAR DestinationBuffer, IN ULONG DestinationBufferSize, OUT PULONG UTF8Count, OUT PULONG ProcessedCount)
Definition: util.c:91
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
char * Text
Definition: combotst.c:136
#define SAC_MAX_MESSAGES
Definition: sacdrv.h:155