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