| 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 <platformdefines.h> |
| 7 | #include "SeqStructDelRevPInvokeNative.h" |
| 8 | |
| 9 | const char* NativeStr = "Native" ; |
| 10 | //const size_t size = strlen(NativeStr); |
| 11 | |
| 12 | struct ScriptParamType |
| 13 | { |
| 14 | int idata; |
| 15 | int useless; //Use this as pedding, since in the Manage code,the union starts at offset 8 |
| 16 | union unionType |
| 17 | { |
| 18 | bool bdata; |
| 19 | double ddata; |
| 20 | int * ptrdata; |
| 21 | }udata; |
| 22 | }; |
| 23 | |
| 24 | struct ComplexStruct |
| 25 | { |
| 26 | INT i; |
| 27 | CHAR b; |
| 28 | LPCSTR str; |
| 29 | //use this(padding), since in the Mac, it use 4bytes as struct pack(In windows, it is 8 bytes). |
| 30 | //if i dont add this. In Mac, it will try to replace the value of (pedding) with idata's value |
| 31 | LPVOID padding;//padding |
| 32 | ScriptParamType type; |
| 33 | }; |
| 34 | |
| 35 | |
| 36 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructComplexStructByRef_Cdecl(ComplexStruct * pcs) |
| 37 | { |
| 38 | //Check the Input |
| 39 | if((321 != pcs->i)||(!pcs->b)||(0 != strcmp(pcs->str,"Managed" ))||(123 != pcs->type.idata)||(0x120000 != (int)(LONG64)(pcs->type.udata.ptrdata))) |
| 40 | { |
| 41 | |
| 42 | printf("The parameter for MarshalRefStruct_Cdecl is wrong\n" ); |
| 43 | printf("ComplexStruct:%d:%d,%s,%d,%d\n" ,pcs->i,pcs->b,pcs->str,pcs->type.idata,(int)(LONG64)(pcs->type.udata.ptrdata)); |
| 44 | return FALSE; |
| 45 | } |
| 46 | CoreClrFree((LPVOID)pcs->str); |
| 47 | |
| 48 | const char* lNativeStr = "Native" ; |
| 49 | const size_t lsize = strlen(lNativeStr); |
| 50 | char * pstr = (char*)CoreClrAlloc((lsize + 1) * sizeof(char)); |
| 51 | memset(pstr,0,lsize+1); |
| 52 | |
| 53 | strncpy_s(pstr,lsize+1,lNativeStr,lsize); |
| 54 | |
| 55 | //Change the value |
| 56 | pcs->i = 9999; |
| 57 | pcs->b = false; |
| 58 | pcs->str = pstr; |
| 59 | pcs->type.idata = -1; |
| 60 | pcs->type.udata.ddata = 3.14159; |
| 61 | |
| 62 | return TRUE; |
| 63 | } |
| 64 | |
| 65 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructComplexStructByRef_StdCall(ComplexStruct * pcs) |
| 66 | { |
| 67 | //Check the input |
| 68 | if((321 != pcs->i)||(!pcs->b)||(0 != strcmp(pcs->str,"Managed" ))||(123 != pcs->type.idata)||(0x120000 != (int)(LONG64)(pcs->type.udata.ptrdata))) |
| 69 | { |
| 70 | printf("The parameter for MarshalRefStruct_StdCall is wrong\n" ); |
| 71 | return FALSE; |
| 72 | } |
| 73 | CoreClrFree((LPVOID)pcs->str); |
| 74 | |
| 75 | const char* lNativeStr = "Native" ; |
| 76 | const size_t lsize = strlen(lNativeStr); |
| 77 | char * pstr = (char*)CoreClrAlloc(lsize + 1); |
| 78 | memset(pstr,0,lsize+1); |
| 79 | strncpy_s(pstr,lsize+1,lNativeStr,lsize); |
| 80 | |
| 81 | //Change the value |
| 82 | pcs->i = 9999; |
| 83 | pcs->b = false; |
| 84 | pcs->str = pstr; |
| 85 | pcs->type.idata = -1; |
| 86 | pcs->type.udata.ddata = 3.14159; |
| 87 | |
| 88 | return TRUE; |
| 89 | } |
| 90 | |
| 91 | typedef BOOL (_cdecl *ComplexStructByRefCdeclCaller)(ComplexStruct* pcs); |
| 92 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructComplexStructByRef_Cdecl(ComplexStructByRefCdeclCaller caller) |
| 93 | { |
| 94 | const char* lNativeStr = "Native" ; |
| 95 | const size_t lsize = strlen(lNativeStr); |
| 96 | |
| 97 | //Init |
| 98 | char * pstr = (char*)CoreClrAlloc(lsize + 1); |
| 99 | memset(pstr,0,lsize+1); |
| 100 | strncpy_s(pstr,lsize+1,lNativeStr,lsize); |
| 101 | |
| 102 | ComplexStruct cs; |
| 103 | cs.i = 9999; |
| 104 | cs.b = false; |
| 105 | cs.str = pstr; |
| 106 | cs.type.idata = -1; |
| 107 | cs.type.udata.ddata = 3.14159; |
| 108 | |
| 109 | if(!caller(&cs)) |
| 110 | { |
| 111 | printf("DoCallBack_MarshalByRefStruct_Cdecl:The Caller return wrong value!\n" ); |
| 112 | return FALSE; |
| 113 | } |
| 114 | |
| 115 | if((321 != cs.i)||(!cs.b)||(0 != strcmp(cs.str,"Managed" ))||(123 != cs.type.idata)||(0x120000 != (int)(LONG64)(cs.type.udata.ptrdata))) |
| 116 | { |
| 117 | printf("The parameter for DoCallBack_MarshalRefStruct_Cdecl is wrong\n" ); |
| 118 | return FALSE; |
| 119 | } |
| 120 | CoreClrFree((LPVOID)cs.str); |
| 121 | return TRUE; |
| 122 | } |
| 123 | |
| 124 | typedef BOOL (__stdcall *ComplexStructByRefStdCallCaller)(ComplexStruct* pcs); |
| 125 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructComplexStructByRef_StdCall(ComplexStructByRefStdCallCaller caller) |
| 126 | { |
| 127 | const char* lNativeStr = "Native" ; |
| 128 | const size_t lsize = strlen(lNativeStr); |
| 129 | |
| 130 | //init |
| 131 | char * pstr = (char*)CoreClrAlloc(lsize + 1); |
| 132 | memset(pstr,0,lsize+1); |
| 133 | strncpy_s(pstr,lsize+1,lNativeStr,lsize); |
| 134 | |
| 135 | ComplexStruct cs; |
| 136 | cs.i = 9999; |
| 137 | cs.b = false; |
| 138 | cs.str = pstr; |
| 139 | cs.type.idata = -1; |
| 140 | cs.type.udata.ddata = 3.14159; |
| 141 | |
| 142 | if(!caller(&cs)) |
| 143 | { |
| 144 | printf("DoCallBack_MarshalByRefStruct_StdCall:The Caller returns wrong value\n" ); |
| 145 | return FALSE; |
| 146 | } |
| 147 | |
| 148 | if((321 != cs.i)||(!cs.b)||(0 != strcmp(cs.str,"Managed" ))||(123 != cs.type.idata)||(0x120000 != (int)(LONG64)(cs.type.udata.ptrdata))) |
| 149 | { |
| 150 | printf("The parameter for DoCallBack_MarshalRefStruct_StdCall is wrong\n" ); |
| 151 | return FALSE; |
| 152 | } |
| 153 | CoreClrFree((LPVOID)cs.str); |
| 154 | return TRUE; |
| 155 | } |
| 156 | //Delegate PInvoke,passbyref |
| 157 | typedef BOOL (_cdecl *ComplexStructDelegatePInvokeByRefCdeclCaller)(ComplexStruct* pcs); |
| 158 | extern "C" DLL_EXPORT ComplexStructDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructComplexStructByRef_Cdecl_FuncPtr() |
| 159 | { |
| 160 | return MarshalStructComplexStructByRef_Cdecl; |
| 161 | } |
| 162 | |
| 163 | typedef BOOL (__stdcall *ComplexStructDelegatePInvokeByRefStdCallCaller)(ComplexStruct* pcs); |
| 164 | extern "C" DLL_EXPORT ComplexStructDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructComplexStructByRef_StdCall_FuncPtr() |
| 165 | { |
| 166 | return MarshalStructComplexStructByRef_StdCall; |
| 167 | } |
| 168 | |
| 169 | //Passby value |
| 170 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructComplexStructByVal_Cdecl(ComplexStruct cs) |
| 171 | { |
| 172 | //Check the Input |
| 173 | if((321 != cs.i)||(!cs.b)||(0 != strcmp(cs.str,"Managed" ))||(123 != cs.type.idata)||(0x120000 != (int)(LONG64)(cs.type.udata.ptrdata))) |
| 174 | { |
| 175 | |
| 176 | printf("The parameter for MarshalStructComplexStructByVal_Cdecl is wrong\n" ); |
| 177 | printf("ComplexStruct:%d:%d,%s,%d,%d\n" ,cs.i,cs.b,cs.str,cs.type.idata,(int)(LONG64)(cs.type.udata.ptrdata)); |
| 178 | return FALSE; |
| 179 | } |
| 180 | |
| 181 | cs.i = 9999; |
| 182 | cs.b = false; |
| 183 | cs.str = "Native" ; |
| 184 | cs.type.idata = -1; |
| 185 | cs.type.udata.ddata = 3.14159; |
| 186 | |
| 187 | return TRUE; |
| 188 | } |
| 189 | |
| 190 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructComplexStructByVal_StdCall(ComplexStruct cs) |
| 191 | { |
| 192 | //Check the input |
| 193 | if((321 != cs.i)||(!cs.b)||(0 != strcmp(cs.str,"Managed" ))||(123 != cs.type.idata)||(0x120000 != (int)(LONG64)(cs.type.udata.ptrdata))) |
| 194 | { |
| 195 | printf("The parameter for MarshalStructComplexStructByVal_StdCall is wrong\n" ); |
| 196 | return FALSE; |
| 197 | } |
| 198 | |
| 199 | cs.i = 9999; |
| 200 | cs.b = false; |
| 201 | cs.str = "Native" ; |
| 202 | cs.type.idata = -1; |
| 203 | cs.type.udata.ddata = 3.14159; |
| 204 | |
| 205 | return TRUE; |
| 206 | } |
| 207 | |
| 208 | typedef BOOL (_cdecl *ComplexStructByValCdeclCaller)(ComplexStruct cs); |
| 209 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructComplexStructByVal_Cdecl(ComplexStructByValCdeclCaller caller) |
| 210 | { |
| 211 | //Init |
| 212 | ComplexStruct cs; |
| 213 | cs.i = 9999; |
| 214 | cs.b = false; |
| 215 | cs.str = "Native" ; |
| 216 | cs.type.idata = -1; |
| 217 | cs.type.udata.ddata = 3.14159; |
| 218 | |
| 219 | if(!caller(cs)) |
| 220 | { |
| 221 | printf("DoCallBack_MarshalStructComplexStructByVal_Cdecl:The Caller returns wrong value\n" ); |
| 222 | return FALSE; |
| 223 | } |
| 224 | |
| 225 | //Verify the value unchanged |
| 226 | if((9999 != cs.i)||(cs.b)||(0 != strcmp(cs.str,NativeStr))||(-1 != cs.type.idata)||(3.14159 != cs.type.udata.ddata)) |
| 227 | { |
| 228 | printf("The parameter for DoCallBack_MarshalByValStruct_Cdecl is wrong\n" ); |
| 229 | return FALSE; |
| 230 | } |
| 231 | return TRUE; |
| 232 | } |
| 233 | |
| 234 | typedef BOOL (__stdcall *ComplexStructByValStdCallCaller)(ComplexStruct cs); |
| 235 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructComplexStructByVal_StdCall(ComplexStructByValStdCallCaller caller) |
| 236 | { |
| 237 | ComplexStruct cs; |
| 238 | cs.i = 9999; |
| 239 | cs.b = false; |
| 240 | cs.str = "Native" ; |
| 241 | cs.type.idata = -1; |
| 242 | cs.type.udata.ddata = 3.14159; |
| 243 | |
| 244 | if(!caller(cs)) |
| 245 | { |
| 246 | printf("The parameter for DoCallBack_MarshalStructComplexStructByVal_StdCall is wrong\n" ); |
| 247 | return FALSE; |
| 248 | } |
| 249 | |
| 250 | //Verify the value unchanged |
| 251 | if((9999 != cs.i)||(cs.b)||(0 != strcmp(cs.str,NativeStr))||(-1 != cs.type.idata)||(3.14159 != cs.type.udata.ddata)) |
| 252 | { |
| 253 | printf("DoCallBack_MarshalStructComplexStructByVal_StdCall:The Caller returns wrong value\n" ); |
| 254 | return FALSE; |
| 255 | } |
| 256 | return TRUE; |
| 257 | } |
| 258 | //Delegate PInvoke,passbyref |
| 259 | typedef BOOL (_cdecl *ComplexStructDelegatePInvokeByValCdeclCaller)(ComplexStruct cs); |
| 260 | extern "C" DLL_EXPORT ComplexStructDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructComplexStructByVal_Cdecl_FuncPtr() |
| 261 | { |
| 262 | return MarshalStructComplexStructByVal_Cdecl; |
| 263 | } |
| 264 | |
| 265 | typedef BOOL (__stdcall *ComplexStructDelegatePInvokeByValStdCallCaller)(ComplexStruct cs); |
| 266 | extern "C" DLL_EXPORT ComplexStructDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructComplexStructByVal_StdCall_FuncPtr() |
| 267 | { |
| 268 | return MarshalStructComplexStructByVal_StdCall; |
| 269 | } |
| 270 | |
| 271 | ///////////////////////////////////////////Methods for InnerSequential struct//////////////////////////////////////////////////// |
| 272 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructInnerSequentialByRef_Cdecl(InnerSequential* argstr) |
| 273 | { |
| 274 | if(!IsCorrectInnerSequential(argstr)) |
| 275 | { |
| 276 | printf("\tMarshalStructInnerSequentialByRef_Cdecl: InnerSequential param not as expected\n" ); |
| 277 | PrintInnerSequential(argstr,"argstr" ); |
| 278 | return FALSE; |
| 279 | } |
| 280 | ChangeInnerSequential(argstr); |
| 281 | return TRUE; |
| 282 | } |
| 283 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructInnerSequentialByRef_StdCall(InnerSequential* argstr) |
| 284 | { |
| 285 | if(!IsCorrectInnerSequential(argstr)) |
| 286 | { |
| 287 | printf("\tMarshalStructInnerSequentialByRef_StdCall: InnerSequential param not as expected\n" ); |
| 288 | PrintInnerSequential(argstr,"argstr" ); |
| 289 | return FALSE; |
| 290 | } |
| 291 | ChangeInnerSequential(argstr); |
| 292 | return TRUE; |
| 293 | } |
| 294 | typedef BOOL (_cdecl *InnerSequentialByRefCdeclCaller)(InnerSequential* pcs); |
| 295 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructInnerSequentialByRef_Cdecl(InnerSequentialByRefCdeclCaller caller) |
| 296 | { |
| 297 | //Init |
| 298 | InnerSequential argstr; |
| 299 | argstr.f1 = 77; |
| 300 | argstr.f2 = 77.0; |
| 301 | const char* lpstr = "changed string" ; |
| 302 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 303 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 304 | memset(temp, 0, size); |
| 305 | if(temp) |
| 306 | { |
| 307 | strcpy_s((char*)temp,size,lpstr); |
| 308 | argstr.f3 = temp; |
| 309 | } |
| 310 | |
| 311 | if(!caller(&argstr)) |
| 312 | { |
| 313 | printf("DoCallBack_MarshalStructInnerSequentialByRef_Cdecl:The Caller returns wrong value\n" ); |
| 314 | return FALSE; |
| 315 | } |
| 316 | //Verify the value unchanged |
| 317 | if(!IsCorrectInnerSequential(&argstr)) |
| 318 | { |
| 319 | printf("The parameter for DoCallBack_MarshalStructInnerSequentialByRef_Cdecl is wrong\n" ); |
| 320 | return FALSE; |
| 321 | } |
| 322 | return TRUE; |
| 323 | } |
| 324 | |
| 325 | typedef BOOL (__stdcall *InnerSequentialByRefStdCallCaller)(InnerSequential* pcs); |
| 326 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructInnerSequentialByRef_StdCall(InnerSequentialByRefStdCallCaller caller) |
| 327 | { |
| 328 | //Init |
| 329 | InnerSequential argstr; |
| 330 | argstr.f1 = 77; |
| 331 | argstr.f2 = 77.0; |
| 332 | const char* lpstr = "changed string" ; |
| 333 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 334 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 335 | memset(temp, 0, size); |
| 336 | if(temp) |
| 337 | { |
| 338 | strcpy_s((char*)temp,size,lpstr); |
| 339 | argstr.f3 = temp; |
| 340 | } |
| 341 | |
| 342 | if(!caller(&argstr)) |
| 343 | { |
| 344 | printf("DoCallBack_MarshalStructInnerSequentialByRef_StdCall:The Caller returns wrong value\n" ); |
| 345 | return FALSE; |
| 346 | } |
| 347 | //Verify the value unchanged |
| 348 | if(!IsCorrectInnerSequential(&argstr)) |
| 349 | { |
| 350 | printf("The parameter for DoCallBack_MarshalStructInnerSequentialByRef_StdCall is wrong\n" ); |
| 351 | return FALSE; |
| 352 | } |
| 353 | return TRUE; |
| 354 | } |
| 355 | //Delegate PInvoke,passbyref |
| 356 | typedef BOOL (_cdecl *InnerSequentialDelegatePInvokeByRefCdeclCaller)(InnerSequential* pcs); |
| 357 | extern "C" DLL_EXPORT InnerSequentialDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructInnerSequentialByRef_Cdecl_FuncPtr() |
| 358 | { |
| 359 | return MarshalStructInnerSequentialByRef_Cdecl; |
| 360 | } |
| 361 | |
| 362 | typedef BOOL (__stdcall *InnerSequentialDelegatePInvokeByRefStdCallCaller)(InnerSequential* pcs); |
| 363 | extern "C" DLL_EXPORT InnerSequentialDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructInnerSequentialByRef_StdCall_FuncPtr() |
| 364 | { |
| 365 | return MarshalStructInnerSequentialByRef_StdCall; |
| 366 | } |
| 367 | |
| 368 | |
| 369 | //Passby value |
| 370 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructInnerSequentialByVal_Cdecl(InnerSequential argstr) |
| 371 | { |
| 372 | //Check the Input |
| 373 | if(!IsCorrectInnerSequential(&argstr)) |
| 374 | { |
| 375 | printf("\tMarshalStructInnerSequentialByVal_Cdecl: InnerSequential param not as expected\n" ); |
| 376 | PrintInnerSequential(&argstr,"argstr" ); |
| 377 | return FALSE; |
| 378 | } |
| 379 | |
| 380 | argstr.f1 = 77; |
| 381 | argstr.f2 = 77.0; |
| 382 | const char* lpstr = "changed string" ; |
| 383 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 384 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 385 | memset(temp, 0, size); |
| 386 | if(temp) |
| 387 | { |
| 388 | strcpy_s((char*)temp,size,lpstr); |
| 389 | argstr.f3 = temp; |
| 390 | } |
| 391 | return TRUE; |
| 392 | } |
| 393 | |
| 394 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructInnerSequentialByVal_StdCall(InnerSequential argstr) |
| 395 | { |
| 396 | //Check the Input |
| 397 | if(!IsCorrectInnerSequential(&argstr)) |
| 398 | { |
| 399 | printf("\tMarshalStructInnerSequentialByVal_StdCall: InnerSequential param not as expected\n" ); |
| 400 | PrintInnerSequential(&argstr,"argstr" ); |
| 401 | return FALSE; |
| 402 | } |
| 403 | |
| 404 | argstr.f1 = 77; |
| 405 | argstr.f2 = 77.0; |
| 406 | const char* lpstr = "changed string" ; |
| 407 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 408 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 409 | memset(temp, 0, size); |
| 410 | if(temp) |
| 411 | { |
| 412 | strcpy_s((char*)temp,size,lpstr); |
| 413 | argstr.f3 = temp; |
| 414 | } |
| 415 | return TRUE; |
| 416 | } |
| 417 | |
| 418 | typedef BOOL (_cdecl *InnerSequentialByValCdeclCaller)(InnerSequential cs); |
| 419 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructInnerSequentialByVal_Cdecl(InnerSequentialByValCdeclCaller caller) |
| 420 | { |
| 421 | //Init |
| 422 | InnerSequential argstr{}; |
| 423 | argstr.f1 = 77; |
| 424 | argstr.f2 = 77.0; |
| 425 | const char* lpstr = "changed string" ; |
| 426 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 427 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 428 | memset(temp, 0, size); |
| 429 | if(temp) |
| 430 | { |
| 431 | strcpy_s((char*)temp,size,lpstr); |
| 432 | argstr.f3 = temp; |
| 433 | } |
| 434 | |
| 435 | if(!caller(argstr)) |
| 436 | { |
| 437 | printf("DoCallBack_MarshalStructInnerSequentialByVal_Cdecl:The Caller returns wrong value\n" ); |
| 438 | return FALSE; |
| 439 | } |
| 440 | |
| 441 | //Verify the value unchanged |
| 442 | if(argstr.f1 != 77 || argstr.f2 != 77.0 || strcmp((char*)argstr.f3, "changed string" ) != 0) |
| 443 | { |
| 444 | printf("The parameter for DoCallBack_MarshalStructInnerSequentialByVal_Cdecl is wrong\n" ); |
| 445 | return FALSE; |
| 446 | } |
| 447 | return TRUE; |
| 448 | } |
| 449 | |
| 450 | typedef BOOL (__stdcall *InnerSequentialByValStdCallCaller)(InnerSequential cs); |
| 451 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructInnerSequentialByVal_StdCall(InnerSequentialByValStdCallCaller caller) |
| 452 | { |
| 453 | //Init |
| 454 | InnerSequential argstr{}; |
| 455 | argstr.f1 = 77; |
| 456 | argstr.f2 = 77.0; |
| 457 | const char* lpstr = "changed string" ; |
| 458 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 459 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 460 | memset(temp, 0, size); |
| 461 | if(temp) |
| 462 | { |
| 463 | strcpy_s((char*)temp,size,lpstr); |
| 464 | argstr.f3 = temp; |
| 465 | } |
| 466 | |
| 467 | if(!caller(argstr)) |
| 468 | { |
| 469 | printf("DoCallBack_MarshalStructInnerSequentialByVal_StdCall:The Caller returns wrong value\n" ); |
| 470 | return FALSE; |
| 471 | } |
| 472 | |
| 473 | //Verify the value unchanged |
| 474 | if(argstr.f1 != 77 || argstr.f2 != 77.0 || strcmp((char*)argstr.f3, "changed string" ) != 0) |
| 475 | { |
| 476 | printf("The parameter for DoCallBack_MarshalStructInnerSequentialByVal_StdCall is wrong\n" ); |
| 477 | return FALSE; |
| 478 | } |
| 479 | return TRUE; |
| 480 | } |
| 481 | //Delegate PInvoke,passbyval |
| 482 | typedef BOOL (_cdecl *InnerSequentialDelegatePInvokeByValCdeclCaller)(InnerSequential cs); |
| 483 | extern "C" DLL_EXPORT InnerSequentialDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructInnerSequentialByVal_Cdecl_FuncPtr() |
| 484 | { |
| 485 | return MarshalStructInnerSequentialByVal_Cdecl; |
| 486 | } |
| 487 | |
| 488 | typedef BOOL (__stdcall *InnerSequentialDelegatePInvokeByValStdCallCaller)(InnerSequential cs); |
| 489 | extern "C" DLL_EXPORT InnerSequentialDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructInnerSequentialByVal_StdCall_FuncPtr() |
| 490 | { |
| 491 | return MarshalStructInnerSequentialByVal_StdCall; |
| 492 | } |
| 493 | |
| 494 | |
| 495 | ///////////////////////////////////////////Methods for InnerArraySequential struct//////////////////////////////////////////////////// |
| 496 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructInnerArraySequentialByRef_Cdecl(InnerArraySequential* argstr) |
| 497 | { |
| 498 | if(!IsCorrectInnerArraySequential(argstr)) |
| 499 | { |
| 500 | printf("\tMarshalStructInnerArraySequentialByRef_Cdecl: InnerArraySequential param not as expected\n" ); |
| 501 | PrintInnerArraySequential(argstr,"argstr" ); |
| 502 | return FALSE; |
| 503 | } |
| 504 | ChangeInnerArraySequential(argstr); |
| 505 | return TRUE; |
| 506 | } |
| 507 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructInnerArraySequentialByRef_StdCall(InnerArraySequential* argstr) |
| 508 | { |
| 509 | if(!IsCorrectInnerArraySequential(argstr)) |
| 510 | { |
| 511 | printf("\tMarshalStructInnerArraySequentialByRef_StdCall: InnerArraySequential param not as expected\n" ); |
| 512 | PrintInnerArraySequential(argstr,"argstr" ); |
| 513 | return FALSE; |
| 514 | } |
| 515 | ChangeInnerArraySequential(argstr); |
| 516 | return TRUE; |
| 517 | } |
| 518 | typedef BOOL (_cdecl *InnerArraySequentialByRefCdeclCaller)(InnerArraySequential* pcs); |
| 519 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructInnerArraySequentialByRef_Cdecl(InnerArraySequentialByRefCdeclCaller caller) |
| 520 | { |
| 521 | //Init |
| 522 | InnerArraySequential argstr; |
| 523 | |
| 524 | for(int i = 0;i<NumArrElements;i++) |
| 525 | { |
| 526 | argstr.arr[i].f1 = 77; |
| 527 | argstr.arr[i].f2 = 77.0; |
| 528 | const char* lpstr = "changed string" ; |
| 529 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 530 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 531 | memset(temp, 0, size); |
| 532 | if(temp) |
| 533 | { |
| 534 | strcpy_s((char*)temp,size,lpstr); |
| 535 | argstr.arr[i].f3 = temp; |
| 536 | } |
| 537 | else |
| 538 | { |
| 539 | printf("Memory Allocated Failed!" ); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | if(!caller(&argstr)) |
| 544 | { |
| 545 | printf("DoCallBack_MarshalStructInnerArraySequentialByRef_Cdecl:The Caller returns wrong value\n" ); |
| 546 | return FALSE; |
| 547 | } |
| 548 | //Verify the value unchanged |
| 549 | if(!IsCorrectInnerArraySequential(&argstr)) |
| 550 | { |
| 551 | printf("The parameter for DoCallBack_MarshalStructInnerArraySequentialByRef_Cdecl is wrong\n" ); |
| 552 | return FALSE; |
| 553 | } |
| 554 | return TRUE; |
| 555 | } |
| 556 | |
| 557 | typedef BOOL (__stdcall *InnerArraySequentialByRefStdCallCaller)(InnerArraySequential* pcs); |
| 558 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructInnerArraySequentialByRef_StdCall(InnerArraySequentialByRefStdCallCaller caller) |
| 559 | { |
| 560 | //Init |
| 561 | InnerArraySequential argstr; |
| 562 | for(int i = 0;i<NumArrElements;i++) |
| 563 | { |
| 564 | argstr.arr[i].f1 = 77; |
| 565 | argstr.arr[i].f2 = 77.0; |
| 566 | const char* lpstr = "changed string" ; |
| 567 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 568 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 569 | memset(temp, 0, size); |
| 570 | if(temp) |
| 571 | { |
| 572 | strcpy_s((char*)temp,size,lpstr); |
| 573 | argstr.arr[i].f3 = temp; |
| 574 | } |
| 575 | else |
| 576 | { |
| 577 | printf("Memory Allocated Failed!" ); |
| 578 | } |
| 579 | } |
| 580 | if(!caller(&argstr)) |
| 581 | { |
| 582 | printf("DoCallBack_MarshalStructInnerArraySequentialByRef_StdCall:The Caller returns wrong value\n" ); |
| 583 | return FALSE; |
| 584 | } |
| 585 | //Verify the value unchanged |
| 586 | if(!IsCorrectInnerArraySequential(&argstr)) |
| 587 | { |
| 588 | printf("The parameter for DoCallBack_MarshalStructInnerArraySequentialByRef_StdCall is wrong\n" ); |
| 589 | return FALSE; |
| 590 | } |
| 591 | return TRUE; |
| 592 | } |
| 593 | //Delegate PInvoke,passbyref |
| 594 | typedef BOOL (_cdecl *InnerArraySequentialDelegatePInvokeByRefCdeclCaller)(InnerArraySequential* pcs); |
| 595 | extern "C" DLL_EXPORT InnerArraySequentialDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructInnerArraySequentialByRef_Cdecl_FuncPtr() |
| 596 | { |
| 597 | return MarshalStructInnerArraySequentialByRef_Cdecl; |
| 598 | } |
| 599 | |
| 600 | typedef BOOL (__stdcall *InnerArraySequentialDelegatePInvokeByRefStdCallCaller)(InnerArraySequential* pcs); |
| 601 | extern "C" DLL_EXPORT InnerArraySequentialDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructInnerArraySequentialByRef_StdCall_FuncPtr() |
| 602 | { |
| 603 | return MarshalStructInnerArraySequentialByRef_StdCall; |
| 604 | } |
| 605 | |
| 606 | |
| 607 | //Passby value |
| 608 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructInnerArraySequentialByVal_Cdecl(InnerArraySequential argstr) |
| 609 | { |
| 610 | //Check the Input |
| 611 | if(!IsCorrectInnerArraySequential(&argstr)) |
| 612 | { |
| 613 | printf("\tMarshalStructInnerArraySequentialByVal_Cdecl: InnerArraySequential param not as expected\n" ); |
| 614 | PrintInnerArraySequential(&argstr,"argstr" ); |
| 615 | return FALSE; |
| 616 | } |
| 617 | |
| 618 | for(int i = 0;i<NumArrElements;i++) |
| 619 | { |
| 620 | argstr.arr[i].f1 = 77; |
| 621 | argstr.arr[i].f2 = 77.0; |
| 622 | const char* lpstr = "changed string" ; |
| 623 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 624 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 625 | memset(temp, 0, size); |
| 626 | if(temp) |
| 627 | { |
| 628 | strcpy_s((char*)temp,size,lpstr); |
| 629 | argstr.arr[i].f3 = temp; |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | printf("Memory Allocated Failed!" ); |
| 634 | } |
| 635 | } |
| 636 | return TRUE; |
| 637 | } |
| 638 | |
| 639 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructInnerArraySequentialByVal_StdCall(InnerArraySequential argstr) |
| 640 | { |
| 641 | //Check the Input |
| 642 | if(!IsCorrectInnerArraySequential(&argstr)) |
| 643 | { |
| 644 | printf("\tMarshalStructInnerArraySequentialByVal_StdCall: InnerArraySequential param not as expected\n" ); |
| 645 | PrintInnerArraySequential(&argstr,"argstr" ); |
| 646 | return FALSE; |
| 647 | } |
| 648 | for(int i = 0; i<NumArrElements;i++) |
| 649 | { |
| 650 | argstr.arr[i].f1 = 77; |
| 651 | argstr.arr[i].f2 = 77.0; |
| 652 | const char* lpstr = "changed string" ; |
| 653 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 654 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 655 | memset(temp, 0, size); |
| 656 | if(temp) |
| 657 | { |
| 658 | strcpy_s((char*)temp,size,lpstr); |
| 659 | argstr.arr[i].f3 = temp; |
| 660 | } |
| 661 | else |
| 662 | { |
| 663 | printf("Memory Allocated Failed!" ); |
| 664 | } |
| 665 | } |
| 666 | return TRUE; |
| 667 | } |
| 668 | |
| 669 | typedef BOOL (_cdecl *InnerArraySequentialByValCdeclCaller)(InnerArraySequential cs); |
| 670 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructInnerArraySequentialByVal_Cdecl(InnerArraySequentialByValCdeclCaller caller) |
| 671 | { |
| 672 | //Init |
| 673 | InnerArraySequential argstr; |
| 674 | for(int i = 0;i<NumArrElements;i++) |
| 675 | { |
| 676 | argstr.arr[i].f1 = 77; |
| 677 | argstr.arr[i].f2 = 77.0; |
| 678 | const char* lpstr = "changed string" ; |
| 679 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 680 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 681 | memset(temp, 0, size); |
| 682 | if(temp) |
| 683 | { |
| 684 | strcpy_s((char*)temp,size,lpstr); |
| 685 | argstr.arr[i].f3 = temp; |
| 686 | } |
| 687 | else |
| 688 | { |
| 689 | printf("Memory Allocated Failed!" ); |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | if(!caller(argstr)) |
| 694 | { |
| 695 | printf("DoCallBack_MarshalStructInnerArraySequentialByVal_Cdecl:The Caller returns wrong value\n" ); |
| 696 | return FALSE; |
| 697 | } |
| 698 | |
| 699 | //Verify the value unchanged |
| 700 | for(int i =0;i<NumArrElements;i++) |
| 701 | { |
| 702 | if(argstr.arr[i].f1 != 77 || argstr.arr[i].f2 != 77.0 || strcmp((char*)argstr.arr[i].f3, "changed string" ) != 0) |
| 703 | { |
| 704 | printf("The parameter for DoCallBack_MarshalStructInnerArraySequentialByVal_Cdecl is wrong\n" ); |
| 705 | return FALSE; |
| 706 | } |
| 707 | } |
| 708 | return TRUE; |
| 709 | } |
| 710 | |
| 711 | typedef BOOL (__stdcall *InnerArraySequentialByValStdCallCaller)(InnerArraySequential cs); |
| 712 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructInnerArraySequentialByVal_StdCall(InnerArraySequentialByValStdCallCaller caller) |
| 713 | { |
| 714 | //Init |
| 715 | InnerArraySequential argstr; |
| 716 | for(int i = 0;i<NumArrElements;i++) |
| 717 | { |
| 718 | argstr.arr[i].f1 = 77; |
| 719 | argstr.arr[i].f2 = 77.0; |
| 720 | const char* lpstr = "changed string" ; |
| 721 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 722 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 723 | memset(temp, 0, size); |
| 724 | if(temp) |
| 725 | { |
| 726 | strcpy_s((char*)temp,size,lpstr); |
| 727 | argstr.arr[i].f3 = temp; |
| 728 | } |
| 729 | else |
| 730 | { |
| 731 | printf("Memory Allocated Failed!" ); |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | if(!caller(argstr)) |
| 736 | { |
| 737 | printf("DoCallBack_MarshalStructInnerArraySequentialByVal_StdCall:The Caller returns wrong value\n" ); |
| 738 | return FALSE; |
| 739 | } |
| 740 | |
| 741 | //Verify the value unchanged |
| 742 | for(int i = 0;i<NumArrElements;i++) |
| 743 | { |
| 744 | if(argstr.arr[i].f1 != 77 || argstr.arr[i].f2 != 77.0 || strcmp((char*)argstr.arr[i].f3, "changed string" ) != 0) |
| 745 | { |
| 746 | printf("The parameter for DoCallBack_MarshalStructInnerArraySequentialByVal_StdCall is wrong\n" ); |
| 747 | return FALSE; |
| 748 | } |
| 749 | } |
| 750 | return TRUE; |
| 751 | } |
| 752 | //Delegate PInvoke,passbyval |
| 753 | typedef BOOL (_cdecl *InnerArraySequentialDelegatePInvokeByValCdeclCaller)(InnerArraySequential cs); |
| 754 | extern "C" DLL_EXPORT InnerArraySequentialDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructInnerArraySequentialByVal_Cdecl_FuncPtr() |
| 755 | { |
| 756 | return MarshalStructInnerArraySequentialByVal_Cdecl; |
| 757 | } |
| 758 | |
| 759 | typedef BOOL (__stdcall *InnerArraySequentialDelegatePInvokeByValStdCallCaller)(InnerArraySequential cs); |
| 760 | extern "C" DLL_EXPORT InnerArraySequentialDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructInnerArraySequentialByVal_StdCall_FuncPtr() |
| 761 | { |
| 762 | return MarshalStructInnerArraySequentialByVal_StdCall; |
| 763 | } |
| 764 | |
| 765 | ///////////////////////////////////////////Methods for CharSetAnsiSequential struct//////////////////////////////////////////////////// |
| 766 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructCharSetAnsiSequentialByRef_Cdecl(CharSetAnsiSequential* argstr) |
| 767 | { |
| 768 | if(!IsCorrectCharSetAnsiSequential(argstr)) |
| 769 | { |
| 770 | printf("\tMarshalStructCharSetAnsiSequentialByRef_Cdecl: CharSetAnsiSequential param not as expected\n" ); |
| 771 | PrintCharSetAnsiSequential(argstr,"argstr" ); |
| 772 | return FALSE; |
| 773 | } |
| 774 | ChangeCharSetAnsiSequential(argstr); |
| 775 | return TRUE; |
| 776 | } |
| 777 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructCharSetAnsiSequentialByRef_StdCall(CharSetAnsiSequential* argstr) |
| 778 | { |
| 779 | if(!IsCorrectCharSetAnsiSequential(argstr)) |
| 780 | { |
| 781 | printf("\tMarshalStructCharSetAnsiSequentialByRef_StdCall: CharSetAnsiSequential param not as expected\n" ); |
| 782 | PrintCharSetAnsiSequential(argstr,"argstr" ); |
| 783 | return FALSE; |
| 784 | } |
| 785 | ChangeCharSetAnsiSequential(argstr); |
| 786 | return TRUE; |
| 787 | } |
| 788 | typedef BOOL (_cdecl *CharSetAnsiSequentialByRefCdeclCaller)(CharSetAnsiSequential* pcs); |
| 789 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructCharSetAnsiSequentialByRef_Cdecl(CharSetAnsiSequentialByRefCdeclCaller caller) |
| 790 | { |
| 791 | //Init |
| 792 | CharSetAnsiSequential argstr; |
| 793 | |
| 794 | const char* strSource = "change string" ; |
| 795 | size_t size = strlen(strSource) + 1; |
| 796 | LPSTR temp = (LPSTR)CoreClrAlloc(size); |
| 797 | if(temp != NULL) |
| 798 | { |
| 799 | strcpy_s((char*)temp,size,strSource); |
| 800 | argstr.f1 = temp; |
| 801 | argstr.f2 = 'n'; |
| 802 | } |
| 803 | else |
| 804 | { |
| 805 | printf("Memory Allocated Failed!" ); |
| 806 | } |
| 807 | |
| 808 | if(!caller(&argstr)) |
| 809 | { |
| 810 | printf("DoCallBack_MarshalStructCharSetAnsiSequentialByRef_Cdecl:The Caller returns wrong value\n" ); |
| 811 | return FALSE; |
| 812 | } |
| 813 | //Verify the value unchanged |
| 814 | if(!IsCorrectCharSetAnsiSequential(&argstr)) |
| 815 | { |
| 816 | printf("The parameter for DoCallBack_MarshalStructCharSetAnsiSequentialByRef_Cdecl is wrong\n" ); |
| 817 | return FALSE; |
| 818 | } |
| 819 | return TRUE; |
| 820 | } |
| 821 | |
| 822 | typedef BOOL (__stdcall *CharSetAnsiSequentialByRefStdCallCaller)(CharSetAnsiSequential* pcs); |
| 823 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructCharSetAnsiSequentialByRef_StdCall(CharSetAnsiSequentialByRefStdCallCaller caller) |
| 824 | { |
| 825 | //Init |
| 826 | CharSetAnsiSequential argstr; |
| 827 | |
| 828 | const char* strSource = "change string" ; |
| 829 | size_t size = strlen(strSource) + 1; |
| 830 | LPSTR temp = (LPSTR)CoreClrAlloc(size); |
| 831 | if(temp != NULL) |
| 832 | { |
| 833 | strcpy_s((char*)temp,size,strSource); |
| 834 | argstr.f1 = temp; |
| 835 | argstr.f2 = 'n'; |
| 836 | } |
| 837 | else |
| 838 | { |
| 839 | printf("Memory Allocated Failed!" ); |
| 840 | } |
| 841 | |
| 842 | if(!caller(&argstr)) |
| 843 | { |
| 844 | printf("DoCallBack_MarshalStructCharSetAnsiSequentialByRef_StdCall:The Caller returns wrong value\n" ); |
| 845 | return FALSE; |
| 846 | } |
| 847 | //Verify the value unchanged |
| 848 | if(!IsCorrectCharSetAnsiSequential(&argstr)) |
| 849 | { |
| 850 | printf("The parameter for DoCallBack_MarshalStructCharSetAnsiSequentialByRef_StdCall is wrong\n" ); |
| 851 | return FALSE; |
| 852 | } |
| 853 | return TRUE; |
| 854 | } |
| 855 | //Delegate PInvoke,passbyref |
| 856 | typedef BOOL (_cdecl *CharSetAnsiSequentialDelegatePInvokeByRefCdeclCaller)(CharSetAnsiSequential* pcs); |
| 857 | extern "C" DLL_EXPORT CharSetAnsiSequentialDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructCharSetAnsiSequentialByRef_Cdecl_FuncPtr() |
| 858 | { |
| 859 | return MarshalStructCharSetAnsiSequentialByRef_Cdecl; |
| 860 | } |
| 861 | |
| 862 | typedef BOOL (__stdcall *CharSetAnsiSequentialDelegatePInvokeByRefStdCallCaller)(CharSetAnsiSequential* pcs); |
| 863 | extern "C" DLL_EXPORT CharSetAnsiSequentialDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructCharSetAnsiSequentialByRef_StdCall_FuncPtr() |
| 864 | { |
| 865 | return MarshalStructCharSetAnsiSequentialByRef_StdCall; |
| 866 | } |
| 867 | |
| 868 | |
| 869 | //Passby value |
| 870 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructCharSetAnsiSequentialByVal_Cdecl(CharSetAnsiSequential argstr) |
| 871 | { |
| 872 | //Check the Input |
| 873 | if(!IsCorrectCharSetAnsiSequential(&argstr)) |
| 874 | { |
| 875 | printf("\tMarshalStructCharSetAnsiSequentialByVal_Cdecl: CharSetAnsiSequential param not as expected\n" ); |
| 876 | PrintCharSetAnsiSequential(&argstr,"argstr" ); |
| 877 | return FALSE; |
| 878 | } |
| 879 | |
| 880 | const char* strSource = "change string" ; |
| 881 | size_t size = strlen(strSource) + 1; |
| 882 | LPSTR temp = (LPSTR)CoreClrAlloc(size); |
| 883 | if(temp != NULL) |
| 884 | { |
| 885 | strcpy_s((char*)temp,size,strSource); |
| 886 | argstr.f1 = temp; |
| 887 | argstr.f2 = 'n'; |
| 888 | } |
| 889 | else |
| 890 | { |
| 891 | printf("Memory Allocated Failed!" ); |
| 892 | } |
| 893 | return TRUE; |
| 894 | } |
| 895 | |
| 896 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructCharSetAnsiSequentialByVal_StdCall(CharSetAnsiSequential argstr) |
| 897 | { |
| 898 | //Check the Input |
| 899 | if(!IsCorrectCharSetAnsiSequential(&argstr)) |
| 900 | { |
| 901 | printf("\tMarshalStructCharSetAnsiSequentialByVal_StdCall: CharSetAnsiSequential param not as expected\n" ); |
| 902 | PrintCharSetAnsiSequential(&argstr,"argstr" ); |
| 903 | return FALSE; |
| 904 | } |
| 905 | |
| 906 | const char* strSource = "change string" ; |
| 907 | size_t size = strlen(strSource) + 1; |
| 908 | LPSTR temp = (LPSTR)CoreClrAlloc(size); |
| 909 | if(temp != NULL) |
| 910 | { |
| 911 | strcpy_s((char*)temp,size,strSource); |
| 912 | argstr.f1 = temp; |
| 913 | argstr.f2 = 'n'; |
| 914 | } |
| 915 | else |
| 916 | { |
| 917 | printf("Memory Allocated Failed!" ); |
| 918 | } |
| 919 | return TRUE; |
| 920 | } |
| 921 | |
| 922 | typedef BOOL (_cdecl *CharSetAnsiSequentialByValCdeclCaller)(CharSetAnsiSequential cs); |
| 923 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructCharSetAnsiSequentialByVal_Cdecl(CharSetAnsiSequentialByValCdeclCaller caller) |
| 924 | { |
| 925 | //Init |
| 926 | CharSetAnsiSequential argstr{}; |
| 927 | const char* strSource = "change string" ; |
| 928 | size_t size = strlen(strSource) + 1; |
| 929 | LPSTR temp = (LPSTR)CoreClrAlloc(size); |
| 930 | if(temp != NULL) |
| 931 | { |
| 932 | strcpy_s((char*)temp,size,strSource); |
| 933 | argstr.f1 = temp; |
| 934 | argstr.f2 = 'n'; |
| 935 | } |
| 936 | else |
| 937 | { |
| 938 | printf("Memory Allocated Failed!" ); |
| 939 | } |
| 940 | |
| 941 | if(!caller(argstr)) |
| 942 | { |
| 943 | printf("DoCallBack_MarshalStructCharSetAnsiSequentialByVal_Cdecl:The Caller returns wrong value\n" ); |
| 944 | return FALSE; |
| 945 | } |
| 946 | |
| 947 | //Verify the value unchanged |
| 948 | if(strcmp((char*)argstr.f1,"change string" ) != 0 || argstr.f2 != 'n') |
| 949 | { |
| 950 | printf("The parameter for DoCallBack_MarshalStructCharSetAnsiSequentialByVal_Cdecl is wrong\n" ); |
| 951 | return FALSE; |
| 952 | } |
| 953 | return TRUE; |
| 954 | } |
| 955 | |
| 956 | typedef BOOL (__stdcall *CharSetAnsiSequentialByValStdCallCaller)(CharSetAnsiSequential cs); |
| 957 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructCharSetAnsiSequentialByVal_StdCall(CharSetAnsiSequentialByValStdCallCaller caller) |
| 958 | { |
| 959 | //Init |
| 960 | CharSetAnsiSequential argstr{}; |
| 961 | const char* strSource = "change string" ; |
| 962 | size_t size = strlen(strSource) + 1; |
| 963 | LPSTR temp = (LPSTR)CoreClrAlloc(size); |
| 964 | if(temp != NULL) |
| 965 | { |
| 966 | strcpy_s((char*)temp,size,strSource); |
| 967 | argstr.f1 = temp; |
| 968 | argstr.f2 = 'n'; |
| 969 | } |
| 970 | else |
| 971 | { |
| 972 | printf("Memory Allocated Failed!" ); |
| 973 | } |
| 974 | |
| 975 | if(!caller(argstr)) |
| 976 | { |
| 977 | printf("DoCallBack_MarshalStructCharSetAnsiSequentialByVal_StdCall:The Caller returns wrong value\n" ); |
| 978 | return FALSE; |
| 979 | } |
| 980 | |
| 981 | //Verify the value unchanged |
| 982 | if(strcmp((char*)argstr.f1,"change string" ) != 0 || argstr.f2 != 'n') |
| 983 | { |
| 984 | printf("The parameter for DoCallBack_MarshalStructCharSetAnsiSequentialByVal_StdCall is wrong\n" ); |
| 985 | return FALSE; |
| 986 | } |
| 987 | return TRUE; |
| 988 | } |
| 989 | //Delegate PInvoke,passbyval |
| 990 | typedef BOOL (_cdecl *CharSetAnsiSequentialDelegatePInvokeByValCdeclCaller)(CharSetAnsiSequential cs); |
| 991 | extern "C" DLL_EXPORT CharSetAnsiSequentialDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructCharSetAnsiSequentialByVal_Cdecl_FuncPtr() |
| 992 | { |
| 993 | return MarshalStructCharSetAnsiSequentialByVal_Cdecl; |
| 994 | } |
| 995 | |
| 996 | typedef BOOL (__stdcall *CharSetAnsiSequentialDelegatePInvokeByValStdCallCaller)(CharSetAnsiSequential cs); |
| 997 | extern "C" DLL_EXPORT CharSetAnsiSequentialDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructCharSetAnsiSequentialByVal_StdCall_FuncPtr() |
| 998 | { |
| 999 | return MarshalStructCharSetAnsiSequentialByVal_StdCall; |
| 1000 | } |
| 1001 | |
| 1002 | |
| 1003 | ///////////////////////////////////////////Methods for CharSetUnicodeSequential struct//////////////////////////////////////////////////// |
| 1004 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructCharSetUnicodeSequentialByRef_Cdecl(CharSetUnicodeSequential* argstr) |
| 1005 | { |
| 1006 | if(!IsCorrectCharSetUnicodeSequential(argstr)) |
| 1007 | { |
| 1008 | printf("\tMarshalStructCharSetUnicodeSequentialByRef_Cdecl: CharSetUnicodeSequential param not as expected\n" ); |
| 1009 | PrintCharSetUnicodeSequential(argstr,"argstr" ); |
| 1010 | return FALSE; |
| 1011 | } |
| 1012 | ChangeCharSetUnicodeSequential(argstr); |
| 1013 | return TRUE; |
| 1014 | } |
| 1015 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructCharSetUnicodeSequentialByRef_StdCall(CharSetUnicodeSequential* argstr) |
| 1016 | { |
| 1017 | if(!IsCorrectCharSetUnicodeSequential(argstr)) |
| 1018 | { |
| 1019 | printf("\tMarshalStructCharSetUnicodeSequentialByRef_StdCall: CharSetUnicodeSequential param not as expected\n" ); |
| 1020 | PrintCharSetUnicodeSequential(argstr,"argstr" ); |
| 1021 | return FALSE; |
| 1022 | } |
| 1023 | ChangeCharSetUnicodeSequential(argstr); |
| 1024 | return TRUE; |
| 1025 | } |
| 1026 | typedef BOOL (_cdecl *CharSetUnicodeSequentialByRefCdeclCaller)(CharSetUnicodeSequential* pcs); |
| 1027 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructCharSetUnicodeSequentialByRef_Cdecl(CharSetUnicodeSequentialByRefCdeclCaller caller) |
| 1028 | { |
| 1029 | //Init |
| 1030 | CharSetUnicodeSequential argstr; |
| 1031 | |
| 1032 | WCHAR* strSource = (WCHAR*)(W("change string" )); |
| 1033 | size_t len = wcslen(strSource); |
| 1034 | LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1)); |
| 1035 | if(temp != NULL) |
| 1036 | { |
| 1037 | //wcscpy((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource); |
| 1038 | wcscpy_s((WCHAR*)temp,len+1,strSource); |
| 1039 | argstr.f1 = temp; |
| 1040 | argstr.f2 = 'n'; |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | printf("Memory Allocated Failed!" ); |
| 1045 | } |
| 1046 | |
| 1047 | if(!caller(&argstr)) |
| 1048 | { |
| 1049 | printf("DoCallBack_MarshalStructCharSetUnicodeSequentialByRef_Cdecl:The Caller returns wrong value\n" ); |
| 1050 | return FALSE; |
| 1051 | } |
| 1052 | //Verify the value unchanged |
| 1053 | if(!IsCorrectCharSetUnicodeSequential(&argstr)) |
| 1054 | { |
| 1055 | printf("The parameter for DoCallBack_MarshalStructCharSetUnicodeSequentialByRef_Cdecl is wrong\n" ); |
| 1056 | return FALSE; |
| 1057 | } |
| 1058 | return TRUE; |
| 1059 | } |
| 1060 | |
| 1061 | typedef BOOL (__stdcall *CharSetUnicodeSequentialByRefStdCallCaller)(CharSetUnicodeSequential* pcs); |
| 1062 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructCharSetUnicodeSequentialByRef_StdCall(CharSetUnicodeSequentialByRefStdCallCaller caller) |
| 1063 | { |
| 1064 | //Init |
| 1065 | CharSetUnicodeSequential argstr; |
| 1066 | |
| 1067 | WCHAR* strSource = (WCHAR*)(W("change string" )); |
| 1068 | size_t len = wcslen(strSource); |
| 1069 | LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1)); |
| 1070 | if(temp != NULL) |
| 1071 | { |
| 1072 | //wcscpy((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource); |
| 1073 | wcscpy_s((WCHAR*)temp,len+1,strSource); |
| 1074 | argstr.f1 = temp; |
| 1075 | argstr.f2 = 'n'; |
| 1076 | } |
| 1077 | else |
| 1078 | { |
| 1079 | printf("Memory Allocated Failed!" ); |
| 1080 | } |
| 1081 | |
| 1082 | if(!caller(&argstr)) |
| 1083 | { |
| 1084 | printf("DoCallBack_MarshalStructCharSetUnicodeSequentialByRef_StdCall:The Caller returns wrong value\n" ); |
| 1085 | return FALSE; |
| 1086 | } |
| 1087 | //Verify the value unchanged |
| 1088 | if(!IsCorrectCharSetUnicodeSequential(&argstr)) |
| 1089 | { |
| 1090 | printf("The parameter for DoCallBack_MarshalStructCharSetUnicodeSequentialByRef_StdCall is wrong\n" ); |
| 1091 | return FALSE; |
| 1092 | } |
| 1093 | return TRUE; |
| 1094 | } |
| 1095 | //Delegate PInvoke,passbyref |
| 1096 | typedef BOOL (_cdecl *CharSetUnicodeSequentialDelegatePInvokeByRefCdeclCaller)(CharSetUnicodeSequential* pcs); |
| 1097 | extern "C" DLL_EXPORT CharSetUnicodeSequentialDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructCharSetUnicodeSequentialByRef_Cdecl_FuncPtr() |
| 1098 | { |
| 1099 | return MarshalStructCharSetUnicodeSequentialByRef_Cdecl; |
| 1100 | } |
| 1101 | |
| 1102 | typedef BOOL (__stdcall *CharSetUnicodeSequentialDelegatePInvokeByRefStdCallCaller)(CharSetUnicodeSequential* pcs); |
| 1103 | extern "C" DLL_EXPORT CharSetUnicodeSequentialDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructCharSetUnicodeSequentialByRef_StdCall_FuncPtr() |
| 1104 | { |
| 1105 | return MarshalStructCharSetUnicodeSequentialByRef_StdCall; |
| 1106 | } |
| 1107 | |
| 1108 | |
| 1109 | //Passby value |
| 1110 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructCharSetUnicodeSequentialByVal_Cdecl(CharSetUnicodeSequential argstr) |
| 1111 | { |
| 1112 | //Check the Input |
| 1113 | if(!IsCorrectCharSetUnicodeSequential(&argstr)) |
| 1114 | { |
| 1115 | printf("\tMarshalStructCharSetUnicodeSequentialByVal_Cdecl: CharSetUnicodeSequential param not as expected\n" ); |
| 1116 | PrintCharSetUnicodeSequential(&argstr,"argstr" ); |
| 1117 | return FALSE; |
| 1118 | } |
| 1119 | |
| 1120 | WCHAR* strSource = (WCHAR*)(W("change string" )); |
| 1121 | size_t len = wcslen(strSource); |
| 1122 | LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1)); |
| 1123 | if(temp != NULL) |
| 1124 | { |
| 1125 | //wcscpy((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource); |
| 1126 | wcscpy_s((WCHAR*)temp,len+1,strSource); |
| 1127 | argstr.f1 = temp; |
| 1128 | argstr.f2 = 'n'; |
| 1129 | } |
| 1130 | else |
| 1131 | { |
| 1132 | printf("Memory Allocated Failed!" ); |
| 1133 | } |
| 1134 | return TRUE; |
| 1135 | } |
| 1136 | |
| 1137 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructCharSetUnicodeSequentialByVal_StdCall(CharSetUnicodeSequential argstr) |
| 1138 | { |
| 1139 | //Check the Input |
| 1140 | if(!IsCorrectCharSetUnicodeSequential(&argstr)) |
| 1141 | { |
| 1142 | printf("\tMarshalStructCharSetUnicodeSequentialByVal_StdCall: CharSetUnicodeSequential param not as expected\n" ); |
| 1143 | PrintCharSetUnicodeSequential(&argstr,"argstr" ); |
| 1144 | return FALSE; |
| 1145 | } |
| 1146 | |
| 1147 | WCHAR* strSource = (WCHAR*)(W("change string" )); |
| 1148 | size_t len = wcslen(strSource); |
| 1149 | LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1)); |
| 1150 | if(temp != NULL) |
| 1151 | { |
| 1152 | //wcscpy((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource); |
| 1153 | wcscpy_s((WCHAR*)temp,len+1,strSource); |
| 1154 | argstr.f1 = temp; |
| 1155 | argstr.f2 = 'n'; |
| 1156 | } |
| 1157 | else |
| 1158 | { |
| 1159 | printf("Memory Allocated Failed!" ); |
| 1160 | } |
| 1161 | return TRUE; |
| 1162 | } |
| 1163 | |
| 1164 | typedef BOOL (_cdecl *CharSetUnicodeSequentialByValCdeclCaller)(CharSetUnicodeSequential cs); |
| 1165 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructCharSetUnicodeSequentialByVal_Cdecl(CharSetUnicodeSequentialByValCdeclCaller caller) |
| 1166 | { |
| 1167 | //Init |
| 1168 | CharSetUnicodeSequential argstr{}; |
| 1169 | WCHAR* strSource = (WCHAR*)(W("change string" )); |
| 1170 | size_t len =wcslen(strSource); |
| 1171 | LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1)); |
| 1172 | if(temp != NULL) |
| 1173 | { |
| 1174 | //wcscpy((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource); |
| 1175 | wcscpy_s((WCHAR*)temp,len+1,strSource); |
| 1176 | argstr.f1 = temp; |
| 1177 | argstr.f2 = 'n'; |
| 1178 | } |
| 1179 | else |
| 1180 | { |
| 1181 | printf("Memory Allocated Failed!" ); |
| 1182 | } |
| 1183 | |
| 1184 | if(!caller(argstr)) |
| 1185 | { |
| 1186 | printf("DoCallBack_MarshalStructCharSetUnicodeSequentialByVal_Cdecl:The Caller returns wrong value\n" ); |
| 1187 | return FALSE; |
| 1188 | } |
| 1189 | |
| 1190 | //Verify the value unchanged |
| 1191 | if(0 != wcscmp(const_cast<WCHAR*>(argstr.f1), const_cast<WCHAR*>(W("change string" ))) || argstr.f2 != L'n') |
| 1192 | { |
| 1193 | printf("The parameter for DoCallBack_MarshalStructCharSetUnicodeSequentialByVal_Cdecl is wrong\n" ); |
| 1194 | return FALSE; |
| 1195 | } |
| 1196 | return TRUE; |
| 1197 | } |
| 1198 | |
| 1199 | typedef BOOL (__stdcall *CharSetUnicodeSequentialByValStdCallCaller)(CharSetUnicodeSequential cs); |
| 1200 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructCharSetUnicodeSequentialByVal_StdCall(CharSetUnicodeSequentialByValStdCallCaller caller) |
| 1201 | { |
| 1202 | //Init |
| 1203 | CharSetUnicodeSequential argstr{}; |
| 1204 | WCHAR* strSource = (WCHAR*)(W("change string" )); |
| 1205 | size_t len =wcslen(strSource); |
| 1206 | LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1)); |
| 1207 | if(temp != NULL) |
| 1208 | { |
| 1209 | //wcscpy((WCHAR*)temp, (len+1)*sizeof(WCHAR), strSource); |
| 1210 | wcscpy_s((WCHAR*)temp,len+1,strSource); |
| 1211 | argstr.f1 = temp; |
| 1212 | argstr.f2 = 'n'; |
| 1213 | } |
| 1214 | else |
| 1215 | { |
| 1216 | printf("Memory Allocated Failed!" ); |
| 1217 | } |
| 1218 | |
| 1219 | if(!caller(argstr)) |
| 1220 | { |
| 1221 | printf("DoCallBack_MarshalStructCharSetUnicodeSequentialByVal_StdCall:The Caller returns wrong value\n" ); |
| 1222 | return FALSE; |
| 1223 | } |
| 1224 | |
| 1225 | //Verify the value unchanged |
| 1226 | if(0 != wcscmp(const_cast<WCHAR*>(argstr.f1), const_cast<WCHAR*>(W("change string" ))) || argstr.f2 != L'n') |
| 1227 | { |
| 1228 | printf("The parameter for DoCallBack_MarshalStructCharSetUnicodeSequentialByVal_StdCall is wrong\n" ); |
| 1229 | return FALSE; |
| 1230 | } |
| 1231 | return TRUE; |
| 1232 | } |
| 1233 | //Delegate PInvoke,passbyval |
| 1234 | typedef BOOL (_cdecl *CharSetUnicodeSequentialDelegatePInvokeByValCdeclCaller)(CharSetUnicodeSequential cs); |
| 1235 | extern "C" DLL_EXPORT CharSetUnicodeSequentialDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructCharSetUnicodeSequentialByVal_Cdecl_FuncPtr() |
| 1236 | { |
| 1237 | return MarshalStructCharSetUnicodeSequentialByVal_Cdecl; |
| 1238 | } |
| 1239 | |
| 1240 | typedef BOOL (__stdcall *CharSetUnicodeSequentialDelegatePInvokeByValStdCallCaller)(CharSetUnicodeSequential cs); |
| 1241 | extern "C" DLL_EXPORT CharSetUnicodeSequentialDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructCharSetUnicodeSequentialByVal_StdCall_FuncPtr() |
| 1242 | { |
| 1243 | return MarshalStructCharSetUnicodeSequentialByVal_StdCall; |
| 1244 | } |
| 1245 | |
| 1246 | |
| 1247 | ///////////////////////////////////////////Methods for NumberSequential struct//////////////////////////////////////////////////// |
| 1248 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructNumberSequentialByRef_Cdecl(NumberSequential* argstr) |
| 1249 | { |
| 1250 | if(!IsCorrectNumberSequential(argstr)) |
| 1251 | { |
| 1252 | printf("\tMarshalStructNumberSequentialByRef_Cdecl: NumberSequential param not as expected\n" ); |
| 1253 | PrintNumberSequential(argstr,"argstr" ); |
| 1254 | return FALSE; |
| 1255 | } |
| 1256 | ChangeNumberSequential(argstr); |
| 1257 | return TRUE; |
| 1258 | } |
| 1259 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructNumberSequentialByRef_StdCall(NumberSequential* argstr) |
| 1260 | { |
| 1261 | if(!IsCorrectNumberSequential(argstr)) |
| 1262 | { |
| 1263 | printf("\tMarshalStructNumberSequentialByRef_StdCall: NumberSequential param not as expected\n" ); |
| 1264 | PrintNumberSequential(argstr,"argstr" ); |
| 1265 | return FALSE; |
| 1266 | } |
| 1267 | ChangeNumberSequential(argstr); |
| 1268 | return TRUE; |
| 1269 | } |
| 1270 | typedef BOOL (_cdecl *NumberSequentialByRefCdeclCaller)(NumberSequential* pcs); |
| 1271 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructNumberSequentialByRef_Cdecl(NumberSequentialByRefCdeclCaller caller) |
| 1272 | { |
| 1273 | //Init |
| 1274 | NumberSequential argstr; |
| 1275 | |
| 1276 | argstr.i32 = 0; |
| 1277 | argstr.ui32 = 32; |
| 1278 | argstr.s1 = 0; |
| 1279 | argstr.us1 = 16; |
| 1280 | argstr.b = 0; |
| 1281 | argstr.sb = 8; |
| 1282 | argstr.i16 = 0; |
| 1283 | argstr.ui16 = 16; |
| 1284 | argstr.i64 = 0; |
| 1285 | argstr.ui64 = 64; |
| 1286 | argstr.sgl = 64.0; |
| 1287 | argstr.d = 6.4; |
| 1288 | |
| 1289 | if(!caller(&argstr)) |
| 1290 | { |
| 1291 | printf("DoCallBack_MarshalStructNumberSequentialByRef_Cdecl:The Caller returns wrong value\n" ); |
| 1292 | return FALSE; |
| 1293 | } |
| 1294 | //Verify the value unchanged |
| 1295 | if(!IsCorrectNumberSequential(&argstr)) |
| 1296 | { |
| 1297 | printf("The parameter for DoCallBack_MarshalStructNumberSequentialByRef_Cdecl is wrong\n" ); |
| 1298 | return FALSE; |
| 1299 | } |
| 1300 | return TRUE; |
| 1301 | } |
| 1302 | |
| 1303 | typedef BOOL (__stdcall *NumberSequentialByRefStdCallCaller)(NumberSequential* pcs); |
| 1304 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructNumberSequentialByRef_StdCall(NumberSequentialByRefStdCallCaller caller) |
| 1305 | { |
| 1306 | //Init |
| 1307 | NumberSequential argstr; |
| 1308 | |
| 1309 | argstr.i32 = 0; |
| 1310 | argstr.ui32 = 32; |
| 1311 | argstr.s1 = 0; |
| 1312 | argstr.us1 = 16; |
| 1313 | argstr.b = 0; |
| 1314 | argstr.sb = 8; |
| 1315 | argstr.i16 = 0; |
| 1316 | argstr.ui16 = 16; |
| 1317 | argstr.i64 = 0; |
| 1318 | argstr.ui64 = 64; |
| 1319 | argstr.sgl = 64.0; |
| 1320 | argstr.d = 6.4; |
| 1321 | |
| 1322 | if(!caller(&argstr)) |
| 1323 | { |
| 1324 | printf("DoCallBack_MarshalStructNumberSequentialByRef_StdCall:The Caller returns wrong value\n" ); |
| 1325 | return FALSE; |
| 1326 | } |
| 1327 | //Verify the value unchanged |
| 1328 | if(!IsCorrectNumberSequential(&argstr)) |
| 1329 | { |
| 1330 | printf("The parameter for DoCallBack_MarshalStructNumberSequentialByRef_StdCall is wrong\n" ); |
| 1331 | return FALSE; |
| 1332 | } |
| 1333 | return TRUE; |
| 1334 | } |
| 1335 | //Delegate PInvoke,passbyref |
| 1336 | typedef BOOL (_cdecl *NumberSequentialDelegatePInvokeByRefCdeclCaller)(NumberSequential* pcs); |
| 1337 | extern "C" DLL_EXPORT NumberSequentialDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructNumberSequentialByRef_Cdecl_FuncPtr() |
| 1338 | { |
| 1339 | return MarshalStructNumberSequentialByRef_Cdecl; |
| 1340 | } |
| 1341 | |
| 1342 | typedef BOOL (__stdcall *NumberSequentialDelegatePInvokeByRefStdCallCaller)(NumberSequential* pcs); |
| 1343 | extern "C" DLL_EXPORT NumberSequentialDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructNumberSequentialByRef_StdCall_FuncPtr() |
| 1344 | { |
| 1345 | return MarshalStructNumberSequentialByRef_StdCall; |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | //Passby value |
| 1350 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructNumberSequentialByVal_Cdecl(NumberSequential argstr) |
| 1351 | { |
| 1352 | //Check the Input |
| 1353 | if(!IsCorrectNumberSequential(&argstr)) |
| 1354 | { |
| 1355 | printf("\tMarshalStructNumberSequentialByVal_Cdecl: NumberSequential param not as expected\n" ); |
| 1356 | PrintNumberSequential(&argstr,"argstr" ); |
| 1357 | return FALSE; |
| 1358 | } |
| 1359 | |
| 1360 | argstr.i32 = 0; |
| 1361 | argstr.ui32 = 32; |
| 1362 | argstr.s1 = 0; |
| 1363 | argstr.us1 = 16; |
| 1364 | argstr.b = 0; |
| 1365 | argstr.sb = 8; |
| 1366 | argstr.i16 = 0; |
| 1367 | argstr.ui16 = 16; |
| 1368 | argstr.i64 = 0; |
| 1369 | argstr.ui64 = 64; |
| 1370 | argstr.sgl = 64.0; |
| 1371 | argstr.d = 6.4; |
| 1372 | |
| 1373 | return TRUE; |
| 1374 | } |
| 1375 | |
| 1376 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructNumberSequentialByVal_StdCall(NumberSequential argstr) |
| 1377 | { |
| 1378 | //Check the Input |
| 1379 | if(!IsCorrectNumberSequential(&argstr)) |
| 1380 | { |
| 1381 | printf("\tMarshalStructNumberSequentialByVal_StdCall: NumberSequential param not as expected\n" ); |
| 1382 | PrintNumberSequential(&argstr,"argstr" ); |
| 1383 | return FALSE; |
| 1384 | } |
| 1385 | |
| 1386 | argstr.i32 = 0; |
| 1387 | argstr.ui32 = 32; |
| 1388 | argstr.s1 = 0; |
| 1389 | argstr.us1 = 16; |
| 1390 | argstr.b = 0; |
| 1391 | argstr.sb = 8; |
| 1392 | argstr.i16 = 0; |
| 1393 | argstr.ui16 = 16; |
| 1394 | argstr.i64 = 0; |
| 1395 | argstr.ui64 = 64; |
| 1396 | argstr.sgl = 64.0; |
| 1397 | argstr.d = 6.4; |
| 1398 | |
| 1399 | return TRUE; |
| 1400 | } |
| 1401 | |
| 1402 | typedef BOOL (_cdecl *NumberSequentialByValCdeclCaller)(NumberSequential cs); |
| 1403 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructNumberSequentialByVal_Cdecl(NumberSequentialByValCdeclCaller caller) |
| 1404 | { |
| 1405 | //Init |
| 1406 | NumberSequential argstr; |
| 1407 | |
| 1408 | argstr.i32 = 0; |
| 1409 | argstr.ui32 = 32; |
| 1410 | argstr.s1 = 0; |
| 1411 | argstr.us1 = 16; |
| 1412 | argstr.b = 0; |
| 1413 | argstr.sb = 8; |
| 1414 | argstr.i16 = 0; |
| 1415 | argstr.ui16 = 16; |
| 1416 | argstr.i64 = 0; |
| 1417 | argstr.ui64 = 64; |
| 1418 | argstr.sgl = 64.0; |
| 1419 | argstr.d = 6.4; |
| 1420 | |
| 1421 | if(!caller(argstr)) |
| 1422 | { |
| 1423 | printf("DoCallBack_MarshalStructNumberSequentialByVal_Cdecl:The Caller returns wrong value\n" ); |
| 1424 | return FALSE; |
| 1425 | } |
| 1426 | |
| 1427 | //Verify the value unchanged |
| 1428 | if(argstr.i32 != 0 || argstr.ui32 != 32 || argstr.s1 != 0 || argstr.us1 != 16 || argstr.b != 0 || |
| 1429 | argstr.sb != 8 || argstr.i16 != 0 || argstr.ui16 != 16 || argstr.i64 != 0 || argstr.ui64 != 64 || |
| 1430 | argstr.sgl != 64.0 || argstr.d != 6.4) |
| 1431 | { |
| 1432 | printf("The parameter for DoCallBack_MarshalStructNumberSequentialByVal_Cdecl is wrong\n" ); |
| 1433 | return FALSE; |
| 1434 | } |
| 1435 | return TRUE; |
| 1436 | } |
| 1437 | |
| 1438 | typedef BOOL (__stdcall *NumberSequentialByValStdCallCaller)(NumberSequential cs); |
| 1439 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructNumberSequentialByVal_StdCall(NumberSequentialByValStdCallCaller caller) |
| 1440 | { |
| 1441 | //Init |
| 1442 | NumberSequential argstr; |
| 1443 | |
| 1444 | argstr.i32 = 0; |
| 1445 | argstr.ui32 = 32; |
| 1446 | argstr.s1 = 0; |
| 1447 | argstr.us1 = 16; |
| 1448 | argstr.b = 0; |
| 1449 | argstr.sb = 8; |
| 1450 | argstr.i16 = 0; |
| 1451 | argstr.ui16 = 16; |
| 1452 | argstr.i64 = 0; |
| 1453 | argstr.ui64 = 64; |
| 1454 | argstr.sgl = 64.0; |
| 1455 | argstr.d = 6.4; |
| 1456 | |
| 1457 | if(!caller(argstr)) |
| 1458 | { |
| 1459 | printf("DoCallBack_MarshalStructNumberSequentialByVal_StdCall:The Caller returns wrong value\n" ); |
| 1460 | return FALSE; |
| 1461 | } |
| 1462 | |
| 1463 | //Verify the value unchanged |
| 1464 | if(argstr.i32 != 0 || argstr.ui32 != 32 || argstr.s1 != 0 || argstr.us1 != 16 || argstr.b != 0 || |
| 1465 | argstr.sb != 8 || argstr.i16 != 0 || argstr.ui16 != 16 || argstr.i64 != 0 || argstr.ui64 != 64 || |
| 1466 | argstr.sgl != 64.0 || argstr.d != 6.4) |
| 1467 | { |
| 1468 | printf("The parameter for DoCallBack_MarshalStructNumberSequentialByVal_StdCall is wrong\n" ); |
| 1469 | return FALSE; |
| 1470 | } |
| 1471 | return TRUE; |
| 1472 | } |
| 1473 | //Delegate PInvoke,passbyval |
| 1474 | typedef BOOL (_cdecl *NumberSequentialDelegatePInvokeByValCdeclCaller)(NumberSequential cs); |
| 1475 | extern "C" DLL_EXPORT NumberSequentialDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructNumberSequentialByVal_Cdecl_FuncPtr() |
| 1476 | { |
| 1477 | return MarshalStructNumberSequentialByVal_Cdecl; |
| 1478 | } |
| 1479 | |
| 1480 | typedef BOOL (__stdcall *NumberSequentialDelegatePInvokeByValStdCallCaller)(NumberSequential cs); |
| 1481 | extern "C" DLL_EXPORT NumberSequentialDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructNumberSequentialByVal_StdCall_FuncPtr() |
| 1482 | { |
| 1483 | return MarshalStructNumberSequentialByVal_StdCall; |
| 1484 | } |
| 1485 | |
| 1486 | |
| 1487 | ///////////////////////////////////////////Methods for S3 struct//////////////////////////////////////////////////// |
| 1488 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS3ByRef_Cdecl(S3* argstr) |
| 1489 | { |
| 1490 | if(!IsCorrectS3(argstr)) |
| 1491 | { |
| 1492 | printf("\tMarshalStructS3ByRef_Cdecl: S3 param not as expected\n" ); |
| 1493 | PrintS3(argstr,"argstr" ); |
| 1494 | return FALSE; |
| 1495 | } |
| 1496 | ChangeS3(argstr); |
| 1497 | return TRUE; |
| 1498 | } |
| 1499 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS3ByRef_StdCall(S3* argstr) |
| 1500 | { |
| 1501 | if(!IsCorrectS3(argstr)) |
| 1502 | { |
| 1503 | printf("\tMarshalStructS3ByRef_StdCall: S3 param not as expected\n" ); |
| 1504 | PrintS3(argstr,"argstr" ); |
| 1505 | return FALSE; |
| 1506 | } |
| 1507 | ChangeS3(argstr); |
| 1508 | return TRUE; |
| 1509 | } |
| 1510 | typedef BOOL (_cdecl *S3ByRefCdeclCaller)(S3* pcs); |
| 1511 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS3ByRef_Cdecl(S3ByRefCdeclCaller caller) |
| 1512 | { |
| 1513 | //Init |
| 1514 | S3 argstr; |
| 1515 | |
| 1516 | argstr.flag = false; |
| 1517 | const char* strSource = "change string" ; |
| 1518 | size_t len =strlen(strSource) + 1; |
| 1519 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1520 | if(temp != NULL) |
| 1521 | { |
| 1522 | strcpy_s((char*)temp,len,strSource); |
| 1523 | argstr.str = temp; |
| 1524 | } |
| 1525 | for(int i = 1;i<257;i++) |
| 1526 | { |
| 1527 | argstr.vals[i-1] = i; |
| 1528 | } |
| 1529 | |
| 1530 | if(!caller(&argstr)) |
| 1531 | { |
| 1532 | printf("DoCallBack_MarshalStructS3ByRef_Cdecl:The Caller returns wrong value\n" ); |
| 1533 | return FALSE; |
| 1534 | } |
| 1535 | //Verify the value unchanged |
| 1536 | if(!IsCorrectS3(&argstr)) |
| 1537 | { |
| 1538 | printf("The parameter for DoCallBack_MarshalStructS3ByRef_Cdecl is wrong\n" ); |
| 1539 | return FALSE; |
| 1540 | } |
| 1541 | return TRUE; |
| 1542 | } |
| 1543 | |
| 1544 | typedef BOOL (__stdcall *S3ByRefStdCallCaller)(S3* pcs); |
| 1545 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS3ByRef_StdCall(S3ByRefStdCallCaller caller) |
| 1546 | { |
| 1547 | //Init |
| 1548 | S3 argstr; |
| 1549 | |
| 1550 | argstr.flag = false; |
| 1551 | const char* strSource = "change string" ; |
| 1552 | size_t len =strlen(strSource) + 1; |
| 1553 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1554 | if(temp != NULL) |
| 1555 | { |
| 1556 | strcpy_s((char*)temp,len,strSource); |
| 1557 | argstr.str = temp; |
| 1558 | } |
| 1559 | for(int i = 1;i<257;i++) |
| 1560 | { |
| 1561 | argstr.vals[i-1] = i; |
| 1562 | } |
| 1563 | |
| 1564 | if(!caller(&argstr)) |
| 1565 | { |
| 1566 | printf("DoCallBack_MarshalStructS3ByRef_StdCall:The Caller returns wrong value\n" ); |
| 1567 | return FALSE; |
| 1568 | } |
| 1569 | //Verify the value unchanged |
| 1570 | if(!IsCorrectS3(&argstr)) |
| 1571 | { |
| 1572 | printf("The parameter for DoCallBack_MarshalStructS3ByRef_StdCall is wrong\n" ); |
| 1573 | return FALSE; |
| 1574 | } |
| 1575 | return TRUE; |
| 1576 | } |
| 1577 | //Delegate PInvoke,passbyref |
| 1578 | typedef BOOL (_cdecl *S3DelegatePInvokeByRefCdeclCaller)(S3* pcs); |
| 1579 | extern "C" DLL_EXPORT S3DelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructS3ByRef_Cdecl_FuncPtr() |
| 1580 | { |
| 1581 | return MarshalStructS3ByRef_Cdecl; |
| 1582 | } |
| 1583 | |
| 1584 | typedef BOOL (__stdcall *S3DelegatePInvokeByRefStdCallCaller)(S3* pcs); |
| 1585 | extern "C" DLL_EXPORT S3DelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructS3ByRef_StdCall_FuncPtr() |
| 1586 | { |
| 1587 | return MarshalStructS3ByRef_StdCall; |
| 1588 | } |
| 1589 | |
| 1590 | |
| 1591 | //Passby value |
| 1592 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS3ByVal_Cdecl(S3 argstr) |
| 1593 | { |
| 1594 | //Check the Input |
| 1595 | if(!IsCorrectS3(&argstr)) |
| 1596 | { |
| 1597 | printf("\tMarshalStructS3ByVal_Cdecl: S3 param not as expected\n" ); |
| 1598 | PrintS3(&argstr,"argstr" ); |
| 1599 | return FALSE; |
| 1600 | } |
| 1601 | |
| 1602 | argstr.flag = false; |
| 1603 | const char* strSource = "change string" ; |
| 1604 | size_t len =strlen(strSource) + 1; |
| 1605 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1606 | if(temp != NULL) |
| 1607 | { |
| 1608 | strcpy_s((char*)temp,len,strSource); |
| 1609 | argstr.str = temp; |
| 1610 | } |
| 1611 | for(int i = 1;i<257;i++) |
| 1612 | { |
| 1613 | argstr.vals[i-1] = i; |
| 1614 | } |
| 1615 | return TRUE; |
| 1616 | } |
| 1617 | |
| 1618 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS3ByVal_StdCall(S3 argstr) |
| 1619 | { |
| 1620 | //Check the Input |
| 1621 | if(!IsCorrectS3(&argstr)) |
| 1622 | { |
| 1623 | printf("\tMarshalStructS3ByVal_StdCall: S3 param not as expected\n" ); |
| 1624 | PrintS3(&argstr,"argstr" ); |
| 1625 | return FALSE; |
| 1626 | } |
| 1627 | |
| 1628 | argstr.flag = false; |
| 1629 | const char* strSource = "change string" ; |
| 1630 | size_t len =strlen(strSource) + 1; |
| 1631 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1632 | if(temp != NULL) |
| 1633 | { |
| 1634 | strcpy_s((char*)temp,len,strSource); |
| 1635 | argstr.str = temp; |
| 1636 | } |
| 1637 | for(int i = 1;i<257;i++) |
| 1638 | { |
| 1639 | argstr.vals[i-1] = i; |
| 1640 | } |
| 1641 | return TRUE; |
| 1642 | } |
| 1643 | |
| 1644 | typedef BOOL (_cdecl *S3ByValCdeclCaller)(S3 cs); |
| 1645 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS3ByVal_Cdecl(S3ByValCdeclCaller caller) |
| 1646 | { |
| 1647 | //Init |
| 1648 | S3 argstr; |
| 1649 | |
| 1650 | argstr.flag = false; |
| 1651 | const char* strSource = "change string" ; |
| 1652 | size_t len =strlen(strSource) + 1; |
| 1653 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1654 | if(temp != NULL) |
| 1655 | { |
| 1656 | strcpy_s((char*)temp,len,strSource); |
| 1657 | argstr.str = temp; |
| 1658 | } |
| 1659 | for(int i = 1;i<257;i++) |
| 1660 | { |
| 1661 | argstr.vals[i-1] = i; |
| 1662 | } |
| 1663 | |
| 1664 | if(!caller(argstr)) |
| 1665 | { |
| 1666 | printf("DoCallBack_MarshalStructS3ByVal_Cdecl:The Caller returns wrong value\n" ); |
| 1667 | return FALSE; |
| 1668 | } |
| 1669 | |
| 1670 | //Verify the value unchanged |
| 1671 | int iflag = 0; |
| 1672 | if(argstr.flag || strcmp((char*)argstr.str,"change string" ) != 0) |
| 1673 | return false; |
| 1674 | for (int i = 1; i < 257; i++) |
| 1675 | { |
| 1676 | if (argstr.vals[i-1] != i) |
| 1677 | { |
| 1678 | printf("\tThe Index of %i is not expected" ,i); |
| 1679 | iflag++; |
| 1680 | } |
| 1681 | } |
| 1682 | if (iflag != 0) |
| 1683 | { |
| 1684 | return false; |
| 1685 | } |
| 1686 | |
| 1687 | return TRUE; |
| 1688 | } |
| 1689 | |
| 1690 | typedef BOOL (__stdcall *S3ByValStdCallCaller)(S3 cs); |
| 1691 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS3ByVal_StdCall(S3ByValStdCallCaller caller) |
| 1692 | { |
| 1693 | //Init |
| 1694 | S3 argstr; |
| 1695 | |
| 1696 | argstr.flag = false; |
| 1697 | const char* strSource = "change string" ; |
| 1698 | size_t len =strlen(strSource) + 1; |
| 1699 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1700 | if(temp != NULL) |
| 1701 | { |
| 1702 | strcpy_s((char*)temp,len,strSource); |
| 1703 | argstr.str = temp; |
| 1704 | } |
| 1705 | for(int i = 1;i<257;i++) |
| 1706 | { |
| 1707 | argstr.vals[i-1] = i; |
| 1708 | } |
| 1709 | |
| 1710 | if(!caller(argstr)) |
| 1711 | { |
| 1712 | printf("DoCallBack_MarshalStructS3ByVal_StdCall:The Caller returns wrong value\n" ); |
| 1713 | return FALSE; |
| 1714 | } |
| 1715 | |
| 1716 | //Verify the value unchanged |
| 1717 | int iflag = 0; |
| 1718 | if(argstr.flag || strcmp((char*)argstr.str,"change string" ) != 0) |
| 1719 | return false; |
| 1720 | for (int i = 1; i < 257; i++) |
| 1721 | { |
| 1722 | if (argstr.vals[i-1] != i) |
| 1723 | { |
| 1724 | printf("\tThe Index of %i is not expected" ,i); |
| 1725 | iflag++; |
| 1726 | } |
| 1727 | } |
| 1728 | if (iflag != 0) |
| 1729 | { |
| 1730 | return false; |
| 1731 | } |
| 1732 | return TRUE; |
| 1733 | } |
| 1734 | //Delegate PInvoke,passbyval |
| 1735 | typedef BOOL (_cdecl *S3DelegatePInvokeByValCdeclCaller)(S3 cs); |
| 1736 | extern "C" DLL_EXPORT S3DelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructS3ByVal_Cdecl_FuncPtr() |
| 1737 | { |
| 1738 | return MarshalStructS3ByVal_Cdecl; |
| 1739 | } |
| 1740 | |
| 1741 | typedef BOOL (__stdcall *S3DelegatePInvokeByValStdCallCaller)(S3 cs); |
| 1742 | extern "C" DLL_EXPORT S3DelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructS3ByVal_StdCall_FuncPtr() |
| 1743 | { |
| 1744 | return MarshalStructS3ByVal_StdCall; |
| 1745 | } |
| 1746 | |
| 1747 | |
| 1748 | |
| 1749 | ///////////////////////////////////////////Methods for S5 struct//////////////////////////////////////////////////// |
| 1750 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS5ByRef_Cdecl(S5* argstr) |
| 1751 | { |
| 1752 | if(!IsCorrectS5(argstr)) |
| 1753 | { |
| 1754 | printf("\tMarshalStructS5ByRef_Cdecl: S5 param not as expected\n" ); |
| 1755 | PrintS5(argstr,"argstr" ); |
| 1756 | return FALSE; |
| 1757 | } |
| 1758 | ChangeS5(argstr); |
| 1759 | return TRUE; |
| 1760 | } |
| 1761 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS5ByRef_StdCall(S5* argstr) |
| 1762 | { |
| 1763 | if(!IsCorrectS5(argstr)) |
| 1764 | { |
| 1765 | printf("\tMarshalStructS5ByRef_StdCall: S5 param not as expected\n" ); |
| 1766 | PrintS5(argstr,"argstr" ); |
| 1767 | return FALSE; |
| 1768 | } |
| 1769 | ChangeS5(argstr); |
| 1770 | return TRUE; |
| 1771 | } |
| 1772 | typedef BOOL (_cdecl *S5ByRefCdeclCaller)(S5* pcs); |
| 1773 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS5ByRef_Cdecl(S5ByRefCdeclCaller caller) |
| 1774 | { |
| 1775 | //Init |
| 1776 | S5 argstr; |
| 1777 | |
| 1778 | Enum1 eInstance = e2; |
| 1779 | const char* strSource = "change string" ; |
| 1780 | size_t len =strlen(strSource) + 1; |
| 1781 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1782 | if(temp != NULL) |
| 1783 | { |
| 1784 | strcpy_s((char*)temp,len,strSource); |
| 1785 | argstr.s4.name = temp; |
| 1786 | } |
| 1787 | argstr.s4.age = 64; |
| 1788 | argstr.ef = eInstance; |
| 1789 | |
| 1790 | if(!caller(&argstr)) |
| 1791 | { |
| 1792 | printf("DoCallBack_MarshalStructS5ByRef_Cdecl:The Caller returns wrong value\n" ); |
| 1793 | return FALSE; |
| 1794 | } |
| 1795 | //Verify the value unchanged |
| 1796 | if(!IsCorrectS5(&argstr)) |
| 1797 | { |
| 1798 | printf("The parameter for DoCallBack_MarshalStructS5ByRef_Cdecl is wrong\n" ); |
| 1799 | return FALSE; |
| 1800 | } |
| 1801 | return TRUE; |
| 1802 | } |
| 1803 | |
| 1804 | typedef BOOL (__stdcall *S5ByRefStdCallCaller)(S5* pcs); |
| 1805 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS5ByRef_StdCall(S5ByRefStdCallCaller caller) |
| 1806 | { |
| 1807 | //Init |
| 1808 | S5 argstr; |
| 1809 | |
| 1810 | Enum1 eInstance = e2; |
| 1811 | const char* strSource = "change string" ; |
| 1812 | size_t len =strlen(strSource) + 1; |
| 1813 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1814 | if(temp != NULL) |
| 1815 | { |
| 1816 | strcpy_s((char*)temp,len,strSource); |
| 1817 | argstr.s4.name = temp; |
| 1818 | } |
| 1819 | argstr.s4.age = 64; |
| 1820 | argstr.ef = eInstance; |
| 1821 | |
| 1822 | if(!caller(&argstr)) |
| 1823 | { |
| 1824 | printf("DoCallBack_MarshalStructS5ByRef_StdCall:The Caller returns wrong value\n" ); |
| 1825 | return FALSE; |
| 1826 | } |
| 1827 | //Verify the value unchanged |
| 1828 | if(!IsCorrectS5(&argstr)) |
| 1829 | { |
| 1830 | printf("The parameter for DoCallBack_MarshalStructS5ByRef_StdCall is wrong\n" ); |
| 1831 | return FALSE; |
| 1832 | } |
| 1833 | return TRUE; |
| 1834 | } |
| 1835 | //Delegate PInvoke,passbyref |
| 1836 | typedef BOOL (_cdecl *S5DelegatePInvokeByRefCdeclCaller)(S5* pcs); |
| 1837 | extern "C" DLL_EXPORT S5DelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructS5ByRef_Cdecl_FuncPtr() |
| 1838 | { |
| 1839 | return MarshalStructS5ByRef_Cdecl; |
| 1840 | } |
| 1841 | |
| 1842 | typedef BOOL (__stdcall *S5DelegatePInvokeByRefStdCallCaller)(S5* pcs); |
| 1843 | extern "C" DLL_EXPORT S5DelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructS5ByRef_StdCall_FuncPtr() |
| 1844 | { |
| 1845 | return MarshalStructS5ByRef_StdCall; |
| 1846 | } |
| 1847 | |
| 1848 | |
| 1849 | //Passby value |
| 1850 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS5ByVal_Cdecl(S5 argstr) |
| 1851 | { |
| 1852 | //Check the Input |
| 1853 | if(!IsCorrectS5(&argstr)) |
| 1854 | { |
| 1855 | printf("\tMarshalStructS5ByVal_Cdecl: S5 param not as expected\n" ); |
| 1856 | PrintS5(&argstr,"argstr" ); |
| 1857 | return FALSE; |
| 1858 | } |
| 1859 | |
| 1860 | Enum1 eInstance = e2; |
| 1861 | const char* strSource = "change string" ; |
| 1862 | size_t len =strlen(strSource) + 1; |
| 1863 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1864 | if(temp != NULL) |
| 1865 | { |
| 1866 | strcpy_s((char*)temp,len,strSource); |
| 1867 | argstr.s4.name = temp; |
| 1868 | } |
| 1869 | argstr.s4.age = 64; |
| 1870 | argstr.ef = eInstance; |
| 1871 | |
| 1872 | return TRUE; |
| 1873 | } |
| 1874 | |
| 1875 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS5ByVal_StdCall(S5 argstr) |
| 1876 | { |
| 1877 | //Check the Input |
| 1878 | if(!IsCorrectS5(&argstr)) |
| 1879 | { |
| 1880 | printf("\tMarshalStructS5ByVal_StdCall: S5 param not as expected\n" ); |
| 1881 | PrintS5(&argstr,"argstr" ); |
| 1882 | return FALSE; |
| 1883 | } |
| 1884 | |
| 1885 | Enum1 eInstance = e2; |
| 1886 | const char* strSource = "change string" ; |
| 1887 | size_t len =strlen(strSource) + 1; |
| 1888 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1889 | if(temp != NULL) |
| 1890 | { |
| 1891 | strcpy_s((char*)temp,len,strSource); |
| 1892 | argstr.s4.name = temp; |
| 1893 | } |
| 1894 | argstr.s4.age = 64; |
| 1895 | argstr.ef = eInstance; |
| 1896 | return TRUE; |
| 1897 | } |
| 1898 | |
| 1899 | typedef BOOL (_cdecl *S5ByValCdeclCaller)(S5 cs); |
| 1900 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS5ByVal_Cdecl(S5ByValCdeclCaller caller) |
| 1901 | { |
| 1902 | //Init |
| 1903 | S5 argstr{}; |
| 1904 | |
| 1905 | Enum1 eInstance = e2; |
| 1906 | const char* strSource = "change string" ; |
| 1907 | size_t len =strlen(strSource) + 1; |
| 1908 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1909 | if(temp != NULL) |
| 1910 | { |
| 1911 | strcpy_s((char*)temp,len,strSource); |
| 1912 | argstr.s4.name = temp; |
| 1913 | } |
| 1914 | argstr.s4.age = 64; |
| 1915 | argstr.ef = eInstance; |
| 1916 | |
| 1917 | if(!caller(argstr)) |
| 1918 | { |
| 1919 | printf("DoCallBack_MarshalStructS5ByVal_Cdecl:The Caller returns wrong value\n" ); |
| 1920 | return FALSE; |
| 1921 | } |
| 1922 | |
| 1923 | //Verify the value unchanged |
| 1924 | if(argstr.s4.age != 64 || strcmp((char*)argstr.s4.name,"change string" ) != 0) |
| 1925 | return false; |
| 1926 | if(argstr.ef != eInstance) |
| 1927 | { |
| 1928 | return false; |
| 1929 | } |
| 1930 | return TRUE; |
| 1931 | } |
| 1932 | |
| 1933 | typedef BOOL (__stdcall *S5ByValStdCallCaller)(S5 cs); |
| 1934 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS5ByVal_StdCall(S5ByValStdCallCaller caller) |
| 1935 | { |
| 1936 | //Init |
| 1937 | S5 argstr{}; |
| 1938 | |
| 1939 | Enum1 eInstance = e2; |
| 1940 | const char* strSource = "change string" ; |
| 1941 | size_t len =strlen(strSource) + 1; |
| 1942 | LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len); |
| 1943 | if(temp != NULL) |
| 1944 | { |
| 1945 | strcpy_s((char*)temp,len,strSource); |
| 1946 | argstr.s4.name = temp; |
| 1947 | } |
| 1948 | argstr.s4.age = 64; |
| 1949 | argstr.ef = eInstance; |
| 1950 | |
| 1951 | if(!caller(argstr)) |
| 1952 | { |
| 1953 | printf("DoCallBack_MarshalStructS5ByVal_StdCall:The Caller returns wrong value\n" ); |
| 1954 | return FALSE; |
| 1955 | } |
| 1956 | |
| 1957 | //Verify the value unchanged |
| 1958 | if(argstr.s4.age != 64 || strcmp((char*)argstr.s4.name,"change string" ) != 0) |
| 1959 | return false; |
| 1960 | if(argstr.ef != eInstance) |
| 1961 | { |
| 1962 | return false; |
| 1963 | } |
| 1964 | return TRUE; |
| 1965 | } |
| 1966 | //Delegate PInvoke,passbyval |
| 1967 | typedef BOOL (_cdecl *S5DelegatePInvokeByValCdeclCaller)(S5 cs); |
| 1968 | extern "C" DLL_EXPORT S5DelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructS5ByVal_Cdecl_FuncPtr() |
| 1969 | { |
| 1970 | return MarshalStructS5ByVal_Cdecl; |
| 1971 | } |
| 1972 | |
| 1973 | typedef BOOL (__stdcall *S5DelegatePInvokeByValStdCallCaller)(S5 cs); |
| 1974 | extern "C" DLL_EXPORT S5DelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructS5ByVal_StdCall_FuncPtr() |
| 1975 | { |
| 1976 | return MarshalStructS5ByVal_StdCall; |
| 1977 | } |
| 1978 | |
| 1979 | |
| 1980 | ///////////////////////////////////////////Methods for StringStructSequentialAnsi struct//////////////////////////////////////////////////// |
| 1981 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructStringStructSequentialAnsiByRef_Cdecl(StringStructSequentialAnsi* argstr) |
| 1982 | { |
| 1983 | if(!IsCorrectStringStructSequentialAnsi(argstr)) |
| 1984 | { |
| 1985 | printf("\tMarshalStructStringStructSequentialAnsiByRef_Cdecl: StringStructSequentialAnsi param not as expected\n" ); |
| 1986 | PrintStringStructSequentialAnsi(argstr,"argstr" ); |
| 1987 | return FALSE; |
| 1988 | } |
| 1989 | ChangeStringStructSequentialAnsi(argstr); |
| 1990 | return TRUE; |
| 1991 | } |
| 1992 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructStringStructSequentialAnsiByRef_StdCall(StringStructSequentialAnsi* argstr) |
| 1993 | { |
| 1994 | if(!IsCorrectStringStructSequentialAnsi(argstr)) |
| 1995 | { |
| 1996 | printf("\tMarshalStructStringStructSequentialAnsiByRef_StdCall: StringStructSequentialAnsi param not as expected\n" ); |
| 1997 | PrintStringStructSequentialAnsi(argstr,"argstr" ); |
| 1998 | return FALSE; |
| 1999 | } |
| 2000 | ChangeStringStructSequentialAnsi(argstr); |
| 2001 | return TRUE; |
| 2002 | } |
| 2003 | typedef BOOL (_cdecl *StringStructSequentialAnsiByRefCdeclCaller)(StringStructSequentialAnsi* pcs); |
| 2004 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructStringStructSequentialAnsiByRef_Cdecl(StringStructSequentialAnsiByRefCdeclCaller caller) |
| 2005 | { |
| 2006 | //Init |
| 2007 | StringStructSequentialAnsi argstr; |
| 2008 | |
| 2009 | char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2010 | char* newLast = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2011 | for (int i = 0; i < 512; ++i) |
| 2012 | { |
| 2013 | newFirst[i] = 'b'; |
| 2014 | newLast[i] = 'a'; |
| 2015 | } |
| 2016 | newFirst[512] = '\0'; |
| 2017 | newLast[512] = '\0'; |
| 2018 | argstr.first = newFirst; |
| 2019 | argstr.last = newLast; |
| 2020 | |
| 2021 | if(!caller(&argstr)) |
| 2022 | { |
| 2023 | printf("DoCallBack_MarshalStructStringStructSequentialAnsiByRef_Cdecl:The Caller returns wrong value\n" ); |
| 2024 | return FALSE; |
| 2025 | } |
| 2026 | //Verify the value unchanged |
| 2027 | if(!IsCorrectStringStructSequentialAnsi(&argstr)) |
| 2028 | { |
| 2029 | printf("The parameter for DoCallBack_MarshalStructStringStructSequentialAnsiByRef_Cdecl is wrong\n" ); |
| 2030 | return FALSE; |
| 2031 | } |
| 2032 | return TRUE; |
| 2033 | } |
| 2034 | |
| 2035 | typedef BOOL (__stdcall *StringStructSequentialAnsiByRefStdCallCaller)(StringStructSequentialAnsi* pcs); |
| 2036 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructStringStructSequentialAnsiByRef_StdCall(StringStructSequentialAnsiByRefStdCallCaller caller) |
| 2037 | { |
| 2038 | //Init |
| 2039 | StringStructSequentialAnsi argstr; |
| 2040 | |
| 2041 | char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2042 | char* newLast = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2043 | for (int i = 0; i < 512; ++i) |
| 2044 | { |
| 2045 | newFirst[i] = 'b'; |
| 2046 | newLast[i] = 'a'; |
| 2047 | } |
| 2048 | newFirst[512] = '\0'; |
| 2049 | newLast[512] = '\0'; |
| 2050 | argstr.first = newFirst; |
| 2051 | argstr.last = newLast; |
| 2052 | |
| 2053 | if(!caller(&argstr)) |
| 2054 | { |
| 2055 | printf("DoCallBack_MarshalStructStringStructSequentialAnsiByRef_StdCall:The Caller returns wrong value\n" ); |
| 2056 | return FALSE; |
| 2057 | } |
| 2058 | //Verify the value unchanged |
| 2059 | if(!IsCorrectStringStructSequentialAnsi(&argstr)) |
| 2060 | { |
| 2061 | printf("The parameter for DoCallBack_MarshalStructStringStructSequentialAnsiByRef_StdCall is wrong\n" ); |
| 2062 | return FALSE; |
| 2063 | } |
| 2064 | return TRUE; |
| 2065 | } |
| 2066 | //Delegate PInvoke,passbyref |
| 2067 | typedef BOOL (_cdecl *StringStructSequentialAnsiDelegatePInvokeByRefCdeclCaller)(StringStructSequentialAnsi* pcs); |
| 2068 | extern "C" DLL_EXPORT StringStructSequentialAnsiDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructStringStructSequentialAnsiByRef_Cdecl_FuncPtr() |
| 2069 | { |
| 2070 | return MarshalStructStringStructSequentialAnsiByRef_Cdecl; |
| 2071 | } |
| 2072 | |
| 2073 | typedef BOOL (__stdcall *StringStructSequentialAnsiDelegatePInvokeByRefStdCallCaller)(StringStructSequentialAnsi* pcs); |
| 2074 | extern "C" DLL_EXPORT StringStructSequentialAnsiDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructStringStructSequentialAnsiByRef_StdCall_FuncPtr() |
| 2075 | { |
| 2076 | return MarshalStructStringStructSequentialAnsiByRef_StdCall; |
| 2077 | } |
| 2078 | |
| 2079 | |
| 2080 | //Passby value |
| 2081 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructStringStructSequentialAnsiByVal_Cdecl(StringStructSequentialAnsi argstr) |
| 2082 | { |
| 2083 | //Check the Input |
| 2084 | if(!IsCorrectStringStructSequentialAnsi(&argstr)) |
| 2085 | { |
| 2086 | printf("\tMarshalStructStringStructSequentialAnsiByVal_Cdecl: StringStructSequentialAnsi param not as expected\n" ); |
| 2087 | PrintStringStructSequentialAnsi(&argstr,"argstr" ); |
| 2088 | return FALSE; |
| 2089 | } |
| 2090 | |
| 2091 | char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2092 | char* newLast = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2093 | for (int i = 0; i < 512; ++i) |
| 2094 | { |
| 2095 | newFirst[i] = 'b'; |
| 2096 | newLast[i] = 'a'; |
| 2097 | } |
| 2098 | newFirst[512] = '\0'; |
| 2099 | newLast[512] = '\0'; |
| 2100 | argstr.first = newFirst; |
| 2101 | argstr.last = newLast; |
| 2102 | |
| 2103 | return TRUE; |
| 2104 | } |
| 2105 | |
| 2106 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructStringStructSequentialAnsiByVal_StdCall(StringStructSequentialAnsi argstr) |
| 2107 | { |
| 2108 | //Check the Input |
| 2109 | if(!IsCorrectStringStructSequentialAnsi(&argstr)) |
| 2110 | { |
| 2111 | printf("\tMarshalStructStringStructSequentialAnsiByVal_StdCall: StringStructSequentialAnsi param not as expected\n" ); |
| 2112 | PrintStringStructSequentialAnsi(&argstr,"argstr" ); |
| 2113 | return FALSE; |
| 2114 | } |
| 2115 | |
| 2116 | char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2117 | char* newLast = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2118 | for (int i = 0; i < 512; ++i) |
| 2119 | { |
| 2120 | newFirst[i] = 'b'; |
| 2121 | newLast[i] = 'a'; |
| 2122 | } |
| 2123 | newFirst[512] = '\0'; |
| 2124 | newLast[512] = '\0'; |
| 2125 | argstr.first = newFirst; |
| 2126 | argstr.last = newLast; |
| 2127 | |
| 2128 | return TRUE; |
| 2129 | } |
| 2130 | |
| 2131 | typedef BOOL (_cdecl *StringStructSequentialAnsiByValCdeclCaller)(StringStructSequentialAnsi cs); |
| 2132 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructStringStructSequentialAnsiByVal_Cdecl(StringStructSequentialAnsiByValCdeclCaller caller) |
| 2133 | { |
| 2134 | //Init |
| 2135 | StringStructSequentialAnsi argstr; |
| 2136 | char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2137 | char* newLast = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2138 | for (int i = 0; i < 512; ++i) |
| 2139 | { |
| 2140 | newFirst[i] = 'b'; |
| 2141 | newLast[i] = 'a'; |
| 2142 | } |
| 2143 | newFirst[512] = '\0'; |
| 2144 | newLast[512] = '\0'; |
| 2145 | argstr.first = newFirst; |
| 2146 | argstr.last = newLast; |
| 2147 | |
| 2148 | if(!caller(argstr)) |
| 2149 | { |
| 2150 | printf("DoCallBack_MarshalStructStringStructSequentialAnsiByVal_Cdecl:The Caller returns wrong value\n" ); |
| 2151 | return FALSE; |
| 2152 | } |
| 2153 | |
| 2154 | //Verify the value unchanged |
| 2155 | if(memcmp(argstr.first,newFirst,512)!= 0) |
| 2156 | return false; |
| 2157 | if(memcmp(argstr.last,newLast,512)!= 0) |
| 2158 | return false; |
| 2159 | |
| 2160 | return TRUE; |
| 2161 | } |
| 2162 | |
| 2163 | typedef BOOL (__stdcall *StringStructSequentialAnsiByValStdCallCaller)(StringStructSequentialAnsi cs); |
| 2164 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructStringStructSequentialAnsiByVal_StdCall(StringStructSequentialAnsiByValStdCallCaller caller) |
| 2165 | { |
| 2166 | //Init |
| 2167 | StringStructSequentialAnsi argstr; |
| 2168 | char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2169 | char* newLast = (char*)CoreClrAlloc(sizeof(char)*513); |
| 2170 | for (int i = 0; i < 512; ++i) |
| 2171 | { |
| 2172 | newFirst[i] = 'b'; |
| 2173 | newLast[i] = 'a'; |
| 2174 | } |
| 2175 | newFirst[512] = '\0'; |
| 2176 | newLast[512] = '\0'; |
| 2177 | argstr.first = newFirst; |
| 2178 | argstr.last = newLast; |
| 2179 | |
| 2180 | if(!caller(argstr)) |
| 2181 | { |
| 2182 | printf("DoCallBack_MarshalStructStringStructSequentialAnsiByVal_StdCall:The Caller returns wrong value\n" ); |
| 2183 | return FALSE; |
| 2184 | } |
| 2185 | |
| 2186 | //Verify the value unchanged |
| 2187 | if(memcmp(argstr.first,newFirst,512)!= 0) |
| 2188 | return false; |
| 2189 | if(memcmp(argstr.last,newLast,512)!= 0) |
| 2190 | return false; |
| 2191 | |
| 2192 | return TRUE; |
| 2193 | } |
| 2194 | //Delegate PInvoke,passbyval |
| 2195 | typedef BOOL (_cdecl *StringStructSequentialAnsiDelegatePInvokeByValCdeclCaller)(StringStructSequentialAnsi cs); |
| 2196 | extern "C" DLL_EXPORT StringStructSequentialAnsiDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructStringStructSequentialAnsiByVal_Cdecl_FuncPtr() |
| 2197 | { |
| 2198 | return MarshalStructStringStructSequentialAnsiByVal_Cdecl; |
| 2199 | } |
| 2200 | |
| 2201 | typedef BOOL (__stdcall *StringStructSequentialAnsiDelegatePInvokeByValStdCallCaller)(StringStructSequentialAnsi cs); |
| 2202 | extern "C" DLL_EXPORT StringStructSequentialAnsiDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructStringStructSequentialAnsiByVal_StdCall_FuncPtr() |
| 2203 | { |
| 2204 | return MarshalStructStringStructSequentialAnsiByVal_StdCall; |
| 2205 | } |
| 2206 | |
| 2207 | |
| 2208 | |
| 2209 | |
| 2210 | ///////////////////////////////////////////Methods for StringStructSequentialUnicode struct//////////////////////////////////////////////////// |
| 2211 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructStringStructSequentialUnicodeByRef_Cdecl(StringStructSequentialUnicode* argstr) |
| 2212 | { |
| 2213 | if(!IsCorrectStringStructSequentialUnicode(argstr)) |
| 2214 | { |
| 2215 | printf("\tMarshalStructStringStructSequentialUnicodeByRef_Cdecl: StringStructSequentialUnicode param not as expected\n" ); |
| 2216 | PrintStringStructSequentialUnicode(argstr,"argstr" ); |
| 2217 | return FALSE; |
| 2218 | } |
| 2219 | ChangeStringStructSequentialUnicode(argstr); |
| 2220 | return TRUE; |
| 2221 | } |
| 2222 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructStringStructSequentialUnicodeByRef_StdCall(StringStructSequentialUnicode* argstr) |
| 2223 | { |
| 2224 | if(!IsCorrectStringStructSequentialUnicode(argstr)) |
| 2225 | { |
| 2226 | printf("\tMarshalStructStringStructSequentialUnicodeByRef_StdCall: StringStructSequentialUnicode param not as expected\n" ); |
| 2227 | PrintStringStructSequentialUnicode(argstr,"argstr" ); |
| 2228 | return FALSE; |
| 2229 | } |
| 2230 | ChangeStringStructSequentialUnicode(argstr); |
| 2231 | return TRUE; |
| 2232 | } |
| 2233 | typedef BOOL (_cdecl *StringStructSequentialUnicodeByRefCdeclCaller)(StringStructSequentialUnicode* pcs); |
| 2234 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructStringStructSequentialUnicodeByRef_Cdecl(StringStructSequentialUnicodeByRefCdeclCaller caller) |
| 2235 | { |
| 2236 | //Init |
| 2237 | StringStructSequentialUnicode argstr; |
| 2238 | |
| 2239 | WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2240 | WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2241 | for (int i = 0; i < 256; ++i) |
| 2242 | { |
| 2243 | newFirst[i] = L'b'; |
| 2244 | newLast[i] = L'a'; |
| 2245 | } |
| 2246 | newFirst[256] = L'\0'; |
| 2247 | newLast[256] = L'\0'; |
| 2248 | argstr.first = (const WCHAR*)newFirst; |
| 2249 | argstr.last = (const WCHAR*)newLast; |
| 2250 | |
| 2251 | if(!caller(&argstr)) |
| 2252 | { |
| 2253 | printf("DoCallBack_MarshalStructStringStructSequentialUnicodeByRef_Cdecl:The Caller returns wrong value\n" ); |
| 2254 | return FALSE; |
| 2255 | } |
| 2256 | //Verify the value unchanged |
| 2257 | if(!IsCorrectStringStructSequentialUnicode(&argstr)) |
| 2258 | { |
| 2259 | printf("The parameter for DoCallBack_MarshalStructStringStructSequentialUnicodeByRef_Cdecl is wrong\n" ); |
| 2260 | return FALSE; |
| 2261 | } |
| 2262 | return TRUE; |
| 2263 | } |
| 2264 | |
| 2265 | typedef BOOL (__stdcall *StringStructSequentialUnicodeByRefStdCallCaller)(StringStructSequentialUnicode* pcs); |
| 2266 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructStringStructSequentialUnicodeByRef_StdCall(StringStructSequentialUnicodeByRefStdCallCaller caller) |
| 2267 | { |
| 2268 | //Init |
| 2269 | StringStructSequentialUnicode argstr; |
| 2270 | |
| 2271 | WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2272 | WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2273 | for (int i = 0; i < 256; ++i) |
| 2274 | { |
| 2275 | newFirst[i] = L'b'; |
| 2276 | newLast[i] = L'a'; |
| 2277 | } |
| 2278 | newFirst[256] = L'\0'; |
| 2279 | newLast[256] = L'\0'; |
| 2280 | argstr.first = (const WCHAR*)newFirst; |
| 2281 | argstr.last = (const WCHAR*)newLast; |
| 2282 | |
| 2283 | if(!caller(&argstr)) |
| 2284 | { |
| 2285 | printf("DoCallBack_MarshalStructStringStructSequentialUnicodeByRef_StdCall:The Caller returns wrong value\n" ); |
| 2286 | return FALSE; |
| 2287 | } |
| 2288 | //Verify the value unchanged |
| 2289 | if(!IsCorrectStringStructSequentialUnicode(&argstr)) |
| 2290 | { |
| 2291 | printf("The parameter for DoCallBack_MarshalStructStringStructSequentialUnicodeByRef_StdCall is wrong\n" ); |
| 2292 | return FALSE; |
| 2293 | } |
| 2294 | return TRUE; |
| 2295 | } |
| 2296 | //Delegate PInvoke,passbyref |
| 2297 | typedef BOOL (_cdecl *StringStructSequentialUnicodeDelegatePInvokeByRefCdeclCaller)(StringStructSequentialUnicode* pcs); |
| 2298 | extern "C" DLL_EXPORT StringStructSequentialUnicodeDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructStringStructSequentialUnicodeByRef_Cdecl_FuncPtr() |
| 2299 | { |
| 2300 | return MarshalStructStringStructSequentialUnicodeByRef_Cdecl; |
| 2301 | } |
| 2302 | |
| 2303 | typedef BOOL (__stdcall *StringStructSequentialUnicodeDelegatePInvokeByRefStdCallCaller)(StringStructSequentialUnicode* pcs); |
| 2304 | extern "C" DLL_EXPORT StringStructSequentialUnicodeDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructStringStructSequentialUnicodeByRef_StdCall_FuncPtr() |
| 2305 | { |
| 2306 | return MarshalStructStringStructSequentialUnicodeByRef_StdCall; |
| 2307 | } |
| 2308 | |
| 2309 | |
| 2310 | //Passby value |
| 2311 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructStringStructSequentialUnicodeByVal_Cdecl(StringStructSequentialUnicode argstr) |
| 2312 | { |
| 2313 | //Check the Input |
| 2314 | if(!IsCorrectStringStructSequentialUnicode(&argstr)) |
| 2315 | { |
| 2316 | printf("\tMarshalStructStringStructSequentialUnicodeByVal_Cdecl: StringStructSequentialUnicode param not as expected\n" ); |
| 2317 | PrintStringStructSequentialUnicode(&argstr,"argstr" ); |
| 2318 | return FALSE; |
| 2319 | } |
| 2320 | |
| 2321 | WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2322 | WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2323 | for (int i = 0; i < 256; ++i) |
| 2324 | { |
| 2325 | newFirst[i] = L'b'; |
| 2326 | newLast[i] = L'a'; |
| 2327 | } |
| 2328 | newFirst[256] = L'\0'; |
| 2329 | newLast[256] = L'\0'; |
| 2330 | argstr.first = (const WCHAR*)newFirst; |
| 2331 | argstr.last = (const WCHAR*)newLast; |
| 2332 | |
| 2333 | return TRUE; |
| 2334 | } |
| 2335 | |
| 2336 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructStringStructSequentialUnicodeByVal_StdCall(StringStructSequentialUnicode argstr) |
| 2337 | { |
| 2338 | //Check the Input |
| 2339 | if(!IsCorrectStringStructSequentialUnicode(&argstr)) |
| 2340 | { |
| 2341 | printf("\tMarshalStructStringStructSequentialUnicodeByVal_StdCall: StringStructSequentialUnicode param not as expected\n" ); |
| 2342 | PrintStringStructSequentialUnicode(&argstr,"argstr" ); |
| 2343 | return FALSE; |
| 2344 | } |
| 2345 | |
| 2346 | WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2347 | WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2348 | for (int i = 0; i < 256; ++i) |
| 2349 | { |
| 2350 | newFirst[i] = L'b'; |
| 2351 | newLast[i] = L'a'; |
| 2352 | } |
| 2353 | newFirst[256] = L'\0'; |
| 2354 | newLast[256] = L'\0'; |
| 2355 | argstr.first = (const WCHAR*)newFirst; |
| 2356 | argstr.last = (const WCHAR*)newLast; |
| 2357 | |
| 2358 | return TRUE; |
| 2359 | } |
| 2360 | |
| 2361 | typedef BOOL (_cdecl *StringStructSequentialUnicodeByValCdeclCaller)(StringStructSequentialUnicode cs); |
| 2362 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructStringStructSequentialUnicodeByVal_Cdecl(StringStructSequentialUnicodeByValCdeclCaller caller) |
| 2363 | { |
| 2364 | //Init |
| 2365 | StringStructSequentialUnicode argstr; |
| 2366 | |
| 2367 | WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2368 | WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2369 | for (int i = 0; i < 256; ++i) |
| 2370 | { |
| 2371 | newFirst[i] = L'b'; |
| 2372 | newLast[i] = L'a'; |
| 2373 | } |
| 2374 | newFirst[256] = L'\0'; |
| 2375 | newLast[256] = L'\0'; |
| 2376 | argstr.first = (const WCHAR*)newFirst; |
| 2377 | argstr.last = (const WCHAR*)newLast; |
| 2378 | |
| 2379 | if(!caller(argstr)) |
| 2380 | { |
| 2381 | printf("DoCallBack_MarshalStructStringStructSequentialUnicodeByVal_Cdecl:The Caller returns wrong value\n" ); |
| 2382 | return FALSE; |
| 2383 | } |
| 2384 | |
| 2385 | //Verify the value unchanged |
| 2386 | if(memcmp(argstr.first,newFirst,256*sizeof(WCHAR)) != 0) |
| 2387 | return false; |
| 2388 | if(memcmp(argstr.last,newLast,256*sizeof(WCHAR)) != 0) |
| 2389 | return false; |
| 2390 | |
| 2391 | return TRUE; |
| 2392 | } |
| 2393 | |
| 2394 | typedef BOOL (__stdcall *StringStructSequentialUnicodeByValStdCallCaller)(StringStructSequentialUnicode cs); |
| 2395 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructStringStructSequentialUnicodeByVal_StdCall(StringStructSequentialUnicodeByValStdCallCaller caller) |
| 2396 | { |
| 2397 | //Init |
| 2398 | StringStructSequentialUnicode argstr; |
| 2399 | |
| 2400 | WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2401 | WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257); |
| 2402 | for (int i = 0; i < 256; ++i) |
| 2403 | { |
| 2404 | newFirst[i] = L'b'; |
| 2405 | newLast[i] = L'a'; |
| 2406 | } |
| 2407 | newFirst[256] = L'\0'; |
| 2408 | newLast[256] = L'\0'; |
| 2409 | argstr.first = (const WCHAR*)newFirst; |
| 2410 | argstr.last = (const WCHAR*)newLast; |
| 2411 | |
| 2412 | if(!caller(argstr)) |
| 2413 | { |
| 2414 | printf("DoCallBack_MarshalStructStringStructSequentialUnicodeByVal_StdCall:The Caller returns wrong value\n" ); |
| 2415 | return FALSE; |
| 2416 | } |
| 2417 | |
| 2418 | //Verify the value unchanged |
| 2419 | if(memcmp(argstr.first,newFirst,256*sizeof(WCHAR)) != 0) |
| 2420 | return false; |
| 2421 | if(memcmp(argstr.last,newLast,256*sizeof(WCHAR)) != 0) |
| 2422 | return false; |
| 2423 | |
| 2424 | return TRUE; |
| 2425 | } |
| 2426 | //Delegate PInvoke,passbyval |
| 2427 | typedef BOOL (_cdecl *StringStructSequentialUnicodeDelegatePInvokeByValCdeclCaller)(StringStructSequentialUnicode cs); |
| 2428 | extern "C" DLL_EXPORT StringStructSequentialUnicodeDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructStringStructSequentialUnicodeByVal_Cdecl_FuncPtr() |
| 2429 | { |
| 2430 | return MarshalStructStringStructSequentialUnicodeByVal_Cdecl; |
| 2431 | } |
| 2432 | |
| 2433 | typedef BOOL (__stdcall *StringStructSequentialUnicodeDelegatePInvokeByValStdCallCaller)(StringStructSequentialUnicode cs); |
| 2434 | extern "C" DLL_EXPORT StringStructSequentialUnicodeDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructStringStructSequentialUnicodeByVal_StdCall_FuncPtr() |
| 2435 | { |
| 2436 | return MarshalStructStringStructSequentialUnicodeByVal_StdCall; |
| 2437 | } |
| 2438 | |
| 2439 | |
| 2440 | |
| 2441 | |
| 2442 | ///////////////////////////////////////////Methods for S8 struct//////////////////////////////////////////////////// |
| 2443 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS8ByRef_Cdecl(S8* argstr) |
| 2444 | { |
| 2445 | if(!IsCorrectS8(argstr)) |
| 2446 | { |
| 2447 | printf("\tMarshalStructS8ByRef_Cdecl: S8 param not as expected\n" ); |
| 2448 | PrintS8(argstr,"argstr" ); |
| 2449 | return FALSE; |
| 2450 | } |
| 2451 | ChangeS8(argstr); |
| 2452 | return TRUE; |
| 2453 | } |
| 2454 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS8ByRef_StdCall(S8* argstr) |
| 2455 | { |
| 2456 | if(!IsCorrectS8(argstr)) |
| 2457 | { |
| 2458 | printf("\tMarshalStructS8ByRef_StdCall: S8 param not as expected\n" ); |
| 2459 | PrintS8(argstr,"argstr" ); |
| 2460 | return FALSE; |
| 2461 | } |
| 2462 | ChangeS8(argstr); |
| 2463 | return TRUE; |
| 2464 | } |
| 2465 | typedef BOOL (_cdecl *S8ByRefCdeclCaller)(S8* pcs); |
| 2466 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS8ByRef_Cdecl(S8ByRefCdeclCaller caller) |
| 2467 | { |
| 2468 | //Init |
| 2469 | S8 argstr; |
| 2470 | |
| 2471 | const char* lpstr = "world" ; |
| 2472 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 2473 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 2474 | memset(temp, 0, size); |
| 2475 | if(temp) |
| 2476 | { |
| 2477 | strcpy_s((char*)temp,size,lpstr); |
| 2478 | argstr.name = temp; |
| 2479 | } |
| 2480 | else |
| 2481 | { |
| 2482 | printf("Memory Allocated Failed!" ); |
| 2483 | } |
| 2484 | argstr.gender = false; |
| 2485 | argstr.jobNum = 1; |
| 2486 | argstr.i32 = 256; |
| 2487 | argstr.ui32 = 256; |
| 2488 | argstr.mySByte = 64; |
| 2489 | |
| 2490 | if(!caller(&argstr)) |
| 2491 | { |
| 2492 | printf("DoCallBack_MarshalStructS8ByRef_Cdecl:The Caller returns wrong value\n" ); |
| 2493 | return FALSE; |
| 2494 | } |
| 2495 | //Verify the value unchanged |
| 2496 | if(!IsCorrectS8(&argstr)) |
| 2497 | { |
| 2498 | printf("The parameter for DoCallBack_MarshalStructS8ByRef_Cdecl is wrong\n" ); |
| 2499 | return FALSE; |
| 2500 | } |
| 2501 | return TRUE; |
| 2502 | } |
| 2503 | |
| 2504 | typedef BOOL (__stdcall *S8ByRefStdCallCaller)(S8* pcs); |
| 2505 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS8ByRef_StdCall(S8ByRefStdCallCaller caller) |
| 2506 | { |
| 2507 | //Init |
| 2508 | S8 argstr; |
| 2509 | |
| 2510 | const char* lpstr = "world" ; |
| 2511 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 2512 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 2513 | memset(temp, 0, size); |
| 2514 | if(temp) |
| 2515 | { |
| 2516 | strcpy_s((char*)temp,size,lpstr); |
| 2517 | argstr.name = temp; |
| 2518 | } |
| 2519 | else |
| 2520 | { |
| 2521 | printf("Memory Allocated Failed!" ); |
| 2522 | } |
| 2523 | argstr.gender = false; |
| 2524 | argstr.jobNum = 1; |
| 2525 | argstr.i32 = 256; |
| 2526 | argstr.ui32 = 256; |
| 2527 | argstr.mySByte = 64; |
| 2528 | |
| 2529 | if(!caller(&argstr)) |
| 2530 | { |
| 2531 | printf("DoCallBack_MarshalStructS8ByRef_StdCall:The Caller returns wrong value\n" ); |
| 2532 | return FALSE; |
| 2533 | } |
| 2534 | //Verify the value unchanged |
| 2535 | if(!IsCorrectS8(&argstr)) |
| 2536 | { |
| 2537 | printf("The parameter for DoCallBack_MarshalStructS8ByRef_StdCall is wrong\n" ); |
| 2538 | return FALSE; |
| 2539 | } |
| 2540 | return TRUE; |
| 2541 | } |
| 2542 | //Delegate PInvoke,passbyref |
| 2543 | typedef BOOL (_cdecl *S8DelegatePInvokeByRefCdeclCaller)(S8* pcs); |
| 2544 | extern "C" DLL_EXPORT S8DelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructS8ByRef_Cdecl_FuncPtr() |
| 2545 | { |
| 2546 | return MarshalStructS8ByRef_Cdecl; |
| 2547 | } |
| 2548 | |
| 2549 | typedef BOOL (__stdcall *S8DelegatePInvokeByRefStdCallCaller)(S8* pcs); |
| 2550 | extern "C" DLL_EXPORT S8DelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructS8ByRef_StdCall_FuncPtr() |
| 2551 | { |
| 2552 | return MarshalStructS8ByRef_StdCall; |
| 2553 | } |
| 2554 | |
| 2555 | |
| 2556 | //Passby value |
| 2557 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS8ByVal_Cdecl(S8 argstr) |
| 2558 | { |
| 2559 | //Check the Input |
| 2560 | if(!IsCorrectS8(&argstr)) |
| 2561 | { |
| 2562 | printf("\tMarshalStructS8ByVal_Cdecl: S8 param not as expected\n" ); |
| 2563 | PrintS8(&argstr,"argstr" ); |
| 2564 | return FALSE; |
| 2565 | } |
| 2566 | |
| 2567 | const char* lpstr = "world" ; |
| 2568 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 2569 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 2570 | memset(temp, 0, size); |
| 2571 | if(temp) |
| 2572 | { |
| 2573 | strcpy_s((char*)temp,size,lpstr); |
| 2574 | argstr.name = temp; |
| 2575 | } |
| 2576 | else |
| 2577 | { |
| 2578 | printf("Memory Allocated Failed!" ); |
| 2579 | } |
| 2580 | argstr.gender = false; |
| 2581 | argstr.jobNum = 1; |
| 2582 | argstr.i32 = 256; |
| 2583 | argstr.ui32 = 256; |
| 2584 | argstr.mySByte = 64; |
| 2585 | |
| 2586 | return TRUE; |
| 2587 | } |
| 2588 | |
| 2589 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS8ByVal_StdCall(S8 argstr) |
| 2590 | { |
| 2591 | //Check the Input |
| 2592 | if(!IsCorrectS8(&argstr)) |
| 2593 | { |
| 2594 | printf("\tMarshalStructS8ByVal_StdCall: S8 param not as expected\n" ); |
| 2595 | PrintS8(&argstr,"argstr" ); |
| 2596 | return FALSE; |
| 2597 | } |
| 2598 | |
| 2599 | const char* lpstr = "world" ; |
| 2600 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 2601 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 2602 | memset(temp, 0, size); |
| 2603 | if(temp) |
| 2604 | { |
| 2605 | strcpy_s((char*)temp,size,lpstr); |
| 2606 | argstr.name = temp; |
| 2607 | } |
| 2608 | else |
| 2609 | { |
| 2610 | printf("Memory Allocated Failed!" ); |
| 2611 | } |
| 2612 | argstr.gender = false; |
| 2613 | argstr.jobNum = 1; |
| 2614 | argstr.i32 = 256; |
| 2615 | argstr.ui32 = 256; |
| 2616 | argstr.mySByte = 64; |
| 2617 | |
| 2618 | return TRUE; |
| 2619 | } |
| 2620 | |
| 2621 | typedef BOOL (_cdecl *S8ByValCdeclCaller)(S8 cs); |
| 2622 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS8ByVal_Cdecl(S8ByValCdeclCaller caller) |
| 2623 | { |
| 2624 | //Init |
| 2625 | S8 argstr{}; |
| 2626 | |
| 2627 | const char* lpstr = "world" ; |
| 2628 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 2629 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 2630 | memset(temp, 0, size); |
| 2631 | if(temp) |
| 2632 | { |
| 2633 | strcpy_s((char*)temp,size,lpstr); |
| 2634 | argstr.name = temp; |
| 2635 | } |
| 2636 | else |
| 2637 | { |
| 2638 | printf("Memory Allocated Failed!" ); |
| 2639 | } |
| 2640 | argstr.gender = false; |
| 2641 | argstr.jobNum = 1; |
| 2642 | argstr.i32 = 256; |
| 2643 | argstr.ui32 = 256; |
| 2644 | argstr.mySByte = 64; |
| 2645 | |
| 2646 | if(!caller(argstr)) |
| 2647 | { |
| 2648 | printf("DoCallBack_MarshalStructS8ByVal_Cdecl:The Caller returns wrong value\n" ); |
| 2649 | return FALSE; |
| 2650 | } |
| 2651 | |
| 2652 | //Verify the value unchanged |
| 2653 | if(memcmp( argstr.name,"world" , strlen("world" )*sizeof(char)+1 )!= 0) |
| 2654 | return false; |
| 2655 | if(argstr.gender) |
| 2656 | return false; |
| 2657 | if(argstr.jobNum != 1) |
| 2658 | return false; |
| 2659 | if(argstr.i32!= 256 || argstr.ui32 != 256) |
| 2660 | return false; |
| 2661 | if(argstr.mySByte != 64) |
| 2662 | return false; |
| 2663 | |
| 2664 | return TRUE; |
| 2665 | } |
| 2666 | |
| 2667 | typedef BOOL (__stdcall *S8ByValStdCallCaller)(S8 cs); |
| 2668 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS8ByVal_StdCall(S8ByValStdCallCaller caller) |
| 2669 | { |
| 2670 | //Init |
| 2671 | S8 argstr{}; |
| 2672 | |
| 2673 | const char* lpstr = "world" ; |
| 2674 | size_t size = sizeof(char) * (strlen(lpstr) + 1); |
| 2675 | LPSTR temp = (LPSTR)CoreClrAlloc( size ); |
| 2676 | memset(temp, 0, size); |
| 2677 | if(temp) |
| 2678 | { |
| 2679 | strcpy_s((char*)temp,size,lpstr); |
| 2680 | argstr.name = temp; |
| 2681 | } |
| 2682 | else |
| 2683 | { |
| 2684 | printf("Memory Allocated Failed!" ); |
| 2685 | } |
| 2686 | argstr.gender = false; |
| 2687 | argstr.jobNum = 1; |
| 2688 | argstr.i32 = 256; |
| 2689 | argstr.ui32 = 256; |
| 2690 | argstr.mySByte = 64; |
| 2691 | |
| 2692 | if(!caller(argstr)) |
| 2693 | { |
| 2694 | printf("DoCallBack_MarshalStructS8ByVal_StdCall:The Caller returns wrong value\n" ); |
| 2695 | return FALSE; |
| 2696 | } |
| 2697 | |
| 2698 | //Verify the value unchanged |
| 2699 | if(memcmp( argstr.name,"world" , strlen("world" )*sizeof(char)+1 )!= 0) |
| 2700 | return false; |
| 2701 | if(argstr.gender) |
| 2702 | return false; |
| 2703 | if(argstr.jobNum != 1) |
| 2704 | return false; |
| 2705 | if(argstr.i32!= 256 || argstr.ui32 != 256) |
| 2706 | return false; |
| 2707 | if(argstr.mySByte != 64) |
| 2708 | return false; |
| 2709 | return TRUE; |
| 2710 | } |
| 2711 | //Delegate PInvoke,passbyval |
| 2712 | typedef BOOL (_cdecl *S8DelegatePInvokeByValCdeclCaller)(S8 cs); |
| 2713 | extern "C" DLL_EXPORT S8DelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructS8ByVal_Cdecl_FuncPtr() |
| 2714 | { |
| 2715 | return MarshalStructS8ByVal_Cdecl; |
| 2716 | } |
| 2717 | |
| 2718 | typedef BOOL (__stdcall *S8DelegatePInvokeByValStdCallCaller)(S8 cs); |
| 2719 | extern "C" DLL_EXPORT S8DelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructS8ByVal_StdCall_FuncPtr() |
| 2720 | { |
| 2721 | return MarshalStructS8ByVal_StdCall; |
| 2722 | } |
| 2723 | |
| 2724 | |
| 2725 | |
| 2726 | ///////////////////////////////////////////Methods for S9 struct//////////////////////////////////////////////////// |
| 2727 | extern "C" DLL_EXPORT void NtestMethod(S9 str1) |
| 2728 | { |
| 2729 | printf("\tAction of the delegate" ); |
| 2730 | } |
| 2731 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS9ByRef_Cdecl(S9* argstr) |
| 2732 | { |
| 2733 | if(argstr->i32 != 128 || |
| 2734 | argstr->myDelegate1 == NULL) |
| 2735 | { |
| 2736 | printf("\tMarshalStructS9ByRef_Cdecl: S9 param not as expected\n" ); |
| 2737 | return FALSE; |
| 2738 | } |
| 2739 | argstr->i32 = 256; |
| 2740 | argstr->myDelegate1 = NULL; |
| 2741 | return TRUE; |
| 2742 | } |
| 2743 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS9ByRef_StdCall(S9* argstr) |
| 2744 | { |
| 2745 | if(argstr->i32 != 128 || |
| 2746 | argstr->myDelegate1 == NULL) |
| 2747 | { |
| 2748 | printf("\tMarshalStructS9ByRef_StdCall: S9 param not as expected\n" ); |
| 2749 | return FALSE; |
| 2750 | } |
| 2751 | argstr->i32 = 256; |
| 2752 | argstr->myDelegate1 = NULL; |
| 2753 | return TRUE; |
| 2754 | } |
| 2755 | typedef BOOL (_cdecl *S9ByRefCdeclCaller)(S9* pcs); |
| 2756 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS9ByRef_Cdecl(S9ByRefCdeclCaller caller) |
| 2757 | { |
| 2758 | //Init |
| 2759 | S9 argstr; |
| 2760 | |
| 2761 | argstr.i32 = 256; |
| 2762 | argstr.myDelegate1 = NULL; |
| 2763 | |
| 2764 | if(!caller(&argstr)) |
| 2765 | { |
| 2766 | printf("DoCallBack_MarshalStructS9ByRef_Cdecl:The Caller returns wrong value\n" ); |
| 2767 | return FALSE; |
| 2768 | } |
| 2769 | //Verify the value unchanged |
| 2770 | if(argstr.i32 != 128 || |
| 2771 | argstr.myDelegate1 == NULL) |
| 2772 | { |
| 2773 | printf("The parameter for DoCallBack_MarshalStructS9ByRef_Cdecl is wrong\n" ); |
| 2774 | return FALSE; |
| 2775 | } |
| 2776 | return TRUE; |
| 2777 | } |
| 2778 | |
| 2779 | typedef BOOL (__stdcall *S9ByRefStdCallCaller)(S9* pcs); |
| 2780 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS9ByRef_StdCall(S9ByRefStdCallCaller caller) |
| 2781 | { |
| 2782 | //Init |
| 2783 | S9 argstr; |
| 2784 | |
| 2785 | argstr.i32 = 256; |
| 2786 | argstr.myDelegate1 = NULL; |
| 2787 | |
| 2788 | if(!caller(&argstr)) |
| 2789 | { |
| 2790 | printf("DoCallBack_MarshalStructS9ByRef_StdCall:The Caller returns wrong value\n" ); |
| 2791 | return FALSE; |
| 2792 | } |
| 2793 | //Verify the value unchanged |
| 2794 | if(argstr.i32 != 128 || |
| 2795 | argstr.myDelegate1 == NULL) |
| 2796 | { |
| 2797 | printf("The parameter for DoCallBack_MarshalStructS9ByRef_StdCall is wrong\n" ); |
| 2798 | return FALSE; |
| 2799 | } |
| 2800 | return TRUE; |
| 2801 | } |
| 2802 | //Delegate PInvoke,passbyref |
| 2803 | typedef BOOL (_cdecl *S9DelegatePInvokeByRefCdeclCaller)(S9* pcs); |
| 2804 | extern "C" DLL_EXPORT S9DelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructS9ByRef_Cdecl_FuncPtr() |
| 2805 | { |
| 2806 | return MarshalStructS9ByRef_Cdecl; |
| 2807 | } |
| 2808 | |
| 2809 | typedef BOOL (__stdcall *S9DelegatePInvokeByRefStdCallCaller)(S9* pcs); |
| 2810 | extern "C" DLL_EXPORT S9DelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructS9ByRef_StdCall_FuncPtr() |
| 2811 | { |
| 2812 | return MarshalStructS9ByRef_StdCall; |
| 2813 | } |
| 2814 | |
| 2815 | |
| 2816 | //Passby value |
| 2817 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS9ByVal_Cdecl(S9 argstr) |
| 2818 | { |
| 2819 | //Check the Input |
| 2820 | if(argstr.i32 != 128 || |
| 2821 | argstr.myDelegate1 == NULL) |
| 2822 | { |
| 2823 | printf("\tMarshalStructS9ByVal_Cdecl: S9 param not as expected\n" ); |
| 2824 | return FALSE; |
| 2825 | } |
| 2826 | argstr.i32 = 256; |
| 2827 | argstr.myDelegate1 = NULL; |
| 2828 | |
| 2829 | return TRUE; |
| 2830 | } |
| 2831 | |
| 2832 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS9ByVal_StdCall(S9 argstr) |
| 2833 | { |
| 2834 | //Check the Input |
| 2835 | if(argstr.i32 != 128 || |
| 2836 | argstr.myDelegate1 == NULL) |
| 2837 | { |
| 2838 | printf("\tMarshalStructS9ByVal_StdCall: S9 param not as expected\n" ); |
| 2839 | return FALSE; |
| 2840 | } |
| 2841 | |
| 2842 | argstr.i32 = 256; |
| 2843 | argstr.myDelegate1 = NULL; |
| 2844 | return TRUE; |
| 2845 | } |
| 2846 | |
| 2847 | typedef BOOL (_cdecl *S9ByValCdeclCaller)(S9 cs); |
| 2848 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS9ByVal_Cdecl(S9ByValCdeclCaller caller) |
| 2849 | { |
| 2850 | //Init |
| 2851 | S9 argstr; |
| 2852 | |
| 2853 | argstr.i32 = 256; |
| 2854 | argstr.myDelegate1 = NULL; |
| 2855 | |
| 2856 | if(!caller(argstr)) |
| 2857 | { |
| 2858 | printf("DoCallBack_MarshalStructS9ByVal_Cdecl:The Caller returns wrong value\n" ); |
| 2859 | return FALSE; |
| 2860 | } |
| 2861 | |
| 2862 | //Verify the value unchanged |
| 2863 | if(argstr.i32 != 256 || argstr.myDelegate1 != NULL) |
| 2864 | return false; |
| 2865 | return TRUE; |
| 2866 | } |
| 2867 | |
| 2868 | typedef BOOL (__stdcall *S9ByValStdCallCaller)(S9 cs); |
| 2869 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS9ByVal_StdCall(S9ByValStdCallCaller caller) |
| 2870 | { |
| 2871 | //Init |
| 2872 | S9 argstr; |
| 2873 | |
| 2874 | argstr.i32 = 256; |
| 2875 | argstr.myDelegate1 = NULL; |
| 2876 | |
| 2877 | if(!caller(argstr)) |
| 2878 | { |
| 2879 | printf("DoCallBack_MarshalStructS9ByVal_StdCall:The Caller returns wrong value\n" ); |
| 2880 | return FALSE; |
| 2881 | } |
| 2882 | |
| 2883 | //Verify the value unchanged |
| 2884 | if(argstr.i32 != 256 || argstr.myDelegate1 != NULL) |
| 2885 | return false; |
| 2886 | return TRUE; |
| 2887 | } |
| 2888 | //Delegate PInvoke,passbyval |
| 2889 | typedef BOOL (_cdecl *S9DelegatePInvokeByValCdeclCaller)(S9 cs); |
| 2890 | extern "C" DLL_EXPORT S9DelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructS9ByVal_Cdecl_FuncPtr() |
| 2891 | { |
| 2892 | return MarshalStructS9ByVal_Cdecl; |
| 2893 | } |
| 2894 | |
| 2895 | typedef BOOL (__stdcall *S9DelegatePInvokeByValStdCallCaller)(S9 cs); |
| 2896 | extern "C" DLL_EXPORT S9DelegatePInvokeByValStdCallCaller _cdecl Get_MarshalStructS9ByVal_StdCall_FuncPtr() |
| 2897 | { |
| 2898 | return MarshalStructS9ByVal_StdCall; |
| 2899 | } |
| 2900 | |
| 2901 | ///////////////////////////////////////////Methods for IncludeOuterIntergerStructSequential struct//////////////////////////////////////////////////// |
| 2902 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl(IncludeOuterIntergerStructSequential* argstr) |
| 2903 | { |
| 2904 | if(!IsCorrectIncludeOuterIntergerStructSequential(argstr)) |
| 2905 | { |
| 2906 | printf("\tMarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl: IncludeOuterIntergerStructSequential param not as expected\n" ); |
| 2907 | PrintIncludeOuterIntergerStructSequential(argstr,"argstr" ); |
| 2908 | return FALSE; |
| 2909 | } |
| 2910 | ChangeIncludeOuterIntergerStructSequential(argstr); |
| 2911 | return TRUE; |
| 2912 | } |
| 2913 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall(IncludeOuterIntergerStructSequential* argstr) |
| 2914 | { |
| 2915 | if(!IsCorrectIncludeOuterIntergerStructSequential(argstr)) |
| 2916 | { |
| 2917 | printf("\tMarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall: IncludeOuterIntergerStructSequential param not as expected\n" ); |
| 2918 | PrintIncludeOuterIntergerStructSequential(argstr,"argstr" ); |
| 2919 | return FALSE; |
| 2920 | } |
| 2921 | ChangeIncludeOuterIntergerStructSequential(argstr); |
| 2922 | return TRUE; |
| 2923 | } |
| 2924 | typedef BOOL (_cdecl *IncludeOuterIntergerStructSequentialByRefCdeclCaller)(IncludeOuterIntergerStructSequential* pcs); |
| 2925 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl(IncludeOuterIntergerStructSequentialByRefCdeclCaller caller) |
| 2926 | { |
| 2927 | //Init |
| 2928 | IncludeOuterIntergerStructSequential argstr; |
| 2929 | |
| 2930 | argstr.s.s_int.i = 64; |
| 2931 | argstr.s.i = 64; |
| 2932 | |
| 2933 | if(!caller(&argstr)) |
| 2934 | { |
| 2935 | printf("DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl:The Caller returns wrong value\n" ); |
| 2936 | return FALSE; |
| 2937 | } |
| 2938 | //Verify the value unchanged |
| 2939 | if(!IsCorrectIncludeOuterIntergerStructSequential(&argstr)) |
| 2940 | { |
| 2941 | printf("The parameter for DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl is wrong\n" ); |
| 2942 | return FALSE; |
| 2943 | } |
| 2944 | return TRUE; |
| 2945 | } |
| 2946 | |
| 2947 | typedef BOOL (__stdcall *IncludeOuterIntergerStructSequentialByRefStdCallCaller)(IncludeOuterIntergerStructSequential* pcs); |
| 2948 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall(IncludeOuterIntergerStructSequentialByRefStdCallCaller caller) |
| 2949 | { |
| 2950 | //Init |
| 2951 | IncludeOuterIntergerStructSequential argstr; |
| 2952 | |
| 2953 | argstr.s.s_int.i = 64; |
| 2954 | argstr.s.i = 64; |
| 2955 | |
| 2956 | if(!caller(&argstr)) |
| 2957 | { |
| 2958 | printf("DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall:The Caller returns wrong value\n" ); |
| 2959 | return FALSE; |
| 2960 | } |
| 2961 | //Verify the value unchanged |
| 2962 | if(!IsCorrectIncludeOuterIntergerStructSequential(&argstr)) |
| 2963 | { |
| 2964 | printf("The parameter for DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall is wrong\n" ); |
| 2965 | return FALSE; |
| 2966 | } |
| 2967 | return TRUE; |
| 2968 | } |
| 2969 | //Delegate PInvoke,passbyref |
| 2970 | typedef BOOL (_cdecl *IncludeOuterIntergerStructSequentialDelegatePInvokeByRefCdeclCaller)(IncludeOuterIntergerStructSequential* pcs); |
| 2971 | extern "C" DLL_EXPORT IncludeOuterIntergerStructSequentialDelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl_FuncPtr() |
| 2972 | { |
| 2973 | return MarshalStructIncludeOuterIntergerStructSequentialByRef_Cdecl; |
| 2974 | } |
| 2975 | |
| 2976 | typedef BOOL (__stdcall *IncludeOuterIntergerStructSequentialDelegatePInvokeByRefStdCallCaller)(IncludeOuterIntergerStructSequential* pcs); |
| 2977 | extern "C" DLL_EXPORT IncludeOuterIntergerStructSequentialDelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall_FuncPtr() |
| 2978 | { |
| 2979 | return MarshalStructIncludeOuterIntergerStructSequentialByRef_StdCall; |
| 2980 | } |
| 2981 | |
| 2982 | |
| 2983 | //Passby value |
| 2984 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructIncludeOuterIntergerStructSequentialByVal_Cdecl(IncludeOuterIntergerStructSequential argstr) |
| 2985 | { |
| 2986 | //Check the Input |
| 2987 | if(!IsCorrectIncludeOuterIntergerStructSequential(&argstr)) |
| 2988 | { |
| 2989 | printf("\tMarshalStructIncludeOuterIntergerStructSequentialByVal_Cdecl: IncludeOuterIntergerStructSequential param not as expected\n" ); |
| 2990 | PrintIncludeOuterIntergerStructSequential(&argstr,"argstr" ); |
| 2991 | return FALSE; |
| 2992 | } |
| 2993 | |
| 2994 | argstr.s.s_int.i = 64; |
| 2995 | argstr.s.i = 64; |
| 2996 | |
| 2997 | return TRUE; |
| 2998 | } |
| 2999 | |
| 3000 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructIncludeOuterIntergerStructSequentialByVal_StdCall(IncludeOuterIntergerStructSequential argstr) |
| 3001 | { |
| 3002 | //Check the Input |
| 3003 | if(!IsCorrectIncludeOuterIntergerStructSequential(&argstr)) |
| 3004 | { |
| 3005 | printf("\tMarshalStructIncludeOuterIntergerStructSequentialByVal_StdCall: IncludeOuterIntergerStructSequential param not as expected\n" ); |
| 3006 | PrintIncludeOuterIntergerStructSequential(&argstr,"argstr" ); |
| 3007 | return FALSE; |
| 3008 | } |
| 3009 | |
| 3010 | argstr.s.s_int.i = 64; |
| 3011 | argstr.s.i = 64; |
| 3012 | |
| 3013 | return TRUE; |
| 3014 | } |
| 3015 | |
| 3016 | typedef BOOL (_cdecl *IncludeOuterIntergerStructSequentialByValCdeclCaller)(IncludeOuterIntergerStructSequential cs); |
| 3017 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByVal_Cdecl(IncludeOuterIntergerStructSequentialByValCdeclCaller caller) |
| 3018 | { |
| 3019 | //Init |
| 3020 | IncludeOuterIntergerStructSequential argstr; |
| 3021 | |
| 3022 | argstr.s.s_int.i = 64; |
| 3023 | argstr.s.i = 64; |
| 3024 | |
| 3025 | if(!caller(argstr)) |
| 3026 | { |
| 3027 | printf("DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByVal_Cdecl:The Caller returns wrong value\n" ); |
| 3028 | return FALSE; |
| 3029 | } |
| 3030 | |
| 3031 | //Verify the value unchanged |
| 3032 | if(argstr.s.s_int.i != 64) |
| 3033 | return false; |
| 3034 | if(argstr.s.i != 64) |
| 3035 | return false; |
| 3036 | |
| 3037 | return TRUE; |
| 3038 | } |
| 3039 | |
| 3040 | typedef BOOL (__stdcall *IncludeOuterIntergerStructSequentialByValStdCallCaller)(IncludeOuterIntergerStructSequential cs); |
| 3041 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByVal_StdCall(IncludeOuterIntergerStructSequentialByValStdCallCaller caller) |
| 3042 | { |
| 3043 | //Init |
| 3044 | IncludeOuterIntergerStructSequential argstr; |
| 3045 | |
| 3046 | argstr.s.s_int.i = 64; |
| 3047 | argstr.s.i = 64; |
| 3048 | |
| 3049 | if(!caller(argstr)) |
| 3050 | { |
| 3051 | printf("DoCallBack_MarshalStructIncludeOuterIntergerStructSequentialByVal_StdCall:The Caller returns wrong value\n" ); |
| 3052 | return FALSE; |
| 3053 | } |
| 3054 | |
| 3055 | //Verify the value unchanged |
| 3056 | if(argstr.s.s_int.i != 64) |
| 3057 | return false; |
| 3058 | if(argstr.s.i != 64) |
| 3059 | return false; |
| 3060 | return TRUE; |
| 3061 | } |
| 3062 | //Delegate PInvoke,passbyval |
| 3063 | typedef BOOL (_cdecl *IncludeOuterIntergerStructSequentialDelegatePInvokeByValCdeclCaller)(IncludeOuterIntergerStructSequential cs); |
| 3064 | extern "C" DLL_EXPORT IncludeOuterIntergerStructSequentialDelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructIncludeOuterIntergerStructSequentialByVal_Cdecl_FuncPtr() |
| 3065 | { |
| 3066 | return MarshalStructIncludeOuterIntergerStructSequentialByVal_Cdecl; |
| 3067 | } |
| 3068 | |
| 3069 | typedef BOOL (__stdcall *IncludeOuterIntergerStructSequentialDelegatePInvokeByValStdCallCaller)(IncludeOuterIntergerStructSequential cs); |
| 3070 | extern "C" DLL_EXPORT IncludeOuterIntergerStructSequentialDelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructIncludeOuterIntergerStructSequentialByVal_StdCall_FuncPtr() |
| 3071 | { |
| 3072 | return MarshalStructIncludeOuterIntergerStructSequentialByVal_StdCall; |
| 3073 | } |
| 3074 | |
| 3075 | ///////////////////////////////////////////Methods for S11 struct//////////////////////////////////////////////////// |
| 3076 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS11ByRef_Cdecl(S11* argstr) |
| 3077 | { |
| 3078 | if(argstr->i32 != (LPINT)(32) || argstr->i != 32) |
| 3079 | { |
| 3080 | printf("\tMarshalStructS11ByRef_Cdecl: S11 param not as expected\n" ); |
| 3081 | return FALSE; |
| 3082 | } |
| 3083 | argstr->i32 = (LPINT)(64); |
| 3084 | argstr->i = 64; |
| 3085 | return TRUE; |
| 3086 | } |
| 3087 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS11ByRef_StdCall(S11* argstr) |
| 3088 | { |
| 3089 | if(argstr->i32 != (LPINT)(32) || argstr->i != 32) |
| 3090 | { |
| 3091 | printf("\tMarshalStructS11ByRef_StdCall: S11 param not as expected\n" ); |
| 3092 | return FALSE; |
| 3093 | } |
| 3094 | argstr->i32 = (LPINT)(64); |
| 3095 | argstr->i = 64; |
| 3096 | return TRUE; |
| 3097 | } |
| 3098 | typedef BOOL (_cdecl *S11ByRefCdeclCaller)(S11* pcs); |
| 3099 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS11ByRef_Cdecl(S11ByRefCdeclCaller caller) |
| 3100 | { |
| 3101 | //Init |
| 3102 | S11 argstr; |
| 3103 | |
| 3104 | argstr.i32 = (LPINT)(64); |
| 3105 | argstr.i = 64; |
| 3106 | |
| 3107 | if(!caller(&argstr)) |
| 3108 | { |
| 3109 | printf("DoCallBack_MarshalStructS11ByRef_Cdecl:The Caller returns wrong value\n" ); |
| 3110 | return FALSE; |
| 3111 | } |
| 3112 | //Verify the value unchanged |
| 3113 | if(argstr.i32 != (LPINT)32 || argstr.i != 32) |
| 3114 | { |
| 3115 | printf("The parameter for DoCallBack_MarshalStructS11ByRef_Cdecl is wrong\n" ); |
| 3116 | return FALSE; |
| 3117 | } |
| 3118 | return TRUE; |
| 3119 | } |
| 3120 | |
| 3121 | typedef BOOL (__stdcall *S11ByRefStdCallCaller)(S11* pcs); |
| 3122 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS11ByRef_StdCall(S11ByRefStdCallCaller caller) |
| 3123 | { |
| 3124 | //Init |
| 3125 | S11 argstr; |
| 3126 | |
| 3127 | argstr.i32 = (LPINT)(64); |
| 3128 | argstr.i = 64; |
| 3129 | |
| 3130 | if(!caller(&argstr)) |
| 3131 | { |
| 3132 | printf("DoCallBack_MarshalStructS11ByRef_StdCall:The Caller returns wrong value\n" ); |
| 3133 | return FALSE; |
| 3134 | } |
| 3135 | //Verify the value unchanged |
| 3136 | if(argstr.i32 != (LPINT)(32) || argstr.i != 32) |
| 3137 | { |
| 3138 | printf("The parameter for DoCallBack_MarshalStructS11ByRef_StdCall is wrong\n" ); |
| 3139 | return FALSE; |
| 3140 | } |
| 3141 | return TRUE; |
| 3142 | } |
| 3143 | //Delegate PInvoke,passbyref |
| 3144 | typedef BOOL (_cdecl *S11DelegatePInvokeByRefCdeclCaller)(S11* pcs); |
| 3145 | extern "C" DLL_EXPORT S11DelegatePInvokeByRefCdeclCaller _cdecl Get_MarshalStructS11ByRef_Cdecl_FuncPtr() |
| 3146 | { |
| 3147 | return MarshalStructS11ByRef_Cdecl; |
| 3148 | } |
| 3149 | |
| 3150 | typedef BOOL (__stdcall *S11DelegatePInvokeByRefStdCallCaller)(S11* pcs); |
| 3151 | extern "C" DLL_EXPORT S11DelegatePInvokeByRefStdCallCaller __stdcall Get_MarshalStructS11ByRef_StdCall_FuncPtr() |
| 3152 | { |
| 3153 | return MarshalStructS11ByRef_StdCall; |
| 3154 | } |
| 3155 | |
| 3156 | |
| 3157 | //Passby value |
| 3158 | extern "C" DLL_EXPORT BOOL _cdecl MarshalStructS11ByVal_Cdecl(S11 argstr) |
| 3159 | { |
| 3160 | //Check the Input |
| 3161 | if(argstr.i32 != (LPINT)(32) || argstr.i != 32) |
| 3162 | { |
| 3163 | printf("\tMarshalStructS11ByVal_Cdecl: S11 param not as expected\n" ); |
| 3164 | return FALSE; |
| 3165 | } |
| 3166 | |
| 3167 | argstr.i32 = (LPINT)(64); |
| 3168 | argstr.i = 64; |
| 3169 | |
| 3170 | return TRUE; |
| 3171 | } |
| 3172 | |
| 3173 | extern "C" DLL_EXPORT BOOL __stdcall MarshalStructS11ByVal_StdCall(S11 argstr) |
| 3174 | { |
| 3175 | //Check the Input |
| 3176 | if(argstr.i32 != (LPINT)(32) || argstr.i != 32) |
| 3177 | { |
| 3178 | printf("\tMarshalStructS11ByVal_StdCall: S11 param not as expected\n" ); |
| 3179 | return FALSE; |
| 3180 | } |
| 3181 | |
| 3182 | argstr.i32 = (LPINT)(64); |
| 3183 | argstr.i = 64; |
| 3184 | |
| 3185 | return TRUE; |
| 3186 | } |
| 3187 | |
| 3188 | typedef BOOL (_cdecl *S11ByValCdeclCaller)(S11 cs); |
| 3189 | extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_MarshalStructS11ByVal_Cdecl(S11ByValCdeclCaller caller) |
| 3190 | { |
| 3191 | //Init |
| 3192 | S11 argstr; |
| 3193 | |
| 3194 | argstr.i32 = (LPINT)(64); |
| 3195 | argstr.i = 64; |
| 3196 | |
| 3197 | if(!caller(argstr)) |
| 3198 | { |
| 3199 | printf("DoCallBack_MarshalStructS11ByVal_Cdecl:The Caller returns wrong value\n" ); |
| 3200 | return FALSE; |
| 3201 | } |
| 3202 | |
| 3203 | //Verify the value unchanged |
| 3204 | if(argstr.i32 != (LPINT)(64) || argstr.i != 64) |
| 3205 | return false; |
| 3206 | |
| 3207 | return TRUE; |
| 3208 | } |
| 3209 | |
| 3210 | typedef BOOL (__stdcall *S11ByValStdCallCaller)(S11 cs); |
| 3211 | extern "C" DLL_EXPORT BOOL __stdcall DoCallBack_MarshalStructS11ByVal_StdCall(S11ByValStdCallCaller caller) |
| 3212 | { |
| 3213 | //Init |
| 3214 | S11 argstr; |
| 3215 | |
| 3216 | argstr.i32 = (LPINT)(64); |
| 3217 | argstr.i = 64; |
| 3218 | |
| 3219 | if(!caller(argstr)) |
| 3220 | { |
| 3221 | printf("DoCallBack_MarshalStructS11ByVal_StdCall:The Caller returns wrong value\n" ); |
| 3222 | return FALSE; |
| 3223 | } |
| 3224 | |
| 3225 | //Verify the value unchanged |
| 3226 | if(argstr.i32 != (LPINT)(64) || argstr.i != 64) |
| 3227 | return false; |
| 3228 | return TRUE; |
| 3229 | } |
| 3230 | //Delegate PInvoke,passbyval |
| 3231 | typedef BOOL (_cdecl *S11DelegatePInvokeByValCdeclCaller)(S11 cs); |
| 3232 | extern "C" DLL_EXPORT S11DelegatePInvokeByValCdeclCaller _cdecl Get_MarshalStructS11ByVal_Cdecl_FuncPtr() |
| 3233 | { |
| 3234 | return MarshalStructS11ByVal_Cdecl; |
| 3235 | } |
| 3236 | |
| 3237 | typedef BOOL (__stdcall *S11DelegatePInvokeByValStdCallCaller)(S11 cs); |
| 3238 | extern "C" DLL_EXPORT S11DelegatePInvokeByValStdCallCaller __stdcall Get_MarshalStructS11ByVal_StdCall_FuncPtr() |
| 3239 | { |
| 3240 | return MarshalStructS11ByVal_StdCall; |
| 3241 | } |
| 3242 | |