| 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>
|
|---|
| 34 | #include <k/kDefs.h>
|
|---|
| 35 | #include "kPrf2WinApiWrapperHlp.h"
|
|---|
| 36 |
|
|---|
| 37 | #if K_ARCH == K_ARCH_X86_32
|
|---|
| 38 | typedef PVOID PRUNTIME_FUNCTION;
|
|---|
| 39 | typedef FARPROC PGET_RUNTIME_FUNCTION_CALLBACK;
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 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 |
|
|---|
| 51 | /*******************************************************************************
|
|---|
| 52 | * Global Variables *
|
|---|
| 53 | *******************************************************************************/
|
|---|
| 54 | KPRF2WRAPDLL g_Kernel32 =
|
|---|
| 55 | {
|
|---|
| 56 | INVALID_HANDLE_VALUE, "KERNEL32"
|
|---|
| 57 | };
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | /*
|
|---|
| 61 | * Include the generated code.
|
|---|
| 62 | */
|
|---|
| 63 | #include "kPrf2WinApiWrappers-kernel32.h"
|
|---|
| 64 |
|
|---|
| 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
|
|---|
| 85 |
|
|---|
| 86 | */
|
|---|
| 87 |
|
|---|
| 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)
|
|---|
| 99 | {
|
|---|
| 100 | switch (fdwReason)
|
|---|
| 101 | {
|
|---|
| 102 | case DLL_PROCESS_ATTACH:
|
|---|
| 103 | break;
|
|---|
| 104 |
|
|---|
| 105 | case DLL_PROCESS_DETACH:
|
|---|
| 106 | break;
|
|---|
| 107 |
|
|---|
| 108 | case DLL_THREAD_ATTACH:
|
|---|
| 109 | break;
|
|---|
| 110 |
|
|---|
| 111 | case DLL_THREAD_DETACH:
|
|---|
| 112 | break;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | return TRUE;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|