| 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 | /*============================================================= |
| 6 | ** |
| 7 | ** Source: loadlibrarya.c |
| 8 | ** |
| 9 | ** Purpose: Positive test the LoadLibrary API. |
| 10 | ** Call LoadLibrary to map a module into the calling |
| 11 | ** process address space(DLL file) |
| 12 | ** |
| 13 | ** |
| 14 | **============================================================*/ |
| 15 | #include <palsuite.h> |
| 16 | |
| 17 | /* SHLEXT is defined only for Unix variants */ |
| 18 | |
| 19 | #if defined(SHLEXT) |
| 20 | #define ModuleName "librotor_pal"SHLEXT |
| 21 | #else |
| 22 | #define ModuleName "rotor_pal.dll" |
| 23 | #endif |
| 24 | |
| 25 | int __cdecl main(int argc, char *argv[]) |
| 26 | { |
| 27 | HMODULE ModuleHandle; |
| 28 | int err; |
| 29 | |
| 30 | /* Initialize the PAL environment */ |
| 31 | err = PAL_Initialize(argc, argv); |
| 32 | if(0 != err) |
| 33 | { |
| 34 | ExitProcess(FAIL); |
| 35 | } |
| 36 | |
| 37 | /* load a module */ |
| 38 | ModuleHandle = LoadLibrary(ModuleName); |
| 39 | if(!ModuleHandle) |
| 40 | { |
| 41 | Fail("Failed to call LoadLibrary API!\n" ); |
| 42 | } |
| 43 | |
| 44 | /* decrement the reference count of the loaded dll */ |
| 45 | err = FreeLibrary(ModuleHandle); |
| 46 | if(0 == err) |
| 47 | { |
| 48 | Fail("\nFailed to all FreeLibrary API!\n" ); |
| 49 | } |
| 50 | |
| 51 | PAL_Terminate(); |
| 52 | return PASS; |
| 53 | } |
| 54 | |