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: Negative test the LoadLibraryA API.
10** Call LoadLibraryA with a not exist module Name
11**
12**
13**============================================================*/
14#include <palsuite.h>
15
16int __cdecl main(int argc, char *argv[])
17{
18 HMODULE ModuleHandle;
19 int err;
20 const char *pModuleName = "Not-exist-module-name";
21
22 /* Initialize the PAL environment */
23 err = PAL_Initialize(argc, argv);
24 if(0 != err)
25 {
26 return FAIL;
27 }
28
29 /*try to load a not exist module */
30 ModuleHandle = LoadLibraryA(pModuleName);
31 if(NULL != ModuleHandle)
32 {
33 Trace("Failed to call LoadLibraryA with a not exist mudule name, "
34 "a NULL module handle is expected, but no NULL module handle "
35 "is returned, error code=%u\n", GetLastError());
36
37 /* decrement the reference count of the loaded module */
38 err = FreeLibrary(ModuleHandle);
39 if(0 == err)
40 {
41 Trace("\nFailed to all FreeLibrary API to decrement "
42 "the reference count of the loaded module, "
43 "error code = %u\n", GetLastError());
44
45 }
46
47 Fail("");
48 }
49
50 PAL_Terminate();
51 return PASS;
52}
53