debugpy 1.8.5__zip → 1.8.7__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. {debugpy-1.8.5/src/debugpy.egg-info → debugpy-1.8.7}/PKG-INFO +1 -1
  2. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_calltip_util.py +19 -21
  3. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_completer.py +30 -30
  4. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_execfile.py +3 -1
  5. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_filesystem_encoding.py +43 -0
  6. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_getopt.py +35 -32
  7. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_imports_tipper.py +83 -84
  8. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_jy_imports_tipper.py +92 -99
  9. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_log.py +2 -3
  10. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py +51 -27
  11. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_sys_patch.py +11 -7
  12. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_tipper_common.py +6 -5
  13. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/fsnotify/__init__.py +34 -38
  14. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_console_utils.py +71 -69
  15. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_import_hook.py +1 -3
  16. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_imports.py +0 -1
  17. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_ipython_console.py +14 -16
  18. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_ipython_console_011.py +81 -93
  19. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_is_thread_alive.py +3 -3
  20. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_localhost.py +9 -8
  21. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_log.py +33 -25
  22. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py +183 -170
  23. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey_qt.py +33 -29
  24. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_override.py +6 -4
  25. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_umd.py +19 -18
  26. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_versioncheck.py +3 -3
  27. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles.py +165 -138
  28. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_coverage.py +77 -0
  29. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_nose.py +35 -36
  30. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_parallel.py +22 -23
  31. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_parallel_client.py +37 -57
  32. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py +54 -52
  33. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_unittest.py +28 -37
  34. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_xml_rpc.py +56 -53
  35. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/__main__pydevd_gen_debug_adapter_protocol.py +604 -0
  36. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/debugProtocol.json +551 -445
  37. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/pydevd_base_schema.py +25 -29
  38. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/pydevd_schema.py +17458 -0
  39. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/pydevd_schema_log.py +11 -12
  40. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevconsole_code.py +18 -19
  41. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_additional_thread_info.py +41 -0
  42. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_additional_thread_info_regular.py +328 -0
  43. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_api.py +263 -214
  44. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_breakpoints.py +7 -10
  45. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_bytecode_utils.py +187 -92
  46. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_bytecode_utils_py311.py +105 -0
  47. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_code_to_source.py +46 -51
  48. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_collect_bytecode_info.py +239 -176
  49. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py +370 -297
  50. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm_constants.py +78 -86
  51. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_command_line_handling.py +55 -59
  52. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_concurrency_analyser/pydevd_concurrency_logger.py +194 -58
  53. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_concurrency_analyser/pydevd_thread_wrappers.py +2 -3
  54. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_console.py +18 -23
  55. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py +159 -127
  56. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_custom_frames.py +10 -12
  57. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython.c +55527 -0
  58. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython.pxd +15 -0
  59. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython.pyx +803 -511
  60. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython_wrapper.py +18 -7
  61. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py +32 -24
  62. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_defaults.py +11 -13
  63. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_dont_trace.py +16 -16
  64. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_dont_trace_files.py +27 -2
  65. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_exec2.py +1 -1
  66. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_extension_api.py +4 -5
  67. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_extension_utils.py +8 -10
  68. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_filtering.py +50 -45
  69. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py +462 -407
  70. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame_utils.py +69 -61
  71. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_gevent_integration.py +14 -16
  72. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_import_class.py +27 -25
  73. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_io.py +40 -42
  74. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_json_debug_options.py +200 -0
  75. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py +20 -19
  76. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py +199 -108
  77. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_xml.py +121 -73
  78. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_plugin_utils.py +208 -0
  79. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py +206 -159
  80. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py +346 -334
  81. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_referrers.py +75 -80
  82. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_reload.py +35 -35
  83. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py +116 -124
  84. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py +44 -58
  85. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_safe_repr.py +51 -55
  86. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_save_locals.py +4 -2
  87. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_signature.py +24 -24
  88. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_source_mapping.py +19 -20
  89. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_stackless.py +45 -49
  90. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_suspended_frames.py +61 -58
  91. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_thread_lifecycle.py +23 -13
  92. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_timeout.py +29 -31
  93. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_trace_dispatch.py +41 -11
  94. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_trace_dispatch_regular.py +117 -55
  95. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_traceproperty.py +11 -14
  96. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py +90 -89
  97. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py +106 -97
  98. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vm_type.py +40 -0
  99. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_xml.py +56 -46
  100. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_eval_cython_wrapper.py +5 -5
  101. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_eval_main.py +71 -0
  102. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.c +11165 -5326
  103. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_tracing.py +5 -6
  104. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_modify_bytecode.py +53 -56
  105. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/__init__.py +1 -0
  106. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/bytecode.py +4 -6
  107. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/cfg.py +6 -26
  108. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/concrete.py +7 -21
  109. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/flags.py +5 -24
  110. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/instr.py +10 -34
  111. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/peephole_opt.py +1 -4
  112. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/__init__.py +2 -6
  113. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_bytecode.py +3 -5
  114. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_cfg.py +11 -31
  115. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_code.py +2 -2
  116. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_concrete.py +14 -41
  117. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_flags.py +2 -4
  118. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_instr.py +7 -18
  119. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_misc.py +6 -18
  120. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/test_peephole_opt.py +7 -18
  121. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/bytecode/tests/util_annotation.py +1 -3
  122. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/pydevd_fix_code.py +14 -19
  123. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_sys_monitoring/_pydevd_sys_monitoring.py +1929 -0
  124. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c +43253 -0
  125. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pxd +46 -0
  126. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx +1935 -0
  127. debugpy-1.8.7/src/debugpy/_vendored/pydevd/_pydevd_sys_monitoring/pydevd_sys_monitoring.py +16 -0
  128. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_app_engine_debug_startup.py +12 -11
  129. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_coverage.py +30 -32
  130. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhook.py +58 -54
  131. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookglut.py +20 -24
  132. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookgtk.py +8 -7
  133. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookgtk3.py +8 -6
  134. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookpyglet.py +11 -8
  135. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookqt4.py +21 -18
  136. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookqt5.py +17 -15
  137. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookqt6.py +17 -15
  138. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhooktk.py +6 -4
  139. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/inputhookwx.py +14 -10
  140. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py +30 -26
  141. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydev_ipython/qt.py +24 -0
  142. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/qt_for_kernel.py +37 -34
  143. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/qt_loaders.py +86 -73
  144. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/version.py +7 -7
  145. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydev_pysrc.py +1 -0
  146. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_run_in_console.py +23 -24
  147. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydev_sitecustomize/sitecustomize.py +267 -0
  148. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevconsole.py +55 -47
  149. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd.py +732 -508
  150. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_always_live_program.py +40 -0
  151. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_check.py +1 -0
  152. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_test_attach_to_process.py +11 -0
  153. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_test_attach_to_process_linux.py +75 -0
  154. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py +130 -125
  155. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_amd64.dll +0 -0
  156. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_amd64.pdb +0 -0
  157. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_pydevd.py +89 -0
  158. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_script.py +41 -32
  159. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86.dll +0 -0
  160. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86.pdb +0 -0
  161. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_utils.hpp +1 -0
  162. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_version.hpp +9 -1
  163. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_amd64.exe +0 -0
  164. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_amd64.pdb +0 -0
  165. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_x86.exe +0 -0
  166. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_x86.pdb +0 -0
  167. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py +10 -9
  168. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_amd64.dll +0 -0
  169. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_amd64.pdb +0 -0
  170. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_x86.dll +0 -0
  171. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_x86.pdb +0 -0
  172. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/__init__.py +103 -119
  173. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/breakpoint.py +457 -516
  174. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/compat.py +33 -15
  175. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/crash.py +336 -281
  176. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/debug.py +101 -131
  177. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/disasm.py +148 -153
  178. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/event.py +310 -302
  179. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/interactive.py +235 -208
  180. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/module.py +185 -218
  181. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/process.py +428 -564
  182. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/registry.py +54 -53
  183. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/search.py +69 -73
  184. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/sql.py +158 -170
  185. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/system.py +143 -213
  186. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/textio.py +302 -333
  187. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/thread.py +220 -239
  188. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/util.py +198 -177
  189. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/__init__.py +11 -11
  190. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/advapi32.py +1191 -713
  191. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/context_amd64.py +248 -194
  192. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/context_i386.py +132 -120
  193. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/dbghelp.py +450 -346
  194. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/defines.py +305 -286
  195. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/gdi32.py +526 -0
  196. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/kernel32.py +1479 -1097
  197. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/ntdll.py +579 -0
  198. debugpy-1.8.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/peb_teb.py +3517 -0
  199. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/psapi.py +54 -31
  200. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/shell32.py +170 -149
  201. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/shlwapi.py +190 -108
  202. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/user32.py +542 -437
  203. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/version.py +489 -442
  204. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/wtsapi32.py +83 -65
  205. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/window.py +70 -76
  206. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/attach.cpp +17 -9
  207. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/compile_windows.bat +1 -1
  208. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_file_utils.py +141 -120
  209. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/__init__.py +1 -0
  210. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/django_debug.py +175 -149
  211. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/__init__.py +1 -0
  212. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/__init__.py +1 -0
  213. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/pydevd_helpers.py +5 -5
  214. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/pydevd_plugin_numpy_types.py +28 -28
  215. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/pydevd_plugin_pandas_types.py +22 -30
  216. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/pydevd_plugins_django_form_str.py +3 -2
  217. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/jinja2_debug.py +130 -108
  218. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/pydevd_line_validation.py +27 -14
  219. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_tracing.py +85 -66
  220. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/setup_pydevd_cython.py +96 -59
  221. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_version.py +3 -3
  222. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/messaging.py +2 -1
  223. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/server/cli.py +32 -17
  224. {debugpy-1.8.5 → debugpy-1.8.7/src/debugpy.egg-info}/PKG-INFO +1 -1
  225. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy.egg-info/SOURCES.txt +6 -1
  226. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_filesystem_encoding.py +0 -41
  227. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_coverage.py +0 -76
  228. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/__main__pydevd_gen_debug_adapter_protocol.py +0 -592
  229. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/pydevd_schema.py +0 -19514
  230. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_additional_thread_info.py +0 -19
  231. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_additional_thread_info_regular.py +0 -153
  232. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_cython.c +0 -43377
  233. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_json_debug_options.py +0 -204
  234. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_plugin_utils.py +0 -91
  235. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_trace_api.py +0 -62
  236. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vm_type.py +0 -41
  237. debugpy-1.8.5/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_eval_main.py +0 -48
  238. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydev_ipython/qt.py +0 -23
  239. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydev_pysrc.py +0 -1
  240. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydev_sitecustomize/sitecustomize.py +0 -237
  241. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_always_live_program.py +0 -32
  242. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_test_attach_to_process.py +0 -9
  243. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/_test_attach_to_process_linux.py +0 -74
  244. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_amd64.dll +0 -0
  245. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_amd64.pdb +0 -0
  246. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_pydevd.py +0 -79
  247. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86.dll +0 -0
  248. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_x86.pdb +0 -0
  249. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_amd64.exe +0 -0
  250. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_amd64.pdb +0 -0
  251. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/inject_dll_x86.pdb +0 -0
  252. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_amd64.dll +0 -0
  253. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_amd64.pdb +0 -0
  254. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_x86.dll +0 -0
  255. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/run_code_on_dllmain_x86.pdb +0 -0
  256. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/gdi32.py +0 -507
  257. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/ntdll.py +0 -539
  258. debugpy-1.8.5/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/peb_teb.py +0 -3435
  259. {debugpy-1.8.5 → debugpy-1.8.7}/DESCRIPTION.md +0 -0
  260. {debugpy-1.8.5 → debugpy-1.8.7}/LICENSE +0 -0
  261. {debugpy-1.8.5 → debugpy-1.8.7}/MANIFEST.in +0 -0
  262. {debugpy-1.8.5 → debugpy-1.8.7}/README.md +0 -0
  263. {debugpy-1.8.5 → debugpy-1.8.7}/pyproject.toml +0 -0
  264. {debugpy-1.8.5 → debugpy-1.8.7}/setup.cfg +0 -0
  265. {debugpy-1.8.5 → debugpy-1.8.7}/setup.py +0 -0
  266. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/ThirdPartyNotices.txt +0 -0
  267. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/__init__.py +0 -0
  268. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/__main__.py +0 -0
  269. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/__init__.py +0 -0
  270. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/_pydevd_packaging.py +0 -0
  271. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/_util.py +0 -0
  272. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/force_pydevd.py +0 -0
  273. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_bundle/__init__.py +0 -0
  274. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydev_runfiles/__init__.py +0 -0
  275. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/__init__.py +0 -0
  276. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/__init__.py +0 -0
  277. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/debugProtocolCustom.json +0 -0
  278. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_concurrency_analyser/__init__.py +0 -0
  279. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/.gitignore +0 -0
  280. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/__init__.py +0 -0
  281. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd +0 -0
  282. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pyx +0 -0
  283. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.template.pyx +0 -0
  284. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/release_mem.h +0 -0
  285. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/README.txt +0 -0
  286. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/_pydevd_frame_eval/vendored/__init__.py +0 -0
  287. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/README +0 -0
  288. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_ipython/__init__.py +0 -0
  289. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydev_sitecustomize/__not_in_default_pythonpath.txt +0 -0
  290. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/README.txt +0 -0
  291. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_custom_pyeval_settrace.hpp +0 -0
  292. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_custom_pyeval_settrace_310.hpp +0 -0
  293. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_custom_pyeval_settrace_311.hpp +0 -0
  294. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_custom_pyeval_settrace_common.hpp +0 -0
  295. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_settrace.hpp +0 -0
  296. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/python.h +0 -0
  297. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/ref_utils.hpp +0 -0
  298. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/.gitignore +0 -0
  299. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/attach.cpp +0 -0
  300. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/compile_linux.sh +0 -0
  301. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/compile_mac.sh +0 -0
  302. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/compile_manylinux.cmd +0 -0
  303. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/attach.h +0 -0
  304. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/inject_dll.cpp +0 -0
  305. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/py_win_helpers.hpp +0 -0
  306. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/run_code_in_memory.hpp +0 -0
  307. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/run_code_on_dllmain.cpp +0 -0
  308. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/stdafx.cpp +0 -0
  309. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/stdafx.h +0 -0
  310. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/windows/targetver.h +0 -0
  311. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/README.md +0 -0
  312. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/__init__.py +0 -0
  313. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/__main__.py +0 -0
  314. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/clients.py +0 -0
  315. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/components.py +0 -0
  316. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/launchers.py +0 -0
  317. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/servers.py +0 -0
  318. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/adapter/sessions.py +0 -0
  319. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/__init__.py +0 -0
  320. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/json.py +0 -0
  321. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/log.py +0 -0
  322. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/singleton.py +0 -0
  323. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/sockets.py +0 -0
  324. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/stacks.py +0 -0
  325. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/timestamp.py +0 -0
  326. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/common/util.py +0 -0
  327. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/launcher/__init__.py +0 -0
  328. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/launcher/__main__.py +0 -0
  329. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/launcher/debuggee.py +0 -0
  330. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/launcher/handlers.py +0 -0
  331. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/launcher/output.py +0 -0
  332. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/launcher/winapi.py +0 -0
  333. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/public_api.py +0 -0
  334. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/server/__init__.py +0 -0
  335. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/server/api.py +0 -0
  336. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy/server/attach_pid_injected.py +0 -0
  337. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy.egg-info/dependency_links.txt +0 -0
  338. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy.egg-info/entry_points.txt +0 -0
  339. {debugpy-1.8.5 → debugpy-1.8.7}/src/debugpy.egg-info/top_level.txt +0 -0
  340. {debugpy-1.8.5 → debugpy-1.8.7}/versioneer.py +0 -0
@@ -40,116 +40,125 @@ from winappdbg.win32.kernel32 import *
40
40
  # XXX TODO
41
41
  # + add transacted registry operations
42
42
 
43
- #==============================================================================
43
+ # ==============================================================================
44
44
  # This is used later on to calculate the list of exported symbols.
45
45
  _all = None
46
46
  _all = set(vars().keys())
47
- #==============================================================================
47
+ # ==============================================================================
48
48
 
49
- #--- Constants ----------------------------------------------------------------
49
+ # --- Constants ----------------------------------------------------------------
50
50
 
51
51
  # Privilege constants
52
- SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
53
- SE_AUDIT_NAME = "SeAuditPrivilege"
54
- SE_BACKUP_NAME = "SeBackupPrivilege"
55
- SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
56
- SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege"
57
- SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
58
- SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
59
- SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege"
60
- SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
61
- SE_DEBUG_NAME = "SeDebugPrivilege"
62
- SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege"
63
- SE_IMPERSONATE_NAME = "SeImpersonatePrivilege"
64
- SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
65
- SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
66
- SE_INC_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege"
67
- SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
68
- SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
69
- SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
70
- SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege"
71
- SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
72
- SE_RELABEL_NAME = "SeRelabelPrivilege"
73
- SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
74
- SE_RESTORE_NAME = "SeRestorePrivilege"
75
- SE_SECURITY_NAME = "SeSecurityPrivilege"
76
- SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
77
- SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege"
78
- SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
79
- SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
80
- SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
81
- SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
82
- SE_TCB_NAME = "SeTcbPrivilege"
83
- SE_TIME_ZONE_NAME = "SeTimeZonePrivilege"
84
- SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege"
85
- SE_UNDOCK_NAME = "SeUndockPrivilege"
86
- SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
52
+ SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
53
+ SE_AUDIT_NAME = "SeAuditPrivilege"
54
+ SE_BACKUP_NAME = "SeBackupPrivilege"
55
+ SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
56
+ SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege"
57
+ SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
58
+ SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
59
+ SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege"
60
+ SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
61
+ SE_DEBUG_NAME = "SeDebugPrivilege"
62
+ SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege"
63
+ SE_IMPERSONATE_NAME = "SeImpersonatePrivilege"
64
+ SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
65
+ SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
66
+ SE_INC_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege"
67
+ SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
68
+ SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
69
+ SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
70
+ SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege"
71
+ SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
72
+ SE_RELABEL_NAME = "SeRelabelPrivilege"
73
+ SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
74
+ SE_RESTORE_NAME = "SeRestorePrivilege"
75
+ SE_SECURITY_NAME = "SeSecurityPrivilege"
76
+ SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
77
+ SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege"
78
+ SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
79
+ SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
80
+ SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
81
+ SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
82
+ SE_TCB_NAME = "SeTcbPrivilege"
83
+ SE_TIME_ZONE_NAME = "SeTimeZonePrivilege"
84
+ SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege"
85
+ SE_UNDOCK_NAME = "SeUndockPrivilege"
86
+ SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
87
87
 
88
88
  SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001
89
- SE_PRIVILEGE_ENABLED = 0x00000002
90
- SE_PRIVILEGE_REMOVED = 0x00000004
91
- SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000
89
+ SE_PRIVILEGE_ENABLED = 0x00000002
90
+ SE_PRIVILEGE_REMOVED = 0x00000004
91
+ SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000
92
92
 
93
- TOKEN_ADJUST_PRIVILEGES = 0x00000020
93
+ TOKEN_ADJUST_PRIVILEGES = 0x00000020
94
94
 
95
- LOGON_WITH_PROFILE = 0x00000001
96
- LOGON_NETCREDENTIALS_ONLY = 0x00000002
95
+ LOGON_WITH_PROFILE = 0x00000001
96
+ LOGON_NETCREDENTIALS_ONLY = 0x00000002
97
97
 
98
98
  # Token access rights
99
- TOKEN_ASSIGN_PRIMARY = 0x0001
100
- TOKEN_DUPLICATE = 0x0002
101
- TOKEN_IMPERSONATE = 0x0004
102
- TOKEN_QUERY = 0x0008
103
- TOKEN_QUERY_SOURCE = 0x0010
99
+ TOKEN_ASSIGN_PRIMARY = 0x0001
100
+ TOKEN_DUPLICATE = 0x0002
101
+ TOKEN_IMPERSONATE = 0x0004
102
+ TOKEN_QUERY = 0x0008
103
+ TOKEN_QUERY_SOURCE = 0x0010
104
104
  TOKEN_ADJUST_PRIVILEGES = 0x0020
105
- TOKEN_ADJUST_GROUPS = 0x0040
106
- TOKEN_ADJUST_DEFAULT = 0x0080
107
- TOKEN_ADJUST_SESSIONID = 0x0100
108
- TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY)
109
- TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY |
110
- TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE |
111
- TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT |
112
- TOKEN_ADJUST_SESSIONID)
105
+ TOKEN_ADJUST_GROUPS = 0x0040
106
+ TOKEN_ADJUST_DEFAULT = 0x0080
107
+ TOKEN_ADJUST_SESSIONID = 0x0100
108
+ TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY
109
+ TOKEN_ALL_ACCESS = (
110
+ STANDARD_RIGHTS_REQUIRED
111
+ | TOKEN_ASSIGN_PRIMARY
112
+ | TOKEN_DUPLICATE
113
+ | TOKEN_IMPERSONATE
114
+ | TOKEN_QUERY
115
+ | TOKEN_QUERY_SOURCE
116
+ | TOKEN_ADJUST_PRIVILEGES
117
+ | TOKEN_ADJUST_GROUPS
118
+ | TOKEN_ADJUST_DEFAULT
119
+ | TOKEN_ADJUST_SESSIONID
120
+ )
113
121
 
114
122
  # Predefined HKEY values
115
- HKEY_CLASSES_ROOT = 0x80000000
116
- HKEY_CURRENT_USER = 0x80000001
117
- HKEY_LOCAL_MACHINE = 0x80000002
118
- HKEY_USERS = 0x80000003
119
- HKEY_PERFORMANCE_DATA = 0x80000004
120
- HKEY_CURRENT_CONFIG = 0x80000005
123
+ HKEY_CLASSES_ROOT = 0x80000000
124
+ HKEY_CURRENT_USER = 0x80000001
125
+ HKEY_LOCAL_MACHINE = 0x80000002
126
+ HKEY_USERS = 0x80000003
127
+ HKEY_PERFORMANCE_DATA = 0x80000004
128
+ HKEY_CURRENT_CONFIG = 0x80000005
121
129
 
122
130
  # Registry access rights
123
- KEY_ALL_ACCESS = 0xF003F
124
- KEY_CREATE_LINK = 0x0020
125
- KEY_CREATE_SUB_KEY = 0x0004
126
- KEY_ENUMERATE_SUB_KEYS = 0x0008
127
- KEY_EXECUTE = 0x20019
128
- KEY_NOTIFY = 0x0010
129
- KEY_QUERY_VALUE = 0x0001
130
- KEY_READ = 0x20019
131
- KEY_SET_VALUE = 0x0002
132
- KEY_WOW64_32KEY = 0x0200
133
- KEY_WOW64_64KEY = 0x0100
134
- KEY_WRITE = 0x20006
131
+ KEY_ALL_ACCESS = 0xF003F
132
+ KEY_CREATE_LINK = 0x0020
133
+ KEY_CREATE_SUB_KEY = 0x0004
134
+ KEY_ENUMERATE_SUB_KEYS = 0x0008
135
+ KEY_EXECUTE = 0x20019
136
+ KEY_NOTIFY = 0x0010
137
+ KEY_QUERY_VALUE = 0x0001
138
+ KEY_READ = 0x20019
139
+ KEY_SET_VALUE = 0x0002
140
+ KEY_WOW64_32KEY = 0x0200
141
+ KEY_WOW64_64KEY = 0x0100
142
+ KEY_WRITE = 0x20006
135
143
 
136
144
  # Registry value types
137
- REG_NONE = 0
138
- REG_SZ = 1
139
- REG_EXPAND_SZ = 2
140
- REG_BINARY = 3
141
- REG_DWORD = 4
142
- REG_DWORD_LITTLE_ENDIAN = REG_DWORD
143
- REG_DWORD_BIG_ENDIAN = 5
144
- REG_LINK = 6
145
- REG_MULTI_SZ = 7
146
- REG_RESOURCE_LIST = 8
147
- REG_FULL_RESOURCE_DESCRIPTOR = 9
148
- REG_RESOURCE_REQUIREMENTS_LIST = 10
149
- REG_QWORD = 11
150
- REG_QWORD_LITTLE_ENDIAN = REG_QWORD
151
-
152
- #--- TOKEN_PRIVILEGE structure ------------------------------------------------
145
+ REG_NONE = 0
146
+ REG_SZ = 1
147
+ REG_EXPAND_SZ = 2
148
+ REG_BINARY = 3
149
+ REG_DWORD = 4
150
+ REG_DWORD_LITTLE_ENDIAN = REG_DWORD
151
+ REG_DWORD_BIG_ENDIAN = 5
152
+ REG_LINK = 6
153
+ REG_MULTI_SZ = 7
154
+ REG_RESOURCE_LIST = 8
155
+ REG_FULL_RESOURCE_DESCRIPTOR = 9
156
+ REG_RESOURCE_REQUIREMENTS_LIST = 10
157
+ REG_QWORD = 11
158
+ REG_QWORD_LITTLE_ENDIAN = REG_QWORD
159
+
160
+ # --- TOKEN_PRIVILEGE structure ------------------------------------------------
161
+
153
162
 
154
163
  # typedef struct _LUID {
155
164
  # DWORD LowPart;
@@ -158,12 +167,14 @@ REG_QWORD_LITTLE_ENDIAN = REG_QWORD
158
167
  # *PLUID;
159
168
  class LUID(Structure):
160
169
  _fields_ = [
161
- ("LowPart", DWORD),
162
- ("HighPart", LONG),
170
+ ("LowPart", DWORD),
171
+ ("HighPart", LONG),
163
172
  ]
164
173
 
174
+
165
175
  PLUID = POINTER(LUID)
166
176
 
177
+
167
178
  # typedef struct _LUID_AND_ATTRIBUTES {
168
179
  # LUID Luid;
169
180
  # DWORD Attributes;
@@ -171,10 +182,11 @@ PLUID = POINTER(LUID)
171
182
  # *PLUID_AND_ATTRIBUTES;
172
183
  class LUID_AND_ATTRIBUTES(Structure):
173
184
  _fields_ = [
174
- ("Luid", LUID),
175
- ("Attributes", DWORD),
185
+ ("Luid", LUID),
186
+ ("Attributes", DWORD),
176
187
  ]
177
188
 
189
+
178
190
  # typedef struct _TOKEN_PRIVILEGES {
179
191
  # DWORD PrivilegeCount;
180
192
  # LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
@@ -182,15 +194,16 @@ class LUID_AND_ATTRIBUTES(Structure):
182
194
  # *PTOKEN_PRIVILEGES;
183
195
  class TOKEN_PRIVILEGES(Structure):
184
196
  _fields_ = [
185
- ("PrivilegeCount", DWORD),
186
- ## ("Privileges", LUID_AND_ATTRIBUTES * ANYSIZE_ARRAY),
187
- ("Privileges", LUID_AND_ATTRIBUTES),
197
+ ("PrivilegeCount", DWORD),
198
+ ## ("Privileges", LUID_AND_ATTRIBUTES * ANYSIZE_ARRAY),
199
+ ("Privileges", LUID_AND_ATTRIBUTES),
188
200
  ]
189
201
  # See comments on AdjustTokenPrivileges about this structure
190
202
 
203
+
191
204
  PTOKEN_PRIVILEGES = POINTER(TOKEN_PRIVILEGES)
192
205
 
193
- #--- GetTokenInformation enums and structures ---------------------------------
206
+ # --- GetTokenInformation enums and structures ---------------------------------
194
207
 
195
208
  # typedef enum _TOKEN_INFORMATION_CLASS {
196
209
  # TokenUser = 1,
@@ -238,47 +251,47 @@ PTOKEN_PRIVILEGES = POINTER(TOKEN_PRIVILEGES)
238
251
 
239
252
  TOKEN_INFORMATION_CLASS = ctypes.c_int
240
253
 
241
- TokenUser = 1
242
- TokenGroups = 2
243
- TokenPrivileges = 3
244
- TokenOwner = 4
245
- TokenPrimaryGroup = 5
246
- TokenDefaultDacl = 6
247
- TokenSource = 7
248
- TokenType = 8
249
- TokenImpersonationLevel = 9
250
- TokenStatistics = 10
251
- TokenRestrictedSids = 11
252
- TokenSessionId = 12
253
- TokenGroupsAndPrivileges = 13
254
- TokenSessionReference = 14
255
- TokenSandBoxInert = 15
256
- TokenAuditPolicy = 16
257
- TokenOrigin = 17
258
- TokenElevationType = 18
259
- TokenLinkedToken = 19
260
- TokenElevation = 20
261
- TokenHasRestrictions = 21
262
- TokenAccessInformation = 22
263
- TokenVirtualizationAllowed = 23
264
- TokenVirtualizationEnabled = 24
265
- TokenIntegrityLevel = 25
266
- TokenUIAccess = 26
267
- TokenMandatoryPolicy = 27
268
- TokenLogonSid = 28
269
- TokenIsAppContainer = 29
270
- TokenCapabilities = 30
271
- TokenAppContainerSid = 31
272
- TokenAppContainerNumber = 32
273
- TokenUserClaimAttributes = 33
274
- TokenDeviceClaimAttributes = 34
275
- TokenRestrictedUserClaimAttributes = 35
276
- TokenRestrictedDeviceClaimAttributes = 36
277
- TokenDeviceGroups = 37
278
- TokenRestrictedDeviceGroups = 38
279
- TokenSecurityAttributes = 39
280
- TokenIsRestricted = 40
281
- MaxTokenInfoClass = 41
254
+ TokenUser = 1
255
+ TokenGroups = 2
256
+ TokenPrivileges = 3
257
+ TokenOwner = 4
258
+ TokenPrimaryGroup = 5
259
+ TokenDefaultDacl = 6
260
+ TokenSource = 7
261
+ TokenType = 8
262
+ TokenImpersonationLevel = 9
263
+ TokenStatistics = 10
264
+ TokenRestrictedSids = 11
265
+ TokenSessionId = 12
266
+ TokenGroupsAndPrivileges = 13
267
+ TokenSessionReference = 14
268
+ TokenSandBoxInert = 15
269
+ TokenAuditPolicy = 16
270
+ TokenOrigin = 17
271
+ TokenElevationType = 18
272
+ TokenLinkedToken = 19
273
+ TokenElevation = 20
274
+ TokenHasRestrictions = 21
275
+ TokenAccessInformation = 22
276
+ TokenVirtualizationAllowed = 23
277
+ TokenVirtualizationEnabled = 24
278
+ TokenIntegrityLevel = 25
279
+ TokenUIAccess = 26
280
+ TokenMandatoryPolicy = 27
281
+ TokenLogonSid = 28
282
+ TokenIsAppContainer = 29
283
+ TokenCapabilities = 30
284
+ TokenAppContainerSid = 31
285
+ TokenAppContainerNumber = 32
286
+ TokenUserClaimAttributes = 33
287
+ TokenDeviceClaimAttributes = 34
288
+ TokenRestrictedUserClaimAttributes = 35
289
+ TokenRestrictedDeviceClaimAttributes = 36
290
+ TokenDeviceGroups = 37
291
+ TokenRestrictedDeviceGroups = 38
292
+ TokenSecurityAttributes = 39
293
+ TokenIsRestricted = 40
294
+ MaxTokenInfoClass = 41
282
295
 
283
296
  # typedef enum tagTOKEN_TYPE {
284
297
  # TokenPrimary = 1,
@@ -288,8 +301,8 @@ MaxTokenInfoClass = 41
288
301
  TOKEN_TYPE = ctypes.c_int
289
302
  PTOKEN_TYPE = POINTER(TOKEN_TYPE)
290
303
 
291
- TokenPrimary = 1
292
- TokenImpersonation = 2
304
+ TokenPrimary = 1
305
+ TokenImpersonation = 2
293
306
 
294
307
  # typedef enum {
295
308
  # TokenElevationTypeDefault = 1,
@@ -297,9 +310,9 @@ TokenImpersonation = 2
297
310
  # TokenElevationTypeLimited
298
311
  # } TOKEN_ELEVATION_TYPE , *PTOKEN_ELEVATION_TYPE;
299
312
 
300
- TokenElevationTypeDefault = 1
301
- TokenElevationTypeFull = 2
302
- TokenElevationTypeLimited = 3
313
+ TokenElevationTypeDefault = 1
314
+ TokenElevationTypeFull = 2
315
+ TokenElevationTypeLimited = 3
303
316
 
304
317
  TOKEN_ELEVATION_TYPE = ctypes.c_int
305
318
  PTOKEN_ELEVATION_TYPE = POINTER(TOKEN_ELEVATION_TYPE)
@@ -311,25 +324,29 @@ PTOKEN_ELEVATION_TYPE = POINTER(TOKEN_ELEVATION_TYPE)
311
324
  # SecurityDelegation
312
325
  # } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
313
326
 
314
- SecurityAnonymous = 0
315
- SecurityIdentification = 1
316
- SecurityImpersonation = 2
317
- SecurityDelegation = 3
327
+ SecurityAnonymous = 0
328
+ SecurityIdentification = 1
329
+ SecurityImpersonation = 2
330
+ SecurityDelegation = 3
318
331
 
319
332
  SECURITY_IMPERSONATION_LEVEL = ctypes.c_int
320
333
  PSECURITY_IMPERSONATION_LEVEL = POINTER(SECURITY_IMPERSONATION_LEVEL)
321
334
 
335
+
322
336
  # typedef struct _SID_AND_ATTRIBUTES {
323
337
  # PSID Sid;
324
338
  # DWORD Attributes;
325
339
  # } SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
326
340
  class SID_AND_ATTRIBUTES(Structure):
327
341
  _fields_ = [
328
- ("Sid", PSID),
329
- ("Attributes", DWORD),
342
+ ("Sid", PSID),
343
+ ("Attributes", DWORD),
330
344
  ]
345
+
346
+
331
347
  PSID_AND_ATTRIBUTES = POINTER(SID_AND_ATTRIBUTES)
332
348
 
349
+
333
350
  # typedef struct _TOKEN_USER {
334
351
  # SID_AND_ATTRIBUTES User;
335
352
  # } TOKEN_USER, *PTOKEN_USER;
@@ -337,8 +354,11 @@ class TOKEN_USER(Structure):
337
354
  _fields_ = [
338
355
  ("User", SID_AND_ATTRIBUTES),
339
356
  ]
357
+
358
+
340
359
  PTOKEN_USER = POINTER(TOKEN_USER)
341
360
 
361
+
342
362
  # typedef struct _TOKEN_MANDATORY_LABEL {
343
363
  # SID_AND_ATTRIBUTES Label;
344
364
  # } TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
@@ -346,8 +366,11 @@ class TOKEN_MANDATORY_LABEL(Structure):
346
366
  _fields_ = [
347
367
  ("Label", SID_AND_ATTRIBUTES),
348
368
  ]
369
+
370
+
349
371
  PTOKEN_MANDATORY_LABEL = POINTER(TOKEN_MANDATORY_LABEL)
350
372
 
373
+
351
374
  # typedef struct _TOKEN_OWNER {
352
375
  # PSID Owner;
353
376
  # } TOKEN_OWNER, *PTOKEN_OWNER;
@@ -355,8 +378,11 @@ class TOKEN_OWNER(Structure):
355
378
  _fields_ = [
356
379
  ("Owner", PSID),
357
380
  ]
381
+
382
+
358
383
  PTOKEN_OWNER = POINTER(TOKEN_OWNER)
359
384
 
385
+
360
386
  # typedef struct _TOKEN_PRIMARY_GROUP {
361
387
  # PSID PrimaryGroup;
362
388
  # } TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP;
@@ -364,8 +390,11 @@ class TOKEN_PRIMARY_GROUP(Structure):
364
390
  _fields_ = [
365
391
  ("PrimaryGroup", PSID),
366
392
  ]
393
+
394
+
367
395
  PTOKEN_PRIMARY_GROUP = POINTER(TOKEN_PRIMARY_GROUP)
368
396
 
397
+
369
398
  # typedef struct _TOKEN_APPCONTAINER_INFORMATION {
370
399
  # PSID TokenAppContainer;
371
400
  # } TOKEN_APPCONTAINER_INFORMATION, *PTOKEN_APPCONTAINER_INFORMATION;
@@ -373,8 +402,11 @@ class TOKEN_APPCONTAINER_INFORMATION(Structure):
373
402
  _fields_ = [
374
403
  ("TokenAppContainer", PSID),
375
404
  ]
405
+
406
+
376
407
  PTOKEN_APPCONTAINER_INFORMATION = POINTER(TOKEN_APPCONTAINER_INFORMATION)
377
408
 
409
+
378
410
  # typedef struct _TOKEN_ORIGIN {
379
411
  # LUID OriginatingLogonSession;
380
412
  # } TOKEN_ORIGIN, *PTOKEN_ORIGIN;
@@ -382,8 +414,11 @@ class TOKEN_ORIGIN(Structure):
382
414
  _fields_ = [
383
415
  ("OriginatingLogonSession", LUID),
384
416
  ]
417
+
418
+
385
419
  PTOKEN_ORIGIN = POINTER(TOKEN_ORIGIN)
386
420
 
421
+
387
422
  # typedef struct _TOKEN_LINKED_TOKEN {
388
423
  # HANDLE LinkedToken;
389
424
  # } TOKEN_LINKED_TOKEN, *PTOKEN_LINKED_TOKEN;
@@ -391,8 +426,11 @@ class TOKEN_LINKED_TOKEN(Structure):
391
426
  _fields_ = [
392
427
  ("LinkedToken", HANDLE),
393
428
  ]
429
+
430
+
394
431
  PTOKEN_LINKED_TOKEN = POINTER(TOKEN_LINKED_TOKEN)
395
432
 
433
+
396
434
  # typedef struct _TOKEN_STATISTICS {
397
435
  # LUID TokenId;
398
436
  # LUID AuthenticationId;
@@ -407,20 +445,22 @@ PTOKEN_LINKED_TOKEN = POINTER(TOKEN_LINKED_TOKEN)
407
445
  # } TOKEN_STATISTICS, *PTOKEN_STATISTICS;
408
446
  class TOKEN_STATISTICS(Structure):
409
447
  _fields_ = [
410
- ("TokenId", LUID),
411
- ("AuthenticationId", LUID),
412
- ("ExpirationTime", LONGLONG), # LARGE_INTEGER
413
- ("TokenType", TOKEN_TYPE),
414
- ("ImpersonationLevel", SECURITY_IMPERSONATION_LEVEL),
415
- ("DynamicCharged", DWORD),
416
- ("DynamicAvailable", DWORD),
417
- ("GroupCount", DWORD),
418
- ("PrivilegeCount", DWORD),
419
- ("ModifiedId", LUID),
448
+ ("TokenId", LUID),
449
+ ("AuthenticationId", LUID),
450
+ ("ExpirationTime", LONGLONG), # LARGE_INTEGER
451
+ ("TokenType", TOKEN_TYPE),
452
+ ("ImpersonationLevel", SECURITY_IMPERSONATION_LEVEL),
453
+ ("DynamicCharged", DWORD),
454
+ ("DynamicAvailable", DWORD),
455
+ ("GroupCount", DWORD),
456
+ ("PrivilegeCount", DWORD),
457
+ ("ModifiedId", LUID),
420
458
  ]
459
+
460
+
421
461
  PTOKEN_STATISTICS = POINTER(TOKEN_STATISTICS)
422
462
 
423
- #--- SID_NAME_USE enum --------------------------------------------------------
463
+ # --- SID_NAME_USE enum --------------------------------------------------------
424
464
 
425
465
  # typedef enum _SID_NAME_USE {
426
466
  # SidTypeUser = 1,
@@ -435,27 +475,27 @@ PTOKEN_STATISTICS = POINTER(TOKEN_STATISTICS)
435
475
  # SidTypeLabel
436
476
  # } SID_NAME_USE, *PSID_NAME_USE;
437
477
 
438
- SidTypeUser = 1
439
- SidTypeGroup = 2
440
- SidTypeDomain = 3
441
- SidTypeAlias = 4
442
- SidTypeWellKnownGroup = 5
443
- SidTypeDeletedAccount = 6
444
- SidTypeInvalid = 7
445
- SidTypeUnknown = 8
446
- SidTypeComputer = 9
447
- SidTypeLabel = 10
448
-
449
- #--- WAITCHAIN_NODE_INFO structure and types ----------------------------------
450
-
451
- WCT_MAX_NODE_COUNT = 16
452
- WCT_OBJNAME_LENGTH = 128
453
- WCT_ASYNC_OPEN_FLAG = 1
454
- WCTP_OPEN_ALL_FLAGS = WCT_ASYNC_OPEN_FLAG
455
- WCT_OUT_OF_PROC_FLAG = 1
478
+ SidTypeUser = 1
479
+ SidTypeGroup = 2
480
+ SidTypeDomain = 3
481
+ SidTypeAlias = 4
482
+ SidTypeWellKnownGroup = 5
483
+ SidTypeDeletedAccount = 6
484
+ SidTypeInvalid = 7
485
+ SidTypeUnknown = 8
486
+ SidTypeComputer = 9
487
+ SidTypeLabel = 10
488
+
489
+ # --- WAITCHAIN_NODE_INFO structure and types ----------------------------------
490
+
491
+ WCT_MAX_NODE_COUNT = 16
492
+ WCT_OBJNAME_LENGTH = 128
493
+ WCT_ASYNC_OPEN_FLAG = 1
494
+ WCTP_OPEN_ALL_FLAGS = WCT_ASYNC_OPEN_FLAG
495
+ WCT_OUT_OF_PROC_FLAG = 1
456
496
  WCT_OUT_OF_PROC_COM_FLAG = 2
457
- WCT_OUT_OF_PROC_CS_FLAG = 4
458
- WCTP_GETINFO_ALL_FLAGS = WCT_OUT_OF_PROC_FLAG | WCT_OUT_OF_PROC_COM_FLAG | WCT_OUT_OF_PROC_CS_FLAG
497
+ WCT_OUT_OF_PROC_CS_FLAG = 4
498
+ WCTP_GETINFO_ALL_FLAGS = WCT_OUT_OF_PROC_FLAG | WCT_OUT_OF_PROC_COM_FLAG | WCT_OUT_OF_PROC_CS_FLAG
459
499
 
460
500
  HWCT = LPVOID
461
501
 
@@ -474,19 +514,19 @@ HWCT = LPVOID
474
514
  # WctMaxType
475
515
  # } WCT_OBJECT_TYPE;
476
516
 
477
- WCT_OBJECT_TYPE = DWORD
517
+ WCT_OBJECT_TYPE = DWORD
478
518
 
479
- WctCriticalSectionType = 1
480
- WctSendMessageType = 2
481
- WctMutexType = 3
482
- WctAlpcType = 4
483
- WctComType = 5
484
- WctThreadWaitType = 6
485
- WctProcessWaitType = 7
486
- WctThreadType = 8
487
- WctComActivationType = 9
488
- WctUnknownType = 10
489
- WctMaxType = 11
519
+ WctCriticalSectionType = 1
520
+ WctSendMessageType = 2
521
+ WctMutexType = 3
522
+ WctAlpcType = 4
523
+ WctComType = 5
524
+ WctThreadWaitType = 6
525
+ WctProcessWaitType = 7
526
+ WctThreadType = 8
527
+ WctComActivationType = 9
528
+ WctUnknownType = 10
529
+ WctMaxType = 11
490
530
 
491
531
  # typedef enum _WCT_OBJECT_STATUS
492
532
  # {
@@ -503,19 +543,19 @@ WctMaxType = 11
503
543
  # WctStatusMax
504
544
  # } WCT_OBJECT_STATUS;
505
545
 
506
- WCT_OBJECT_STATUS = DWORD
546
+ WCT_OBJECT_STATUS = DWORD
507
547
 
508
- WctStatusNoAccess = 1 # ACCESS_DENIED for this object
509
- WctStatusRunning = 2 # Thread status
510
- WctStatusBlocked = 3 # Thread status
511
- WctStatusPidOnly = 4 # Thread status
512
- WctStatusPidOnlyRpcss = 5 # Thread status
513
- WctStatusOwned = 6 # Dispatcher object status
514
- WctStatusNotOwned = 7 # Dispatcher object status
515
- WctStatusAbandoned = 8 # Dispatcher object status
516
- WctStatusUnknown = 9 # All objects
517
- WctStatusError = 10 # All objects
518
- WctStatusMax = 11
548
+ WctStatusNoAccess = 1 # ACCESS_DENIED for this object
549
+ WctStatusRunning = 2 # Thread status
550
+ WctStatusBlocked = 3 # Thread status
551
+ WctStatusPidOnly = 4 # Thread status
552
+ WctStatusPidOnlyRpcss = 5 # Thread status
553
+ WctStatusOwned = 6 # Dispatcher object status
554
+ WctStatusNotOwned = 7 # Dispatcher object status
555
+ WctStatusAbandoned = 8 # Dispatcher object status
556
+ WctStatusUnknown = 9 # All objects
557
+ WctStatusError = 10 # All objects
558
+ WctStatusMax = 11
519
559
 
520
560
  # typedef struct _WAITCHAIN_NODE_INFO {
521
561
  # WCT_OBJECT_TYPE ObjectType;
@@ -535,37 +575,43 @@ WctStatusMax = 11
535
575
  # } ;
536
576
  # }WAITCHAIN_NODE_INFO, *PWAITCHAIN_NODE_INFO;
537
577
 
578
+
538
579
  class _WAITCHAIN_NODE_INFO_STRUCT_1(Structure):
539
580
  _fields_ = [
540
- ("ObjectName", WCHAR * WCT_OBJNAME_LENGTH),
541
- ("Timeout", LONGLONG), # LARGE_INTEGER
542
- ("Alertable", BOOL),
581
+ ("ObjectName", WCHAR * WCT_OBJNAME_LENGTH),
582
+ ("Timeout", LONGLONG), # LARGE_INTEGER
583
+ ("Alertable", BOOL),
543
584
  ]
544
585
 
586
+
545
587
  class _WAITCHAIN_NODE_INFO_STRUCT_2(Structure):
546
588
  _fields_ = [
547
- ("ProcessId", DWORD),
548
- ("ThreadId", DWORD),
549
- ("WaitTime", DWORD),
589
+ ("ProcessId", DWORD),
590
+ ("ThreadId", DWORD),
591
+ ("WaitTime", DWORD),
550
592
  ("ContextSwitches", DWORD),
551
593
  ]
552
594
 
595
+
553
596
  class _WAITCHAIN_NODE_INFO_UNION(Union):
554
597
  _fields_ = [
555
- ("LockObject", _WAITCHAIN_NODE_INFO_STRUCT_1),
556
- ("ThreadObject", _WAITCHAIN_NODE_INFO_STRUCT_2),
598
+ ("LockObject", _WAITCHAIN_NODE_INFO_STRUCT_1),
599
+ ("ThreadObject", _WAITCHAIN_NODE_INFO_STRUCT_2),
557
600
  ]
558
601
 
602
+
559
603
  class WAITCHAIN_NODE_INFO(Structure):
560
604
  _fields_ = [
561
- ("ObjectType", WCT_OBJECT_TYPE),
562
- ("ObjectStatus", WCT_OBJECT_STATUS),
563
- ("u", _WAITCHAIN_NODE_INFO_UNION),
605
+ ("ObjectType", WCT_OBJECT_TYPE),
606
+ ("ObjectStatus", WCT_OBJECT_STATUS),
607
+ ("u", _WAITCHAIN_NODE_INFO_UNION),
564
608
  ]
565
609
 
610
+
566
611
  PWAITCHAIN_NODE_INFO = POINTER(WAITCHAIN_NODE_INFO)
567
612
 
568
- class WaitChainNodeInfo (object):
613
+
614
+ class WaitChainNodeInfo(object):
569
615
  """
570
616
  Represents a node in the wait chain.
571
617
 
@@ -624,11 +670,11 @@ class WaitChainNodeInfo (object):
624
670
  @ivar ContextSwitches: Number of context switches.
625
671
  """
626
672
 
627
- #@type Timeout: int
628
- #@ivar Timeout: Currently not documented in MSDN.
673
+ # @type Timeout: int
674
+ # @ivar Timeout: Currently not documented in MSDN.
629
675
  #
630
- #@type Alertable: bool
631
- #@ivar Alertable: Currently not documented in MSDN.
676
+ # @type Alertable: bool
677
+ # @ivar Alertable: Currently not documented in MSDN.
632
678
 
633
679
  # TODO: __repr__
634
680
 
@@ -640,13 +686,14 @@ class WaitChainNodeInfo (object):
640
686
  self.ThreadId = aStructure.u.ThreadObject.ThreadId
641
687
  self.WaitTime = aStructure.u.ThreadObject.WaitTime
642
688
  self.ContextSwitches = aStructure.u.ThreadObject.ContextSwitches
643
- self.ObjectName = u''
689
+ self.ObjectName = ""
644
690
  else:
645
691
  self.ObjectName = aStructure.u.LockObject.ObjectName.value
646
- #self.Timeout = aStructure.u.LockObject.Timeout
647
- #self.Alertable = bool(aStructure.u.LockObject.Alertable)
692
+ # self.Timeout = aStructure.u.LockObject.Timeout
693
+ # self.Alertable = bool(aStructure.u.LockObject.Alertable)
648
694
 
649
- class ThreadWaitChainSessionHandle (Handle):
695
+
696
+ class ThreadWaitChainSessionHandle(Handle):
650
697
  """
651
698
  Thread wait chain session handle.
652
699
 
@@ -655,13 +702,12 @@ class ThreadWaitChainSessionHandle (Handle):
655
702
  @see: L{Handle}
656
703
  """
657
704
 
658
- def __init__(self, aHandle = None):
705
+ def __init__(self, aHandle=None):
659
706
  """
660
707
  @type aHandle: int
661
708
  @param aHandle: Win32 handle value.
662
709
  """
663
- super(ThreadWaitChainSessionHandle, self).__init__(aHandle,
664
- bOwnership = True)
710
+ super(ThreadWaitChainSessionHandle, self).__init__(aHandle, bOwnership=True)
665
711
 
666
712
  def _close(self):
667
713
  if self.value is None:
@@ -671,7 +717,7 @@ class ThreadWaitChainSessionHandle (Handle):
671
717
  def dup(self):
672
718
  raise NotImplementedError()
673
719
 
674
- def wait(self, dwMilliseconds = None):
720
+ def wait(self, dwMilliseconds=None):
675
721
  raise NotImplementedError()
676
722
 
677
723
  @property
@@ -682,19 +728,20 @@ class ThreadWaitChainSessionHandle (Handle):
682
728
  def protectFromClose(self):
683
729
  return False
684
730
 
685
- #--- Privilege dropping -------------------------------------------------------
731
+
732
+ # --- Privilege dropping -------------------------------------------------------
686
733
 
687
734
  SAFER_LEVEL_HANDLE = HANDLE
688
735
 
689
736
  SAFER_SCOPEID_MACHINE = 1
690
- SAFER_SCOPEID_USER = 2
737
+ SAFER_SCOPEID_USER = 2
691
738
 
692
739
  SAFER_LEVEL_OPEN = 1
693
740
 
694
- SAFER_LEVELID_DISALLOWED = 0x00000
695
- SAFER_LEVELID_UNTRUSTED = 0x01000
696
- SAFER_LEVELID_CONSTRAINED = 0x10000
697
- SAFER_LEVELID_NORMALUSER = 0x20000
741
+ SAFER_LEVELID_DISALLOWED = 0x00000
742
+ SAFER_LEVELID_UNTRUSTED = 0x01000
743
+ SAFER_LEVELID_CONSTRAINED = 0x10000
744
+ SAFER_LEVELID_NORMALUSER = 0x20000
698
745
  SAFER_LEVELID_FULLYTRUSTED = 0x40000
699
746
 
700
747
  SAFER_POLICY_INFO_CLASS = DWORD
@@ -705,150 +752,151 @@ SaferPolicyEvaluateUserScope = 4
705
752
  SaferPolicyScopeFlags = 5
706
753
 
707
754
  SAFER_TOKEN_NULL_IF_EQUAL = 1
708
- SAFER_TOKEN_COMPARE_ONLY = 2
709
- SAFER_TOKEN_MAKE_INERT = 4
710
- SAFER_TOKEN_WANT_FLAGS = 8
711
- SAFER_TOKEN_MASK = 15
755
+ SAFER_TOKEN_COMPARE_ONLY = 2
756
+ SAFER_TOKEN_MAKE_INERT = 4
757
+ SAFER_TOKEN_WANT_FLAGS = 8
758
+ SAFER_TOKEN_MASK = 15
712
759
 
713
- #--- Service Control Manager types, constants and structures ------------------
760
+ # --- Service Control Manager types, constants and structures ------------------
714
761
 
715
762
  SC_HANDLE = HANDLE
716
763
 
717
- SERVICES_ACTIVE_DATABASEW = u"ServicesActive"
718
- SERVICES_FAILED_DATABASEW = u"ServicesFailed"
764
+ SERVICES_ACTIVE_DATABASEW = "ServicesActive"
765
+ SERVICES_FAILED_DATABASEW = "ServicesFailed"
719
766
 
720
767
  SERVICES_ACTIVE_DATABASEA = "ServicesActive"
721
768
  SERVICES_FAILED_DATABASEA = "ServicesFailed"
722
769
 
723
- SC_GROUP_IDENTIFIERW = u'+'
724
- SC_GROUP_IDENTIFIERA = '+'
770
+ SC_GROUP_IDENTIFIERW = "+"
771
+ SC_GROUP_IDENTIFIERA = "+"
725
772
 
726
- SERVICE_NO_CHANGE = 0xffffffff
773
+ SERVICE_NO_CHANGE = 0xFFFFFFFF
727
774
 
728
775
  # enum SC_STATUS_TYPE
729
- SC_STATUS_TYPE = ctypes.c_int
776
+ SC_STATUS_TYPE = ctypes.c_int
730
777
  SC_STATUS_PROCESS_INFO = 0
731
778
 
732
779
  # enum SC_ENUM_TYPE
733
- SC_ENUM_TYPE = ctypes.c_int
780
+ SC_ENUM_TYPE = ctypes.c_int
734
781
  SC_ENUM_PROCESS_INFO = 0
735
782
 
736
783
  # Access rights
737
784
  # http://msdn.microsoft.com/en-us/library/windows/desktop/ms685981(v=vs.85).aspx
738
785
 
739
- SERVICE_ALL_ACCESS = 0xF01FF
740
- SERVICE_QUERY_CONFIG = 0x0001
741
- SERVICE_CHANGE_CONFIG = 0x0002
742
- SERVICE_QUERY_STATUS = 0x0004
786
+ SERVICE_ALL_ACCESS = 0xF01FF
787
+ SERVICE_QUERY_CONFIG = 0x0001
788
+ SERVICE_CHANGE_CONFIG = 0x0002
789
+ SERVICE_QUERY_STATUS = 0x0004
743
790
  SERVICE_ENUMERATE_DEPENDENTS = 0x0008
744
- SERVICE_START = 0x0010
745
- SERVICE_STOP = 0x0020
746
- SERVICE_PAUSE_CONTINUE = 0x0040
747
- SERVICE_INTERROGATE = 0x0080
791
+ SERVICE_START = 0x0010
792
+ SERVICE_STOP = 0x0020
793
+ SERVICE_PAUSE_CONTINUE = 0x0040
794
+ SERVICE_INTERROGATE = 0x0080
748
795
  SERVICE_USER_DEFINED_CONTROL = 0x0100
749
796
 
750
- SC_MANAGER_ALL_ACCESS = 0xF003F
751
- SC_MANAGER_CONNECT = 0x0001
752
- SC_MANAGER_CREATE_SERVICE = 0x0002
753
- SC_MANAGER_ENUMERATE_SERVICE = 0x0004
754
- SC_MANAGER_LOCK = 0x0008
755
- SC_MANAGER_QUERY_LOCK_STATUS = 0x0010
756
- SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020
797
+ SC_MANAGER_ALL_ACCESS = 0xF003F
798
+ SC_MANAGER_CONNECT = 0x0001
799
+ SC_MANAGER_CREATE_SERVICE = 0x0002
800
+ SC_MANAGER_ENUMERATE_SERVICE = 0x0004
801
+ SC_MANAGER_LOCK = 0x0008
802
+ SC_MANAGER_QUERY_LOCK_STATUS = 0x0010
803
+ SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020
757
804
 
758
805
  # CreateService() service start type
759
- SERVICE_BOOT_START = 0x00000000
806
+ SERVICE_BOOT_START = 0x00000000
760
807
  SERVICE_SYSTEM_START = 0x00000001
761
- SERVICE_AUTO_START = 0x00000002
808
+ SERVICE_AUTO_START = 0x00000002
762
809
  SERVICE_DEMAND_START = 0x00000003
763
- SERVICE_DISABLED = 0x00000004
810
+ SERVICE_DISABLED = 0x00000004
764
811
 
765
812
  # CreateService() error control flags
766
- SERVICE_ERROR_IGNORE = 0x00000000
767
- SERVICE_ERROR_NORMAL = 0x00000001
768
- SERVICE_ERROR_SEVERE = 0x00000002
769
- SERVICE_ERROR_CRITICAL = 0x00000003
813
+ SERVICE_ERROR_IGNORE = 0x00000000
814
+ SERVICE_ERROR_NORMAL = 0x00000001
815
+ SERVICE_ERROR_SEVERE = 0x00000002
816
+ SERVICE_ERROR_CRITICAL = 0x00000003
770
817
 
771
818
  # EnumServicesStatusEx() service state filters
772
- SERVICE_ACTIVE = 1
773
- SERVICE_INACTIVE = 2
819
+ SERVICE_ACTIVE = 1
820
+ SERVICE_INACTIVE = 2
774
821
  SERVICE_STATE_ALL = 3
775
822
 
776
823
  # SERVICE_STATUS_PROCESS.dwServiceType
777
- SERVICE_KERNEL_DRIVER = 0x00000001
778
- SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
779
- SERVICE_ADAPTER = 0x00000004
780
- SERVICE_RECOGNIZER_DRIVER = 0x00000008
781
- SERVICE_WIN32_OWN_PROCESS = 0x00000010
824
+ SERVICE_KERNEL_DRIVER = 0x00000001
825
+ SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
826
+ SERVICE_ADAPTER = 0x00000004
827
+ SERVICE_RECOGNIZER_DRIVER = 0x00000008
828
+ SERVICE_WIN32_OWN_PROCESS = 0x00000010
782
829
  SERVICE_WIN32_SHARE_PROCESS = 0x00000020
783
830
  SERVICE_INTERACTIVE_PROCESS = 0x00000100
784
831
 
785
832
  # EnumServicesStatusEx() service type filters (in addition to actual types)
786
- SERVICE_DRIVER = 0x0000000B # SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER
787
- SERVICE_WIN32 = 0x00000030 # SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS
833
+ SERVICE_DRIVER = 0x0000000B # SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER
834
+ SERVICE_WIN32 = 0x00000030 # SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS
788
835
 
789
836
  # SERVICE_STATUS_PROCESS.dwCurrentState
790
- SERVICE_STOPPED = 0x00000001
791
- SERVICE_START_PENDING = 0x00000002
792
- SERVICE_STOP_PENDING = 0x00000003
793
- SERVICE_RUNNING = 0x00000004
794
- SERVICE_CONTINUE_PENDING = 0x00000005
795
- SERVICE_PAUSE_PENDING = 0x00000006
796
- SERVICE_PAUSED = 0x00000007
837
+ SERVICE_STOPPED = 0x00000001
838
+ SERVICE_START_PENDING = 0x00000002
839
+ SERVICE_STOP_PENDING = 0x00000003
840
+ SERVICE_RUNNING = 0x00000004
841
+ SERVICE_CONTINUE_PENDING = 0x00000005
842
+ SERVICE_PAUSE_PENDING = 0x00000006
843
+ SERVICE_PAUSED = 0x00000007
797
844
 
798
845
  # SERVICE_STATUS_PROCESS.dwControlsAccepted
799
- SERVICE_ACCEPT_STOP = 0x00000001
800
- SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
801
- SERVICE_ACCEPT_SHUTDOWN = 0x00000004
802
- SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
803
- SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
846
+ SERVICE_ACCEPT_STOP = 0x00000001
847
+ SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
848
+ SERVICE_ACCEPT_SHUTDOWN = 0x00000004
849
+ SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
850
+ SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
804
851
  SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020
805
- SERVICE_ACCEPT_POWEREVENT = 0x00000040
806
- SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
807
- SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100
852
+ SERVICE_ACCEPT_POWEREVENT = 0x00000040
853
+ SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
854
+ SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100
808
855
 
809
856
  # SERVICE_STATUS_PROCESS.dwServiceFlags
810
857
  SERVICE_RUNS_IN_SYSTEM_PROCESS = 0x00000001
811
858
 
812
859
  # Service control flags
813
- SERVICE_CONTROL_STOP = 0x00000001
814
- SERVICE_CONTROL_PAUSE = 0x00000002
815
- SERVICE_CONTROL_CONTINUE = 0x00000003
816
- SERVICE_CONTROL_INTERROGATE = 0x00000004
817
- SERVICE_CONTROL_SHUTDOWN = 0x00000005
818
- SERVICE_CONTROL_PARAMCHANGE = 0x00000006
819
- SERVICE_CONTROL_NETBINDADD = 0x00000007
820
- SERVICE_CONTROL_NETBINDREMOVE = 0x00000008
821
- SERVICE_CONTROL_NETBINDENABLE = 0x00000009
822
- SERVICE_CONTROL_NETBINDDISABLE = 0x0000000A
823
- SERVICE_CONTROL_DEVICEEVENT = 0x0000000B
860
+ SERVICE_CONTROL_STOP = 0x00000001
861
+ SERVICE_CONTROL_PAUSE = 0x00000002
862
+ SERVICE_CONTROL_CONTINUE = 0x00000003
863
+ SERVICE_CONTROL_INTERROGATE = 0x00000004
864
+ SERVICE_CONTROL_SHUTDOWN = 0x00000005
865
+ SERVICE_CONTROL_PARAMCHANGE = 0x00000006
866
+ SERVICE_CONTROL_NETBINDADD = 0x00000007
867
+ SERVICE_CONTROL_NETBINDREMOVE = 0x00000008
868
+ SERVICE_CONTROL_NETBINDENABLE = 0x00000009
869
+ SERVICE_CONTROL_NETBINDDISABLE = 0x0000000A
870
+ SERVICE_CONTROL_DEVICEEVENT = 0x0000000B
824
871
  SERVICE_CONTROL_HARDWAREPROFILECHANGE = 0x0000000C
825
- SERVICE_CONTROL_POWEREVENT = 0x0000000D
826
- SERVICE_CONTROL_SESSIONCHANGE = 0x0000000E
872
+ SERVICE_CONTROL_POWEREVENT = 0x0000000D
873
+ SERVICE_CONTROL_SESSIONCHANGE = 0x0000000E
827
874
 
828
875
  # Service control accepted bitmasks
829
- SERVICE_ACCEPT_STOP = 0x00000001
830
- SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
831
- SERVICE_ACCEPT_SHUTDOWN = 0x00000004
832
- SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
833
- SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
876
+ SERVICE_ACCEPT_STOP = 0x00000001
877
+ SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
878
+ SERVICE_ACCEPT_SHUTDOWN = 0x00000004
879
+ SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
880
+ SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
834
881
  SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020
835
- SERVICE_ACCEPT_POWEREVENT = 0x00000040
836
- SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
837
- SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100
838
- SERVICE_ACCEPT_TIMECHANGE = 0x00000200
839
- SERVICE_ACCEPT_TRIGGEREVENT = 0x00000400
840
- SERVICE_ACCEPT_USERMODEREBOOT = 0x00000800
882
+ SERVICE_ACCEPT_POWEREVENT = 0x00000040
883
+ SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
884
+ SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100
885
+ SERVICE_ACCEPT_TIMECHANGE = 0x00000200
886
+ SERVICE_ACCEPT_TRIGGEREVENT = 0x00000400
887
+ SERVICE_ACCEPT_USERMODEREBOOT = 0x00000800
841
888
 
842
889
  # enum SC_ACTION_TYPE
843
- SC_ACTION_NONE = 0
844
- SC_ACTION_RESTART = 1
845
- SC_ACTION_REBOOT = 2
890
+ SC_ACTION_NONE = 0
891
+ SC_ACTION_RESTART = 1
892
+ SC_ACTION_REBOOT = 2
846
893
  SC_ACTION_RUN_COMMAND = 3
847
894
 
848
895
  # QueryServiceConfig2
849
- SERVICE_CONFIG_DESCRIPTION = 1
896
+ SERVICE_CONFIG_DESCRIPTION = 1
850
897
  SERVICE_CONFIG_FAILURE_ACTIONS = 2
851
898
 
899
+
852
900
  # typedef struct _SERVICE_STATUS {
853
901
  # DWORD dwServiceType;
854
902
  # DWORD dwCurrentState;
@@ -860,16 +908,19 @@ SERVICE_CONFIG_FAILURE_ACTIONS = 2
860
908
  # } SERVICE_STATUS, *LPSERVICE_STATUS;
861
909
  class SERVICE_STATUS(Structure):
862
910
  _fields_ = [
863
- ("dwServiceType", DWORD),
864
- ("dwCurrentState", DWORD),
865
- ("dwControlsAccepted", DWORD),
866
- ("dwWin32ExitCode", DWORD),
867
- ("dwServiceSpecificExitCode", DWORD),
868
- ("dwCheckPoint", DWORD),
869
- ("dwWaitHint", DWORD),
911
+ ("dwServiceType", DWORD),
912
+ ("dwCurrentState", DWORD),
913
+ ("dwControlsAccepted", DWORD),
914
+ ("dwWin32ExitCode", DWORD),
915
+ ("dwServiceSpecificExitCode", DWORD),
916
+ ("dwCheckPoint", DWORD),
917
+ ("dwWaitHint", DWORD),
870
918
  ]
919
+
920
+
871
921
  LPSERVICE_STATUS = POINTER(SERVICE_STATUS)
872
922
 
923
+
873
924
  # typedef struct _SERVICE_STATUS_PROCESS {
874
925
  # DWORD dwServiceType;
875
926
  # DWORD dwCurrentState;
@@ -883,11 +934,14 @@ LPSERVICE_STATUS = POINTER(SERVICE_STATUS)
883
934
  # } SERVICE_STATUS_PROCESS, *LPSERVICE_STATUS_PROCESS;
884
935
  class SERVICE_STATUS_PROCESS(Structure):
885
936
  _fields_ = SERVICE_STATUS._fields_ + [
886
- ("dwProcessId", DWORD),
887
- ("dwServiceFlags", DWORD),
937
+ ("dwProcessId", DWORD),
938
+ ("dwServiceFlags", DWORD),
888
939
  ]
940
+
941
+
889
942
  LPSERVICE_STATUS_PROCESS = POINTER(SERVICE_STATUS_PROCESS)
890
943
 
944
+
891
945
  # typedef struct _ENUM_SERVICE_STATUS {
892
946
  # LPTSTR lpServiceName;
893
947
  # LPTSTR lpDisplayName;
@@ -899,15 +953,20 @@ class ENUM_SERVICE_STATUSA(Structure):
899
953
  ("lpDisplayName", LPSTR),
900
954
  ("ServiceStatus", SERVICE_STATUS),
901
955
  ]
956
+
957
+
902
958
  class ENUM_SERVICE_STATUSW(Structure):
903
959
  _fields_ = [
904
960
  ("lpServiceName", LPWSTR),
905
961
  ("lpDisplayName", LPWSTR),
906
962
  ("ServiceStatus", SERVICE_STATUS),
907
963
  ]
964
+
965
+
908
966
  LPENUM_SERVICE_STATUSA = POINTER(ENUM_SERVICE_STATUSA)
909
967
  LPENUM_SERVICE_STATUSW = POINTER(ENUM_SERVICE_STATUSW)
910
968
 
969
+
911
970
  # typedef struct _ENUM_SERVICE_STATUS_PROCESS {
912
971
  # LPTSTR lpServiceName;
913
972
  # LPTSTR lpDisplayName;
@@ -915,19 +974,24 @@ LPENUM_SERVICE_STATUSW = POINTER(ENUM_SERVICE_STATUSW)
915
974
  # } ENUM_SERVICE_STATUS_PROCESS, *LPENUM_SERVICE_STATUS_PROCESS;
916
975
  class ENUM_SERVICE_STATUS_PROCESSA(Structure):
917
976
  _fields_ = [
918
- ("lpServiceName", LPSTR),
919
- ("lpDisplayName", LPSTR),
977
+ ("lpServiceName", LPSTR),
978
+ ("lpDisplayName", LPSTR),
920
979
  ("ServiceStatusProcess", SERVICE_STATUS_PROCESS),
921
980
  ]
981
+
982
+
922
983
  class ENUM_SERVICE_STATUS_PROCESSW(Structure):
923
984
  _fields_ = [
924
- ("lpServiceName", LPWSTR),
925
- ("lpDisplayName", LPWSTR),
985
+ ("lpServiceName", LPWSTR),
986
+ ("lpDisplayName", LPWSTR),
926
987
  ("ServiceStatusProcess", SERVICE_STATUS_PROCESS),
927
988
  ]
989
+
990
+
928
991
  LPENUM_SERVICE_STATUS_PROCESSA = POINTER(ENUM_SERVICE_STATUS_PROCESSA)
929
992
  LPENUM_SERVICE_STATUS_PROCESSW = POINTER(ENUM_SERVICE_STATUS_PROCESSW)
930
993
 
994
+
931
995
  class ServiceStatus(object):
932
996
  """
933
997
  Wrapper for the L{SERVICE_STATUS} structure.
@@ -938,13 +1002,14 @@ class ServiceStatus(object):
938
1002
  @type raw: L{SERVICE_STATUS}
939
1003
  @param raw: Raw structure for this service status data.
940
1004
  """
941
- self.ServiceType = raw.dwServiceType
942
- self.CurrentState = raw.dwCurrentState
943
- self.ControlsAccepted = raw.dwControlsAccepted
944
- self.Win32ExitCode = raw.dwWin32ExitCode
1005
+ self.ServiceType = raw.dwServiceType
1006
+ self.CurrentState = raw.dwCurrentState
1007
+ self.ControlsAccepted = raw.dwControlsAccepted
1008
+ self.Win32ExitCode = raw.dwWin32ExitCode
945
1009
  self.ServiceSpecificExitCode = raw.dwServiceSpecificExitCode
946
- self.CheckPoint = raw.dwCheckPoint
947
- self.WaitHint = raw.dwWaitHint
1010
+ self.CheckPoint = raw.dwCheckPoint
1011
+ self.WaitHint = raw.dwWaitHint
1012
+
948
1013
 
949
1014
  class ServiceStatusProcess(object):
950
1015
  """
@@ -956,15 +1021,16 @@ class ServiceStatusProcess(object):
956
1021
  @type raw: L{SERVICE_STATUS_PROCESS}
957
1022
  @param raw: Raw structure for this service status data.
958
1023
  """
959
- self.ServiceType = raw.dwServiceType
960
- self.CurrentState = raw.dwCurrentState
961
- self.ControlsAccepted = raw.dwControlsAccepted
962
- self.Win32ExitCode = raw.dwWin32ExitCode
1024
+ self.ServiceType = raw.dwServiceType
1025
+ self.CurrentState = raw.dwCurrentState
1026
+ self.ControlsAccepted = raw.dwControlsAccepted
1027
+ self.Win32ExitCode = raw.dwWin32ExitCode
963
1028
  self.ServiceSpecificExitCode = raw.dwServiceSpecificExitCode
964
- self.CheckPoint = raw.dwCheckPoint
965
- self.WaitHint = raw.dwWaitHint
966
- self.ProcessId = raw.dwProcessId
967
- self.ServiceFlags = raw.dwServiceFlags
1029
+ self.CheckPoint = raw.dwCheckPoint
1030
+ self.WaitHint = raw.dwWaitHint
1031
+ self.ProcessId = raw.dwProcessId
1032
+ self.ServiceFlags = raw.dwServiceFlags
1033
+
968
1034
 
969
1035
  class ServiceStatusEntry(object):
970
1036
  """
@@ -976,15 +1042,15 @@ class ServiceStatusEntry(object):
976
1042
  @type raw: L{ENUM_SERVICE_STATUSA} or L{ENUM_SERVICE_STATUSW}
977
1043
  @param raw: Raw structure for this service status entry.
978
1044
  """
979
- self.ServiceName = raw.lpServiceName
980
- self.DisplayName = raw.lpDisplayName
981
- self.ServiceType = raw.ServiceStatus.dwServiceType
982
- self.CurrentState = raw.ServiceStatus.dwCurrentState
983
- self.ControlsAccepted = raw.ServiceStatus.dwControlsAccepted
984
- self.Win32ExitCode = raw.ServiceStatus.dwWin32ExitCode
1045
+ self.ServiceName = raw.lpServiceName
1046
+ self.DisplayName = raw.lpDisplayName
1047
+ self.ServiceType = raw.ServiceStatus.dwServiceType
1048
+ self.CurrentState = raw.ServiceStatus.dwCurrentState
1049
+ self.ControlsAccepted = raw.ServiceStatus.dwControlsAccepted
1050
+ self.Win32ExitCode = raw.ServiceStatus.dwWin32ExitCode
985
1051
  self.ServiceSpecificExitCode = raw.ServiceStatus.dwServiceSpecificExitCode
986
- self.CheckPoint = raw.ServiceStatus.dwCheckPoint
987
- self.WaitHint = raw.ServiceStatus.dwWaitHint
1052
+ self.CheckPoint = raw.ServiceStatus.dwCheckPoint
1053
+ self.WaitHint = raw.ServiceStatus.dwWaitHint
988
1054
 
989
1055
  def __str__(self):
990
1056
  output = []
@@ -993,10 +1059,10 @@ class ServiceStatusEntry(object):
993
1059
  else:
994
1060
  output.append("Service")
995
1061
  if self.DisplayName:
996
- output.append("\"%s\" (%s)" % (self.DisplayName, self.ServiceName))
1062
+ output.append('"%s" (%s)' % (self.DisplayName, self.ServiceName))
997
1063
  else:
998
- output.append("\"%s\"" % self.ServiceName)
999
- if self.CurrentState == SERVICE_CONTINUE_PENDING:
1064
+ output.append('"%s"' % self.ServiceName)
1065
+ if self.CurrentState == SERVICE_CONTINUE_PENDING:
1000
1066
  output.append("is about to continue.")
1001
1067
  elif self.CurrentState == SERVICE_PAUSE_PENDING:
1002
1068
  output.append("is pausing.")
@@ -1012,6 +1078,7 @@ class ServiceStatusEntry(object):
1012
1078
  output.append("is stopped.")
1013
1079
  return " ".join(output)
1014
1080
 
1081
+
1015
1082
  class ServiceStatusProcessEntry(object):
1016
1083
  """
1017
1084
  Service status entry returned by L{EnumServicesStatusEx}.
@@ -1022,17 +1089,17 @@ class ServiceStatusProcessEntry(object):
1022
1089
  @type raw: L{ENUM_SERVICE_STATUS_PROCESSA} or L{ENUM_SERVICE_STATUS_PROCESSW}
1023
1090
  @param raw: Raw structure for this service status entry.
1024
1091
  """
1025
- self.ServiceName = raw.lpServiceName
1026
- self.DisplayName = raw.lpDisplayName
1027
- self.ServiceType = raw.ServiceStatusProcess.dwServiceType
1028
- self.CurrentState = raw.ServiceStatusProcess.dwCurrentState
1029
- self.ControlsAccepted = raw.ServiceStatusProcess.dwControlsAccepted
1030
- self.Win32ExitCode = raw.ServiceStatusProcess.dwWin32ExitCode
1092
+ self.ServiceName = raw.lpServiceName
1093
+ self.DisplayName = raw.lpDisplayName
1094
+ self.ServiceType = raw.ServiceStatusProcess.dwServiceType
1095
+ self.CurrentState = raw.ServiceStatusProcess.dwCurrentState
1096
+ self.ControlsAccepted = raw.ServiceStatusProcess.dwControlsAccepted
1097
+ self.Win32ExitCode = raw.ServiceStatusProcess.dwWin32ExitCode
1031
1098
  self.ServiceSpecificExitCode = raw.ServiceStatusProcess.dwServiceSpecificExitCode
1032
- self.CheckPoint = raw.ServiceStatusProcess.dwCheckPoint
1033
- self.WaitHint = raw.ServiceStatusProcess.dwWaitHint
1034
- self.ProcessId = raw.ServiceStatusProcess.dwProcessId
1035
- self.ServiceFlags = raw.ServiceStatusProcess.dwServiceFlags
1099
+ self.CheckPoint = raw.ServiceStatusProcess.dwCheckPoint
1100
+ self.WaitHint = raw.ServiceStatusProcess.dwWaitHint
1101
+ self.ProcessId = raw.ServiceStatusProcess.dwProcessId
1102
+ self.ServiceFlags = raw.ServiceStatusProcess.dwServiceFlags
1036
1103
 
1037
1104
  def __str__(self):
1038
1105
  output = []
@@ -1041,10 +1108,10 @@ class ServiceStatusProcessEntry(object):
1041
1108
  else:
1042
1109
  output.append("Service ")
1043
1110
  if self.DisplayName:
1044
- output.append("\"%s\" (%s)" % (self.DisplayName, self.ServiceName))
1111
+ output.append('"%s" (%s)' % (self.DisplayName, self.ServiceName))
1045
1112
  else:
1046
- output.append("\"%s\"" % self.ServiceName)
1047
- if self.CurrentState == SERVICE_CONTINUE_PENDING:
1113
+ output.append('"%s"' % self.ServiceName)
1114
+ if self.CurrentState == SERVICE_CONTINUE_PENDING:
1048
1115
  output.append(" is about to continue")
1049
1116
  elif self.CurrentState == SERVICE_PAUSE_PENDING:
1050
1117
  output.append(" is pausing")
@@ -1063,18 +1130,22 @@ class ServiceStatusProcessEntry(object):
1063
1130
  output.append(".")
1064
1131
  return "".join(output)
1065
1132
 
1066
- #--- Handle wrappers ----------------------------------------------------------
1133
+
1134
+ # --- Handle wrappers ----------------------------------------------------------
1135
+
1067
1136
 
1068
1137
  # XXX maybe add functions related to the tokens here?
1069
- class TokenHandle (Handle):
1138
+ class TokenHandle(Handle):
1070
1139
  """
1071
1140
  Access token handle.
1072
1141
 
1073
1142
  @see: L{Handle}
1074
1143
  """
1144
+
1075
1145
  pass
1076
1146
 
1077
- class RegistryKeyHandle (UserModeHandle):
1147
+
1148
+ class RegistryKeyHandle(UserModeHandle):
1078
1149
  """
1079
1150
  Registry key handle.
1080
1151
  """
@@ -1084,7 +1155,8 @@ class RegistryKeyHandle (UserModeHandle):
1084
1155
  def _close(self):
1085
1156
  RegCloseKey(self.value)
1086
1157
 
1087
- class SaferLevelHandle (UserModeHandle):
1158
+
1159
+ class SaferLevelHandle(UserModeHandle):
1088
1160
  """
1089
1161
  Safer level handle.
1090
1162
 
@@ -1096,7 +1168,8 @@ class SaferLevelHandle (UserModeHandle):
1096
1168
  def _close(self):
1097
1169
  SaferCloseLevel(self.value)
1098
1170
 
1099
- class ServiceHandle (UserModeHandle):
1171
+
1172
+ class ServiceHandle(UserModeHandle):
1100
1173
  """
1101
1174
  Service handle.
1102
1175
 
@@ -1108,7 +1181,8 @@ class ServiceHandle (UserModeHandle):
1108
1181
  def _close(self):
1109
1182
  CloseServiceHandle(self.value)
1110
1183
 
1111
- class ServiceControlManagerHandle (UserModeHandle):
1184
+
1185
+ class ServiceControlManagerHandle(UserModeHandle):
1112
1186
  """
1113
1187
  Service Control Manager (SCM) handle.
1114
1188
 
@@ -1120,7 +1194,9 @@ class ServiceControlManagerHandle (UserModeHandle):
1120
1194
  def _close(self):
1121
1195
  CloseServiceHandle(self.value)
1122
1196
 
1123
- #--- advapi32.dll -------------------------------------------------------------
1197
+
1198
+ # --- advapi32.dll -------------------------------------------------------------
1199
+
1124
1200
 
1125
1201
  # BOOL WINAPI GetUserName(
1126
1202
  # __out LPTSTR lpBuffer,
@@ -1129,35 +1205,37 @@ class ServiceControlManagerHandle (UserModeHandle):
1129
1205
  def GetUserNameA():
1130
1206
  _GetUserNameA = windll.advapi32.GetUserNameA
1131
1207
  _GetUserNameA.argtypes = [LPSTR, LPDWORD]
1132
- _GetUserNameA.restype = bool
1208
+ _GetUserNameA.restype = bool
1133
1209
 
1134
1210
  nSize = DWORD(0)
1135
1211
  _GetUserNameA(None, byref(nSize))
1136
1212
  error = GetLastError()
1137
1213
  if error != ERROR_INSUFFICIENT_BUFFER:
1138
1214
  raise ctypes.WinError(error)
1139
- lpBuffer = ctypes.create_string_buffer('', nSize.value + 1)
1215
+ lpBuffer = ctypes.create_string_buffer("", nSize.value + 1)
1140
1216
  success = _GetUserNameA(lpBuffer, byref(nSize))
1141
1217
  if not success:
1142
1218
  raise ctypes.WinError()
1143
1219
  return lpBuffer.value
1144
1220
 
1221
+
1145
1222
  def GetUserNameW():
1146
1223
  _GetUserNameW = windll.advapi32.GetUserNameW
1147
1224
  _GetUserNameW.argtypes = [LPWSTR, LPDWORD]
1148
- _GetUserNameW.restype = bool
1225
+ _GetUserNameW.restype = bool
1149
1226
 
1150
1227
  nSize = DWORD(0)
1151
1228
  _GetUserNameW(None, byref(nSize))
1152
1229
  error = GetLastError()
1153
1230
  if error != ERROR_INSUFFICIENT_BUFFER:
1154
1231
  raise ctypes.WinError(error)
1155
- lpBuffer = ctypes.create_unicode_buffer(u'', nSize.value + 1)
1232
+ lpBuffer = ctypes.create_unicode_buffer("", nSize.value + 1)
1156
1233
  success = _GetUserNameW(lpBuffer, byref(nSize))
1157
1234
  if not success:
1158
1235
  raise ctypes.WinError()
1159
1236
  return lpBuffer.value
1160
1237
 
1238
+
1161
1239
  GetUserName = DefaultStringType(GetUserNameA, GetUserNameW)
1162
1240
 
1163
1241
  # BOOL WINAPI LookupAccountName(
@@ -1172,6 +1250,7 @@ GetUserName = DefaultStringType(GetUserNameA, GetUserNameW)
1172
1250
 
1173
1251
  # XXX TO DO
1174
1252
 
1253
+
1175
1254
  # BOOL WINAPI LookupAccountSid(
1176
1255
  # __in_opt LPCTSTR lpSystemName,
1177
1256
  # __in PSID lpSid,
@@ -1184,7 +1263,7 @@ GetUserName = DefaultStringType(GetUserNameA, GetUserNameW)
1184
1263
  def LookupAccountSidA(lpSystemName, lpSid):
1185
1264
  _LookupAccountSidA = windll.advapi32.LookupAccountSidA
1186
1265
  _LookupAccountSidA.argtypes = [LPSTR, PSID, LPSTR, LPDWORD, LPSTR, LPDWORD, LPDWORD]
1187
- _LookupAccountSidA.restype = bool
1266
+ _LookupAccountSidA.restype = bool
1188
1267
 
1189
1268
  cchName = DWORD(0)
1190
1269
  cchReferencedDomainName = DWORD(0)
@@ -1193,17 +1272,20 @@ def LookupAccountSidA(lpSystemName, lpSid):
1193
1272
  error = GetLastError()
1194
1273
  if error != ERROR_INSUFFICIENT_BUFFER:
1195
1274
  raise ctypes.WinError(error)
1196
- lpName = ctypes.create_string_buffer('', cchName + 1)
1197
- lpReferencedDomainName = ctypes.create_string_buffer('', cchReferencedDomainName + 1)
1198
- success = _LookupAccountSidA(lpSystemName, lpSid, lpName, byref(cchName), lpReferencedDomainName, byref(cchReferencedDomainName), byref(peUse))
1275
+ lpName = ctypes.create_string_buffer("", cchName + 1)
1276
+ lpReferencedDomainName = ctypes.create_string_buffer("", cchReferencedDomainName + 1)
1277
+ success = _LookupAccountSidA(
1278
+ lpSystemName, lpSid, lpName, byref(cchName), lpReferencedDomainName, byref(cchReferencedDomainName), byref(peUse)
1279
+ )
1199
1280
  if not success:
1200
1281
  raise ctypes.WinError()
1201
1282
  return lpName.value, lpReferencedDomainName.value, peUse.value
1202
1283
 
1284
+
1203
1285
  def LookupAccountSidW(lpSystemName, lpSid):
1204
1286
  _LookupAccountSidW = windll.advapi32.LookupAccountSidA
1205
1287
  _LookupAccountSidW.argtypes = [LPSTR, PSID, LPWSTR, LPDWORD, LPWSTR, LPDWORD, LPDWORD]
1206
- _LookupAccountSidW.restype = bool
1288
+ _LookupAccountSidW.restype = bool
1207
1289
 
1208
1290
  cchName = DWORD(0)
1209
1291
  cchReferencedDomainName = DWORD(0)
@@ -1212,15 +1294,19 @@ def LookupAccountSidW(lpSystemName, lpSid):
1212
1294
  error = GetLastError()
1213
1295
  if error != ERROR_INSUFFICIENT_BUFFER:
1214
1296
  raise ctypes.WinError(error)
1215
- lpName = ctypes.create_unicode_buffer(u'', cchName + 1)
1216
- lpReferencedDomainName = ctypes.create_unicode_buffer(u'', cchReferencedDomainName + 1)
1217
- success = _LookupAccountSidW(lpSystemName, lpSid, lpName, byref(cchName), lpReferencedDomainName, byref(cchReferencedDomainName), byref(peUse))
1297
+ lpName = ctypes.create_unicode_buffer("", cchName + 1)
1298
+ lpReferencedDomainName = ctypes.create_unicode_buffer("", cchReferencedDomainName + 1)
1299
+ success = _LookupAccountSidW(
1300
+ lpSystemName, lpSid, lpName, byref(cchName), lpReferencedDomainName, byref(cchReferencedDomainName), byref(peUse)
1301
+ )
1218
1302
  if not success:
1219
1303
  raise ctypes.WinError()
1220
1304
  return lpName.value, lpReferencedDomainName.value, peUse.value
1221
1305
 
1306
+
1222
1307
  LookupAccountSid = GuessStringType(LookupAccountSidA, LookupAccountSidW)
1223
1308
 
1309
+
1224
1310
  # BOOL ConvertSidToStringSid(
1225
1311
  # __in PSID Sid,
1226
1312
  # __out LPTSTR *StringSid
@@ -1228,7 +1314,7 @@ LookupAccountSid = GuessStringType(LookupAccountSidA, LookupAccountSidW)
1228
1314
  def ConvertSidToStringSidA(Sid):
1229
1315
  _ConvertSidToStringSidA = windll.advapi32.ConvertSidToStringSidA
1230
1316
  _ConvertSidToStringSidA.argtypes = [PSID, LPSTR]
1231
- _ConvertSidToStringSidA.restype = bool
1317
+ _ConvertSidToStringSidA.restype = bool
1232
1318
  _ConvertSidToStringSidA.errcheck = RaiseIfZero
1233
1319
 
1234
1320
  pStringSid = LPSTR()
@@ -1239,10 +1325,11 @@ def ConvertSidToStringSidA(Sid):
1239
1325
  LocalFree(pStringSid)
1240
1326
  return StringSid
1241
1327
 
1328
+
1242
1329
  def ConvertSidToStringSidW(Sid):
1243
1330
  _ConvertSidToStringSidW = windll.advapi32.ConvertSidToStringSidW
1244
1331
  _ConvertSidToStringSidW.argtypes = [PSID, LPWSTR]
1245
- _ConvertSidToStringSidW.restype = bool
1332
+ _ConvertSidToStringSidW.restype = bool
1246
1333
  _ConvertSidToStringSidW.errcheck = RaiseIfZero
1247
1334
 
1248
1335
  pStringSid = LPWSTR()
@@ -1253,8 +1340,10 @@ def ConvertSidToStringSidW(Sid):
1253
1340
  LocalFree(pStringSid)
1254
1341
  return StringSid
1255
1342
 
1343
+
1256
1344
  ConvertSidToStringSid = DefaultStringType(ConvertSidToStringSidA, ConvertSidToStringSidW)
1257
1345
 
1346
+
1258
1347
  # BOOL WINAPI ConvertStringSidToSid(
1259
1348
  # __in LPCTSTR StringSid,
1260
1349
  # __out PSID *Sid
@@ -1262,34 +1351,38 @@ ConvertSidToStringSid = DefaultStringType(ConvertSidToStringSidA, ConvertSidToSt
1262
1351
  def ConvertStringSidToSidA(StringSid):
1263
1352
  _ConvertStringSidToSidA = windll.advapi32.ConvertStringSidToSidA
1264
1353
  _ConvertStringSidToSidA.argtypes = [LPSTR, PVOID]
1265
- _ConvertStringSidToSidA.restype = bool
1354
+ _ConvertStringSidToSidA.restype = bool
1266
1355
  _ConvertStringSidToSidA.errcheck = RaiseIfZero
1267
1356
 
1268
1357
  Sid = PVOID()
1269
1358
  _ConvertStringSidToSidA(StringSid, ctypes.pointer(Sid))
1270
1359
  return Sid.value
1271
1360
 
1361
+
1272
1362
  def ConvertStringSidToSidW(StringSid):
1273
1363
  _ConvertStringSidToSidW = windll.advapi32.ConvertStringSidToSidW
1274
1364
  _ConvertStringSidToSidW.argtypes = [LPWSTR, PVOID]
1275
- _ConvertStringSidToSidW.restype = bool
1365
+ _ConvertStringSidToSidW.restype = bool
1276
1366
  _ConvertStringSidToSidW.errcheck = RaiseIfZero
1277
1367
 
1278
1368
  Sid = PVOID()
1279
1369
  _ConvertStringSidToSidW(StringSid, ctypes.pointer(Sid))
1280
1370
  return Sid.value
1281
1371
 
1372
+
1282
1373
  ConvertStringSidToSid = GuessStringType(ConvertStringSidToSidA, ConvertStringSidToSidW)
1283
1374
 
1375
+
1284
1376
  # BOOL WINAPI IsValidSid(
1285
1377
  # __in PSID pSid
1286
1378
  # );
1287
1379
  def IsValidSid(pSid):
1288
1380
  _IsValidSid = windll.advapi32.IsValidSid
1289
1381
  _IsValidSid.argtypes = [PSID]
1290
- _IsValidSid.restype = bool
1382
+ _IsValidSid.restype = bool
1291
1383
  return _IsValidSid(pSid)
1292
1384
 
1385
+
1293
1386
  # BOOL WINAPI EqualSid(
1294
1387
  # __in PSID pSid1,
1295
1388
  # __in PSID pSid2
@@ -1297,18 +1390,20 @@ def IsValidSid(pSid):
1297
1390
  def EqualSid(pSid1, pSid2):
1298
1391
  _EqualSid = windll.advapi32.EqualSid
1299
1392
  _EqualSid.argtypes = [PSID, PSID]
1300
- _EqualSid.restype = bool
1393
+ _EqualSid.restype = bool
1301
1394
  return _EqualSid(pSid1, pSid2)
1302
1395
 
1396
+
1303
1397
  # DWORD WINAPI GetLengthSid(
1304
1398
  # __in PSID pSid
1305
1399
  # );
1306
1400
  def GetLengthSid(pSid):
1307
1401
  _GetLengthSid = windll.advapi32.GetLengthSid
1308
1402
  _GetLengthSid.argtypes = [PSID]
1309
- _GetLengthSid.restype = DWORD
1403
+ _GetLengthSid.restype = DWORD
1310
1404
  return _GetLengthSid(pSid)
1311
1405
 
1406
+
1312
1407
  # BOOL WINAPI CopySid(
1313
1408
  # __in DWORD nDestinationSidLength,
1314
1409
  # __out PSID pDestinationSid,
@@ -1317,71 +1412,76 @@ def GetLengthSid(pSid):
1317
1412
  def CopySid(pSourceSid):
1318
1413
  _CopySid = windll.advapi32.CopySid
1319
1414
  _CopySid.argtypes = [DWORD, PVOID, PSID]
1320
- _CopySid.restype = bool
1415
+ _CopySid.restype = bool
1321
1416
  _CopySid.errcheck = RaiseIfZero
1322
1417
 
1323
1418
  nDestinationSidLength = GetLengthSid(pSourceSid)
1324
- DestinationSid = ctypes.create_string_buffer('', nDestinationSidLength)
1419
+ DestinationSid = ctypes.create_string_buffer("", nDestinationSidLength)
1325
1420
  pDestinationSid = ctypes.cast(ctypes.pointer(DestinationSid), PVOID)
1326
1421
  _CopySid(nDestinationSidLength, pDestinationSid, pSourceSid)
1327
1422
  return ctypes.cast(pDestinationSid, PSID)
1328
1423
 
1424
+
1329
1425
  # PVOID WINAPI FreeSid(
1330
1426
  # __in PSID pSid
1331
1427
  # );
1332
1428
  def FreeSid(pSid):
1333
1429
  _FreeSid = windll.advapi32.FreeSid
1334
1430
  _FreeSid.argtypes = [PSID]
1335
- _FreeSid.restype = PSID
1431
+ _FreeSid.restype = PSID
1336
1432
  _FreeSid.errcheck = RaiseIfNotZero
1337
1433
  _FreeSid(pSid)
1338
1434
 
1435
+
1339
1436
  # BOOL WINAPI OpenProcessToken(
1340
1437
  # __in HANDLE ProcessHandle,
1341
1438
  # __in DWORD DesiredAccess,
1342
1439
  # __out PHANDLE TokenHandle
1343
1440
  # );
1344
- def OpenProcessToken(ProcessHandle, DesiredAccess = TOKEN_ALL_ACCESS):
1441
+ def OpenProcessToken(ProcessHandle, DesiredAccess=TOKEN_ALL_ACCESS):
1345
1442
  _OpenProcessToken = windll.advapi32.OpenProcessToken
1346
1443
  _OpenProcessToken.argtypes = [HANDLE, DWORD, PHANDLE]
1347
- _OpenProcessToken.restype = bool
1444
+ _OpenProcessToken.restype = bool
1348
1445
  _OpenProcessToken.errcheck = RaiseIfZero
1349
1446
 
1350
1447
  NewTokenHandle = HANDLE(INVALID_HANDLE_VALUE)
1351
1448
  _OpenProcessToken(ProcessHandle, DesiredAccess, byref(NewTokenHandle))
1352
1449
  return TokenHandle(NewTokenHandle.value)
1353
1450
 
1451
+
1354
1452
  # BOOL WINAPI OpenThreadToken(
1355
1453
  # __in HANDLE ThreadHandle,
1356
1454
  # __in DWORD DesiredAccess,
1357
1455
  # __in BOOL OpenAsSelf,
1358
1456
  # __out PHANDLE TokenHandle
1359
1457
  # );
1360
- def OpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf = True):
1458
+ def OpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf=True):
1361
1459
  _OpenThreadToken = windll.advapi32.OpenThreadToken
1362
1460
  _OpenThreadToken.argtypes = [HANDLE, DWORD, BOOL, PHANDLE]
1363
- _OpenThreadToken.restype = bool
1461
+ _OpenThreadToken.restype = bool
1364
1462
  _OpenThreadToken.errcheck = RaiseIfZero
1365
1463
 
1366
1464
  NewTokenHandle = HANDLE(INVALID_HANDLE_VALUE)
1367
1465
  _OpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, byref(NewTokenHandle))
1368
1466
  return TokenHandle(NewTokenHandle.value)
1369
1467
 
1468
+
1370
1469
  # BOOL WINAPI DuplicateToken(
1371
1470
  # _In_ HANDLE ExistingTokenHandle,
1372
1471
  # _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
1373
1472
  # _Out_ PHANDLE DuplicateTokenHandle
1374
1473
  # );
1375
- def DuplicateToken(ExistingTokenHandle, ImpersonationLevel = SecurityImpersonation):
1474
+ def DuplicateToken(ExistingTokenHandle, ImpersonationLevel=SecurityImpersonation):
1376
1475
  _DuplicateToken = windll.advapi32.DuplicateToken
1377
1476
  _DuplicateToken.argtypes = [HANDLE, SECURITY_IMPERSONATION_LEVEL, PHANDLE]
1378
- _DuplicateToken.restype = bool
1477
+ _DuplicateToken.restype = bool
1379
1478
  _DuplicateToken.errcheck = RaiseIfZero
1380
1479
 
1381
1480
  DuplicateTokenHandle = HANDLE(INVALID_HANDLE_VALUE)
1382
1481
  _DuplicateToken(ExistingTokenHandle, ImpersonationLevel, byref(DuplicateTokenHandle))
1383
1482
  return TokenHandle(DuplicateTokenHandle.value)
1384
1483
 
1484
+
1385
1485
  # BOOL WINAPI DuplicateTokenEx(
1386
1486
  # _In_ HANDLE hExistingToken,
1387
1487
  # _In_ DWORD dwDesiredAccess,
@@ -1390,28 +1490,36 @@ def DuplicateToken(ExistingTokenHandle, ImpersonationLevel = SecurityImpersonati
1390
1490
  # _In_ TOKEN_TYPE TokenType,
1391
1491
  # _Out_ PHANDLE phNewToken
1392
1492
  # );
1393
- def DuplicateTokenEx(hExistingToken, dwDesiredAccess = TOKEN_ALL_ACCESS, lpTokenAttributes = None, ImpersonationLevel = SecurityImpersonation, TokenType = TokenPrimary):
1493
+ def DuplicateTokenEx(
1494
+ hExistingToken,
1495
+ dwDesiredAccess=TOKEN_ALL_ACCESS,
1496
+ lpTokenAttributes=None,
1497
+ ImpersonationLevel=SecurityImpersonation,
1498
+ TokenType=TokenPrimary,
1499
+ ):
1394
1500
  _DuplicateTokenEx = windll.advapi32.DuplicateTokenEx
1395
1501
  _DuplicateTokenEx.argtypes = [HANDLE, DWORD, LPSECURITY_ATTRIBUTES, SECURITY_IMPERSONATION_LEVEL, TOKEN_TYPE, PHANDLE]
1396
- _DuplicateTokenEx.restype = bool
1502
+ _DuplicateTokenEx.restype = bool
1397
1503
  _DuplicateTokenEx.errcheck = RaiseIfZero
1398
1504
 
1399
1505
  DuplicateTokenHandle = HANDLE(INVALID_HANDLE_VALUE)
1400
1506
  _DuplicateTokenEx(hExistingToken, dwDesiredAccess, lpTokenAttributes, ImpersonationLevel, TokenType, byref(DuplicateTokenHandle))
1401
1507
  return TokenHandle(DuplicateTokenHandle.value)
1402
1508
 
1509
+
1403
1510
  # BOOL WINAPI IsTokenRestricted(
1404
1511
  # __in HANDLE TokenHandle
1405
1512
  # );
1406
1513
  def IsTokenRestricted(hTokenHandle):
1407
1514
  _IsTokenRestricted = windll.advapi32.IsTokenRestricted
1408
1515
  _IsTokenRestricted.argtypes = [HANDLE]
1409
- _IsTokenRestricted.restype = bool
1516
+ _IsTokenRestricted.restype = bool
1410
1517
  _IsTokenRestricted.errcheck = RaiseIfNotErrorSuccess
1411
1518
 
1412
1519
  SetLastError(ERROR_SUCCESS)
1413
1520
  return _IsTokenRestricted(hTokenHandle)
1414
1521
 
1522
+
1415
1523
  # BOOL WINAPI LookupPrivilegeValue(
1416
1524
  # __in_opt LPCTSTR lpSystemName,
1417
1525
  # __in LPCTSTR lpName,
@@ -1420,7 +1528,7 @@ def IsTokenRestricted(hTokenHandle):
1420
1528
  def LookupPrivilegeValueA(lpSystemName, lpName):
1421
1529
  _LookupPrivilegeValueA = windll.advapi32.LookupPrivilegeValueA
1422
1530
  _LookupPrivilegeValueA.argtypes = [LPSTR, LPSTR, PLUID]
1423
- _LookupPrivilegeValueA.restype = bool
1531
+ _LookupPrivilegeValueA.restype = bool
1424
1532
  _LookupPrivilegeValueA.errcheck = RaiseIfZero
1425
1533
 
1426
1534
  lpLuid = LUID()
@@ -1429,10 +1537,11 @@ def LookupPrivilegeValueA(lpSystemName, lpName):
1429
1537
  _LookupPrivilegeValueA(lpSystemName, lpName, byref(lpLuid))
1430
1538
  return lpLuid
1431
1539
 
1540
+
1432
1541
  def LookupPrivilegeValueW(lpSystemName, lpName):
1433
1542
  _LookupPrivilegeValueW = windll.advapi32.LookupPrivilegeValueW
1434
1543
  _LookupPrivilegeValueW.argtypes = [LPWSTR, LPWSTR, PLUID]
1435
- _LookupPrivilegeValueW.restype = bool
1544
+ _LookupPrivilegeValueW.restype = bool
1436
1545
  _LookupPrivilegeValueW.errcheck = RaiseIfZero
1437
1546
 
1438
1547
  lpLuid = LUID()
@@ -1441,6 +1550,7 @@ def LookupPrivilegeValueW(lpSystemName, lpName):
1441
1550
  _LookupPrivilegeValueW(lpSystemName, lpName, byref(lpLuid))
1442
1551
  return lpLuid
1443
1552
 
1553
+
1444
1554
  LookupPrivilegeValue = GuessStringType(LookupPrivilegeValueA, LookupPrivilegeValueW)
1445
1555
 
1446
1556
  # BOOL WINAPI LookupPrivilegeName(
@@ -1450,10 +1560,11 @@ LookupPrivilegeValue = GuessStringType(LookupPrivilegeValueA, LookupPrivilegeVal
1450
1560
  # __inout LPDWORD cchName
1451
1561
  # );
1452
1562
 
1563
+
1453
1564
  def LookupPrivilegeNameA(lpSystemName, lpLuid):
1454
1565
  _LookupPrivilegeNameA = windll.advapi32.LookupPrivilegeNameA
1455
1566
  _LookupPrivilegeNameA.argtypes = [LPSTR, PLUID, LPSTR, LPDWORD]
1456
- _LookupPrivilegeNameA.restype = bool
1567
+ _LookupPrivilegeNameA.restype = bool
1457
1568
  _LookupPrivilegeNameA.errcheck = RaiseIfZero
1458
1569
 
1459
1570
  cchName = DWORD(0)
@@ -1462,20 +1573,23 @@ def LookupPrivilegeNameA(lpSystemName, lpLuid):
1462
1573
  _LookupPrivilegeNameA(lpSystemName, byref(lpLuid), byref(lpName), byref(cchName))
1463
1574
  return lpName.value
1464
1575
 
1576
+
1465
1577
  def LookupPrivilegeNameW(lpSystemName, lpLuid):
1466
1578
  _LookupPrivilegeNameW = windll.advapi32.LookupPrivilegeNameW
1467
1579
  _LookupPrivilegeNameW.argtypes = [LPWSTR, PLUID, LPWSTR, LPDWORD]
1468
- _LookupPrivilegeNameW.restype = bool
1580
+ _LookupPrivilegeNameW.restype = bool
1469
1581
  _LookupPrivilegeNameW.errcheck = RaiseIfZero
1470
1582
 
1471
1583
  cchName = DWORD(0)
1472
1584
  _LookupPrivilegeNameW(lpSystemName, byref(lpLuid), NULL, byref(cchName))
1473
- lpName = ctypes.create_unicode_buffer(u"", cchName.value)
1585
+ lpName = ctypes.create_unicode_buffer("", cchName.value)
1474
1586
  _LookupPrivilegeNameW(lpSystemName, byref(lpLuid), byref(lpName), byref(cchName))
1475
1587
  return lpName.value
1476
1588
 
1589
+
1477
1590
  LookupPrivilegeName = GuessStringType(LookupPrivilegeNameA, LookupPrivilegeNameW)
1478
1591
 
1592
+
1479
1593
  # BOOL WINAPI AdjustTokenPrivileges(
1480
1594
  # __in HANDLE TokenHandle,
1481
1595
  # __in BOOL DisableAllPrivileges,
@@ -1484,10 +1598,10 @@ LookupPrivilegeName = GuessStringType(LookupPrivilegeNameA, LookupPrivilegeNameW
1484
1598
  # __out_opt PTOKEN_PRIVILEGES PreviousState,
1485
1599
  # __out_opt PDWORD ReturnLength
1486
1600
  # );
1487
- def AdjustTokenPrivileges(TokenHandle, NewState = ()):
1601
+ def AdjustTokenPrivileges(TokenHandle, NewState=()):
1488
1602
  _AdjustTokenPrivileges = windll.advapi32.AdjustTokenPrivileges
1489
1603
  _AdjustTokenPrivileges.argtypes = [HANDLE, BOOL, LPVOID, DWORD, LPVOID, LPVOID]
1490
- _AdjustTokenPrivileges.restype = bool
1604
+ _AdjustTokenPrivileges.restype = bool
1491
1605
  _AdjustTokenPrivileges.errcheck = RaiseIfZero
1492
1606
  #
1493
1607
  # I don't know how to allocate variable sized structures in ctypes :(
@@ -1500,7 +1614,7 @@ def AdjustTokenPrivileges(TokenHandle, NewState = ()):
1500
1614
  _AdjustTokenPrivileges(TokenHandle, TRUE, NULL, 0, NULL, NULL)
1501
1615
  else:
1502
1616
  success = True
1503
- for (privilege, enabled) in NewState:
1617
+ for privilege, enabled in NewState:
1504
1618
  if not isinstance(privilege, LUID):
1505
1619
  privilege = LookupPrivilegeValue(NULL, privilege)
1506
1620
  if enabled == True:
@@ -1512,9 +1626,10 @@ def AdjustTokenPrivileges(TokenHandle, NewState = ()):
1512
1626
  else:
1513
1627
  flags = enabled
1514
1628
  laa = LUID_AND_ATTRIBUTES(privilege, flags)
1515
- tp = TOKEN_PRIVILEGES(1, laa)
1629
+ tp = TOKEN_PRIVILEGES(1, laa)
1516
1630
  _AdjustTokenPrivileges(TokenHandle, FALSE, byref(tp), sizeof(tp), NULL, NULL)
1517
1631
 
1632
+
1518
1633
  # BOOL WINAPI GetTokenInformation(
1519
1634
  # __in HANDLE TokenHandle,
1520
1635
  # __in TOKEN_INFORMATION_CLASS TokenInformationClass,
@@ -1587,8 +1702,13 @@ def GetTokenInformation(hTokenHandle, TokenInformationClass):
1587
1702
  return TokenInformation.value
1588
1703
 
1589
1704
  # Various boolean flags.
1590
- if TokenInformationClass in (TokenSandBoxInert, TokenHasRestrictions, TokenUIAccess,
1591
- TokenVirtualizationAllowed, TokenVirtualizationEnabled):
1705
+ if TokenInformationClass in (
1706
+ TokenSandBoxInert,
1707
+ TokenHasRestrictions,
1708
+ TokenUIAccess,
1709
+ TokenVirtualizationAllowed,
1710
+ TokenVirtualizationEnabled,
1711
+ ):
1592
1712
  TokenInformation = DWORD(0)
1593
1713
  _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInformation)
1594
1714
  return bool(TokenInformation.value)
@@ -1597,21 +1717,22 @@ def GetTokenInformation(hTokenHandle, TokenInformationClass):
1597
1717
  if TokenInformationClass == TokenLinkedToken:
1598
1718
  TokenInformation = TOKEN_LINKED_TOKEN(0)
1599
1719
  _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInformation)
1600
- return TokenHandle(TokenInformation.LinkedToken.value, bOwnership = True)
1720
+ return TokenHandle(TokenInformation.LinkedToken.value, bOwnership=True)
1601
1721
 
1602
1722
  # Token statistics.
1603
1723
  if TokenInformationClass == TokenStatistics:
1604
1724
  TokenInformation = TOKEN_STATISTICS()
1605
1725
  _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInformation)
1606
- return TokenInformation # TODO add a class wrapper?
1726
+ return TokenInformation # TODO add a class wrapper?
1607
1727
 
1608
1728
  # Currently unsupported flags.
1609
1729
  raise NotImplementedError("TokenInformationClass(%i) not yet supported!" % TokenInformationClass)
1610
1730
 
1731
+
1611
1732
  def _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInformation):
1612
1733
  _GetTokenInformation = windll.advapi32.GetTokenInformation
1613
1734
  _GetTokenInformation.argtypes = [HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD]
1614
- _GetTokenInformation.restype = bool
1735
+ _GetTokenInformation.restype = bool
1615
1736
  _GetTokenInformation.errcheck = RaiseIfZero
1616
1737
 
1617
1738
  ReturnLength = DWORD(0)
@@ -1621,6 +1742,7 @@ def _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInfo
1621
1742
  raise ctypes.WinError(ERROR_INSUFFICIENT_BUFFER)
1622
1743
  return TokenInformation
1623
1744
 
1745
+
1624
1746
  # BOOL WINAPI SetTokenInformation(
1625
1747
  # __in HANDLE TokenHandle,
1626
1748
  # __in TOKEN_INFORMATION_CLASS TokenInformationClass,
@@ -1630,6 +1752,7 @@ def _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInfo
1630
1752
 
1631
1753
  # XXX TODO
1632
1754
 
1755
+
1633
1756
  # BOOL WINAPI CreateProcessWithLogonW(
1634
1757
  # __in LPCWSTR lpUsername,
1635
1758
  # __in_opt LPCWSTR lpDomain,
@@ -1643,50 +1766,87 @@ def _internal_GetTokenInformation(hTokenHandle, TokenInformationClass, TokenInfo
1643
1766
  # __in LPSTARTUPINFOW lpStartupInfo,
1644
1767
  # __out LPPROCESS_INFORMATION lpProcessInfo
1645
1768
  # );
1646
- def CreateProcessWithLogonW(lpUsername = None, lpDomain = None, lpPassword = None, dwLogonFlags = 0, lpApplicationName = None, lpCommandLine = None, dwCreationFlags = 0, lpEnvironment = None, lpCurrentDirectory = None, lpStartupInfo = None):
1769
+ def CreateProcessWithLogonW(
1770
+ lpUsername=None,
1771
+ lpDomain=None,
1772
+ lpPassword=None,
1773
+ dwLogonFlags=0,
1774
+ lpApplicationName=None,
1775
+ lpCommandLine=None,
1776
+ dwCreationFlags=0,
1777
+ lpEnvironment=None,
1778
+ lpCurrentDirectory=None,
1779
+ lpStartupInfo=None,
1780
+ ):
1647
1781
  _CreateProcessWithLogonW = windll.advapi32.CreateProcessWithLogonW
1648
- _CreateProcessWithLogonW.argtypes = [LPWSTR, LPWSTR, LPWSTR, DWORD, LPWSTR, LPWSTR, DWORD, LPVOID, LPWSTR, LPVOID, LPPROCESS_INFORMATION]
1782
+ _CreateProcessWithLogonW.argtypes = [
1783
+ LPWSTR,
1784
+ LPWSTR,
1785
+ LPWSTR,
1786
+ DWORD,
1787
+ LPWSTR,
1788
+ LPWSTR,
1789
+ DWORD,
1790
+ LPVOID,
1791
+ LPWSTR,
1792
+ LPVOID,
1793
+ LPPROCESS_INFORMATION,
1794
+ ]
1649
1795
  _CreateProcessWithLogonW.restype = bool
1650
1796
  _CreateProcessWithLogonW.errcheck = RaiseIfZero
1651
1797
 
1652
1798
  if not lpUsername:
1653
- lpUsername = None
1799
+ lpUsername = None
1654
1800
  if not lpDomain:
1655
- lpDomain = None
1801
+ lpDomain = None
1656
1802
  if not lpPassword:
1657
- lpPassword = None
1803
+ lpPassword = None
1658
1804
  if not lpApplicationName:
1659
- lpApplicationName = None
1805
+ lpApplicationName = None
1660
1806
  if not lpCommandLine:
1661
- lpCommandLine = None
1807
+ lpCommandLine = None
1662
1808
  else:
1663
- lpCommandLine = ctypes.create_unicode_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1809
+ lpCommandLine = ctypes.create_unicode_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1664
1810
  if not lpEnvironment:
1665
- lpEnvironment = None
1811
+ lpEnvironment = None
1666
1812
  else:
1667
- lpEnvironment = ctypes.create_unicode_buffer(lpEnvironment)
1813
+ lpEnvironment = ctypes.create_unicode_buffer(lpEnvironment)
1668
1814
  if not lpCurrentDirectory:
1669
- lpCurrentDirectory = None
1815
+ lpCurrentDirectory = None
1670
1816
  if not lpStartupInfo:
1671
- lpStartupInfo = STARTUPINFOW()
1672
- lpStartupInfo.cb = sizeof(STARTUPINFOW)
1673
- lpStartupInfo.lpReserved = 0
1674
- lpStartupInfo.lpDesktop = 0
1675
- lpStartupInfo.lpTitle = 0
1676
- lpStartupInfo.dwFlags = 0
1677
- lpStartupInfo.cbReserved2 = 0
1678
- lpStartupInfo.lpReserved2 = 0
1679
- lpProcessInformation = PROCESS_INFORMATION()
1680
- lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1681
- lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1682
- lpProcessInformation.dwProcessId = 0
1683
- lpProcessInformation.dwThreadId = 0
1684
- _CreateProcessWithLogonW(lpUsername, lpDomain, lpPassword, dwLogonFlags, lpApplicationName, lpCommandLine, dwCreationFlags, lpEnvironment, lpCurrentDirectory, byref(lpStartupInfo), byref(lpProcessInformation))
1817
+ lpStartupInfo = STARTUPINFOW()
1818
+ lpStartupInfo.cb = sizeof(STARTUPINFOW)
1819
+ lpStartupInfo.lpReserved = 0
1820
+ lpStartupInfo.lpDesktop = 0
1821
+ lpStartupInfo.lpTitle = 0
1822
+ lpStartupInfo.dwFlags = 0
1823
+ lpStartupInfo.cbReserved2 = 0
1824
+ lpStartupInfo.lpReserved2 = 0
1825
+ lpProcessInformation = PROCESS_INFORMATION()
1826
+ lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1827
+ lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1828
+ lpProcessInformation.dwProcessId = 0
1829
+ lpProcessInformation.dwThreadId = 0
1830
+ _CreateProcessWithLogonW(
1831
+ lpUsername,
1832
+ lpDomain,
1833
+ lpPassword,
1834
+ dwLogonFlags,
1835
+ lpApplicationName,
1836
+ lpCommandLine,
1837
+ dwCreationFlags,
1838
+ lpEnvironment,
1839
+ lpCurrentDirectory,
1840
+ byref(lpStartupInfo),
1841
+ byref(lpProcessInformation),
1842
+ )
1685
1843
  return ProcessInformation(lpProcessInformation)
1686
1844
 
1845
+
1687
1846
  CreateProcessWithLogonA = MakeANSIVersion(CreateProcessWithLogonW)
1688
1847
  CreateProcessWithLogon = DefaultStringType(CreateProcessWithLogonA, CreateProcessWithLogonW)
1689
1848
 
1849
+
1690
1850
  # BOOL WINAPI CreateProcessWithTokenW(
1691
1851
  # __in HANDLE hToken,
1692
1852
  # __in DWORD dwLogonFlags,
@@ -1698,46 +1858,67 @@ CreateProcessWithLogon = DefaultStringType(CreateProcessWithLogonA, CreateProces
1698
1858
  # __in LPSTARTUPINFOW lpStartupInfo,
1699
1859
  # __out LPPROCESS_INFORMATION lpProcessInfo
1700
1860
  # );
1701
- def CreateProcessWithTokenW(hToken = None, dwLogonFlags = 0, lpApplicationName = None, lpCommandLine = None, dwCreationFlags = 0, lpEnvironment = None, lpCurrentDirectory = None, lpStartupInfo = None):
1861
+ def CreateProcessWithTokenW(
1862
+ hToken=None,
1863
+ dwLogonFlags=0,
1864
+ lpApplicationName=None,
1865
+ lpCommandLine=None,
1866
+ dwCreationFlags=0,
1867
+ lpEnvironment=None,
1868
+ lpCurrentDirectory=None,
1869
+ lpStartupInfo=None,
1870
+ ):
1702
1871
  _CreateProcessWithTokenW = windll.advapi32.CreateProcessWithTokenW
1703
1872
  _CreateProcessWithTokenW.argtypes = [HANDLE, DWORD, LPWSTR, LPWSTR, DWORD, LPVOID, LPWSTR, LPVOID, LPPROCESS_INFORMATION]
1704
1873
  _CreateProcessWithTokenW.restype = bool
1705
1874
  _CreateProcessWithTokenW.errcheck = RaiseIfZero
1706
1875
 
1707
1876
  if not hToken:
1708
- hToken = None
1877
+ hToken = None
1709
1878
  if not lpApplicationName:
1710
- lpApplicationName = None
1879
+ lpApplicationName = None
1711
1880
  if not lpCommandLine:
1712
- lpCommandLine = None
1881
+ lpCommandLine = None
1713
1882
  else:
1714
- lpCommandLine = ctypes.create_unicode_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1883
+ lpCommandLine = ctypes.create_unicode_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1715
1884
  if not lpEnvironment:
1716
- lpEnvironment = None
1885
+ lpEnvironment = None
1717
1886
  else:
1718
- lpEnvironment = ctypes.create_unicode_buffer(lpEnvironment)
1887
+ lpEnvironment = ctypes.create_unicode_buffer(lpEnvironment)
1719
1888
  if not lpCurrentDirectory:
1720
- lpCurrentDirectory = None
1889
+ lpCurrentDirectory = None
1721
1890
  if not lpStartupInfo:
1722
- lpStartupInfo = STARTUPINFOW()
1723
- lpStartupInfo.cb = sizeof(STARTUPINFOW)
1724
- lpStartupInfo.lpReserved = 0
1725
- lpStartupInfo.lpDesktop = 0
1726
- lpStartupInfo.lpTitle = 0
1727
- lpStartupInfo.dwFlags = 0
1728
- lpStartupInfo.cbReserved2 = 0
1729
- lpStartupInfo.lpReserved2 = 0
1730
- lpProcessInformation = PROCESS_INFORMATION()
1731
- lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1732
- lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1733
- lpProcessInformation.dwProcessId = 0
1734
- lpProcessInformation.dwThreadId = 0
1735
- _CreateProcessWithTokenW(hToken, dwLogonFlags, lpApplicationName, lpCommandLine, dwCreationFlags, lpEnvironment, lpCurrentDirectory, byref(lpStartupInfo), byref(lpProcessInformation))
1891
+ lpStartupInfo = STARTUPINFOW()
1892
+ lpStartupInfo.cb = sizeof(STARTUPINFOW)
1893
+ lpStartupInfo.lpReserved = 0
1894
+ lpStartupInfo.lpDesktop = 0
1895
+ lpStartupInfo.lpTitle = 0
1896
+ lpStartupInfo.dwFlags = 0
1897
+ lpStartupInfo.cbReserved2 = 0
1898
+ lpStartupInfo.lpReserved2 = 0
1899
+ lpProcessInformation = PROCESS_INFORMATION()
1900
+ lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1901
+ lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1902
+ lpProcessInformation.dwProcessId = 0
1903
+ lpProcessInformation.dwThreadId = 0
1904
+ _CreateProcessWithTokenW(
1905
+ hToken,
1906
+ dwLogonFlags,
1907
+ lpApplicationName,
1908
+ lpCommandLine,
1909
+ dwCreationFlags,
1910
+ lpEnvironment,
1911
+ lpCurrentDirectory,
1912
+ byref(lpStartupInfo),
1913
+ byref(lpProcessInformation),
1914
+ )
1736
1915
  return ProcessInformation(lpProcessInformation)
1737
1916
 
1917
+
1738
1918
  CreateProcessWithTokenA = MakeANSIVersion(CreateProcessWithTokenW)
1739
1919
  CreateProcessWithToken = DefaultStringType(CreateProcessWithTokenA, CreateProcessWithTokenW)
1740
1920
 
1921
+
1741
1922
  # BOOL WINAPI CreateProcessAsUser(
1742
1923
  # __in_opt HANDLE hToken,
1743
1924
  # __in_opt LPCTSTR lpApplicationName,
@@ -1751,24 +1932,47 @@ CreateProcessWithToken = DefaultStringType(CreateProcessWithTokenA, CreateProces
1751
1932
  # __in LPSTARTUPINFO lpStartupInfo,
1752
1933
  # __out LPPROCESS_INFORMATION lpProcessInformation
1753
1934
  # );
1754
- def CreateProcessAsUserA(hToken = None, lpApplicationName = None, lpCommandLine=None, lpProcessAttributes=None, lpThreadAttributes=None, bInheritHandles=False, dwCreationFlags=0, lpEnvironment=None, lpCurrentDirectory=None, lpStartupInfo=None):
1935
+ def CreateProcessAsUserA(
1936
+ hToken=None,
1937
+ lpApplicationName=None,
1938
+ lpCommandLine=None,
1939
+ lpProcessAttributes=None,
1940
+ lpThreadAttributes=None,
1941
+ bInheritHandles=False,
1942
+ dwCreationFlags=0,
1943
+ lpEnvironment=None,
1944
+ lpCurrentDirectory=None,
1945
+ lpStartupInfo=None,
1946
+ ):
1755
1947
  _CreateProcessAsUserA = windll.advapi32.CreateProcessAsUserA
1756
- _CreateProcessAsUserA.argtypes = [HANDLE, LPSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPSTR, LPVOID, LPPROCESS_INFORMATION]
1757
- _CreateProcessAsUserA.restype = bool
1948
+ _CreateProcessAsUserA.argtypes = [
1949
+ HANDLE,
1950
+ LPSTR,
1951
+ LPSTR,
1952
+ LPSECURITY_ATTRIBUTES,
1953
+ LPSECURITY_ATTRIBUTES,
1954
+ BOOL,
1955
+ DWORD,
1956
+ LPVOID,
1957
+ LPSTR,
1958
+ LPVOID,
1959
+ LPPROCESS_INFORMATION,
1960
+ ]
1961
+ _CreateProcessAsUserA.restype = bool
1758
1962
  _CreateProcessAsUserA.errcheck = RaiseIfZero
1759
1963
 
1760
1964
  if not lpApplicationName:
1761
- lpApplicationName = None
1965
+ lpApplicationName = None
1762
1966
  if not lpCommandLine:
1763
- lpCommandLine = None
1967
+ lpCommandLine = None
1764
1968
  else:
1765
- lpCommandLine = ctypes.create_string_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1969
+ lpCommandLine = ctypes.create_string_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1766
1970
  if not lpEnvironment:
1767
- lpEnvironment = None
1971
+ lpEnvironment = None
1768
1972
  else:
1769
- lpEnvironment = ctypes.create_string_buffer(lpEnvironment)
1973
+ lpEnvironment = ctypes.create_string_buffer(lpEnvironment)
1770
1974
  if not lpCurrentDirectory:
1771
- lpCurrentDirectory = None
1975
+ lpCurrentDirectory = None
1772
1976
  if not lpProcessAttributes:
1773
1977
  lpProcessAttributes = None
1774
1978
  else:
@@ -1778,40 +1982,76 @@ def CreateProcessAsUserA(hToken = None, lpApplicationName = None, lpCommandLine=
1778
1982
  else:
1779
1983
  lpThreadAttributes = byref(lpThreadAttributes)
1780
1984
  if not lpStartupInfo:
1781
- lpStartupInfo = STARTUPINFO()
1782
- lpStartupInfo.cb = sizeof(STARTUPINFO)
1783
- lpStartupInfo.lpReserved = 0
1784
- lpStartupInfo.lpDesktop = 0
1785
- lpStartupInfo.lpTitle = 0
1786
- lpStartupInfo.dwFlags = 0
1787
- lpStartupInfo.cbReserved2 = 0
1788
- lpStartupInfo.lpReserved2 = 0
1789
- lpProcessInformation = PROCESS_INFORMATION()
1790
- lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1791
- lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1792
- lpProcessInformation.dwProcessId = 0
1793
- lpProcessInformation.dwThreadId = 0
1794
- _CreateProcessAsUserA(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bool(bInheritHandles), dwCreationFlags, lpEnvironment, lpCurrentDirectory, byref(lpStartupInfo), byref(lpProcessInformation))
1985
+ lpStartupInfo = STARTUPINFO()
1986
+ lpStartupInfo.cb = sizeof(STARTUPINFO)
1987
+ lpStartupInfo.lpReserved = 0
1988
+ lpStartupInfo.lpDesktop = 0
1989
+ lpStartupInfo.lpTitle = 0
1990
+ lpStartupInfo.dwFlags = 0
1991
+ lpStartupInfo.cbReserved2 = 0
1992
+ lpStartupInfo.lpReserved2 = 0
1993
+ lpProcessInformation = PROCESS_INFORMATION()
1994
+ lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1995
+ lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1996
+ lpProcessInformation.dwProcessId = 0
1997
+ lpProcessInformation.dwThreadId = 0
1998
+ _CreateProcessAsUserA(
1999
+ hToken,
2000
+ lpApplicationName,
2001
+ lpCommandLine,
2002
+ lpProcessAttributes,
2003
+ lpThreadAttributes,
2004
+ bool(bInheritHandles),
2005
+ dwCreationFlags,
2006
+ lpEnvironment,
2007
+ lpCurrentDirectory,
2008
+ byref(lpStartupInfo),
2009
+ byref(lpProcessInformation),
2010
+ )
1795
2011
  return ProcessInformation(lpProcessInformation)
1796
2012
 
1797
- def CreateProcessAsUserW(hToken = None, lpApplicationName = None, lpCommandLine=None, lpProcessAttributes=None, lpThreadAttributes=None, bInheritHandles=False, dwCreationFlags=0, lpEnvironment=None, lpCurrentDirectory=None, lpStartupInfo=None):
2013
+
2014
+ def CreateProcessAsUserW(
2015
+ hToken=None,
2016
+ lpApplicationName=None,
2017
+ lpCommandLine=None,
2018
+ lpProcessAttributes=None,
2019
+ lpThreadAttributes=None,
2020
+ bInheritHandles=False,
2021
+ dwCreationFlags=0,
2022
+ lpEnvironment=None,
2023
+ lpCurrentDirectory=None,
2024
+ lpStartupInfo=None,
2025
+ ):
1798
2026
  _CreateProcessAsUserW = windll.advapi32.CreateProcessAsUserW
1799
- _CreateProcessAsUserW.argtypes = [HANDLE, LPWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPWSTR, LPVOID, LPPROCESS_INFORMATION]
1800
- _CreateProcessAsUserW.restype = bool
2027
+ _CreateProcessAsUserW.argtypes = [
2028
+ HANDLE,
2029
+ LPWSTR,
2030
+ LPWSTR,
2031
+ LPSECURITY_ATTRIBUTES,
2032
+ LPSECURITY_ATTRIBUTES,
2033
+ BOOL,
2034
+ DWORD,
2035
+ LPVOID,
2036
+ LPWSTR,
2037
+ LPVOID,
2038
+ LPPROCESS_INFORMATION,
2039
+ ]
2040
+ _CreateProcessAsUserW.restype = bool
1801
2041
  _CreateProcessAsUserW.errcheck = RaiseIfZero
1802
2042
 
1803
2043
  if not lpApplicationName:
1804
- lpApplicationName = None
2044
+ lpApplicationName = None
1805
2045
  if not lpCommandLine:
1806
- lpCommandLine = None
2046
+ lpCommandLine = None
1807
2047
  else:
1808
- lpCommandLine = ctypes.create_unicode_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
2048
+ lpCommandLine = ctypes.create_unicode_buffer(lpCommandLine, max(MAX_PATH, len(lpCommandLine)))
1809
2049
  if not lpEnvironment:
1810
- lpEnvironment = None
2050
+ lpEnvironment = None
1811
2051
  else:
1812
- lpEnvironment = ctypes.create_unicode_buffer(lpEnvironment)
2052
+ lpEnvironment = ctypes.create_unicode_buffer(lpEnvironment)
1813
2053
  if not lpCurrentDirectory:
1814
- lpCurrentDirectory = None
2054
+ lpCurrentDirectory = None
1815
2055
  if not lpProcessAttributes:
1816
2056
  lpProcessAttributes = None
1817
2057
  else:
@@ -1821,22 +2061,35 @@ def CreateProcessAsUserW(hToken = None, lpApplicationName = None, lpCommandLine=
1821
2061
  else:
1822
2062
  lpThreadAttributes = byref(lpThreadAttributes)
1823
2063
  if not lpStartupInfo:
1824
- lpStartupInfo = STARTUPINFO()
1825
- lpStartupInfo.cb = sizeof(STARTUPINFO)
1826
- lpStartupInfo.lpReserved = 0
1827
- lpStartupInfo.lpDesktop = 0
1828
- lpStartupInfo.lpTitle = 0
1829
- lpStartupInfo.dwFlags = 0
1830
- lpStartupInfo.cbReserved2 = 0
1831
- lpStartupInfo.lpReserved2 = 0
1832
- lpProcessInformation = PROCESS_INFORMATION()
1833
- lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
1834
- lpProcessInformation.hThread = INVALID_HANDLE_VALUE
1835
- lpProcessInformation.dwProcessId = 0
1836
- lpProcessInformation.dwThreadId = 0
1837
- _CreateProcessAsUserW(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bool(bInheritHandles), dwCreationFlags, lpEnvironment, lpCurrentDirectory, byref(lpStartupInfo), byref(lpProcessInformation))
2064
+ lpStartupInfo = STARTUPINFO()
2065
+ lpStartupInfo.cb = sizeof(STARTUPINFO)
2066
+ lpStartupInfo.lpReserved = 0
2067
+ lpStartupInfo.lpDesktop = 0
2068
+ lpStartupInfo.lpTitle = 0
2069
+ lpStartupInfo.dwFlags = 0
2070
+ lpStartupInfo.cbReserved2 = 0
2071
+ lpStartupInfo.lpReserved2 = 0
2072
+ lpProcessInformation = PROCESS_INFORMATION()
2073
+ lpProcessInformation.hProcess = INVALID_HANDLE_VALUE
2074
+ lpProcessInformation.hThread = INVALID_HANDLE_VALUE
2075
+ lpProcessInformation.dwProcessId = 0
2076
+ lpProcessInformation.dwThreadId = 0
2077
+ _CreateProcessAsUserW(
2078
+ hToken,
2079
+ lpApplicationName,
2080
+ lpCommandLine,
2081
+ lpProcessAttributes,
2082
+ lpThreadAttributes,
2083
+ bool(bInheritHandles),
2084
+ dwCreationFlags,
2085
+ lpEnvironment,
2086
+ lpCurrentDirectory,
2087
+ byref(lpStartupInfo),
2088
+ byref(lpProcessInformation),
2089
+ )
1838
2090
  return ProcessInformation(lpProcessInformation)
1839
2091
 
2092
+
1840
2093
  CreateProcessAsUser = GuessStringType(CreateProcessAsUserA, CreateProcessAsUserW)
1841
2094
 
1842
2095
  # VOID CALLBACK WaitChainCallback(
@@ -1849,14 +2102,15 @@ CreateProcessAsUser = GuessStringType(CreateProcessAsUserA, CreateProcessAsUserW
1849
2102
  # );
1850
2103
  PWAITCHAINCALLBACK = WINFUNCTYPE(HWCT, DWORD_PTR, DWORD, LPDWORD, PWAITCHAIN_NODE_INFO, LPBOOL)
1851
2104
 
2105
+
1852
2106
  # HWCT WINAPI OpenThreadWaitChainSession(
1853
2107
  # __in DWORD Flags,
1854
2108
  # __in_opt PWAITCHAINCALLBACK callback
1855
2109
  # );
1856
- def OpenThreadWaitChainSession(Flags = 0, callback = None):
2110
+ def OpenThreadWaitChainSession(Flags=0, callback=None):
1857
2111
  _OpenThreadWaitChainSession = windll.advapi32.OpenThreadWaitChainSession
1858
2112
  _OpenThreadWaitChainSession.argtypes = [DWORD, PVOID]
1859
- _OpenThreadWaitChainSession.restype = HWCT
2113
+ _OpenThreadWaitChainSession.restype = HWCT
1860
2114
  _OpenThreadWaitChainSession.errcheck = RaiseIfZero
1861
2115
 
1862
2116
  if callback is not None:
@@ -1864,6 +2118,7 @@ def OpenThreadWaitChainSession(Flags = 0, callback = None):
1864
2118
  aHandle = _OpenThreadWaitChainSession(Flags, callback)
1865
2119
  return ThreadWaitChainSessionHandle(aHandle)
1866
2120
 
2121
+
1867
2122
  # BOOL WINAPI GetThreadWaitChain(
1868
2123
  # _In_ HWCT WctHandle,
1869
2124
  # _In_opt_ DWORD_PTR Context,
@@ -1873,24 +2128,38 @@ def OpenThreadWaitChainSession(Flags = 0, callback = None):
1873
2128
  # _Out_ PWAITCHAIN_NODE_INFO NodeInfoArray,
1874
2129
  # _Out_ LPBOOL IsCycle
1875
2130
  # );
1876
- def GetThreadWaitChain(WctHandle, Context = None, Flags = WCTP_GETINFO_ALL_FLAGS, ThreadId = -1, NodeCount = WCT_MAX_NODE_COUNT):
2131
+ def GetThreadWaitChain(WctHandle, Context=None, Flags=WCTP_GETINFO_ALL_FLAGS, ThreadId=-1, NodeCount=WCT_MAX_NODE_COUNT):
1877
2132
  _GetThreadWaitChain = windll.advapi32.GetThreadWaitChain
1878
2133
  _GetThreadWaitChain.argtypes = [HWCT, LPDWORD, DWORD, DWORD, LPDWORD, PWAITCHAIN_NODE_INFO, LPBOOL]
1879
- _GetThreadWaitChain.restype = bool
2134
+ _GetThreadWaitChain.restype = bool
1880
2135
  _GetThreadWaitChain.errcheck = RaiseIfZero
1881
2136
 
1882
2137
  dwNodeCount = DWORD(NodeCount)
1883
2138
  NodeInfoArray = (WAITCHAIN_NODE_INFO * NodeCount)()
1884
2139
  IsCycle = BOOL(0)
1885
- _GetThreadWaitChain(WctHandle, Context, Flags, ThreadId, byref(dwNodeCount), ctypes.cast(ctypes.pointer(NodeInfoArray), PWAITCHAIN_NODE_INFO), byref(IsCycle))
2140
+ _GetThreadWaitChain(
2141
+ WctHandle,
2142
+ Context,
2143
+ Flags,
2144
+ ThreadId,
2145
+ byref(dwNodeCount),
2146
+ ctypes.cast(ctypes.pointer(NodeInfoArray), PWAITCHAIN_NODE_INFO),
2147
+ byref(IsCycle),
2148
+ )
1886
2149
  while dwNodeCount.value > NodeCount:
1887
2150
  NodeCount = dwNodeCount.value
1888
2151
  NodeInfoArray = (WAITCHAIN_NODE_INFO * NodeCount)()
1889
- _GetThreadWaitChain(WctHandle, Context, Flags, ThreadId, byref(dwNodeCount), ctypes.cast(ctypes.pointer(NodeInfoArray), PWAITCHAIN_NODE_INFO), byref(IsCycle))
1890
- return (
1891
- [ WaitChainNodeInfo(NodeInfoArray[index]) for index in compat.xrange(dwNodeCount.value) ],
1892
- bool(IsCycle.value)
1893
- )
2152
+ _GetThreadWaitChain(
2153
+ WctHandle,
2154
+ Context,
2155
+ Flags,
2156
+ ThreadId,
2157
+ byref(dwNodeCount),
2158
+ ctypes.cast(ctypes.pointer(NodeInfoArray), PWAITCHAIN_NODE_INFO),
2159
+ byref(IsCycle),
2160
+ )
2161
+ return ([WaitChainNodeInfo(NodeInfoArray[index]) for index in compat.xrange(dwNodeCount.value)], bool(IsCycle.value))
2162
+
1894
2163
 
1895
2164
  # VOID WINAPI CloseThreadWaitChainSession(
1896
2165
  # __in HWCT WctHandle
@@ -1900,6 +2169,7 @@ def CloseThreadWaitChainSession(WctHandle):
1900
2169
  _CloseThreadWaitChainSession.argtypes = [HWCT]
1901
2170
  _CloseThreadWaitChainSession(WctHandle)
1902
2171
 
2172
+
1903
2173
  # BOOL WINAPI SaferCreateLevel(
1904
2174
  # __in DWORD dwScopeId,
1905
2175
  # __in DWORD dwLevelId,
@@ -1910,13 +2180,14 @@ def CloseThreadWaitChainSession(WctHandle):
1910
2180
  def SaferCreateLevel(dwScopeId=SAFER_SCOPEID_USER, dwLevelId=SAFER_LEVELID_NORMALUSER, OpenFlags=0):
1911
2181
  _SaferCreateLevel = windll.advapi32.SaferCreateLevel
1912
2182
  _SaferCreateLevel.argtypes = [DWORD, DWORD, DWORD, POINTER(SAFER_LEVEL_HANDLE), LPVOID]
1913
- _SaferCreateLevel.restype = BOOL
2183
+ _SaferCreateLevel.restype = BOOL
1914
2184
  _SaferCreateLevel.errcheck = RaiseIfZero
1915
2185
 
1916
2186
  hLevelHandle = SAFER_LEVEL_HANDLE(INVALID_HANDLE_VALUE)
1917
2187
  _SaferCreateLevel(dwScopeId, dwLevelId, OpenFlags, byref(hLevelHandle), None)
1918
2188
  return SaferLevelHandle(hLevelHandle.value)
1919
2189
 
2190
+
1920
2191
  # BOOL WINAPI SaferIdentifyLevel(
1921
2192
  # __in DWORD dwNumProperties,
1922
2193
  # __in_opt PSAFER_CODE_PROPERTIES pCodeProperties,
@@ -1926,6 +2197,7 @@ def SaferCreateLevel(dwScopeId=SAFER_SCOPEID_USER, dwLevelId=SAFER_LEVELID_NORMA
1926
2197
 
1927
2198
  # XXX TODO
1928
2199
 
2200
+
1929
2201
  # BOOL WINAPI SaferComputeTokenFromLevel(
1930
2202
  # __in SAFER_LEVEL_HANDLE LevelHandle,
1931
2203
  # __in_opt HANDLE InAccessToken,
@@ -1936,7 +2208,7 @@ def SaferCreateLevel(dwScopeId=SAFER_SCOPEID_USER, dwLevelId=SAFER_LEVELID_NORMA
1936
2208
  def SaferComputeTokenFromLevel(LevelHandle, InAccessToken=None, dwFlags=0):
1937
2209
  _SaferComputeTokenFromLevel = windll.advapi32.SaferComputeTokenFromLevel
1938
2210
  _SaferComputeTokenFromLevel.argtypes = [SAFER_LEVEL_HANDLE, HANDLE, PHANDLE, DWORD, LPDWORD]
1939
- _SaferComputeTokenFromLevel.restype = BOOL
2211
+ _SaferComputeTokenFromLevel.restype = BOOL
1940
2212
  _SaferComputeTokenFromLevel.errcheck = RaiseIfZero
1941
2213
 
1942
2214
  OutAccessToken = HANDLE(INVALID_HANDLE_VALUE)
@@ -1944,115 +2216,118 @@ def SaferComputeTokenFromLevel(LevelHandle, InAccessToken=None, dwFlags=0):
1944
2216
  _SaferComputeTokenFromLevel(LevelHandle, InAccessToken, byref(OutAccessToken), dwFlags, byref(lpReserved))
1945
2217
  return TokenHandle(OutAccessToken.value), lpReserved.value
1946
2218
 
2219
+
1947
2220
  # BOOL WINAPI SaferCloseLevel(
1948
2221
  # __in SAFER_LEVEL_HANDLE hLevelHandle
1949
2222
  # );
1950
2223
  def SaferCloseLevel(hLevelHandle):
1951
2224
  _SaferCloseLevel = windll.advapi32.SaferCloseLevel
1952
2225
  _SaferCloseLevel.argtypes = [SAFER_LEVEL_HANDLE]
1953
- _SaferCloseLevel.restype = BOOL
2226
+ _SaferCloseLevel.restype = BOOL
1954
2227
  _SaferCloseLevel.errcheck = RaiseIfZero
1955
2228
 
1956
- if hasattr(hLevelHandle, 'value'):
2229
+ if hasattr(hLevelHandle, "value"):
1957
2230
  _SaferCloseLevel(hLevelHandle.value)
1958
2231
  else:
1959
2232
  _SaferCloseLevel(hLevelHandle)
1960
2233
 
2234
+
1961
2235
  # BOOL SaferiIsExecutableFileType(
1962
2236
  # __in LPCWSTR szFullPath,
1963
2237
  # __in BOOLEAN bFromShellExecute
1964
2238
  # );
1965
- def SaferiIsExecutableFileType(szFullPath, bFromShellExecute = False):
2239
+ def SaferiIsExecutableFileType(szFullPath, bFromShellExecute=False):
1966
2240
  _SaferiIsExecutableFileType = windll.advapi32.SaferiIsExecutableFileType
1967
2241
  _SaferiIsExecutableFileType.argtypes = [LPWSTR, BOOLEAN]
1968
- _SaferiIsExecutableFileType.restype = BOOL
2242
+ _SaferiIsExecutableFileType.restype = BOOL
1969
2243
  _SaferiIsExecutableFileType.errcheck = RaiseIfLastError
1970
2244
 
1971
2245
  SetLastError(ERROR_SUCCESS)
1972
2246
  return bool(_SaferiIsExecutableFileType(compat.unicode(szFullPath), bFromShellExecute))
1973
2247
 
2248
+
1974
2249
  # useful alias since I'm likely to misspell it :P
1975
2250
  SaferIsExecutableFileType = SaferiIsExecutableFileType
1976
2251
 
1977
- #------------------------------------------------------------------------------
2252
+ # ------------------------------------------------------------------------------
2253
+
1978
2254
 
1979
2255
  # LONG WINAPI RegCloseKey(
1980
2256
  # __in HKEY hKey
1981
2257
  # );
1982
2258
  def RegCloseKey(hKey):
1983
- if hasattr(hKey, 'value'):
2259
+ if hasattr(hKey, "value"):
1984
2260
  value = hKey.value
1985
2261
  else:
1986
2262
  value = hKey
1987
2263
 
1988
- if value in (
1989
- HKEY_CLASSES_ROOT,
1990
- HKEY_CURRENT_USER,
1991
- HKEY_LOCAL_MACHINE,
1992
- HKEY_USERS,
1993
- HKEY_PERFORMANCE_DATA,
1994
- HKEY_CURRENT_CONFIG
1995
- ):
2264
+ if value in (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA, HKEY_CURRENT_CONFIG):
1996
2265
  return
1997
2266
 
1998
2267
  _RegCloseKey = windll.advapi32.RegCloseKey
1999
2268
  _RegCloseKey.argtypes = [HKEY]
2000
- _RegCloseKey.restype = LONG
2269
+ _RegCloseKey.restype = LONG
2001
2270
  _RegCloseKey.errcheck = RaiseIfNotErrorSuccess
2002
2271
  _RegCloseKey(hKey)
2003
2272
 
2273
+
2004
2274
  # LONG WINAPI RegConnectRegistry(
2005
2275
  # __in_opt LPCTSTR lpMachineName,
2006
2276
  # __in HKEY hKey,
2007
2277
  # __out PHKEY phkResult
2008
2278
  # );
2009
- def RegConnectRegistryA(lpMachineName = None, hKey = HKEY_LOCAL_MACHINE):
2279
+ def RegConnectRegistryA(lpMachineName=None, hKey=HKEY_LOCAL_MACHINE):
2010
2280
  _RegConnectRegistryA = windll.advapi32.RegConnectRegistryA
2011
2281
  _RegConnectRegistryA.argtypes = [LPSTR, HKEY, PHKEY]
2012
- _RegConnectRegistryA.restype = LONG
2282
+ _RegConnectRegistryA.restype = LONG
2013
2283
  _RegConnectRegistryA.errcheck = RaiseIfNotErrorSuccess
2014
2284
 
2015
2285
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2016
2286
  _RegConnectRegistryA(lpMachineName, hKey, byref(hkResult))
2017
2287
  return RegistryKeyHandle(hkResult.value)
2018
2288
 
2019
- def RegConnectRegistryW(lpMachineName = None, hKey = HKEY_LOCAL_MACHINE):
2289
+
2290
+ def RegConnectRegistryW(lpMachineName=None, hKey=HKEY_LOCAL_MACHINE):
2020
2291
  _RegConnectRegistryW = windll.advapi32.RegConnectRegistryW
2021
2292
  _RegConnectRegistryW.argtypes = [LPWSTR, HKEY, PHKEY]
2022
- _RegConnectRegistryW.restype = LONG
2293
+ _RegConnectRegistryW.restype = LONG
2023
2294
  _RegConnectRegistryW.errcheck = RaiseIfNotErrorSuccess
2024
2295
 
2025
2296
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2026
2297
  _RegConnectRegistryW(lpMachineName, hKey, byref(hkResult))
2027
2298
  return RegistryKeyHandle(hkResult.value)
2028
2299
 
2300
+
2029
2301
  RegConnectRegistry = GuessStringType(RegConnectRegistryA, RegConnectRegistryW)
2030
2302
 
2303
+
2031
2304
  # LONG WINAPI RegCreateKey(
2032
2305
  # __in HKEY hKey,
2033
2306
  # __in_opt LPCTSTR lpSubKey,
2034
2307
  # __out PHKEY phkResult
2035
2308
  # );
2036
- def RegCreateKeyA(hKey = HKEY_LOCAL_MACHINE, lpSubKey = None):
2309
+ def RegCreateKeyA(hKey=HKEY_LOCAL_MACHINE, lpSubKey=None):
2037
2310
  _RegCreateKeyA = windll.advapi32.RegCreateKeyA
2038
2311
  _RegCreateKeyA.argtypes = [HKEY, LPSTR, PHKEY]
2039
- _RegCreateKeyA.restype = LONG
2312
+ _RegCreateKeyA.restype = LONG
2040
2313
  _RegCreateKeyA.errcheck = RaiseIfNotErrorSuccess
2041
2314
 
2042
2315
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2043
2316
  _RegCreateKeyA(hKey, lpSubKey, byref(hkResult))
2044
2317
  return RegistryKeyHandle(hkResult.value)
2045
2318
 
2046
- def RegCreateKeyW(hKey = HKEY_LOCAL_MACHINE, lpSubKey = None):
2319
+
2320
+ def RegCreateKeyW(hKey=HKEY_LOCAL_MACHINE, lpSubKey=None):
2047
2321
  _RegCreateKeyW = windll.advapi32.RegCreateKeyW
2048
2322
  _RegCreateKeyW.argtypes = [HKEY, LPWSTR, PHKEY]
2049
- _RegCreateKeyW.restype = LONG
2323
+ _RegCreateKeyW.restype = LONG
2050
2324
  _RegCreateKeyW.errcheck = RaiseIfNotErrorSuccess
2051
2325
 
2052
2326
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2053
2327
  _RegCreateKeyW(hKey, lpSubKey, byref(hkResult))
2054
2328
  return RegistryKeyHandle(hkResult.value)
2055
2329
 
2330
+
2056
2331
  RegCreateKey = GuessStringType(RegCreateKeyA, RegCreateKeyW)
2057
2332
 
2058
2333
  # LONG WINAPI RegCreateKeyEx(
@@ -2069,33 +2344,37 @@ RegCreateKey = GuessStringType(RegCreateKeyA, RegCreateKeyW)
2069
2344
 
2070
2345
  # XXX TODO
2071
2346
 
2347
+
2072
2348
  # LONG WINAPI RegOpenKey(
2073
2349
  # __in HKEY hKey,
2074
2350
  # __in_opt LPCTSTR lpSubKey,
2075
2351
  # __out PHKEY phkResult
2076
2352
  # );
2077
- def RegOpenKeyA(hKey = HKEY_LOCAL_MACHINE, lpSubKey = None):
2353
+ def RegOpenKeyA(hKey=HKEY_LOCAL_MACHINE, lpSubKey=None):
2078
2354
  _RegOpenKeyA = windll.advapi32.RegOpenKeyA
2079
2355
  _RegOpenKeyA.argtypes = [HKEY, LPSTR, PHKEY]
2080
- _RegOpenKeyA.restype = LONG
2356
+ _RegOpenKeyA.restype = LONG
2081
2357
  _RegOpenKeyA.errcheck = RaiseIfNotErrorSuccess
2082
2358
 
2083
2359
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2084
2360
  _RegOpenKeyA(hKey, lpSubKey, byref(hkResult))
2085
2361
  return RegistryKeyHandle(hkResult.value)
2086
2362
 
2087
- def RegOpenKeyW(hKey = HKEY_LOCAL_MACHINE, lpSubKey = None):
2363
+
2364
+ def RegOpenKeyW(hKey=HKEY_LOCAL_MACHINE, lpSubKey=None):
2088
2365
  _RegOpenKeyW = windll.advapi32.RegOpenKeyW
2089
2366
  _RegOpenKeyW.argtypes = [HKEY, LPWSTR, PHKEY]
2090
- _RegOpenKeyW.restype = LONG
2367
+ _RegOpenKeyW.restype = LONG
2091
2368
  _RegOpenKeyW.errcheck = RaiseIfNotErrorSuccess
2092
2369
 
2093
2370
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2094
2371
  _RegOpenKeyW(hKey, lpSubKey, byref(hkResult))
2095
2372
  return RegistryKeyHandle(hkResult.value)
2096
2373
 
2374
+
2097
2375
  RegOpenKey = GuessStringType(RegOpenKeyA, RegOpenKeyW)
2098
2376
 
2377
+
2099
2378
  # LONG WINAPI RegOpenKeyEx(
2100
2379
  # __in HKEY hKey,
2101
2380
  # __in_opt LPCTSTR lpSubKey,
@@ -2103,68 +2382,73 @@ RegOpenKey = GuessStringType(RegOpenKeyA, RegOpenKeyW)
2103
2382
  # __in REGSAM samDesired,
2104
2383
  # __out PHKEY phkResult
2105
2384
  # );
2106
- def RegOpenKeyExA(hKey = HKEY_LOCAL_MACHINE, lpSubKey = None, samDesired = KEY_ALL_ACCESS):
2385
+ def RegOpenKeyExA(hKey=HKEY_LOCAL_MACHINE, lpSubKey=None, samDesired=KEY_ALL_ACCESS):
2107
2386
  _RegOpenKeyExA = windll.advapi32.RegOpenKeyExA
2108
2387
  _RegOpenKeyExA.argtypes = [HKEY, LPSTR, DWORD, REGSAM, PHKEY]
2109
- _RegOpenKeyExA.restype = LONG
2388
+ _RegOpenKeyExA.restype = LONG
2110
2389
  _RegOpenKeyExA.errcheck = RaiseIfNotErrorSuccess
2111
2390
 
2112
2391
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2113
2392
  _RegOpenKeyExA(hKey, lpSubKey, 0, samDesired, byref(hkResult))
2114
2393
  return RegistryKeyHandle(hkResult.value)
2115
2394
 
2116
- def RegOpenKeyExW(hKey = HKEY_LOCAL_MACHINE, lpSubKey = None, samDesired = KEY_ALL_ACCESS):
2395
+
2396
+ def RegOpenKeyExW(hKey=HKEY_LOCAL_MACHINE, lpSubKey=None, samDesired=KEY_ALL_ACCESS):
2117
2397
  _RegOpenKeyExW = windll.advapi32.RegOpenKeyExW
2118
2398
  _RegOpenKeyExW.argtypes = [HKEY, LPWSTR, DWORD, REGSAM, PHKEY]
2119
- _RegOpenKeyExW.restype = LONG
2399
+ _RegOpenKeyExW.restype = LONG
2120
2400
  _RegOpenKeyExW.errcheck = RaiseIfNotErrorSuccess
2121
2401
 
2122
2402
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2123
2403
  _RegOpenKeyExW(hKey, lpSubKey, 0, samDesired, byref(hkResult))
2124
2404
  return RegistryKeyHandle(hkResult.value)
2125
2405
 
2406
+
2126
2407
  RegOpenKeyEx = GuessStringType(RegOpenKeyExA, RegOpenKeyExW)
2127
2408
 
2409
+
2128
2410
  # LONG WINAPI RegOpenCurrentUser(
2129
2411
  # __in REGSAM samDesired,
2130
2412
  # __out PHKEY phkResult
2131
2413
  # );
2132
- def RegOpenCurrentUser(samDesired = KEY_ALL_ACCESS):
2414
+ def RegOpenCurrentUser(samDesired=KEY_ALL_ACCESS):
2133
2415
  _RegOpenCurrentUser = windll.advapi32.RegOpenCurrentUser
2134
2416
  _RegOpenCurrentUser.argtypes = [REGSAM, PHKEY]
2135
- _RegOpenCurrentUser.restype = LONG
2417
+ _RegOpenCurrentUser.restype = LONG
2136
2418
  _RegOpenCurrentUser.errcheck = RaiseIfNotErrorSuccess
2137
2419
 
2138
2420
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2139
2421
  _RegOpenCurrentUser(samDesired, byref(hkResult))
2140
2422
  return RegistryKeyHandle(hkResult.value)
2141
2423
 
2424
+
2142
2425
  # LONG WINAPI RegOpenUserClassesRoot(
2143
2426
  # __in HANDLE hToken,
2144
2427
  # __reserved DWORD dwOptions,
2145
2428
  # __in REGSAM samDesired,
2146
2429
  # __out PHKEY phkResult
2147
2430
  # );
2148
- def RegOpenUserClassesRoot(hToken, samDesired = KEY_ALL_ACCESS):
2431
+ def RegOpenUserClassesRoot(hToken, samDesired=KEY_ALL_ACCESS):
2149
2432
  _RegOpenUserClassesRoot = windll.advapi32.RegOpenUserClassesRoot
2150
2433
  _RegOpenUserClassesRoot.argtypes = [HANDLE, DWORD, REGSAM, PHKEY]
2151
- _RegOpenUserClassesRoot.restype = LONG
2434
+ _RegOpenUserClassesRoot.restype = LONG
2152
2435
  _RegOpenUserClassesRoot.errcheck = RaiseIfNotErrorSuccess
2153
2436
 
2154
2437
  hkResult = HKEY(INVALID_HANDLE_VALUE)
2155
2438
  _RegOpenUserClassesRoot(hToken, 0, samDesired, byref(hkResult))
2156
2439
  return RegistryKeyHandle(hkResult.value)
2157
2440
 
2441
+
2158
2442
  # LONG WINAPI RegQueryValue(
2159
2443
  # __in HKEY hKey,
2160
2444
  # __in_opt LPCTSTR lpSubKey,
2161
2445
  # __out_opt LPTSTR lpValue,
2162
2446
  # __inout_opt PLONG lpcbValue
2163
2447
  # );
2164
- def RegQueryValueA(hKey, lpSubKey = None):
2448
+ def RegQueryValueA(hKey, lpSubKey=None):
2165
2449
  _RegQueryValueA = windll.advapi32.RegQueryValueA
2166
2450
  _RegQueryValueA.argtypes = [HKEY, LPSTR, LPVOID, PLONG]
2167
- _RegQueryValueA.restype = LONG
2451
+ _RegQueryValueA.restype = LONG
2168
2452
  _RegQueryValueA.errcheck = RaiseIfNotErrorSuccess
2169
2453
 
2170
2454
  cbValue = LONG(0)
@@ -2173,10 +2457,11 @@ def RegQueryValueA(hKey, lpSubKey = None):
2173
2457
  _RegQueryValueA(hKey, lpSubKey, lpValue, byref(cbValue))
2174
2458
  return lpValue.value
2175
2459
 
2176
- def RegQueryValueW(hKey, lpSubKey = None):
2460
+
2461
+ def RegQueryValueW(hKey, lpSubKey=None):
2177
2462
  _RegQueryValueW = windll.advapi32.RegQueryValueW
2178
2463
  _RegQueryValueW.argtypes = [HKEY, LPWSTR, LPVOID, PLONG]
2179
- _RegQueryValueW.restype = LONG
2464
+ _RegQueryValueW.restype = LONG
2180
2465
  _RegQueryValueW.errcheck = RaiseIfNotErrorSuccess
2181
2466
 
2182
2467
  cbValue = LONG(0)
@@ -2185,8 +2470,10 @@ def RegQueryValueW(hKey, lpSubKey = None):
2185
2470
  _RegQueryValueW(hKey, lpSubKey, lpValue, byref(cbValue))
2186
2471
  return lpValue.value
2187
2472
 
2473
+
2188
2474
  RegQueryValue = GuessStringType(RegQueryValueA, RegQueryValueW)
2189
2475
 
2476
+
2190
2477
  # LONG WINAPI RegQueryValueEx(
2191
2478
  # __in HKEY hKey,
2192
2479
  # __in_opt LPCTSTR lpValueName,
@@ -2195,7 +2482,7 @@ RegQueryValue = GuessStringType(RegQueryValueA, RegQueryValueW)
2195
2482
  # __out_opt LPBYTE lpData,
2196
2483
  # __inout_opt LPDWORD lpcbData
2197
2484
  # );
2198
- def _internal_RegQueryValueEx(ansi, hKey, lpValueName = None, bGetData = True):
2485
+ def _internal_RegQueryValueEx(ansi, hKey, lpValueName=None, bGetData=True):
2199
2486
  _RegQueryValueEx = _caller_RegQueryValueEx(ansi)
2200
2487
 
2201
2488
  cbData = DWORD(0)
@@ -2206,14 +2493,14 @@ def _internal_RegQueryValueEx(ansi, hKey, lpValueName = None, bGetData = True):
2206
2493
  if not bGetData:
2207
2494
  return cbData.value, Type
2208
2495
 
2209
- if Type in (REG_DWORD, REG_DWORD_BIG_ENDIAN): # REG_DWORD_LITTLE_ENDIAN
2496
+ if Type in (REG_DWORD, REG_DWORD_BIG_ENDIAN): # REG_DWORD_LITTLE_ENDIAN
2210
2497
  if cbData.value != 4:
2211
2498
  raise ValueError("REG_DWORD value of size %d" % cbData.value)
2212
2499
  dwData = DWORD(0)
2213
2500
  _RegQueryValueEx(hKey, lpValueName, None, None, byref(dwData), byref(cbData))
2214
2501
  return dwData.value, Type
2215
2502
 
2216
- if Type == REG_QWORD: # REG_QWORD_LITTLE_ENDIAN
2503
+ if Type == REG_QWORD: # REG_QWORD_LITTLE_ENDIAN
2217
2504
  if cbData.value != 8:
2218
2505
  raise ValueError("REG_QWORD value of size %d" % cbData.value)
2219
2506
  qwData = QWORD(long(0))
@@ -2236,9 +2523,9 @@ def _internal_RegQueryValueEx(ansi, hKey, lpValueName = None, bGetData = True):
2236
2523
  _RegQueryValueEx(hKey, lpValueName, None, None, byref(szData), byref(cbData))
2237
2524
  Data = szData[:]
2238
2525
  if ansi:
2239
- aData = Data.split('\0')
2526
+ aData = Data.split("\0")
2240
2527
  else:
2241
- aData = Data.split(u'\0')
2528
+ aData = Data.split("\0")
2242
2529
  aData = [token for token in aData if token]
2243
2530
  return aData, Type
2244
2531
 
@@ -2252,6 +2539,7 @@ def _internal_RegQueryValueEx(ansi, hKey, lpValueName = None, bGetData = True):
2252
2539
  _RegQueryValueEx(hKey, lpValueName, None, None, byref(szData), byref(cbData))
2253
2540
  return szData.raw, Type
2254
2541
 
2542
+
2255
2543
  def _caller_RegQueryValueEx(ansi):
2256
2544
  if ansi:
2257
2545
  _RegQueryValueEx = windll.advapi32.RegQueryValueExA
@@ -2259,20 +2547,24 @@ def _caller_RegQueryValueEx(ansi):
2259
2547
  else:
2260
2548
  _RegQueryValueEx = windll.advapi32.RegQueryValueExW
2261
2549
  _RegQueryValueEx.argtypes = [HKEY, LPWSTR, LPVOID, PDWORD, LPVOID, PDWORD]
2262
- _RegQueryValueEx.restype = LONG
2550
+ _RegQueryValueEx.restype = LONG
2263
2551
  _RegQueryValueEx.errcheck = RaiseIfNotErrorSuccess
2264
2552
  return _RegQueryValueEx
2265
2553
 
2554
+
2266
2555
  # see _internal_RegQueryValueEx
2267
- def RegQueryValueExA(hKey, lpValueName = None, bGetData = True):
2556
+ def RegQueryValueExA(hKey, lpValueName=None, bGetData=True):
2268
2557
  return _internal_RegQueryValueEx(True, hKey, lpValueName, bGetData)
2269
2558
 
2559
+
2270
2560
  # see _internal_RegQueryValueEx
2271
- def RegQueryValueExW(hKey, lpValueName = None, bGetData = True):
2561
+ def RegQueryValueExW(hKey, lpValueName=None, bGetData=True):
2272
2562
  return _internal_RegQueryValueEx(False, hKey, lpValueName, bGetData)
2273
2563
 
2564
+
2274
2565
  RegQueryValueEx = GuessStringType(RegQueryValueExA, RegQueryValueExW)
2275
2566
 
2567
+
2276
2568
  # LONG WINAPI RegSetValueEx(
2277
2569
  # __in HKEY hKey,
2278
2570
  # __in_opt LPCTSTR lpValueName,
@@ -2281,8 +2573,7 @@ RegQueryValueEx = GuessStringType(RegQueryValueExA, RegQueryValueExW)
2281
2573
  # __in_opt const BYTE *lpData,
2282
2574
  # __in DWORD cbData
2283
2575
  # );
2284
- def RegSetValueEx(hKey, lpValueName = None, lpData = None, dwType = None):
2285
-
2576
+ def RegSetValueEx(hKey, lpValueName=None, lpData=None, dwType=None):
2286
2577
  # Determine which version of the API to use, ANSI or Widechar.
2287
2578
  if lpValueName is None:
2288
2579
  if isinstance(lpData, GuessStringType.t_ansi):
@@ -2290,7 +2581,7 @@ def RegSetValueEx(hKey, lpValueName = None, lpData = None, dwType = None):
2290
2581
  elif isinstance(lpData, GuessStringType.t_unicode):
2291
2582
  ansi = False
2292
2583
  else:
2293
- ansi = (GuessStringType.t_ansi == GuessStringType.t_default)
2584
+ ansi = GuessStringType.t_ansi == GuessStringType.t_default
2294
2585
  elif isinstance(lpValueName, GuessStringType.t_ansi):
2295
2586
  ansi = True
2296
2587
  elif isinstance(lpValueName, GuessStringType.t_unicode):
@@ -2323,17 +2614,17 @@ def RegSetValueEx(hKey, lpValueName = None, lpData = None, dwType = None):
2323
2614
  else:
2324
2615
  _RegSetValueEx = windll.advapi32.RegSetValueExW
2325
2616
  _RegSetValueEx.argtypes = [HKEY, LPWSTR, DWORD, DWORD, LPVOID, DWORD]
2326
- _RegSetValueEx.restype = LONG
2617
+ _RegSetValueEx.restype = LONG
2327
2618
  _RegSetValueEx.errcheck = RaiseIfNotErrorSuccess
2328
2619
 
2329
2620
  # Convert the arguments so ctypes can understand them.
2330
2621
  if lpData is None:
2331
- DataRef = None
2622
+ DataRef = None
2332
2623
  DataSize = 0
2333
2624
  else:
2334
2625
  if dwType in (REG_DWORD, REG_DWORD_BIG_ENDIAN): # REG_DWORD_LITTLE_ENDIAN
2335
2626
  Data = DWORD(lpData)
2336
- elif dwType == REG_QWORD: # REG_QWORD_LITTLE_ENDIAN
2627
+ elif dwType == REG_QWORD: # REG_QWORD_LITTLE_ENDIAN
2337
2628
  Data = QWORD(lpData)
2338
2629
  elif dwType in (REG_SZ, REG_EXPAND_SZ):
2339
2630
  if ansi:
@@ -2342,22 +2633,24 @@ def RegSetValueEx(hKey, lpValueName = None, lpData = None, dwType = None):
2342
2633
  Data = ctypes.create_unicode_buffer(lpData)
2343
2634
  elif dwType == REG_MULTI_SZ:
2344
2635
  if ansi:
2345
- Data = ctypes.create_string_buffer('\0'.join(lpData) + '\0\0')
2636
+ Data = ctypes.create_string_buffer("\0".join(lpData) + "\0\0")
2346
2637
  else:
2347
- Data = ctypes.create_unicode_buffer(u'\0'.join(lpData) + u'\0\0')
2638
+ Data = ctypes.create_unicode_buffer("\0".join(lpData) + "\0\0")
2348
2639
  elif dwType == REG_LINK:
2349
2640
  Data = ctypes.create_unicode_buffer(lpData)
2350
2641
  else:
2351
2642
  Data = ctypes.create_string_buffer(lpData)
2352
- DataRef = byref(Data)
2643
+ DataRef = byref(Data)
2353
2644
  DataSize = sizeof(Data)
2354
2645
 
2355
2646
  # Call the API with the converted arguments.
2356
2647
  _RegSetValueEx(hKey, lpValueName, 0, dwType, DataRef, DataSize)
2357
2648
 
2649
+
2358
2650
  # No "GuessStringType" here since detection is done inside.
2359
2651
  RegSetValueExA = RegSetValueExW = RegSetValueEx
2360
2652
 
2653
+
2361
2654
  # LONG WINAPI RegEnumKey(
2362
2655
  # __in HKEY hKey,
2363
2656
  # __in DWORD dwIndex,
@@ -2367,7 +2660,7 @@ RegSetValueExA = RegSetValueExW = RegSetValueEx
2367
2660
  def RegEnumKeyA(hKey, dwIndex):
2368
2661
  _RegEnumKeyA = windll.advapi32.RegEnumKeyA
2369
2662
  _RegEnumKeyA.argtypes = [HKEY, DWORD, LPSTR, DWORD]
2370
- _RegEnumKeyA.restype = LONG
2663
+ _RegEnumKeyA.restype = LONG
2371
2664
 
2372
2665
  cchName = 1024
2373
2666
  while True:
@@ -2384,10 +2677,11 @@ def RegEnumKeyA(hKey, dwIndex):
2384
2677
  raise ctypes.WinError(errcode)
2385
2678
  return lpName.value
2386
2679
 
2680
+
2387
2681
  def RegEnumKeyW(hKey, dwIndex):
2388
2682
  _RegEnumKeyW = windll.advapi32.RegEnumKeyW
2389
2683
  _RegEnumKeyW.argtypes = [HKEY, DWORD, LPWSTR, DWORD]
2390
- _RegEnumKeyW.restype = LONG
2684
+ _RegEnumKeyW.restype = LONG
2391
2685
 
2392
2686
  cchName = 512
2393
2687
  while True:
@@ -2404,6 +2698,7 @@ def RegEnumKeyW(hKey, dwIndex):
2404
2698
  raise ctypes.WinError(errcode)
2405
2699
  return lpName.value
2406
2700
 
2701
+
2407
2702
  RegEnumKey = DefaultStringType(RegEnumKeyA, RegEnumKeyW)
2408
2703
 
2409
2704
  # LONG WINAPI RegEnumKeyEx(
@@ -2419,6 +2714,7 @@ RegEnumKey = DefaultStringType(RegEnumKeyA, RegEnumKeyW)
2419
2714
 
2420
2715
  # XXX TODO
2421
2716
 
2717
+
2422
2718
  # LONG WINAPI RegEnumValue(
2423
2719
  # __in HKEY hKey,
2424
2720
  # __in DWORD dwIndex,
@@ -2429,14 +2725,14 @@ RegEnumKey = DefaultStringType(RegEnumKeyA, RegEnumKeyW)
2429
2725
  # __out_opt LPBYTE lpData,
2430
2726
  # __inout_opt LPDWORD lpcbData
2431
2727
  # );
2432
- def _internal_RegEnumValue(ansi, hKey, dwIndex, bGetData = True):
2728
+ def _internal_RegEnumValue(ansi, hKey, dwIndex, bGetData=True):
2433
2729
  if ansi:
2434
2730
  _RegEnumValue = windll.advapi32.RegEnumValueA
2435
2731
  _RegEnumValue.argtypes = [HKEY, DWORD, LPSTR, LPDWORD, LPVOID, LPDWORD, LPVOID, LPDWORD]
2436
2732
  else:
2437
2733
  _RegEnumValue = windll.advapi32.RegEnumValueW
2438
2734
  _RegEnumValue.argtypes = [HKEY, DWORD, LPWSTR, LPDWORD, LPVOID, LPDWORD, LPVOID, LPDWORD]
2439
- _RegEnumValue.restype = LONG
2735
+ _RegEnumValue.restype = LONG
2440
2736
 
2441
2737
  cchValueName = DWORD(1024)
2442
2738
  dwType = DWORD(-1)
@@ -2465,12 +2761,12 @@ def _internal_RegEnumValue(ansi, hKey, dwIndex, bGetData = True):
2465
2761
  if bGetData:
2466
2762
  Type = dwType.value
2467
2763
 
2468
- if Type in (REG_DWORD, REG_DWORD_BIG_ENDIAN): # REG_DWORD_LITTLE_ENDIAN
2764
+ if Type in (REG_DWORD, REG_DWORD_BIG_ENDIAN): # REG_DWORD_LITTLE_ENDIAN
2469
2765
  if cbData.value != sizeof(DWORD):
2470
2766
  raise ValueError("REG_DWORD value of size %d" % cbData.value)
2471
2767
  Data = DWORD(0)
2472
2768
 
2473
- elif Type == REG_QWORD: # REG_QWORD_LITTLE_ENDIAN
2769
+ elif Type == REG_QWORD: # REG_QWORD_LITTLE_ENDIAN
2474
2770
  if cbData.value != sizeof(QWORD):
2475
2771
  raise ValueError("REG_QWORD value of size %d" % cbData.value)
2476
2772
  Data = QWORD(long(0))
@@ -2484,7 +2780,7 @@ def _internal_RegEnumValue(ansi, hKey, dwIndex, bGetData = True):
2484
2780
  elif Type == REG_LINK:
2485
2781
  Data = ctypes.create_unicode_buffer(cbData.value)
2486
2782
 
2487
- else: # REG_BINARY, REG_NONE, and any future types
2783
+ else: # REG_BINARY, REG_NONE, and any future types
2488
2784
  Data = ctypes.create_string_buffer(cbData.value)
2489
2785
 
2490
2786
  lpData = byref(Data)
@@ -2493,34 +2789,44 @@ def _internal_RegEnumValue(ansi, hKey, dwIndex, bGetData = True):
2493
2789
 
2494
2790
  if errcode == ERROR_NO_MORE_ITEMS:
2495
2791
  return None
2496
- #if errcode != ERROR_SUCCESS:
2792
+ # if errcode != ERROR_SUCCESS:
2497
2793
  # raise ctypes.WinError(errcode)
2498
2794
 
2499
2795
  if not bGetData:
2500
2796
  return lpValueName.value, dwType.value
2501
2797
 
2502
- if Type in (REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD, REG_SZ, REG_EXPAND_SZ, REG_LINK): # REG_DWORD_LITTLE_ENDIAN, REG_QWORD_LITTLE_ENDIAN
2798
+ if Type in (
2799
+ REG_DWORD,
2800
+ REG_DWORD_BIG_ENDIAN,
2801
+ REG_QWORD,
2802
+ REG_SZ,
2803
+ REG_EXPAND_SZ,
2804
+ REG_LINK,
2805
+ ): # REG_DWORD_LITTLE_ENDIAN, REG_QWORD_LITTLE_ENDIAN
2503
2806
  return lpValueName.value, dwType.value, Data.value
2504
2807
 
2505
2808
  if Type == REG_MULTI_SZ:
2506
2809
  sData = Data[:]
2507
2810
  del Data
2508
2811
  if ansi:
2509
- aData = sData.split('\0')
2812
+ aData = sData.split("\0")
2510
2813
  else:
2511
- aData = sData.split(u'\0')
2814
+ aData = sData.split("\0")
2512
2815
  aData = [token for token in aData if token]
2513
2816
  return lpValueName.value, dwType.value, aData
2514
2817
 
2515
2818
  # REG_BINARY, REG_NONE, and any future types
2516
2819
  return lpValueName.value, dwType.value, Data.raw
2517
2820
 
2518
- def RegEnumValueA(hKey, dwIndex, bGetData = True):
2821
+
2822
+ def RegEnumValueA(hKey, dwIndex, bGetData=True):
2519
2823
  return _internal_RegEnumValue(True, hKey, dwIndex, bGetData)
2520
2824
 
2521
- def RegEnumValueW(hKey, dwIndex, bGetData = True):
2825
+
2826
+ def RegEnumValueW(hKey, dwIndex, bGetData=True):
2522
2827
  return _internal_RegEnumValue(False, hKey, dwIndex, bGetData)
2523
2828
 
2829
+
2524
2830
  RegEnumValue = DefaultStringType(RegEnumValueA, RegEnumValueW)
2525
2831
 
2526
2832
  # XXX TODO
@@ -2546,59 +2852,74 @@ RegEnumValue = DefaultStringType(RegEnumValueA, RegEnumValueW)
2546
2852
 
2547
2853
  # XXX TODO
2548
2854
 
2855
+
2549
2856
  # LONG WINAPI RegDeleteValue(
2550
2857
  # __in HKEY hKey,
2551
2858
  # __in_opt LPCTSTR lpValueName
2552
2859
  # );
2553
- def RegDeleteValueA(hKeySrc, lpValueName = None):
2860
+ def RegDeleteValueA(hKeySrc, lpValueName=None):
2554
2861
  _RegDeleteValueA = windll.advapi32.RegDeleteValueA
2555
2862
  _RegDeleteValueA.argtypes = [HKEY, LPSTR]
2556
- _RegDeleteValueA.restype = LONG
2863
+ _RegDeleteValueA.restype = LONG
2557
2864
  _RegDeleteValueA.errcheck = RaiseIfNotErrorSuccess
2558
2865
  _RegDeleteValueA(hKeySrc, lpValueName)
2559
- def RegDeleteValueW(hKeySrc, lpValueName = None):
2866
+
2867
+
2868
+ def RegDeleteValueW(hKeySrc, lpValueName=None):
2560
2869
  _RegDeleteValueW = windll.advapi32.RegDeleteValueW
2561
2870
  _RegDeleteValueW.argtypes = [HKEY, LPWSTR]
2562
- _RegDeleteValueW.restype = LONG
2871
+ _RegDeleteValueW.restype = LONG
2563
2872
  _RegDeleteValueW.errcheck = RaiseIfNotErrorSuccess
2564
2873
  _RegDeleteValueW(hKeySrc, lpValueName)
2874
+
2875
+
2565
2876
  RegDeleteValue = GuessStringType(RegDeleteValueA, RegDeleteValueW)
2566
2877
 
2878
+
2567
2879
  # LONG WINAPI RegDeleteKeyValue(
2568
2880
  # __in HKEY hKey,
2569
2881
  # __in_opt LPCTSTR lpSubKey,
2570
2882
  # __in_opt LPCTSTR lpValueName
2571
2883
  # );
2572
- def RegDeleteKeyValueA(hKeySrc, lpSubKey = None, lpValueName = None):
2884
+ def RegDeleteKeyValueA(hKeySrc, lpSubKey=None, lpValueName=None):
2573
2885
  _RegDeleteKeyValueA = windll.advapi32.RegDeleteKeyValueA
2574
2886
  _RegDeleteKeyValueA.argtypes = [HKEY, LPSTR, LPSTR]
2575
- _RegDeleteKeyValueA.restype = LONG
2887
+ _RegDeleteKeyValueA.restype = LONG
2576
2888
  _RegDeleteKeyValueA.errcheck = RaiseIfNotErrorSuccess
2577
2889
  _RegDeleteKeyValueA(hKeySrc, lpSubKey, lpValueName)
2578
- def RegDeleteKeyValueW(hKeySrc, lpSubKey = None, lpValueName = None):
2890
+
2891
+
2892
+ def RegDeleteKeyValueW(hKeySrc, lpSubKey=None, lpValueName=None):
2579
2893
  _RegDeleteKeyValueW = windll.advapi32.RegDeleteKeyValueW
2580
2894
  _RegDeleteKeyValueW.argtypes = [HKEY, LPWSTR, LPWSTR]
2581
- _RegDeleteKeyValueW.restype = LONG
2895
+ _RegDeleteKeyValueW.restype = LONG
2582
2896
  _RegDeleteKeyValueW.errcheck = RaiseIfNotErrorSuccess
2583
2897
  _RegDeleteKeyValueW(hKeySrc, lpSubKey, lpValueName)
2898
+
2899
+
2584
2900
  RegDeleteKeyValue = GuessStringType(RegDeleteKeyValueA, RegDeleteKeyValueW)
2585
2901
 
2902
+
2586
2903
  # LONG WINAPI RegDeleteKey(
2587
2904
  # __in HKEY hKey,
2588
2905
  # __in LPCTSTR lpSubKey
2589
2906
  # );
2590
- def RegDeleteKeyA(hKeySrc, lpSubKey = None):
2907
+ def RegDeleteKeyA(hKeySrc, lpSubKey=None):
2591
2908
  _RegDeleteKeyA = windll.advapi32.RegDeleteKeyA
2592
2909
  _RegDeleteKeyA.argtypes = [HKEY, LPSTR]
2593
- _RegDeleteKeyA.restype = LONG
2910
+ _RegDeleteKeyA.restype = LONG
2594
2911
  _RegDeleteKeyA.errcheck = RaiseIfNotErrorSuccess
2595
2912
  _RegDeleteKeyA(hKeySrc, lpSubKey)
2596
- def RegDeleteKeyW(hKeySrc, lpSubKey = None):
2913
+
2914
+
2915
+ def RegDeleteKeyW(hKeySrc, lpSubKey=None):
2597
2916
  _RegDeleteKeyW = windll.advapi32.RegDeleteKeyW
2598
2917
  _RegDeleteKeyW.argtypes = [HKEY, LPWSTR]
2599
- _RegDeleteKeyW.restype = LONG
2918
+ _RegDeleteKeyW.restype = LONG
2600
2919
  _RegDeleteKeyW.errcheck = RaiseIfNotErrorSuccess
2601
2920
  _RegDeleteKeyW(hKeySrc, lpSubKey)
2921
+
2922
+
2602
2923
  RegDeleteKey = GuessStringType(RegDeleteKeyA, RegDeleteKeyW)
2603
2924
 
2604
2925
  # LONG WINAPI RegDeleteKeyEx(
@@ -2608,20 +2929,26 @@ RegDeleteKey = GuessStringType(RegDeleteKeyA, RegDeleteKeyW)
2608
2929
  # __reserved DWORD Reserved
2609
2930
  # );
2610
2931
 
2611
- def RegDeleteKeyExA(hKeySrc, lpSubKey = None, samDesired = KEY_WOW64_32KEY):
2932
+
2933
+ def RegDeleteKeyExA(hKeySrc, lpSubKey=None, samDesired=KEY_WOW64_32KEY):
2612
2934
  _RegDeleteKeyExA = windll.advapi32.RegDeleteKeyExA
2613
2935
  _RegDeleteKeyExA.argtypes = [HKEY, LPSTR, REGSAM, DWORD]
2614
- _RegDeleteKeyExA.restype = LONG
2936
+ _RegDeleteKeyExA.restype = LONG
2615
2937
  _RegDeleteKeyExA.errcheck = RaiseIfNotErrorSuccess
2616
2938
  _RegDeleteKeyExA(hKeySrc, lpSubKey, samDesired, 0)
2617
- def RegDeleteKeyExW(hKeySrc, lpSubKey = None, samDesired = KEY_WOW64_32KEY):
2939
+
2940
+
2941
+ def RegDeleteKeyExW(hKeySrc, lpSubKey=None, samDesired=KEY_WOW64_32KEY):
2618
2942
  _RegDeleteKeyExW = windll.advapi32.RegDeleteKeyExW
2619
2943
  _RegDeleteKeyExW.argtypes = [HKEY, LPWSTR, REGSAM, DWORD]
2620
- _RegDeleteKeyExW.restype = LONG
2944
+ _RegDeleteKeyExW.restype = LONG
2621
2945
  _RegDeleteKeyExW.errcheck = RaiseIfNotErrorSuccess
2622
2946
  _RegDeleteKeyExW(hKeySrc, lpSubKey, samDesired, 0)
2947
+
2948
+
2623
2949
  RegDeleteKeyEx = GuessStringType(RegDeleteKeyExA, RegDeleteKeyExW)
2624
2950
 
2951
+
2625
2952
  # LONG WINAPI RegCopyTree(
2626
2953
  # __in HKEY hKeySrc,
2627
2954
  # __in_opt LPCTSTR lpSubKey,
@@ -2630,45 +2957,56 @@ RegDeleteKeyEx = GuessStringType(RegDeleteKeyExA, RegDeleteKeyExW)
2630
2957
  def RegCopyTreeA(hKeySrc, lpSubKey, hKeyDest):
2631
2958
  _RegCopyTreeA = windll.advapi32.RegCopyTreeA
2632
2959
  _RegCopyTreeA.argtypes = [HKEY, LPSTR, HKEY]
2633
- _RegCopyTreeA.restype = LONG
2960
+ _RegCopyTreeA.restype = LONG
2634
2961
  _RegCopyTreeA.errcheck = RaiseIfNotErrorSuccess
2635
2962
  _RegCopyTreeA(hKeySrc, lpSubKey, hKeyDest)
2963
+
2964
+
2636
2965
  def RegCopyTreeW(hKeySrc, lpSubKey, hKeyDest):
2637
2966
  _RegCopyTreeW = windll.advapi32.RegCopyTreeW
2638
2967
  _RegCopyTreeW.argtypes = [HKEY, LPWSTR, HKEY]
2639
- _RegCopyTreeW.restype = LONG
2968
+ _RegCopyTreeW.restype = LONG
2640
2969
  _RegCopyTreeW.errcheck = RaiseIfNotErrorSuccess
2641
2970
  _RegCopyTreeW(hKeySrc, lpSubKey, hKeyDest)
2971
+
2972
+
2642
2973
  RegCopyTree = GuessStringType(RegCopyTreeA, RegCopyTreeW)
2643
2974
 
2975
+
2644
2976
  # LONG WINAPI RegDeleteTree(
2645
2977
  # __in HKEY hKey,
2646
2978
  # __in_opt LPCTSTR lpSubKey
2647
2979
  # );
2648
- def RegDeleteTreeA(hKey, lpSubKey = None):
2980
+ def RegDeleteTreeA(hKey, lpSubKey=None):
2649
2981
  _RegDeleteTreeA = windll.advapi32.RegDeleteTreeA
2650
2982
  _RegDeleteTreeA.argtypes = [HKEY, LPWSTR]
2651
- _RegDeleteTreeA.restype = LONG
2983
+ _RegDeleteTreeA.restype = LONG
2652
2984
  _RegDeleteTreeA.errcheck = RaiseIfNotErrorSuccess
2653
2985
  _RegDeleteTreeA(hKey, lpSubKey)
2654
- def RegDeleteTreeW(hKey, lpSubKey = None):
2986
+
2987
+
2988
+ def RegDeleteTreeW(hKey, lpSubKey=None):
2655
2989
  _RegDeleteTreeW = windll.advapi32.RegDeleteTreeW
2656
2990
  _RegDeleteTreeW.argtypes = [HKEY, LPWSTR]
2657
- _RegDeleteTreeW.restype = LONG
2991
+ _RegDeleteTreeW.restype = LONG
2658
2992
  _RegDeleteTreeW.errcheck = RaiseIfNotErrorSuccess
2659
2993
  _RegDeleteTreeW(hKey, lpSubKey)
2994
+
2995
+
2660
2996
  RegDeleteTree = GuessStringType(RegDeleteTreeA, RegDeleteTreeW)
2661
2997
 
2998
+
2662
2999
  # LONG WINAPI RegFlushKey(
2663
3000
  # __in HKEY hKey
2664
3001
  # );
2665
3002
  def RegFlushKey(hKey):
2666
3003
  _RegFlushKey = windll.advapi32.RegFlushKey
2667
3004
  _RegFlushKey.argtypes = [HKEY]
2668
- _RegFlushKey.restype = LONG
3005
+ _RegFlushKey.restype = LONG
2669
3006
  _RegFlushKey.errcheck = RaiseIfNotErrorSuccess
2670
3007
  _RegFlushKey(hKey)
2671
3008
 
3009
+
2672
3010
  # LONG WINAPI RegLoadMUIString(
2673
3011
  # _In_ HKEY hKey,
2674
3012
  # _In_opt_ LPCTSTR pszValue,
@@ -2681,7 +3019,8 @@ def RegFlushKey(hKey):
2681
3019
 
2682
3020
  # TO DO
2683
3021
 
2684
- #------------------------------------------------------------------------------
3022
+ # ------------------------------------------------------------------------------
3023
+
2685
3024
 
2686
3025
  # BOOL WINAPI CloseServiceHandle(
2687
3026
  # _In_ SC_HANDLE hSCObject
@@ -2689,7 +3028,7 @@ def RegFlushKey(hKey):
2689
3028
  def CloseServiceHandle(hSCObject):
2690
3029
  _CloseServiceHandle = windll.advapi32.CloseServiceHandle
2691
3030
  _CloseServiceHandle.argtypes = [SC_HANDLE]
2692
- _CloseServiceHandle.restype = bool
3031
+ _CloseServiceHandle.restype = bool
2693
3032
  _CloseServiceHandle.errcheck = RaiseIfZero
2694
3033
 
2695
3034
  if isinstance(hSCObject, Handle):
@@ -2698,52 +3037,59 @@ def CloseServiceHandle(hSCObject):
2698
3037
  else:
2699
3038
  _CloseServiceHandle(hSCObject)
2700
3039
 
3040
+
2701
3041
  # SC_HANDLE WINAPI OpenSCManager(
2702
3042
  # _In_opt_ LPCTSTR lpMachineName,
2703
3043
  # _In_opt_ LPCTSTR lpDatabaseName,
2704
3044
  # _In_ DWORD dwDesiredAccess
2705
3045
  # );
2706
- def OpenSCManagerA(lpMachineName = None, lpDatabaseName = None, dwDesiredAccess = SC_MANAGER_ALL_ACCESS):
3046
+ def OpenSCManagerA(lpMachineName=None, lpDatabaseName=None, dwDesiredAccess=SC_MANAGER_ALL_ACCESS):
2707
3047
  _OpenSCManagerA = windll.advapi32.OpenSCManagerA
2708
3048
  _OpenSCManagerA.argtypes = [LPSTR, LPSTR, DWORD]
2709
- _OpenSCManagerA.restype = SC_HANDLE
3049
+ _OpenSCManagerA.restype = SC_HANDLE
2710
3050
  _OpenSCManagerA.errcheck = RaiseIfZero
2711
3051
 
2712
3052
  hSCObject = _OpenSCManagerA(lpMachineName, lpDatabaseName, dwDesiredAccess)
2713
3053
  return ServiceControlManagerHandle(hSCObject)
2714
3054
 
2715
- def OpenSCManagerW(lpMachineName = None, lpDatabaseName = None, dwDesiredAccess = SC_MANAGER_ALL_ACCESS):
3055
+
3056
+ def OpenSCManagerW(lpMachineName=None, lpDatabaseName=None, dwDesiredAccess=SC_MANAGER_ALL_ACCESS):
2716
3057
  _OpenSCManagerW = windll.advapi32.OpenSCManagerW
2717
3058
  _OpenSCManagerW.argtypes = [LPWSTR, LPWSTR, DWORD]
2718
- _OpenSCManagerW.restype = SC_HANDLE
3059
+ _OpenSCManagerW.restype = SC_HANDLE
2719
3060
  _OpenSCManagerW.errcheck = RaiseIfZero
2720
3061
 
2721
3062
  hSCObject = _OpenSCManagerA(lpMachineName, lpDatabaseName, dwDesiredAccess)
2722
3063
  return ServiceControlManagerHandle(hSCObject)
2723
3064
 
3065
+
2724
3066
  OpenSCManager = GuessStringType(OpenSCManagerA, OpenSCManagerW)
2725
3067
 
3068
+
2726
3069
  # SC_HANDLE WINAPI OpenService(
2727
3070
  # _In_ SC_HANDLE hSCManager,
2728
3071
  # _In_ LPCTSTR lpServiceName,
2729
3072
  # _In_ DWORD dwDesiredAccess
2730
3073
  # );
2731
- def OpenServiceA(hSCManager, lpServiceName, dwDesiredAccess = SERVICE_ALL_ACCESS):
3074
+ def OpenServiceA(hSCManager, lpServiceName, dwDesiredAccess=SERVICE_ALL_ACCESS):
2732
3075
  _OpenServiceA = windll.advapi32.OpenServiceA
2733
3076
  _OpenServiceA.argtypes = [SC_HANDLE, LPSTR, DWORD]
2734
- _OpenServiceA.restype = SC_HANDLE
3077
+ _OpenServiceA.restype = SC_HANDLE
2735
3078
  _OpenServiceA.errcheck = RaiseIfZero
2736
- return ServiceHandle( _OpenServiceA(hSCManager, lpServiceName, dwDesiredAccess) )
3079
+ return ServiceHandle(_OpenServiceA(hSCManager, lpServiceName, dwDesiredAccess))
2737
3080
 
2738
- def OpenServiceW(hSCManager, lpServiceName, dwDesiredAccess = SERVICE_ALL_ACCESS):
3081
+
3082
+ def OpenServiceW(hSCManager, lpServiceName, dwDesiredAccess=SERVICE_ALL_ACCESS):
2739
3083
  _OpenServiceW = windll.advapi32.OpenServiceW
2740
3084
  _OpenServiceW.argtypes = [SC_HANDLE, LPWSTR, DWORD]
2741
- _OpenServiceW.restype = SC_HANDLE
3085
+ _OpenServiceW.restype = SC_HANDLE
2742
3086
  _OpenServiceW.errcheck = RaiseIfZero
2743
- return ServiceHandle( _OpenServiceW(hSCManager, lpServiceName, dwDesiredAccess) )
3087
+ return ServiceHandle(_OpenServiceW(hSCManager, lpServiceName, dwDesiredAccess))
3088
+
2744
3089
 
2745
3090
  OpenService = GuessStringType(OpenServiceA, OpenServiceW)
2746
3091
 
3092
+
2747
3093
  # SC_HANDLE WINAPI CreateService(
2748
3094
  # _In_ SC_HANDLE hSCManager,
2749
3095
  # _In_ LPCTSTR lpServiceName,
@@ -2759,60 +3105,94 @@ OpenService = GuessStringType(OpenServiceA, OpenServiceW)
2759
3105
  # _In_opt_ LPCTSTR lpServiceStartName,
2760
3106
  # _In_opt_ LPCTSTR lpPassword
2761
3107
  # );
2762
- def CreateServiceA(hSCManager, lpServiceName,
2763
- lpDisplayName = None,
2764
- dwDesiredAccess = SERVICE_ALL_ACCESS,
2765
- dwServiceType = SERVICE_WIN32_OWN_PROCESS,
2766
- dwStartType = SERVICE_DEMAND_START,
2767
- dwErrorControl = SERVICE_ERROR_NORMAL,
2768
- lpBinaryPathName = None,
2769
- lpLoadOrderGroup = None,
2770
- lpDependencies = None,
2771
- lpServiceStartName = None,
2772
- lpPassword = None):
2773
-
3108
+ def CreateServiceA(
3109
+ hSCManager,
3110
+ lpServiceName,
3111
+ lpDisplayName=None,
3112
+ dwDesiredAccess=SERVICE_ALL_ACCESS,
3113
+ dwServiceType=SERVICE_WIN32_OWN_PROCESS,
3114
+ dwStartType=SERVICE_DEMAND_START,
3115
+ dwErrorControl=SERVICE_ERROR_NORMAL,
3116
+ lpBinaryPathName=None,
3117
+ lpLoadOrderGroup=None,
3118
+ lpDependencies=None,
3119
+ lpServiceStartName=None,
3120
+ lpPassword=None,
3121
+ ):
2774
3122
  _CreateServiceA = windll.advapi32.CreateServiceA
2775
3123
  _CreateServiceA.argtypes = [SC_HANDLE, LPSTR, LPSTR, DWORD, DWORD, DWORD, DWORD, LPSTR, LPSTR, LPDWORD, LPSTR, LPSTR, LPSTR]
2776
- _CreateServiceA.restype = SC_HANDLE
3124
+ _CreateServiceA.restype = SC_HANDLE
2777
3125
  _CreateServiceA.errcheck = RaiseIfZero
2778
3126
 
2779
3127
  dwTagId = DWORD(0)
2780
- hService = _CreateServiceA(hSCManager, lpServiceName, dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, byref(dwTagId), lpDependencies, lpServiceStartName, lpPassword)
3128
+ hService = _CreateServiceA(
3129
+ hSCManager,
3130
+ lpServiceName,
3131
+ dwDesiredAccess,
3132
+ dwServiceType,
3133
+ dwStartType,
3134
+ dwErrorControl,
3135
+ lpBinaryPathName,
3136
+ lpLoadOrderGroup,
3137
+ byref(dwTagId),
3138
+ lpDependencies,
3139
+ lpServiceStartName,
3140
+ lpPassword,
3141
+ )
2781
3142
  return ServiceHandle(hService), dwTagId.value
2782
3143
 
2783
- def CreateServiceW(hSCManager, lpServiceName,
2784
- lpDisplayName = None,
2785
- dwDesiredAccess = SERVICE_ALL_ACCESS,
2786
- dwServiceType = SERVICE_WIN32_OWN_PROCESS,
2787
- dwStartType = SERVICE_DEMAND_START,
2788
- dwErrorControl = SERVICE_ERROR_NORMAL,
2789
- lpBinaryPathName = None,
2790
- lpLoadOrderGroup = None,
2791
- lpDependencies = None,
2792
- lpServiceStartName = None,
2793
- lpPassword = None):
2794
3144
 
3145
+ def CreateServiceW(
3146
+ hSCManager,
3147
+ lpServiceName,
3148
+ lpDisplayName=None,
3149
+ dwDesiredAccess=SERVICE_ALL_ACCESS,
3150
+ dwServiceType=SERVICE_WIN32_OWN_PROCESS,
3151
+ dwStartType=SERVICE_DEMAND_START,
3152
+ dwErrorControl=SERVICE_ERROR_NORMAL,
3153
+ lpBinaryPathName=None,
3154
+ lpLoadOrderGroup=None,
3155
+ lpDependencies=None,
3156
+ lpServiceStartName=None,
3157
+ lpPassword=None,
3158
+ ):
2795
3159
  _CreateServiceW = windll.advapi32.CreateServiceW
2796
3160
  _CreateServiceW.argtypes = [SC_HANDLE, LPWSTR, LPWSTR, DWORD, DWORD, DWORD, DWORD, LPWSTR, LPWSTR, LPDWORD, LPWSTR, LPWSTR, LPWSTR]
2797
- _CreateServiceW.restype = SC_HANDLE
3161
+ _CreateServiceW.restype = SC_HANDLE
2798
3162
  _CreateServiceW.errcheck = RaiseIfZero
2799
3163
 
2800
3164
  dwTagId = DWORD(0)
2801
- hService = _CreateServiceW(hSCManager, lpServiceName, dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, byref(dwTagId), lpDependencies, lpServiceStartName, lpPassword)
3165
+ hService = _CreateServiceW(
3166
+ hSCManager,
3167
+ lpServiceName,
3168
+ dwDesiredAccess,
3169
+ dwServiceType,
3170
+ dwStartType,
3171
+ dwErrorControl,
3172
+ lpBinaryPathName,
3173
+ lpLoadOrderGroup,
3174
+ byref(dwTagId),
3175
+ lpDependencies,
3176
+ lpServiceStartName,
3177
+ lpPassword,
3178
+ )
2802
3179
  return ServiceHandle(hService), dwTagId.value
2803
3180
 
3181
+
2804
3182
  CreateService = GuessStringType(CreateServiceA, CreateServiceW)
2805
3183
 
3184
+
2806
3185
  # BOOL WINAPI DeleteService(
2807
3186
  # _In_ SC_HANDLE hService
2808
3187
  # );
2809
3188
  def DeleteService(hService):
2810
3189
  _DeleteService = windll.advapi32.DeleteService
2811
3190
  _DeleteService.argtypes = [SC_HANDLE]
2812
- _DeleteService.restype = bool
3191
+ _DeleteService.restype = bool
2813
3192
  _DeleteService.errcheck = RaiseIfZero
2814
3193
  _DeleteService(hService)
2815
3194
 
3195
+
2816
3196
  # BOOL WINAPI GetServiceKeyName(
2817
3197
  # _In_ SC_HANDLE hSCManager,
2818
3198
  # _In_ LPCTSTR lpDisplayName,
@@ -2822,7 +3202,7 @@ def DeleteService(hService):
2822
3202
  def GetServiceKeyNameA(hSCManager, lpDisplayName):
2823
3203
  _GetServiceKeyNameA = windll.advapi32.GetServiceKeyNameA
2824
3204
  _GetServiceKeyNameA.argtypes = [SC_HANDLE, LPSTR, LPSTR, LPDWORD]
2825
- _GetServiceKeyNameA.restype = bool
3205
+ _GetServiceKeyNameA.restype = bool
2826
3206
 
2827
3207
  cchBuffer = DWORD(0)
2828
3208
  _GetServiceKeyNameA(hSCManager, lpDisplayName, None, byref(cchBuffer))
@@ -2835,10 +3215,11 @@ def GetServiceKeyNameA(hSCManager, lpDisplayName):
2835
3215
  raise ctypes.WinError()
2836
3216
  return lpServiceName.value
2837
3217
 
3218
+
2838
3219
  def GetServiceKeyNameW(hSCManager, lpDisplayName):
2839
3220
  _GetServiceKeyNameW = windll.advapi32.GetServiceKeyNameW
2840
3221
  _GetServiceKeyNameW.argtypes = [SC_HANDLE, LPWSTR, LPWSTR, LPDWORD]
2841
- _GetServiceKeyNameW.restype = bool
3222
+ _GetServiceKeyNameW.restype = bool
2842
3223
 
2843
3224
  cchBuffer = DWORD(0)
2844
3225
  _GetServiceKeyNameW(hSCManager, lpDisplayName, None, byref(cchBuffer))
@@ -2851,8 +3232,10 @@ def GetServiceKeyNameW(hSCManager, lpDisplayName):
2851
3232
  raise ctypes.WinError()
2852
3233
  return lpServiceName.value
2853
3234
 
3235
+
2854
3236
  GetServiceKeyName = GuessStringType(GetServiceKeyNameA, GetServiceKeyNameW)
2855
3237
 
3238
+
2856
3239
  # BOOL WINAPI GetServiceDisplayName(
2857
3240
  # _In_ SC_HANDLE hSCManager,
2858
3241
  # _In_ LPCTSTR lpServiceName,
@@ -2862,7 +3245,7 @@ GetServiceKeyName = GuessStringType(GetServiceKeyNameA, GetServiceKeyNameW)
2862
3245
  def GetServiceDisplayNameA(hSCManager, lpServiceName):
2863
3246
  _GetServiceDisplayNameA = windll.advapi32.GetServiceDisplayNameA
2864
3247
  _GetServiceDisplayNameA.argtypes = [SC_HANDLE, LPSTR, LPSTR, LPDWORD]
2865
- _GetServiceDisplayNameA.restype = bool
3248
+ _GetServiceDisplayNameA.restype = bool
2866
3249
 
2867
3250
  cchBuffer = DWORD(0)
2868
3251
  _GetServiceDisplayNameA(hSCManager, lpServiceName, None, byref(cchBuffer))
@@ -2875,10 +3258,11 @@ def GetServiceDisplayNameA(hSCManager, lpServiceName):
2875
3258
  raise ctypes.WinError()
2876
3259
  return lpDisplayName.value
2877
3260
 
3261
+
2878
3262
  def GetServiceDisplayNameW(hSCManager, lpServiceName):
2879
3263
  _GetServiceDisplayNameW = windll.advapi32.GetServiceDisplayNameW
2880
3264
  _GetServiceDisplayNameW.argtypes = [SC_HANDLE, LPWSTR, LPWSTR, LPDWORD]
2881
- _GetServiceDisplayNameW.restype = bool
3265
+ _GetServiceDisplayNameW.restype = bool
2882
3266
 
2883
3267
  cchBuffer = DWORD(0)
2884
3268
  _GetServiceDisplayNameW(hSCManager, lpServiceName, None, byref(cchBuffer))
@@ -2891,6 +3275,7 @@ def GetServiceDisplayNameW(hSCManager, lpServiceName):
2891
3275
  raise ctypes.WinError()
2892
3276
  return lpDisplayName.value
2893
3277
 
3278
+
2894
3279
  GetServiceDisplayName = GuessStringType(GetServiceDisplayNameA, GetServiceDisplayNameW)
2895
3280
 
2896
3281
  # BOOL WINAPI QueryServiceConfig(
@@ -2936,15 +3321,16 @@ GetServiceDisplayName = GuessStringType(GetServiceDisplayNameA, GetServiceDispla
2936
3321
 
2937
3322
  # TO DO
2938
3323
 
3324
+
2939
3325
  # BOOL WINAPI StartService(
2940
3326
  # _In_ SC_HANDLE hService,
2941
3327
  # _In_ DWORD dwNumServiceArgs,
2942
3328
  # _In_opt_ LPCTSTR *lpServiceArgVectors
2943
3329
  # );
2944
- def StartServiceA(hService, ServiceArgVectors = None):
3330
+ def StartServiceA(hService, ServiceArgVectors=None):
2945
3331
  _StartServiceA = windll.advapi32.StartServiceA
2946
3332
  _StartServiceA.argtypes = [SC_HANDLE, DWORD, LPVOID]
2947
- _StartServiceA.restype = bool
3333
+ _StartServiceA.restype = bool
2948
3334
  _StartServiceA.errcheck = RaiseIfZero
2949
3335
 
2950
3336
  if ServiceArgVectors:
@@ -2956,10 +3342,11 @@ def StartServiceA(hService, ServiceArgVectors = None):
2956
3342
  lpServiceArgVectors = None
2957
3343
  _StartServiceA(hService, dwNumServiceArgs, lpServiceArgVectors)
2958
3344
 
2959
- def StartServiceW(hService, ServiceArgVectors = None):
3345
+
3346
+ def StartServiceW(hService, ServiceArgVectors=None):
2960
3347
  _StartServiceW = windll.advapi32.StartServiceW
2961
3348
  _StartServiceW.argtypes = [SC_HANDLE, DWORD, LPVOID]
2962
- _StartServiceW.restype = bool
3349
+ _StartServiceW.restype = bool
2963
3350
  _StartServiceW.errcheck = RaiseIfZero
2964
3351
 
2965
3352
  if ServiceArgVectors:
@@ -2971,8 +3358,10 @@ def StartServiceW(hService, ServiceArgVectors = None):
2971
3358
  lpServiceArgVectors = None
2972
3359
  _StartServiceW(hService, dwNumServiceArgs, lpServiceArgVectors)
2973
3360
 
3361
+
2974
3362
  StartService = GuessStringType(StartServiceA, StartServiceW)
2975
3363
 
3364
+
2976
3365
  # BOOL WINAPI ControlService(
2977
3366
  # _In_ SC_HANDLE hService,
2978
3367
  # _In_ DWORD dwControl,
@@ -2981,13 +3370,14 @@ StartService = GuessStringType(StartServiceA, StartServiceW)
2981
3370
  def ControlService(hService, dwControl):
2982
3371
  _ControlService = windll.advapi32.ControlService
2983
3372
  _ControlService.argtypes = [SC_HANDLE, DWORD, LPSERVICE_STATUS]
2984
- _ControlService.restype = bool
3373
+ _ControlService.restype = bool
2985
3374
  _ControlService.errcheck = RaiseIfZero
2986
3375
 
2987
3376
  rawServiceStatus = SERVICE_STATUS()
2988
3377
  _ControlService(hService, dwControl, byref(rawServiceStatus))
2989
3378
  return ServiceStatus(rawServiceStatus)
2990
3379
 
3380
+
2991
3381
  # BOOL WINAPI ControlServiceEx(
2992
3382
  # _In_ SC_HANDLE hService,
2993
3383
  # _In_ DWORD dwControl,
@@ -3005,6 +3395,7 @@ def ControlService(hService, dwControl):
3005
3395
 
3006
3396
  # TO DO
3007
3397
 
3398
+
3008
3399
  # BOOL WINAPI QueryServiceStatus(
3009
3400
  # _In_ SC_HANDLE hService,
3010
3401
  # _Out_ LPSERVICE_STATUS lpServiceStatus
@@ -3012,13 +3403,14 @@ def ControlService(hService, dwControl):
3012
3403
  def QueryServiceStatus(hService):
3013
3404
  _QueryServiceStatus = windll.advapi32.QueryServiceStatus
3014
3405
  _QueryServiceStatus.argtypes = [SC_HANDLE, LPSERVICE_STATUS]
3015
- _QueryServiceStatus.restype = bool
3406
+ _QueryServiceStatus.restype = bool
3016
3407
  _QueryServiceStatus.errcheck = RaiseIfZero
3017
3408
 
3018
3409
  rawServiceStatus = SERVICE_STATUS()
3019
3410
  _QueryServiceStatus(hService, byref(rawServiceStatus))
3020
3411
  return ServiceStatus(rawServiceStatus)
3021
3412
 
3413
+
3022
3414
  # BOOL WINAPI QueryServiceStatusEx(
3023
3415
  # _In_ SC_HANDLE hService,
3024
3416
  # _In_ SC_STATUS_TYPE InfoLevel,
@@ -3026,14 +3418,13 @@ def QueryServiceStatus(hService):
3026
3418
  # _In_ DWORD cbBufSize,
3027
3419
  # _Out_ LPDWORD pcbBytesNeeded
3028
3420
  # );
3029
- def QueryServiceStatusEx(hService, InfoLevel = SC_STATUS_PROCESS_INFO):
3030
-
3421
+ def QueryServiceStatusEx(hService, InfoLevel=SC_STATUS_PROCESS_INFO):
3031
3422
  if InfoLevel != SC_STATUS_PROCESS_INFO:
3032
3423
  raise NotImplementedError()
3033
3424
 
3034
3425
  _QueryServiceStatusEx = windll.advapi32.QueryServiceStatusEx
3035
3426
  _QueryServiceStatusEx.argtypes = [SC_HANDLE, SC_STATUS_TYPE, LPVOID, DWORD, LPDWORD]
3036
- _QueryServiceStatusEx.restype = bool
3427
+ _QueryServiceStatusEx.restype = bool
3037
3428
  _QueryServiceStatusEx.errcheck = RaiseIfZero
3038
3429
 
3039
3430
  lpBuffer = SERVICE_STATUS_PROCESS()
@@ -3041,6 +3432,7 @@ def QueryServiceStatusEx(hService, InfoLevel = SC_STATUS_PROCESS_INFO):
3041
3432
  _QueryServiceStatusEx(hService, InfoLevel, byref(lpBuffer), sizeof(lpBuffer), byref(cbBytesNeeded))
3042
3433
  return ServiceStatusProcess(lpBuffer)
3043
3434
 
3435
+
3044
3436
  # BOOL WINAPI EnumServicesStatus(
3045
3437
  # _In_ SC_HANDLE hSCManager,
3046
3438
  # _In_ DWORD dwServiceType,
@@ -3051,16 +3443,18 @@ def QueryServiceStatusEx(hService, InfoLevel = SC_STATUS_PROCESS_INFO):
3051
3443
  # _Out_ LPDWORD lpServicesReturned,
3052
3444
  # _Inout_opt_ LPDWORD lpResumeHandle
3053
3445
  # );
3054
- def EnumServicesStatusA(hSCManager, dwServiceType = SERVICE_DRIVER | SERVICE_WIN32, dwServiceState = SERVICE_STATE_ALL):
3446
+ def EnumServicesStatusA(hSCManager, dwServiceType=SERVICE_DRIVER | SERVICE_WIN32, dwServiceState=SERVICE_STATE_ALL):
3055
3447
  _EnumServicesStatusA = windll.advapi32.EnumServicesStatusA
3056
3448
  _EnumServicesStatusA.argtypes = [SC_HANDLE, DWORD, DWORD, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD]
3057
- _EnumServicesStatusA.restype = bool
3449
+ _EnumServicesStatusA.restype = bool
3058
3450
 
3059
- cbBytesNeeded = DWORD(0)
3451
+ cbBytesNeeded = DWORD(0)
3060
3452
  ServicesReturned = DWORD(0)
3061
- ResumeHandle = DWORD(0)
3453
+ ResumeHandle = DWORD(0)
3062
3454
 
3063
- _EnumServicesStatusA(hSCManager, dwServiceType, dwServiceState, None, 0, byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle))
3455
+ _EnumServicesStatusA(
3456
+ hSCManager, dwServiceType, dwServiceState, None, 0, byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle)
3457
+ )
3064
3458
 
3065
3459
  Services = []
3066
3460
  success = False
@@ -3068,28 +3462,41 @@ def EnumServicesStatusA(hSCManager, dwServiceType = SERVICE_DRIVER | SERVICE_WIN
3068
3462
  if cbBytesNeeded.value < sizeof(ENUM_SERVICE_STATUSA):
3069
3463
  break
3070
3464
  ServicesBuffer = ctypes.create_string_buffer("", cbBytesNeeded.value)
3071
- success = _EnumServicesStatusA(hSCManager, dwServiceType, dwServiceState, byref(ServicesBuffer), sizeof(ServicesBuffer), byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle))
3465
+ success = _EnumServicesStatusA(
3466
+ hSCManager,
3467
+ dwServiceType,
3468
+ dwServiceState,
3469
+ byref(ServicesBuffer),
3470
+ sizeof(ServicesBuffer),
3471
+ byref(cbBytesNeeded),
3472
+ byref(ServicesReturned),
3473
+ byref(ResumeHandle),
3474
+ )
3072
3475
  if sizeof(ServicesBuffer) < (sizeof(ENUM_SERVICE_STATUSA) * ServicesReturned.value):
3073
3476
  raise ctypes.WinError()
3074
3477
  lpServicesArray = ctypes.cast(ctypes.cast(ctypes.pointer(ServicesBuffer), ctypes.c_void_p), LPENUM_SERVICE_STATUSA)
3075
3478
  for index in compat.xrange(0, ServicesReturned.value):
3076
- Services.append( ServiceStatusEntry(lpServicesArray[index]) )
3077
- if success: break
3479
+ Services.append(ServiceStatusEntry(lpServicesArray[index]))
3480
+ if success:
3481
+ break
3078
3482
  if not success:
3079
3483
  raise ctypes.WinError()
3080
3484
 
3081
3485
  return Services
3082
3486
 
3083
- def EnumServicesStatusW(hSCManager, dwServiceType = SERVICE_DRIVER | SERVICE_WIN32, dwServiceState = SERVICE_STATE_ALL):
3487
+
3488
+ def EnumServicesStatusW(hSCManager, dwServiceType=SERVICE_DRIVER | SERVICE_WIN32, dwServiceState=SERVICE_STATE_ALL):
3084
3489
  _EnumServicesStatusW = windll.advapi32.EnumServicesStatusW
3085
3490
  _EnumServicesStatusW.argtypes = [SC_HANDLE, DWORD, DWORD, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD]
3086
- _EnumServicesStatusW.restype = bool
3491
+ _EnumServicesStatusW.restype = bool
3087
3492
 
3088
- cbBytesNeeded = DWORD(0)
3493
+ cbBytesNeeded = DWORD(0)
3089
3494
  ServicesReturned = DWORD(0)
3090
- ResumeHandle = DWORD(0)
3495
+ ResumeHandle = DWORD(0)
3091
3496
 
3092
- _EnumServicesStatusW(hSCManager, dwServiceType, dwServiceState, None, 0, byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle))
3497
+ _EnumServicesStatusW(
3498
+ hSCManager, dwServiceType, dwServiceState, None, 0, byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle)
3499
+ )
3093
3500
 
3094
3501
  Services = []
3095
3502
  success = False
@@ -3097,20 +3504,32 @@ def EnumServicesStatusW(hSCManager, dwServiceType = SERVICE_DRIVER | SERVICE_WIN
3097
3504
  if cbBytesNeeded.value < sizeof(ENUM_SERVICE_STATUSW):
3098
3505
  break
3099
3506
  ServicesBuffer = ctypes.create_string_buffer("", cbBytesNeeded.value)
3100
- success = _EnumServicesStatusW(hSCManager, dwServiceType, dwServiceState, byref(ServicesBuffer), sizeof(ServicesBuffer), byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle))
3507
+ success = _EnumServicesStatusW(
3508
+ hSCManager,
3509
+ dwServiceType,
3510
+ dwServiceState,
3511
+ byref(ServicesBuffer),
3512
+ sizeof(ServicesBuffer),
3513
+ byref(cbBytesNeeded),
3514
+ byref(ServicesReturned),
3515
+ byref(ResumeHandle),
3516
+ )
3101
3517
  if sizeof(ServicesBuffer) < (sizeof(ENUM_SERVICE_STATUSW) * ServicesReturned.value):
3102
3518
  raise ctypes.WinError()
3103
3519
  lpServicesArray = ctypes.cast(ctypes.cast(ctypes.pointer(ServicesBuffer), ctypes.c_void_p), LPENUM_SERVICE_STATUSW)
3104
3520
  for index in compat.xrange(0, ServicesReturned.value):
3105
- Services.append( ServiceStatusEntry(lpServicesArray[index]) )
3106
- if success: break
3521
+ Services.append(ServiceStatusEntry(lpServicesArray[index]))
3522
+ if success:
3523
+ break
3107
3524
  if not success:
3108
3525
  raise ctypes.WinError()
3109
3526
 
3110
3527
  return Services
3111
3528
 
3529
+
3112
3530
  EnumServicesStatus = DefaultStringType(EnumServicesStatusA, EnumServicesStatusW)
3113
3531
 
3532
+
3114
3533
  # BOOL WINAPI EnumServicesStatusEx(
3115
3534
  # _In_ SC_HANDLE hSCManager,
3116
3535
  # _In_ SC_ENUM_TYPE InfoLevel,
@@ -3123,20 +3542,36 @@ EnumServicesStatus = DefaultStringType(EnumServicesStatusA, EnumServicesStatusW)
3123
3542
  # _Inout_opt_ LPDWORD lpResumeHandle,
3124
3543
  # _In_opt_ LPCTSTR pszGroupName
3125
3544
  # );
3126
- def EnumServicesStatusExA(hSCManager, InfoLevel = SC_ENUM_PROCESS_INFO, dwServiceType = SERVICE_DRIVER | SERVICE_WIN32, dwServiceState = SERVICE_STATE_ALL, pszGroupName = None):
3127
-
3545
+ def EnumServicesStatusExA(
3546
+ hSCManager,
3547
+ InfoLevel=SC_ENUM_PROCESS_INFO,
3548
+ dwServiceType=SERVICE_DRIVER | SERVICE_WIN32,
3549
+ dwServiceState=SERVICE_STATE_ALL,
3550
+ pszGroupName=None,
3551
+ ):
3128
3552
  if InfoLevel != SC_ENUM_PROCESS_INFO:
3129
3553
  raise NotImplementedError()
3130
3554
 
3131
3555
  _EnumServicesStatusExA = windll.advapi32.EnumServicesStatusExA
3132
3556
  _EnumServicesStatusExA.argtypes = [SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR]
3133
- _EnumServicesStatusExA.restype = bool
3557
+ _EnumServicesStatusExA.restype = bool
3134
3558
 
3135
- cbBytesNeeded = DWORD(0)
3559
+ cbBytesNeeded = DWORD(0)
3136
3560
  ServicesReturned = DWORD(0)
3137
- ResumeHandle = DWORD(0)
3138
-
3139
- _EnumServicesStatusExA(hSCManager, InfoLevel, dwServiceType, dwServiceState, None, 0, byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle), pszGroupName)
3561
+ ResumeHandle = DWORD(0)
3562
+
3563
+ _EnumServicesStatusExA(
3564
+ hSCManager,
3565
+ InfoLevel,
3566
+ dwServiceType,
3567
+ dwServiceState,
3568
+ None,
3569
+ 0,
3570
+ byref(cbBytesNeeded),
3571
+ byref(ServicesReturned),
3572
+ byref(ResumeHandle),
3573
+ pszGroupName,
3574
+ )
3140
3575
 
3141
3576
  Services = []
3142
3577
  success = False
@@ -3144,31 +3579,61 @@ def EnumServicesStatusExA(hSCManager, InfoLevel = SC_ENUM_PROCESS_INFO, dwServic
3144
3579
  if cbBytesNeeded.value < sizeof(ENUM_SERVICE_STATUS_PROCESSA):
3145
3580
  break
3146
3581
  ServicesBuffer = ctypes.create_string_buffer("", cbBytesNeeded.value)
3147
- success = _EnumServicesStatusExA(hSCManager, InfoLevel, dwServiceType, dwServiceState, byref(ServicesBuffer), sizeof(ServicesBuffer), byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle), pszGroupName)
3582
+ success = _EnumServicesStatusExA(
3583
+ hSCManager,
3584
+ InfoLevel,
3585
+ dwServiceType,
3586
+ dwServiceState,
3587
+ byref(ServicesBuffer),
3588
+ sizeof(ServicesBuffer),
3589
+ byref(cbBytesNeeded),
3590
+ byref(ServicesReturned),
3591
+ byref(ResumeHandle),
3592
+ pszGroupName,
3593
+ )
3148
3594
  if sizeof(ServicesBuffer) < (sizeof(ENUM_SERVICE_STATUS_PROCESSA) * ServicesReturned.value):
3149
3595
  raise ctypes.WinError()
3150
3596
  lpServicesArray = ctypes.cast(ctypes.cast(ctypes.pointer(ServicesBuffer), ctypes.c_void_p), LPENUM_SERVICE_STATUS_PROCESSA)
3151
3597
  for index in compat.xrange(0, ServicesReturned.value):
3152
- Services.append( ServiceStatusProcessEntry(lpServicesArray[index]) )
3153
- if success: break
3598
+ Services.append(ServiceStatusProcessEntry(lpServicesArray[index]))
3599
+ if success:
3600
+ break
3154
3601
  if not success:
3155
3602
  raise ctypes.WinError()
3156
3603
 
3157
3604
  return Services
3158
3605
 
3159
- def EnumServicesStatusExW(hSCManager, InfoLevel = SC_ENUM_PROCESS_INFO, dwServiceType = SERVICE_DRIVER | SERVICE_WIN32, dwServiceState = SERVICE_STATE_ALL, pszGroupName = None):
3606
+
3607
+ def EnumServicesStatusExW(
3608
+ hSCManager,
3609
+ InfoLevel=SC_ENUM_PROCESS_INFO,
3610
+ dwServiceType=SERVICE_DRIVER | SERVICE_WIN32,
3611
+ dwServiceState=SERVICE_STATE_ALL,
3612
+ pszGroupName=None,
3613
+ ):
3160
3614
  _EnumServicesStatusExW = windll.advapi32.EnumServicesStatusExW
3161
3615
  _EnumServicesStatusExW.argtypes = [SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPVOID, DWORD, LPDWORD, LPDWORD, LPDWORD, LPWSTR]
3162
- _EnumServicesStatusExW.restype = bool
3616
+ _EnumServicesStatusExW.restype = bool
3163
3617
 
3164
3618
  if InfoLevel != SC_ENUM_PROCESS_INFO:
3165
3619
  raise NotImplementedError()
3166
3620
 
3167
- cbBytesNeeded = DWORD(0)
3621
+ cbBytesNeeded = DWORD(0)
3168
3622
  ServicesReturned = DWORD(0)
3169
- ResumeHandle = DWORD(0)
3170
-
3171
- _EnumServicesStatusExW(hSCManager, InfoLevel, dwServiceType, dwServiceState, None, 0, byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle), pszGroupName)
3623
+ ResumeHandle = DWORD(0)
3624
+
3625
+ _EnumServicesStatusExW(
3626
+ hSCManager,
3627
+ InfoLevel,
3628
+ dwServiceType,
3629
+ dwServiceState,
3630
+ None,
3631
+ 0,
3632
+ byref(cbBytesNeeded),
3633
+ byref(ServicesReturned),
3634
+ byref(ResumeHandle),
3635
+ pszGroupName,
3636
+ )
3172
3637
 
3173
3638
  Services = []
3174
3639
  success = False
@@ -3176,18 +3641,31 @@ def EnumServicesStatusExW(hSCManager, InfoLevel = SC_ENUM_PROCESS_INFO, dwServic
3176
3641
  if cbBytesNeeded.value < sizeof(ENUM_SERVICE_STATUS_PROCESSW):
3177
3642
  break
3178
3643
  ServicesBuffer = ctypes.create_string_buffer("", cbBytesNeeded.value)
3179
- success = _EnumServicesStatusExW(hSCManager, InfoLevel, dwServiceType, dwServiceState, byref(ServicesBuffer), sizeof(ServicesBuffer), byref(cbBytesNeeded), byref(ServicesReturned), byref(ResumeHandle), pszGroupName)
3644
+ success = _EnumServicesStatusExW(
3645
+ hSCManager,
3646
+ InfoLevel,
3647
+ dwServiceType,
3648
+ dwServiceState,
3649
+ byref(ServicesBuffer),
3650
+ sizeof(ServicesBuffer),
3651
+ byref(cbBytesNeeded),
3652
+ byref(ServicesReturned),
3653
+ byref(ResumeHandle),
3654
+ pszGroupName,
3655
+ )
3180
3656
  if sizeof(ServicesBuffer) < (sizeof(ENUM_SERVICE_STATUS_PROCESSW) * ServicesReturned.value):
3181
3657
  raise ctypes.WinError()
3182
3658
  lpServicesArray = ctypes.cast(ctypes.cast(ctypes.pointer(ServicesBuffer), ctypes.c_void_p), LPENUM_SERVICE_STATUS_PROCESSW)
3183
3659
  for index in compat.xrange(0, ServicesReturned.value):
3184
- Services.append( ServiceStatusProcessEntry(lpServicesArray[index]) )
3185
- if success: break
3660
+ Services.append(ServiceStatusProcessEntry(lpServicesArray[index]))
3661
+ if success:
3662
+ break
3186
3663
  if not success:
3187
3664
  raise ctypes.WinError()
3188
3665
 
3189
3666
  return Services
3190
3667
 
3668
+
3191
3669
  EnumServicesStatusEx = DefaultStringType(EnumServicesStatusExA, EnumServicesStatusExW)
3192
3670
 
3193
3671
  # BOOL WINAPI EnumDependentServices(
@@ -3201,9 +3679,9 @@ EnumServicesStatusEx = DefaultStringType(EnumServicesStatusExA, EnumServicesStat
3201
3679
 
3202
3680
  # TO DO
3203
3681
 
3204
- #==============================================================================
3682
+ # ==============================================================================
3205
3683
  # This calculates the list of exported symbols.
3206
3684
  _all = set(vars().keys()).difference(_all)
3207
- __all__ = [_x for _x in _all if not _x.startswith('_')]
3685
+ __all__ = [_x for _x in _all if not _x.startswith("_")]
3208
3686
  __all__.sort()
3209
- #==============================================================================
3687
+ # ==============================================================================