浅谈Windows CE中的未公开函数

PerformCallBack4

强制令别的进程调用某个API,如果这个API是LoadLibrary的话,就相当于线程注入了,由coredll.dll提供

PerformCallBack4函数的定义:

 
 
  1. [DllImport("coredll.dll")]  
  2. public static extern uint PerformCallBack4(ref CallBackInfo CallBackInfo,  
  3. IntPtr ni_pVoid1,IntPtr ni_pVoid2,IntPtr ni_pVoid3); 

其中函数的参数CallBackInfo结构定义:

 
 
  1. public struct CallBackInfo  
  2. {  
  3. public IntPtr hProc; //远程的目标进程  
  4. public IntPtr pfn; //指向远程目标进程的函数地址的指针  
  5. public IntPtr pvArg0; //函数的需要的第一个参数  

而PerformCallback4的 ni_pVoid1、ni_pVoid2、ni_pVoid3为传递到远程目标进程执行函数的其它三个参数。

例子:

 
 
  1. /*-------------------------------------------------------------------  
  2.    FUNCTION: CallCoredllInProc  
  3.    PURPOSE: CallCoredllInProc uses undocumented method   
  4.     PerformCallBack4 to call exported methods from coredll.dll in   
  5.     the specified process.  
  6.    PARAMETERS:  
  7.     HANDLE p_hProcess - handle to the process, where the call should  
  8.         be made  
  9.     LPCTSTR p_pszMethodName - name of method exported from coredll,   
  10.         such as VirtualAlloc, VirtualFree, etc.  
  11.     DWORD p_dwParam1, p_dwParam2, p_dwParam3, p_dwParam4 - arguments  
  12.     DWORD * p_pdwResult - pointer to the return value  
  13.    RETURNS:  
  14.     TRUE on success, FALSE on failure  
  15. -------------------------------------------------------------------*/  
  16. BOOL CallCoredllInProc  
  17. (  
  18.     HANDLE p_hProcess,  
  19.     LPCTSTR p_pszMethodName,  
  20.     DWORD   p_dwParam1, DWORD p_dwParam2,   
  21.     DWORD   p_dwParam3, DWORD p_dwParam4,  
  22.     DWORD * p_pdwResult)  
  23. {  
  24.     HINSTANCE l_hCoreDll = NULL;  
  25.     BOOL l_bReturn = FALSE;  
  26.     __try  
  27.     {  
  28.         //Use undocumented method PerformCallBack4   
  29.         //to call method in NK.EXE.  
  30.         CALLBACKINFO CallbackInfo;  
  31.         CallbackInfo.m_hDestinationProcessHandle = p_hProcess;  
  32.         l_hCoreDll = LoadLibrary(_T("COREDLL"));  
  33.         CallbackInfo.m_pFunction =   
  34.             (FARPROC)GetProcAddress(l_hCoreDll, p_pszMethodName);  
  35.         if(!CallbackInfo.m_pFunction)  
  36.         {  
  37.             /*HTRACE(TG_Error,   
  38.                 _T("GetProcAddress(%x, %s) failed. Err %d"),   
  39.                 l_hCoreDll, p_pszMethodName, GetLastError());  
  40.             */  
  41.         }  
  42.         else  
  43.         {  
  44.             CallbackInfo.m_pFirstArgument = (LPVOID)p_dwParam1;  
  45.             DWORD l_dwResult = PerformCallBack4 
  46.                 (&CallbackInfo, p_dwParam2, p_dwParam3, p_dwParam4);  
  47.             if(p_pdwResult)  
  48.             {  
  49.                 *p_pdwResult = l_dwResult;  
  50.             }  
  51.             l_bReturn = TRUE;  
  52.         }  
  53.     }  
  54.     __except(1)  
  55.     {  
  56.         /*  
  57.         HTRACE(TG_Error, _T("Exception in CallCoredllInProc(%s)"),   
  58.             p_pszMethodName);  
  59.         */  
  60.         l_bReturn = FALSE;  
  61.     }  
  62.     if(l_hCoreDll)  
  63.     {  
  64.         FreeLibrary(l_hCoreDll);  
  65.     }  
  66.     return l_bReturn;  
  67. }//BOOL CallCoredllInProc 

CreateAPISet

CE6.0以前是个未公开API,不过6.0以后就公开了

This function creates an API set from the list of functions passed as a parameter.

Syntax

 
 
  1. HANDLE CreateAPISet(  
  2. char acName[4],  
  3. USHORT cFunctions,  
  4. const PFNVOID *ppfnMethods,  
  5. const ULONGLONG *pu64Sig  
  6. );  
  7. Parameters   
  8. acName   
  9. [in] Name of the API set.  
  10.  
  11. cFunctions   
  12. [in] Number of functions for this API set.  
  13.  
  14. ppfnMethods   
  15. [in] Array of functions for the API set.  
  16.  
  17. pu64Sig   
  18. [in] Array of signatures for the functions.  
  19.  
  20.  
  21. Return Value   
  22. A handle to the API set.  
  23.  
  24. Remarks   
  25. Before any process can become a handle server, the process must create and register a handle-based API set with this function and RegisterAPISet.  
  26.  
  27. Requirements   
  28. Header pkfuncs.h   
  29. Library coredll.lib   
  30. Windows Embedded CE Windows Embedded CE 6.0 and later  

CE6.0以前在coredll.dll里面有这个函数


RegisterAPISet

CE6.0以前是个未公开API,不过6.0以后就公开了

This function registers an API set.

Syntax

 
 
  1. BOOL RegisterAPISet(  
  2. HANDLE hASet,  
  3. DWORD dwSetID  
  4. );  
  5.  
  6. Parameters   
  7. hASet   
  8. [in] Handle to API set created by the CreateAPISet function.  
  9.  
  10. dwSetID   
  11. [in] Type of API set. You must perform a bitwise OR operation on this parameter with REGISTER_APISET_TYPE to create a handle-based API set.  
  12.  
  13. Return Value   
  14. TRUE indicates success. FALSE indicates failure. Call GetLastError to get extended error information.  
  15.  
  16. Remarks   
  17. Before any process can become a handle server, the process must create and register a handle-based API set with CreateAPISet and RegisterAPISet.  
  18.  
  19. Requirements   
  20. Header pkfuncs.h   
  21. Library coredll.lib   
  22. Windows Embedded CE Windows Embedded CE 6.0 and later  

CE6.0以前在coredll.dll里面有这个函数

QueryAPISetID

根据名字查询该API的ID,由coredll.dll提供

Syntax

 
 
  1. int QueryAPISetID(  
  2. char *pName  
  3. );  
  4.  
  5. Parameters  
  6. pName   
  7. [in] API的名字  
  8.  
  9. Return Value   
  10. API的ID 

GetAPIAddress
获取特定API的特定Method的地址,由coredll.dll提供

 
 
  1. FARPROC GetAPIAddress(  
  2. int setId,  
  3. int iMethod  
  4. );  
  5.  
  6. Parameters   
  7. setId   
  8. [in] API的ID  
  9.  
  10. iMethod   
  11. [in] Method的ID  
  12.  
  13. Return Value   
  14. 该Method的地址 

GetProcessIndexFromID

根据进程的ID计算出进程的序号(这个序号就是进程处于第几个slot),由coredll.dll提供

Syntax

 
 
  1. DWORD GetProcessIndexFromID(  
  2. HANDLE hProc  
  3. ); 

Parameters

hProc

[in] 进程的句柄,这里为什么不是进程的ID而是进程的句柄呢?非常简单,因为在CE中进程的句柄就是进程的ID!

Return Value

进程的序号

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值