Posted on 2009-10-24 23:58
S.l.e!ep.¢% 閱讀(370)
評論(0) 編輯 收藏 引用 所屬分類:
RootKit
[資料] http://m.shnenglu.com/sleepwom/archive/2009/10/24/99375.html
What is SSDT?
SSDT的全稱是System Services Descriptor Table,系統服務描述符表。這個表就是一個把ring3的Win32 API和ring0的內核API聯系起來。SSDT并不僅僅只包含一個龐大的地址索引表,它還包含著一些其它有用的信息,諸如地址索引的基地址、服務函數個數等。
How to use?
在頭文件如此定義即可
#pragma? pack(1)
typedef struct _SSDT_TABLE
{
? PVOID?? ServiceTableBase;
? PULONG? ServiceCounterTableBase;
? ULONG?? NumberOfService;
? ULONG?? ParamTableBase;
}SSDT_TABLE,* PSSDT_TABLE;
#pragma pack()
extern "C" extern PSSDT_TABLE??KeServiceDescriptorTable;
why?
KeServiceDescriptorTable是ntoskrnl.exe導出的(Win下所有PE都可以導出接口或變量)
用 vc 自帶的 dependency.exe 工具查看 ntoskrnl.exe 就可以看到
609(0x0261) 594(0x0252) KeServiceDescriptorTable??? 0x0008B520?
(另外可以看到? Nt開頭的是ntdll.dll導出的,ntoskrnl.exe導出的是Zw開頭的函數 )
可以參考以下這篇文章,里面提到系統服務號101h,NtTerminateProcess和ZwTerminateProcess的關系:
內核下,ZwXxx函數還是會走int?2e這條路,為的是把PreviousMode變為KernelMode。NtXxx是真正實現的地方。SSDT里面放的是NtXxx的函數地址。
標?題:?【原創】內核態進程管理器Intercessor和實現細節
作?者:?greatcsk
時?間:?2007-09-05,20:20
鏈?接:?http://bbs.pediy.com/showthread.php?t=51157?
try it;
寫一個Exe程序
.h 加上
#pragma comment(linker, "/EXPORT:_Add,@1,NONAME")
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) int Add(int a, int b);
#ifdef __cplusplus
}
#endif? /* __cplusplus */
.cpp 加上
#ifdef __cplusplus
extern "C" {
#endif
?? int Add(int a, int b)
?? {
???? return (a + b);
?? }
#ifdef __cplusplus
}
#endif? /* __cplusplus */
最后加上 .def
EXPORTS
?? Add??????? @1??
生成后,發現有 *.lib
用 dependency.exe 一看,確實導出了
調用時,跟調用DLL的函數是一樣的
void CTestexeexportDlg::OnButton1()
{
?HMODULE moudule = ::LoadLibrary("C:\\\\exeexport.exe");
?typedef int(*MyFuncProc)(int a, int b);
?MyFuncProc pFun;
?pFun = (MyFuncProc)GetProcAddress(moudule, "Add");
?int i = pFun(10, 20);
}