{"action":"created","issue":{"url":"https://api.github.com/repos/radare/radare2-bindings/issues/188","repository_url":"https://api.github.com/repos/radare/radare2-bindings","labels_url":"https://api.github.com/repos/radare/radare2-bindings/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/radare/radare2-bindings/issues/188/comments","events_url":"https://api.github.com/repos/radare/radare2-bindings/issues/188/events","html_url":"https://github.com/radare/radare2-bindings/issues/188","id":315829837,"number":188,"title":"limits of Python bindings to write plugins","user":{"login":"Wenzel","id":964610,"avatar_url":"https://avatars2.githubusercontent.com/u/964610?v=4","gravatar_id":"","url":"https://api.github.com/users/Wenzel","html_url":"https://github.com/Wenzel","followers_url":"https://api.github.com/users/Wenzel/followers","following_url":"https://api.github.com/users/Wenzel/following{/other_user}","gists_url":"https://api.github.com/users/Wenzel/gists{/gist_id}","starred_url":"https://api.github.com/users/Wenzel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wenzel/subscriptions","organizations_url":"https://api.github.com/users/Wenzel/orgs","repos_url":"https://api.github.com/users/Wenzel/repos","events_url":"https://api.github.com/users/Wenzel/events{/privacy}","received_events_url":"https://api.github.com/users/Wenzel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-04-19T11:06:08Z","updated_at":"2018-04-20T13:46:21Z","closed_at":null,"author_association":"NONE","body":"Hi !\r\n\r\nI developed an [IO and debug plugins](https://github.com/Wenzel/radare2-extras/tree/vmi/vmi) for radare2 in C, and i wanted to port them in Python.\r\n\r\nAs there was no support to register a debug plugin in Python with `r2lang`, i forked `radare2-bindings` and started to implement the required [function and interface](https://github.com/Wenzel/radare2-bindings/blob/debug_python/libr/lang/p/python/debug.c).\r\n\r\nHowever, i realized that i would not be able to fully translate my C debug plugin to python, because of limitation of the bindings:\r\n\r\nFor example my `__attach` implementation requires to access multiple sub-fields of the `RDebug *` structure, (`dbg->iob.io->desc->data`), and from this pointer, i need to recreate my `RIOVmi *`.\r\n~~~C\r\nstatic int __attach(RDebug *dbg, int pid) {\r\n    RIODesc *desc = NULL;\r\n    RIOVmi *rio_vmi = NULL;\r\n    status_t status = 0;\r\n\r\n    printf(\"Attaching to pid %d...\\n\", pid);\r\n\r\n    desc = dbg->iob.io->desc;\r\n    rio_vmi = desc->data;\r\n~~~\r\n\r\nwhile I'm implementing this in `libr/lang/p/python/debug.c`, i don't really know how to pass the content of the `RDebug *` structure:\r\n~~~C\r\nstatic int py_debug_attach(RDebug *dbg, int pid) {\r\n\tprintf(\"py %s\\n\", __func__);\r\n        PyObject *arglist = Py_BuildValue (?????);\r\n        PyObject *result = PyEval_CallObject (py_debug_attach_cb, arglist);\r\n}\r\n~~~\r\n\r\nWhich could allow me to implement my debugger and have the same arguments:\r\n~~~Python\r\nimport r2lang\r\ndef pydebug(_):\r\n\r\n    def attach(rdebug, pid):\r\n        print(\"attaching !\")\r\n\r\nprint(\"Registering Python debug plugin...\")\r\nprint(r2lang.plugin(\"debug\", pydebug))\r\n~~~\r\n\r\nSo what is the status of the Python bindings ?\r\nWhat solution do you recommend ?\r\n\r\ncc @XVilka \r\n\r\nThanks !"},"comment":{"url":"https://api.github.com/repos/radare/radare2-bindings/issues/comments/383100991","html_url":"https://github.com/radare/radare2-bindings/issues/188#issuecomment-383100991","issue_url":"https://api.github.com/repos/radare/radare2-bindings/issues/188","id":383100991,"user":{"login":"radare","id":917142,"avatar_url":"https://avatars1.githubusercontent.com/u/917142?v=4","gravatar_id":"","url":"https://api.github.com/users/radare","html_url":"https://github.com/radare","followers_url":"https://api.github.com/users/radare/followers","following_url":"https://api.github.com/users/radare/following{/other_user}","gists_url":"https://api.github.com/users/radare/gists{/gist_id}","starred_url":"https://api.github.com/users/radare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radare/subscriptions","organizations_url":"https://api.github.com/users/radare/orgs","repos_url":"https://api.github.com/users/radare/repos","events_url":"https://api.github.com/users/radare/events{/privacy}","received_events_url":"https://api.github.com/users/radare/received_events","type":"User","site_admin":false},"created_at":"2018-04-20T13:46:21Z","updated_at":"2018-04-20T13:46:21Z","author_association":"OWNER","body":"so the “problem” is only with the debug plugin, not the io one. because you want to get the address of the process selected using rekall? how do you make rekall use the io plugin? i mean.. isnt it suposed to work only with memory dumps?\n\n> On 20 Apr 2018, at 14:55, Mathieu Tarral <notifications@github.com> wrote:\n> \n> And you can just use rekall with r2pipe\n> \n> I agree, and I went into that direction last month.\n> \n> But I realized that I needed to interact with Rekall already in my attach implementation (see my answer above).\n> That's why i started to look into having the plugin in Python.\n> \n> —\n> You are receiving this because you commented.\n> Reply to this email directly, view it on GitHub <https://github.com/radare/radare2-bindings/issues/188#issuecomment-383086716>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA3-lkX7wNHpZNjglI5gmsZ83TSflkpsks5tqdqtgaJpZM4TblxG>.\n> \n\n"}}
{"actor":{"display_login":"radare"}}