[issue29131] Calling printf from the cdll does not print the full string

2017-01-02 Thread Eryk Sun
Eryk Sun added the comment: > I am following the "Gray Hat Python - Python Programming for Hackers and > Reverse Engineers" >From what I've seen in Stack Overflow questions asked by people reading that >book, its ctypes code is generally of poor quality. It only works in 32-bit >Python 2 beca

[issue29131] Calling printf from the cdll does not print the full string

2017-01-02 Thread mike peremsky
mike peremsky added the comment: I appreciate the feedback, but as I had originally mentioned. I am following the "Gray Hat Python - Python Programming for Hackers and Reverse Engineers" book and was attempting to use Python 3 instead of Python 2 (as was used in the book). The cdll code is tak

[issue29131] Calling printf from the cdll does not print the full string

2017-01-02 Thread Eryk Sun
Eryk Sun added the comment: > from ctypes import * > msvcrt = cdll.msvcrt > message_string = "Hello World!\n" > msvcrt.printf("Testing: %s", message_string) Avoid using libraries as attributes of cdll and windll. They get cached, and in turn they cache function pointers. Thus all modules conten

[issue29131] Calling printf from the cdll does not print the full string

2017-01-02 Thread Eryk Sun
Changes by Eryk Sun : -- Removed message: http://bugs.python.org/msg284525 ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue29131] Calling printf from the cdll does not print the full string

2017-01-02 Thread Eryk Sun
Eryk Sun added the comment: > from ctypes import * > msvcrt = cdll.msvcrt > message_string = "Hello World!\n" > msvcrt.printf("Testing: %s", message_string) Avoid using libraries as attributes of cdll and windll. They get cached, and in turn they cache function pointers. Thus all modules conten

[issue29131] Calling printf from the cdll does not print the full string

2017-01-02 Thread R. David Murray
Changes by R. David Murray : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python

[issue29131] Calling printf from the cdll does not print the full string

2017-01-01 Thread Steve Dower
Steve Dower added the comment: Though if you do really want to use the (very) old msvcrt DLL rather than the proper functionality, calling cdd.msvcrt.wprintf will behave as you expect, or prefixing the strings with b (e.g. b"Testing") will pass it as bytes rather than wchar_t. But unless all

[issue29131] Calling printf from the cdll does not print the full string

2017-01-01 Thread Steve Dower
Steve Dower added the comment: In Python 3, this passes a wchar_t* string, but printf('%s') expects a char* string. You may want to start by looking at the tutorial at https://docs.python.org/3/tutorial/index.html to get a feel for what builtins are available. Using ctypes is fairly advanced

[issue29131] Calling printf from the cdll does not print the full string

2017-01-01 Thread mike peremsky
New submission from mike peremsky: I am going throught he Gray Hat Python book and installed Python 3.7 (32-bit) on a windows x64 machine. The following code will only print the first character of the passed string argument. The same code run on Python 2.7 will print the correct string value.