WindowsユーザのためのはじめてのPerlプログラミング

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites & 1 Group

    WindowsユーザのためのはじめてのPerlプログラミング - Presentation Transcript

    1. はせがわようすけ Yosuke HASEGAWA
    2. 第1部 WindowsでもPerlを使いたい How can I use Perl on Windows?
    3. WindowsでもPerlを使いたい! How can I use Perl on Windows? それ、ActivePerlでできるよ! You can do that with ActivePerl!
    4. 第1部 完
    5. 第2部 PerlからDLLを呼びたい! Calling DLL from Perl!
    6. PerlからDLLを呼びたい! Calling DLL from Perl! ❤それ、Win32::APIでできるよ! use Win32::API; my $MessageBox = Win32::API->new( DLL名 \"user32\", 関数名 \"MessageBoxA\", \"NPPN\", 引数:整数、ポインタ、ポインタ、整数 \"N\" 戻り値:整数 ); $MessageBox->Call( 0, \"Happy Wedding\", \"Perl\", 0 );
    7. 第2部 完
    8. 第3部 Perlからx86コードを 呼びたい! Calling x86 code from Perl
    9. Perlからx86コードを呼びたい! Calling x86 code from Perl ❤シグナルハンドラを利用 Using signal handlers ❤実行コードのバイト列を用意 Preparing binary array for executable code ❤シグナルハンドラとしてバイト列を指定 Assign the array as a signal handler ❤シグナルの生成 Raise signal to call binary code ❤ActivePerlはヒープごとDEP解除? Disabled DEP for all of heap area?
    10. Perlからx86コードを呼びたい! Calling x86 code from Perl ❤シグナルハンドラでやってみた シグナルハンドラ my $x86 = \"\" 実効するコード . \"¥x83¥x7d¥x08¥x00\" # cmp [dwCtrlEvent], 0 . \"¥x74¥x05\" # je if( not Ctrl+C ) return . \"¥x33¥xc0\" # xor eax, eax . \"¥xc2¥x04¥x00\" # ret 4 . …(略)… ; シグナルハンドラ の設定 $SetConsoleCtrlHandler->Call( unpack( 'L', pack( 'P', $x86 ) ), TRUE ); $GenerateConsoleCtrlEvent->Call( CTRL_C_EVENT, 0 ); Ctrl+C(SIGINT) シグナル発生
    11. Perlからx86コードを呼びたい! Calling x86 code from Perl DEMO
    12. 第3部 完
    13. 第4部 x86コードからPerlを 呼びたい! Calling Perl subs from x86 code
    14. x86コードからPerlを呼びたい! Calling Perl subs from x86 code ❤これもシグナルハンドラでやってみた シグナルハンドラ sub handler { print \"signal¥n\"; } $SIG{INT} = ¥&handler; ハンドラの設定 my $x86 = \"…(略) …\" . \"¥x6a¥0\" # push 0 Process Group Id . \"¥x6a¥0\" # push 0 Ctrl-C Event . \"¥xb8\" # mov eax, addr シグナルの発生 . $addr{'GenerateConsoleCtrlEvent'} . \"¥xff¥xd0\" # call eax . …(略)… ; $SetConsoleCtrlHandler->Call( x86コードの呼出 unpack( 'L', pack( 'P', $x86 ) ), TRUE ); $GenerateConsoleCtrlEvent->Call( CTRL_BREAK_EVENT, 0 );
    15. x86コードからPerlを呼びたい! DEMO
    16. x86コードからPerlを呼びたい! Calling Perl subs from x86 code シグナルを使ったプロセス内通信 InProc communication with signal ❤シグナルを使い分ける Separate signals ❤Perl → x86 : SIGBREAK (Ctrl-Break) ❤x86 → Perl : SIGINT (Ctrl-C) ❤シグナルハンドラ内でシグナルを発生させてる>< Raise signal in signal handler. X-(
    17. x86コードからPerlを呼びたい! Calling Perl subs from x86 code シグナルを使ったプロセス内通信 InProc communication with signal Perlさ~ん バイナリさ~ん
    18. 命 バ シッ 名 通グド 高 信ナ 林 哲 さ ル ん 公 認
    19. x86コードからPerlを呼びたい! Calling Perl subs from x86 code それ Win32::API::Callback で できるよ You can do that with Win32::API::Callback orz
    20. x86コードからPerlを呼びたい! Calling Perl subs from x86 code DEMO
    21. 第4部 完
    22. 第5部 まともな使い道! Decent use
    23. まともな使い道! Decent use ❤stdcall以外のDLL関数も呼び出せる! Calling non-stdcall functions 呼出規約 引数の渡し方 引数のクリア stdcall 右から左にスタックに格納 関数内 右から左にスタックに格納 呼び出し側 cdecl fastcall レジスタを使用 呼び出し側 ❤Win32::API はstdcallのみ Win32::API is only for stdcall
    24. まともな使い道! Decent use DEMO
    25. 第5部 完
    26. まとめ ❤頑張れば結構なんでもできる! ❤バイナリコード書くの難しい? →「迷ったときはテキスト」 ❤printfデバッグ万歳! print unpack( 'H2 ' x length( $x86 ), $x86 ); Thanks to TAKESAKOさん、kazuhoさん、tokuhiromさん

    + Yosuke HASEGAWAYosuke HASEGAWA, 6 months ago

    custom

    1978 views, 2 favs, 1 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1978
      • 1977 on SlideShare
      • 1 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 12
    Most viewed embeds
    • 1 views on http://www.slideshare.net

    more

    All embeds
    • 1 views on http://www.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events