summaryrefslogblamecommitdiffstats
path: root/private/mvdm/wow32/wkgthunk.c
blob: 7d6fb356bef1ea4dfa368803350a3ee4186a8242 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583






































































































































































































































































































































































































































































































































































































                                                                                   
/*++
 *
 *  WOW v1.0
 *
 *  Copyright (c) 1992, Microsoft Corporation
 *
 *  wkgthunk.C
 *  WOW32 Generic Thunk Mechanism (for OLE 2.0 and others)
 *
 *  History:
 *  Created 11-MARCH-1993 by Matt Felton (mattfe)
 *
--*/

#include "precomp.h"
#pragma hdrstop

MODNAME(wkgthunk.c);


HINSTANCE FASTCALL WK32LoadLibraryEx32(PVDMFRAME pFrame)
{
    PSZ psz1;
    HINSTANCE hinstance;
    PLOADLIBRARYEX32 parg16;

#ifdef i386
    BYTE FpuState[108];

    // Save the 487 state
    _asm {
        lea    ecx, [FpuState]
        fsave  [ecx]
    }
#endif

    GETARGPTR(pFrame, sizeof(LOADLIBRARYEX32), parg16);
    GETVDMPTR(parg16->lpszLibFile,0,psz1);

    //
    // Make sure the Win32 current directory matches this task's.
    //

    UpdateDosCurrentDirectory(DIR_DOS_TO_NT);

    hinstance = LoadLibraryEx(psz1, (HANDLE)parg16->hFile, parg16->dwFlags);

    FREEARGPTR(parg16);

#ifdef i386
    // Restore the 487 state
    _asm {
        lea    ecx, [FpuState]
        frstor [ecx]
    }
#endif

    return (hinstance);
}


BOOL FASTCALL WK32FreeLibrary32(PVDMFRAME pFrame)
{
    BOOL fResult;
    PFREELIBRARY32 parg16;

    GETARGPTR(pFrame, sizeof(FREELIBRARY32), parg16);

    fResult = FreeLibrary((HMODULE)parg16->hLibModule);

    FREEARGPTR(parg16);
    return (fResult);
}


FARPROC FASTCALL WK32GetProcAddress32(PVDMFRAME pFrame)
{
    FARPROC lpAddress;
    PSZ psz1;
    PGETPROCADDRESS32 parg16;

    GETARGPTR(pFrame, sizeof(GETPROCADDRESS32), parg16);
    GETPSZIDPTR(parg16->lpszProc, psz1);

    lpAddress = GetProcAddress((HMODULE)parg16->hModule, psz1);

    FREEARGPTR(parg16);
    return (lpAddress);
}


LPVOID FASTCALL WK32GetVDMPointer32(PVDMFRAME pFrame)
{
    LPVOID lpAddress;
    PGETVDMPOINTER32 parg16;

    GETARGPTR(pFrame, sizeof(GETVDMPOITNER32), parg16);

    lpAddress = WOWGetVDMPointer(parg16->lpAddress, 0, parg16->fMode);

    FREEARGPTR(parg16);
    return(lpAddress);
}


DWORD FASTCALL WK32ICallProc32(PVDMFRAME pFrame)
{
    register DWORD dwReturn;
    PICALLPROC32 parg16;
    UNALIGNED DWORD *pArg;
    DWORD  fAddress;
    BOOL    fSourceCDECL;
    BOOL    fDestCDECL;
    UINT    cParams;
    UINT    nParam;
    UNALIGNED DWORD *lpArgs;
    DWORD   dwTemp[32];

    GETARGPTR(pFrame, sizeof(*parg16), parg16);

    fSourceCDECL = HIWORD(parg16->cParams) & CPEX32_SOURCE_CDECL;
    fDestCDECL =   HIWORD(parg16->cParams) & CPEX32_DEST_CDECL;

    // We only support up to 32 parameters

    cParams = LOWORD(parg16->cParams);

    if (cParams > 32)
	return(0);

    // Don't call to Zero

    if (parg16->lpProcAddress == 0) {
	LOGDEBUG(LOG_ALWAYS,("WK32ICallProc32 - Error calling to 0 not allowed"));
	return(0);
    }

    lpArgs = &parg16->p1;

    // Convert Any 16:16 Addresses to 32 bit
    // flat as required by fAddressConvert

    pArg = lpArgs;

    fAddress = parg16->fAddressConvert;

    while (fAddress != 0) {
        if (fAddress & 0x1) {
            *pArg = (DWORD) GetPModeVDMPointer(*pArg, 0);
        }
        pArg++;
        fAddress = fAddress >> 1;
    }

    //
    // The above code is funny.  It means that parameter translation will
    // occur before accounting for the calling convention.  This means that
    // they will be specifying the bit position for pascal by counting the
    // parameters from the end, whereas with cdecl, they count from the
    // beginning.  Weird for pascal, but that is compatible with what we've
    // already shipped.  cdecl should be more understandable.
    //
    // The above comment applies to CallProc32W, for CallProc32ExW,
    // the lowest bit position always refers to the leftmost parameter.
    //

    //
    // Make sure the Win32 current directory matches this task's.
    //

    UpdateDosCurrentDirectory(DIR_DOS_TO_NT);


#ifdef i386

    {
        extern DWORD WK32ICallProc32MakeCall(DWORD pfn, DWORD cArgs, VOID *pArgs);

        //
        // On x86 we call an assembly routine to actually make the call to
        // the client's Win32 routine.  The code is much more compact
        // this way, and it's the only way we can be compatible with
        // Win95's implementation, which cleans up the stack if the
        // routine doesn't.
        //
        // This assembly routine "pushes" the arguments by copying
        // them as a block, so they must be in the proper order for
        // the destination calling convention.
        //

        if ( ! fSourceCDECL) {
            //
            // Invert the parameters
            //
            pArg = lpArgs;
            lpArgs = dwTemp;

            nParam = cParams;
            while ( nParam != 0 ) {
                --nParam;
                lpArgs[nParam] = *pArg;
                pArg++;
            }
        }

        dwReturn = WK32ICallProc32MakeCall(parg16->lpProcAddress, cParams, lpArgs);
    }

#else

    if ( fSourceCDECL != fDestCDECL ) {
        //
        // Invert the parameters
        //
        pArg = lpArgs;
        lpArgs = dwTemp;

        nParam = cParams;
        while ( nParam != 0 ) {
            --nParam;
            lpArgs[nParam] = *pArg;
            pArg++;
        }
    }

    //
    // lpArgs now points to the very first parameter in any calling convention
    // And all of the parameters have been appropriately converted to flat ptrs
    //

    if ( fDestCDECL ) {
        typedef int (FAR WINAPIV *FARFUNC)();

        dwReturn = ((FARFUNC)parg16->lpProcAddress)(
                        lpArgs[ 0], lpArgs[ 1], lpArgs[ 2], lpArgs[ 3],
                        lpArgs[ 4], lpArgs[ 5], lpArgs[ 6], lpArgs[ 7],
                        lpArgs[ 8], lpArgs[ 9], lpArgs[10], lpArgs[11],
                        lpArgs[12], lpArgs[13], lpArgs[14], lpArgs[15],
                        lpArgs[16], lpArgs[17], lpArgs[18], lpArgs[19],
                        lpArgs[20], lpArgs[21], lpArgs[22], lpArgs[23],
                        lpArgs[24], lpArgs[25], lpArgs[26], lpArgs[27],
                        lpArgs[28], lpArgs[29], lpArgs[30], lpArgs[31] );
    } else {
        //
        // There HAS to be a better way for portable variable number of
        // Arguments
        //
        switch(cParams) {

        	case 0:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)();
        	    break;
        	case 1:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[ 0] );
        	    break;
        	case 2:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[ 1], lpArgs[ 0] );
        	    break;
        	case 3:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;
        	case 4:

        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;
        	case 5:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;
        	case 6:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;
        	case 7:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;
        	case 8:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 9:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 10:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 11:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 12:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 13:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 14:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 15:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;


        	case 16:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 17:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 18:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 19:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 20:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 21:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 22:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 23:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 24:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 25:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 26:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 27:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[26], lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 28:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[27], lpArgs[26], lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 29:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                            lpArgs[28],
                        lpArgs[27], lpArgs[26], lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 30:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                                lpArgs[29], lpArgs[28],
                        lpArgs[27], lpArgs[26], lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 31:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                                    lpArgs[30], lpArgs[29], lpArgs[28],
                        lpArgs[27], lpArgs[26], lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        	case 32:
        	    dwReturn = ((FARPROC)parg16->lpProcAddress)(
                        lpArgs[31], lpArgs[30], lpArgs[29], lpArgs[28],
                        lpArgs[27], lpArgs[26], lpArgs[25], lpArgs[24],
                        lpArgs[23], lpArgs[22], lpArgs[21], lpArgs[20],
                        lpArgs[19], lpArgs[18], lpArgs[17], lpArgs[16],
                        lpArgs[15], lpArgs[14], lpArgs[13], lpArgs[12],
                        lpArgs[11], lpArgs[10], lpArgs[ 9], lpArgs[ 8],
                        lpArgs[ 7], lpArgs[ 6], lpArgs[ 5], lpArgs[ 4],
                        lpArgs[ 3], lpArgs[ 2], lpArgs[ 1], lpArgs[ 0] );
        	    break;

        }
    }

#endif


    FREEARGPTR(parg16);
    return(dwReturn);
}


//
// Chicago has WOWGetVDMPointerFix, which is just like WOWGetVDMPointer
// but also calls GlobalFix to keep the 16-bit memory from moving.  It
// has a companion WOWGetVDMPointerUnfix, which is basically a Win32-callable
// GlobalUnfix.
//
// Chicago found the need for these functions because their global heaps
// can be rearranged while Win32 code called from a generic thunk is
// executing.  In Windows NT, global memory cannot move while in a thunk
// unless the thunk calls back to the 16-bit side.
//
// Our exported WOWGetVDMPointerFix is simply an alias to WOWGetVDMPointer --
// it does *not* call GlobalFix because it is not needed in 99% of the
// cases.  WOWGetVDMPointerUnfix is implemented below as NOP.
//

VOID WOWGetVDMPointerUnfix(VPVOID vp)
{
    UNREFERENCED_PARAMETER(vp);

    return;
}


//
// Yielding functions allow 32-bit thunks to avoid 4 16<-->32 transitions
// involved in calling back to 16-bit side to call Yield or DirectedYield,
// which are thunked back to user32.
//

VOID WOWYield16(VOID)
{
    //
    // Since WK32Yield (the thunk for Yield) doesn't use pStack16,
    // just call it rather than duplicate the code.
    //

    WK32Yield(NULL);
}

VOID WOWDirectedYield16(WORD hTask16)
{
    //
    // This is duplicating the code of WK32DirectedYield, the
    // two must be kept synchronized.
    //

    BlockWOWIdle(TRUE);

    (pfnOut.pfnDirectedYield)(THREADID32(hTask16));

    BlockWOWIdle(FALSE);
}