[pypy-dev] r55005 - in pypy/branch/win32port/pypy: lib lib/_ctypes module/_rawffi module/_rawffi/test rlib rlib/test

Thomas Heller theller at ctypes.org
Wed May 21 11:21:11 CEST 2008


afa at codespeak.net schrieb:
> > Author: afa
> > Date: Tue May 20 16:17:22 2008
> > New Revision: 55005
> > 
> > Modified:
> >    pypy/branch/win32port/pypy/lib/_ctypes/builtin.py
> >    pypy/branch/win32port/pypy/lib/msvcrt.py
> >    pypy/branch/win32port/pypy/module/_rawffi/__init__.py
> >    pypy/branch/win32port/pypy/module/_rawffi/interp_rawffi.py
> >    pypy/branch/win32port/pypy/module/_rawffi/test/test__rawffi.py
> >    pypy/branch/win32port/pypy/rlib/libffi.py
> >    pypy/branch/win32port/pypy/rlib/rwin32.py
> >    pypy/branch/win32port/pypy/rlib/test/test_libffi.py
> > Log:
> > Maciej was right: it's better to dynamically get the name of the msvcrt library:
> > the same generated sources may be recompiled, e.g. in debug mode.
> > 
> > I hope I got it right: in pypy-c.exe, we compile a function that 
> > retrieves the dll containing the "fopen" pointer address.

> > +        #include <stdio.h>
> > +
> > +        /* Get the module where the "fopen" function resides in */
> > +        HANDLE get_libc_handle() {
> > +            MEMORY_BASIC_INFORMATION  mi;
> > +            memset(&mi, 0, sizeof(mi));
> > +
> > +            if( !VirtualQueryEx(GetCurrentProcess(), &fopen, &mi, sizeof(mi)) )
> > +                return 0;
> > +
> > +            return (HMODULE)mi.AllocationBase;
> > +        }
> > +        '''],

Ha, that's the best approach I have seen so far to get the name if the
msvcrt runtime library.  Hope you don't mind if I steal it for 'official'
ctypes (I will check if it works in win64 also before) ?

-- Thanks, Thomas



More information about the Pypy-dev mailing list