1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#include <xplatform.h>
6#include <stdio.h>
7
8UINT_PTR uintPtrManaged = 1000;
9UINT_PTR uintPtrNative = 2000;
10UINT_PTR uintPtrReturn = 3000;
11UINT_PTR uintPtrErrReturn = 4000;
12
13//
14// PInvokeUIntPtrTest.cs declares that all of these APIs use STDCALL.
15//
16extern "C" DLL_EXPORT UINT_PTR STDMETHODCALLTYPE Marshal_In(/*[in]*/UINT_PTR uintPtr)
17{
18 //Check the input
19 if(uintPtr != uintPtrManaged)
20 {
21 printf("Error in Function Marshal_In(Native Client)\n");
22
23 //Return the error value instead if verification failed
24 return uintPtrErrReturn;
25 }
26
27 return uintPtrReturn;
28}
29
30extern "C" DLL_EXPORT UINT_PTR STDMETHODCALLTYPE Marshal_InOut(/*[In,Out]*/UINT_PTR uintPtr)
31{
32 //Check the input
33 if(uintPtr != uintPtrManaged)
34 {
35 printf("Error in Function Marshal_In(Native Client)\n");
36
37 //Return the error value instead if verification failed
38 return uintPtrErrReturn;
39 }
40
41 //In-Place Change
42 uintPtr = uintPtrNative;
43
44 //Return
45 return uintPtrReturn;
46}
47
48extern "C" DLL_EXPORT UINT_PTR STDMETHODCALLTYPE Marshal_Out(/*[Out]*/UINT_PTR uintPtr)
49{
50 uintPtr = uintPtrNative;
51
52 //Return
53 return uintPtrReturn;
54}
55
56extern "C" DLL_EXPORT UINT_PTR STDMETHODCALLTYPE MarshalPointer_In(/*[in]*/UINT_PTR *puintPtr)
57{
58 //Check the input
59 if(*puintPtr != uintPtrManaged)
60 {
61 printf("Error in Function Marshal_In(Native Client)\n");
62 //Return the error value instead if verification failed
63 return uintPtrErrReturn;
64 }
65
66 return uintPtrReturn;
67}
68
69extern "C" DLL_EXPORT UINT_PTR STDMETHODCALLTYPE MarshalPointer_InOut(/*[in,out]*/UINT_PTR *puintPtr)
70{
71 //Check the input
72 if(*puintPtr != uintPtrManaged)
73 {
74 printf("Error in Function Marshal_In(Native Client)\n");
75 //Return the error value instead if verification failed
76 return uintPtrErrReturn;
77 }
78
79 //In-Place Change
80 *puintPtr = uintPtrNative;
81
82 //Return
83 return uintPtrReturn;
84}
85
86extern "C" DLL_EXPORT UINT_PTR STDMETHODCALLTYPE MarshalPointer_Out(/*[out]*/ UINT_PTR *puintPtr)
87{
88 *puintPtr = uintPtrNative;
89
90 //Return
91 return uintPtrReturn;
92}
93