Jump to content
Korean Random
fecell

Создание PYD для embedded python

Recommended Posts

по идее без структур ничего не запустишь...

Ну я джва года ждал штобы грабить корованы - не спешу в принципе никуда ;)

Share this post


Link to post

Short link
Share on other sites

@Mixaill, сигнатуры некоторые можно сократить.

"\x55\x8B\xEC\x81\xEC\x14\x02" (xxxxxxx) достаточно для Py_InitModule4, по крайней мере с 9.4 и до сих пор (на тестовых не знаю).

Edited by fecell

Share this post


Link to post

Short link
Share on other sites

сигнатуры некоторые можно сократить.

Я даже на питоне написал функцию для минимилазции)

Сути это не меняет.

Лишние несколько байт не мешают ведь.

Share this post


Link to post

Short link
Share on other sites

Я даже на питоне написал функцию для минимилазции)

Сути это не меняет.

Лишние несколько байт не мешают ведь.

 

Вот меня периодически спрашивают, почему я код

self.angles = (0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345)

не запишу циклом. А я отвечаю - константы ни кому еще не мешали )))))))

Share this post


Link to post

Short link
Share on other sites

Вопрос незнающего человека. Ctypes заработает с Вашим PYD?

Можно попытаться.

Edited by Mixaill

Share this post


Link to post

Short link
Share on other sites

 

 

PyList_New

 

PyList_Append_tmpl = "\x55\x8B\xEC\x8B\x4D\x08\x8B\x41\x04\xF7\x40\x54\x00\x00\x00\x02\x74";
PyList_Append_mask = "xxxxxxxxxxxxxxxxx";

 

PyList_New_tmpl = "\x55\x8B\xEC\x57\x8B\x7D\x08\x85\xFF\x79";

PyList_New_mask = "xxxxxxxxxx"; 

Share this post


Link to post

Short link
Share on other sites

@fecell, ну такие простые функции можно было и не скидывать.

А вот PyCapsule_IsValid, PyCapsule_GetPointer и прочие полезно было бы и отыскать...

Edited by SkepticalFox

Share this post


Link to post

Short link
Share on other sites
PyCapsule_IsValid

 

смещение E9A9A0 (9.16), 12DBD10 (9.14) сигнатуру признаться не смотрел.

 

PyCapsule_GetPointer

 

E9A7D0 (9.16), 12DBB40 (9.14)

 

'бросилось в глаза.. остальные завтра, три ночи за окном как-никак'

#    PyDict_GetItem_Address
\x55\x8b\xec\x83\xec\x08\x53\x8b\x5d\x08\x8b\x43\x04\xf7\x40\x54\x00\x00\x00\x20\x75\x07\x33\xc0\x5b\x8b\xe5\x5d\xc3
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

#    WorldOfTanks_9_15o.exe
\x55\x8b\xec\x83\xec\x08\x53\x8b\x5d\x08\x8b\x43
xxxxxxxxxxxx

#    WorldOfTanks_9_16o.exe
\x55\x8b\xec\x83\xec\x08\x53\x8b\x5d\x08\x8b\x43
xxxxxxxxxxxx

избыточность уж слишком большая, имхо.

Edited by fecell

Share this post


Link to post

Short link
Share on other sites

смещение E9A9E0 (9.16), 12DBD10 (9.14) сигнатуру признаться не смотрел.

Вообще не то.

Это PyCapsule_New

Edited by SkepticalFox

Share this post


Link to post

Short link
Share on other sites

Вообще не то. Это PyCapsule_New

 

блин, ночью заметил что ошибся, и исправил на... тоже самое что было, по запарке.

Сейчас уже выше исправил смещение на верное.

'asm code for check'

.text:00E9A9A0 sub_E9A9A0 proc near
.text:00E9A9A0
.text:00E9A9A0 arg_0= dword ptr  8
.text:00E9A9A0 arg_4= dword ptr  0Ch
.text:00E9A9A0
.text:00E9A9A0 push    ebp
.text:00E9A9A1 mov     ebp, esp
.text:00E9A9A3 mov     eax, [ebp+arg_0]
.text:00E9A9A6 test    eax, eax
.text:00E9A9A8 jz      short loc_E9A9D2
.text:00E9A9AA cmp     dword ptr [eax+4], offset unk_1980968
.text:00E9A9B1 jnz     short loc_E9A9D2
.text:00E9A9B3 cmp     dword ptr [eax+8], 0
.text:00E9A9B7 jz      short loc_E9A9D2
.text:00E9A9B9 push    [ebp+arg_4]
.text:00E9A9BC push    dword ptr [eax+0Ch]
.text:00E9A9BF call    sub_E9AA80
.text:00E9A9C4 add     esp, 8
.text:00E9A9C7 test    eax, eax
.text:00E9A9C9 jz      short loc_E9A9D2
.text:00E9A9CB mov     eax, 1
.text:00E9A9D0 pop     ebp
.text:00E9A9D1 retn
.text:00E9A9D2
.text:00E9A9D2 loc_E9A9D2:
.text:00E9A9D2 xor     eax, eax
.text:00E9A9D4 pop     ebp
.text:00E9A9D5 retn
.text:00E9A9D5 sub_E9A9A0 endp
.text:1E0860F0 ; Attributes: bp-based frame
.text:1E0860F0
.text:1E0860F0 ; int __cdecl PyCapsule_IsValid(_object *o, const char *name)
.text:1E0860F0             public _PyCapsule_IsValid
.text:1E0860F0 _PyCapsule_IsValid proc near        ; CODE XREF: importmap+33↑p
.text:1E0860F0                         ; importmap_0+33↑p ...
.text:1E0860F0
.text:1E0860F0 o           = dword ptr  8
.text:1E0860F0 name        = dword ptr  0Ch
.text:1E0860F0
.text:1E0860F0             push    ebp
.text:1E0860F1             mov     ebp, esp
.text:1E0860F3             mov     eax, [ebp+o]
.text:1E0860F6             test    eax, eax
.text:1E0860F8             jz      short loc_1E08611F
.text:1E0860FA             cmp     dword ptr [eax+4], offset _PyCapsule_Type
.text:1E086101             jnz     short loc_1E08611F
.text:1E086103             cmp     dword ptr [eax+8], 0
.text:1E086107             jz      short loc_1E08611F
.text:1E086109             mov     ecx, [ebp+name] ; name2
.text:1E08610C             mov     eax, [eax+0Ch]  ; name1
.text:1E08610F             call    name_matches
.text:1E086114             test    eax, eax
.text:1E086116             jz      short loc_1E08611F
.text:1E086118             mov     eax, 1
.text:1E08611D             pop     ebp
.text:1E08611E             retn
.text:1E08611F ; ---------------------------------------------------------------------------
.text:1E08611F
.text:1E08611F loc_1E08611F:                   ; CODE XREF: _PyCapsule_IsValid+8↑j
.text:1E08611F                         ; _PyCapsule_IsValid+11↑j ...
.text:1E08611F             xor     eax, eax
.text:1E086121             pop     ebp
.text:1E086122             retn
.text:1E086122 _PyCapsule_IsValid endp

Edited by fecell

Share this post


Link to post

Short link
Share on other sites

обновил первый пост под 9.16, добавил в исходник пример реализации __doc__ для пида.

Edited by fecell
  • Upvote 2

Share this post


Link to post

Short link
Share on other sites

@kharlashkin, ну что?

У меня так:

attachicon.gifСнимок экрана (310).png

ImportError: dynamic module does not define init function (initpython27)

 

Потому что Python27 (с большой буковки)

 

_ctypes у меня вчера крашился c access violation, возможно неверно завернул структуры (ещё нет в репе)

Share this post


Link to post

Short link
Share on other sites

Потому что Python27 (с большой буковки)

Блин. Точно.

Теперь так

_ctypes = imp.load_dynamic('_ctypes', 'res_mods/_ctypes.pyd')
#ImportError: DLL load failed: Не найдена указанная процедура.
Edited by SkepticalFox

Share this post


Link to post

Short link
Share on other sites

Блин. Точно.

Теперь так

_ctypes = imp.load_dynamic('_ctypes', 'res_mods/_ctypes.pyd')
#ImportError: DLL load failed: Не найдена указанная процедура.

 

Залил вчерашние наработки, теперь дойдет до краша.

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...