comparison loader/pe_image.c @ 2069:ce45cce7f7a5

sync with avifile
author arpi
date Thu, 04 Oct 2001 02:21:47 +0000
parents db849cee5777
children 958d10763c34
comparison
equal deleted inserted replaced
2068:3189c317dfc1 2069:ce45cce7f7a5
31 * and 'blocksize' file-aligned (offsets). Since we have 512/1024/2048 (CDROM) 31 * and 'blocksize' file-aligned (offsets). Since we have 512/1024/2048 (CDROM)
32 * and other byte blocksizes, we can't always do this. We *can* do this for 32 * and other byte blocksizes, we can't always do this. We *can* do this for
33 * newer pe binaries produced by MSVC 5 and later, since they are also aligned 33 * newer pe binaries produced by MSVC 5 and later, since they are also aligned
34 * to 4096 byte boundaries on disk. 34 * to 4096 byte boundaries on disk.
35 */ 35 */
36 #include <config.h> 36 #include "config.h"
37 //#include <wine/config.h>
37 38
38 #include <errno.h> 39 #include <errno.h>
39 #include <assert.h> 40 #include <assert.h>
40 #include <stdio.h> 41 #include <stdio.h>
41 #include <stdlib.h> 42 #include <stdlib.h>
42 #include <string.h> 43 #include <string.h>
43 #include <unistd.h> 44 #include <unistd.h>
44 #include <sys/types.h> 45 #include <sys/types.h>
45 #include <sys/stat.h> 46 #include <sys/stat.h>
46 #include <fcntl.h> 47 #include <fcntl.h>
47 #ifdef HAVE_ALLOCA_H
48 #include <alloca.h>
49 #endif
50 #ifdef HAVE_SYS_MMAN_H 48 #ifdef HAVE_SYS_MMAN_H
51 #include <sys/mman.h> 49 #include <sys/mman.h>
52 #endif 50 #endif
53 #include <wine/windef.h> 51 #include <wine/windef.h>
54 #include <wine/winbase.h> 52 #include <wine/winbase.h>
55 #include <wine/winerror.h> 53 #include <wine/winerror.h>
56 #include <wine/heap.h> 54 #include <wine/heap.h>
57 #include <wine/pe_image.h> 55 #include <wine/pe_image.h>
58 #include <wine/module.h> 56 #include <wine/module.h>
59 #include <wine/debugtools.h> 57 #include <wine/debugtools.h>
60 #include <ext.h> 58 #include "ext.h"
61
62 #include "win32.h" 59 #include "win32.h"
63 60
64 #define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x))) 61 #define RVA(x) ((void *)((char *)load_addr+(unsigned int)(x)))
65 62
66 #define AdjustPtr(ptr,delta) ((char *)(ptr) + (delta)) 63 #define AdjustPtr(ptr,delta) ((char *)(ptr) + (delta))
177 for (i = 0; i < exports->NumberOfNames; i++) 174 for (i = 0; i < exports->NumberOfNames; i++)
178 { 175 {
179 ename = RVA(name[i]); 176 ename = RVA(name[i]);
180 if (!strcmp( ename, funcName )) 177 if (!strcmp( ename, funcName ))
181 { 178 {
182 ERR( "%s.%s required a linear search\n", wm->modname, funcName ); 179 ERR( "%s.%s required a linear search\n", wm->modname, funcName );
183 ordinal = ordinals[i]; 180 ordinal = ordinals[i];
184 goto found; 181 goto found;
185 } 182 }
186 } 183 }
187 return NULL; 184 return NULL;
563 UnmapViewOfFile( (LPVOID)hModule ); 560 UnmapViewOfFile( (LPVOID)hModule );
564 return sharedMod; 561 return sharedMod;
565 } 562 }
566 } 563 }
567 564
565
568 566
569 load_addr = nt->OptionalHeader.ImageBase; 567 load_addr = nt->OptionalHeader.ImageBase;
570 vma_size = calc_vma_size( hModule ); 568 vma_size = calc_vma_size( hModule );
571 569
572 load_addr = (DWORD)VirtualAlloc( (void*)load_addr, vma_size, 570 load_addr = (DWORD)VirtualAlloc( (void*)load_addr, vma_size,
882 * Load the PE main .EXE. All other loading is done by PE_LoadLibraryExA 880 * Load the PE main .EXE. All other loading is done by PE_LoadLibraryExA
883 * FIXME: this function should use PE_LoadLibraryExA, but currently can't 881 * FIXME: this function should use PE_LoadLibraryExA, but currently can't
884 * due to the PROCESS_Create stuff. 882 * due to the PROCESS_Create stuff.
885 */ 883 */
886 884
885
887 /* 886 /*
888 * This is a dirty hack. 887 * This is a dirty hack.
889 * The win32 DLLs contain an alloca routine, that first probes the soon 888 * The win32 DLLs contain an alloca routine, that first probes the soon
890 * to be allocated new memory *below* the current stack pointer in 4KByte 889 * to be allocated new memory *below* the current stack pointer in 4KByte
891 * increments. After the mem probing below the current %esp, the stack 890 * increments. After the mem probing below the current %esp, the stack
896 * The extend_stack_for_dll_alloca() routine just preallocates a big chunk 895 * The extend_stack_for_dll_alloca() routine just preallocates a big chunk
897 * of memory on the stack, for use by the DLLs alloca routine. 896 * of memory on the stack, for use by the DLLs alloca routine.
898 */ 897 */
899 static void extend_stack_for_dll_alloca(void) 898 static void extend_stack_for_dll_alloca(void)
900 { 899 {
900 #ifndef __FreeBSD__
901 void* mem=alloca(0x20000); 901 void* mem=alloca(0x20000);
902 *(int*)mem=0x1234; 902 *(int*)mem=0x1234;
903 } 903 #endif
904 904 }
905 905
906 /* Called if the library is loaded or freed. 906 /* Called if the library is loaded or freed.
907 * NOTE: if a thread attaches a DLL, the current thread will only do 907 * NOTE: if a thread attaches a DLL, the current thread will only do
908 * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH 908 * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH
909 * (SDK) 909 * (SDK)