annotate loader/win32.c @ 37:b5ce4f6a8651

TODO: updated codecs
author gabucino
date Sun, 04 Mar 2001 22:17:28 +0000
parents 3b5f5d1c5041
children 94a1a9f52050
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /***********************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 Win32 emulation code. Functions that emulate
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 responses from corresponding Win32 API calls.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 Since we are not going to be able to load
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 virtually any DLL, we can only implement this
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 much, adding needed functions with each new codec.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 ************************************************************/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include <config.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 #include "win32.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <pthread.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #ifdef HAVE_MALLOC_H
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <malloc.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include <time.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include <sys/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include <sys/time.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <sys/timeb.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <wine/winbase.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <wine/winreg.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include <wine/winnt.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <wine/winerror.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include <wine/debugtools.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #include <wine/module.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 #include <registry.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 #include <loader.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 #ifdef USE_TSC
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 static unsigned int localcount()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 int a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 __asm__ __volatile__("rdtsc\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 :"=a"(a)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 :
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 :"edx");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 return a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 static void longcount(long long* z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 __asm__ __volatile__(
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 "pushl %%ebx\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 "movl %%eax, %%ebx\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 "rdtsc\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 "movl %%eax, 0(%%ebx)\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 "movl %%edx, 4(%%ebx)\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 "popl %%ebx\n\t"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 ::"a"(z));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 #include <sys/time.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 static unsigned int localcount()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 struct timeval tv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 unsigned limit=~0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 limit/=1000000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 gettimeofday(&tv, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 return limit*tv.tv_usec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 static void longcount(long long* z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 struct timeval tv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 unsigned long long result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 unsigned limit=~0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 if(!z)return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 limit/=1000000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 gettimeofday(&tv, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 result=tv.tv_sec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 result<<=32;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 result+=limit*tv.tv_usec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 *z=result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 void dbgprintf(char* fmt, ...)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 #ifdef DETAILED_OUT
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 va_list va;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 va_start(va, fmt);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 vprintf(fmt, va);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 va_end(va);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 va_list va;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 FILE* f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 va_start(va, fmt);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 f=fopen("./log", "a");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 if(f==0)return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 vfprintf(f, fmt, va);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 fsync(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 fclose(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 char export_names[500][30]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 "name1",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 //"name2",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 //"name3"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 //#define min(x,y) ((x)<(y)?(x):(y))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 static unsigned char* heap=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 static int heap_counter=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 void test_heap()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 int offset=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 if(heap==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 while(offset<heap_counter)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 if(*(int*)(heap+offset)!=0x433476)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 printf("Heap corruption at address %d\n", offset);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 offset+=8+*(int*)(heap+offset+4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 for(;offset<min(offset+1000, 20000000); offset++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 if(heap[offset]!=0xCC)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 printf("Free heap corruption at address %d\n", offset);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 #undef MEMORY_DEBUG
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 #ifdef MEMORY_DEBUG
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 void* my_mreq(int size, int to_zero)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 static int test=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 test++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 if(test%10==0)printf("Memory: %d bytes allocated\n", heap_counter);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 // test_heap();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 if(heap==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 heap=malloc(20000000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 memset(heap, 0xCC,20000000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 if(heap==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 printf("No enough memory\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 if(heap_counter+size>20000000)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 printf("No enough memory\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 *(int*)(heap+heap_counter)=0x433476;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 heap_counter+=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 *(int*)(heap+heap_counter)=size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 heap_counter+=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 printf("Allocated %d bytes of memory: sys %d, user %d-%d\n", size, heap_counter-8, heap_counter, heap_counter+size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 if(to_zero)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 memset(heap+heap_counter, 0, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 heap_counter+=size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 return heap+heap_counter-size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 int my_release(char* memory)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 // test_heap();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 if(memory==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 printf("ERROR: free(0)\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 if(*(int*)(memory-8)!=0x433476)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 printf("MEMORY CORRUPTION !!!!!!!!!!!!!!!!!!!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 printf("Freed %d bytes of memory\n", *(int*)(memory-4));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 // memset(memory-8, *(int*)(memory-4), 0xCC);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 void* my_mreq(int size, int to_zero)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 void* answer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 if(to_zero)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 answer=calloc(size+4, 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 answer=malloc(size+4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 *(int*)answer=size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 return (int*)answer+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 int my_release(char* memory)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 if(memory==0)return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 free(memory-4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 int my_size(char* memory)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 return *(int*)(memory-4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 extern int unk_exp1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 char extcode[20000];// place for 200 unresolved exports
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 int pos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 int WINAPI ext_unknown()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 printf("Unknown func called\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 int WINAPI expIsBadWritePtr(void* ptr, unsigned int count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 dbgprintf("IsBadWritePtr(%x, %x)\n", ptr, count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 if(count==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 if(ptr==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 int WINAPI expIsBadReadPtr(void* ptr, unsigned int count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 dbgprintf("IsBadReadPtr(%x, %x)\n", ptr, count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 if(count==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 if(ptr==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 void* CDECL expmalloc(int size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 //printf("malloc");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 // return malloc(size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 void* result=my_mreq(size,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 dbgprintf("malloc(%x)\n", size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 if(result==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 dbgprintf("returns 0\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 printf("WARNING: malloc() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 return result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 void CDECL expfree(void* mem)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 // return free(mem);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 dbgprintf("free(%x)\n", mem);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 my_release(mem);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 void* CDECL expnew(int size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 // printf("NEW:: Call from address %08x\n STACK DUMP:\n", *(-1+(int*)&size));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 // printf("%08x %08x %08x %08x\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 // size, *(1+(int*)&size),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 // *(2+(int*)&size),*(3+(int*)&size));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 void* result=expmalloc(size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 dbgprintf("new(%x)\n", size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 if(result==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 dbgprintf("returns 0\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 printf("WARNING: malloc() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 return result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 int CDECL expdelete(void* memory)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 dbgprintf("delete(%x)\n", memory);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 expfree(memory);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 int WINAPI expDisableThreadLibraryCalls(int module)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 dbgprintf("DisableThreadLibraryCalls(%x)\n", module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 int CDECL exp_initterm(int v1, int v2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 typedef struct {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 unsigned int uDriverSignature;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 void* hDriverModule;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 void* DriverProc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 unsigned int dwDriverID;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 } DRVR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 void* WINAPI expGetDriverModuleHandle(DRVR* pdrv)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 dbgprintf("GetDriverModuleHandle(%x)\n", pdrv);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 return pdrv->hDriverModule;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 void* WINAPI expGetModuleHandleA(const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 WINE_MODREF* wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 dbgprintf("GetModuleHandleA(%s)\n", name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 if(!name)return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 wm=MODULE_FindModule(name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 if(wm==0)return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 return (void*)(wm->module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 struct th_list_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 typedef struct th_list_t{
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 int id;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 void* thread;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 struct th_list_t* next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 struct th_list_t* prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 }th_list;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 static th_list* list=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize, void* lpStartAddress,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 void* lpParameter, long dwFlags, long* dwThreadId)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 pthread_t *pth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 // printf("CreateThread:");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 pth=my_mreq(sizeof(pthread_t), 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 dbgprintf("pthread_create\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 if(dwFlags)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 dbgprintf( "WARNING: CreateThread flags not supported\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 if(dwThreadId)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 *dwThreadId=(long)pth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 dbgprintf( "Created thread %08X\n", pth);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 list=my_mreq(sizeof(th_list), 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 list->next=list->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 list->next=my_mreq(sizeof(th_list), 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 list->next->prev=list;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 list->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 list=list->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 list->thread=pth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 return pth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 struct mutex_list_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 struct mutex_list_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 pthread_mutex_t *pm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 char name[64];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 struct mutex_list_t* next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 struct mutex_list_t* prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 typedef struct mutex_list_t mutex_list;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 static mutex_list* mlist=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 char bInitialState, const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 #warning ManualReset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 pthread_mutex_t *pm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 dbgprintf("CreateEvent\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 if(mlist!=NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 mutex_list* pp=mlist;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 if(name!=NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369 do
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 if(strcmp(pp->name, name)==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 return pp->pm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 }while(pp=pp->prev);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 pm=my_mreq(sizeof(pthread_mutex_t), 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 pthread_mutex_init(pm, NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 if(mlist==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 mlist=my_mreq(sizeof(mutex_list), 00);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 mlist->next=mlist->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 mlist->next=my_mreq(sizeof(mutex_list), 00);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 mlist->next->prev=mlist->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 mlist->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 mlist=mlist->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 mlist->pm=pm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 if(name!=NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 strncpy(mlist->name, name, 64);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 mlist->name[0]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 if(pm==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 dbgprintf("ERROR::: CreateEventA failure\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 if(bInitialState)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 pthread_mutex_lock(pm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 return pm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 void* WINAPI expSetEvent(void* event)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 dbgprintf("Trying to lock %X\n", event);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 pthread_mutex_lock(event);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 void* WINAPI expResetEvent(void* event)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 dbgprintf("Unlocking %X\n", event);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 pthread_mutex_unlock(event);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 void* WINAPI expWaitForSingleObject(void* object, int duration)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 #warning not sure
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 dbgprintf("WaitForSingleObject: duration %d\n", duration);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 pthread_mutex_lock(object);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 pthread_mutex_unlock(object);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 static BYTE PF[64] = {0,};
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 /* FIXME: better values for the two entries below... */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 static int cache = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 static SYSTEM_INFO cachedsi;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 HKEY xhkey=0,hkey;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 dbgprintf("GetSystemInfo()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 if (cache) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 memcpy(si,&cachedsi,sizeof(*si));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 memset(PF,0,sizeof(PF));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 cachedsi.dwPageSize = getpagesize();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 /* FIXME: better values for the two entries below... */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 cachedsi.lpMinimumApplicationAddress = (void *)0x40000000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 cachedsi.lpMaximumApplicationAddress = (void *)0x7FFFFFFF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 cachedsi.dwActiveProcessorMask = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 cachedsi.dwNumberOfProcessors = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445 cachedsi.dwAllocationGranularity = 0x10000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 cachedsi.wProcessorLevel = 3; /* pentium */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447 cachedsi.wProcessorRevision = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 #ifdef __FreeBSD__
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 #ifdef MMX
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 cachedsi.dwNumberOfProcessors=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 char buf[20];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 char line[200];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 FILE *f = fopen ("/proc/cpuinfo", "r");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 if (!f)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 xhkey = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466 while (fgets(line,200,f)!=NULL) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 char *s,*value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 /* NOTE: the ':' is the only character we can rely on */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 if (!(value = strchr(line,':')))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 /* terminate the valuename */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 *value++ = '\0';
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 /* skip any leading spaces */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 while (*value==' ') value++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
476 if ((s=strchr(value,'\n')))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
477 *s='\0';
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
478
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
479 /* 2.1 method */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 if (isdigit (value[0])) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 switch (value[0] - '0') {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
483 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
484 cachedsi.wProcessorLevel= 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
485 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
486 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 cachedsi.wProcessorLevel= 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
488 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
489 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
490 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
491 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
492 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
493 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
494 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
495 default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
496 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
497 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
498 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
499 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
500 /* set the CPU type of the current processor */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
501 sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
502 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
503 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
504 /* old 2.0 method */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
505 if (!lstrncmpiA(line, "cpu",strlen("cpu"))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
506 if ( isdigit (value[0]) && value[1] == '8' &&
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
507 value[2] == '6' && value[3] == 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
508 ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
509 switch (value[0] - '0') {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
510 case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
511 cachedsi.wProcessorLevel= 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
512 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
513 case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
514 cachedsi.wProcessorLevel= 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
515 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
516 case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
517 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
518 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
519 case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
520 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
521 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
522 default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
523 cachedsi.wProcessorLevel= 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
524 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
525 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
526 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
527 /* set the CPU type of the current processor */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
528 sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
529 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
530 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
531 if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
532 if (!lstrncmpiA(value,"yes",3))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
533 PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
534
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
535 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
536 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
537 if (!lstrncmpiA(line,"fpu",strlen("fpu"))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
538 if (!lstrncmpiA(value,"no",2))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
539 PF[PF_FLOATING_POINT_EMULATED] = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
540
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
541 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
542 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
543 if (!lstrncmpiA(line,"processor",strlen("processor"))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
544 /* processor number counts up...*/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
545 int x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
546
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
547 if (sscanf(value,"%d",&x))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
548 if (x+1>cachedsi.dwNumberOfProcessors)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
549 cachedsi.dwNumberOfProcessors=x+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
550
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
551 /* Create a new processor subkey on a multiprocessor
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
552 * system
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
553 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
554 sprintf(buf,"%d",x);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
555 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
556 if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
557 int x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
558
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
559 if (sscanf(value,"%d",&x))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
560 cachedsi.wProcessorRevision = x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
561 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
562 if ( (!lstrncmpiA(line,"flags",strlen("flags"))) ||
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
563 (!lstrncmpiA(line,"features",strlen("features"))) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
564 if (strstr(value,"cx8"))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
565 PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
566 if (strstr(value,"mmx"))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
567 PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
568
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
569 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
570 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
571 fclose (f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
572 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
573 #endif /* __FreeBSD__ */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
574 memcpy(si,&cachedsi,sizeof(*si));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
575 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
576
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
577 long WINAPI expGetVersion()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
578 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
579 return 0xC0000A04;//Windows 98
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
580 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
581
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
582 HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
583 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
584 // printf("HeapCreate:");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
585 dbgprintf("HeapCreate(%X, %X, %X)\n", flags, init_size, max_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
586 if(init_size==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
587 return (HANDLE)my_mreq(0x110000, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
588 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
589 return (HANDLE)my_mreq(init_size, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
590 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
591 void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
592 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
593 void* z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
594 dbgprintf("HeapAlloc(%X, %X, %X)\n", heap, flags, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
595 // printf("HeapAlloc:");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
596 z=my_mreq(size, flags&8);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
597 // z=HeapAlloc(heap,flags,size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
598 if(z==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
599 printf("HeapAlloc failure\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
600 return z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
601 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
602 long WINAPI expHeapDestroy(void* heap)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
603 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
604 dbgprintf("HeapDestroy(%X)\n", heap);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
605 my_release(heap);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
606 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
607 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
608
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
609 long WINAPI expHeapFree(int arg1, int arg2, void* ptr)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
610 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
611 dbgprintf("HeapFree(%X, %X, %X)\n", arg1, arg2, ptr);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
612 my_release(ptr);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
613 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
614 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
615 long WINAPI expHeapSize(int heap, int flags, void* pointer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
616 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
617 return my_size(pointer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
618 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
619 long WINAPI expGetProcessHeap(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
620 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
621 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
622 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
623 void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
624 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
625 void* z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
626 dbgprintf("VirtualAlloc(%d %d %d %d) \n",v1,v2,v3,v4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
627 z=VirtualAlloc(v1, v2, v3, v4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
628 if(z==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
629 printf("VirtualAlloc failure\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
630 return z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
631 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
632 int WINAPI expVirtualFree(void* v1, int v2, int v3)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
633 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
634 dbgprintf("VirtualFree(%X %X %X) \n",v1,v2,v3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
635 return VirtualFree(v1,v2,v3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
636 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
637 struct CRITSECT
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
638 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
639 pthread_t id;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
640 pthread_mutex_t mutex;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
641 int locked;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
642 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
643 void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
644 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
645 struct CRITSECT cs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
646 dbgprintf("InitCriticalSection(%X) \n", c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
647 /* if(sizeof(pthread_mutex_t)>sizeof(CRITICAL_SECTION))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
648 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
649 printf(" ERROR:::: sizeof(pthread_mutex_t) is %d, expected <=%d!\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
650 sizeof(pthread_mutex_t), sizeof(CRITICAL_SECTION));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
651 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
652 }*/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
653 /* pthread_mutex_init((pthread_mutex_t*)c, NULL); */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
654 pthread_mutex_init(&cs.mutex, NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
655 cs.locked=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
656 *(void**)c=malloc(sizeof cs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
657 memcpy(*(void**)c, &cs, sizeof cs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
658 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
659 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
660 void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
661 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
662 struct CRITSECT* cs=(struct CRITSECT*)c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
663 dbgprintf("EnterCriticalSection(%X) \n",c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
664 // cs.id=pthread_self();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
665 if(cs->locked)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
666 if(cs->id==pthread_self())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
667 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
668 pthread_mutex_lock(&(cs->mutex));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
669 cs->locked=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
670 cs->id=pthread_self();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
671 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
672 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
673 void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
674 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
675 struct CRITSECT* cs=(struct CRITSECT*)c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
676 dbgprintf("LeaveCriticalSection(%X) \n",c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
677 cs->locked=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
678 pthread_mutex_unlock(&(cs->mutex));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
679 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
680 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
681 void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
682 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
683 dbgprintf("DeleteCriticalSection(%X) \n",c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
684 pthread_mutex_destroy((pthread_mutex_t*)c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
685 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
686 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
687 int WINAPI expGetCurrentThreadId()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
688 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
689 dbgprintf("GetCurrentThreadId() \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
690 return getpid();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
691 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
692 struct tls_s;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
693 typedef struct tls_s
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
694 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
695 void* value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
696 int used;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
697 struct tls_s* prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
698 struct tls_s* next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
699 }tls_t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
700
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
701 tls_t* g_tls=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
702
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
703 void* WINAPI expTlsAlloc()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
704 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
705 dbgprintf("TlsAlloc \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
706 if(g_tls==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
707 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
708 g_tls=my_mreq(sizeof(tls_t), 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
709 g_tls->next=g_tls->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
710 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
711 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
712 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
713 g_tls->next=my_mreq(sizeof(tls_t), 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
714 g_tls->next->prev=g_tls;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
715 g_tls->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
716 g_tls=g_tls->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
717 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
718 return g_tls;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
719 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
720
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
721 int WINAPI expTlsSetValue(tls_t* index, void* value)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
722 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
723 dbgprintf("TlsSetVal(%X %X) \n", index, value );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
724 if(index==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
725 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
726 index->value=value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
727 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
728 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
729 void* WINAPI expTlsGetValue(tls_t* index)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
730 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
731 dbgprintf("TlsGetVal(%X) \n", index );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
732 if(index==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
733 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
734 return index->value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
735 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
736 int WINAPI expTlsFree(tls_t* index)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
737 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
738 dbgprintf("TlsFree(%X) \n", index);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
739 if(index==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
740 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
741 if(index->next)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
742 index->next->prev=index->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
743 if(index->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
744 index->prev->next=index->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
745 my_release((void*)index);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
746 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
747 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
748
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
749 void* WINAPI expLocalAlloc(int flags, int size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
750 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
751 void* z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
752 dbgprintf("LocalAlloc(%d, flags %X)\n", size, flags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
753 if(flags&GMEM_ZEROINIT)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
754 z=my_mreq(size, 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
755 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
756 z=my_mreq(size, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
757 if(z==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
758 printf("LocalAlloc() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
759 return z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
760 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
761 void* WINAPI expLocalLock(void* z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
762 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
763 dbgprintf("LocalLock\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
764 return z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
765 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
766 void* WINAPI expGlobalAlloc(int flags, int size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
767 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
768 void* z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
769 dbgprintf("GlobalAlloc(%d, flags 0x%X)\n", size, flags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
770 if(flags&GMEM_ZEROINIT)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
771 z=my_mreq(size, 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
772 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
773 z=my_mreq(size, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
774 if(z==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
775 printf("LocalAlloc() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
776 return z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
777 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
778 void* WINAPI expGlobalLock(void* z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
779 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
780 dbgprintf("GlobalLock\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
781 return z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
782 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
783
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
784 int WINAPI expLoadStringA(long instance, long id, void* buf, long size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
785 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
786 dbgprintf("LoadStringA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
787 return LoadStringA(instance, id, buf, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
788 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
789
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
790 long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1, char* s2, int siz2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
791 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
792 #warning FIXME
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
793 dbgprintf("MB2WCh\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
794 dbgprintf("WARNING: Unsupported call: MBToWCh %s\n", s1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
795 if(s2==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
796 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
797 s2[0]=s2[1]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
798 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
799 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
800 long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1, char* s2, int siz2, char* c3, int* siz3)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
801 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
802 int result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
803 dbgprintf("WCh2MB\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
804 result=WideCharToMultiByte(v1, v2, s1, siz1, s2, siz2, c3, siz3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
805 dbgprintf("=> %d\n", result);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
806 return result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
807 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
808 long WINAPI expGetVersionExA(OSVERSIONINFOA* c)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
809 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
810 dbgprintf("GetVersionExA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
811 c->dwMajorVersion=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
812 c->dwMinorVersion=10;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
813 c->dwBuildNumber=0x40a07ce;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
814 c->dwPlatformId=VER_PLATFORM_WIN32_WINDOWS;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
815 strcpy(c->szCSDVersion, "Win98");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
816 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
817 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
818 #include <sys/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
819 #include <sys/ipc.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
820 #include <sys/sem.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
821 HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count, long max_count, char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
822 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
823 #warning FIXME
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
824 /* struct sembuf buf[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
825 int sem=semget(IPC_PRIVATE,1,IPC_CREAT);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
826 if(sem==-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
827 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
828 printf("semget() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
829 return (HANDLE)-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
830 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
831 buf[0].sem_num=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
832 printf("%s\n", name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
833 printf("Init count %d, max count %d\n", init_count, max_count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
834 buf[0].sem_op=-max_count+init_count;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
835 buf[0].sem_flg=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
836 if(semop(sem, &buf, 1)<0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
837 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
838 printf("semop() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
839 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
840 return sem;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
841 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
842 void* z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
843 dbgprintf("CreateSemaphoreA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
844 z=my_mreq(24, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
845 pthread_mutex_init(z, NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
846 return (HANDLE)z;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
847 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
848
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
849 long WINAPI expReleaseSemaphore(long hsem, long increment, long* prev_count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
850 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
851 // The state of a semaphore object is signaled when its count
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
852 // is greater than zero and nonsignaled when its count is equal to zero
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
853 // Each time a waiting thread is released because of the semaphore's signaled
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
854 // state, the count of the semaphore is decreased by one.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
855 struct sembuf buf[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
856 dbgprintf("ReleaseSemaphore\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
857 dbgprintf("WARNING: Unsupported call: ReleaseSemaphoreA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
858 /* if(hsem==-1)return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
859 buf[0].sem_num=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
860 buf[0].sem_op=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
861 buf[0].sem_flg=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
862 if(semop(hsem, &buf, 1)<0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
863 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
864 printf("ReleaseSemaphore: semop() failed\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
865 }*/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
866
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
867 return 1;//zero on error
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
868 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
869
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
870
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
871 long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
872 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
873 dbgprintf("RegOpenKeyExA(%d,%s)\n", key, subkey);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
874 return RegOpenKeyExA(key, subkey, reserved, access, newkey);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
875 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
876 long WINAPI expRegCloseKey(long key)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
877 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
878 dbgprintf("RegCloseKey()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
879 return RegCloseKey(key);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
880 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
881 long WINAPI expRegQueryValueExA(long key, const char* value, int* reserved, int* type, int* data, int* count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
882 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
883 dbgprintf("RegQueryValueExA()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
884 return RegQueryValueExA(key, value, reserved, type, data, count);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
885 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
886 long WINAPI expRegCreateKeyExA(long key, const char* name, long reserved,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
887 void* classs, long options, long security,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
888 void* sec_attr, int* newkey, int* status)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
889 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
890 dbgprintf("RegCreateKeyExA()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
891 return RegCreateKeyExA(key, name, reserved, classs, options, security, sec_attr, newkey, status);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
892 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
893 long WINAPI expRegSetValueExA(long key, const char* name, long v1, long v2, void* data, long size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
894 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
895 dbgprintf("RegSetValueExA()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
896 return RegSetValueExA(key, name, v1, v2, data, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
897 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
898
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
899 long WINAPI expRegOpenKeyA (
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
900 long hKey,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
901 LPCSTR lpSubKey,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
902 int* phkResult
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
903 ){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
904 return RegOpenKeyExA(hKey, lpSubKey, 0, 0, phkResult);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
905 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
906
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
907 long WINAPI expQueryPerformanceCounter(long long* z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
908 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
909 dbgprintf("QueryPerformanceCounter()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
910 longcount(z);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
911 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
912 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
913
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
914 static double old_freq()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
915 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
916 int i=time(NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
917 int x,y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
918 while(i==time(NULL));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
919 x=localcount();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
920 i++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
921 while(i==time(NULL));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
922 y=localcount();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
923 return (double)(y-x)/1000.;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
924 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
925 static double CPU_Freq()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
926 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
927 #ifdef USE_TSC
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
928 FILE *f = fopen ("/proc/cpuinfo", "r");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
929 char line[200];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
930 char model[200]="unknown";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
931 char flags[500]="";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
932 char *s,*value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
933 double freq=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
934
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
935 if (!f)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
936 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
937 printf("Can't open /proc/cpuinfo for reading\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
938 return old_freq();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
939 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
940 while (fgets(line,200,f)!=NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
941 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
942 /* NOTE: the ':' is the only character we can rely on */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
943 if (!(value = strchr(line,':')))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
944 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
945 /* terminate the valuename */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
946 *value++ = '\0';
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
947 /* skip any leading spaces */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
948 while (*value==' ') value++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
949 if ((s=strchr(value,'\n')))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
950 *s='\0';
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
951
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
952 if (!strncasecmp(line, "cpu MHz",strlen("cpu MHz")))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
953 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
954 sscanf(value, "%lf", &freq);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
955 freq*=1000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
956 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
957 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
958 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
959
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
960 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
961 fclose(f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
962 if(freq<0)return old_freq();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
963 return freq;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
964 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
965 return old_freq();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
966 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
967 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
968
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
969 long WINAPI expQueryPerformanceFrequency(long long* z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
970 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
971 dbgprintf("QueryPerformanceFrequency()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
972 *z=(long long)CPU_Freq();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
973 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
974 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
975 long WINAPI exptimeGetTime()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
976 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
977 struct timeval t;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
978 dbgprintf("timeGetTime()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
979 gettimeofday(&t, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
980 return 1000*t.tv_sec+t.tv_usec/1000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
981 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
982 void* WINAPI expLocalHandle(void* v)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
983 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
984 dbgprintf("LocalHandle\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
985 return v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
986 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
987 void* WINAPI expGlobalHandle(void* v)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
988 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
989 dbgprintf("GlobalHandle\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
990 return v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
991 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
992 int WINAPI expGlobalUnlock(void* v)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
993 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
994 dbgprintf("GlobalUnlock\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
995 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
996 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
997 //
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
998 void* WINAPI expGlobalFree(void* v)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
999 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1000 dbgprintf("GlobalFree(%X)\n", v);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1001 my_release(v);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1002 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1003 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1004
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1005 int WINAPI expLocalUnlock(void* v)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1006 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1007 dbgprintf("LocalUnlock\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1008 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1009 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1010 //
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1011 void* WINAPI expLocalFree(void* v)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1012 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1013 dbgprintf("LocalFree(%X)\n", v);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1014 my_release(v);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1015 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1016 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1017
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1018 HRSRC WINAPI expFindResourceA(HMODULE module, char* name, char* type)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1019 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1020 dbgprintf("FindResourceA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1021 return FindResourceA(module, name, type);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1022 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1023 HGLOBAL WINAPI expLoadResource(HMODULE module, HRSRC res)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1024 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1025 dbgprintf("LoadResource\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1026 return LoadResource(module, res);;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1027 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1028 void* WINAPI expLockResource(long res)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1029 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1030 dbgprintf("LockResource\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1031 return LockResource(res);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1032 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1033 int WINAPI expFreeResource(long res)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1034 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1035 dbgprintf("FreeResource\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1036 return FreeResource(res);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1037 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1038 //bool fun(HANDLE)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1039 //!0 on success
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1040 int WINAPI expCloseHandle(long v1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1041 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1042 dbgprintf("CloseHandle\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1043 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1044 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1045
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1046 const char* WINAPI expGetCommandLineA()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1047 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1048 dbgprintf("GetCommandLine\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1049 return "c:\\aviplay.exe";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1050 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1051 LPWSTR WINAPI expGetEnvironmentStringsW()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1052 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1053 static wchar_t envs[]={'p', 'a', 't', 'h', ' ', 'c', ':', '\\', 0, 0};
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1054 dbgprintf("GetEnvStringsW\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1055 return (LPWSTR)envs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1056 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1057
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1058 int WINAPI expFreeEnvironmentStringsW(short* strings)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1059 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1060 dbgprintf("FreeEnvStringsW\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1061 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1062 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1063 LPCSTR WINAPI expGetEnvironmentStrings()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1064 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1065 dbgprintf("GetEnvStrings\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1066 return "\0\0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1067 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1068
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1069 int WINAPI expGetStartupInfoA(STARTUPINFOA *s)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1070 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1071 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1072 dbgprintf("GetStartupInfoA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1073 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1074 for(i=0; i<sizeof(STARTUPINFOA)/4; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1075 ((int*)s)[i]=i+0x200;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1076 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1077 memset(s, 0, sizeof(*s));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1078 s->cb=sizeof(*s);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1079 s->lpReserved="qwe";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1080 s->lpDesktop="rty";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1081 s->lpTitle="uio";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1082 s->dwX=s->dwY=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1083 s->dwXSize=s->dwYSize=200;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1084 s->dwFlags=s->wShowWindow=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1085 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1086 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1087
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1088 int WINAPI expGetStdHandle(int z)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1089 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1090 dbgprintf("GetStdHandle\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1091 dbgprintf("WARNING: Unsupported call: GetStdHandle\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1092 return 1234;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1093 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1094 int WINAPI expGetFileType(int handle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1095 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1096 dbgprintf("GetFileType\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1097 dbgprintf("WARNING: Unsupported call: GetFileType\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1098 return 5678;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1099 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1100 int WINAPI expSetHandleCount(int count)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1101 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1102 dbgprintf("SetHandleCount\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1103 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1104 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1105 int WINAPI expGetACP()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1106 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1107 dbgprintf("GetACP\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1108 dbgprintf("WARNING: Unsupported call: GetACP\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1109 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1110 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1111 extern WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1112 int WINAPI expGetModuleFileNameA(int module, char* s, int len)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1113 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1114 WINE_MODREF *mr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1115 dbgprintf("GetModuleFileNameA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1116 // printf("File name of module %X requested\n", module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1117 if(s==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1118 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1119 if(len<35)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1120 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1121 strcpy(s, "c:\\windows\\system\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1122 mr=MODULE32_LookupHMODULE(module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1123 if(mr==0)//oops
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1124 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1125 strcat(s, "aviplay.dll");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1126 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1127 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1128 if(strrchr(mr->filename, '/')==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1129 strcat(s, mr->filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1130 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1131 strcat(s, strrchr(mr->filename, '/')+1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1132 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1133 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1134
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1135 int WINAPI expSetUnhandledExceptionFilter(void* filter)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1136 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1137 dbgprintf("SetUnhandledExcFilter\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1138 return 1;//unsupported and probably won't ever be supported
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1139 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1140 extern char* def_path;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1141
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1142 int WINAPI expLoadLibraryA(char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1143 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1144 char qq[256];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1145 dbgprintf("LoadLibraryA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1146 printf("They want library %s\n", name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1147 strcpy(qq, def_path);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1148 strcat(qq, "/");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1149 strcat(qq, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1150 return LoadLibraryA(qq);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1151 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1152 int WINAPI expFreeLibrary(int module)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1153 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1154 dbgprintf("FreeLibrary\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1155 return FreeLibrary(module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1156 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1157 void* WINAPI expGetProcAddress(HMODULE mod, char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1158 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1159 dbgprintf("GetProcAddress\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1160 return GetProcAddress(mod, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1161 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1162
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1163 long WINAPI expCreateFileMappingA(int hFile, void* lpAttr,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1164 long flProtect, long dwMaxHigh, long dwMaxLow, const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1165 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1166 dbgprintf("CreateFileMappingA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1167 return CreateFileMappingA(hFile, lpAttr, flProtect, dwMaxHigh, dwMaxLow, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1168 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1169
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1170 long WINAPI expOpenFileMappingA(long hFile, long hz, const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1171 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1172 dbgprintf("OpenFileMappingA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1173 return OpenFileMappingA(hFile, hz, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1174 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1175
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1176 void* WINAPI expMapViewOfFile(HANDLE file, DWORD mode, DWORD offHigh, DWORD offLow, DWORD size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1177 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1178 dbgprintf("MapViewOfFile(%d, %x, %x, %x, %x)\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1179 file,mode,offHigh,offLow,size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1180 return (char*)file+offLow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1181 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1182
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1183 void* WINAPI expUnmapViewOfFile(void* view)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1184 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1185 dbgprintf("UnmapViewOfFile()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1186 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1187 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1188
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1189 void* WINAPI expSleep(int time)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1190 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1191 dbgprintf("Sleep(%d)\n", time);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1192 usleep(time);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1193 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1194 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1195 // why does IV32 codec want to call this? I don't know ...
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1196 void* WINAPI expCreateCompatibleDC(int hdc)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1197 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1198 dbgprintf("CreateCompatibleDC(%d)\n", hdc);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1199 return (void*)129;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1200 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1201
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1202 int WINAPI expGetDeviceCaps(int hdc, int unk)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1203 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1204 dbgprintf("GetDeviceCaps(%d, %d)\n", hdc, unk);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1205 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1206 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1207
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1208 WIN_BOOL WINAPI expDeleteDC(int hdc)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1209 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1210 dbgprintf("DeleteDC(%d)\n", hdc);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1211 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1212 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1213
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1214 int expwsprintfA(char* string, char* format, ...)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1215 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1216 va_list va;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1217 va_start(va, format);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1218 dbgprintf("wsprintfA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1219 return vsprintf(string, format, va);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1220 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1221
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1222 int WINAPI expGetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1223 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1224 int size=255;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1225 char buffer[256];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1226 char* fullname;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1227 int result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1228
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1229 buffer[255]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1230 dbgprintf("GetPrivateProfileIntA(%s, %s, %s)\n", appname, keyname, filename );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1231 if(!(appname && keyname && filename) ) return default_value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1232 fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1233 strcpy(fullname, "Software\\IniFileMapping\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1234 strcat(fullname, appname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1235 strcat(fullname, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1236 strcat(fullname, keyname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1237 strcat(fullname, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1238 strcat(fullname, filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1239 result=RegQueryValueExA(HKEY_LOCAL_MACHINE, fullname, NULL, NULL, (int*)buffer, &size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1240 if((size>=0)&&(size<256))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1241 buffer[size]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1242 // printf("GetPrivateProfileIntA(%s, %s, %s) -> %s\n", appname, keyname, filename, buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1243 free(fullname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1244 if(result)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1245 return default_value;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1246 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1247 return atoi(buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1248 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1249 int WINAPI expGetPrivateProfileStringA(const char* appname, const char* keyname,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1250 const char* def_val, char* dest, unsigned int len, const char* filename)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1251 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1252 int result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1253 int size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1254 char* fullname;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1255 dbgprintf("GetPrivateProfileStringA(%s, %s, %s, %X, %X, %s)\n", appname, keyname, def_val, dest, len, filename );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1256 if(!(appname && keyname && filename) ) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1257 fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1258 strcpy(fullname, "Software\\IniFileMapping\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1259 strcat(fullname, appname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1260 strcat(fullname, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1261 strcat(fullname, keyname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1262 strcat(fullname, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1263 strcat(fullname, filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1264 size=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1265 result=RegQueryValueExA(HKEY_LOCAL_MACHINE, fullname, NULL, NULL, (int*)dest, &size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1266 // printf("GetPrivateProfileStringA(%s, %s, %s, %X, %X, %s)\n", appname, keyname, def_val, dest, len, filename );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1267 free(fullname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1268 if(!result)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1269 return size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1270 strncpy(dest, def_val, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1271 return size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1272 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1273 int WINAPI expWritePrivateProfileStringA(const char* appname, const char* keyname,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1274 const char* string, const char* filename)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1275 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1276 int size=256;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1277 char* fullname;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1278 dbgprintf("WritePrivateProfileStringA(%s, %s, %s, %s)\n", appname, keyname, string, filename );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1279 if(!(appname && keyname && filename) ) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1280 fullname=(char*)malloc(50+strlen(appname)+strlen(keyname)+strlen(filename));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1281 strcpy(fullname, "Software\\IniFileMapping\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1282 strcat(fullname, appname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1283 strcat(fullname, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1284 strcat(fullname, keyname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1285 strcat(fullname, "\\");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1286 strcat(fullname, filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1287 RegSetValueExA(HKEY_LOCAL_MACHINE, fullname, 0, REG_SZ, (int*)string, strlen(string));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1288 // printf("RegSetValueExA(%s,%d)\n", string, strlen(string));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1289 // printf("WritePrivateProfileStringA(%s, %s, %s, %s)\n", appname, keyname, string, filename );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1290 free(fullname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1291 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1292 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1293
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1294 unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, INT default_value, const char* filename)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1295 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1296 return expGetPrivateProfileIntA(appname, keyname, default_value, filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1297 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1298 int _GetPrivateProfileStringA(const char* appname, const char* keyname,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1299 const char* def_val, char* dest, unsigned int len, const char* filename)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1300 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1301 return expGetPrivateProfileStringA(appname, keyname, def_val, dest, len, filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1302 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1303 int _WritePrivateProfileStringA(const char* appname, const char* keyname,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1304 const char* string, const char* filename)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1305 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1306 return expWritePrivateProfileStringA(appname, keyname, string, filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1307 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1308
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1309
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1310 int WINAPI expDefDriverProc(int _private, int id, int msg, int arg1, int arg2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1311 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1312 printf("Called DefDriverProc(%X)\n", msg);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1313 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1314 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1315
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1316 int WINAPI expSizeofResource(int v1, int v2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1317 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1318 dbgprintf("SizeofResource()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1319 return SizeofResource(v1, v2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1320 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1321
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1322 int WINAPI expGetLastError()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1323 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1324 dbgprintf("GetLastError()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1325 return GetLastError();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1326 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1327
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1328 void WINAPI expSetLastError(int error)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1329 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1330 dbgprintf("SetLastError()\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1331 SetLastError(error);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1332 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1333
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1334 char* expstrrchr(char* string, int value)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1335 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1336 return strrchr(string, value);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1337 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1338
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1339 char* expstrchr(char* string, int value)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1340 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1341 return strchr(string, value);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1342 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1343
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1344 int WINAPI expGetFileVersionInfoSizeA(const char* name, int* lpHandle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1345 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1346 printf("GetFileVersionInfoSizeA(%s,0x%X)\n", name, lpHandle);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1347 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1348 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1349
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1350 int WINAPI expIsBadStringPtrW(const short* string, int nchars)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1351 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1352 if(string==0)return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1353 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1354 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1355 extern long WINAPI InterlockedExchangeAdd( long* dest, long incr )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1356 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1357 long ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1358 __asm__ __volatile__( "lock; xaddl %0,(%1)"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1359 : "=r" (ret) : "r" (dest), "0" (incr) : "memory" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1360 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1361 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1362
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1363 extern long WINAPI expInterlockedIncrement( long* dest )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1364 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1365 return InterlockedExchangeAdd( dest, 1 ) + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1366 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1367 extern long WINAPI expInterlockedDecrement( long* dest )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1368 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1369 return InterlockedExchangeAdd( dest, -1 ) - 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1370 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1371
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1372 extern void WINAPI expOutputDebugStringA( const char* string )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1373 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1374 fprintf(stderr, "DEBUG: %s\n", string);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1375 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1376
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1377 int WINAPI expGetDC(int hwnd)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1378 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1379 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1380 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1381
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1382 int WINAPI expGetDesktopWindow()
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1383 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1384 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1385 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1386
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1387 int WINAPI expReleaseDC(int hwnd, int hdc)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1388 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1389 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1390 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1391
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1392 int WINAPI expGetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, void* lppe)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1393 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1394 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1395 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1396 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1397 typedef struct _TIME_ZONE_INFORMATION {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1398 long Bias;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1399 char StandardName[32];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1400 SYSTEMTIME StandardDate;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1401 long StandardBias;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1402 char DaylightName[32];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1403 SYSTEMTIME DaylightDate;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1404 long DaylightBias;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1405 } TIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1406 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1407
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1408 int WINAPI expGetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1409 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1410 memset(lpTimeZoneInformation, 0, sizeof(TIME_ZONE_INFORMATION));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1411 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1412 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1413
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1414 void WINAPI expGetLocalTime(SYSTEMTIME* systime)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1415 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1416 time_t local_time;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1417 struct tm *local_tm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1418 struct timeval tv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1419
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1420 gettimeofday(&tv, NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1421 local_time=tv.tv_sec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1422 local_tm=localtime(&local_time);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1423
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1424 systime->wYear = local_tm->tm_year + 1900;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1425 systime->wMonth = local_tm->tm_mon + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1426 systime->wDayOfWeek = local_tm->tm_wday;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1427 systime->wDay = local_tm->tm_mday;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1428 systime->wHour = local_tm->tm_hour;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1429 systime->wMinute = local_tm->tm_min;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1430 systime->wSecond = local_tm->tm_sec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1431 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1432 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1433
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1434 int WINAPI expGetSystemTime(SYSTEMTIME* systime)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1435 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1436 time_t local_time;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1437 struct tm *local_tm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1438 struct timeval tv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1439
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1440 gettimeofday(&tv, NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1441 local_time=tv.tv_sec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1442 local_tm=gmtime(&local_time);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1443
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1444 systime->wYear = local_tm->tm_year + 1900;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1445 systime->wMonth = local_tm->tm_mon + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1446 systime->wDayOfWeek = local_tm->tm_wday;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1447 systime->wDay = local_tm->tm_mday;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1448 systime->wHour = local_tm->tm_hour;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1449 systime->wMinute = local_tm->tm_min;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1450 systime->wSecond = local_tm->tm_sec;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1451 systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1452
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1453 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1454
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1455 int WINAPI expGetEnvironmentVariableA(const char* name, char* field, int size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1456 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1457 dbgprintf("GetEnvironmentVariableA\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1458 printf("%s %x %x\n", name, field, size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1459 if(field)field[0]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1460 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1461 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1462
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1463
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1464 //HDRVR WINAPI expOpenDriverA(LPCSTR szDriverName, LPCSTR szSectionName, LPARAM lParam2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1465 //HDRVR WINAPI expOpenDriverW(LPCWSTR szDriverName, LPCWSTR szSectionName, LPARAM lParam2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1466 HDRVR WINAPI expOpenDriver(LPCSTR szDriverName, LPCSTR szSectionName, LPARAM lParam2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1467 printf("winmm32::OpenDriver() called\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1468 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1469 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1470
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1471
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1472 struct exports
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1473 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1474 char name[64];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1475 int id;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1476 void* func;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1477 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1478 struct libs
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1479 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1480 char name[64];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1481 int length;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1482 struct exports* exps;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1483 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1484
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1485 #define FF(X,Y) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1486 {#X, Y, (void*)exp##X},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1487
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1488 struct exports exp_kernel32[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1489 FF(IsBadWritePtr, 357)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1490 FF(IsBadReadPtr, 354)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1491 FF(IsBadStringPtrW, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1492 FF(DisableThreadLibraryCalls, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1493 FF(CreateThread, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1494 FF(CreateEventA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1495 FF(SetEvent, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1496 FF(ResetEvent, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1497 FF(WaitForSingleObject, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1498 FF(GetSystemInfo, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1499 FF(GetVersion, 332)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1500 FF(HeapCreate, 461)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1501 FF(HeapAlloc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1502 FF(HeapDestroy, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1503 FF(HeapFree, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1504 FF(HeapSize, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1505 FF(GetProcessHeap, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1506 FF(VirtualAlloc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1507 FF(VirtualFree, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1508 FF(InitializeCriticalSection, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1509 FF(EnterCriticalSection, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1510 FF(LeaveCriticalSection, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1511 FF(DeleteCriticalSection, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1512 FF(TlsAlloc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1513 FF(TlsFree, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1514 FF(TlsGetValue, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1515 FF(TlsSetValue, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1516 FF(GetCurrentThreadId, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1517 FF(LocalAlloc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1518 FF(LocalLock, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1519 FF(GlobalAlloc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1520 FF(GlobalLock, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1521 FF(MultiByteToWideChar, 427)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1522 FF(WideCharToMultiByte, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1523 FF(GetVersionExA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1524 FF(CreateSemaphoreA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1525 FF(QueryPerformanceCounter, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1526 FF(QueryPerformanceFrequency, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1527 FF(LocalHandle, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1528 FF(LocalUnlock, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1529 FF(LocalFree, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1530 FF(GlobalHandle, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1531 FF(GlobalUnlock, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1532 FF(GlobalFree, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1533 FF(LoadResource, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1534 FF(ReleaseSemaphore, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1535 FF(FindResourceA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1536 FF(LockResource, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1537 FF(FreeResource, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1538 FF(SizeofResource, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1539 FF(CloseHandle, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1540 FF(GetCommandLineA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1541 FF(GetEnvironmentStringsW, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1542 FF(FreeEnvironmentStringsW, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1543 FF(GetEnvironmentStrings, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1544 FF(GetStartupInfoA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1545 FF(GetStdHandle, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1546 FF(GetFileType, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1547 FF(SetHandleCount, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1548 FF(GetACP, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1549 FF(GetModuleFileNameA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1550 FF(SetUnhandledExceptionFilter, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1551 FF(LoadLibraryA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1552 FF(GetProcAddress, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1553 FF(FreeLibrary, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1554 FF(CreateFileMappingA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1555 FF(OpenFileMappingA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1556 FF(MapViewOfFile, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1557 FF(UnmapViewOfFile, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1558 FF(Sleep, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1559 FF(GetModuleHandleA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1560 FF(GetPrivateProfileIntA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1561 FF(GetPrivateProfileStringA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1562 FF(WritePrivateProfileStringA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1563 FF(GetLastError, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1564 FF(SetLastError, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1565 FF(InterlockedIncrement, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1566 FF(InterlockedDecrement, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1567 FF(GetTimeZoneInformation, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1568 FF(OutputDebugStringA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1569 FF(GetLocalTime, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1570 FF(GetSystemTime, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1571 FF(GetEnvironmentVariableA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1572 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1573
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1574 struct exports exp_msvcrt[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1575 FF(malloc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1576 FF(_initterm, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1577 FF(free, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1578 {"??3@YAXPAX@Z", -1, expdelete},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1579 {"??2@YAPAXI@Z", -1, expnew},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1580 FF(strrchr, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1581 FF(strchr, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1582 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1583 struct exports exp_winmm[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1584 FF(GetDriverModuleHandle, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1585 FF(timeGetTime, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1586 FF(DefDriverProc, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1587 FF(OpenDriver, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1588 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1589 struct exports exp_user32[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1590 FF(LoadStringA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1591 FF(wsprintfA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1592 FF(GetDC, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1593 FF(GetDesktopWindow, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1594 FF(ReleaseDC, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1595 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1596 struct exports exp_advapi32[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1597 FF(RegOpenKeyA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1598 FF(RegOpenKeyExA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1599 FF(RegCreateKeyExA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1600 FF(RegQueryValueExA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1601 FF(RegSetValueExA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1602 FF(RegCloseKey, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1603 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1604 struct exports exp_gdi32[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1605 FF(CreateCompatibleDC, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1606 FF(GetDeviceCaps, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1607 FF(DeleteDC, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1608 FF(GetSystemPaletteEntries, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1609 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1610 struct exports exp_version[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1611 FF(GetFileVersionInfoSizeA, -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1612 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1613 #define LL(X) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1614 {#X".dll", sizeof(exp_##X)/sizeof(struct exports), exp_##X},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1615
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1616 struct libs libraries[]={
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1617 LL(kernel32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1618 LL(msvcrt)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1619 LL(winmm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1620 LL(user32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1621 LL(advapi32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1622 LL(gdi32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1623 LL(version)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1624 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1625
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1626 void* LookupExternal(const char* library, int ordinal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1627 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1628 char* answ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1629 int i,j;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1630 if(library==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1631 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1632 printf("ERROR: library=0\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1633 return (void*)ext_unknown;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1634 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1635 printf("External func %s:%d\n", library, ordinal);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1636 // printf("%x %x\n", &unk_exp1, &unk_exp2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1637
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1638 for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1639 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1640 if(strcasecmp(library, libraries[i].name))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1641 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1642 for(j=0; j<libraries[i].length; j++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1643 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1644 if(ordinal!=libraries[i].exps[j].id)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1645 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1646 printf("Hit: 0x%08X\n", libraries[i].exps[j].func);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1647 return libraries[i].exps[j].func;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1648 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1649 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1650 if(pos>150)return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1651 answ=(char*)extcode+pos*0x64;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1652 memcpy(answ, &unk_exp1, 0x64);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1653 *(int*)(answ+9)=pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1654 *(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1655 sprintf(export_names[pos], "%s:%d", library, ordinal);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1656 pos++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1657 return (void*)answ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1658 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1659
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1660 void* LookupExternalByName(const char* library, const char* name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1661 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1662 char* answ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1663 int i,j;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1664 // return (void*)ext_unknown;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1665 if(library==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1666 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1667 printf("ERROR: library=0\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1668 return (void*)ext_unknown;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1669 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1670 if(name==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1671 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1672 printf("ERROR: name=0\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1673 return (void*)ext_unknown;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1674 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1675 // printf("External func %s:%s\n", library, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1676 for(i=0; i<sizeof(libraries)/sizeof(struct libs); i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1677 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1678 if(strcasecmp(library, libraries[i].name))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1679 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1680 for(j=0; j<libraries[i].length; j++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1681 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1682 if(strcmp(name, libraries[i].exps[j].name))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1683 continue;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1684 // printf("Hit: 0x%08X\n", libraries[i].exps[j].func);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1685 return libraries[i].exps[j].func;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1686 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1687 }// printf("%x %x\n", &unk_exp1, &unk_exp2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1688 //printf("Missing (%d) External func %s:%s\n", pos, library, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1689 if(pos>150){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1690 // printf("Warning! Too many missing externals!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1691 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1692 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1693 strcpy(export_names[pos], name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1694 answ=(char*)extcode+pos*0x64;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1695 memcpy(answ, &unk_exp1, 0x64);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1696 *(int*)(answ+9)=pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1697 *(int*)(answ+47)-=((int)answ-(int)&unk_exp1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1698 pos++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1699 return (void*)answ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1700 // memcpy(extcode, &unk_exp1, 0x64);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1701 // *(int*)(extcode+52)-=((int)extcode-(int)&unk_exp1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1702 // return (void*)extcode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1703 // printf("Unknown func %s:%s\n", library, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1704 // return (void*)ext_unknown;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1705 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1706