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