Python ctypes.wintypes.USHORT Examples

The following are 2 code examples of ctypes.wintypes.USHORT(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ctypes.wintypes , or try the search function .
Example #1
Source File: evntprov.py    From pywintrace with Apache License 2.0 5 votes vote down vote up
def __init__(self, filter_in, events):
        struct_size = len(events) * ct.sizeof(wt.USHORT) + ct.sizeof(EVENT_FILTER_EVENT_ID)
        self._buf = (ct.c_char * struct_size)()
        self._props = ct.cast(ct.pointer(self._buf), ct.POINTER(EVENT_FILTER_EVENT_ID))
        self._props.contents.FilterIn = filter_in
        self._props.contents.Reserved = 0
        self._props.contents.Count = len(events)

        for i in range(len(events)):
            ct.memmove(ct.cast(ct.addressof(self._buf) + ct.sizeof(EVENT_FILTER_EVENT_ID) + (ct.sizeof(wt.WCHAR) * i),
                               ct.c_void_p),
                       ct.byref(wt.USHORT(events[i])),
                       ct.sizeof(wt.WCHAR)) 
Example #2
Source File: test_etw.py    From pywintrace with Apache License 2.0 4 votes vote down vote up
def test_etw_eq(self):
        """
        Test container classes comparision

        :return: None
        """

        params = et.ENABLE_TRACE_PARAMETERS()
        params.Version = 1
        other_params = et.ENABLE_TRACE_PARAMETERS()
        other_params.Version = 1

        provider = ProviderInfo('Microsoft-Windows-Kernel-Process',
                                GUID("{22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716}"),
                                any_keywords=['WINEVENT_KEYWORD_PROCESS'],
                                params=ct.pointer(params))

        other_provider = ProviderInfo('Microsoft-Windows-Kernel-Process',
                                      GUID("{22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716}"),
                                      any_keywords=['WINEVENT_KEYWORD_PROCESS'],
                                      params=ct.pointer(other_params))
        self.assertEqual(provider, other_provider)
        other_params.Version = 2
        self.assertNotEqual(provider, other_provider)
        event_id_list = [54]
        event_filter = ep.EVENT_FILTER_EVENT_ID(common.TRUE, event_id_list).get()
        event_filters = [ep.EVENT_FILTER_DESCRIPTOR(ct.addressof(event_filter.contents),
                                                    ct.sizeof(event_filter.contents) +
                                                    ct.sizeof(wt.USHORT) * len(event_id_list),
                                                    ep.EVENT_FILTER_TYPE_EVENT_ID)]
        properties = ProviderParameters(0, event_filters)
        other_properties = ProviderParameters(0, event_filters)
        self.assertEqual(properties, other_properties)

        other_properties.get().contents.Version = 1
        self.assertNotEqual(properties, other_properties)

        params = TraceProperties(1024, 1024, 0, 10)
        other_params = TraceProperties(1024, 1024, 0, 10)
        self.assertEqual(params, other_params)
        other_params.get().contents.BufferSize = 1025

        self.assertNotEqual(params, other_params)

        return