Win32::APIã¢ã¸ã¥ã¼ã«ãDynaLoaderã§ã®ãHello, World!ãããã°ã©ã
ä»ã®ç§ã®ã¬ãã«ã§ã¯ããã³ãã³ã«ã³ãã³ã§ãããã¨ããããã¡ã¢ãã¨ãã¾ãã
âWin32::APIã¢ã¸ã¥ã¼ã«ã§
#!/usr/bin/perl use Win32::API; my $MessageBox = Win32::API->new("user32", "MessageBoxA", "NPPN", "N"); $MessageBox->Call(0, "Hello, World!\n", "Message", 0);http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559
âDynaLoaderã§
#!/usr/bin/perl use DynaLoader; sub GetProcAddress { my ($DLL, $API) = @_; my $path = "$ENV{SystemRoot}\\system32\\$DLL"; my $libref = DynaLoader::dl_load_file($path); pack "L", DynaLoader::dl_find_symbol($libref, $API); } my $x86 = "" . "h\0\0\0\0" . "h" . pack("P", "Message") . "h" . pack("P", "Hello, World!\n") . "h\0\0\0\0" . "\xb8" . GetProcAddress("user32.dll", "MessageBoxA") . "\xff\xd0" # call eax . "\xc3" # ret ; DynaLoader::dl_install_xsub("X",unpack"L",pack"P",$x86);&X;http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559
æãªæã«ã½ã¼ã¹è§£æããã¦ã¿ã¾ããã
ããããå
¥éã¨ãããªãããã½ã¼ã¹è§£èª¬ãå
¨ããªãã§ããã
ã ããéã«èª¿ã¹ããã¨ã«ãªããå
¥éã«ãªãã®ï½¥ï½¥ï½¥ããã