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 by passing a module name |
11 | ** without extension but with a trailing dot. |
12 | ** |
13 | ** |
14 | **============================================================*/ |
15 | #include <palsuite.h> |
16 | |
17 | int __cdecl main(int argc, char *argv[]) |
18 | { |
19 | HMODULE ModuleHandle; |
20 | char ModuleName[_MAX_FNAME]; |
21 | int err; |
22 | |
23 | /* Initialize the PAL environment */ |
24 | err = PAL_Initialize(argc, argv); |
25 | if(0 != err) |
26 | { |
27 | return FAIL; |
28 | } |
29 | |
30 | memset(ModuleName, 0, _MAX_FNAME); |
31 | |
32 | /*Module name without extension but with a trailing dot*/ |
33 | #if WIN32 |
34 | sprintf_s(ModuleName, _countof(ModuleName), "%s" , "rotor_pal." ); |
35 | #else |
36 | /* Under FreeBSD */ |
37 | sprintf_s(ModuleName, _countof(ModuleName), "%s" , "librotor_pal." ); |
38 | #endif |
39 | |
40 | /* load a module which does not have the file extension, |
41 | * but has a trailing dot |
42 | */ |
43 | ModuleHandle = LoadLibraryA(ModuleName); |
44 | if(NULL != ModuleHandle) |
45 | { |
46 | Trace("Failed to call LoadLibraryA API for a negative test " |
47 | "call LoadLibraryA with module name which does not have " |
48 | "extension except a trailing dot, a NULL module handle is" |
49 | "expected, but no NULL module handle is returned, " |
50 | "error code = %u\n" , GetLastError()); |
51 | |
52 | |
53 | /* decrement the reference count of the loaded dll */ |
54 | err = FreeLibrary(ModuleHandle); |
55 | if(0 == err) |
56 | { |
57 | Trace("\nFailed to call FreeLibrary API, " |
58 | "error code = %u\n" , GetLastError()); |
59 | } |
60 | |
61 | Fail("" ); |
62 | } |
63 | |
64 | |
65 | PAL_Terminate(); |
66 | return PASS; |
67 | } |
68 | |