Ignore:
Timestamp:
Apr 20, 2008, 12:13:43 PM (17 years ago)
Author:
bird
Message:

Made it (winapi wrapping) work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kProfiler2/kPrf2WinApiWrappers.c

    r12 r13  
    3333#include <TLHelp32.h>
    3434#include <k/kDefs.h>
     35#include "kPrf2WinApiWrapperHlp.h"
    3536
    3637#if K_ARCH == K_ARCH_X86_32
     
    3940#endif
    4041
     42/* RtlUnwindEx is used by msvcrt on amd64, but winnt.h only defines it for IA64... */
     43typedef struct _FRAME_POINTERS {
     44    ULONGLONG MemoryStackFp;
     45    ULONGLONG BackingStoreFp;
     46} FRAME_POINTERS, *PFRAME_POINTERS;
     47typedef PVOID PUNWIND_HISTORY_TABLE;
     48typedef PVOID PKNONVOLATILE_CONTEXT_POINTERS;
     49
     50
    4151/*******************************************************************************
    42 *   Structures and Typedefs                                                    *
     52*   Global Variables                                                           *
    4353*******************************************************************************/
    44 typedef struct KPRF2WRAPDLL
     54KPRF2WRAPDLL g_Kernel32 =
    4555{
    46     HMODULE hmod;
    47     char szName[32];
    48 } KPRF2WRAPDLL;
    49 typedef KPRF2WRAPDLL *PKPRF2WRAPDLL;
    50 typedef KPRF2WRAPDLL const *PCKPRF2WRAPDLL;
     56    INVALID_HANDLE_VALUE, "KERNEL32"
     57};
    5158
     59
     60/*
     61 * Include the generated code.
     62 */
     63#include "kPrf2WinApiWrappers-kernel32.h"
    5264
    5365/* TODO (amd64):
     
    7183__misaligned_access
    7284_local_unwind
     85
    7386*/
    7487
    75 /*******************************************************************************
    76 *   Global Variables                                                           *
    77 *******************************************************************************/
    78 KPRF2WRAPDLL g_Kernel32 =
     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 */
     98BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, PVOID pReserved)
    7999{
    80     INVALID_HANDLE_VALUE, "KERNEL32"
    81 };
     100    switch (fdwReason)
     101    {
     102        case DLL_PROCESS_ATTACH:
     103            break;
    82104
     105        case DLL_PROCESS_DETACH:
     106            break;
    83107
    84 /*******************************************************************************
    85 *   Internal Functions                                                         *
    86 *******************************************************************************/
    87 FARPROC kPrf2WrapResolve(void **ppfn, const char *pszName, PKPRF2WRAPDLL pDll);
     108        case DLL_THREAD_ATTACH:
     109            break;
    88110
    89 
    90 FARPROC kPrf2WrapResolve(void **ppfn, const char *pszName, PKPRF2WRAPDLL pDll)
    91 {
    92     FARPROC pfn;
    93     HMODULE hmod = pDll->hmod;
    94     if (hmod == INVALID_HANDLE_VALUE)
    95     {
    96         hmod = LoadLibraryA(pDll->szName);
    97         pDll->hmod = hmod;
     111        case DLL_THREAD_DETACH:
     112            break;
    98113    }
    99114
    100     pfn = GetProcAddress(hmod, pszName);
    101     *ppfn = (void *)pfn;
    102     return pfn;
     115    return TRUE;
    103116}
    104117
    105 
    106 #include "kPrf2WinApiWrappers-kernel32.h"
Note: See TracChangeset for help on using the changeset viewer.