{"id":255591,"date":"2015-04-20T14:56:02","date_gmt":"2015-04-20T10:56:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=255591"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=255591","title":{"rendered":"\u0421\u0430\u043c \u0441\u0435\u0431\u0435 \u0420\u0443\u0441\u0441\u0438\u043d\u043e\u0432\u0438\u0447: \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430"},"content":{"rendered":"<br \/>\n<table>\n<tr>\n<td>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/eac\/af8\/6b2\/eacaf86b23b1795019d73a917a48530c.png\" alt=\"ctypes\"\/><\/td>\n<td>\u0421\u0440\u0435\u0434\u0438 \u0443\u0442\u0438\u043b\u0438\u0442 SysInternals \u0435\u0441\u0442\u044c \u0442\u0435, \u0447\u0442\u043e \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0433\u043e\u0434\u0430\u043c\u0438, \u0430 \u0438\u0445 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0418 \u0432\u0441\u0435 \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0438\u0445 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u044f\u0437\u044b\u043a \u043d\u0435 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430 Python \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e; \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u0441\u043a\u043e\u0440\u0435\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439.<a name=\"habracut\"><\/a><\/td>\n<\/tr>\n<\/table>\n<p>  \u041f\u043e \u0441\u043b\u0443\u0445\u0430\u043c \u043d\u0435\u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0443\u0442\u0438\u043b\u0438\u0442 SysInternals \u0431\u044b\u043b\u0438 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435, \u0438 \u0435\u0441\u043b\u0438 \u043f\u043e\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0438\u0445 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u043e\u0442\u044b\u0441\u043a\u0430\u0442\u044c. \u041f\u0440\u0430\u0432\u0434\u0430 \u0442\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043e\u0442\u043e\u0431\u044c\u0435\u0442 \u0432\u0441\u044f\u043a\u0443\u044e \u043e\u0445\u043e\u0442\u0443 \u043f\u043e\u043d\u044f\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0443\u0442\u0438\u043b\u0438\u0442, \u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043c\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b. \u0418 \u0433\u043e\u043b\u043e\u0432\u0430 \u0434\u0430\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0438\u0449\u0435\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0432\u0435\u0440\u043d\u043e? \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0440\u043f\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u043d\u0430 \u043f\u0443\u0442\u0438 \u2014 \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c? \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441 \u0433\u043e\u043b\u043e\u0432\u043e\u0439 \u0432 \u043e\u043c\u0443\u0442 \u0431\u0440\u043e\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u0430 \u0435\u0449\u0435 \u043f\u0440\u0435\u0436\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u0432\u043d\u0435\u0448\u0442\u0430\u0442\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0445 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f Python. \u041f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f API&#8217;\u0448\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0438\u0436\u0435 \u0441 \u043d\u0438\u043c\u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0441 \u043d\u0435\u0437\u0430\u0442\u0435\u0439\u043b\u0438\u0432\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <i>russinovich.py<\/i>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"python\">from ctypes import (    byref, c_ulong, c_void_p, c_wchar_p, windll )  FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100 FORMAT_MESSAGE_IGNORE_INSERTS  = 0x00000200 FORMAT_MESSAGE_FROM_SYSTEM     = 0x00001000 LANG_NEUTRAL                   = 0x00000000 SUBLANG_DEFAULT                = 0x00000001  FormatMessage         = windll.kernel32.FormatMessageW GetLastError          = windll.kernel32.GetLastError LocalFree             = windll.kernel32.LocalFree RtlNtStatusToDosError = windll.ntdll.RtlNtStatusToDosError  def printerror(err):    def MAKELANGID(p, s):       return c_ulong((s &lt;&lt; 10) | p)    msg = c_void_p()    err = RtlNtStatusToDosError(err) if err != 0 else GetLastError()    FormatMessage(       FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,       None,       err,       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),       byref(msg),       0,       None    )    print(c_wchar_p(msg.value).value.strip())    LocalFree(msg) <\/code><\/pre>\n<p>  \u042d\u0434\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e <s>\u0424\u0440\u0435\u0439\u0434\u0443<\/s> \u0420\u0438\u0445\u0442\u0435\u0440\u0443, \u043f\u0440\u0430\u0432\u0434\u0430 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u0448\u043b\u0438 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c: \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 printerror \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a <i>NTSTATUS<\/i>, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 <i>GetLastError<\/i>.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a clockres \u2014 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 SysInternals Suite, \u0441 \u043d\u0435\u0433\u043e \u0438 \u043d\u0430\u0447\u043d\u0435\u043c. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 russinovich.py \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>NtQueryTimerResolution<\/i>:<\/p>\n<pre><code class=\"python\">... NtQueryTimerResolution = windll.ntdll.NtQueryTimerResolution ... <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <i>clockres.py<\/i>:<\/p>\n<pre><code class=\"python\">from russinovich import printerror, NtQueryTimerResolution from ctypes      import byref, c_ulong from sys         import exit  if __name__ == '__main__':    _max, _min, _cur = c_ulong(), c_ulong(), c_ulong()     ntstatus = NtQueryTimerResolution(byref(_max), byref(_min), byref(_cur))    if ntstatus != 0:       printerror(ntstatus)       exit(1)    print('Maximum timer interval: %.3f ms' % (_max.value \/ 10000))    print('Minimum timer interval: %.3f ms' % (_min.value \/ 10000))    print('Current timer interval: %.3f ms' % (_cur.value \/ 10000)) <\/code><\/pre>\n<p>  \u0410 \u043e\u0442\u043a\u0443\u0434\u0430, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0437\u044f\u0442\u0430 NtQueryTimerResolution? \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from os.path import abspath &gt;&gt;&gt; with open(abspath('clockres.exe'), 'rb') as f: ...     raw = str(f.read(), 'utf7', 'replace') ... &gt;&gt;&gt; from re import compile, findall &gt;&gt;&gt; for i in compile('[\\x20-\\x7E]{13,}').findall(raw): print(i) ... !This program cannot be run in DOS mode. tM&lt;it-&lt;ot)&lt;ut%&lt;xt!&lt;Xt &lt;dty&lt;itu&lt;otq&lt;utm&lt;xti&lt;Xte Current timer interval: %.03f ms Minimum timer interval: %.03f ms Maximum timer interval: %.03f ms NtQueryTimerResolution ... &gt;&gt;&gt; <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0438 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043e\u043c \u2014 \u043a\u043e\u043c\u0443 \u043a\u0430\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f.<\/p>\n<p>  Clockres \u2014 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e, \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, pipelist, \u0442\u0435\u043c \u043f\u0430\u0447\u0435, \u0447\u0442\u043e \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0420\u0443\u0441\u0441\u0438\u043d\u043e\u0432\u0438\u0447 \u043d\u0435 \u0441\u0442\u0430\u043b \u0445\u043e\u0434\u0438\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u0434\u0430 \u043e\u043a\u043e\u043b\u043e, \u0430 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u0443\u044e \u0437\u0430\u044f\u0432\u0438\u043b, \u043c\u043e\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <i>NtQueryDirectoryFile<\/i>, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 (\u043f\u0440\u0430\u0432\u0434\u0430 \u0441 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u043e\u0439 Zw) \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043b\u0438\u0431\u043e \u0432 MSDN, \u043b\u0438\u0431\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <i>ntifs.h<\/i>:<\/p>\n<pre><code class=\"cpp\">... #if (NTDDI_VERSION &gt;= NTDDI_WIN2K) __drv_maxIRQL(PASSIVE_LEVEL) NTSYSAPI NTSTATUS NTAPI ZwQueryDirectoryFile(     __in HANDLE FileHandle,     __in_opt HANDLE Event,     __in_opt PIO_APC_ROUTINE ApcRoutine,     __in_opt PVOID ApcContext,     __out PIO_STATUS_BLOCK IoStatusBlock,     __out_bcount(Length) PVOID FileInformation,     __in ULONG Length,     __in FILE_INFORMATION_CLASS FileInformationClass,     __in BOOLEAN ReturnSingleEntry,     __in_opt PUNICODE_STRING FileName,     __in BOOLEAN RestartScan     ); #endif ... <\/code><\/pre>\n<p>  \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c NtQueryDirectoryFile \u0432 russinovich.py:<\/p>\n<pre><code class=\"python\">... NtQueryDirectoryFile = windll.ntdll.NtQueryDirectoryFile ... <\/code><\/pre>\n<p>  \u0422\u0430\u043c \u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0447\u0438\u0435 \u0442\u0438\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f:<\/p>\n<pre><code class=\"python\">from ctypes import (    ..., Structure, Union, c_long, c_longlong, addressof, c_wchar, sizeof )  ... class LARGE_INTEGER_UNION(Structure):    _fields_ = [       ('LowPart',  c_ulong),       ('HighPart', c_ulong),    ]  class LARGE_INTEGER(Union):    _fields_ = [       ('liu1',     LARGE_INTEGER_UNION),       ('liu2',     LARGE_INTEGER_UNION),       ('QuadPart', c_longlong),    ]  class FILE_DIRECTORY_INFORMATION(Structure):    _fields_ = [       ('NextEntryOffset', c_ulong),       ('FileIndex',       c_ulong),       ('CreationTime',    LARGE_INTEGER),       ('LastAccessTime',  LARGE_INTEGER),       ('LastWriteTime',   LARGE_INTEGER),       ('ChangeTime',      LARGE_INTEGER),       ('EndOfFile',       LARGE_INTEGER),       ('AllocationSize',  LARGE_INTEGER),       ('FileAttributes',  c_ulong),       ('FileNameLength',  c_ulong),       ('_FileName',       c_wchar * 1),    ]    @property    def FileName(self):       addr = addressof(self) + type(self)._FileName.offset       name = c_wchar * (self.FileNameLength \/\/ sizeof(c_wchar))       return name.from_address(addr).value ... <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u0435 _FileName \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 FILE_DIRECTORY_INFORMATION \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043b\u0438\u0448\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u043c\u0435\u043d\u0438, \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c FileName, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0435\u0435 \u0438\u043c\u044f \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u041f\u0430\u0440\u0430 \u0448\u0442\u0440\u0438\u0445\u043e\u0432 \u043a russinovich.py:<\/p>\n<pre><code class=\"python\">... GENERIC_READ             = 0x80000000 FILE_SHARE_READ          = 0x00000001 OPEN_EXISTING            = 0x00000003 INVALID_HANDLE_VALUE     = -1 FileDirectoryInformation = 1 ... CloseHandle = windll.kernel32.CloseHandle CreateFile  = windll.kernel32.CreateFileW ... <\/code><\/pre>\n<p>  \u0418 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <i>pipelist.py<\/i>:<\/p>\n<pre><code class=\"python\">from russinovich import (    CloseHandle, CreateFile, NtQueryDirectoryFile, GENERIC_READ,    FILE_SHARE_READ, OPEN_EXISTING, INVALID_HANDLE_VALUE, printerror,    IO_STATUS_BLOCK, FILE_DIRECTORY_INFORMATION, FileDirectoryInformation ) from ctypes      import (    POINTER, addressof, byref, cast, create_string_buffer ) from sys         import exit  def NT_SUCCESS(ntstatus): return True if ntstatus &gt;= 0 else False  if __name__ == '__main__':    pipes = None        try:       isb = IO_STATUS_BLOCK()       dir_inf = cast(create_string_buffer(1024), POINTER(FILE_DIRECTORY_INFORMATION))       query = True              pipes = CreateFile('\\\\\\\\.\\\\pipe\\\\', GENERIC_READ, FILE_SHARE_READ, None, OPEN_EXISTING, 0, None)              if pipes == INVALID_HANDLE_VALUE:          printerror(0)          exit(1)                 print(&quot;%-40s%14s%20s&quot; % ('Pipe Name', 'Instances', 'Max Instances'))       print(&quot;%-40s%14s%20s&quot; % ('-' * 9, '-' * 9, '-' * 13))              while(1):          ntstatus = NtQueryDirectoryFile(             pipes,             None,             None,             0,             byref(isb),             dir_inf,             1024,             FileDirectoryInformation,             False,             None,             query          )                    if not NT_SUCCESS(ntstatus): break                    cur_inf = dir_inf          while(1):             cur = cur_inf.contents             print(&quot;%-40s%14s%20s&quot; % (cur.FileName, cur.EndOfFile.liu1.LowPart, cur.AllocationSize.liu1.LowPart))             if cur.NextEntryOffset == 0: break             cur_inf = cast(int(addressof(cur)) + cur.NextEntryOffset, POINTER(FILE_DIRECTORY_INFORMATION))          query = False    except Exception as e:       print(e)    finally:       CloseHandle(pipes) <\/code><\/pre>\n<p>  \u0412\u0438\u0434 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043e\u0433\u043d\u0430\u043d \u043f\u043e\u0434 \u0442\u043e\u0442, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442 pipelist \u0420\u0443\u0441\u0441\u0438\u043d\u043e\u0432\u0438\u0447\u0430, \u0442\u0430\u043a \u0447\u0442\u043e, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f. \u0410 \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043d\u0435\u0442, \u043a\u0430\u043a\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/p>\n<p>  \u0423\u0442\u0438\u043b\u0438\u0442 SysInternals \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435 \u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u2026     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/256161\/\"> http:\/\/habrahabr.ru\/post\/256161\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<table>\n<tr>\n<td>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/eac\/af8\/6b2\/eacaf86b23b1795019d73a917a48530c.png\" alt=\"ctypes\"\/><\/td>\n<td>\u0421\u0440\u0435\u0434\u0438 \u0443\u0442\u0438\u043b\u0438\u0442 SysInternals \u0435\u0441\u0442\u044c \u0442\u0435, \u0447\u0442\u043e \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0433\u043e\u0434\u0430\u043c\u0438, \u0430 \u0438\u0445 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0418 \u0432\u0441\u0435 \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0438\u0445 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u044f\u0437\u044b\u043a \u043d\u0435 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430 Python \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e; \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u0441\u043a\u043e\u0440\u0435\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-255591","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=255591"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255591\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}