Пример #1
0
Файл: unzip.c Проект: nbzwt/nPal
void         process_local_file_header(void)
{ 
   printf("Process local file header\r\n");
	fread(&lrec,1,sizeof(lrec),zipfd);
   //get_string(lrec.filename_length,filename);
	printf("Ready to get extra string.\r\n");
   //get_string(lrec.extra_field_length,extra);
	printf("String got.\r\n");
   csize = lrec.compressed_size;
   cusize = lrec.uncompressed_size;
   cmethod = lrec.compression_method;
    printf("csize:%d,cusize:%d,cmethod:%d",csize,cusize,cmethod);
   extract_member(); 
} 
Пример #2
0
/* process an import */
static int
do_import (char *name, uint32 offset, FILE *f)
{
  struct ar_hdr ar_hdr;
  struct imp_hdr imp_hdr;
  char imp_flags[16];
  char *buf;
  char *sym;
  char *dll;
  int ord;
  long pos;

  if (fseek (f, offset, SEEK_SET) != 0)
    return 0;

  if (!ar_read_header (&ar_hdr, f))
    return 0;

  pos = ftell (f);
  if (fread (&imp_hdr, sizeof (imp_hdr), 1, f) != 1)
    return 1;

  /* check if this is an import or not */
  if (imp_hdr.sig1 != IMAGE_FILE_MACHINE_UNKNOWN || imp_hdr.sig2 != SIG2)
    {
      if (!only_defs)
        {
          /* rewind to start of member */
          fseek (f, pos, SEEK_SET);
          extract_member (get_ar_name (&ar_hdr),
                          strtol (ar_hdr.ar_size, NULL, 10), f);
        }
      return;
    }

  sym = buf = xmalloc (imp_hdr.size);
  if (fread (buf, imp_hdr.size, 1, f) != 1)
    {
      free (buf);
      return 0;
    }
  dll = sym + strlen (sym) + 1;

  if (TEST_IMPNT(imp_hdr.type, IMPORT_ORDINAL))
    ord = imp_hdr.ord_or_hint;
  else
    ord = -1;

  if (TEST_IMPNT(imp_hdr.type, IMPORT_NAME_NOPREFIX))
    {
      if (*sym == '_')
        sym++;
      else while (*sym == '?' || *sym == '@')
        sym++;
    }
  else if (TEST_IMPNT(imp_hdr.type, IMPORT_NAME_UNDECORATE))
    {
      if (*sym == '_')
        sym++;
      else while (*sym == '?' || *sym == '@')
        sym++;
    }

  imp_flags[0] = '\0';
  if (imp_hdr.type & IMPORT_DATA)
    strcpy (imp_flags, "DATA ");
  if (imp_hdr.type & IMPORT_CONST)
    strcat (imp_flags, "CONST");

  write_def (dll, sym, ord, imp_flags[0] ? imp_flags : NULL);

  free (buf);

  return 1;
}