// File: /workspace/github_c_makefile_star2_O0/mikeakohn[P]print_pe/build/../src/exports.c
// Function: exports_print
int exports_print(
  FILE *in,
  int addr,
  int size,
  struct section_header_t *section_header,
  struct funct_t *funct)
{
  struct export_dir_t export_dir;
  char func_name[1024];
  int virtual_address,raw_ptr;
  int func_addr,name_ord;
  long marker;
  int t,ptr;

  virtual_address = section_header->VirtualAddress;
  raw_ptr = section_header->PointerToRawData;

  addr = (addr - virtual_address) + raw_ptr;
  marker = ftell(in);
  fseek(in, addr, SEEK_SET);

  printf("  -- Exported Symbols --\n\n");

  export_dir.Characteristics = read_uint32(in);
  export_dir.TimeDateStamp = read_uint32(in);
  export_dir.MajorVersion = read_uint16(in);
  export_dir.MinorVersion = read_uint16(in);
  export_dir.Name = read_uint32(in);
  export_dir.Base = read_uint32(in);
  export_dir.NumberOfFunctions = read_uint32(in);
  export_dir.NumberOfNames = read_uint32(in);
  export_dir.AddressOfFunctions = read_uint32(in);
  export_dir.AddressOfNames = read_uint32(in);
  export_dir.AddressOfNameOrdinals = read_uint32(in);

  printf("   Characteristics: 0x%08x\n", export_dir.Characteristics);
  printf("     TimeDateStamp: %s", ctime((time_t *)&export_dir.TimeDateStamp));
  printf("      MajorVersion: %d\n", export_dir.MajorVersion);
  printf("      MinorVersion: %d\n", export_dir.MinorVersion);
  printf("              Name: ");
  print_string(in, (export_dir.Name - virtual_address) + raw_ptr);
  printf("\n");
  printf("              Base: %d\n", export_dir.Base);
  printf(" NumberOfFunctions: %d\n", export_dir.NumberOfFunctions);
  printf("     NumberOfNames: %d\n", export_dir.NumberOfNames);
  printf("AddressOfFunctions: 0x%04x\n", export_dir.AddressOfFunctions);
  printf("    AddressOfNames: 0x%04x\n", export_dir.AddressOfNames);
  printf("AddrOfNameOrdinals: 0x%04x\n", export_dir.AddressOfNameOrdinals);
  printf("\n");

  printf("     Function Name                   Address     Ordinal\n");

  for (t = 0; t < export_dir.NumberOfNames; t++)
  {
    ptr = get_ptr(in, (export_dir.AddressOfNames - virtual_address) + raw_ptr + (t * 4));
    get_string(in, func_name, (ptr - virtual_address) + raw_ptr);

    func_addr = get_ptr(in, (export_dir.AddressOfFunctions - virtual_address) + raw_ptr + (t * 4));
    name_ord = get_ushort(in, (export_dir.AddressOfNameOrdinals - virtual_address) + raw_ptr + (t * 2));

    printf("     %-30s  0x%08x  0x%04x\n", func_name, func_addr, name_ord);

    if (funct->funct_name[0] != 0)
    {
      if (strcmp(funct->funct_name, func_name) == 0)
      {
        funct->funct_ptr = func_addr;
      }
    }
  }

  printf("\n");

  fseek(in, marker, SEEK_SET);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x454(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x458(%rbp)
movl -0xc(%rbp), %eax
subl -0x454(%rbp), %eax
addl -0x458(%rbp), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x30e0
movq %rax, -0x468(%rbp)
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rsi
xorl %edx, %edx
callq 0x3100
leaq 0x5c6d(%rip), %rdi      # 0xb20c
movb $0x0, %al
callq 0x3080
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6070
movw %ax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6070
movw %ax, -0x3e(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6010
movl %eax, -0x24(%rbp)
movl -0x48(%rbp), %esi
leaq 0x5bf1(%rip), %rdi      # 0xb227
movb $0x0, %al
callq 0x3080
leaq -0x48(%rbp), %rdi
addq $0x4, %rdi
callq 0x3070
movq %rax, %rsi
leaq 0x5704(%rip), %rdi      # 0xad58
movb $0x0, %al
callq 0x3080
movzwl -0x40(%rbp), %esi
leaq 0x5709(%rip), %rdi      # 0xad6f
movb $0x0, %al
callq 0x3080
movzwl -0x3e(%rbp), %esi
leaq 0x570f(%rip), %rdi      # 0xad87
movb $0x0, %al
callq 0x3080
leaq 0x5bbd(%rip), %rdi      # 0xb243
movb $0x0, %al
callq 0x3080
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
subl -0x454(%rbp), %esi
addl -0x458(%rbp), %esi
callq 0x6230
leaq 0x4a80(%rip), %rdi      # 0xa12c
movb $0x0, %al
callq 0x3080
movl -0x38(%rbp), %esi
leaq 0x5b9b(%rip), %rdi      # 0xb258
movb $0x0, %al
callq 0x3080
movl -0x34(%rbp), %esi
leaq 0x5ba2(%rip), %rdi      # 0xb270
movb $0x0, %al
callq 0x3080
movl -0x30(%rbp), %esi
leaq 0x5ba9(%rip), %rdi      # 0xb288
movb $0x0, %al
callq 0x3080
movl -0x2c(%rbp), %esi
leaq 0x5bb0(%rip), %rdi      # 0xb2a0
movb $0x0, %al
callq 0x3080
movl -0x28(%rbp), %esi
leaq 0x5bbb(%rip), %rdi      # 0xb2bc
movb $0x0, %al
callq 0x3080
movl -0x24(%rbp), %esi
leaq 0x5bc6(%rip), %rdi      # 0xb2d8
movb $0x0, %al
callq 0x3080
leaq 0x4a0c(%rip), %rdi      # 0xa12c
movb $0x0, %al
callq 0x3080
leaq 0x5bc6(%rip), %rdi      # 0xb2f4
movb $0x0, %al
callq 0x3080
movl $0x0, -0x46c(%rbp)
movl -0x46c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jae 0x5856
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
subl -0x454(%rbp), %esi
addl -0x458(%rbp), %esi
movl -0x46c(%rbp), %eax
shll $0x2, %eax
addl %eax, %esi
callq 0x6330
movl %eax, -0x470(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x450(%rbp), %rsi
movl -0x470(%rbp), %edx
subl -0x454(%rbp), %edx
addl -0x458(%rbp), %edx
callq 0x62a0
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
subl -0x454(%rbp), %esi
addl -0x458(%rbp), %esi
movl -0x46c(%rbp), %eax
shll $0x2, %eax
addl %eax, %esi
callq 0x6330
movl %eax, -0x45c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
subl -0x454(%rbp), %esi
addl -0x458(%rbp), %esi
movl -0x46c(%rbp), %eax
shll %eax
addl %eax, %esi
callq 0x6380
movl %eax, -0x460(%rbp)
leaq -0x450(%rbp), %rsi
movl -0x45c(%rbp), %edx
movl -0x460(%rbp), %ecx
leaq 0x5b2a(%rip), %rdi      # 0xb32e
movb $0x0, %al
callq 0x3080
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x5840
movq -0x20(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x30b0
cmpl $0x0, %eax
jne 0x583e
movslq -0x45c(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x408(%rax)
jmp 0x5840
jmp 0x5842
movl -0x46c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x46c(%rbp)
jmp 0x573f
leaq 0x48cf(%rip), %rdi      # 0xa12c
movb $0x0, %al
callq 0x3080
movq -0x8(%rbp), %rdi
movq -0x468(%rbp), %rsi
xorl %edx, %edx
callq 0x3100
xorl %eax, %eax
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)