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.
5 /*=============================================================
7 ** Source: pal_registerlibraryw_unregisterlibraryw_neg.c
9 ** Purpose: Negative test the PAL_RegisterLibrary API.
10 ** Call PAL_RegisterLibrary to map a non-existant module
11 ** into the calling process address space.
14 **============================================================*/
18 int __cdecl main(int argc, char *argv[])
22 WCHAR *wpModuleName = NULL;
25 /*Initialize the PAL environment*/
26 err = PAL_Initialize(argc, argv);
32 memset(ModuleName, 0, 64);
33 sprintf_s(ModuleName, _countof(ModuleName), "%s", "not_exist_module_name");
35 /*convert a normal string to a wide one*/
36 wpModuleName = convert(ModuleName);
38 /*load a not exist module*/
39 ModuleHandle = PAL_RegisterLibrary(wpModuleName);
44 if(NULL != ModuleHandle)
46 Trace("ERROR: PAL_RegisterLibrary successfully mapped "
47 "a module that does not exist into the calling process\n");
49 /*decrement the reference count of the loaded DLL*/
50 err = PAL_UnregisterLibrary(ModuleHandle);
53 Trace("\nFailed to call PAL_UnregisterLibrary API to decrement the "
54 "count of the loaded DLL module!\n");