[11] | 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 | /*
|
---|
[29] | 7 | * Copyright (c) 2008 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
|
---|
[11] | 8 | *
|
---|
[29] | 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:
|
---|
[11] | 17 | *
|
---|
[29] | 18 | * The above copyright notice and this permission notice shall be
|
---|
| 19 | * included in all copies or substantial portions of the Software.
|
---|
[11] | 20 | *
|
---|
[29] | 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.
|
---|
[11] | 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>
|
---|
[12] | 40 | #include <k/kDefs.h>
|
---|
[13] | 41 | #include "kPrf2WinApiWrapperHlp.h"
|
---|
[11] | 42 |
|
---|
[12] | 43 | #if K_ARCH == K_ARCH_X86_32
|
---|
| 44 | typedef PVOID PRUNTIME_FUNCTION;
|
---|
| 45 | typedef FARPROC PGET_RUNTIME_FUNCTION_CALLBACK;
|
---|
| 46 | #endif
|
---|
[11] | 47 |
|
---|
[13] | 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 |
|
---|
[11] | 57 | /*******************************************************************************
|
---|
[13] | 58 | * Global Variables *
|
---|
[11] | 59 | *******************************************************************************/
|
---|
[13] | 60 | KPRF2WRAPDLL g_Kernel32 =
|
---|
[11] | 61 | {
|
---|
[13] | 62 | INVALID_HANDLE_VALUE, "KERNEL32"
|
---|
| 63 | };
|
---|
[11] | 64 |
|
---|
[12] | 65 |
|
---|
[13] | 66 | /*
|
---|
| 67 | * Include the generated code.
|
---|
| 68 | */
|
---|
| 69 | #include "kPrf2WinApiWrappers-kernel32.h"
|
---|
| 70 |
|
---|
[11] | 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
|
---|
[13] | 91 |
|
---|
[11] | 92 | */
|
---|
| 93 |
|
---|
[13] | 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)
|
---|
[11] | 105 | {
|
---|
[13] | 106 | switch (fdwReason)
|
---|
| 107 | {
|
---|
| 108 | case DLL_PROCESS_ATTACH:
|
---|
| 109 | break;
|
---|
[11] | 110 |
|
---|
[13] | 111 | case DLL_PROCESS_DETACH:
|
---|
| 112 | break;
|
---|
[11] | 113 |
|
---|
[13] | 114 | case DLL_THREAD_ATTACH:
|
---|
| 115 | break;
|
---|
[11] | 116 |
|
---|
[13] | 117 | case DLL_THREAD_DETACH:
|
---|
| 118 | break;
|
---|
[11] | 119 | }
|
---|
| 120 |
|
---|
[13] | 121 | return TRUE;
|
---|
[11] | 122 | }
|
---|
| 123 |
|
---|