annotate loader/ext.c @ 15572:5d738acd664c

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