1 | /* $Id: kPrf2WinApiWrappers.c 29 2009-07-01 20:30:29Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * Wrappers for a number of common Windows APIs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2008 Knut St. Osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person
|
---|
10 | * obtaining a copy of this software and associated documentation
|
---|
11 | * files (the "Software"), to deal in the Software without
|
---|
12 | * restriction, including without limitation the rights to use,
|
---|
13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | * copies of the Software, and to permit persons to whom the
|
---|
15 | * Software is furnished to do so, subject to the following
|
---|
16 | * conditions:
|
---|
17 | *
|
---|
18 | * The above copyright notice and this permission notice shall be
|
---|
19 | * included in all copies or substantial portions of the Software.
|
---|
20 | *
|
---|
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | */
|
---|
30 |
|
---|
31 | /*******************************************************************************
|
---|
32 | * Header Files *
|
---|
33 | *******************************************************************************/
|
---|
34 | #define _ADVAPI32_
|
---|
35 | #define _KERNEL32_
|
---|
36 | #define _WIN32_WINNT 0x0600
|
---|
37 | #define UNICODE
|
---|
38 | #include <Windows.h>
|
---|
39 | #include <TLHelp32.h>
|
---|
40 | #include <k/kDefs.h>
|
---|
41 | #include "kPrf2WinApiWrapperHlp.h"
|
---|
42 |
|
---|
43 | #if K_ARCH == K_ARCH_X86_32
|
---|
44 | typedef PVOID PRUNTIME_FUNCTION;
|
---|
45 | typedef FARPROC PGET_RUNTIME_FUNCTION_CALLBACK;
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | /* RtlUnwindEx is used by msvcrt on amd64, but winnt.h only defines it for IA64... */
|
---|
49 | typedef struct _FRAME_POINTERS {
|
---|
50 | ULONGLONG MemoryStackFp;
|
---|
51 | ULONGLONG BackingStoreFp;
|
---|
52 | } FRAME_POINTERS, *PFRAME_POINTERS;
|
---|
53 | typedef PVOID PUNWIND_HISTORY_TABLE;
|
---|
54 | typedef PVOID PKNONVOLATILE_CONTEXT_POINTERS;
|
---|
55 |
|
---|
56 |
|
---|
57 | /*******************************************************************************
|
---|
58 | * Global Variables *
|
---|
59 | *******************************************************************************/
|
---|
60 | KPRF2WRAPDLL g_Kernel32 =
|
---|
61 | {
|
---|
62 | INVALID_HANDLE_VALUE, "KERNEL32"
|
---|
63 | };
|
---|
64 |
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * Include the generated code.
|
---|
68 | */
|
---|
69 | #include "kPrf2WinApiWrappers-kernel32.h"
|
---|
70 |
|
---|
71 | /* TODO (amd64):
|
---|
72 |
|
---|
73 | AddLocalAlternateComputerNameA
|
---|
74 | AddLocalAlternateComputerNameW
|
---|
75 | EnumerateLocalComputerNamesA
|
---|
76 | EnumerateLocalComputerNamesW
|
---|
77 | RemoveLocalAlternateComputerNameA
|
---|
78 | RemoveLocalAlternateComputerNameW
|
---|
79 |
|
---|
80 | RtlLookupFunctionEntry
|
---|
81 | RtlPcToFileHeader
|
---|
82 | RtlRaiseException
|
---|
83 | RtlVirtualUnwind
|
---|
84 |
|
---|
85 | SetConsoleCursor
|
---|
86 | SetLocalPrimaryComputerNameA
|
---|
87 | SetLocalPrimaryComputerNameW
|
---|
88 | __C_specific_handler
|
---|
89 | __misaligned_access
|
---|
90 | _local_unwind
|
---|
91 |
|
---|
92 | */
|
---|
93 |
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * The DLL Main for the Windows API wrapper DLL.
|
---|
97 | *
|
---|
98 | * @returns Success indicator.
|
---|
99 | * @param hInstDll The instance handle of the DLL. (i.e. the module handle)
|
---|
100 | * @param fdwReason The reason why we're here. This is a 'flag' for reasons of
|
---|
101 | * tradition, it's really a kind of enum.
|
---|
102 | * @param pReserved Reserved / undocumented something.
|
---|
103 | */
|
---|
104 | BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, PVOID pReserved)
|
---|
105 | {
|
---|
106 | switch (fdwReason)
|
---|
107 | {
|
---|
108 | case DLL_PROCESS_ATTACH:
|
---|
109 | break;
|
---|
110 |
|
---|
111 | case DLL_PROCESS_DETACH:
|
---|
112 | break;
|
---|
113 |
|
---|
114 | case DLL_THREAD_ATTACH:
|
---|
115 | break;
|
---|
116 |
|
---|
117 | case DLL_THREAD_DETACH:
|
---|
118 | break;
|
---|
119 | }
|
---|
120 |
|
---|
121 | return TRUE;
|
---|
122 | }
|
---|
123 |
|
---|