是这样的:HMODULE hD3D9 = LoadLibrary("Kernel32.dll");
LPVOID pSystemDirectory =GetProcAddress(hD3D9,"GetSystemDirectory");
//函数的地址已经找到了 请问怎么根据pSystemDirectory 来调用GetSystemDirectory函数?

解决方案 »

  1.   

    GetSystemDirectory 的函数原型如果是 int GetSystemDirectory(int param);
    typedef (* int GetSYSDIR)(int param);
    GetSYSDIR GetSysDir;
    GetSysDir =GetProcAddress(hD3D9,"GetSystemDirectory");int m =  GetSysDir (1);  就可以调用了
      

  2.   

    typedef UINT (WINAPI* PFNGetSystemDirectory)(LPTSTR lpBuffer, UINT uSize);HMODULE hD3D9 = LoadLibrary("Kernel32.dll");
    PFNGetSystemDirectory pSystemDirectory =(PFNGetSystemDirectory)GetProcAddress(hD3D9,"GetSystemDirectory");
      

  3.   


    不对啊
    函数原型:
    IDirect3D9 * Direct3DCreate9(
      UINT SDKVersion
    );
    typedef   (*IDirect3D9   MyDirect3DCreate9)(UINT SDKVersion );
    C:\1\hxwdllwx\hxwdllwx.cpp(10) : error C2146: syntax error : missing ')' before identifier 'MyDirect3DCreate9'
    C:\1\hxwdllwx\hxwdllwx.cpp(10) : error C2146: syntax error : missing ';' before identifier 'MyDirect3DCreate9'
    C:\1\hxwdllwx\hxwdllwx.cpp(10) : error C2040: 'IDirect3D9' : 'int *' differs in levels of indirection from 'struct IDirect3D9'
    C:\1\hxwdllwx\hxwdllwx.cpp(10) : fatal error C1004: unexpected end of file found
      

  4.   

    LS正解,不过有个笔误,typedef (* int GetSYSDIR)(int param); 
                  改为    typedef (int *GetSYSDIR)(int param);
    然后在赋值时加个类型转换 GetSysDir = (GetSYSDIR)GetProcAddress(hD3D9,"GetSystemDirectory");
      

  5.   


    #include "stdafx.h"
    #include <Windows.h>
    #include <tchar.h>typedef UINT (WINAPI* PFNGetSystemDirectory)(LPWSTR lpBuffer, UINT uSize);
    int main()
    {

    HMODULE hD3D9 = LoadLibrary("Kernel32.dll");
    if(hD3D9)
    {
    PFNGetSystemDirectory pFn = (PFNGetSystemDirectory)GetProcAddress(hD3D9, "GetSystemDirectoryW");

    if(pFn)
    {
    WCHAR buf[MAX_PATH] = {0};
    pFn(buf, MAX_PATH);
    wprintf(L"%s\n", buf);
    }

    FreeLibrary(hD3D9);
    }

    return 0;
    }
      

  6.   

    Kernel32.dll中导出的GetSystemDirectoryA和GetSystemDirectoryW这两个函数,不是GetSystemDirectory
      

  7.   

    哈哈
    其实我要调用的是由 d3d9.dll导出的 Direct3DCreate9 函数
    IDirect3D9 * Direct3DCreate9(
      UINT SDKVersion
    );
      

  8.   

    直接调用不行吗?还从kernel32.dll中导出?
      

  9.   

    比如话: 我要调用的是GetSystemDirectory 因为我已经在我的程序里封装了一个GetSystemDirectory
    函数 如果直接调用的话不就是调用了自己封装的那个函数了吗
      

  10.   

    ::GetSystemDirectory();使用作用域标识符
      

  11.   

    还是重复调用自己的函数 MessageBox个不停
      

  12.   

    IDirect3D9 * WINAPI Direct3DCreate9(UINT SDKVersion)
    {

    MessageBox(0,"拦截到了",0,0);
    ::Direct3DCreate9(SDKVersion);
    return 0;
    }
      

  13.   

    难道要这样?
    执行到 Direct3DCreate9函数时 调用另外一个DLL导出的函数
    然后sleep 将自己重命名
    另外一个DLL就执行Direct3DCreate9 这时执行的就是system32里面的d3d9.dll 导出的函数
    这样啊? 麻烦了点
      

  14.   

    IDirect3D9    * WINAPI Direct3DCreate9(UINT SDKVersion)
    {

    MessageBox(0,"拦截到了",0,0);
      char chPath[MAX_PATH];
      GetSystemDirectory(chPath,MAX_PATH);
      strcat(chPath,"\\d3d9.dll");
     
      HMODULE hD3D9 = LoadLibrary(chPath);
      if (hD3D9 == NULL)
      {
      MessageBox(0,"failed",0,0);
      }
       LPVOID pDirect3DCreate9 =GetProcAddress(hD3D9,"Direct3DCreate9");
      if (pDirect3DCreate9 == NULL)
      {
      MessageBox(0,"GetProcAddress Failed",0,0);
    }
    _asm
    {
    mov eax,SDKVersion
    mov ecx ,pDirect3DCreate9
    call ecx

    }

    return 0;
    }
    内联汇编也可以啊不过调用约定那些麻烦 不知道怎么搞了
      

  15.   


    哈哈 我也刚想到内联汇编的但是调用约定 堆栈平衡那些就麻烦了 
    函数原型是:
    IDirect3D9 * Direct3DCreate9(
      UINT SDKVersion
    );
    约定是 _stdcall
      

  16.   

    右至左 压栈   PUSHAD  POPAD
      

  17.   

    还是崩溃ing
    IDirect3D9  * WINAPI Direct3DCreate9(UINT SDKVersion)
    {
    __asm pushad
    MessageBox(0,"拦截到了",0,0);
      char chPath[MAX_PATH];
      GetSystemDirectory(chPath,MAX_PATH);
      strcat(chPath,"\\d3d9.dll");
     
      HMODULE hD3D9 = LoadLibrary(chPath);
      if (hD3D9 == NULL)
      {
      MessageBox(0,"failed",0,0);
      }
       LPVOID pDirect3DCreate9 =GetProcAddress(hD3D9,"Direct3DCreate9");
      if (pDirect3DCreate9 == NULL)
      {
      MessageBox(0,"GetProcAddress Failed",0,0);
    }
    _asm
    {
    mov eax,SDKVersion
    mov ecx ,pDirect3DCreate9
    call ecx

    }
    __asm popad

    return 0;
    }