Mercurial > mplayer.hg
annotate loader/ext.c @ 1925:633a7f0d72a4
add gui error handling jol.
author | pontscho |
---|---|
date | Thu, 20 Sep 2001 10:27:24 +0000 |
parents | d8c1b0b38edc |
children | ce45cce7f7a5 |
rev | line source |
---|---|
1 | 1 /******************************************************** |
2 * | |
3 * | |
4 * Stub functions for Wine module | |
5 * | |
6 * | |
7 ********************************************************/ | |
8 #include <config.h> | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
9 #include <stdio.h> |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
10 #include <stdlib.h> |
1 | 11 #ifdef HAVE_MALLOC_H |
12 #include <malloc.h> | |
13 #endif | |
14 #include <unistd.h> | |
15 #include <sys/mman.h> | |
16 #include <errno.h> | |
17 #include <fcntl.h> | |
18 #include <string.h> | |
19 #include <stdarg.h> | |
20 #include <wine/windef.h> | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
21 #include <wine/winbase.h> |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
22 #include <wine/debugtools.h> |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
23 #include <wine/heap.h> |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
24 #include "ext.h" |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
25 |
1 | 26 int dbg_header_err( const char *dbg_channel, const char *func ) |
27 { | |
28 return 0; | |
29 } | |
30 int dbg_header_warn( const char *dbg_channel, const char *func ) | |
31 { | |
32 return 0; | |
33 } | |
34 int dbg_header_fixme( const char *dbg_channel, const char *func ) | |
35 { | |
36 return 0; | |
37 } | |
38 int dbg_header_trace( const char *dbg_channel, const char *func ) | |
39 { | |
40 return 0; | |
41 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
42 int dbg_vprintf( const char *format, va_list args ) |
1 | 43 { |
44 return 0; | |
45 } | |
46 int __vprintf( const char *format, ... ) | |
47 { | |
48 #ifdef DETAILED_OUT | |
49 va_list va; | |
50 va_start(va, format); | |
51 vprintf(format, va); | |
52 va_end(va); | |
53 #endif | |
54 return 0; | |
55 } | |
56 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
57 HANDLE WINAPI GetProcessHeap(void) |
1 | 58 { |
59 return 1; | |
60 } | |
61 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
62 LPVOID WINAPI HeapAlloc(HANDLE heap, DWORD flags, DWORD size) |
1 | 63 { |
64 if(flags & 0x8) | |
65 return calloc(size, 1); | |
66 else | |
67 return malloc(size); | |
68 } | |
69 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
70 WIN_BOOL WINAPI HeapFree(HANDLE heap, DWORD flags,LPVOID mem) |
1 | 71 { |
128 | 72 if (mem) free(mem); |
1 | 73 return 1; |
74 } | |
75 | |
76 static int last_error; | |
77 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
78 DWORD WINAPI GetLastError(void) |
1 | 79 { |
80 return last_error; | |
81 } | |
82 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
83 VOID WINAPI SetLastError(DWORD error) |
1 | 84 { |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
85 last_error = error; |
1 | 86 } |
87 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
88 WIN_BOOL WINAPI ReadFile(HANDLE handle,LPVOID mem, DWORD size, LPDWORD result, LPOVERLAPPED flags) |
1 | 89 { |
90 *result=read(handle, mem, size); | |
91 return *result; | |
92 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
93 int WINAPI lstrcmpiA(const char* c1, const char* c2) |
1 | 94 { |
95 return strcasecmp(c1,c2); | |
96 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
97 LPSTR WINAPI lstrcpynA(LPSTR dest, LPCSTR src, INT num) |
1 | 98 { |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
99 return strncpy(dest,src,num); |
1 | 100 } |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
101 int WINAPI lstrlenA(const char* s) |
1 | 102 { |
103 return strlen(s); | |
104 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
105 INT WINAPI lstrlenW(LPCWSTR s) |
1 | 106 { |
107 int l; | |
108 if(!s) | |
109 return 0; | |
110 l=0; | |
111 while(s[l]) | |
112 l++; | |
113 return l; | |
114 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
115 LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count) |
1 | 116 { |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
117 LPSTR rval = dest; |
1 | 118 int moved=0; |
119 if((dest==0) || (src==0)) | |
120 return 0; | |
121 while(moved<count) | |
122 { | |
123 *dest=*src; | |
124 moved++; | |
125 if(*src==0) | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
126 break; |
1 | 127 src++; |
128 dest++; | |
129 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
130 return rval; |
1 | 131 } |
132 int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n) | |
133 { | |
134 if(s1==0) | |
135 return; | |
136 if(s2==0) | |
137 return; | |
138 while(n>0) | |
139 { | |
140 if(*s1<*s2) | |
141 return -1; | |
142 else | |
143 if(*s1>*s2) | |
144 return 1; | |
145 else | |
146 if(*s1==0) | |
147 return 0; | |
148 s1++; | |
149 s2++; | |
150 n--; | |
151 } | |
152 return 0; | |
153 } | |
154 | |
155 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
156 WIN_BOOL WINAPI IsBadReadPtr(LPCVOID data, UINT size) |
1 | 157 { |
158 if(size==0) | |
159 return 0; | |
160 if(data==NULL) | |
161 return 1; | |
162 return 0; | |
163 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
164 LPSTR HEAP_strdupA(HANDLE heap, DWORD flags, LPCSTR string) |
1 | 165 { |
166 // return strdup(string); | |
167 char* answ=malloc(strlen(string)+1); | |
168 strcpy(answ, string); | |
169 return answ; | |
170 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
171 LPWSTR HEAP_strdupAtoW(HANDLE heap, DWORD flags, LPCSTR string) |
1 | 172 { |
173 int size, i; | |
174 short* answer; | |
175 if(string==0) | |
176 return 0; | |
177 size=strlen(string); | |
178 answer=malloc(size+size+2); | |
179 for(i=0; i<=size; i++) | |
180 answer[i]=(short)string[i]; | |
181 return answer; | |
182 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
183 LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string) |
1 | 184 { |
185 int size, i; | |
186 char* answer; | |
187 if(string==0) | |
188 return 0; | |
189 size=0; | |
190 while(string[size]) | |
191 size++; | |
192 answer=malloc(size+2); | |
193 for(i=0; i<=size; i++) | |
194 answer[i]=(char)string[i]; | |
195 return answer; | |
196 } | |
197 | |
198 /*********************************************************************** | |
199 * FILE_dommap | |
200 */ | |
201 | |
202 //#define MAP_PRIVATE | |
203 //#define MAP_SHARED | |
204 #undef MAP_ANON | |
205 LPVOID FILE_dommap( int unix_handle, LPVOID start, | |
206 DWORD size_high, DWORD size_low, | |
207 DWORD offset_high, DWORD offset_low, | |
208 int prot, int flags ) | |
209 { | |
210 int fd = -1; | |
211 int pos; | |
212 LPVOID ret; | |
213 | |
214 if (size_high || offset_high) | |
215 printf("offsets larger than 4Gb not supported\n"); | |
216 | |
217 if (unix_handle == -1) | |
218 { | |
219 #ifdef MAP_ANON | |
220 // printf("Anonymous\n"); | |
221 flags |= MAP_ANON; | |
222 #else | |
223 static int fdzero = -1; | |
224 | |
225 if (fdzero == -1) | |
226 { | |
227 if ((fdzero = open( "/dev/zero", O_RDONLY )) == -1) | |
228 { | |
229 perror( "/dev/zero: open" ); | |
230 exit(1); | |
231 } | |
232 } | |
233 fd = fdzero; | |
234 #endif /* MAP_ANON */ | |
235 /* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */ | |
236 #ifdef MAP_SHARED | |
237 flags &= ~MAP_SHARED; | |
238 #endif | |
239 #ifdef MAP_PRIVATE | |
240 flags |= MAP_PRIVATE; | |
241 #endif | |
242 } | |
243 else fd = unix_handle; | |
244 // printf("fd %x, start %x, size %x, pos %x, prot %x\n",fd,start,size_low, offset_low, prot); | |
245 // if ((ret = mmap( start, size_low, prot, | |
246 // flags, fd, offset_low )) != (LPVOID)-1) | |
247 if ((ret = mmap( start, size_low, prot, | |
248 MAP_PRIVATE | MAP_FIXED, fd, offset_low )) != (LPVOID)-1) | |
249 { | |
250 // printf("address %08x\n", *(int*)ret); | |
251 // printf("%x\n", ret); | |
252 return ret; | |
253 } | |
254 | |
255 // printf("mmap %d\n", errno); | |
256 | |
257 /* mmap() failed; if this is because the file offset is not */ | |
258 /* page-aligned (EINVAL), or because the underlying filesystem */ | |
259 /* does not support mmap() (ENOEXEC), we do it by hand. */ | |
260 | |
261 if (unix_handle == -1) return ret; | |
262 if ((errno != ENOEXEC) && (errno != EINVAL)) return ret; | |
263 if (prot & PROT_WRITE) | |
264 { | |
265 /* We cannot fake shared write mappings */ | |
266 #ifdef MAP_SHARED | |
267 if (flags & MAP_SHARED) return ret; | |
268 #endif | |
269 #ifdef MAP_PRIVATE | |
270 if (!(flags & MAP_PRIVATE)) return ret; | |
271 #endif | |
272 } | |
273 /* printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/ | |
274 /* Reserve the memory with an anonymous mmap */ | |
275 ret = FILE_dommap( -1, start, size_high, size_low, 0, 0, | |
276 PROT_READ | PROT_WRITE, flags ); | |
277 if (ret == (LPVOID)-1) | |
278 // { | |
279 // perror( | |
280 return ret; | |
281 /* Now read in the file */ | |
282 if ((pos = lseek( fd, offset_low, SEEK_SET )) == -1) | |
283 { | |
284 FILE_munmap( ret, size_high, size_low ); | |
285 // printf("lseek\n"); | |
286 return (LPVOID)-1; | |
287 } | |
288 read( fd, ret, size_low ); | |
289 lseek( fd, pos, SEEK_SET ); /* Restore the file pointer */ | |
290 mprotect( ret, size_low, prot ); /* Set the right protection */ | |
291 // printf("address %08x\n", *(int*)ret); | |
292 return ret; | |
293 } | |
294 | |
295 | |
296 /*********************************************************************** | |
297 * FILE_munmap | |
298 */ | |
299 int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low ) | |
300 { | |
301 if (size_high) | |
302 printf("offsets larger than 4Gb not supported\n"); | |
303 return munmap( start, size_low ); | |
304 } | |
305 static int mapping_size=0; | |
306 | |
307 struct file_mapping_s; | |
308 typedef struct file_mapping_s | |
309 { | |
310 int mapping_size; | |
311 char* name; | |
312 HANDLE handle; | |
313 struct file_mapping_s* next; | |
314 struct file_mapping_s* prev; | |
315 }file_mapping; | |
316 static file_mapping* fm=0; | |
317 | |
318 | |
319 | |
320 #define PAGE_NOACCESS 0x01 | |
321 #define PAGE_READONLY 0x02 | |
322 #define PAGE_READWRITE 0x04 | |
323 #define PAGE_WRITECOPY 0x08 | |
324 #define PAGE_EXECUTE 0x10 | |
325 #define PAGE_EXECUTE_READ 0x20 | |
326 #define PAGE_EXECUTE_READWRITE 0x40 | |
327 #define PAGE_EXECUTE_WRITECOPY 0x80 | |
328 #define PAGE_GUARD 0x100 | |
329 #define PAGE_NOCACHE 0x200 | |
330 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
331 HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
332 DWORD flProtect, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
333 DWORD dwMaxHigh, DWORD dwMaxLow, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
334 LPCSTR name) |
1 | 335 { |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
336 int hFile = (int)handle; |
1 | 337 unsigned int len; |
338 HANDLE answer; | |
339 int anon=0; | |
340 int mmap_access=0; | |
341 if(hFile<0) | |
342 { | |
343 anon=1; | |
344 hFile=open("/dev/zero", O_RDWR); | |
345 if(hFile<0) | |
346 return 0; | |
347 } | |
348 if(!anon) | |
349 { | |
350 len=lseek(hFile, 0, SEEK_END); | |
351 lseek(hFile, 0, SEEK_SET); | |
352 } | |
353 else len=dwMaxLow; | |
354 | |
355 if(flProtect & PAGE_READONLY) | |
356 mmap_access |=PROT_READ; | |
357 else | |
358 mmap_access |=PROT_READ|PROT_WRITE; | |
359 | |
360 answer=(HANDLE)mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0); | |
361 if(anon) | |
362 close(hFile); | |
363 if(answer!=(HANDLE)-1) | |
364 { | |
365 if(fm==0) | |
366 { | |
367 fm=malloc(sizeof(file_mapping)); | |
368 fm->prev=NULL; | |
369 } | |
370 else | |
371 { | |
372 fm->next=malloc(sizeof(file_mapping)); | |
373 fm->next->prev=fm; | |
374 fm=fm->next; | |
375 } | |
376 fm->next=NULL; | |
377 fm->handle=answer; | |
378 if(name) | |
379 { | |
380 fm->name=malloc(strlen(name)+1); | |
381 strcpy(fm->name, name); | |
382 } | |
383 else | |
384 fm->name=NULL; | |
385 fm->mapping_size=len; | |
386 | |
387 if(anon) | |
388 close(hFile); | |
389 return answer; | |
390 } | |
391 return (HANDLE)0; | |
392 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
393 WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle) |
1 | 394 { |
395 file_mapping* p; | |
396 int result; | |
397 if(fm==0) | |
398 return (HANDLE)0; | |
399 for(p=fm; p; p=p->next) | |
400 { | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
401 if(p->handle==(HANDLE)handle) |
1 | 402 { |
403 result=munmap((void*)handle, p->mapping_size); | |
404 if(p->next)p->next->prev=p->prev; | |
405 if(p->prev)p->prev->next=p->next; | |
406 if(p->name) | |
407 free(p->name); | |
408 if(p==fm) | |
409 fm=p->prev; | |
410 free(p); | |
411 return result; | |
412 } | |
413 } | |
414 return 0; | |
415 } | |
416 //static int va_size=0; | |
417 struct virt_alloc_s; | |
418 typedef struct virt_alloc_s | |
419 { | |
420 int mapping_size; | |
421 char* address; | |
422 struct virt_alloc_s* next; | |
423 struct virt_alloc_s* prev; | |
424 int state; | |
425 }virt_alloc; | |
426 static virt_alloc* vm=0; | |
427 #define MEM_COMMIT 0x00001000 | |
428 #define MEM_RESERVE 0x00002000 | |
429 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
430 void* WINAPI VirtualAlloc(void* address, DWORD size, DWORD type, DWORD protection) |
1 | 431 { |
432 void* answer; | |
433 int fd=open("/dev/zero", O_RDWR); | |
434 size=(size+0xffff)&(~0xffff); | |
435 // printf("VirtualAlloc(0x%08X, %d)\n", address | |
436 if(address!=0) | |
437 { | |
438 //check whether we can allow to allocate this | |
439 virt_alloc* str=vm; | |
440 while(str) | |
441 { | |
442 if((unsigned)address>=(unsigned)str->address+str->mapping_size) | |
443 { | |
444 str=str->prev; | |
445 continue; | |
446 } | |
447 if((unsigned)address+size<(unsigned)str->address) | |
448 { | |
449 str=str->prev; | |
450 continue; | |
451 } | |
452 if(str->state==0) | |
453 { | |
454 #warning FIXME | |
455 if(((unsigned)address+size<(unsigned)str->address+str->mapping_size) && (type & MEM_COMMIT)) | |
456 { | |
457 close(fd); | |
458 return address; //returning previously reserved memory | |
459 } | |
460 return NULL; | |
461 } | |
462 close(fd); | |
463 return NULL; | |
464 } | |
465 answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, | |
466 MAP_FIXED | MAP_PRIVATE, fd, 0); | |
467 } | |
468 else | |
469 answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, | |
470 MAP_PRIVATE, fd, 0); | |
471 // answer=FILE_dommap(-1, address, 0, size, 0, 0, | |
472 // PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE); | |
473 close(fd); | |
474 if(answer==(void*)-1) | |
475 { | |
476 printf("Error no %d\n", errno); | |
477 printf("VirtualAlloc(0x%08X, %d) failed\n", address, size); | |
478 return NULL; | |
479 } | |
480 else | |
481 { | |
482 virt_alloc *new_vm=malloc(sizeof(virt_alloc)); | |
483 new_vm->mapping_size=size; | |
484 new_vm->address=answer; | |
485 new_vm->prev=vm; | |
486 if(type == MEM_RESERVE) | |
487 new_vm->state=0; | |
488 else | |
489 new_vm->state=1; | |
490 if(vm) | |
491 vm->next=new_vm; | |
492 vm=new_vm; | |
493 vm->next=0; | |
494 // if(va_size!=0) | |
495 // printf("Multiple VirtualAlloc!\n"); | |
496 // printf("answer=0x%08x\n", answer); | |
497 return answer; | |
498 } | |
499 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
500 WIN_BOOL WINAPI VirtualFree(LPVOID address, DWORD t1, DWORD t2)//not sure |
1 | 501 { |
502 virt_alloc* str=vm; | |
503 int answer; | |
504 while(str) | |
505 { | |
506 if(address!=str->address) | |
507 { | |
508 str=str->prev; | |
509 continue; | |
510 } | |
511 answer=munmap(str->address, str->mapping_size); | |
512 if(str->next)str->next->prev=str->prev; | |
513 if(str->prev)str->prev->next=str->next; | |
514 if(vm==str)vm=0; | |
515 free(str); | |
516 return 0; | |
517 } | |
518 return -1; | |
519 } | |
520 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
521 INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
522 LPCWSTR src, INT srclen, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
523 LPSTR dest, INT destlen, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
524 LPCSTR defch, WIN_BOOL*used_defch) |
1 | 525 { |
526 int i; | |
527 if(src==0) | |
528 return 0; | |
128 | 529 if(srclen==-1){srclen=0; while(src[srclen++]);} |
530 // for(i=0; i<srclen; i++) | |
531 // printf("%c", src[i]); | |
532 // printf("\n"); | |
1 | 533 if(dest==0) |
534 { | |
535 for(i=0; i<srclen; i++) | |
536 { | |
537 src++; | |
538 if(*src==0) | |
539 return i+1; | |
540 } | |
541 return srclen+1; | |
542 } | |
543 if(used_defch) | |
544 *used_defch=0; | |
545 for(i=0; i<min(srclen, destlen); i++) | |
546 { | |
547 *dest=(char)*src; | |
548 dest++; | |
549 src++; | |
550 if(*src==0) | |
551 return i+1; | |
552 } | |
553 return min(srclen, destlen); | |
554 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
555 INT WINAPI MultiByteToWideChar(UINT codepage, DWORD flags, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
556 LPCSTR src, INT srclen, |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
557 LPWSTR dest, INT destlen) |
1 | 558 { |
559 return 0; | |
560 } | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
128
diff
changeset
|
561 HANDLE WINAPI OpenFileMappingA(DWORD access, WIN_BOOL prot, LPCSTR name) |
1 | 562 { |
563 file_mapping* p; | |
564 if(fm==0) | |
565 return (HANDLE)0; | |
566 if(name==0) | |
567 return (HANDLE)0; | |
568 for(p=fm; p; p=p->prev) | |
569 { | |
570 if(p->name==0) | |
571 continue; | |
572 if(strcmp(p->name, name)==0) | |
573 return p->handle; | |
574 } | |
575 return 0; | |
576 } |