自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

淺談Windows CE中的未公開函數(shù)

開發(fā)
本文將介紹Windows CE中的未公開函數(shù),包括PerformCallBack4、RegisterAPISet、QueryAPISetID、GetAPIAddress等多個函數(shù)。

PerformCallBack4

強(qiáng)制令別的進(jìn)程調(diào)用某個API,如果這個API是LoadLibrary的話,就相當(dāng)于線程注入了,由coredll.dll提供

PerformCallBack4函數(shù)的定義:

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

其中函數(shù)的參數(shù)CallBackInfo結(jié)構(gòu)定義:

  1. public struct CallBackInfo  
  2. {  
  3. public IntPtr hProc; //遠(yuǎn)程的目標(biāo)進(jìn)程  
  4. public IntPtr pfn; //指向遠(yuǎn)程目標(biāo)進(jìn)程的函數(shù)地址的指針  
  5. public IntPtr pvArg0; //函數(shù)的需要的***個參數(shù)  

而PerformCallback4的 ni_pVoid1、ni_pVoid2、ni_pVoid3為傳遞到遠(yuǎn)程目標(biāo)進(jìn)程執(zhí)行函數(shù)的其它三個參數(shù)。

例子:

  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里面有這個函數(shù)


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里面有這個函數(shù)

QueryAPISetID

根據(jù)名字查詢該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

根據(jù)進(jìn)程的ID計算出進(jìn)程的序號(這個序號就是進(jìn)程處于第幾個slot),由coredll.dll提供

Syntax

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

Parameters

hProc

[in] 進(jìn)程的句柄,這里為什么不是進(jìn)程的ID而是進(jìn)程的句柄呢?非常簡單,因?yàn)樵贑E中進(jìn)程的句柄就是進(jìn)程的ID!

Return Value

進(jìn)程的序號

【編輯推薦】

  1. WinCE編譯過程的四個階段
  2. WinCE中觸摸屏驅(qū)動開發(fā)詳解
  3. Windows Mobile和WinCE的區(qū)別
  4. WinCE中串口驅(qū)動及接口函數(shù)介紹
  5. WinCE中nandflash驅(qū)動開發(fā)介紹
責(zé)任編輯:彭凡 來源: 百度空間
相關(guān)推薦

2010-07-26 16:26:56

MS SQL Serv

2010-07-23 15:52:52

MS SQL Serv

2022-04-13 16:48:51

CPU網(wǎng)絡(luò)安全

2025-01-20 15:22:55

2015-05-22 11:33:08

2009-07-31 13:48:34

C# eval()函數(shù)

2010-03-31 16:36:35

Windows CE

2009-05-28 13:39:13

Windows CE

2010-01-06 10:08:16

Boot Loader

2011-08-01 16:52:42

Windows CE 嵌入式

2011-06-27 09:49:53

Windows CEAndroid

2009-08-17 09:57:00

C# Windows

2009-07-23 14:08:46

Windows Emb

2009-04-11 15:12:24

Windows CE串行通信GPS

2009-07-31 16:06:50

成員函數(shù)構(gòu)造函數(shù)C#

2011-06-17 14:16:21

ListBoxWindows Pho

2011-07-14 10:58:26

JavaScript強(qiáng)制類型轉(zhuǎn)換函數(shù)

2012-09-11 10:23:24

Windows 8

2010-03-17 14:21:47

Windows Emb

2010-11-08 14:47:02

Powershell函數(shù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號