Guest User

Untitled

a guest
Aug 3rd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. from ctypes import *
  2.  
  3. for nested, data in (
  4.     (BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
  5.     (LittleEndianStructure, b'\1\0\0\0\2\0\0\0'),
  6. ):
  7.     for parent in (
  8.         BigEndianStructure,
  9.         LittleEndianStructure,
  10.         Structure,
  11.     ):
  12.         class NestedStructure(nested):
  13.             _fields_ = [("x", c_uint32),
  14.                         ("y", c_uint32)]
  15.  
  16.         class TestStructure(parent):
  17.             _fields_ = [("point", NestedStructure)]
  18.  
  19.         ptr = POINTER(TestStructure)
  20.         s = cast(data, ptr)[0]
Add Comment
Please, Sign In to add comment