[11] | 1 | /* $Id: kPrf2WinApiWrappers.c 13 2008-04-20 10:13:43Z 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>
|
---|
[12] | 34 | #include <k/kDefs.h>
|
---|
[13] | 35 | #include "kPrf2WinApiWrapperHlp.h"
|
---|
[11] | 36 |
|
---|
[12] | 37 | #if K_ARCH == K_ARCH_X86_32
|
---|
| 38 | typedef PVOID PRUNTIME_FUNCTION;
|
---|
| 39 | typedef FARPROC PGET_RUNTIME_FUNCTION_CALLBACK;
|
---|
| 40 | #endif
|
---|
[11] | 41 |
|
---|
[13] | 42 | /* RtlUnwindEx is used by msvcrt on amd64, but winnt.h only defines it for IA64... */
|
---|
| 43 | typedef struct _FRAME_POINTERS {
|
---|
| 44 | ULONGLONG MemoryStackFp;
|
---|
| 45 | ULONGLONG BackingStoreFp;
|
---|
| 46 | } FRAME_POINTERS, *PFRAME_POINTERS;
|
---|
| 47 | typedef PVOID PUNWIND_HISTORY_TABLE;
|
---|
| 48 | typedef PVOID PKNONVOLATILE_CONTEXT_POINTERS;
|
---|
| 49 |
|
---|
| 50 |
|
---|
[11] | 51 | /*******************************************************************************
|
---|
[13] | 52 | * Global Variables *
|
---|
[11] | 53 | *******************************************************************************/
|
---|
[13] | 54 | KPRF2WRAPDLL g_Kernel32 =
|
---|
[11] | 55 | {
|
---|
[13] | 56 | INVALID_HANDLE_VALUE, "KERNEL32"
|
---|
| 57 | };
|
---|
[11] | 58 |
|
---|
[12] | 59 |
|
---|
[13] | 60 | /*
|
---|
| 61 | * Include the generated code.
|
---|
| 62 | */
|
---|
| 63 | #include "kPrf2WinApiWrappers-kernel32.h"
|
---|
| 64 |
|
---|
[11] | 65 | /* TODO (amd64):
|
---|
| 66 |
|
---|
| 67 | AddLocalAlternateComputerNameA
|
---|
| 68 | AddLocalAlternateComputerNameW
|
---|
| 69 | EnumerateLocalComputerNamesA
|
---|
| 70 | EnumerateLocalComputerNamesW
|
---|
| 71 | RemoveLocalAlternateComputerNameA
|
---|
| 72 | RemoveLocalAlternateComputerNameW
|
---|
| 73 |
|
---|
| 74 | RtlLookupFunctionEntry
|
---|
| 75 | RtlPcToFileHeader
|
---|
| 76 | RtlRaiseException
|
---|
| 77 | RtlVirtualUnwind
|
---|
| 78 |
|
---|
| 79 | SetConsoleCursor
|
---|
| 80 | SetLocalPrimaryComputerNameA
|
---|
| 81 | SetLocalPrimaryComputerNameW
|
---|
| 82 | __C_specific_handler
|
---|
| 83 | __misaligned_access
|
---|
| 84 | _local_unwind
|
---|
[13] | 85 |
|
---|
[11] | 86 | */
|
---|
| 87 |
|
---|
[13] | 88 |
|
---|
| 89 | /**
|
---|
| 90 | * The DLL Main for the Windows API wrapper DLL.
|
---|
| 91 | *
|
---|
| 92 | * @returns Success indicator.
|
---|
| 93 | * @param hInstDll The instance handle of the DLL. (i.e. the module handle)
|
---|
| 94 | * @param fdwReason The reason why we're here. This is a 'flag' for reasons of
|
---|
| 95 | * tradition, it's really a kind of enum.
|
---|
| 96 | * @param pReserved Reserved / undocumented something.
|
---|
| 97 | */
|
---|
| 98 | BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, PVOID pReserved)
|
---|
[11] | 99 | {
|
---|
[13] | 100 | switch (fdwReason)
|
---|
| 101 | {
|
---|
| 102 | case DLL_PROCESS_ATTACH:
|
---|
| 103 | break;
|
---|
[11] | 104 |
|
---|
[13] | 105 | case DLL_PROCESS_DETACH:
|
---|
| 106 | break;
|
---|
[11] | 107 |
|
---|
[13] | 108 | case DLL_THREAD_ATTACH:
|
---|
| 109 | break;
|
---|
[11] | 110 |
|
---|
[13] | 111 | case DLL_THREAD_DETACH:
|
---|
| 112 | break;
|
---|
[11] | 113 | }
|
---|
| 114 |
|
---|
[13] | 115 | return TRUE;
|
---|
[11] | 116 | }
|
---|
| 117 |
|
---|