What the assignment of the attribute magicnumber should do is that the Python interpreter shall write the 32bit address 0xCAFEBABE into the right memory address of the pointer inside the structure (what many other Python distributions except of IronPython can do). Other Python implementations (CPyhton 2.x, CPython 3.x, PyPy & ActivePython. Unfortunately the last assignment raises an OverflowError. Mystruct.magicnumber = cast(0xCAFEBABE, c_char_p) In addition I am only allowed to use the 32bit version of the IronPython interpreter since I have to load a 32bit DLL. This 'address' will not be a valid memory address to read from but it acts as a magic word to trigger something (you can read the background of why I have to use a char* without content in my question at ' How do I set an IronPython ctypes c_char_p pointer to an absolute address manually?' where the original question was not good enough for my problem). In IronPython 2.7.9 I need to set a c_char_p to the absolute address 0xCAFEBABE.
0 Comments
Leave a Reply. |