已经保存跳转地址 到 PROC * paorigfuncs
paorigfuncs = (PROC *)prealthunk->u1.Function; 
应该怎么做呢?
另外如果用这种方法能截获与SOCKET相关的函数调用吗?如果能,思路又是什么呢?

解决方案 »

  1.   

    看看Windows核心编程中的例子~
    它是一个函数,然后传入你要查的module、函数名和你要替换的函数名~
    ---------------------------------
    注册表学习器  For  Windows9x\me\2000\XP    
            我是CSDN的Windows9x\me的斑竹。平时在论坛里经常看到有人问一些各式各样的关于注册表方面的问题。我经常建议他(她)们使用各种工具软件,但是很多人想要手动修改,但是不知道怎么改。所以我搜集了一些资料,作了这个软件。希望它能对这些想学习注册表的朋友有帮助!1、本程序包含注册表操作方面的绝大部分。如系统性能优化、网络优化、各类菜单等等。
    2、本程序支持注册表定位。请选择键值菜单下一个应用条目,然后双击之,或者单击菜单栏上的定位,便可到达相应位置。
    3、本程序支持窗体最前端。可以将窗体置前,以不影响后面对其它程序如注册表等的操作。
    4、本程序可以调用一些常用的系统应用程序。见工具菜单。
    5、本程序的注册表应用可能不够准确和详细。我会尽量在下一个版本进行添加并检查改进。
    ---------------------------------
    下载地址:http://www.csdn.net/cnshare/soft/12/12531.shtm
      

  2.   

    http://www.csdn.net/expert/topic/1001/1001813.xml?temp=.2465021
      

  3.   

    比如你自己的函数是  MyConnect(..........);
    参数和返回值都和标准connect相同
    然后
    你在你的MyConnect函数里return paorigfuncs(..........);
    就行了
    paorigfuncs是你用GetProcAddress得到的原函数地址
      

  4.   

    晕~我是想问怎样通过paorigfuncs 来调用原来的api!
      

  5.   

    不行啊!to sesins
    error C2197: 'int (__stdcall *)(void)' : too many actual parameters
      

  6.   

    to snsins你说
    你在你的MyConnect函数里return paorigfuncs(..........);
    这里的paorigfuncs是你用GetProcAddress得到的原函数地址
    可我不是用GetProcAddress得到paorigfuncs的啊!
      

  7.   

    void CAPIHook::ReplaceIATEntryInOneMod(PCSTR pszCalleeModName,PROC pfnCurrent,
       PROC pfnNew,HMODULE hmodCaller)
    {
    // Get the address of the module's import section
    ULONG ulSize;
    PIMAGE_IMPORT_DESCRIPTOR pImportDesc=(PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(hmodCaller,
    TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT,&ulSize);

    if (pImportDesc == NULL) //判断是否有输入节
    return;  // This module has no import section


    // Find the import descriptor containing references to callee's functions
    for (; pImportDesc->Name; pImportDesc++) 
    {
    PSTR pszModName = (PSTR) ((PBYTE) hmodCaller + pImportDesc->Name);
    if(lstrcmpiA(pszModName,pszCalleeModName)==0)//寻找dll,pszModName:hmodCaller导出的dll 

    break;   // Found
    }

    if (pImportDesc->Name == 0)
    return;  // This module doesn't import any functions from this callee

    // Get caller's import address table (IAT) for the callee's functions
    PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA) 
    ((PBYTE) hmodCaller + pImportDesc->FirstThunk);

    // Replace current function address with new function address
    for (; pThunk->u1.Function; pThunk++) //寻找函数
    {
    // Get the address of the function address
    PROC* ppfn = (PROC*) &pThunk->u1.Function;

    // Is this the function we're looking for?
    BOOL fFound = (*ppfn == pfnCurrent); //ppfn:得到的函数

    if (!fFound && (*ppfn > sm_pvMaxAppAddr)) 
    {
    // If this is not the function and the address is in a shared DLL, 
    // then maybe we're running under a debugger on Windows 98. In this 
    // case, this address points to an instruction that may have the 
    // correct address.

    PBYTE pbInFunc = (PBYTE) *ppfn;
    if (pbInFunc[0] == cPushOpCode) 
    {
    // We see the PUSH instruction, the real function address follows
    ppfn = (PROC*) &pbInFunc[1];

    // Is this the function we're looking for?
    fFound = (*ppfn == pfnCurrent);
    }
    }

    if (fFound) 
    {
    // The addresses match, change the import section address
    WriteProcessMemory(GetCurrentProcess(), ppfn, &pfnNew, 
    sizeof(pfnNew), NULL);
    return;  // We did it, get out
    }
    }

    // If we get to here, the function is not in the caller's import section
    }
      

  8.   

    to  rivershan(笨猫)(C++/VC初学者) 555~~~我想问的地方怎么没有啊?在我自己的函数里面怎样通过paorigfuncs来调用原来的api?也就是在你的程序中如何通过PROC* ppfn 来调用原来的api!
      

  9.   

    nbk16(=nbk=16) :你仔细看看我那方法吧
    我那样做是可以的
      

  10.   

    可我已经用这个方法保存了函数原来的地址了,paorigfuncs = (PROC *)prealthunk->u1.Function; 为什么不能用paorigfuncs 来直接调用原来的函数呢?非用GetProcAddress来保存原来的地址才行吗?