Mercurial > mplayer.hg
annotate loader/win32.c @ 2977:28bcf0ca1448
ao_mpegpes isn't really optional
author | pl |
---|---|
date | Sun, 18 Nov 2001 18:58:03 +0000 |
parents | 2ec3ec904cd4 |
children | adcdd30d7e7d |
rev | line source |
---|---|
1 | 1 /*********************************************************** |
2 | |
3 Win32 emulation code. Functions that emulate | |
4 responses from corresponding Win32 API calls. | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
5 Since we are not going to be able to load |
1 | 6 virtually any DLL, we can only implement this |
7 much, adding needed functions with each new codec. | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
8 |
128 | 9 Basic principle of implementation: it's not good |
10 for DLL to know too much about its environment. | |
1 | 11 |
12 ************************************************************/ | |
13 | |
2069 | 14 #include "config.h" |
1 | 15 |
2069 | 16 #include "wine/winbase.h" |
17 #include "wine/winreg.h" | |
18 #include "wine/winnt.h" | |
19 #include "wine/winerror.h" | |
20 #include "wine/debugtools.h" | |
21 #include "wine/module.h" | |
2139 | 22 |
23 #include <stdio.h> | |
1 | 24 #include "win32.h" |
2069 | 25 |
2139 | 26 #include "registry.h" |
27 #include "loader.h" | |
28 #include "com.h" | |
29 | |
2069 | 30 #include <stdlib.h> |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
31 #include <assert.h> |
2139 | 32 #include <stdarg.h> |
2069 | 33 #include <ctype.h> |
1 | 34 #include <pthread.h> |
128 | 35 #include <errno.h> |
1 | 36 #ifdef HAVE_MALLOC_H |
37 #include <malloc.h> | |
38 #endif | |
39 #include <time.h> | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
40 #include <math.h> |
128 | 41 #include <unistd.h> |
42 #include <fcntl.h> | |
1 | 43 #include <sys/types.h> |
44 #include <sys/time.h> | |
45 #include <sys/timeb.h> | |
2069 | 46 #ifdef HAVE_KSTAT |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
47 #include <kstat.h> |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
48 #endif |
1 | 49 |
2906
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
50 #if HAVE_VSSCANF |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
51 int vsscanf( const char *str, const char *format, va_list ap); |
2906
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
52 #else |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
53 /* system has no vsscanf. try to provide one */ |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
54 static int vsscanf( const char *str, const char *format, va_list ap) |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
55 { |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
56 long p1 = va_arg(ap, long); |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
57 long p2 = va_arg(ap, long); |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
58 long p3 = va_arg(ap, long); |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
59 long p4 = va_arg(ap, long); |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
60 long p5 = va_arg(ap, long); |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
61 return sscanf(str, format, p1, p2, p3, p4, p5); |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
62 } |
2ec3ec904cd4
Try to provide a vsscanf() implementation, if the system does not have
jkeil
parents:
2780
diff
changeset
|
63 #endif |
1416 | 64 |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
65 char* def_path = WIN32_PATH; |
128 | 66 |
1923
40084ad62591
do_cpuid stored the results of the cpuid instruction in the wrong place
jkeil
parents:
1679
diff
changeset
|
67 static void do_cpuid(unsigned int ax, unsigned int *regs) |
128 | 68 { |
2069 | 69 __asm__ __volatile__( |
70 "pushl %%ebx; pushl %%ecx; pushl %%edx;" | |
71 ".byte 0x0f, 0xa2;" | |
72 "movl %%eax, (%2);" | |
73 "movl %%ebx, 4(%2);" | |
74 "movl %%ecx, 8(%2);" | |
75 "movl %%edx, 12(%2);" | |
76 "popl %%edx; popl %%ecx; popl %%ebx;" | |
77 : "=a" (ax) | |
78 : "0" (ax), "S" (regs) | |
79 ); | |
128 | 80 } |
81 static unsigned int c_localcount_tsc() | |
1 | 82 { |
83 int a; | |
84 __asm__ __volatile__("rdtsc\n\t" | |
85 :"=a"(a) | |
86 : | |
87 :"edx"); | |
88 return a; | |
89 } | |
128 | 90 static void c_longcount_tsc(long long* z) |
1 | 91 { |
92 __asm__ __volatile__( | |
93 "pushl %%ebx\n\t" | |
94 "movl %%eax, %%ebx\n\t" | |
95 "rdtsc\n\t" | |
96 "movl %%eax, 0(%%ebx)\n\t" | |
97 "movl %%edx, 4(%%ebx)\n\t" | |
98 "popl %%ebx\n\t" | |
99 ::"a"(z)); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
100 } |
128 | 101 static unsigned int c_localcount_notsc() |
1 | 102 { |
103 struct timeval tv; | |
104 unsigned limit=~0; | |
105 limit/=1000000; | |
106 gettimeofday(&tv, 0); | |
107 return limit*tv.tv_usec; | |
108 } | |
128 | 109 static void c_longcount_notsc(long long* z) |
1 | 110 { |
111 struct timeval tv; | |
112 unsigned long long result; | |
113 unsigned limit=~0; | |
114 if(!z)return; | |
115 limit/=1000000; | |
116 gettimeofday(&tv, 0); | |
117 result=tv.tv_sec; | |
118 result<<=32; | |
119 result+=limit*tv.tv_usec; | |
120 *z=result; | |
121 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
122 static unsigned int localcount_stub(void); |
2069 | 123 static void longcount_stub(long long*); |
128 | 124 static unsigned int (*localcount)()=localcount_stub; |
125 static void (*longcount)(long long*)=longcount_stub; | |
1 | 126 |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
127 static pthread_mutex_t memmut; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
128 |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
129 static unsigned int localcount_stub(void) |
128 | 130 { |
131 unsigned int regs[4]; | |
1923
40084ad62591
do_cpuid stored the results of the cpuid instruction in the wrong place
jkeil
parents:
1679
diff
changeset
|
132 do_cpuid(1, regs); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
133 if ((regs[3] & 0x00000010) != 0) |
128 | 134 { |
135 localcount=c_localcount_tsc; | |
136 longcount=c_longcount_tsc; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
137 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
138 else |
128 | 139 { |
140 localcount=c_localcount_notsc; | |
141 longcount=c_longcount_notsc; | |
142 } | |
143 return localcount(); | |
144 } | |
145 static void longcount_stub(long long* z) | |
1 | 146 { |
128 | 147 unsigned int regs[4]; |
1923
40084ad62591
do_cpuid stored the results of the cpuid instruction in the wrong place
jkeil
parents:
1679
diff
changeset
|
148 do_cpuid(1, regs); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
149 if ((regs[3] & 0x00000010) != 0) |
128 | 150 { |
151 localcount=c_localcount_tsc; | |
152 longcount=c_longcount_tsc; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
153 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
154 else |
128 | 155 { |
156 localcount=c_localcount_notsc; | |
157 longcount=c_longcount_notsc; | |
158 } | |
159 longcount(z); | |
160 } | |
2780 | 161 |
2069 | 162 int LOADER_DEBUG=1; // active only if compiled with -DDETAILED_OUT |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
163 static inline void dbgprintf(char* fmt, ...) |
128 | 164 { |
235 | 165 #ifdef DETAILED_OUT |
128 | 166 if(LOADER_DEBUG) |
167 { | |
168 FILE* f; | |
169 va_list va; | |
170 va_start(va, fmt); | |
171 f=fopen("./log", "a"); | |
172 vprintf(fmt, va); | |
173 if(f) | |
174 { | |
175 vfprintf(f, fmt, va); | |
176 fsync(fileno(f)); | |
177 fclose(f); | |
178 } | |
179 va_end(va); | |
180 } | |
235 | 181 #endif |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
182 } |
1 | 183 char export_names[500][30]={ |
184 "name1", | |
185 //"name2", | |
186 //"name3" | |
187 }; | |
188 //#define min(x,y) ((x)<(y)?(x):(y)) | |
189 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
190 void destroy_event(void* event); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
191 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
192 static unsigned char* heap=NULL; |
1 | 193 static int heap_counter=0; |
2069 | 194 static void test_heap(void) |
1 | 195 { |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
196 int offset=0; |
1 | 197 if(heap==0) |
198 return; | |
199 while(offset<heap_counter) | |
200 { | |
201 if(*(int*)(heap+offset)!=0x433476) | |
202 { | |
203 printf("Heap corruption at address %d\n", offset); | |
204 return; | |
205 } | |
206 offset+=8+*(int*)(heap+offset+4); | |
207 } | |
208 for(;offset<min(offset+1000, 20000000); offset++) | |
209 if(heap[offset]!=0xCC) | |
210 { | |
211 printf("Free heap corruption at address %d\n", offset); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
212 } |
1 | 213 } |
214 #undef MEMORY_DEBUG | |
215 | |
216 #ifdef MEMORY_DEBUG | |
217 | |
218 void* my_mreq(int size, int to_zero) | |
219 { | |
220 static int test=0; | |
221 test++; | |
222 if(test%10==0)printf("Memory: %d bytes allocated\n", heap_counter); | |
223 // test_heap(); | |
224 if(heap==NULL) | |
225 { | |
226 heap=malloc(20000000); | |
227 memset(heap, 0xCC,20000000); | |
228 } | |
229 if(heap==0) | |
230 { | |
231 printf("No enough memory\n"); | |
232 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
233 } |
1 | 234 if(heap_counter+size>20000000) |
235 { | |
236 printf("No enough memory\n"); | |
237 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
238 } |
1 | 239 *(int*)(heap+heap_counter)=0x433476; |
240 heap_counter+=4; | |
241 *(int*)(heap+heap_counter)=size; | |
242 heap_counter+=4; | |
243 printf("Allocated %d bytes of memory: sys %d, user %d-%d\n", size, heap_counter-8, heap_counter, heap_counter+size); | |
244 if(to_zero) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
245 memset(heap+heap_counter, 0, size); |
1543 | 246 else |
2139 | 247 memset(heap+heap_counter, 0xcc, size); // make crash reproducable |
1 | 248 heap_counter+=size; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
249 return heap+heap_counter-size; |
1 | 250 } |
2069 | 251 int my_release(char* memory) |
1 | 252 { |
253 // test_heap(); | |
254 if(memory==NULL) | |
255 { | |
256 printf("ERROR: free(0)\n"); | |
257 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
258 } |
1 | 259 if(*(int*)(memory-8)!=0x433476) |
260 { | |
261 printf("MEMORY CORRUPTION !!!!!!!!!!!!!!!!!!!\n"); | |
262 return 0; | |
263 } | |
264 printf("Freed %d bytes of memory\n", *(int*)(memory-4)); | |
265 // memset(memory-8, *(int*)(memory-4), 0xCC); | |
266 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
267 } |
1 | 268 |
269 #else | |
128 | 270 #define GARBAGE |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
271 typedef struct alloc_header_t alloc_header; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
272 struct alloc_header_t |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
273 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
274 // let's keep allocated data 16 byte aligned |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
275 alloc_header* prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
276 alloc_header* next; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
277 long deadbeef; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
278 long size; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
279 long type; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
280 long reserved1; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
281 long reserved2; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
282 long reserved3; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
283 }; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
284 |
128 | 285 #ifdef GARBAGE |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
286 static alloc_header* last_alloc = NULL; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
287 static int alccnt = 0; |
128 | 288 #endif |
289 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
290 #define AREATYPE_CLIENT 0 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
291 #define AREATYPE_EVENT 1 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
292 #define AREATYPE_MUTEX 2 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
293 #define AREATYPE_COND 3 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
294 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
295 void* mreq_private(int size, int to_zero, int type); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
296 void* mreq_private(int size, int to_zero, int type) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
297 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
298 alloc_header* header; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
299 if (to_zero) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
300 header=calloc(size + sizeof(alloc_header), 1); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
301 else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
302 header=malloc(size + sizeof(alloc_header)); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
303 #ifdef GARBAGE |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
304 if (!last_alloc) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
305 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
306 pthread_mutex_init(&memmut, NULL); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
307 pthread_mutex_lock(&memmut); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
308 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
309 else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
310 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
311 pthread_mutex_lock(&memmut); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
312 last_alloc->next = header; /* set next */ |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
313 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
314 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
315 header->prev = last_alloc; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
316 header->next = 0; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
317 last_alloc = header; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
318 alccnt++; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
319 pthread_mutex_unlock(&memmut); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
320 #endif |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
321 header->deadbeef = 0xdeadbeef; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
322 header->size = size; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
323 header->type = type; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
324 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
325 //if (alccnt < 400) printf("MY_REQ: %p\t%d (%d)\n", answer, size, alccnt); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
326 return header + 1; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
327 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
328 |
1 | 329 void* my_mreq(int size, int to_zero) |
330 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
331 return mreq_private(size, to_zero, AREATYPE_CLIENT); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
332 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
333 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
334 |
597 | 335 int my_release(void* memory) |
1 | 336 { |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
337 alloc_header* header = (alloc_header*) memory - 1; |
128 | 338 #ifdef GARBAGE |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
339 alloc_header* prevmem; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
340 alloc_header* nextmem; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
341 if (memory == 0) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
342 return 0; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
343 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
344 pthread_mutex_lock(&memmut); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
345 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
346 if (header->deadbeef != 0xdeadbeef) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
347 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
348 printf("FATAL releasing corrupted memory!\n"); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
349 return 0; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
350 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
351 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
352 switch(header->type) |
128 | 353 { |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
354 case AREATYPE_EVENT: |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
355 destroy_event(memory); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
356 break; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
357 case AREATYPE_COND: |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
358 pthread_cond_destroy((pthread_cond_t*)memory); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
359 break; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
360 case AREATYPE_MUTEX: |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
361 pthread_mutex_destroy((pthread_mutex_t*)memory); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
362 break; |
128 | 363 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
364 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
365 prevmem = header->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
366 nextmem = header->next; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
367 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
368 if (prevmem) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
369 prevmem->next = nextmem; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
370 if (nextmem) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
371 nextmem->prev = prevmem; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
372 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
373 if (header == last_alloc) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
374 last_alloc = prevmem; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
375 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
376 alccnt--; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
377 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
378 if (last_alloc) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
379 pthread_mutex_unlock(&memmut); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
380 else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
381 pthread_mutex_destroy(&memmut); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
382 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
383 //if (alccnt < 400) printf("MY_RELEASE: %p\t%ld (%d)\n", mem, mem[3], alccnt); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
384 #else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
385 if (memory == 0) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
386 return 0; |
128 | 387 #endif |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
388 free(header); |
1 | 389 return 0; |
390 } | |
391 #endif | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
392 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
393 static inline int my_size(void* memory) |
2069 | 394 { |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
395 return ((alloc_header*)memory)[-1].size; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
396 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
397 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
398 void* my_realloc(void* memory, int size) |
1 | 399 { |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
400 void *ans = memory; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
401 int osize = my_size(memory); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
402 if (memory == NULL) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
403 return my_mreq(size, 0); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
404 if (osize < size) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
405 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
406 ans = my_mreq(size, 0); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
407 memcpy(ans, memory, osize); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
408 my_release(memory); |
2069 | 409 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
410 return ans; |
2069 | 411 } |
1 | 412 |
413 extern int unk_exp1; | |
414 char extcode[20000];// place for 200 unresolved exports | |
415 int pos=0; | |
416 | |
2069 | 417 int WINAPI ext_unknown() |
1 | 418 { |
419 printf("Unknown func called\n"); | |
420 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
421 } |
1 | 422 int WINAPI expIsBadWritePtr(void* ptr, unsigned int count) |
423 { | |
128 | 424 int result; |
1 | 425 if(count==0) |
128 | 426 result=0; |
427 else | |
1 | 428 if(ptr==0) |
128 | 429 result=1; |
430 else | |
431 result=0; | |
432 dbgprintf("IsBadWritePtr(0x%x, 0x%x) => %d\n", ptr, count, result); | |
433 return result; | |
1 | 434 } |
435 int WINAPI expIsBadReadPtr(void* ptr, unsigned int count) | |
436 { | |
128 | 437 int result; |
1 | 438 if(count==0) |
128 | 439 result=0; |
440 else | |
1 | 441 if(ptr==0) |
128 | 442 result=1; |
443 else | |
444 result=0; | |
445 dbgprintf("IsBadReadPtr(0x%x, 0x%x) => %d\n", ptr, count, result); | |
446 return result; | |
1 | 447 } |
448 void* CDECL expmalloc(int size) | |
449 { | |
450 //printf("malloc"); | |
451 // return malloc(size); | |
452 void* result=my_mreq(size,0); | |
128 | 453 dbgprintf("malloc(0x%x) => 0x%x\n", size,result); |
1 | 454 if(result==0) |
455 printf("WARNING: malloc() failed\n"); | |
456 return result; | |
457 } | |
458 void CDECL expfree(void* mem) | |
459 { | |
460 // return free(mem); | |
128 | 461 dbgprintf("free(0x%x)\n", mem); |
1 | 462 my_release(mem); |
463 } | |
464 void* CDECL expnew(int size) | |
465 { | |
466 // printf("NEW:: Call from address %08x\n STACK DUMP:\n", *(-1+(int*)&size)); | |
467 // printf("%08x %08x %08x %08x\n", | |
468 // size, *(1+(int*)&size), | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
469 // *(2+(int*)&size),*(3+(int*)&size)); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
470 void* result = 0; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
471 assert(size >= 0); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
472 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
473 result=my_mreq(size,0); |
128 | 474 dbgprintf("new(0x%x) => 0x%x\n", size, result); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
475 if (result==0) |
128 | 476 printf("WARNING: new() failed\n"); |
1 | 477 return result; |
478 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
479 } |
1 | 480 int CDECL expdelete(void* memory) |
481 { | |
128 | 482 dbgprintf("delete(0x%x)\n", memory); |
483 my_release(memory); | |
1 | 484 return 0; |
485 } | |
486 int WINAPI expDisableThreadLibraryCalls(int module) | |
487 { | |
128 | 488 dbgprintf("DisableThreadLibraryCalls(0x%x) => 0\n", module); |
1 | 489 return 0; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
490 } |
1 | 491 int CDECL exp_initterm(int v1, int v2) |
492 { | |
128 | 493 dbgprintf("_initterm(0x%x, 0x%x) => 0\n", v1, v2); |
1 | 494 return 0; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
495 } |
1 | 496 |
2069 | 497 HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv) |
1 | 498 { |
2069 | 499 HMODULE result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
500 if (pdrv==NULL) |
2069 | 501 result=0; |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
502 else |
2069 | 503 result=pdrv->hDriverModule; |
504 dbgprintf("GetDriverModuleHandle(%p) => %p\n", pdrv, result); | |
128 | 505 return result; |
1 | 506 } |
507 | |
2069 | 508 #define MODULE_HANDLE_kernel32 ((HMODULE)0x120) |
509 | |
510 HMODULE WINAPI expGetModuleHandleA(const char* name) | |
1 | 511 { |
512 WINE_MODREF* wm; | |
2069 | 513 HMODULE result; |
128 | 514 if(!name) |
515 result=0; | |
516 else | |
517 { | |
518 wm=MODULE_FindModule(name); | |
519 if(wm==0)result=0; | |
520 else | |
2069 | 521 result=(HMODULE)(wm->module); |
128 | 522 } |
523 if(!result) | |
524 { | |
525 if(strcasecmp(name, "kernel32")==0) | |
2069 | 526 result=MODULE_HANDLE_kernel32; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
527 } |
128 | 528 dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result); |
529 return result; | |
1 | 530 } |
128 | 531 |
1 | 532 struct th_list_t; |
533 typedef struct th_list_t{ | |
534 int id; | |
535 void* thread; | |
536 struct th_list_t* next; | |
537 struct th_list_t* prev; | |
538 }th_list; | |
539 | |
540 static th_list* list=NULL; | |
541 | |
542 | |
543 | |
544 void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddress, | |
545 void* lpParameter, long dwFlags, long* dwThreadId) | |
546 { | |
547 pthread_t *pth; | |
548 // printf("CreateThread:"); | |
549 pth=my_mreq(sizeof(pthread_t), 0); | |
550 pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter); | |
551 if(dwFlags) | |
128 | 552 printf( "WARNING: CreateThread flags not supported\n"); |
1 | 553 if(dwThreadId) |
554 *dwThreadId=(long)pth; | |
555 if(list==NULL) | |
556 { | |
557 list=my_mreq(sizeof(th_list), 1); | |
558 list->next=list->prev=NULL; | |
559 } | |
560 else | |
561 { | |
562 list->next=my_mreq(sizeof(th_list), 0); | |
563 list->next->prev=list; | |
564 list->next->next=NULL; | |
565 list=list->next; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
566 } |
1 | 567 list->thread=pth; |
128 | 568 dbgprintf("CreateThread(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) => 0x%x\n", |
569 pSecAttr, dwStackSize, lpStartAddress, lpParameter, dwFlags, dwThreadId, pth); | |
1 | 570 return pth; |
571 } | |
572 | |
573 struct mutex_list_t; | |
574 | |
575 struct mutex_list_t | |
576 { | |
128 | 577 char type; |
1 | 578 pthread_mutex_t *pm; |
128 | 579 pthread_cond_t *pc; |
580 char state; | |
581 char reset; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
582 char name[128]; |
128 | 583 int semaphore; |
1 | 584 struct mutex_list_t* next; |
585 struct mutex_list_t* prev; | |
586 }; | |
587 typedef struct mutex_list_t mutex_list; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
588 static mutex_list* mlist=NULL; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
589 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
590 void destroy_event(void* event) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
591 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
592 mutex_list* pp=mlist; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
593 // printf("garbage collector: destroy_event(%x)\n", event); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
594 while(pp) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
595 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
596 if(pp==(mutex_list*)event) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
597 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
598 if(pp->next) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
599 pp->next->prev=pp->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
600 if(pp->prev) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
601 pp->prev->next=pp->next; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
602 if(mlist==(mutex_list*)event) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
603 mlist=mlist->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
604 /* |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
605 pp=mlist; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
606 while(pp) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
607 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
608 printf("%x => ", pp); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
609 pp=pp->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
610 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
611 printf("0\n"); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
612 */ |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
613 return; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
614 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
615 pp=pp->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
616 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
617 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
618 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
619 void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset, |
1 | 620 char bInitialState, const char* name) |
621 { | |
622 pthread_mutex_t *pm; | |
128 | 623 pthread_cond_t *pc; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
624 /* |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
625 mutex_list* pp; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
626 pp=mlist; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
627 while(pp) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
628 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
629 printf("%x => ", pp); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
630 pp=pp->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
631 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
632 printf("0\n"); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
633 */ |
1 | 634 if(mlist!=NULL) |
635 { | |
636 mutex_list* pp=mlist; | |
637 if(name!=NULL) | |
638 do | |
639 { | |
128 | 640 if((strcmp(pp->name, name)==0) && (pp->type==0)) |
641 { | |
642 dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n", | |
643 pSecAttr, bManualReset, bInitialState, name, name, pp->pm); | |
1 | 644 return pp->pm; |
128 | 645 } |
2069 | 646 }while((pp=pp->prev) != NULL); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
647 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
648 pm=mreq_private(sizeof(pthread_mutex_t), 0, AREATYPE_MUTEX); |
1 | 649 pthread_mutex_init(pm, NULL); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
650 pc=mreq_private(sizeof(pthread_cond_t), 0, AREATYPE_COND); |
128 | 651 pthread_cond_init(pc, NULL); |
1 | 652 if(mlist==NULL) |
653 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
654 mlist=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT); |
1 | 655 mlist->next=mlist->prev=NULL; |
656 } | |
657 else | |
658 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
659 mlist->next=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT); |
128 | 660 mlist->next->prev=mlist; |
1 | 661 mlist->next->next=NULL; |
662 mlist=mlist->next; | |
663 } | |
128 | 664 mlist->type=0; /* Type Event */ |
1 | 665 mlist->pm=pm; |
128 | 666 mlist->pc=pc; |
667 mlist->state=bInitialState; | |
668 mlist->reset=bManualReset; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
669 if(name) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
670 strncpy(mlist->name, name, 127); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
671 else |
1 | 672 mlist->name[0]=0; |
673 if(pm==NULL) | |
674 dbgprintf("ERROR::: CreateEventA failure\n"); | |
128 | 675 /* |
1 | 676 if(bInitialState) |
677 pthread_mutex_lock(pm); | |
128 | 678 */ |
679 if(name) | |
680 dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n", | |
681 pSecAttr, bManualReset, bInitialState, name, name, mlist); | |
682 else | |
683 dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n", | |
684 pSecAttr, bManualReset, bInitialState, mlist); | |
685 return mlist; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
686 } |
1 | 687 |
688 void* WINAPI expSetEvent(void* event) | |
689 { | |
128 | 690 mutex_list *ml = (mutex_list *)event; |
691 dbgprintf("SetEvent(%x) => 0x1\n", event); | |
692 pthread_mutex_lock(ml->pm); | |
693 if (ml->state == 0) { | |
694 ml->state = 1; | |
695 pthread_cond_signal(ml->pc); | |
696 } | |
697 pthread_mutex_unlock(ml->pm); | |
698 | |
699 return (void *)1; | |
1 | 700 } |
701 void* WINAPI expResetEvent(void* event) | |
702 { | |
128 | 703 mutex_list *ml = (mutex_list *)event; |
704 dbgprintf("ResetEvent(0x%x) => 0x1\n", event); | |
705 pthread_mutex_lock(ml->pm); | |
706 ml->state = 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
707 pthread_mutex_unlock(ml->pm); |
128 | 708 |
709 return (void *)1; | |
1 | 710 } |
711 | |
712 void* WINAPI expWaitForSingleObject(void* object, int duration) | |
713 { | |
128 | 714 mutex_list *ml = (mutex_list *)object; |
2069 | 715 // FIXME FIXME FIXME - this value is sometime unititialize !!! |
716 int ret = WAIT_FAILED; | |
128 | 717 mutex_list* pp=mlist; |
2779 | 718 if(object == (void*)0xcfcf9898) |
719 { | |
720 /** | |
721 From GetCurrentThread() documentation: | |
722 A pseudo handle is a special constant that is interpreted as the current thread handle. The calling thread can use this handle to specify itself whenever a thread handle is required. Pseudo handles are not inherited by child processes. | |
723 | |
724 This handle has the maximum possible access to the thread object. For systems that support security descriptors, this is the maximum access allowed by the security descriptor for the calling process. For systems that do not support security descriptors, this is THREAD_ALL_ACCESS. | |
725 | |
726 The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it. A thread can create a "real" handle to itself that can be used by other threads, or inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function. | |
727 **/ | |
728 dbgprintf("WaitForSingleObject(thread_handle) called\n"); | |
729 return WAIT_FAILED; | |
730 } | |
2069 | 731 dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration); |
732 | |
718 | 733 // loop below was slightly fixed - its used just for checking if |
734 // this object really exists in our list | |
735 if (!ml) | |
736 return (void*) ret; | |
737 while (pp && (pp->pm != ml->pm)) | |
2069 | 738 pp = pp->prev; |
718 | 739 if (!pp) { |
2069 | 740 dbgprintf("WaitForSingleObject: NotFound\n"); |
741 return (void*)ret; | |
718 | 742 } |
128 | 743 |
744 pthread_mutex_lock(ml->pm); | |
745 | |
746 switch(ml->type) { | |
747 case 0: /* Event */ | |
748 if (duration == 0) { /* Check Only */ | |
749 if (ml->state == 1) ret = WAIT_FAILED; | |
750 else ret = WAIT_OBJECT_0; | |
751 } | |
752 if (duration == -1) { /* INFINITE */ | |
753 if (ml->state == 0) | |
754 pthread_cond_wait(ml->pc,ml->pm); | |
755 if (ml->reset) | |
756 ml->state = 0; | |
757 ret = WAIT_OBJECT_0; | |
758 } | |
759 if (duration > 0) { /* Timed Wait */ | |
760 struct timespec abstime; | |
761 struct timeval now; | |
762 gettimeofday(&now, 0); | |
763 abstime.tv_sec = now.tv_sec + (now.tv_usec+duration)/1000000; | |
764 abstime.tv_nsec = ((now.tv_usec+duration)%1000000)*1000; | |
765 if (ml->state == 0) | |
766 ret=pthread_cond_timedwait(ml->pc,ml->pm,&abstime); | |
767 if (ret == ETIMEDOUT) ret = WAIT_TIMEOUT; | |
768 else ret = WAIT_OBJECT_0; | |
769 if (ml->reset) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
770 ml->state = 0; |
128 | 771 } |
772 break; | |
773 case 1: /* Semaphore */ | |
774 if (duration == 0) { | |
775 if(ml->semaphore==0) ret = WAIT_FAILED; | |
776 else { | |
777 ml->semaphore++; | |
778 ret = WAIT_OBJECT_0; | |
779 } | |
780 } | |
781 if (duration == -1) { | |
782 if (ml->semaphore==0) | |
783 pthread_cond_wait(ml->pc,ml->pm); | |
784 ml->semaphore--; | |
785 } | |
786 break; | |
787 } | |
788 pthread_mutex_unlock(ml->pm); | |
789 | |
790 dbgprintf("WaitForSingleObject(0x%x, %d): 0x%x => 0x%x \n",object,duration,ml,ret); | |
791 return (void *)ret; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
792 } |
1 | 793 |
794 static BYTE PF[64] = {0,}; | |
795 | |
128 | 796 WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v) |
797 { | |
798 WIN_BOOL result; | |
799 if(v>63)result=0; | |
800 else result=PF[v]; | |
801 dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result); | |
802 return result; | |
803 } | |
804 | |
805 static void DumpSystemInfo(const SYSTEM_INFO* si) | |
806 { | |
807 dbgprintf(" Processor architecture %d\n", si->u.s.wProcessorArchitecture); | |
808 dbgprintf(" Page size: %d\n", si->dwPageSize); | |
809 dbgprintf(" Minimum app address: %d\n", si->lpMinimumApplicationAddress); | |
810 dbgprintf(" Maximum app address: %d\n", si->lpMaximumApplicationAddress); | |
811 dbgprintf(" Active processor mask: 0x%x\n", si->dwActiveProcessorMask); | |
812 dbgprintf(" Number of processors: %d\n", si->dwNumberOfProcessors); | |
813 dbgprintf(" Processor type: 0x%x\n", si->dwProcessorType); | |
814 dbgprintf(" Allocation granularity: 0x%x\n", si->dwAllocationGranularity); | |
815 dbgprintf(" Processor level: 0x%x\n", si->wProcessorLevel); | |
816 dbgprintf(" Processor revision: 0x%x\n", si->wProcessorRevision); | |
817 } | |
818 | |
1 | 819 void WINAPI expGetSystemInfo(SYSTEM_INFO* si) |
820 { | |
821 /* FIXME: better values for the two entries below... */ | |
822 static int cache = 0; | |
823 static SYSTEM_INFO cachedsi; | |
128 | 824 unsigned int regs[4]; |
2069 | 825 dbgprintf("GetSystemInfo(%p) =>\n", si); |
1 | 826 |
827 if (cache) { | |
828 memcpy(si,&cachedsi,sizeof(*si)); | |
128 | 829 DumpSystemInfo(si); |
1 | 830 return; |
831 } | |
832 memset(PF,0,sizeof(PF)); | |
833 | |
834 cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL; | |
835 cachedsi.dwPageSize = getpagesize(); | |
836 | |
837 /* FIXME: better values for the two entries below... */ | |
128 | 838 cachedsi.lpMinimumApplicationAddress = (void *)0x00000000; |
1 | 839 cachedsi.lpMaximumApplicationAddress = (void *)0x7FFFFFFF; |
840 cachedsi.dwActiveProcessorMask = 1; | |
841 cachedsi.dwNumberOfProcessors = 1; | |
842 cachedsi.dwProcessorType = PROCESSOR_INTEL_386; | |
843 cachedsi.dwAllocationGranularity = 0x10000; | |
128 | 844 cachedsi.wProcessorLevel = 5; /* pentium */ |
845 cachedsi.wProcessorRevision = 0x0101; | |
2573 | 846 cachedsi.dwNumberOfProcessors = 1; |
847 | |
848 #if 1 | |
849 /* mplayer's way to detect PF's */ | |
850 { | |
851 #include "../cpudetect.h" | |
852 extern CpuCaps gCpuCaps; | |
853 | |
854 if (gCpuCaps.hasMMX) | |
855 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE; | |
856 if (gCpuCaps.hasSSE) | |
857 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE; | |
858 if (gCpuCaps.has3DNow) | |
859 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE; | |
860 } | |
861 #endif | |
1 | 862 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
863 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__) |
1923
40084ad62591
do_cpuid stored the results of the cpuid instruction in the wrong place
jkeil
parents:
1679
diff
changeset
|
864 do_cpuid(1, regs); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
865 switch ((regs[0] >> 8) & 0xf) { // cpu family |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
866 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
867 cachedsi.wProcessorLevel= 3; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
868 break; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
869 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
870 cachedsi.wProcessorLevel= 4; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
871 break; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
872 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
873 cachedsi.wProcessorLevel= 5; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
874 break; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
875 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
876 cachedsi.wProcessorLevel= 5; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
877 break; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
878 default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
879 cachedsi.wProcessorLevel= 5; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
880 break; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
881 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
882 cachedsi.wProcessorRevision = regs[0] & 0xf; // stepping |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
883 if (regs[3] & (1 << 8)) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
884 PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J«ärgen Keil <jk@tools.de>
arpi_esp
parents:
718
diff
changeset
|
885 if (regs[3] & (1 << 23)) |
128 | 886 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE; |
2573 | 887 if (regs[3] & (1 << 25)) |
888 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE; | |
889 if (regs[3] & (1 << 31)) | |
890 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE; | |
1 | 891 cachedsi.dwNumberOfProcessors=1; |
892 #else | |
893 { | |
894 char buf[20]; | |
895 char line[200]; | |
896 FILE *f = fopen ("/proc/cpuinfo", "r"); | |
897 | |
898 if (!f) | |
899 return; | |
900 while (fgets(line,200,f)!=NULL) { | |
901 char *s,*value; | |
902 | |
903 /* NOTE: the ':' is the only character we can rely on */ | |
904 if (!(value = strchr(line,':'))) | |
905 continue; | |
906 /* terminate the valuename */ | |
907 *value++ = '\0'; | |
908 /* skip any leading spaces */ | |
909 while (*value==' ') value++; | |
910 if ((s=strchr(value,'\n'))) | |
911 *s='\0'; | |
912 | |
913 /* 2.1 method */ | |
914 if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) { | |
915 if (isdigit (value[0])) { | |
916 switch (value[0] - '0') { | |
917 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386; | |
918 cachedsi.wProcessorLevel= 3; | |
919 break; | |
920 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486; | |
921 cachedsi.wProcessorLevel= 4; | |
922 break; | |
923 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; | |
924 cachedsi.wProcessorLevel= 5; | |
925 break; | |
926 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; | |
927 cachedsi.wProcessorLevel= 5; | |
928 break; | |
929 default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; | |
930 cachedsi.wProcessorLevel= 5; | |
931 break; | |
932 } | |
933 } | |
934 /* set the CPU type of the current processor */ | |
2069 | 935 sprintf(buf,"CPU %ld",cachedsi.dwProcessorType); |
1 | 936 continue; |
937 } | |
938 /* old 2.0 method */ | |
939 if (!lstrncmpiA(line, "cpu",strlen("cpu"))) { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
940 if ( isdigit (value[0]) && value[1] == '8' && |
1 | 941 value[2] == '6' && value[3] == 0 |
942 ) { | |
943 switch (value[0] - '0') { | |
944 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386; | |
945 cachedsi.wProcessorLevel= 3; | |
946 break; | |
947 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486; | |
948 cachedsi.wProcessorLevel= 4; | |
949 break; | |
950 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; | |
951 cachedsi.wProcessorLevel= 5; | |
952 break; | |
953 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; | |
954 cachedsi.wProcessorLevel= 5; | |
955 break; | |
956 default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; | |
957 cachedsi.wProcessorLevel= 5; | |
958 break; | |
959 } | |
960 } | |
961 /* set the CPU type of the current processor */ | |
2069 | 962 sprintf(buf,"CPU %ld",cachedsi.dwProcessorType); |
1 | 963 continue; |
964 } | |
965 if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) { | |
966 if (!lstrncmpiA(value,"yes",3)) | |
967 PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE; | |
968 | |
969 continue; | |
970 } | |
971 if (!lstrncmpiA(line,"fpu",strlen("fpu"))) { | |
972 if (!lstrncmpiA(value,"no",2)) | |
973 PF[PF_FLOATING_POINT_EMULATED] = TRUE; | |
974 | |
975 continue; | |
976 } | |
977 if (!lstrncmpiA(line,"processor",strlen("processor"))) { | |
978 /* processor number counts up...*/ | |
979 int x; | |
980 | |
981 if (sscanf(value,"%d",&x)) | |
982 if (x+1>cachedsi.dwNumberOfProcessors) | |
983 cachedsi.dwNumberOfProcessors=x+1; | |
984 | |
985 /* Create a new processor subkey on a multiprocessor | |
986 * system | |
987 */ | |
2069 | 988 sprintf(buf,"%d",x); |
1 | 989 } |
990 if (!lstrncmpiA(line,"stepping",strlen("stepping"))) { | |
991 int x; | |
992 | |
993 if (sscanf(value,"%d",&x)) | |
994 cachedsi.wProcessorRevision = x; | |
995 } | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
996 if |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
997 ( (!lstrncmpiA(line,"flags",strlen("flags"))) |
128 | 998 || (!lstrncmpiA(line,"features",strlen("features"))) ) |
999 { | |
1 | 1000 if (strstr(value,"cx8")) |
1001 PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE; | |
1002 if (strstr(value,"mmx")) | |
1003 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE; | |
2573 | 1004 if (strstr(value,"tsc")) |
1005 PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE; | |
1006 if (strstr(value,"xmm")) | |
1007 PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE; | |
1008 if (strstr(value,"3dnow")) | |
1009 PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE; | |
1 | 1010 } |
1011 } | |
1012 fclose (f); | |
128 | 1013 /* |
1014 * ad hoc fix for smp machines. | |
1015 * some problems on WaitForSingleObject,CreateEvent,SetEvent | |
1016 * CreateThread ...etc.. | |
1017 * | |
1018 */ | |
1019 cachedsi.dwNumberOfProcessors=1; | |
1 | 1020 } |
1021 #endif /* __FreeBSD__ */ | |
2069 | 1022 cache = 1; |
1 | 1023 memcpy(si,&cachedsi,sizeof(*si)); |
128 | 1024 DumpSystemInfo(si); |
1 | 1025 } |
1026 | |
1027 long WINAPI expGetVersion() | |
1028 { | |
128 | 1029 dbgprintf("GetVersion() => 0xC0000004\n"); |
1030 return 0xC0000004;//Windows 95 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1031 } |
1 | 1032 |
1033 HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size) | |
1034 { | |
1035 // printf("HeapCreate:"); | |
128 | 1036 HANDLE result; |
1 | 1037 if(init_size==0) |
128 | 1038 result=(HANDLE)my_mreq(0x110000, 0); |
1 | 1039 else |
128 | 1040 result=(HANDLE)my_mreq(init_size, 0); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1041 dbgprintf("HeapCreate(flags 0x%x, initial size %d, maximum size %d) => 0x%x\n", flags, init_size, max_size, result); |
128 | 1042 return result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1043 } |
1 | 1044 void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size) |
1045 { | |
1046 void* z; | |
1047 // printf("HeapAlloc:"); | |
128 | 1048 /** |
1049 Morgan's m3jpeg32.dll v. 2.0 encoder expects that request for | |
1050 HeapAlloc returns area larger than size argument :-/ | |
1051 **/ | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1052 z=my_mreq(((size+4095)/4096)*4096, flags&8); |
1 | 1053 // z=HeapAlloc(heap,flags,size); |
1054 if(z==0) | |
1055 printf("HeapAlloc failure\n"); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1056 dbgprintf("HeapAlloc(heap 0x%x, flags 0x%x, size 0x%x) => 0x%x\n", heap, flags, size, z); |
1 | 1057 return z; |
1058 } | |
1059 long WINAPI expHeapDestroy(void* heap) | |
1060 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1061 dbgprintf("HeapDestroy(heap 0x%x) => 1\n", heap); |
1 | 1062 my_release(heap); |
1063 return 1; | |
1064 } | |
1065 | |
1066 long WINAPI expHeapFree(int arg1, int arg2, void* ptr) | |
1067 { | |
128 | 1068 dbgprintf("HeapFree(0x%x, 0x%x, pointer 0x%x) => 1\n", arg1, arg2, ptr); |
1 | 1069 my_release(ptr); |
1070 return 1; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1071 } |
1 | 1072 long WINAPI expHeapSize(int heap, int flags, void* pointer) |
1073 { | |
128 | 1074 long result=my_size(pointer); |
1075 dbgprintf("HeapSize(heap 0x%x, flags 0x%x, pointer 0x%x) => %d\n", heap, flags, pointer, result); | |
1076 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1077 } |
2069 | 1078 void* WINAPI expHeapReAlloc(HANDLE heap,int flags,void *lpMem,int size) |
1079 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1080 long orgsize; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1081 void *newp; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1082 orgsize = my_size(lpMem); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1083 dbgprintf("HeapReAlloc() Size %ld org %d\n",orgsize,size); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1084 return my_realloc(lpMem, size); |
2069 | 1085 } |
1 | 1086 long WINAPI expGetProcessHeap(void) |
1087 { | |
128 | 1088 dbgprintf("GetProcessHeap() => 1\n"); |
1 | 1089 return 1; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1090 } |
1 | 1091 void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4) |
1092 { | |
1093 void* z; | |
1094 z=VirtualAlloc(v1, v2, v3, v4); | |
1095 if(z==0) | |
1096 printf("VirtualAlloc failure\n"); | |
128 | 1097 dbgprintf("VirtualAlloc(0x%x, %d, %d, %d) => 0x%x \n",v1,v2,v3,v4, z); |
1 | 1098 return z; |
1099 } | |
1100 int WINAPI expVirtualFree(void* v1, int v2, int v3) | |
1101 { | |
128 | 1102 int result=VirtualFree(v1,v2,v3); |
1103 dbgprintf("VirtualFree(0x%x, %d, %d) => %d\n",v1,v2,v3, result); | |
1104 return result; | |
1 | 1105 } |
2579 | 1106 |
1107 /* -- critical sections -- */ | |
1 | 1108 struct CRITSECT |
1109 { | |
1110 pthread_t id; | |
1111 pthread_mutex_t mutex; | |
1112 int locked; | |
1113 }; | |
2069 | 1114 |
2579 | 1115 /* we're building a table of critical sections. cs_win pointer uses the DLL |
1116 cs_unix is the real structure, we're using cs_win only to identifying cs_unix */ | |
1117 struct critsecs_list_t | |
1118 { | |
1119 CRITICAL_SECTION *cs_win; | |
1120 struct CRITSECT *cs_unix; | |
1121 }; | |
1122 | |
1123 #define CRITSECS_LIST_MAX 20 | |
1124 static struct critsecs_list_t critsecs_list[CRITSECS_LIST_MAX]; | |
1125 | |
1126 int critsecs_get_pos(CRITICAL_SECTION *cs_win) | |
1127 { | |
1128 int i; | |
1129 | |
1130 for (i=0; i < CRITSECS_LIST_MAX; i++) | |
1131 if (critsecs_list[i].cs_win == cs_win) | |
1132 return(i); | |
1133 return(-1); | |
1134 } | |
1135 | |
1136 int critsecs_get_unused(void) | |
1137 { | |
1138 int i; | |
1139 | |
1140 for (i=0; i < CRITSECS_LIST_MAX; i++) | |
1141 if (critsecs_list[i].cs_win == NULL) | |
1142 return(i); | |
1143 return(-1); | |
1144 } | |
1145 | |
1146 #if 0 | |
1147 #define critsecs_get_unix(cs_win) (critsecs_list[critsecs_get_pos(cs_win)].cs_win) | |
1148 #else | |
1149 struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win) | |
1150 { | |
1151 int i; | |
1152 | |
1153 for (i=0; i < CRITSECS_LIST_MAX; i++) | |
2670 | 1154 if (critsecs_list[i].cs_win == cs_win && critsecs_list[i].cs_unix) |
2579 | 1155 return(critsecs_list[i].cs_unix); |
1156 return(NULL); | |
1157 } | |
1158 #endif | |
1159 | |
2670 | 1160 #undef CRITSECS_NEWTYPE |
1161 //#define CRITSECS_NEWTYPE 1 | |
2579 | 1162 |
1 | 1163 void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c) |
1164 { | |
128 | 1165 dbgprintf("InitializeCriticalSection(0x%x)\n", c); |
1 | 1166 /* if(sizeof(pthread_mutex_t)>sizeof(CRITICAL_SECTION)) |
1167 { | |
1168 printf(" ERROR:::: sizeof(pthread_mutex_t) is %d, expected <=%d!\n", | |
1169 sizeof(pthread_mutex_t), sizeof(CRITICAL_SECTION)); | |
1170 return; | |
1171 }*/ | |
1172 /* pthread_mutex_init((pthread_mutex_t*)c, NULL); */ | |
2579 | 1173 #ifdef CRITSECS_NEWTYPE |
1174 { | |
1175 struct CRITSECT *cs; | |
1176 int i = critsecs_get_unused(); | |
1177 | |
1178 if (i < 0) | |
1179 { | |
1180 printf("InitializeCriticalSection(%p) - no more space in list\n", c); | |
1181 return; | |
1182 } | |
2670 | 1183 printf("got unused space at %d\n", i); |
1184 cs = expmalloc(sizeof(struct CRITSECT)); | |
1185 if (!cs) | |
1186 { | |
1187 printf("InitializeCriticalSection(%p) - out of memory\n", c); | |
1188 return; | |
1189 } | |
2579 | 1190 pthread_mutex_init(&cs->mutex, NULL); |
1191 cs->locked = 0; | |
1192 critsecs_list[i].cs_win = c; | |
1193 critsecs_list[i].cs_unix = cs; | |
1194 dbgprintf("InitializeCriticalSection -> itemno=%d, cs_win=%p, cs_unix=%p\n", | |
1195 i, c, cs); | |
1196 } | |
1197 #else | |
1198 { | |
1199 struct CRITSECT cs; | |
1200 pthread_mutex_init(&cs.mutex, NULL); | |
1 | 1201 cs.locked=0; |
1202 *(void**)c=malloc(sizeof cs); | |
1203 memcpy(*(void**)c, &cs, sizeof cs); | |
2579 | 1204 } |
1205 #endif | |
1 | 1206 return; |
2579 | 1207 } |
1208 | |
1 | 1209 void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c) |
1210 { | |
2579 | 1211 #ifdef CRITSECS_NEWTYPE |
1212 struct CRITSECT* cs = critsecs_get_unix(c); | |
1213 #else | |
128 | 1214 struct CRITSECT* cs=*(struct CRITSECT**)c; |
2579 | 1215 #endif |
128 | 1216 dbgprintf("EnterCriticalSection(0x%x)\n",c); |
2069 | 1217 if (!cs) |
1218 { | |
2670 | 1219 printf("entered uninitialized critisec!\n"); |
2069 | 1220 expInitializeCriticalSection(c); |
2579 | 1221 #ifdef CRITSECS_NEWTYPE |
1222 cs=critsecs_get_unix(c); | |
1223 #else | |
2069 | 1224 cs=*(struct CRITSECT**)c; |
2579 | 1225 #endif |
2069 | 1226 printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c); |
1227 } | |
1 | 1228 // cs.id=pthread_self(); |
1229 if(cs->locked) | |
1230 if(cs->id==pthread_self()) | |
1231 return; | |
1232 pthread_mutex_lock(&(cs->mutex)); | |
1233 cs->locked=1; | |
1234 cs->id=pthread_self(); | |
1235 return; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1236 } |
1 | 1237 void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c) |
1238 { | |
2579 | 1239 #ifdef CRITSECS_NEWTYPE |
1240 struct CRITSECT* cs = critsecs_get_unix(c); | |
1241 #else | |
128 | 1242 struct CRITSECT* cs=*(struct CRITSECT**)c; |
2579 | 1243 #endif |
128 | 1244 // struct CRITSECT* cs=(struct CRITSECT*)c; |
1245 dbgprintf("LeaveCriticalSection(0x%x)\n",c); | |
2069 | 1246 if (!cs) |
1247 { | |
1248 printf("Win32 Warning: Leaving noninitialized Critical Section %p!!\n", c); | |
1249 return; | |
1250 } | |
1 | 1251 cs->locked=0; |
1252 pthread_mutex_unlock(&(cs->mutex)); | |
1253 return; | |
1254 } | |
1255 void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c) | |
1256 { | |
2579 | 1257 #ifdef CRITSECS_NEWTYPE |
1258 struct CRITSECT* cs = critsecs_get_unix(c); | |
1259 #else | |
128 | 1260 struct CRITSECT* cs=*(struct CRITSECT**)c; |
2579 | 1261 #endif |
128 | 1262 // struct CRITSECT* cs=(struct CRITSECT*)c; |
1263 dbgprintf("DeleteCriticalSection(0x%x)\n",c); | |
1264 pthread_mutex_destroy(&(cs->mutex)); | |
2579 | 1265 // free(cs); |
1266 #ifdef CRITSECS_NEWTYPE | |
1267 { | |
1268 int i = critsecs_get_pos(c); | |
1269 | |
1270 if (i < 0) | |
1271 { | |
1272 printf("DeleteCriticalSection(%p) error (critsec not found)\n", c); | |
1273 return; | |
1274 } | |
1275 | |
1276 critsecs_list[i].cs_win = NULL; | |
2670 | 1277 expfree(critsecs_list[i].cs_unix); |
2579 | 1278 critsecs_list[i].cs_unix = NULL; |
1279 dbgprintf("DeleteCriticalSection -> itemno=%d\n", i); | |
1280 } | |
1281 #endif | |
1 | 1282 return; |
1283 } | |
1284 int WINAPI expGetCurrentThreadId() | |
1285 { | |
128 | 1286 dbgprintf("GetCurrentThreadId() => %d\n", getpid()); |
1287 return getpid(); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1288 } |
128 | 1289 int WINAPI expGetCurrentProcess() |
1290 { | |
1291 dbgprintf("GetCurrentProcess() => %d\n", getpid()); | |
1 | 1292 return getpid(); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1293 } |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1294 |
2779 | 1295 extern void* fs_seg; |
1296 | |
1297 #if 1 | |
1298 //static int tls_count; | |
1299 static int tls_use_map[64]; | |
1300 int WINAPI expTlsAlloc() | |
1301 { | |
1302 int i; | |
1303 for(i=0; i<64; i++) | |
1304 if(tls_use_map[i]==0) | |
1305 { | |
1306 tls_use_map[i]=1; | |
1307 return i; | |
1308 } | |
1309 return -1; | |
1310 } | |
1311 | |
1312 int WINAPI expTlsSetValue(int index, void* value) | |
1313 { | |
1314 if((index<0) || (index>64)) | |
1315 return 0; | |
1316 *(void**)((char*)fs_seg+0x88+4*index) = value; | |
1317 return 1; | |
1318 } | |
1319 | |
1320 void* WINAPI expTlsGetValue(int index) | |
1321 { | |
1322 if((index<0) || (index>64)) | |
1323 return 0; | |
1324 return *(void**)((char*)fs_seg+0x88+index); | |
1325 } | |
1326 | |
1327 int WINAPI expTlsFree(int index) | |
1328 { | |
1329 if((index<0) || (index>64)) | |
1330 return 0; | |
1331 tls_use_map[index]=0; | |
1332 return 1; | |
1333 } | |
1334 | |
1335 #else | |
2069 | 1336 struct tls_s { |
1 | 1337 void* value; |
1338 int used; | |
1339 struct tls_s* prev; | |
1340 struct tls_s* next; | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1341 }; |
2069 | 1342 |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1343 tls_t* g_tls=NULL; |
1 | 1344 void* WINAPI expTlsAlloc() |
1345 { | |
1346 if(g_tls==NULL) | |
1347 { | |
1348 g_tls=my_mreq(sizeof(tls_t), 0); | |
1349 g_tls->next=g_tls->prev=NULL; | |
1350 } | |
1351 else | |
1352 { | |
1353 g_tls->next=my_mreq(sizeof(tls_t), 0); | |
1354 g_tls->next->prev=g_tls; | |
1355 g_tls->next->next=NULL; | |
1356 g_tls=g_tls->next; | |
1357 } | |
128 | 1358 dbgprintf("TlsAlloc() => 0x%x\n", g_tls); |
2670 | 1359 if (g_tls) |
1360 g_tls->value=0; /* XXX For Divx.dll */ | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1361 return g_tls; |
1 | 1362 } |
1363 | |
1364 int WINAPI expTlsSetValue(tls_t* index, void* value) | |
1365 { | |
128 | 1366 int result; |
1 | 1367 if(index==0) |
128 | 1368 result=0; |
1369 else | |
1370 { | |
1371 index->value=value; | |
1372 result=1; | |
1373 } | |
1374 dbgprintf("TlsSetValue(index 0x%x, value 0x%x) => %d \n", index, value, result ); | |
1375 return result; | |
1 | 1376 } |
1377 void* WINAPI expTlsGetValue(tls_t* index) | |
1378 { | |
128 | 1379 void* result; |
1 | 1380 if(index==0) |
128 | 1381 result=0; |
1382 else | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1383 result=index->value; |
128 | 1384 dbgprintf("TlsGetValue(index 0x%x) => 0x%x\n", index, result); |
1385 return result; | |
1 | 1386 } |
1387 int WINAPI expTlsFree(tls_t* index) | |
1388 { | |
128 | 1389 int result; |
1 | 1390 if(index==0) |
128 | 1391 result=0; |
1392 else | |
1393 { | |
1394 if(index->next) | |
1395 index->next->prev=index->prev; | |
1396 if(index->prev) | |
1397 index->prev->next=index->next; | |
1398 my_release((void*)index); | |
1399 result=1; | |
1400 } | |
1401 dbgprintf("TlsFree(index 0x%x) => %d\n", index, result); | |
1402 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1403 } |
2779 | 1404 #endif |
1405 | |
1 | 1406 void* WINAPI expLocalAlloc(int flags, int size) |
1407 { | |
1408 void* z; | |
1409 if(flags&GMEM_ZEROINIT) | |
1410 z=my_mreq(size, 1); | |
1411 else | |
1412 z=my_mreq(size, 0); | |
1413 if(z==0) | |
1414 printf("LocalAlloc() failed\n"); | |
128 | 1415 dbgprintf("LocalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z); |
1 | 1416 return z; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1417 } |
2069 | 1418 |
1419 void* WINAPI expLocalReAlloc(int handle,int size, int flags) | |
1420 { | |
1421 void *newpointer; | |
1422 int oldsize; | |
1423 | |
1424 newpointer=NULL; | |
1425 if (flags & LMEM_MODIFY) { | |
1426 dbgprintf("LocalReAlloc MODIFY\n"); | |
1427 return (void *)handle; | |
1428 } | |
1429 oldsize = my_size((void *)handle); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1430 newpointer = my_realloc((void *)handle,size); |
2069 | 1431 dbgprintf("LocalReAlloc(%x %d(old %d), flags 0x%x) => 0x%x\n", handle,size,oldsize, flags,newpointer); |
1432 | |
1433 return newpointer; | |
1434 } | |
1435 | |
1 | 1436 void* WINAPI expLocalLock(void* z) |
1437 { | |
128 | 1438 dbgprintf("LocalLock(0x%x) => 0x%x\n", z, z); |
1 | 1439 return z; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1440 } |
128 | 1441 |
1 | 1442 void* WINAPI expGlobalAlloc(int flags, int size) |
1443 { | |
1444 void* z; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1445 dbgprintf("GlobalAlloc(%d, flags 0x%X)\n", size, flags); |
1 | 1446 if(flags&GMEM_ZEROINIT) |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1447 z=my_mreq(size, 1); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1448 //z=calloc(size, 1); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1449 else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1450 z=my_mreq(size, 0); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1451 //z=malloc(size); |
1 | 1452 if(z==0) |
128 | 1453 printf("GlobalAlloc() failed\n"); |
1454 dbgprintf("GlobalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z); | |
1 | 1455 return z; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1456 } |
1 | 1457 void* WINAPI expGlobalLock(void* z) |
1458 { | |
128 | 1459 dbgprintf("GlobalLock(0x%x) => 0x%x\n", z, z); |
1 | 1460 return z; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1461 } |
1 | 1462 int WINAPI expLoadStringA(long instance, long id, void* buf, long size) |
1463 { | |
128 | 1464 int result=LoadStringA(instance, id, buf, size); |
1465 // if(buf) | |
1466 dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d ( %s )\n", | |
1467 instance, id, buf, size, result, buf); | |
1468 // else | |
1469 // dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d\n", | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1470 // instance, id, buf, size, result); |
128 | 1471 return result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1472 } |
1 | 1473 |
128 | 1474 long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1, short* s2, int siz2) |
1 | 1475 { |
1476 #warning FIXME | |
128 | 1477 int i; |
1478 int result; | |
1 | 1479 if(s2==0) |
128 | 1480 result=1; |
1481 else | |
1482 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1483 if(siz1>siz2/2)siz1=siz2/2; |
128 | 1484 for(i=1; i<=siz1; i++) |
1485 { | |
1486 *s2=*s1; | |
1487 if(!*s1)break; | |
1488 s2++; | |
1489 s1++; | |
1490 } | |
1491 result=i; | |
1492 } | |
1493 if(s1) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1494 dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s'," |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1495 "size %d, dest buffer 0x%x, dest size %d) => %d\n", |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1496 v1, v2, s1, s1, siz1, s2, siz2, result); |
128 | 1497 else |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1498 dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL," |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1499 "size %d, dest buffer 0x%x, dest size %d) =>\n", |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1500 v1, v2, siz1, s2, siz2, result); |
128 | 1501 return result; |
1502 } | |
1503 static void wch_print(const short* str) | |
1504 { | |
1505 dbgprintf(" src: "); | |
1506 while(*str)dbgprintf("%c", *str++); | |
1507 dbgprintf("\n"); | |
1 | 1508 } |
1509 long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1, char* s2, int siz2, char* c3, int* siz3) | |
1510 { | |
1511 int result; | |
128 | 1512 dbgprintf("WideCharToMultiByte(codepage %d, flags 0x%x, src 0x%x, src size %d, " |
1513 "dest 0x%x, dest size %d, defch 0x%x, used_defch 0x%x)", v1, v2, s1, siz1, s2, siz2, c3, siz3); | |
1 | 1514 result=WideCharToMultiByte(v1, v2, s1, siz1, s2, siz2, c3, siz3); |
1515 dbgprintf("=> %d\n", result); | |
2069 | 1516 //if(s1)wch_print(s1); |
128 | 1517 if(s2)dbgprintf(" dest: %s\n", s2); |
1 | 1518 return result; |
1519 } | |
1520 long WINAPI expGetVersionExA(OSVERSIONINFOA* c) | |
1521 { | |
128 | 1522 dbgprintf("GetVersionExA(0x%x) => 1\n"); |
1523 c->dwOSVersionInfoSize=sizeof(*c); | |
1 | 1524 c->dwMajorVersion=4; |
128 | 1525 c->dwMinorVersion=0; |
1526 c->dwBuildNumber=0x4000457; | |
2069 | 1527 #if 0 |
1528 // leave it here for testing win9x-only codecs | |
1 | 1529 c->dwPlatformId=VER_PLATFORM_WIN32_WINDOWS; |
128 | 1530 strcpy(c->szCSDVersion, " B"); |
2069 | 1531 #else |
1532 c->dwPlatformId=VER_PLATFORM_WIN32_NT; // let's not make DLL assume that it can read CR* registers | |
1533 strcpy(c->szCSDVersion, "Service Pack 3"); | |
1534 #endif | |
128 | 1535 dbgprintf(" Major version: 4\n Minor version: 0\n Build number: 0x4000457\n" |
2069 | 1536 " Platform Id: VER_PLATFORM_WIN32_NT\n Version string: 'Service Pack 3'\n"); |
1 | 1537 return 1; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1538 } |
1 | 1539 HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, char* name) |
1540 { | |
128 | 1541 pthread_mutex_t *pm; |
1542 pthread_cond_t *pc; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1543 mutex_list* pp; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1544 /* |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1545 printf("CreateSemaphoreA(%p = %s)\n", name, (name ? name : "<null>")); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1546 pp=mlist; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1547 while(pp) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1548 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1549 printf("%p => ", pp); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1550 pp=pp->prev; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1551 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1552 printf("0\n"); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1553 */ |
128 | 1554 if(mlist!=NULL) |
1 | 1555 { |
128 | 1556 mutex_list* pp=mlist; |
1557 if(name!=NULL) | |
1558 do | |
1559 { | |
1560 if((strcmp(pp->name, name)==0) && (pp->type==1)) | |
1561 { | |
1562 dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x", | |
1563 v1, init_count, max_count, name, name, mlist); | |
1564 return (HANDLE)mlist; | |
1565 } | |
2069 | 1566 }while((pp=pp->prev) != NULL); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1567 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1568 pm=mreq_private(sizeof(pthread_mutex_t), 0, AREATYPE_MUTEX); |
128 | 1569 pthread_mutex_init(pm, NULL); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1570 pc=mreq_private(sizeof(pthread_cond_t), 0, AREATYPE_COND); |
128 | 1571 pthread_cond_init(pc, NULL); |
1572 if(mlist==NULL) | |
1573 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1574 mlist=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT); |
128 | 1575 mlist->next=mlist->prev=NULL; |
1576 } | |
1577 else | |
1 | 1578 { |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1579 mlist->next=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT); |
128 | 1580 mlist->next->prev=mlist; |
1581 mlist->next->next=NULL; | |
1582 mlist=mlist->next; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1583 // printf("new semaphore %p\n", mlist); |
1 | 1584 } |
128 | 1585 mlist->type=1; /* Type Semaphore */ |
1586 mlist->pm=pm; | |
1587 mlist->pc=pc; | |
1588 mlist->state=0; | |
1589 mlist->reset=0; | |
1590 mlist->semaphore=init_count; | |
1591 if(name!=NULL) | |
1592 strncpy(mlist->name, name, 64); | |
1593 else | |
1594 mlist->name[0]=0; | |
1595 if(pm==NULL) | |
1596 dbgprintf("ERROR::: CreateSemaphoreA failure\n"); | |
1597 if(name) | |
1598 dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x", | |
1599 v1, init_count, max_count, name, name, mlist); | |
1600 else | |
1601 dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0) => 0x%x", | |
1602 v1, init_count, max_count, mlist); | |
1603 return (HANDLE)mlist; | |
1 | 1604 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1605 |
1 | 1606 long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count) |
1607 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1608 // The state of a semaphore object is signaled when its count |
1 | 1609 // is greater than zero and nonsignaled when its count is equal to zero |
1610 // Each time a waiting thread is released because of the semaphore's signaled | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1611 // state, the count of the semaphore is decreased by one. |
128 | 1612 mutex_list *ml = (mutex_list *)hsem; |
1 | 1613 |
128 | 1614 pthread_mutex_lock(ml->pm); |
1615 if (prev_count != 0) *prev_count = ml->semaphore; | |
1616 if (ml->semaphore == 0) pthread_cond_signal(ml->pc); | |
1617 ml->semaphore += increment; | |
1618 pthread_mutex_unlock(ml->pm); | |
1619 dbgprintf("ReleaseSemaphore(semaphore 0x%x, increment %d, prev_count 0x%x) => 1\n", | |
1620 hsem, increment, prev_count); | |
1621 return 1; | |
1 | 1622 } |
1623 | |
1624 | |
1625 long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey) | |
1626 { | |
128 | 1627 long result=RegOpenKeyExA(key, subkey, reserved, access, newkey); |
1628 dbgprintf("RegOpenKeyExA(key 0x%x, subkey %s, reserved %d, access 0x%x, pnewkey 0x%x) => %d\n", | |
1629 key, subkey, reserved, access, newkey, result); | |
1630 if(newkey)dbgprintf(" New key: 0x%x\n", *newkey); | |
1631 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1632 } |
1 | 1633 long WINAPI expRegCloseKey(long key) |
1634 { | |
128 | 1635 long result=RegCloseKey(key); |
1636 dbgprintf("RegCloseKey(0x%x) => %d\n", key, result); | |
1637 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1638 } |
1 | 1639 long WINAPI expRegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count) |
1640 { | |
128 | 1641 long result=RegQueryValueExA(key, value, reserved, type, data, count); |
1642 dbgprintf("RegQueryValueExA(key 0x%x, value %s, reserved 0x%x, data 0x%x, count 0x%x)" | |
1643 " => 0x%x\n", key, value, reserved, data, count, result); | |
1644 if(data && count)dbgprintf(" read %d bytes: '%s'\n", *count, data); | |
1645 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1646 } |
1 | 1647 long WINAPI expRegCreateKeyExA(long key, const char* name, long reserved, |
1648 void* classs, long options, long security, | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1649 void* sec_attr, int* newkey, int* status) |
1 | 1650 { |
128 | 1651 long result=RegCreateKeyExA(key, name, reserved, classs, options, security, sec_attr, newkey, status); |
1652 dbgprintf("RegCreateKeyExA(key 0x%x, name 0x%x='%s', reserved=0x%x," | |
1653 " 0x%x, 0x%x, 0x%x, newkey=0x%x, status=0x%x) => %d\n", | |
1654 key, name, name, reserved, classs, options, security, sec_attr, newkey, status, result); | |
1655 if(!result && newkey) dbgprintf(" New key: 0x%x\n", *newkey); | |
1656 if(!result && status) dbgprintf(" New key status: 0x%x\n", *status); | |
1657 return result; | |
1 | 1658 } |
1659 long WINAPI expRegSetValueExA(long key, const char* name, long v1, long v2, void* data, long size) | |
1660 { | |
128 | 1661 long result=RegSetValueExA(key, name, v1, v2, data, size); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1662 dbgprintf("RegSetValueExA(key 0x%x, name '%s', 0x%x, 0x%x, data 0x%x -> 0x%x '%s', size=%d) => %d", |
128 | 1663 key, name, v1, v2, data, *(int*)data, data, size, result); |
1664 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1665 } |
1 | 1666 |
1667 long WINAPI expRegOpenKeyA ( | |
1668 long hKey, | |
1669 LPCSTR lpSubKey, | |
1670 int* phkResult | |
1671 ){ | |
128 | 1672 long result=RegOpenKeyExA(hKey, lpSubKey, 0, 0, phkResult); |
1673 dbgprintf("RegOpenKeyExA(key 0x%x, subkey '%s', 0x%x) => %d\n", | |
1674 hKey, lpSubKey, phkResult, result); | |
1675 if(!result && phkResult) dbgprintf(" New key: 0x%x\n", *phkResult); | |
1676 return result; | |
1 | 1677 } |
1678 | |
2069 | 1679 DWORD WINAPI expRegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count, |
1680 LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count) | |
1681 { | |
1682 return RegEnumValueA(hkey, index, value, val_count, | |
1683 reserved, type, data, count); | |
1684 } | |
1685 | |
1 | 1686 long WINAPI expQueryPerformanceCounter(long long* z) |
1687 { | |
1688 longcount(z); | |
128 | 1689 dbgprintf("QueryPerformanceCounter(0x%x) => 1 ( %Ld )\n", z, *z); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1690 return 1; |
1 | 1691 } |
1692 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1693 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1694 * return CPU clock (in kHz), using linux's /proc filesystem (/proc/cpuinfo) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1695 */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1696 static double linux_cpuinfo_freq() |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1697 { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1698 double freq=-1; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1699 FILE *f; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1700 char line[200]; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1701 char *s,*value; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1702 |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1703 f = fopen ("/proc/cpuinfo", "r"); |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1704 if (f != NULL) { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1705 while (fgets(line,sizeof(line),f)!=NULL) { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1706 /* NOTE: the ':' is the only character we can rely on */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1707 if (!(value = strchr(line,':'))) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1708 continue; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1709 /* terminate the valuename */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1710 *value++ = '\0'; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1711 /* skip any leading spaces */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1712 while (*value==' ') value++; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1713 if ((s=strchr(value,'\n'))) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1714 *s='\0'; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1715 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1716 if (!strncasecmp(line, "cpu MHz",strlen("cpu MHz")) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1717 && sscanf(value, "%lf", &freq) == 1) { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1718 freq*=1000; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1719 break; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1720 } |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1721 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1722 fclose(f); |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1723 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1724 return freq; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1725 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1726 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1727 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1728 static double |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1729 solaris_kstat_freq() |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1730 { |
1679
73c8f54305b1
Add a few ifdefs, so that the code compiles on old solaris releases (2.6 and 7)
jkeil
parents:
1543
diff
changeset
|
1731 #if defined(HAVE_LIBKSTAT) && defined(KSTAT_DATA_INT32) |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1732 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1733 * try to extract the CPU speed from the solaris kernel's kstat data |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1734 */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1735 kstat_ctl_t *kc; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1736 kstat_t *ksp; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1737 kstat_named_t *kdata; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1738 int mhz = 0; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1739 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1740 kc = kstat_open(); |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1741 if (kc != NULL) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1742 { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1743 ksp = kstat_lookup(kc, "cpu_info", 0, "cpu_info0"); |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1744 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1745 /* kstat found and name/value pairs? */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1746 if (ksp != NULL && ksp->ks_type == KSTAT_TYPE_NAMED) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1747 { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1748 /* read the kstat data from the kernel */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1749 if (kstat_read(kc, ksp, NULL) != -1) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1750 { |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1751 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1752 * lookup desired "clock_MHz" entry, check the expected |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1753 * data type |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1754 */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1755 kdata = (kstat_named_t *)kstat_data_lookup(ksp, "clock_MHz"); |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1756 if (kdata != NULL && kdata->data_type == KSTAT_DATA_INT32) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1757 mhz = kdata->value.i32; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1758 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1759 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1760 kstat_close(kc); |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1761 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1762 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1763 if (mhz > 0) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1764 return mhz * 1000.; |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1765 #endif /* HAVE_LIBKSTAT */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1766 return -1; // kstat stuff is not available, CPU freq is unknown |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1767 } |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1768 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1769 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1770 * Measure CPU freq using the pentium's time stamp counter register (TSC) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1771 */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1772 static double tsc_freq() |
1 | 1773 { |
128 | 1774 static double ofreq=0.0; |
1775 int i; | |
1 | 1776 int x,y; |
128 | 1777 i=time(NULL); |
1778 if (ofreq != 0.0) return ofreq; | |
1 | 1779 while(i==time(NULL)); |
1780 x=localcount(); | |
1781 i++; | |
1782 while(i==time(NULL)); | |
1783 y=localcount(); | |
128 | 1784 ofreq = (double)(y-x)/1000.; |
1785 return ofreq; | |
1 | 1786 } |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1787 |
1 | 1788 static double CPU_Freq() |
1789 { | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1790 double freq; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1791 |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1792 if ((freq = linux_cpuinfo_freq()) > 0) |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1793 return freq; |
1 | 1794 |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1795 if ((freq = solaris_kstat_freq()) > 0) |
1 | 1796 return freq; |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1096
diff
changeset
|
1797 |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1798 return tsc_freq(); |
1 | 1799 } |
1800 | |
1801 long WINAPI expQueryPerformanceFrequency(long long* z) | |
1802 { | |
1803 *z=(long long)CPU_Freq(); | |
128 | 1804 dbgprintf("QueryPerformanceFrequency(0x%x) => 1 ( %Ld )\n", z, *z); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1805 return 1; |
1 | 1806 } |
1807 long WINAPI exptimeGetTime() | |
1808 { | |
1809 struct timeval t; | |
128 | 1810 long result; |
1 | 1811 gettimeofday(&t, 0); |
128 | 1812 result=1000*t.tv_sec+t.tv_usec/1000; |
1813 dbgprintf("timeGetTime() => %d\n", result); | |
1814 return result; | |
1 | 1815 } |
1816 void* WINAPI expLocalHandle(void* v) | |
1817 { | |
128 | 1818 dbgprintf("LocalHandle(0x%x) => 0x%x\n", v, v); |
1 | 1819 return v; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1820 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1821 |
1 | 1822 void* WINAPI expGlobalHandle(void* v) |
1823 { | |
128 | 1824 dbgprintf("GlobalHandle(0x%x) => 0x%x\n", v, v); |
1 | 1825 return v; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1826 } |
1 | 1827 int WINAPI expGlobalUnlock(void* v) |
1828 { | |
128 | 1829 dbgprintf("GlobalUnlock(0x%x) => 1\n", v); |
1 | 1830 return 1; |
1831 } | |
1832 void* WINAPI expGlobalFree(void* v) | |
1833 { | |
128 | 1834 dbgprintf("GlobalFree(0x%x) => 0\n", v); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1835 my_release(v); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1836 //free(v); |
1 | 1837 return 0; |
128 | 1838 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1839 |
128 | 1840 void* WINAPI expGlobalReAlloc(void* v, int size, int flags) |
1841 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1842 void* result=my_realloc(v, size); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1843 //void* result=realloc(v, size); |
128 | 1844 dbgprintf("GlobalReAlloc(0x%x, size %d, flags 0x%x) => 0x%x\n", v,size,flags,result); |
1845 return result; | |
1846 } | |
1 | 1847 |
1848 int WINAPI expLocalUnlock(void* v) | |
1849 { | |
128 | 1850 dbgprintf("LocalUnlock(0x%x) => 1\n", v); |
1 | 1851 return 1; |
1852 } | |
128 | 1853 // |
1 | 1854 void* WINAPI expLocalFree(void* v) |
1855 { | |
128 | 1856 dbgprintf("LocalFree(0x%x) => 0\n", v); |
1 | 1857 my_release(v); |
1858 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1859 } |
1 | 1860 HRSRC WINAPI expFindResourceA(HMODULE module, char* name, char* type) |
1861 { | |
128 | 1862 HRSRC result=FindResourceA(module, name, type); |
1863 dbgprintf("FindResourceA(module 0x%x, name 0x%x, type 0x%x) => 0x%x\n", module, name, type, result); | |
1864 return result; | |
1 | 1865 } |
128 | 1866 extern HRSRC WINAPI LoadResource(HMODULE, HRSRC); |
1 | 1867 HGLOBAL WINAPI expLoadResource(HMODULE module, HRSRC res) |
1868 { | |
128 | 1869 HGLOBAL result=LoadResource(module, res); |
1870 dbgprintf("LoadResource(module 0x%x, resource 0x%x) => 0x%x\n", module, res, result); | |
1871 return result; | |
1 | 1872 } |
1873 void* WINAPI expLockResource(long res) | |
1874 { | |
128 | 1875 void* result=LockResource(res); |
1876 dbgprintf("LockResource(0x%x) => 0x%x\n", res, result); | |
1877 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1878 } |
1 | 1879 int WINAPI expFreeResource(long res) |
1880 { | |
128 | 1881 int result=FreeResource(res); |
1882 dbgprintf("FreeResource(0x%x) => %d\n", res, result); | |
1883 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1884 } |
1 | 1885 //bool fun(HANDLE) |
1886 //!0 on success | |
1887 int WINAPI expCloseHandle(long v1) | |
1888 { | |
128 | 1889 dbgprintf("CloseHandle(0x%x) => 1\n", v1); |
1 | 1890 return 1; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1891 } |
1 | 1892 |
1893 const char* WINAPI expGetCommandLineA() | |
1894 { | |
128 | 1895 dbgprintf("GetCommandLineA() => \"c:\\aviplay.exe\"\n"); |
1 | 1896 return "c:\\aviplay.exe"; |
1897 } | |
128 | 1898 static short envs[]={'p', 'a', 't', 'h', ' ', 'c', ':', '\\', 0, 0}; |
1 | 1899 LPWSTR WINAPI expGetEnvironmentStringsW() |
1900 { | |
128 | 1901 dbgprintf("GetEnvironmentStringsW() => 0\n", envs); |
1902 return 0; | |
1 | 1903 } |
121 | 1904 void * WINAPI expRtlZeroMemory(void *p, size_t len) |
1905 { | |
1906 void* result=memset(p,0,len); | |
1907 dbgprintf("RtlZeroMemory(0x%x, len %d) => 0x%x\n",p,len,result); | |
1908 return result; | |
1909 } | |
1910 void * WINAPI expRtlMoveMemory(void *dst, void *src, size_t len) | |
1911 { | |
1912 void* result=memmove(dst,src,len); | |
1913 dbgprintf("RtlMoveMemory (dest 0x%x, src 0x%x, len %d) => 0x%x\n",dst,src,len,result); | |
1914 return result; | |
1915 } | |
1916 | |
1917 void * WINAPI expRtlFillMemory(void *p, int ch, size_t len) | |
1918 { | |
1919 void* result=memset(p,ch,len); | |
1920 dbgprintf("RtlFillMemory(0x%x, char 0x%x, len %d) => 0x%x\n",p,ch,len,result); | |
1921 return result; | |
1922 } | |
1 | 1923 int WINAPI expFreeEnvironmentStringsW(short* strings) |
1924 { | |
128 | 1925 dbgprintf("FreeEnvironmentStringsW(0x%x) => 1\n", strings); |
1 | 1926 return 1; |
1927 } | |
128 | 1928 int WINAPI expFreeEnvironmentStringsA(char* strings) |
1929 { | |
1930 dbgprintf("FreeEnvironmentStringsA(0x%x) => 1\n", strings); | |
1931 return 1; | |
1932 } | |
1933 static const char ch_envs[]= | |
1934 "__MSVCRT_HEAP_SELECT=__GLOBAL_HEAP_SELECTED,1\r\n" | |
1935 "PATH=C:\\;C:\\windows\\;C:\\windows\\system\r\n"; | |
1 | 1936 LPCSTR WINAPI expGetEnvironmentStrings() |
1937 { | |
128 | 1938 dbgprintf("GetEnvironmentStrings() => 0x%x\n", ch_envs); |
1939 return (LPCSTR)ch_envs; | |
1940 // dbgprintf("GetEnvironmentStrings() => 0\n"); | |
1941 // return 0; | |
1 | 1942 } |
1943 | |
1944 int WINAPI expGetStartupInfoA(STARTUPINFOA *s) | |
1945 { | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1946 int i; |
128 | 1947 dbgprintf("GetStartupInfoA(0x%x) => 1\n"); |
1 | 1948 memset(s, 0, sizeof(*s)); |
1949 s->cb=sizeof(*s); | |
128 | 1950 // s->lpReserved="Reserved"; |
1951 // s->lpDesktop="Desktop"; | |
1952 // s->lpTitle="Title"; | |
1953 // s->dwX=s->dwY=0; | |
1954 // s->dwXSize=s->dwYSize=200; | |
1955 s->dwFlags=s->wShowWindow=1; | |
1956 // s->hStdInput=s->hStdOutput=s->hStdError=0x1234; | |
1957 dbgprintf(" cb=%d\n", s->cb); | |
1958 dbgprintf(" lpReserved='%s'\n", s->lpReserved); | |
1959 dbgprintf(" lpDesktop='%s'\n", s->lpDesktop); | |
1960 dbgprintf(" lpTitle='%s'\n", s->lpTitle); | |
1961 dbgprintf(" dwX=%d dwY=%d dwXSize=%d dwYSize=%d\n", | |
1962 s->dwX, s->dwY, s->dwXSize, s->dwYSize); | |
1963 dbgprintf(" dwXCountChars=%d dwYCountChars=%d dwFillAttribute=%d\n", | |
1964 s->dwXCountChars, s->dwYCountChars, s->dwFillAttribute); | |
1965 dbgprintf(" dwFlags=0x%x wShowWindow=0x%x cbReserved2=0x%x\n", | |
1966 s->dwFlags, s->wShowWindow, s->cbReserved2); | |
1967 dbgprintf(" lpReserved2=0x%x hStdInput=0x%x hStdOutput=0x%x hStdError=0x%x\n", | |
1968 s->lpReserved2, s->hStdInput, s->hStdOutput, s->hStdError); | |
1 | 1969 return 1; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1970 } |
1 | 1971 |
1972 int WINAPI expGetStdHandle(int z) | |
1973 { | |
128 | 1974 dbgprintf("GetStdHandle(0x%x) => 0x%x\n", z+0x1234); |
1975 return z+0x1234; | |
1 | 1976 } |
1977 int WINAPI expGetFileType(int handle) | |
1978 { | |
128 | 1979 dbgprintf("GetFileType(0x%x) => 0x3 = pipe\n", handle); |
1980 return 0x3; | |
1 | 1981 } |
1982 int WINAPI expSetHandleCount(int count) | |
1983 { | |
128 | 1984 dbgprintf("SetHandleCount(0x%x) => 1\n", count); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1985 return 1; |
1 | 1986 } |
1987 int WINAPI expGetACP() | |
1988 { | |
128 | 1989 dbgprintf("GetACP() => 0\n"); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
1990 return 0; |
1 | 1991 } |
1992 extern WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m); | |
1993 int WINAPI expGetModuleFileNameA(int module, char* s, int len) | |
1994 { | |
1995 WINE_MODREF *mr; | |
128 | 1996 int result; |
1 | 1997 // printf("File name of module %X requested\n", module); |
1998 if(s==0) | |
128 | 1999 result=0; |
2000 else | |
1 | 2001 if(len<35) |
128 | 2002 result=0; |
2003 else | |
1 | 2004 { |
128 | 2005 result=1; |
2006 strcpy(s, "c:\\windows\\system\\"); | |
2007 mr=MODULE32_LookupHMODULE(module); | |
2008 if(mr==0)//oops | |
2009 strcat(s, "aviplay.dll"); | |
2010 else | |
2011 if(strrchr(mr->filename, '/')==NULL) | |
2012 strcat(s, mr->filename); | |
2013 else | |
2014 strcat(s, strrchr(mr->filename, '/')+1); | |
2015 } | |
2016 if(!s) | |
2017 dbgprintf("GetModuleFileNameA(0x%x, 0x%x, %d) => %d\n", | |
2018 module, s, len, result); | |
1 | 2019 else |
128 | 2020 dbgprintf("GetModuleFileNameA(0x%x, 0x%x, %d) => %d ( '%s' )", |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2021 module, s, len, result, s); |
128 | 2022 return result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2023 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2024 |
1 | 2025 int WINAPI expSetUnhandledExceptionFilter(void* filter) |
2026 { | |
128 | 2027 dbgprintf("SetUnhandledExceptionFilter(0x%x) => 1\n", filter); |
1 | 2028 return 1;//unsupported and probably won't ever be supported |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2029 } |
2069 | 2030 |
1 | 2031 int WINAPI expLoadLibraryA(char* name) |
2032 { | |
2069 | 2033 int result = 0; |
713 | 2034 char* lastbc; |
2069 | 2035 int i; |
713 | 2036 if (!name) |
2037 return -1; | |
2038 // we skip to the last backslash | |
2039 // this is effectively eliminating weird characters in | |
2040 // the text output windows | |
2668 | 2041 |
2042 if (strcmp(name, "KERNEL32") == 0){ | |
2043 printf("expLoadLibraryA('%s')\n",name); | |
2044 return (int) LookupExternal(name, 0); | |
2045 } | |
2069 | 2046 |
713 | 2047 lastbc = strrchr(name, '\\'); |
2048 if (lastbc) | |
2049 { | |
2050 int i; | |
2051 lastbc++; | |
2052 for (i = 0; 1 ;i++) | |
2053 { | |
2054 name[i] = *lastbc++; | |
2055 if (!name[i]) | |
2056 break; | |
2057 } | |
2058 } | |
2069 | 2059 if(strncmp(name, "c:\\windows\\", 11)==0) name += 11; |
1416 | 2060 if(strncmp(name, ".\\", 2)==0) name += 2; |
2069 | 2061 |
2062 dbgprintf("Entering LoadLibraryA(%s)\n", name); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2063 // PIMJ is loading kernel32.dll |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2064 if (strcasecmp(name, "kernel32.dll") == 1) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2065 return (int) LookupExternal(name, 0); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2066 |
2069 | 2067 result=LoadLibraryA(name); |
2068 dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result); | |
2069 | |
128 | 2070 return result; |
2069 | 2071 } |
1 | 2072 int WINAPI expFreeLibrary(int module) |
2073 { | |
128 | 2074 int result=FreeLibrary(module); |
2075 dbgprintf("FreeLibrary(0x%x) => %d\n", module, result); | |
2076 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2077 } |
1 | 2078 void* WINAPI expGetProcAddress(HMODULE mod, char* name) |
2079 { | |
2069 | 2080 void* result; |
2081 if(mod!=MODULE_HANDLE_kernel32) | |
128 | 2082 result=GetProcAddress(mod, name); |
2083 else | |
2084 result=LookupExternalByName("kernel32.dll", name); | |
2085 dbgprintf("GetProcAddress(0x%x, '%s') => 0x%x\n", mod, name, result); | |
2086 return result; | |
2069 | 2087 } |
1 | 2088 |
2089 long WINAPI expCreateFileMappingA(int hFile, void* lpAttr, | |
2090 long flProtect, long dwMaxHigh, long dwMaxLow, const char* name) | |
2091 { | |
128 | 2092 long result=CreateFileMappingA(hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name); |
2093 if(!name) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2094 dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x," |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2095 "flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0) => %d\n", |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2096 hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, result); |
128 | 2097 else |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2098 dbgprintf("CreateFileMappingA(file 0x%x, lpAttr 0x%x," |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2099 "flProtect 0x%x, dwMaxHigh 0x%x, dwMaxLow 0x%x, name 0x%x='%s') => %d\n", |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2100 hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name, name, result); |
128 | 2101 return result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2102 } |
1 | 2103 |
2104 long WINAPI expOpenFileMappingA(long hFile, long hz, const char* name) | |
2105 { | |
128 | 2106 long result=OpenFileMappingA(hFile, hz, name); |
2107 if(!name) | |
2108 dbgprintf("OpenFileMappingA(0x%x, 0x%x, 0) => %d\n", | |
2109 hFile, hz, result); | |
2110 else | |
2111 dbgprintf("OpenFileMappingA(0x%x, 0x%x, 0x%x='%s') => %d\n", | |
2112 hFile, hz, name, name, result); | |
2113 return result; | |
1 | 2114 } |
2115 | |
2116 void* WINAPI expMapViewOfFile(HANDLE file, DWORD mode, DWORD offHigh, DWORD offLow, DWORD size) | |
2117 { | |
128 | 2118 dbgprintf("MapViewOfFile(0x%x, 0x%x, 0x%x, 0x%x, size %d) => 0x%x\n", |
2119 file,mode,offHigh,offLow,size,(char*)file+offLow); | |
1 | 2120 return (char*)file+offLow; |
2121 } | |
2122 | |
2123 void* WINAPI expUnmapViewOfFile(void* view) | |
2124 { | |
128 | 2125 dbgprintf("UnmapViewOfFile(0x%x) => 0\n", view); |
1 | 2126 return 0; |
2127 } | |
2128 | |
2129 void* WINAPI expSleep(int time) | |
2130 { | |
2069 | 2131 // extern int avm_usleep(int); |
128 | 2132 dbgprintf("Sleep(%d) => 0\n", time); |
2069 | 2133 // avm_usleep(time); |
1 | 2134 usleep(time); |
2135 return 0; | |
2136 } | |
2137 // why does IV32 codec want to call this? I don't know ... | |
2138 void* WINAPI expCreateCompatibleDC(int hdc) | |
2139 { | |
128 | 2140 dbgprintf("CreateCompatibleDC(%d) => 0x81\n", hdc); |
2141 return (void*)0x81; | |
1 | 2142 } |
2143 | |
2144 int WINAPI expGetDeviceCaps(int hdc, int unk) | |
2145 { | |
128 | 2146 dbgprintf("GetDeviceCaps(0x%x, %d) => 0\n", hdc, unk); |
1 | 2147 return 0; |
2148 } | |
2149 | |
2150 WIN_BOOL WINAPI expDeleteDC(int hdc) | |
2151 { | |
128 | 2152 dbgprintf("DeleteDC(0x%x) => 0\n", hdc); |
1 | 2153 return 0; |
2154 } | |
2155 | |
2156 int expwsprintfA(char* string, char* format, ...) | |
2157 { | |
2158 va_list va; | |
128 | 2159 int result; |
1 | 2160 va_start(va, format); |
128 | 2161 result=vsprintf(string, format, va); |
2162 dbgprintf("wsprintfA(0x%x, '%s', ...) => %d\n", string, format, result); | |
2163 va_end(va); | |
2164 return result; | |
1 | 2165 } |
2166 | |
2167 int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename) | |
2168 { | |
2169 int size=255; | |
2170 char buffer[256]; | |
2171 char* fullname; | |
2172 int result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2173 |
1 | 2174 buffer[255]=0; |
128 | 2175 if(!(appname && keyname && filename) ) |
2176 { | |
2177 dbgprintf("GetPrivateProfileIntA('%s', '%s', %d, '%s') => %d\n", appname, keyname, default_value, filename, default_value ); | |
2178 return default_value; | |
2179 } | |
1 | 2180 fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename)); |
2181 strcpy(fullname, "Software\\IniFileMapping\\"); | |
2182 strcat(fullname, appname); | |
2183 strcat(fullname, "\\"); | |
2184 strcat(fullname, keyname); | |
2185 strcat(fullname, "\\"); | |
2186 strcat(fullname, filename); | |
2187 result=RegQueryValueExA(HKEY_LOCAL_MACHINE, fullname, NULL, NULL, (int*)buffer, &size); | |
2188 if((size>=0)&&(size<256)) | |
2189 buffer[size]=0; | |
2190 // printf("GetPrivateProfileIntA(%s, %s, %s) -> %s\n", appname, keyname, filename, buffer); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2191 free(fullname); |
1 | 2192 if(result) |
128 | 2193 result=default_value; |
1 | 2194 else |
128 | 2195 result=atoi(buffer); |
2196 dbgprintf("GetPrivateProfileIntA('%s', '%s', %d, '%s') => %d\n", appname, keyname, default_value, filename, result); | |
2197 return result; | |
1 | 2198 } |
128 | 2199 int WINAPI expGetProfileIntA(const char* appname, const char* keyname, int default_value) |
2200 { | |
2201 dbgprintf("GetProfileIntA -> "); | |
2202 // dbgprintf("GetProfileIntA(%s, %s, %d)\n", appname, keyname, default_value); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2203 return expGetPrivateProfileIntA(appname, keyname, default_value, "default"); |
128 | 2204 } |
2205 | |
1 | 2206 int WINAPI expGetPrivateProfileStringA(const char* appname, const char* keyname, |
2207 const char* def_val, char* dest, unsigned int len, const char* filename) | |
2208 { | |
2209 int result; | |
2210 int size; | |
2211 char* fullname; | |
128 | 2212 dbgprintf("GetPrivateProfileStringA('%s', '%s', def_val '%s', 0x%x, 0x%x, '%s')", appname, keyname, def_val, dest, len, filename ); |
1 | 2213 if(!(appname && keyname && filename) ) return 0; |
2214 fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename)); | |
2215 strcpy(fullname, "Software\\IniFileMapping\\"); | |
2216 strcat(fullname, appname); | |
2217 strcat(fullname, "\\"); | |
2218 strcat(fullname, keyname); | |
2219 strcat(fullname, "\\"); | |
2220 strcat(fullname, filename); | |
2221 size=len; | |
2222 result=RegQueryValueExA(HKEY_LOCAL_MACHINE, fullname, NULL, NULL, (int*)dest, &size); | |
2223 // printf("GetPrivateProfileStringA(%s, %s, %s, %X, %X, %s)\n", appname, keyname, def_val, dest, len, filename ); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2224 free(fullname); |
128 | 2225 if(result) |
2226 { | |
2227 strncpy(dest, def_val, size); | |
2228 if (strlen(def_val)< size) size = strlen(def_val); | |
2229 } | |
2230 dbgprintf(" => %d ( '%s' )\n", size, dest); | |
1 | 2231 return size; |
2232 } | |
2233 int WINAPI expWritePrivateProfileStringA(const char* appname, const char* keyname, | |
2234 const char* string, const char* filename) | |
2235 { | |
2236 int size=256; | |
2237 char* fullname; | |
128 | 2238 dbgprintf("WritePrivateProfileStringA('%s', '%s', '%s', '%s')", appname, keyname, string, filename ); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2239 if(!(appname && keyname && filename) ) |
128 | 2240 { |
2241 dbgprintf(" => -1\n"); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2242 return -1; |
128 | 2243 } |
1 | 2244 fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename)); |
2245 strcpy(fullname, "Software\\IniFileMapping\\"); | |
2246 strcat(fullname, appname); | |
2247 strcat(fullname, "\\"); | |
2248 strcat(fullname, keyname); | |
2249 strcat(fullname, "\\"); | |
2250 strcat(fullname, filename); | |
2251 RegSetValueExA(HKEY_LOCAL_MACHINE, fullname, 0, REG_SZ, (int*)string, strlen(string)); | |
2252 // printf("RegSetValueExA(%s,%d)\n", string, strlen(string)); | |
2253 // printf("WritePrivateProfileStringA(%s, %s, %s, %s)\n", appname, keyname, string, filename ); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2254 free(fullname); |
128 | 2255 dbgprintf(" => 0\n"); |
1 | 2256 return 0; |
2257 } | |
2139 | 2258 int expsprintf(char* str, const char* format, ...) |
2259 { | |
2260 va_list args; | |
2261 int r; | |
2262 dbgprintf("sprintf(%s, %s)\n", str, format); | |
2263 va_start(args, format); | |
2264 r = vsprintf(str, format, args); | |
2265 va_end(args); | |
2266 return r; | |
2267 } | |
2268 int expsscanf(const char* str, const char* format, ...) | |
2269 { | |
2270 va_list args; | |
2271 int r; | |
2272 dbgprintf("sscanf(%s, %s)\n", str, format); | |
2273 va_start(args, format); | |
2274 r = vsscanf(str, format, args); | |
2275 va_end(args); | |
2276 return r; | |
2277 } | |
2278 void* expfopen(const char* path, const char* mode) | |
2279 { | |
2280 printf("fopen: \"%s\" mode:%s\n", path, mode); | |
2281 //return fopen(path, mode); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2282 return fdopen(0, mode); // everything on screen |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2283 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2284 int expfprintf(void* stream, const char* format, ...) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2285 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2286 va_list args; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2287 int r = 0; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2288 #if 1 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2289 va_start(args, format); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2290 r = vfprintf((FILE*) stream, format, args); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2291 va_end(args); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2292 #endif |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2293 return r; |
2139 | 2294 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2295 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2296 int expprintf(const char* format, ...) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2297 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2298 va_list args; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2299 int r; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2300 va_start(args, format); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2301 r = vprintf(format, args); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2302 va_end(args); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2303 return r; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2304 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2305 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2306 void* expwcscpy(WCHAR* dst, const WCHAR* src) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2307 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2308 WCHAR* p = dst; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2309 while ((*p++ = *src++)) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2310 ; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2311 return dst; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2312 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2313 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2314 |
1 | 2315 unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, INT default_value, const char* filename) |
2316 { | |
2317 return expGetPrivateProfileIntA(appname, keyname, default_value, filename); | |
2318 } | |
2319 int _GetPrivateProfileStringA(const char* appname, const char* keyname, | |
2320 const char* def_val, char* dest, unsigned int len, const char* filename) | |
2321 { | |
2322 return expGetPrivateProfileStringA(appname, keyname, def_val, dest, len, filename); | |
2323 } | |
2324 int _WritePrivateProfileStringA(const char* appname, const char* keyname, | |
2325 const char* string, const char* filename) | |
2326 { | |
2327 return expWritePrivateProfileStringA(appname, keyname, string, filename); | |
2328 } | |
2329 | |
2330 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2331 |
1 | 2332 int WINAPI expDefDriverProc(int _private, int id, int msg, int arg1, int arg2) |
2333 { | |
128 | 2334 dbgprintf("DefDriverProc(0x%x, 0x%x, 0x%x, 0x%x, 0x%x) => 0\n", _private, id, msg, arg1, arg2); |
1 | 2335 return 0; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2336 } |
1 | 2337 |
2338 int WINAPI expSizeofResource(int v1, int v2) | |
2339 { | |
128 | 2340 int result=SizeofResource(v1, v2); |
2341 dbgprintf("SizeofResource(0x%x, 0x%x) => %d\n", v1, v2, result); | |
2342 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2343 } |
1 | 2344 |
2345 int WINAPI expGetLastError() | |
2346 { | |
128 | 2347 int result=GetLastError(); |
2348 dbgprintf("GetLastError() => 0x%x\n", result); | |
2349 return result; | |
1 | 2350 } |
2351 | |
2352 void WINAPI expSetLastError(int error) | |
2353 { | |
128 | 2354 dbgprintf("SetLastError(0x%x)\n", error); |
1 | 2355 SetLastError(error); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2356 } |
1 | 2357 |
2358 char* expstrrchr(char* string, int value) | |
2359 { | |
128 | 2360 char* result=strrchr(string, value); |
2361 if(result) | |
2362 dbgprintf("strrchr(0x%x='%s', %d) => 0x%x='%s'", string, string, value, result, result); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2363 else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2364 dbgprintf("strrchr(0x%x='%s', %d) => 0", string, string, value); |
128 | 2365 return result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2366 } |
1 | 2367 |
2368 char* expstrchr(char* string, int value) | |
2369 { | |
128 | 2370 char* result=strchr(string, value); |
2371 if(result) | |
2372 dbgprintf("strchr(0x%x='%s', %d) => 0x%x='%s'", string, string, value, result, result); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2373 else |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2374 dbgprintf("strchr(0x%x='%s', %d) => 0", string, string, value); |
128 | 2375 return result; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2376 } |
128 | 2377 int expstrlen(char* str) |
2378 { | |
2379 int result=strlen(str); | |
2380 dbgprintf("strlen(0x%x='%s') => %d\n", str, str, result); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2381 return result; |
128 | 2382 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2383 int expstrcpy(char* str1, const char* str2) |
128 | 2384 { |
713 | 2385 int result= (int) strcpy(str1, str2); |
2386 dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result); | |
128 | 2387 return result; |
2388 } | |
2389 int expstrcmp(const char* str1, const char* str2) | |
2390 { | |
2391 int result=strcmp(str1, str2); | |
2392 dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); | |
2393 return result; | |
2394 } | |
2668 | 2395 int expstrncmp(const char* str1, const char* str2,int x) |
2396 { | |
2397 int result=strncmp(str1, str2,x); | |
2398 dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); | |
2399 return result; | |
2400 } | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2401 int expstrcat(char* str1, const char* str2) |
128 | 2402 { |
713 | 2403 int result= (int) strcat(str1, str2); |
2404 dbgprintf("strcat(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2405 return result; |
128 | 2406 } |
713 | 2407 int expisalnum(int c) |
128 | 2408 { |
713 | 2409 int result= (int) isalnum(c); |
2410 dbgprintf("isalnum(0x%x='%c' => %d\n", c, c, result); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2411 return result; |
713 | 2412 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2413 int expmemmove(void* dest, void* src, int n) |
713 | 2414 { |
2415 int result= (int) memmove(dest, src, n); | |
2416 dbgprintf("memmove(0x%x, 0x%x, %d) => %d\n", dest, src, n, result); | |
2417 return result; | |
128 | 2418 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2419 int expmemcmp(void* dest, void* src, int n) |
128 | 2420 { |
2421 int result=memcmp(dest, src, n); | |
2422 dbgprintf("memcmp(0x%x, 0x%x, %d) => %d\n", dest, src, n, result); | |
2423 return result; | |
2424 } | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2425 void *expmemcpy(void* dest, void* src, int n) |
130 | 2426 { |
597 | 2427 void *result=memcpy(dest, src, n); |
2428 dbgprintf("memcpy(0x%x, 0x%x, %d) => %p\n", dest, src, n, result); | |
130 | 2429 return result; |
2430 } | |
128 | 2431 time_t exptime(time_t* t) |
2432 { | |
2433 time_t result=time(t); | |
2434 dbgprintf("time(0x%x) => %d\n", t, result); | |
2435 return result; | |
2436 } | |
2437 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2438 int exprand(void) |
2139 | 2439 { |
2440 return rand(); | |
2441 } | |
2442 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2443 double explog10(double x) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2444 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2445 return log10(x); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2446 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2447 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2448 double expcos(double x) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2449 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2450 return cos(x); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2451 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2452 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2453 double exppow(double x, double y) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2454 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2455 return pow(x, y); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2456 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2457 |
2139 | 2458 void expsrand(int seed) |
2459 { | |
2460 srand(seed); | |
2461 } | |
2462 | |
2463 int exp_ftol(float f) | |
2464 { | |
2465 return (int)(f+.5); | |
2466 } | |
2467 | |
128 | 2468 int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax) |
2469 { | |
2069 | 2470 int result=snprintf(str, cbMax, "%.8x-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", |
2471 guid->f1, guid->f2, guid->f3, | |
2472 (unsigned char)guid->f4[0], (unsigned char)guid->f4[1], | |
2473 (unsigned char)guid->f4[2], (unsigned char)guid->f4[3], | |
2474 (unsigned char)guid->f4[4], (unsigned char)guid->f4[5], | |
2475 (unsigned char)guid->f4[6], (unsigned char)guid->f4[7]); | |
128 | 2476 dbgprintf("StringFromGUID2(0x%x, 0x%x='%s', %d) => %d\n", guid, str, str, cbMax, result); |
2477 return result; | |
2478 } | |
2479 | |
1 | 2480 |
2481 int WINAPI expGetFileVersionInfoSizeA(const char* name, int* lpHandle) | |
2482 { | |
128 | 2483 dbgprintf("GetFileVersionInfoSizeA(0x%x='%s', 0x%X) => 0\n", name, name, lpHandle); |
1 | 2484 return 0; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2485 } |
1 | 2486 |
2487 int WINAPI expIsBadStringPtrW(const short* string, int nchars) | |
2488 { | |
128 | 2489 int result; |
2490 if(string==0)result=1; else result=0; | |
2491 dbgprintf("IsBadStringPtrW(0x%x, %d) => %d", string, nchars, result); | |
2492 if(string)wch_print(string); | |
2493 return result; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2494 } |
1 | 2495 extern long WINAPI InterlockedExchangeAdd( long* dest, long incr ) |
2496 { | |
2497 long ret; | |
2498 __asm__ __volatile__( "lock; xaddl %0,(%1)" | |
2499 : "=r" (ret) : "r" (dest), "0" (incr) : "memory" ); | |
2500 return ret; | |
2501 } | |
2502 | |
2503 extern long WINAPI expInterlockedIncrement( long* dest ) | |
2504 { | |
128 | 2505 long result=InterlockedExchangeAdd( dest, 1 ) + 1; |
2506 dbgprintf("InterlockedIncrement(0x%x => %d) => %d\n", dest, *dest, result); | |
2507 return result; | |
1 | 2508 } |
2509 extern long WINAPI expInterlockedDecrement( long* dest ) | |
2510 { | |
128 | 2511 long result=InterlockedExchangeAdd( dest, -1 ) - 1; |
2512 dbgprintf("InterlockedDecrement(0x%x => %d) => %d\n", dest, *dest, result); | |
2513 return result; | |
1 | 2514 } |
2515 | |
2516 extern void WINAPI expOutputDebugStringA( const char* string ) | |
2517 { | |
128 | 2518 dbgprintf("OutputDebugStringA(0x%x='%s')\n", string); |
1 | 2519 fprintf(stderr, "DEBUG: %s\n", string); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2520 } |
1 | 2521 |
2522 int WINAPI expGetDC(int hwnd) | |
2523 { | |
128 | 2524 dbgprintf("GetDC(0x%x) => 0\n", hwnd); |
1 | 2525 return 0; |
2526 } | |
2527 | |
2528 int WINAPI expGetDesktopWindow() | |
2529 { | |
128 | 2530 dbgprintf("GetDesktopWindow() => 0\n"); |
1 | 2531 return 0; |
2532 } | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2533 |
1 | 2534 int WINAPI expReleaseDC(int hwnd, int hdc) |
2535 { | |
128 | 2536 dbgprintf("ReleaseDC(0x%x, 0x%x) => 0\n", hwnd, hdc); |
2537 return 0; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2538 } |
128 | 2539 static int cursor[100]; |
2540 | |
2541 int WINAPI expLoadCursorA(int handle,LPCSTR name) | |
2542 { | |
2543 dbgprintf("LoadCursorA(%d, 0x%x='%s') => 0x%x\n", handle, name, (int)&cursor[0]); | |
2544 return (int)&cursor[0]; | |
2545 } | |
2546 int WINAPI expSetCursor(void *cursor) | |
2547 { | |
2548 dbgprintf("SetCursor(0x%x) => 0x%x\n", cursor, cursor); | |
2549 return (int)cursor; | |
2550 } | |
2069 | 2551 int WINAPI expGetCursorPos(void *cursor) |
2552 { | |
2553 dbgprintf("GetCursorPos(0x%x) => 0x%x\n", cursor, cursor); | |
2554 return 1; | |
2555 } | |
2556 int WINAPI expRegisterWindowMessageA(char *message) | |
2557 { | |
2558 dbgprintf("RegisterWindowMessageA(%s)\n", message); | |
2559 return 1; | |
2560 } | |
2561 int WINAPI expGetProcessVersion(int pid) | |
2562 { | |
2563 dbgprintf("GetProcessVersion(%d)\n", pid); | |
2564 return 1; | |
2565 } | |
2566 int WINAPI expGetCurrentThread(void) | |
2567 { | |
2568 dbgprintf("GetCurrentThread()\n"); | |
2779 | 2569 return 0xcfcf9898; |
2069 | 2570 } |
2571 int WINAPI expGetOEMCP(void) | |
2572 { | |
2573 dbgprintf("GetOEMCP()\n"); | |
2574 return 1; | |
2575 } | |
2576 int WINAPI expGetCPInfo(int cp,void *info) | |
2577 { | |
2578 dbgprintf("GetCPInfo()\n"); | |
2579 return 0; | |
2580 } | |
2581 int WINAPI expGetSystemMetrics(int index) | |
2582 { | |
2583 dbgprintf("GetSystemMetrics(%d)\n", index); | |
2584 return 1; | |
2585 } | |
2586 int WINAPI expGetSysColor(int index) | |
2587 { | |
2588 dbgprintf("GetSysColor(%d)\n", index); | |
2589 return 1; | |
2590 } | |
2591 int WINAPI expGetSysColorBrush(int index) | |
2592 { | |
2593 dbgprintf("GetSysColorBrush(%d)\n", index); | |
2594 return 1; | |
2595 } | |
2596 | |
2597 | |
2598 | |
128 | 2599 int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe) |
2600 { | |
2601 dbgprintf("GetSystemPaletteEntries(0x%x, 0x%x, 0x%x, 0x%x) => 0\n", | |
2602 hdc, iStartIndex, nEntries, lppe); | |
1 | 2603 return 0; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2604 } |
1 | 2605 |
2606 /* | |
2607 typedef struct _TIME_ZONE_INFORMATION { | |
2608 long Bias; | |
2609 char StandardName[32]; | |
2610 SYSTEMTIME StandardDate; | |
2611 long StandardBias; | |
2612 char DaylightName[32]; | |
2613 SYSTEMTIME DaylightDate; | |
2614 long DaylightBias; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2615 } TIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION; |
1 | 2616 */ |
2617 | |
2618 int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation) | |
2619 { | |
128 | 2620 const short name[]={'C', 'e', 'n', 't', 'r', 'a', 'l', ' ', 'S', 't', 'a', |
2621 'n', 'd', 'a', 'r', 'd', ' ', 'T', 'i', 'm', 'e', 0}; | |
2622 const short pname[]={'C', 'e', 'n', 't', 'r', 'a', 'l', ' ', 'D', 'a', 'y', | |
2623 'l', 'i', 'g', 'h', 't', ' ', 'T', 'i', 'm', 'e', 0}; | |
2624 dbgprintf("GetTimeZoneInformation(0x%x) => TIME_ZONE_ID_STANDARD\n"); | |
1 | 2625 memset(lpTimeZoneInformation, 0, sizeof(TIME_ZONE_INFORMATION)); |
128 | 2626 lpTimeZoneInformation->Bias=360;//GMT-6 |
2627 memcpy(lpTimeZoneInformation->StandardName, name, sizeof(name)); | |
2628 lpTimeZoneInformation->StandardDate.wMonth=10; | |
2629 lpTimeZoneInformation->StandardDate.wDay=5; | |
2630 lpTimeZoneInformation->StandardDate.wHour=2; | |
2631 lpTimeZoneInformation->StandardBias=0; | |
2632 memcpy(lpTimeZoneInformation->DaylightName, pname, sizeof(pname)); | |
2633 lpTimeZoneInformation->DaylightDate.wMonth=4; | |
2634 lpTimeZoneInformation->DaylightDate.wDay=1; | |
2635 lpTimeZoneInformation->DaylightDate.wHour=2; | |
2636 lpTimeZoneInformation->DaylightBias=-60; | |
2637 return TIME_ZONE_ID_STANDARD; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2638 } |
1 | 2639 |
2640 void WINAPI expGetLocalTime(SYSTEMTIME* systime) | |
2641 { | |
2642 time_t local_time; | |
2643 struct tm *local_tm; | |
2644 struct timeval tv; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2645 |
128 | 2646 dbgprintf("GetLocalTime(0x%x)\n"); |
1 | 2647 gettimeofday(&tv, NULL); |
2648 local_time=tv.tv_sec; | |
2649 local_tm=localtime(&local_time); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2650 |
1 | 2651 systime->wYear = local_tm->tm_year + 1900; |
2652 systime->wMonth = local_tm->tm_mon + 1; | |
2653 systime->wDayOfWeek = local_tm->tm_wday; | |
2654 systime->wDay = local_tm->tm_mday; | |
2655 systime->wHour = local_tm->tm_hour; | |
2656 systime->wMinute = local_tm->tm_min; | |
2657 systime->wSecond = local_tm->tm_sec; | |
2658 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000; | |
128 | 2659 dbgprintf(" Year: %d\n Month: %d\n Day of week: %d\n" |
2660 " Day: %d\n Hour: %d\n Minute: %d\n Second: %d\n" | |
2661 " Milliseconds: %d\n", | |
2662 systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay, | |
2663 systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds); | |
1 | 2664 } |
2665 | |
2666 int WINAPI expGetSystemTime(SYSTEMTIME* systime) | |
2667 { | |
2668 time_t local_time; | |
2669 struct tm *local_tm; | |
2670 struct timeval tv; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2671 |
128 | 2672 dbgprintf("GetSystemTime(0x%x)\n", systime); |
1 | 2673 gettimeofday(&tv, NULL); |
2674 local_time=tv.tv_sec; | |
2675 local_tm=gmtime(&local_time); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2676 |
1 | 2677 systime->wYear = local_tm->tm_year + 1900; |
2678 systime->wMonth = local_tm->tm_mon + 1; | |
2679 systime->wDayOfWeek = local_tm->tm_wday; | |
2680 systime->wDay = local_tm->tm_mday; | |
2681 systime->wHour = local_tm->tm_hour; | |
2682 systime->wMinute = local_tm->tm_min; | |
2683 systime->wSecond = local_tm->tm_sec; | |
2684 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000; | |
128 | 2685 dbgprintf(" Year: %d\n Month: %d\n Day of week: %d\n" |
2686 " Day: %d\n Hour: %d\n Minute: %d\n Second: %d\n" | |
2687 " Milliseconds: %d\n", | |
2688 systime->wYear, systime->wMonth, systime->wDayOfWeek, systime->wDay, | |
2689 systime->wHour, systime->wMinute, systime->wSecond, systime->wMilliseconds); | |
2069 | 2690 return 0; |
1 | 2691 } |
2692 | |
2693 int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size) | |
2694 { | |
128 | 2695 char *p; |
2696 // printf("%s %x %x\n", name, field, size); | |
1 | 2697 if(field)field[0]=0; |
128 | 2698 /* |
2699 p = getenv(name); | |
2700 if (p) strncpy(field,p,size); | |
2701 */ | |
2702 if (strcmp(name,"__MSVCRT_HEAP_SELECT")==0) | |
2703 strcpy(field,"__GLOBAL_HEAP_SELECTED,1"); | |
2704 dbgprintf("GetEnvironmentVariableA(0x%x='%s', 0x%x, %d) => %d\n", name, name, field, size, strlen(field)); | |
2705 return strlen(field); | |
2706 } | |
2707 | |
2708 void* WINAPI expCoTaskMemAlloc(ULONG cb) | |
2709 { | |
2710 return my_mreq(cb, 0); | |
2711 } | |
2712 void WINAPI expCoTaskMemFree(void* cb) | |
2713 { | |
2714 my_release(cb); | |
2715 } | |
2716 | |
2717 void* CoTaskMemAlloc(ULONG cb){return expCoTaskMemAlloc(cb);} | |
2718 void CoTaskMemFree(void* cb){expCoTaskMemFree(cb);} | |
2719 | |
2720 struct COM_OBJECT_INFO | |
2721 { | |
2722 GUID clsid; | |
2723 long (*GetClassObject) (GUID* clsid, GUID* iid, void** ppv); | |
2724 }; | |
2725 | |
2726 static struct COM_OBJECT_INFO* com_object_table=0; | |
2727 static int com_object_size=0; | |
2728 int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs) | |
2729 { | |
2069 | 2730 if(!clsid || !gcs) |
2731 return -1; | |
128 | 2732 com_object_table=realloc(com_object_table, sizeof(struct COM_OBJECT_INFO)*(++com_object_size)); |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2733 com_object_table[com_object_size-1].clsid=*clsid; |
128 | 2734 com_object_table[com_object_size-1].GetClassObject=gcs; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2735 return 0; |
128 | 2736 } |
2737 | |
2069 | 2738 int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs) |
2739 { | |
2740 int found = 0; | |
2741 int i = 0; | |
2742 if(!clsid || !gcs) | |
2743 return -1; | |
2744 | |
2745 if (com_object_table == 0) | |
2746 printf("Warning: UnregisterComClass() called without any registered class\n"); | |
2747 while (i < com_object_size) | |
2748 { | |
2749 if (found && i > 0) | |
2750 { | |
2751 memcpy(&com_object_table[i - 1].clsid, | |
2752 &com_object_table[i].clsid, sizeof(GUID)); | |
2753 com_object_table[i - 1].GetClassObject = | |
2754 com_object_table[i].GetClassObject; | |
2755 } | |
2756 else if (memcmp(&com_object_table[i].clsid, clsid, sizeof(GUID)) == 0 | |
2757 && com_object_table[i].GetClassObject == gcs) | |
2758 { | |
2759 found++; | |
2760 } | |
2761 i++; | |
2762 } | |
2763 if (found) | |
2764 { | |
2765 if (--com_object_size == 0) | |
2766 { | |
2767 free(com_object_table); | |
2768 com_object_table = 0; | |
2769 } | |
2770 } | |
2771 return 0; | |
2772 } | |
2773 | |
2774 | |
128 | 2775 GUID IID_IUnknown={0x00000000, 0x0000, 0x0000, |
2776 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; | |
2777 GUID IID_IClassFactory={0x00000001, 0x0000, 0x0000, | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2778 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; |
128 | 2779 |
2780 long WINAPI expCoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter, | |
2781 long dwClsContext, GUID* riid, void** ppv) | |
2782 { | |
2783 int i; | |
2784 struct COM_OBJECT_INFO* ci=0; | |
2785 for(i=0; i<com_object_size; i++) | |
2786 if(!memcmp(rclsid, &com_object_table[i].clsid, sizeof(GUID))) | |
2787 ci=&com_object_table[i]; | |
2788 if(!ci)return 0x80040154; | |
2789 // in 'real' world we should mess with IClassFactory here | |
2790 i=ci->GetClassObject(rclsid, riid, ppv); | |
2791 return i; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2792 } |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2793 |
128 | 2794 long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter, |
2795 long dwClsContext, GUID* riid, void** ppv) | |
2796 { | |
2797 return expCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv); | |
2798 } | |
2799 | |
2800 int WINAPI | |
2801 expIsRectEmpty( | |
2802 CONST RECT *lprc) | |
2803 { | |
2804 dbgprintf("IsRectEmpty(0x%x)"); | |
2805 if((!lprc) || (lprc->right==lprc->left) || (lprc->top==lprc->bottom)) | |
2806 { | |
2807 dbgprintf(" => TRUE\n"); | |
2808 return TRUE; | |
2809 } | |
2810 dbgprintf(" => FALSE\n"); | |
2811 return FALSE; | |
2812 } | |
2813 | |
2814 int _adjust_fdiv=0; //what's this? | |
2815 | |
2816 | |
2817 | |
2818 | |
2819 unsigned int WINAPI expGetTempPathA(unsigned int len, char* path) | |
2820 { | |
2821 dbgprintf("GetTempPathA(%d, 0x%x)", len, path); | |
2822 if(len<5) | |
2823 { | |
2824 dbgprintf(" => 0\n"); | |
2825 return 0; | |
2826 } | |
2827 strcpy(path, "/tmp"); | |
2828 dbgprintf(" => 5 ( '/tmp' )\n"); | |
2829 return 5; | |
2830 } | |
2831 /* | |
2832 FYI: | |
2833 typedef struct | |
2834 { | |
2835 DWORD dwFileAttributes; | |
2836 FILETIME ftCreationTime; | |
2837 FILETIME ftLastAccessTime; | |
2838 FILETIME ftLastWriteTime; | |
2839 DWORD nFileSizeHigh; | |
2840 DWORD nFileSizeLow; | |
2841 DWORD dwReserved0; | |
2842 DWORD dwReserved1; | |
2843 CHAR cFileName[260]; | |
2844 CHAR cAlternateFileName[14]; | |
2845 } WIN32_FIND_DATAA, *LPWIN32_FIND_DATAA; | |
2846 */ | |
2847 | |
2848 HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd) | |
2849 { | |
2850 dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => 0\n", s, s, lpfd); | |
2851 strcpy(lpfd->cFileName, "msms001.vwp"); | |
2852 strcpy(lpfd->cAlternateFileName, "msms001.vwp"); | |
2853 return (HANDLE)0; | |
2854 } | |
2855 WIN_BOOL WINAPI expFindNextFileA(HANDLE h,LPWIN32_FIND_DATAA p) | |
2856 { | |
2857 dbgprintf("FindNextFileA(0x%x, 0x%x) => 0\n", h, p); | |
1 | 2858 return 0; |
2859 } | |
128 | 2860 WIN_BOOL WINAPI expFindClose(HANDLE h) |
2861 { | |
2862 dbgprintf("FindClose(0x%x) => 0\n", h); | |
2863 return 0; | |
2864 } | |
2865 UINT WINAPI expSetErrorMode(UINT i) | |
2866 { | |
2867 dbgprintf("SetErrorMode(%d) => 0\n", i); | |
2868 return 0; | |
2869 } | |
2870 UINT WINAPI expGetWindowsDirectoryA(LPSTR s,UINT c) | |
2871 { | |
2872 char windir[]="c:\\windows"; | |
2873 int result; | |
2874 strncpy(s, windir, c); | |
2875 result=1+((c<strlen(windir))?c:strlen(windir)); | |
2876 dbgprintf("GetWindowsDirectoryA(0x%x, %d) => %d\n", s, c, result); | |
2877 return result; | |
2878 } | |
2879 | |
2880 WIN_BOOL WINAPI expDeleteFileA(LPCSTR s) | |
2881 { | |
2882 dbgprintf("DeleteFileA(0x%x='%s') => 0\n", s, s); | |
2883 return 0; | |
2884 } | |
2885 WIN_BOOL WINAPI expFileTimeToLocalFileTime(const FILETIME* cpf, LPFILETIME pf) | |
2886 { | |
2887 dbgprintf("FileTimeToLocalFileTime(0x%x, 0x%x) => 0\n", cpf, pf); | |
2888 return 0; | |
2889 } | |
2890 | |
2891 UINT WINAPI expGetTempFileNameA(LPCSTR cs1,LPCSTR cs2,UINT i,LPSTR ps) | |
2892 { | |
2893 char mask[16]="/tmp/AP_XXXXXX"; | |
2894 int result; | |
2895 dbgprintf("GetTempFileNameA(0x%x='%s', 0x%x='%s', %d, 0x%x)", cs1, cs1, cs2, cs2, i, ps); | |
2896 if(i && i<10) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2897 { |
128 | 2898 dbgprintf(" => -1\n"); |
2899 return -1; | |
2900 } | |
2901 result=mkstemp(mask); | |
2902 sprintf(ps, "AP%d", result); | |
2903 dbgprintf(" => %d\n", strlen(ps)); | |
2904 return strlen(ps); | |
2905 } | |
2906 // | |
2907 // This func might need proper implementation if we want AngelPotion codec. | |
2908 // They try to open APmpeg4v1.apl with it. | |
2909 // DLL will close opened file with CloseHandle(). | |
2910 // | |
2911 HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, | |
2912 LPSECURITY_ATTRIBUTES p1, DWORD i3,DWORD i4,HANDLE i5) | |
2913 { | |
2914 dbgprintf("CreateFileA(0x%x='%s', %d, %d, 0x%x, %d, %d, 0x%x)\n", cs1, cs1, i1, | |
2915 i2, p1, i3, i4, i5); | |
2916 if((!cs1) || (strlen(cs1)<2))return -1; | |
2917 if(strncmp(cs1, "AP", 2)) | |
2918 { | |
2919 int result; | |
2920 char* tmp=(char*)malloc(strlen(def_path)+50); | |
2921 strcpy(tmp, def_path); | |
2922 strcat(tmp, "/"); | |
2923 strcat(tmp, "APmpg4v1.apl"); | |
2924 result=open(tmp, O_RDONLY); | |
2925 free(tmp); | |
2926 return result; | |
2927 }; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2928 return atoi(cs1+2); |
128 | 2929 } |
2930 static char sysdir[]="."; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2931 LPCSTR WINAPI expGetSystemDirectoryA() |
128 | 2932 { |
2933 dbgprintf("GetSystemDirectoryA() => 0x%x='%s'\n", sysdir, sysdir); | |
2934 return sysdir; | |
2935 } | |
2936 WIN_BOOL WINAPI expReadFile(HANDLE h,LPVOID pv,DWORD size,LPDWORD rd,LPOVERLAPPED unused) | |
2937 { | |
2938 int result; | |
2939 dbgprintf("ReadFile(%d, 0x%x, %d -> 0x%x)\n", h, pv, size, rd); | |
2940 result=read(h, pv, size); | |
2941 if(rd)*rd=result; | |
2942 if(!result)return 0; | |
2943 return 1; | |
2944 } | |
2945 | |
2946 WIN_BOOL WINAPI expWriteFile(HANDLE h,LPCVOID pv,DWORD size,LPDWORD wr,LPOVERLAPPED unused) | |
2947 { | |
2948 int result; | |
2949 dbgprintf("WriteFile(%d, 0x%x, %d -> 0x%x)\n", h, pv, size, wr); | |
2950 if(h==1234)h=1; | |
2951 result=write(h, pv, size); | |
2952 if(wr)*wr=result; | |
2953 if(!result)return 0; | |
2954 return 1; | |
2955 } | |
2956 DWORD WINAPI expSetFilePointer(HANDLE h, LONG val, LPLONG ext, DWORD whence) | |
2957 { | |
2958 int wh; | |
2959 dbgprintf("SetFilePointer(%d, %d, 0x%x, %d)\n", h, val, ext, whence); | |
2960 //why would DLL want temporary file with >2Gb size? | |
2961 switch(whence) | |
2962 { | |
2963 case FILE_BEGIN: | |
2964 wh=SEEK_SET;break; | |
2965 case FILE_END: | |
2966 wh=SEEK_END;break; | |
2967 case FILE_CURRENT: | |
2968 wh=SEEK_CUR;break; | |
2969 default: | |
2970 return -1; | |
2971 } | |
2972 return lseek(h, val, wh); | |
2973 } | |
2974 | |
2975 HDRVR WINAPI expOpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName, | |
2976 LPARAM lParam2) | |
2977 { | |
2978 dbgprintf("OpenDriverA(0x%x='%s', 0x%x='%s', 0x%x) => -1\n", szDriverName, szDriverName, szSectionName, szSectionName, lParam2); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2979 return -1; |
128 | 2980 } |
2981 HDRVR WINAPI expOpenDriver(LPCSTR szDriverName, LPCSTR szSectionName, | |
2982 LPARAM lParam2) | |
2983 { | |
2984 dbgprintf("OpenDriver(0x%x='%s', 0x%x='%s', 0x%x) => -1\n", szDriverName, szDriverName, szSectionName, szSectionName, lParam2); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
2985 return -1; |
128 | 2986 } |
1 | 2987 |
2988 | |
128 | 2989 WIN_BOOL |
2990 WINAPI | |
2991 expGetProcessAffinityMask( | |
2992 HANDLE hProcess, | |
2993 LPDWORD lpProcessAffinityMask, | |
2994 LPDWORD lpSystemAffinityMask | |
2995 ) | |
2996 { | |
2997 dbgprintf("GetProcessAffinityMask(0x%x, 0x%x, 0x%x) => 1\n", | |
2998 hProcess, lpProcessAffinityMask, lpSystemAffinityMask); | |
2999 if(lpProcessAffinityMask)*lpProcessAffinityMask=1; | |
3000 if(lpSystemAffinityMask)*lpSystemAffinityMask=1; | |
3001 return 1; | |
1 | 3002 } |
3003 | |
713 | 3004 int WINAPI expMulDiv(int nNumber, int nNumerator, int nDenominator) |
3005 { | |
3006 static const long long max_int=0x7FFFFFFFLL; | |
3007 static const long long min_int=-0x80000000LL; | |
3008 long long tmp=(long long)nNumber*(long long)nNumerator; | |
3009 if(!nDenominator)return 1; | |
3010 tmp/=nDenominator; | |
3011 if(tmp<min_int) return 1; | |
3012 if(tmp>max_int) return 1; | |
3013 return (int)tmp; | |
3014 } | |
3015 | |
3016 LONG WINAPI explstrcmpiA(const char* str1, const char* str2) | |
3017 { | |
3018 LONG result=strcasecmp(str1, str2); | |
3019 dbgprintf("strcmpi(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); | |
3020 return result; | |
3021 } | |
3022 | |
3023 LONG WINAPI explstrlenA(const char* str1) | |
3024 { | |
3025 LONG result=strlen(str1); | |
3026 dbgprintf("strlen(0x%x='%s') => %d\n", str1, str1, result); | |
3027 return result; | |
3028 } | |
3029 | |
3030 LONG WINAPI explstrcpyA(char* str1, const char* str2) | |
3031 { | |
3032 int result= (int) strcpy(str1, str2); | |
3033 dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result); | |
3034 return result; | |
3035 } | |
2069 | 3036 LONG WINAPI explstrcpynA(char* str1, const char* str2,int len) |
3037 { | |
3038 int result; | |
3039 if (strlen(str2)>len) | |
3040 result = (int) strncpy(str1, str2,len); | |
3041 else | |
3042 result = (int) strcpy(str1,str2); | |
3043 dbgprintf("strncpy(0x%x, 0x%x='%s' len %d strlen %d) => %x\n", str1, str2, str2,len, strlen(str2),result); | |
3044 return result; | |
3045 } | |
3046 LONG WINAPI explstrcatA(char* str1, const char* str2) | |
3047 { | |
3048 int result= (int) strcat(str1, str2); | |
3049 dbgprintf("strcat(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result); | |
3050 return result; | |
3051 } | |
3052 | |
128 | 3053 |
497 | 3054 LONG WINAPI expInterlockedExchange(long *dest, long l) |
3055 { | |
3056 long retval; | |
3057 retval = *dest; | |
3058 *dest = l; | |
3059 return retval; | |
3060 } | |
3061 | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3062 void WINAPI expInitCommonControls(void) |
1543 | 3063 { |
2069 | 3064 printf("InitCommonControls called!\n"); |
3065 return; | |
1543 | 3066 } |
3067 | |
2396 | 3068 HRESULT WINAPI expCoCreateFreeThreadedMarshaler(void *pUnkOuter, void **ppUnkInner) |
3069 { | |
3070 printf("CoCreateFreeThreadedMarshaler(%p, %p) called!\n", | |
3071 pUnkOuter, ppUnkInner); | |
3072 return E_FAIL; | |
3073 // return S_OK; | |
3074 } | |
3075 | |
2779 | 3076 |
3077 int WINAPI expDuplicateHandle( | |
3078 HANDLE hSourceProcessHandle, // handle to source process | |
3079 HANDLE hSourceHandle, // handle to duplicate | |
3080 HANDLE hTargetProcessHandle, // handle to target process | |
3081 HANDLE* lpTargetHandle, // duplicate handle | |
3082 DWORD dwDesiredAccess, // requested access | |
3083 int bInheritHandle, // handle inheritance option | |
3084 DWORD dwOptions // optional actions | |
3085 ) | |
3086 { | |
3087 dbgprintf("DuplicateHandle(%p, %p, %p, %p, 0x%x, %d, %d) called\n", | |
3088 hSourceProcessHandle, hSourceHandle, hTargetProcessHandle, | |
3089 lpTargetHandle, dwDesiredAccess, bInheritHandle, dwOptions); | |
3090 *lpTargetHandle = hSourceHandle; | |
3091 return 1; | |
3092 } | |
3093 | |
3094 | |
1 | 3095 struct exports |
3096 { | |
3097 char name[64]; | |
3098 int id; | |
3099 void* func; | |
3100 }; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3101 struct libs |
1 | 3102 { |
3103 char name[64]; | |
3104 int length; | |
3105 struct exports* exps; | |
3106 }; | |
3107 | |
3108 #define FF(X,Y) \ | |
3109 {#X, Y, (void*)exp##X}, | |
3110 | |
3111 struct exports exp_kernel32[]={ | |
3112 FF(IsBadWritePtr, 357) | |
3113 FF(IsBadReadPtr, 354) | |
3114 FF(IsBadStringPtrW, -1) | |
3115 FF(DisableThreadLibraryCalls, -1) | |
3116 FF(CreateThread, -1) | |
3117 FF(CreateEventA, -1) | |
3118 FF(SetEvent, -1) | |
3119 FF(ResetEvent, -1) | |
3120 FF(WaitForSingleObject, -1) | |
3121 FF(GetSystemInfo, -1) | |
3122 FF(GetVersion, 332) | |
3123 FF(HeapCreate, 461) | |
3124 FF(HeapAlloc, -1) | |
3125 FF(HeapDestroy, -1) | |
3126 FF(HeapFree, -1) | |
3127 FF(HeapSize, -1) | |
2069 | 3128 FF(HeapReAlloc,-1) |
1 | 3129 FF(GetProcessHeap, -1) |
3130 FF(VirtualAlloc, -1) | |
3131 FF(VirtualFree, -1) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3132 FF(InitializeCriticalSection, -1) |
1 | 3133 FF(EnterCriticalSection, -1) |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3134 FF(LeaveCriticalSection, -1) |
1 | 3135 FF(DeleteCriticalSection, -1) |
3136 FF(TlsAlloc, -1) | |
3137 FF(TlsFree, -1) | |
3138 FF(TlsGetValue, -1) | |
3139 FF(TlsSetValue, -1) | |
3140 FF(GetCurrentThreadId, -1) | |
128 | 3141 FF(GetCurrentProcess, -1) |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3142 FF(LocalAlloc, -1) |
2069 | 3143 FF(LocalReAlloc,-1) |
1 | 3144 FF(LocalLock, -1) |
3145 FF(GlobalAlloc, -1) | |
128 | 3146 FF(GlobalReAlloc, -1) |
1 | 3147 FF(GlobalLock, -1) |
3148 FF(MultiByteToWideChar, 427) | |
3149 FF(WideCharToMultiByte, -1) | |
3150 FF(GetVersionExA, -1) | |
3151 FF(CreateSemaphoreA, -1) | |
3152 FF(QueryPerformanceCounter, -1) | |
3153 FF(QueryPerformanceFrequency, -1) | |
3154 FF(LocalHandle, -1) | |
3155 FF(LocalUnlock, -1) | |
3156 FF(LocalFree, -1) | |
3157 FF(GlobalHandle, -1) | |
3158 FF(GlobalUnlock, -1) | |
3159 FF(GlobalFree, -1) | |
3160 FF(LoadResource, -1) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3161 FF(ReleaseSemaphore, -1) |
1 | 3162 FF(FindResourceA, -1) |
3163 FF(LockResource, -1) | |
3164 FF(FreeResource, -1) | |
3165 FF(SizeofResource, -1) | |
3166 FF(CloseHandle, -1) | |
3167 FF(GetCommandLineA, -1) | |
3168 FF(GetEnvironmentStringsW, -1) | |
3169 FF(FreeEnvironmentStringsW, -1) | |
128 | 3170 FF(FreeEnvironmentStringsA, -1) |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3171 FF(GetEnvironmentStrings, -1) |
1 | 3172 FF(GetStartupInfoA, -1) |
3173 FF(GetStdHandle, -1) | |
3174 FF(GetFileType, -1) | |
3175 FF(SetHandleCount, -1) | |
3176 FF(GetACP, -1) | |
3177 FF(GetModuleFileNameA, -1) | |
3178 FF(SetUnhandledExceptionFilter, -1) | |
3179 FF(LoadLibraryA, -1) | |
3180 FF(GetProcAddress, -1) | |
3181 FF(FreeLibrary, -1) | |
3182 FF(CreateFileMappingA, -1) | |
3183 FF(OpenFileMappingA, -1) | |
3184 FF(MapViewOfFile, -1) | |
3185 FF(UnmapViewOfFile, -1) | |
3186 FF(Sleep, -1) | |
3187 FF(GetModuleHandleA, -1) | |
128 | 3188 FF(GetProfileIntA, -1) |
1 | 3189 FF(GetPrivateProfileIntA, -1) |
3190 FF(GetPrivateProfileStringA, -1) | |
3191 FF(WritePrivateProfileStringA, -1) | |
3192 FF(GetLastError, -1) | |
3193 FF(SetLastError, -1) | |
3194 FF(InterlockedIncrement, -1) | |
3195 FF(InterlockedDecrement, -1) | |
3196 FF(GetTimeZoneInformation, -1) | |
3197 FF(OutputDebugStringA, -1) | |
3198 FF(GetLocalTime, -1) | |
3199 FF(GetSystemTime, -1) | |
3200 FF(GetEnvironmentVariableA, -1) | |
121 | 3201 FF(RtlZeroMemory,-1) |
3202 FF(RtlMoveMemory,-1) | |
3203 FF(RtlFillMemory,-1) | |
128 | 3204 FF(GetTempPathA,-1) |
3205 FF(FindFirstFileA,-1) | |
3206 FF(FindNextFileA,-1) | |
3207 FF(FindClose,-1) | |
3208 FF(FileTimeToLocalFileTime,-1) | |
3209 FF(DeleteFileA,-1) | |
3210 FF(ReadFile,-1) | |
3211 FF(WriteFile,-1) | |
3212 FF(SetFilePointer,-1) | |
3213 FF(GetTempFileNameA,-1) | |
3214 FF(CreateFileA,-1) | |
3215 FF(GetSystemDirectoryA,-1) | |
3216 FF(GetWindowsDirectoryA,-1) | |
3217 FF(SetErrorMode, -1) | |
3218 FF(IsProcessorFeaturePresent, -1) | |
3219 FF(GetProcessAffinityMask, -1) | |
497 | 3220 FF(InterlockedExchange, -1) |
3221 FF(MulDiv, -1) | |
713 | 3222 FF(lstrcmpiA, -1) |
3223 FF(lstrlenA, -1) | |
3224 FF(lstrcpyA, -1) | |
2069 | 3225 FF(lstrcatA, -1) |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3226 FF(lstrcpynA,-1) |
2069 | 3227 FF(GetProcessVersion,-1) |
3228 FF(GetCurrentThread,-1) | |
3229 FF(GetOEMCP,-1) | |
3230 FF(GetCPInfo,-1) | |
2779 | 3231 FF(DuplicateHandle,-1) |
1 | 3232 }; |
3233 | |
3234 struct exports exp_msvcrt[]={ | |
3235 FF(malloc, -1) | |
3236 FF(_initterm, -1) | |
3237 FF(free, -1) | |
3238 {"??3@YAXPAX@Z", -1, expdelete}, | |
3239 {"??2@YAPAXI@Z", -1, expnew}, | |
128 | 3240 {"_adjust_fdiv", -1, (void*)&_adjust_fdiv}, |
1 | 3241 FF(strrchr, -1) |
3242 FF(strchr, -1) | |
128 | 3243 FF(strlen, -1) |
3244 FF(strcpy, -1) | |
3245 FF(strcmp, -1) | |
2668 | 3246 FF(strncmp, -1) |
128 | 3247 FF(strcat, -1) |
713 | 3248 FF(isalnum, -1) |
128 | 3249 FF(memmove, -1) |
3250 FF(memcmp, -1) | |
3251 FF(time, -1) | |
2139 | 3252 FF(_ftol,-1) |
3253 FF(rand, -1) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3254 FF(log10, -1) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3255 FF(pow, -1) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3256 FF(cos, -1) |
2139 | 3257 FF(srand, -1) |
3258 FF(sprintf,-1) | |
3259 FF(sscanf,-1) | |
3260 FF(fopen,-1) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3261 FF(fprintf,-1) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3262 FF(printf,-1) |
1 | 3263 }; |
3264 struct exports exp_winmm[]={ | |
3265 FF(GetDriverModuleHandle, -1) | |
3266 FF(timeGetTime, -1) | |
3267 FF(DefDriverProc, -1) | |
128 | 3268 FF(OpenDriverA, -1) |
1 | 3269 FF(OpenDriver, -1) |
3270 }; | |
3271 struct exports exp_user32[]={ | |
3272 FF(LoadStringA, -1) | |
3273 FF(wsprintfA, -1) | |
3274 FF(GetDC, -1) | |
3275 FF(GetDesktopWindow, -1) | |
3276 FF(ReleaseDC, -1) | |
128 | 3277 FF(IsRectEmpty, -1) |
3278 FF(LoadCursorA,-1) | |
3279 FF(SetCursor,-1) | |
2069 | 3280 FF(GetCursorPos,-1) |
3281 FF(GetCursorPos,-1) | |
3282 FF(RegisterWindowMessageA,-1) | |
3283 FF(GetSystemMetrics,-1) | |
3284 FF(GetSysColor,-1) | |
3285 FF(GetSysColorBrush,-1) | |
1 | 3286 }; |
3287 struct exports exp_advapi32[]={ | |
3288 FF(RegOpenKeyA, -1) | |
3289 FF(RegOpenKeyExA, -1) | |
3290 FF(RegCreateKeyExA, -1) | |
3291 FF(RegQueryValueExA, -1) | |
3292 FF(RegSetValueExA, -1) | |
3293 FF(RegCloseKey, -1) | |
2069 | 3294 FF(RegEnumValueA, -1) |
1 | 3295 }; |
3296 struct exports exp_gdi32[]={ | |
3297 FF(CreateCompatibleDC, -1) | |
3298 FF(GetDeviceCaps, -1) | |
3299 FF(DeleteDC, -1) | |
3300 FF(GetSystemPaletteEntries, -1) | |
3301 }; | |
3302 struct exports exp_version[]={ | |
3303 FF(GetFileVersionInfoSizeA, -1) | |
3304 }; | |
128 | 3305 struct exports exp_ole32[]={ |
3306 FF(CoTaskMemAlloc, -1) | |
3307 FF(CoTaskMemFree, -1) | |
3308 FF(CoCreateInstance, -1) | |
3309 FF(StringFromGUID2, -1) | |
2396 | 3310 FF(CoCreateFreeThreadedMarshaler,-1) |
128 | 3311 }; |
130 | 3312 struct exports exp_crtdll[]={ |
3313 FF(memcpy, -1) | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3314 FF(wcscpy, -1) |
130 | 3315 }; |
2069 | 3316 struct exports exp_comctl32[]={ |
3317 FF(StringFromGUID2, -1) | |
3318 FF(InitCommonControls, 17) | |
3319 }; | |
1 | 3320 #define LL(X) \ |
3321 {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X}, | |
3322 | |
3323 struct libs libraries[]={ | |
3324 LL(kernel32) | |
3325 LL(msvcrt) | |
3326 LL(winmm) | |
3327 LL(user32) | |
3328 LL(advapi32) | |
3329 LL(gdi32) | |
3330 LL(version) | |
128 | 3331 LL(ole32) |
130 | 3332 LL(crtdll) |
2069 | 3333 LL(comctl32) |
1 | 3334 }; |
3335 | |
2069 | 3336 |
1 | 3337 void* LookupExternal(const char* library, int ordinal) |
3338 { | |
3339 char* answ; | |
3340 int i,j; | |
3341 if(library==0) | |
3342 { | |
3343 printf("ERROR: library=0\n"); | |
3344 return (void*)ext_unknown; | |
3345 } | |
3346 // printf("%x %x\n", &unk_exp1, &unk_exp2); | |
3347 | |
3348 for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++) | |
3349 { | |
3350 if(strcasecmp(library, libraries[i].name)) | |
3351 continue; | |
3352 for(j=0; j<libraries[i].length; j++) | |
3353 { | |
3354 if(ordinal!=libraries[i].exps[j].id) | |
3355 continue; | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3356 //printf("Hit: 0x%p\n", libraries[i].exps[j].func); |
1 | 3357 return libraries[i].exps[j].func; |
3358 } | |
3359 } | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3360 printf("External func %s:%d\n", library, ordinal); |
1 | 3361 if(pos>150)return 0; |
3362 answ=(char*)extcode+pos*0x64; | |
3363 memcpy(answ, &unk_exp1, 0x64); | |
3364 *(int*)(answ+9)=pos; | |
3365 *(int*)(answ+47)-=((int)answ-(int)&unk_exp1); | |
3366 sprintf(export_names[pos], "%s:%d", library, ordinal); | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3367 pos++; |
1 | 3368 return (void*)answ; |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3369 } |
1 | 3370 |
3371 void* LookupExternalByName(const char* library, const char* name) | |
3372 { | |
3373 char* answ; | |
3374 int i,j; | |
3375 // return (void*)ext_unknown; | |
3376 if(library==0) | |
3377 { | |
3378 printf("ERROR: library=0\n"); | |
3379 return (void*)ext_unknown; | |
3380 } | |
3381 if(name==0) | |
3382 { | |
3383 printf("ERROR: name=0\n"); | |
3384 return (void*)ext_unknown; | |
3385 } | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3386 //printf("External func %s:%s\n", library, name); |
1 | 3387 for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++) |
3388 { | |
3389 if(strcasecmp(library, libraries[i].name)) | |
3390 continue; | |
3391 for(j=0; j<libraries[i].length; j++) | |
3392 { | |
3393 if(strcmp(name, libraries[i].exps[j].name)) | |
3394 continue; | |
3395 // printf("Hit: 0x%08X\n", libraries[i].exps[j].func); | |
3396 return libraries[i].exps[j].func; | |
3397 } | |
3398 } | |
128 | 3399 // printf("%s %s\n", library, name); |
3400 if(pos>150)return 0; | |
1 | 3401 strcpy(export_names[pos], name); |
3402 answ=(char*)extcode+pos*0x64; | |
3403 memcpy(answ, &unk_exp1, 0x64); | |
3404 *(int*)(answ+9)=pos; | |
3405 *(int*)(answ+47)-=((int)answ-(int)&unk_exp1); | |
3406 pos++; | |
3407 return (void*)answ; | |
3408 // memcpy(extcode, &unk_exp1, 0x64); | |
3409 // *(int*)(extcode+52)-=((int)extcode-(int)&unk_exp1); | |
3410 // return (void*)extcode; | |
3411 // printf("Unknown func %s:%s\n", library, name); | |
3412 // return (void*)ext_unknown; | |
3413 } | |
3414 | |
2069 | 3415 void my_garbagecollection(void) |
128 | 3416 { |
3417 #ifdef GARBAGE | |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3418 int unfree = 0, unfreecnt = 0; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3419 |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3420 while (last_alloc) |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3421 { |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3422 alloc_header* mem = last_alloc + 1; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3423 unfree += my_size(mem); |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3424 unfreecnt++; |
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3425 my_release(mem); |
128 | 3426 } |
2651
958d10763c34
partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents:
2579
diff
changeset
|
3427 printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree, unfreecnt, last_alloc, alccnt); |
128 | 3428 #endif |
3429 } |