2009年8月8日星期六

[PerlChina] Re: 16进制文件操作

my $tmp;
open (my $fp, '+<', 'filename');
binmode ($fp);
read ($fp, $tmp, 0x8f);
.................
seek ($fp, 0xb0, 0);
read ($fp, $tmp, (-s $fp) - tell ($fp));
.................
close ($fp);


-------- Original Message  --------
Subject: [PerlChina] Re: 16½øÖÆÎļþ²Ù×÷
From: perlw01f <p3r1w01f@gmail.com>
To: PerlChina Mongers ÌÖÂÛ×é <perlchina@googlegroups.com>
Date: 8/8/2009 23:51
½ÓÎÊÒ»¾ä ÈçºÎ ¶ÁÈ¡  0x00-0x8f £¿ ÎÒÏÈ binmode ÔÙ read òËƲ»ºÃʹ£¿   
On 8ÔÂ8ÈÕ, ÏÂÎç7ʱ24·Ö, Anthony WU <anthonywu...@gmail.com> wrote:> ÎÒ°Ñ seek µÚ¶þ ¼°µÚÈý‚€…¢"µŒ'·´ÁË£¬„h³ýÊDz»Äܵģ¬µ«Äã¿ÉÒÔͨß^ ÏÈ×x     
0x00-0x8f Ìøµ½0xb0ÔÙ×xµ½EOFK°ÑËùÈ¡µÃµÄBYTESŒ'µ½Ð™n°¸       
-------- Original Message -------- Subject: [PerlChina] Re: 16½øÖÆÎļþ²Ù×÷ From: perlw01f <p3r1w...@gmail.com> To: PerlChina Mongers ÌÖÂÛ×é <perlchina@googlegroups.com> Date: 8/8/2009 10:42       
лл perldoc -f seekµÄ½áÂÛòËƸúÕâ¸ö²»Ò»Ñù £¿         
  seek FILEHANDLE,POSITION,WHENCE           Sets FILEHANDLE's position, just like the "fseek" call of           "stdio". FILEHANDLE may be an expression whose value gives the           name of the filehandle. The values for WHENCE are 0 to set the           new position *in bytes* to POSITION, 1 to set it to the current           position plus POSITION, and 2 to set it to EOF plus POSITION           (typically negative). For WHENCE you may use the constants           "SEEK_SET", "SEEK_CUR", and "SEEK_END" (start of the file,           current position, end of the file) from the Fcntl module.           Returns 1 upon success, 0 otherwise.         
          Note the *in bytes*: even if the filehandle has been set to           operate on characters (for example by using the ":utf8" open           layer), tell() will return byte offsets, not character offsets           (because implementing that would render seek() and tell() rather           slow).         
          If you want to position file for "sysread" or "syswrite", don't           use "seek"--buffering makes its effect on the file's system           position unpredictable and non-portable. Use "sysseek" instead.         
          Due to the rules and rigors of ANSI C, on some systems you have           to do a seek whenever you switch between reading and writing.           Amongst other things, this may have the effect of calling           stdio's clearerr(3). A WHENCE of 1 ("SEEK_CUR") is useful for           not moving the file position:         
              seek(TEST,0,1);         
          This is also useful for applications emulating "tail -f". Once           you hit EOF on your read, and then sleep for a while, you might           have to stick in a seek() to reset things. The "seek" doesn't           change the current position, but it *does* clear the end-of- file           condition on the handle, so that the next "<FILE>" makes Perl           try again to read something. We hope.         
          If that doesn't work (some IO implementations are particularly           cantankerous), then you may need something more like this:         
              for (;;) {                   for ($curpos = tell(FILE); $_ = <FILE>;                        $curpos = tell(FILE)) {                       # search for some stuff and put it into files                   }                   sleep($for_a_while);                   seek(FILE, $curpos, 0);               }         
ÁíÍ⣬ÄúµÄcode ÎÒ³¢ÊÔÁËһϠseek ($fp, 0, 0x80); print $fp "\x0"; ʵ¼ÊµÄЧ¹ûÊÇ 00000000hÕâÒ»ÐÐ µÚ1ºÍ2×Ö½Ú±ä³ÉÁË0 ûÓÐÆ«ÒÆ£¿ ÎÒ×Ô¼º³¢ÊÔ seek ($fp, 16*8, 0x00); print $fp "\x0"; ¿ÉÒԴﵽĿµÄ         
ÁíÍâ ÎÒÏëÇë½Ì ÈçºÎɾ³ýµôÒ»²¿·ÖÄÚÈÝÄØ ±ÈÈç 0x90-0xb0 лл On 8ÔÂ8ÈÕ, ÉÏÎç12ʱ48·Ö, Anthony WU <anthonywu...@gmail.com> wrote:         
ÒÔÄãËùÕfµÄ²Ù×÷´ó¼sÊÇ open (my $fp, '+<', 'x.dat'); binmode ($fp); seek ($fp, 0, 0x80); print $fp "\x0"; seek ($fp, 0, 0x82); print $fp "\x0"; seek ($fp, 0, 0x84); print $fp "\x0"; seek ($fp, 0, 0x86); print $fp "\x8B"; seek ($fp, 0, 0x87); print $fp "\x8B"; seek ($fp, 0, 0x88); print $fp "\x0A"; seek ($fp, 0, 0x89); print $fp "\x0A"; .... .... .... close ($fp);           
-------- Original Message -------- Subject: [PerlChina] Re: 16½øÖÆÎļþ²Ù×÷ From: perlw01f <p3r1w...@gmail.com> To: PerlChina Mongers ÌÖÂÛ×é <perlchina@googlegroups.com> Date: 7/8/2009 21:16           
¶¼ÊÇÔÚÈ·¶¨µÄλÖà             
Èç 00000080h ÕâÒ»À¸ µÚ1 3  5 ×Ö½Ú»»Îª0 78»»Îª8B  9 10 »»Îª0A »¹ÓÐһЩÆäËûµÄ             
On 8ÔÂ7ÈÕ, ÏÂÎç9ʱ04·Ö, Anthony WU <anthonywu...@gmail.com> wrote:             
ÄãµÄ×Ö¹ÊǶ¨Î»Ð޸ĵĆ᣿ÓÐʲüNÒŽÂɵģ¿               
-------- Original Message -------- Subject: [PerlChina] Re: 16½øÖÆÎļþ²Ù×÷ From: perlw01f <p3r1w...@gmail.com> To: PerlChina Mongers ÌÖÂÛ×é <perlchina@googlegroups.com> Date: 7/8/2009 20:56               
ÎÒÓÐÒ»¸öÎļþ x.dat£¬ÓÉx.rar.gzѹËõ¶ø³É µ«ÊÇÆäÖÐijЩ×Ö½Ú×öÁËÐ޸Ĵ¦Àí ÏÖÔÚµÄÎļþÃûÊÇ a.dat ÏÖÔÚ ÎÒÏëÄæÐвÙ×÷£¬¼´ ÏȽ«a.date rename³Éx.rar.gz È»ºóÀûÓÃueÐÞ¸ÄijЩ×Ö½Ú Ö®ºó²ÅÄܽâѹËõ³Éx.date                 
ÓÉÓÚÎļþÊýÁ¿½Ï¶à ÇÒue 16½øÖÆ ÐÞ¸ÄÒ²²»ÊǺܷ½±ã ËùÒÔÏë Óà perlʵÏÖ Ð»Ð»                 
On 8ÔÂ7ÈÕ, ÏÂÎç5ʱ17·Ö, cnhack TNT <cnhack...@gmail.com> wrote:                 
ÄܾÙÀý˵Ã÷ÄãÒª×öµÄÊÂÇéô£¿                   
2009/8/7 perlw01f <p3r1w...@gmail.com>                   
perlÖÐ ÓÐûÓÐÀàËÆultreditÖÐÄÇÖÖÖ±½Óת»»³É16½øÖƽøÐвÙ×÷µÄ·½·¨»òÕßmodule                     
unpackÊDz»ÊÇÌ«·ÑÊÂÁË                     
-- Best Regards,         Anthony WU               
-- Best Regards,         Anthony WU           
-- Best Regards,         Anthony WU       
    

--  Best Regards, 	Anthony WU

--~--~---------~--~----~------------~-------~--~----~
ÄúÊÕµ½´ËÐÅÏ¢ÊÇÓÉÓÚÄú¶©ÔÄÁË Google ÂÛ̳¡°PerlChina Mongers ÌÖÂÛ×顱ÂÛ̳¡£
 ÒªÔÚ´ËÂÛ̳·¢Ìû£¬Çë·¢µç×ÓÓʼþµ½ perlchina@googlegroups.com
 ÒªÍ˶©´ËÂÛ̳£¬Çë·¢ÓʼþÖÁ perlchina+unsubscribe@googlegroups.com
 ¸ü¶àÑ¡ÏÇëͨ¹ý http://groups.google.com/group/perlchina?hl=zh-CN ·ÃÎʸÃÂÛ̳

-~----------~----~----~----~------~----~------~--~---

没有评论: