Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a string to a char* argument #14

Open
iamkisly opened this issue Aug 13, 2017 · 0 comments
Open

Passing a string to a char* argument #14

iamkisly opened this issue Aug 13, 2017 · 0 comments

Comments

@iamkisly
Copy link

I'm trying to emulate a function call
int __cdecl sub_46F8B0(int a1, char *a2)
The function I want to invoke is a wrapper over sprintf (a2, template, ... ).

In IDA 6.6, I call this:

from idaemu import  * 
a = Emu ( UC_ARCH_X86 , UC_MODE_32 )
print a.eFunc(0x0046F8B0, None, [0x4105C0, ?])

How to pass the second argument? The most reasonable would be to use ctypes.create_string_buffer(%) (because the return type is ctypes.c_char_Array_%). But an integer argument is required.

Python>s2=ctypes.create_string_buffer(50)
Python>print a.eFunc(0x454AB0, None, [0x4105C0, s2])
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:/Program Files (x86)/IDA 6.6/plugins\idaemu.py", line 371, in eFunc
    self._emulate(func.startEA, retAddr, args)
  File "C:/Program Files (x86)/IDA 6.6/plugins\idaemu.py", line 285, in _emulate
    self._initStackAndArgs(uc, stopAddr, args)
  File "C:/Program Files (x86)/IDA 6.6/plugins\idaemu.py", line 177, in _initStackAndArgs
    uc.mem_write(sp, pack(self.pack_fmt, args[i]))
struct.error: cannot convert argument to integer

I'm not strong at python and ctypes. How to be in this situation?

@iamkisly iamkisly changed the title Passing a string to a char * a2 argument Passing a string to a char* argument Aug 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant