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