typedef struct UNICODE_STRING
{
USHORT _ength;
USHORT MaximumLength;
PWSTR Buffer;
}UNICODE_STRING,*PUNICODE_STRING;
typedef struct PEB_LDR_DATA{
ULONG Length;
BOOLEAN initialized;
PVOID SsHandle;
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;
LIST_ENTRY InInitializationOrderModuleList;
}PEB_LDR_DATA,*PPEB_LDR_DATA;
typedef struct LDR_DATA_TABLE_ENTRY
{
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;
LIST_ENTRY InInitializationOrderModuleList;
void* BaseAddress;
void* EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
ULONG Flags;
SHORT LoadCount;
SHORT TlsIndex;
HANDLE SectionHandle;
ULONG CheckSum;
ULONG TimeDateStamp;
}LDR_MODULE,*PLDR_MODULE;
HMODULE hMod=::GetModuleHandle(szModuleName);
LDR_MODULE *pPLD=NULL,*pBeg=NULL;
__asm{
mov eax,fs:[0x30]
mov eax,[eax+0x0c]
add eax,0x0c
mov pBeg,eax
mov eax,[eax]
mov pPLD,eax
}
do
{
if(hMod==pPLD->BaseAddress)
{
pPLD->InLoadOrderModuleList.Blink->Flink =
pPLD->InLoadOrderModuleList.Flink;
pPLD->InLoadOrderModuleList.Flink->Blink =
pPLD->InLoadOrderModuleList.Blink;
pPLD->InInitializationOrderModuleList.Blink->Flink =
pPLD->InInitializationOrderModuleList.Flink;
pPLD->InInitializationOrderModuleList.Flink->Blink =
pPLD->InInitializationOrderModuleList.Blink;
pPLD->InMemoryOrderModuleList.Blink->Flink =
pPLD->InMemoryOrderModuleList.Flink;
pPLD->InMemoryOrderModuleList.Flink->Blink =
pPLD->InMemoryOrderModuleList.Blink;
break;
}
pPLD=(LDR_MODULE*)pPLD->InLoadOrderModuleList.Flink;
}
while(pBeg!=pPLD);
#include<stdio.h>
#include<windows.h>
typedef struct UNICODE_STRING
{
USHORT _ength;
USHORT MaximumLength;
PWSTR Buffer;
}UNICODE_STRING,*PUNICODE_STRING;
typedef struct PEB_LDR_DATA{
ULONG Length;
BOOLEAN initialized;
PVOID SsHandle;
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;
LIST_ENTRY InInitializationOrderModuleList;
}PEB_LDR_DATA,*PPEB_LDR_DATA;
typedef struct LDR_DATA_TABLE_ENTRY
{
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;
LIST_ENTRY InInitializationOrderModuleList;
void* BaseAddress;
void* EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
ULONG Flags;
SHORT LoadCount;
SHORT TlsIndex;
HANDLE SectionHandle;
ULONG CheckSum;
ULONG TimeDateStamp;
}LDR_MODULE,*PLDR_MODULE;
void HideModule(char *szModuleName)
{
HMODULE hMod=::GetModuleHandle(szModuleName);
LDR_MODULE *pPLD=NULL,*pBeg=NULL;
__asm{
mov eax,fs:[0x30]
mov eax,[eax+0x0c]
add eax,0x0c
mov pBeg,eax
mov eax,[eax]
mov pPLD,eax
}
do
{
if(hMod==pPLD->BaseAddress)
{
pPLD->InLoadOrderModuleList.Blink->Flink =
pPLD->InLoadOrderModuleList.Flink;
pPLD->InLoadOrderModuleList.Flink->Blink =
pPLD->InLoadOrderModuleList.Blink;
pPLD->InInitializationOrderModuleList.Blink->Flink =
pPLD->InInitializationOrderModuleList.Flink;
pPLD->InInitializationOrderModuleList.Flink->Blink =
pPLD->InInitializationOrderModuleList.Blink;
pPLD->InMemoryOrderModuleList.Blink->Flink =
pPLD->InMemoryOrderModuleList.Flink;
pPLD->InMemoryOrderModuleList.Flink->Blink =
pPLD->InMemoryOrderModuleList.Blink;
break;
}
pPLD=(LDR_MODULE*)pPLD->InLoadOrderModuleList.Flink;
}
while(pBeg!=pPLD);
}
int main()
{
HideModule("kernel32.dll");
getchar();
return 0;
}