移除bzImage文件中'1f8b08'之前内容,存为gz文件

移除bzImage文件中'1f8b08'之前内容,存为gz文件

 

#include  < stdlib.h >
#include 
< stdio.h >

int  _tmain( int  argc, _TCHAR *  argv[])
{
    FILE
* r=fopen("linux26","rb");
    FILE
* w=fopen("linux26.gz","wb");
    
int s=0;
    
for(;;)
    
{
        unsigned 
char c;
        
int l=fread(&c,1,1,r);
        
if(l>=1)
        
{
            
if(s==3)
            
{
                fwrite(
&c,1,1,w);
            }

            
else if(s==2)
            
{
                
if(c==0x08)
                
{
                    c
=0x1f;
                    fwrite(
&c,1,1,w);
                    c
=0x8b;
                    fwrite(
&c,1,1,w);
                    c
=0x08;
                    fwrite(
&c,1,1,w);
                    
++s;
                }

                
else
                
{
                    s
=0;
                }

            }

            
else if(s==1)
            
{
                
if(c==0x8b)
                
{
                    
++s;
                }

                
else
                
{
                    s
=0;
                }

            }

            
else if(s==0)
            
{
                
if(c==0x1f)
                
{
                    
++s;
                }

            }

        }

        
else
        
{
            
break;
        }

    }

    fclose(w);
    fclose(r);
    
return 0;
}

 

你可能感兴趣的:(移除bzImage文件中'1f8b08'之前内容,存为gz文件)