1 | /* $Id: kPrf2WinApiWrappers.c 11 2008-04-20 09:18:23Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * Wrappers for a number of common Windows APIs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2008 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
8 | *
|
---|
9 | * This program is free software; you can redistribute it and/or modify
|
---|
10 | * it under the terms of the GNU General Public License as published by
|
---|
11 | * the Free Software Foundation; either version 2 of the License, or
|
---|
12 | * (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This program is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public License
|
---|
20 | * along with This program; if not, write to the Free Software
|
---|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | /*******************************************************************************
|
---|
26 | * Header Files *
|
---|
27 | *******************************************************************************/
|
---|
28 | #define _ADVAPI32_
|
---|
29 | #define _KERNEL32_
|
---|
30 | #define _WIN32_WINNT 0x0600
|
---|
31 | #define UNICODE
|
---|
32 | #include <Windows.h>
|
---|
33 | #include <TLHelp32.h>
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | /*******************************************************************************
|
---|
38 | * Structures and Typedefs *
|
---|
39 | *******************************************************************************/
|
---|
40 | typedef struct KPRF2WRAPDLL
|
---|
41 | {
|
---|
42 | HMODULE hmod;
|
---|
43 | char szName[32];
|
---|
44 | } KPRF2WRAPDLL;
|
---|
45 | typedef KPRF2WRAPDLL *PKPRF2WRAPDLL;
|
---|
46 | typedef KPRF2WRAPDLL const *PCKPRF2WRAPDLL;
|
---|
47 |
|
---|
48 | /* TODO (amd64):
|
---|
49 |
|
---|
50 | AddLocalAlternateComputerNameA
|
---|
51 | AddLocalAlternateComputerNameW
|
---|
52 | EnumerateLocalComputerNamesA
|
---|
53 | EnumerateLocalComputerNamesW
|
---|
54 | RemoveLocalAlternateComputerNameA
|
---|
55 | RemoveLocalAlternateComputerNameW
|
---|
56 |
|
---|
57 | RtlLookupFunctionEntry
|
---|
58 | RtlPcToFileHeader
|
---|
59 | RtlRaiseException
|
---|
60 | RtlVirtualUnwind
|
---|
61 |
|
---|
62 | SetConsoleCursor
|
---|
63 | SetLocalPrimaryComputerNameA
|
---|
64 | SetLocalPrimaryComputerNameW
|
---|
65 | __C_specific_handler
|
---|
66 | __misaligned_access
|
---|
67 | _local_unwind
|
---|
68 | */
|
---|
69 |
|
---|
70 | /*******************************************************************************
|
---|
71 | * Global Variables *
|
---|
72 | *******************************************************************************/
|
---|
73 | KPRF2WRAPDLL g_Kernel32 =
|
---|
74 | {
|
---|
75 | INVALID_HANDLE_VALUE, "KERNEL32"
|
---|
76 | };
|
---|
77 |
|
---|
78 |
|
---|
79 | /*******************************************************************************
|
---|
80 | * Internal Functions *
|
---|
81 | *******************************************************************************/
|
---|
82 | FARPROC kPrf2WrapResolve(void **ppfn, const char *pszName, PKPRF2WRAPDLL pDll);
|
---|
83 |
|
---|
84 |
|
---|
85 | FARPROC kPrf2WrapResolve(void **ppfn, const char *pszName, PKPRF2WRAPDLL pDll)
|
---|
86 | {
|
---|
87 | FARPROC pfn;
|
---|
88 | HMODULE hmod = pDll->hmod;
|
---|
89 | if (hmod == INVALID_HANDLE_VALUE)
|
---|
90 | {
|
---|
91 | hmod = LoadLibraryA(pDll->szName);
|
---|
92 | pDll->hmod = hmod;
|
---|
93 | }
|
---|
94 |
|
---|
95 | pfn = GetProcAddress(hmod, pszName);
|
---|
96 | *ppfn = (void *)pfn;
|
---|
97 | return pfn;
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | #include "kPrf2WinApiWrappers-kernel32.h"
|
---|