kDefs.h: Added risc-v to the K_ARCH_XXX defines.
[kstuff-mirror.git] / kProfiler2 / kPrf2WinApiWrappers.c
blob9da66e15ab4971ba3afaef5da39a2d607ef6adb3
1 /* $Id$ */
2 /** @file
3 * Wrappers for a number of common Windows APIs.
4 */
6 /*
7 * Copyright (c) 2008 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
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:
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
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.
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"
43 #if K_ARCH == K_ARCH_X86_32
44 typedef PVOID PRUNTIME_FUNCTION;
45 typedef FARPROC PGET_RUNTIME_FUNCTION_CALLBACK;
46 #endif
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;
57 /*******************************************************************************
58 * Global Variables *
59 *******************************************************************************/
60 KPRF2WRAPDLL g_Kernel32 =
62 INVALID_HANDLE_VALUE, "KERNEL32"
67 * Include the generated code.
69 #include "kPrf2WinApiWrappers-kernel32.h"
71 /* TODO (amd64):
73 AddLocalAlternateComputerNameA
74 AddLocalAlternateComputerNameW
75 EnumerateLocalComputerNamesA
76 EnumerateLocalComputerNamesW
77 RemoveLocalAlternateComputerNameA
78 RemoveLocalAlternateComputerNameW
80 RtlLookupFunctionEntry
81 RtlPcToFileHeader
82 RtlRaiseException
83 RtlVirtualUnwind
85 SetConsoleCursor
86 SetLocalPrimaryComputerNameA
87 SetLocalPrimaryComputerNameW
88 __C_specific_handler
89 __misaligned_access
90 _local_unwind
95 /**
96 * The DLL Main for the Windows API wrapper DLL.
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.
104 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, PVOID pReserved)
106 switch (fdwReason)
108 case DLL_PROCESS_ATTACH:
109 break;
111 case DLL_PROCESS_DETACH:
112 break;
114 case DLL_THREAD_ATTACH:
115 break;
117 case DLL_THREAD_DETACH:
118 break;
121 return TRUE;