blob: ff0d33879c0c27700eafdb21559369f583d1ca47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*=============================================================
**
** Source: pal_registerlibrary_unregisterlibrary
**
** Purpose: Positive test the PAL_RegisterLibrary API and
** PAL_UnRegisterLibrary.
** Call PAL_RegisterLibrary to map a module into the calling
** process address space and call PAL_UnRegisterLibrary
** to unmap this module.
**
**
**============================================================*/
#define UNICODE
#include <palsuite.h>
int __cdecl main(int argc, char *argv[])
{
HMODULE ModuleHandle;
char ModuleName[64];
WCHAR *wpModuleName = NULL;
int err;
/*Initialize the PAL environment*/
err = PAL_Initialize(argc, argv);
if(0 != err)
{
return FAIL;
}
/*zero the buffer*/
memset(ModuleName,0,64);
sprintf(ModuleName, "%s", "rotor_pal");
/*convert a normal string to a wide one*/
wpModuleName = convert(ModuleName);
/*load a module*/
ModuleHandle = PAL_RegisterLibrary(wpModuleName);
/*free the memory*/
free(wpModuleName);
if(!ModuleHandle)
{
Fail("Failed to call PAL_RegisterLibrary API to map a module "
"into calling process, error code=%u!\n", GetLastError());
}
/*decrement the reference count of the loaded DLL*/
err = PAL_UnregisterLibrary(ModuleHandle);
if(0 == err)
{
Fail("\nFailed to call PAL_UnregisterLibrary API to "
"decrement the count of the loaded DLL module, "
"error code=%u!\n", GetLastError());
}
PAL_Terminate();
return PASS;
}
|