annotate loader/ext.c @ 36518:3e7ce8fc870d

vo_sdl: set VFCAP_FLIP correctly. For interleaved YUV formats there is special flipping code.
author reimar
date Sat, 18 Jan 2014 23:08:28 +0000
parents 389d43c448b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /********************************************************
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
2 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Stub functions for Wine module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 ********************************************************/
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 13827
diff changeset
8
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 13827
diff changeset
9 /*
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 15166
diff changeset
10 * Modified for use with MPlayer, detailed changelog at
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 15166
diff changeset
11 * http://svn.mplayerhq.hu/mplayer/trunk/
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 13827
diff changeset
12 */
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 13827
diff changeset
13
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
14 #include "config.h"
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
15 #include <stdio.h>
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
16 #include <stdlib.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <unistd.h>
33412
2a2e9b6551d8 configure: Convert HAVE_SYS_MMAN_H into a 0/1 definition.
diego
parents: 32537
diff changeset
18 #if HAVE_SYS_MMAN_H
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <sys/mman.h>
26111
eb82d1524b6d #include osdep/mman.h if sys/mman.h is not available.
diego
parents: 26105
diff changeset
20 #else
eb82d1524b6d #include osdep/mman.h if sys/mman.h is not available.
diego
parents: 26105
diff changeset
21 #include "osdep/mmap.h"
26105
c99d53b76ee5 Wrap '#include <sys/mman.h>' in HAVE_SYS_MMAN_H.
diego
parents: 25849
diff changeset
22 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <string.h>
35903
389d43c448b3 Add missing strings.h #includes for strcasecmp().
diego
parents: 33412
diff changeset
26 #include <strings.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <stdarg.h>
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
28 #include <ctype.h>
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
29
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
30 #include "osdep/mmap_anon.h"
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
31 #include "wine/windef.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
32 #include "wine/winbase.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
33 #include "wine/debugtools.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
34 #include "wine/heap.h"
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
35 #include "ext.h"
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
36
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
37 #if 0
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
38 //REMOVE SIMPLIFY
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
39 static void* mymalloc(unsigned int size)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
40 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
41 printf("malloc %d\n", size);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
42 return malloc(size);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
43 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
44
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
45 #undef malloc
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
46 #define malloc mymalloc
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
47 #endif
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
48
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 int dbg_header_err( const char *dbg_channel, const char *func )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
51 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 int dbg_header_warn( const char *dbg_channel, const char *func )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
55 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 int dbg_header_fixme( const char *dbg_channel, const char *func )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
59 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 int dbg_header_trace( const char *dbg_channel, const char *func )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
63 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
65 int dbg_vprintf( const char *format, va_list args )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
67 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 int __vprintf( const char *format, ... )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 #ifdef DETAILED_OUT
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 va_list va;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 va_start(va, format);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 vprintf(format, va);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 va_end(va);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 #endif
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
77 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
79
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
80 HANDLE WINAPI GetProcessHeap(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
85 LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 {
24383
d7f252c2e3a6 warning fixes:
diego
parents: 22413
diff changeset
87 //static int i = 5;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
88 void* m = (flags & 0x8) ? calloc(size, 1) : malloc(size);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
89 //printf("HeapAlloc %p %d (%d)\n", m, size, flags);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
90 //if (--i == 0)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
91 // abort();
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
92 return m;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
95 WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags, LPVOID mem)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32394
diff changeset
97 free(mem);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
98 //printf("HeapFree %p\n", mem);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
99 //if (!mem)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
100 // abort();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 return 1;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
102 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 static int last_error;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
106 DWORD WINAPI GetLastError(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 return last_error;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
111 VOID WINAPI SetLastError(DWORD error)
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
112 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
113 last_error=error;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
114 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
116 WIN_BOOL WINAPI ReadFile(HANDLE handle, LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 *result=read(handle, mem, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 return *result;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
120 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
121 INT WINAPI lstrcmpiA(LPCSTR c1, LPCSTR c2)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 return strcasecmp(c1,c2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
125 LPSTR WINAPI lstrcpynA(LPSTR dest, LPCSTR src, INT num)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 {
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
127 return strncpy(dest,src,num);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
129 INT WINAPI lstrlenA(LPCSTR s)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 return strlen(s);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
132 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
133 INT WINAPI lstrlenW(LPCWSTR s)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 int l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 if(!s)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 l=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 while(s[l])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 l++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 return l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
143 LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
145 LPSTR result = dest;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 int moved=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 if((dest==0) || (src==0))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 while(moved<count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 *dest=*src;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 moved++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 if(*src==0)
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
154 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 src++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 dest++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
158 return result;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 }
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
160 /* i stands here for ignore case! */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
163 /*
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 if(s1==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 if(s2==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 return;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
168 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 while(n>0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 {
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
171 if (((*s1 | *s2) & 0xff00) || toupper((char)*s1) != toupper((char)*s2))
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
172 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
173
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
174 if(*s1<*s2)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
175 return -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 else
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
177 if(*s1>*s2)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
178 return 1;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
179 else
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
180 if(*s1==0)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
181 return 0;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
182 }
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
183 s1++;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
184 s2++;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 3134
diff changeset
185 n--;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 return 0;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
188 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
189
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
190 WIN_BOOL WINAPI IsBadReadPtr(LPCVOID data, UINT size)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 if(size==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 if(data==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 return 0;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
197 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
198 LPSTR HEAP_strdupA(HANDLE heap, DWORD flags, LPCSTR string)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 // return strdup(string);
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
201 char* answ = malloc(strlen(string) + 1);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 strcpy(answ, string);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 return answ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
205 LPWSTR HEAP_strdupAtoW(HANDLE heap, DWORD flags, LPCSTR string)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 int size, i;
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
208 WCHAR* answer;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 if(string==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 size=strlen(string);
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
212 answer = malloc(sizeof(WCHAR) * (size + 1));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 for(i=0; i<=size; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 answer[i]=(short)string[i];
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
215 return answer;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
217 LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 int size, i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 char* answer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 if(string==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 while(string[size])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 size++;
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
226 answer = malloc(size + 2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 for(i=0; i<=size; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 answer[i]=(char)string[i];
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
229 return answer;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 * FILE_dommap
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 //#define MAP_PRIVATE
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 //#define MAP_SHARED
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 LPVOID FILE_dommap( int unix_handle, LPVOID start,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 DWORD size_high, DWORD size_low,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 DWORD offset_high, DWORD offset_low,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 int prot, int flags )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 int fd = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 int pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 LPVOID ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 if (size_high || offset_high)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 printf("offsets larger than 4Gb not supported\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 if (unix_handle == -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 {
21248
2de480457872 Remove useless fd parameter for mmap_anon
reimar
parents: 21246
diff changeset
252 ret = mmap_anon( start, size_low, prot, flags, offset_low );
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
253 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
254 else
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
255 {
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
256 fd = unix_handle;
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
257 ret = mmap( start, size_low, prot, flags, fd, offset_low );
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
258 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
260 if (ret != (LPVOID)-1)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 // printf("address %08x\n", *(int*)ret);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
263 // printf("%x\n", ret);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 return ret;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
265 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 // printf("mmap %d\n", errno);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 /* mmap() failed; if this is because the file offset is not */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 /* page-aligned (EINVAL), or because the underlying filesystem */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 /* does not support mmap() (ENOEXEC), we do it by hand. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 if (unix_handle == -1) return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 if ((errno != ENOEXEC) && (errno != EINVAL)) return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 if (prot & PROT_WRITE)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 /* We cannot fake shared write mappings */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 #ifdef MAP_SHARED
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 if (flags & MAP_SHARED) return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 #ifdef MAP_PRIVATE
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 if (!(flags & MAP_PRIVATE)) return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 /* printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 /* Reserve the memory with an anonymous mmap */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 ret = FILE_dommap( -1, start, size_high, size_low, 0, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 PROT_READ | PROT_WRITE, flags );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 if (ret == (LPVOID)-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 // {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 // perror(
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 /* Now read in the file */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 if ((pos = lseek( fd, offset_low, SEEK_SET )) == -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 FILE_munmap( ret, size_high, size_low );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 // printf("lseek\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 return (LPVOID)-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 read( fd, ret, size_low );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 lseek( fd, pos, SEEK_SET ); /* Restore the file pointer */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 mprotect( ret, size_low, prot ); /* Set the right protection */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 // printf("address %08x\n", *(int*)ret);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 * FILE_munmap
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 if (size_high)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 printf("offsets larger than 4Gb not supported\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 return munmap( start, size_low );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 struct file_mapping_s;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 typedef struct file_mapping_s
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 int mapping_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 char* name;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
323 LPVOID handle;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 struct file_mapping_s* next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 struct file_mapping_s* prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 }file_mapping;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 static file_mapping* fm=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 #define PAGE_NOACCESS 0x01
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 #define PAGE_READONLY 0x02
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 #define PAGE_READWRITE 0x04
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 #define PAGE_WRITECOPY 0x08
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 #define PAGE_EXECUTE 0x10
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 #define PAGE_EXECUTE_READ 0x20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 #define PAGE_EXECUTE_READWRITE 0x40
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 #define PAGE_EXECUTE_WRITECOPY 0x80
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 #define PAGE_GUARD 0x100
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 #define PAGE_NOCACHE 0x200
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
342 HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
343 DWORD flProtect,
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
344 DWORD dwMaxHigh, DWORD dwMaxLow,
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
345 LPCSTR name)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 {
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
347 int hFile = (int)handle;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 unsigned int len;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
349 LPVOID answer;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 int anon=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 int mmap_access=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 if(hFile<0)
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
353 anon=1;
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
354
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 if(!anon)
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
356 {
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 len=lseek(hFile, 0, SEEK_END);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 lseek(hFile, 0, SEEK_SET);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 else len=dwMaxLow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 if(flProtect & PAGE_READONLY)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 mmap_access |=PROT_READ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 mmap_access |=PROT_READ|PROT_WRITE;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
366
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 if(anon)
21248
2de480457872 Remove useless fd parameter for mmap_anon
reimar
parents: 21246
diff changeset
368 answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, 0);
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
369 else
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
370 answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
371
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
372 if(answer!=(LPVOID)-1)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 if(fm==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
376 fm = malloc(sizeof(file_mapping));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 fm->prev=NULL;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
378 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
381 fm->next = malloc(sizeof(file_mapping));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 fm->next->prev=fm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 fm=fm->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
385 fm->next=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 fm->handle=answer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 if(name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
389 fm->name = malloc(strlen(name)+1);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 strcpy(fm->name, name);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
391 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 fm->name=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 fm->mapping_size=len;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
395
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
396 return (HANDLE)answer;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 return (HANDLE)0;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
399 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
400 WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 file_mapping* p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 int result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 if(fm==0)
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
405 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 for(p=fm; p; p=p->next)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
408 if(p->handle==handle)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 result=munmap((void*)handle, p->mapping_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 if(p->next)p->next->prev=p->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 if(p->prev)p->prev->next=p->next;
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32394
diff changeset
413 free(p->name);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 if(p==fm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 fm=p->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 free(p);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 return result;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
418 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
420 return 0;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
421 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 //static int va_size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 struct virt_alloc_s;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 typedef struct virt_alloc_s
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 int mapping_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 char* address;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 struct virt_alloc_s* next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 struct virt_alloc_s* prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 int state;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 }virt_alloc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 static virt_alloc* vm=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 #define MEM_COMMIT 0x00001000
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 #define MEM_RESERVE 0x00002000
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
436 LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protection)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 void* answer;
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
439 long pgsz;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
440
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
441 //printf("VirtualAlloc(0x%08X, %u, 0x%08X, 0x%08X)\n", (unsigned)address, size, type, protection);
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
442
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
443 if ((type&(MEM_RESERVE|MEM_COMMIT)) == 0) return NULL;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
444
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
445 if (type&MEM_RESERVE && (unsigned)address&0xffff) {
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
446 size += (unsigned)address&0xffff;
13827
374178b2a49a gcc-4.0.0-20041024 compile-fix
atmos4
parents: 13306
diff changeset
447 address = (unsigned)address&~0xffff;
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
448 }
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
449 pgsz = sysconf(_SC_PAGESIZE);
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
450 if (type&MEM_COMMIT && (unsigned)address%pgsz) {
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
451 size += (unsigned)address%pgsz;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
452 address -= (unsigned)address%pgsz;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
453 }
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
454
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
455 if (type&MEM_RESERVE && size<0x10000) size = 0x10000;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
456 if (size%pgsz) size += pgsz - size%pgsz;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
457
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 if(address!=0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
460 //check whether we can allow to allocate this
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 virt_alloc* str=vm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 while(str)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 if((unsigned)address>=(unsigned)str->address+str->mapping_size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466 str=str->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 continue;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
468 }
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
469 if((unsigned)address+size<=(unsigned)str->address)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 str=str->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 if(str->state==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 {
32394
914208d188b9 Remove #warning preprocessor directives or replace them by suitable comments.
diego
parents: 30702
diff changeset
476 // FIXME
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
477 if( ((unsigned)address >= (unsigned)str->address)
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
478 && ((unsigned)address+size<=(unsigned)str->address+str->mapping_size)
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
479 && (type & MEM_COMMIT))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 return address; //returning previously reserved memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 }
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
483 //printf(" VirtualAlloc(...) does not commit or not entirely within reserved, and\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
484 }
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
485 /*printf(" VirtualAlloc(...) (0x%08X, %u) overlaps with (0x%08X, %u, state=%d)\n",
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
486 (unsigned)address, size, (unsigned)str->address, str->mapping_size, str->state);*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
488 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
489 }
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
490
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
491 answer=mmap_anon(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
21248
2de480457872 Remove useless fd parameter for mmap_anon
reimar
parents: 21246
diff changeset
492 MAP_PRIVATE, 0);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
493 // answer=FILE_dommap(-1, address, 0, size, 0, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
494 // PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
21187
d9cedf7b8069 added mmap_anon to osdep lib. Used in loader for now
nplourde
parents: 18783
diff changeset
495
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
496 if (answer != (void *)-1 && address && answer != address) {
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
497 /* It is dangerous to try mmap() with MAP_FIXED since it does not
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
498 always detect conflicts or non-allocation and chaos ensues after
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
499 a successful call but an overlapping or non-allocated region. */
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
500 munmap(answer, size);
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
501 answer = (void *) -1;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
502 errno = EINVAL;
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
503 //printf(" VirtualAlloc(...) cannot satisfy requested address but address=NULL would work.\n");
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
504 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
505 if(answer==(void*)-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
506 {
13306
rtognimp
parents: 13303
diff changeset
507 /*printf(" VirtualAlloc(...) mmap(0x%08X, %u, ...) failed with errno=%d (\"%s\")\n",
rtognimp
parents: 13303
diff changeset
508 (unsigned)address, size, errno, strerror(errno));*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
509 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
510 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
511 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
512 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
513 virt_alloc *new_vm = malloc(sizeof(virt_alloc));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
514 new_vm->mapping_size=size;
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 3775
diff changeset
515 new_vm->address=(char*)answer;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
516 new_vm->prev=vm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
517 if(type == MEM_RESERVE)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
518 new_vm->state=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
519 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
520 new_vm->state=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
521 if(vm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
522 vm->next=new_vm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
523 vm=new_vm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
524 vm->next=0;
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 2651
diff changeset
525 //if(va_size!=0)
181db9e5a887 avifile sync again... :(
arpi
parents: 2651
diff changeset
526 // printf("Multiple VirtualAlloc!\n");
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
527 //printf(" VirtualAlloc(...) provides (0x%08X, %u)\n", (unsigned)answer, size);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
528 return answer;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
529 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
530 }
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
531
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 2651
diff changeset
532 WIN_BOOL WINAPI VirtualFree(LPVOID address, SIZE_T dwSize, DWORD dwFreeType)//not sure
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
533 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
534 virt_alloc* str=vm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
535 int answer;
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
536
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
537 //printf("VirtualFree(0x%08X, %d, 0x%08X)\n", (unsigned)address, dwSize, dwFreeType);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
538 while(str)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
539 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
540 if(address!=str->address)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
541 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
542 str=str->prev;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
543 continue;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
544 }
13303
2571b2e0c0b4 Fixes for VirtualAlloc function:
rtognimp
parents: 7386
diff changeset
545 //printf(" VirtualFree(...) munmap(0x%08X, %d)\n", (unsigned)str->address, str->mapping_size);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
546 answer=munmap(str->address, str->mapping_size);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
547 if(str->next)str->next->prev=str->prev;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
548 if(str->prev)str->prev->next=str->next;
3134
181db9e5a887 avifile sync again... :(
arpi
parents: 2651
diff changeset
549 if(vm==str)vm=str->prev;
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
550 free(str);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
551 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
552 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
553 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
554 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
555
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
556 INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags, LPCWSTR src,
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
557 INT srclen,LPSTR dest, INT destlen, LPCSTR defch, WIN_BOOL* used_defch)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
558 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
559 int i;
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
560 if(srclen==-1){srclen=0; while(src[srclen++]);}
22413
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
561 if(destlen==0)
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
562 return srclen;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
563 if(used_defch)
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
564 *used_defch=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
565 for(i=0; i<min(srclen, destlen); i++)
22413
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
566 *dest++=(char)*src++;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
567 return min(srclen, destlen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
568 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
569 INT WINAPI MultiByteToWideChar(UINT codepage,DWORD flags, LPCSTR src, INT srclen,
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
570 LPWSTR dest, INT destlen)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
571 {
22413
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
572 int i;
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
573 if(srclen==-1){srclen=0; while(src[srclen++]);}
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
574 if(destlen==0)
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
575 return srclen;
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
576 for(i=0; i<min(srclen, destlen); i++)
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
577 *dest++=(WCHAR)*src++;
219d577285e1 Fix and simplify the WideCharToMultiByte and MultiByteToWideChar pseudo-implementations.
reimar
parents: 21248
diff changeset
578 return min(srclen, destlen);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
579 }
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
580 HANDLE WINAPI OpenFileMappingA(DWORD access, WIN_BOOL prot, LPCSTR name)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
581 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
582 file_mapping* p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
583 if(fm==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
584 return (HANDLE)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
585 if(name==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
586 return (HANDLE)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
587 for(p=fm; p; p=p->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
588 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
589 if(p->name==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
590 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
591 if(strcmp(p->name, name)==0)
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
592 return (HANDLE)p->handle;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
593 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
594 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
595 }