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

87 lines
1.9 KiB

  1. /*****************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1988-1991 **/
  4. /*****************************************************************/
  5. #include <stdio.h>
  6. #include <process.h>
  7. #include <setjmp.h>
  8. #include <time.h>
  9. #include <nt.h>
  10. #include <ntrtl.h>
  11. #include <nturtl.h>
  12. #include <windows.h>
  13. struct {
  14. ULONG Flags;
  15. PUCHAR String;
  16. } EsFlags[] = {
  17. ES_CONTINUOUS, "Continuous",
  18. ES_SYSTEM_REQUIRED, "System",
  19. ES_DISPLAY_REQUIRED, "Display",
  20. 0, NULL
  21. } ;
  22. PUCHAR
  23. EsState (
  24. IN EXECUTION_STATE State
  25. )
  26. {
  27. static UCHAR text[200];
  28. ULONG i;
  29. PUCHAR p;
  30. UCHAR c;
  31. p = text;
  32. c = '(';
  33. for (i=0; EsFlags[i].Flags; i++) {
  34. if (State & EsFlags[i].Flags) {
  35. p += sprintf (p, "%c%s", c, EsFlags[i].String);
  36. c = '|';
  37. }
  38. }
  39. p += sprintf (p, ")");
  40. return text;
  41. }
  42. VOID __cdecl
  43. main (argc, argv)
  44. int argc;
  45. char *argv[];
  46. {
  47. UCHAR s[200];
  48. EXECUTION_STATE State, PriorState;
  49. NTSTATUS Status;
  50. for (; ;) {
  51. printf ("con sys disp: ");
  52. gets (s);
  53. State = 0;
  54. if (strstr(s, "con")) State |= ES_CONTINUOUS;
  55. if (strstr(s, "disp")) State |= ES_DISPLAY_REQUIRED;
  56. if (strstr(s, "sys")) State |= ES_SYSTEM_REQUIRED;
  57. Status = NtSetThreadExecutionState (
  58. State,
  59. &PriorState
  60. );
  61. if (NT_SUCCESS(Status)) {
  62. printf ("PriorState:%x, Set:%x\n", PriorState, State);
  63. //printf ("PriorState%s, ", EsState(PriorState));
  64. //printf ("Set%s\n", EsState(State));
  65. } else {
  66. printf ("Failed: %x\n", Status);
  67. }
  68. }
  69. }