Failed to import my Python wrapper into IDA (version 6.3, Windows edition)

635 views
Skip to first unread message

jun

unread,
Aug 13, 2012, 4:07:48 AM8/13/12
to idap...@googlegroups.com
hi IDA experts,

i have a C++ library, and wrote a Python wrapper around that. i wrote some Python code with this wrapper, and it works perfectly on Windows. so it seems there is no problem with my C++ lib, Python wrapper or my Python code.

now i want to run this code inside IDA (6.3, Windows edition) with a IDAPython script. however, when my IDAPython (just only) imports my Python wrapper, IDA reports error like below.

########
Runtime Error!
Program: c:\program files\ida\idaq.exe
R6034
An application has made an attempt to load the C runtime library incorrectly.

ImportError: DLL load failed: DLL initialization routine failed.
########

so it seems the problem is that inside IDAPython, the wrapper cannot load the C++ core. i am wondering why this happens, given that my python wrapper works very well outside IDA.

i suspect that for a Python wrapper to work inside IDA, it must be coded in special way, or something specific to IDAPython must be made for the wrapper to load the C++ lib?

this is pretty frustrated, and i have no idea how to fix that. Elias told me to debug this code, but because it seems the problem is with the C++ lib, i have no idea how to do that under IDAPython environment.

please would you give me some hints?

thanks a lot!
Jun

nir izraeli

unread,
Aug 13, 2012, 4:26:53 AM8/13/12
to idap...@googlegroups.com

You would probably get responses from more knowledgeable people in the list soon,


But I’ve seen this error when trying to load the original PySide library for python instead of the one IDA provides for it.

you might want to try to take a look at the patch (supposed to be very small) to figure out what you should do to make it work.

you can download the patch at IDA's licensed users download center...


hope this helps,

 - Nir



Jun

--
You received this message because you are subscribed to the Google Groups "idapython" group.
To view this discussion on the web visit https://groups.google.com/d/msg/idapython/-/TWiniZrbvBAJ.
To post to this group, send email to idap...@googlegroups.com.
To unsubscribe from this group, send email to idapython+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/idapython?hl=en.

Jun Koi

unread,
Aug 13, 2012, 4:48:32 AM8/13/12
to idap...@googlegroups.com
On Mon, Aug 13, 2012 at 4:26 PM, nir izraeli <nir...@gmail.com> wrote:
> You would probably get responses from more knowledgeable people in the list
> soon,
>
>
> But I’ve seen this error when trying to load the original PySide library for
> python instead of the one IDA provides for it.
>
> you might want to try to take a look at the patch (supposed to be very
> small) to figure out what you should do to make it work.
>
> you can download the patch at IDA's licensed users download center...

what a great hint, thanks!

but ... at the support download center, i can only see the patch there
without the original code (named pyside_clone.tgz in the readme.txt
file)
without the original code, it is hard to figure out what is changed in
the patch.

so where can i find the pyside_clone.tgz?

any further hint on how to modify my C++ lib & Python wrapper so it
can be imported into IDAPython would be hugely appreciated!!!

thanks!
Jun

nir izraeli

unread,
Aug 13, 2012, 4:59:15 AM8/13/12
to idap...@googlegroups.com
pyside is a package for running QT in python, it has its own site and sources can be downloaded from the Qt project wiki at  http://qt-project.org/wiki/PySideDownloads
might be a bit tricky to get the exact version...

I'm afraid i can't help you further since i mostly write my libraries in python to begin with,
- Nir

Lauri N

unread,
Aug 13, 2012, 10:12:04 AM8/13/12
to idap...@googlegroups.com, Jun Koi
Hi.

The problem arises from trying to load a dll with depends on one version
of C runtime into a process that depends on another version
(http://msdn.microsoft.com/en-us/library/ms235560(v=vs.80).aspx
<http://msdn.microsoft.com/en-us/library/ms235560%28v=vs.80%29.aspx>).

Check the comments for solution or build your dll against the same
version of C runtime as the exe.

Lauri
On 13.08.2012 11:48, Jun Koi wrote:
> On Mon, Aug 13, 2012 at 4:26 PM, nir izraeli<nir...@gmail.com> wrote:
>> You would probably get responses from more knowledgeable people in the list
>> soon,
>>
>>
>> But I�ve seen this error when trying to load the original PySide library for
>> python instead of the one IDA provides for it.
>>
>> you might want to try to take a look at the patch (supposed to be very
>> small) to figure out what you should do to make it work.
>>
>> you can download the patch at IDA's licensed users download center...
> what a great hint, thanks!
>
> but ... at the support download center, i can only see the patch there
> without the original code (named pyside_clone.tgz in the readme.txt
> file)
> without the original code, it is hard to figure out what is changed in
> the patch.
>
> so where can i find the pyside_clone.tgz?
>
> any further hint on how to modify my C++ lib& Python wrapper so it

Jun Koi

unread,
Aug 21, 2012, 6:17:02 AM8/21/12
to Lauri N, idap...@googlegroups.com
On Mon, Aug 13, 2012 at 10:12 PM, Lauri N <lauri...@gmail.com> wrote:
> Hi.
>
> The problem arises from trying to load a dll with depends on one version of
> C runtime into a process that depends on another version
> (http://msdn.microsoft.com/en-us/library/ms235560(v=vs.80).aspx
> <http://msdn.microsoft.com/en-us/library/ms235560%28v=vs.80%29.aspx>).
>
> Check the comments for solution or build your dll against the same version
> of C runtime as the exe.

Lauri, thanks for the great hint! this certainly help me to move
closer to the solution.

actually, my situation is like this: my Python wrapper compiles a .PYD
file, and IDA 6.3 would need to load this PYD file in (when i import
the Python wrapper)

i use Dependency Walker, and can confirm that the PYD file depends on
msvcp90.dll and msvcr90.dll.
(I use Python 2.7, and Visual Studio 2008, if that matters)

however, since IDA 6.3 depends on msvcp100.dll and msvcr100.dll, this
seems to be the reason why IDA cannot load my PYD file (which depend
on another version of msvcr and msvcp, as you pointed out)

then now the solution for my problem would be to specify the MSVC DLL
version in the manifest file.
but then i have no idea how to do that with
disutils.core.setup/Extension in Python. all the dependencies seems to
be chosen automatically, and i dont see any way to correct the
problem.

do you have any idea on how to fix this?

thanks so much!
Jun






>> On Mon, Aug 13, 2012 at 4:26 PM, nir izraeli<nir...@gmail.com> wrote:
>>>
>>> You would probably get responses from more knowledgeable people in the
>>> list
>>> soon,
>>>
>>>
>>> But I’ve seen this error when trying to load the original PySide library
Reply all
Reply to author
Forward
0 new messages