驱动之路_函数大全

 

RtlEqualUnicodeString(&str,ObjectAttributes->ObjectName,TRUE)//为TRUE表示不区分大小写

http://mzf2008.blog.163.com/blog/static/3559978620101112115510592/

 

 

字符串操作:

_stricmp(char*s1,char*s2) #include <string.h>  比较字符串,忽略大小写,如果相等返回0

char string1[] = "The quick brown dog jumps over the lazy fox";
char string2[] = "The QUICK brown dog jumps over the lazy fox";
int result = _stricmp( string1, string2 );

 

DbgPrint()打印字符串

RtlZeroMemory((PVOID)ProcName , 64);其实这是个宏,memset((Destination),0,(Length))

RtlCopyMemory((PVOID)ProcName , ImageName , 16);其实这是个宏memcpy((Destination),(Source),(Length))

 

wcsncpy(wchar_t*s1,wchar_t*s2,INT count) 拷贝字符串从c到d,,后面的一个参数为拷贝多少个字符,wchar_t为单位

wchar_t c[]={L"aaa"};
wchar_t d[13]={0};
wcsncpy(d,c,3);
getchar();

 

_wcsupr(wchar_t*s1) 抓换为大写,单位为宽字符

wchar_t c[]={L"aaa"};
_wcsupr(c);

 

wcsstr(wchar_t*s1) 查找字符串

wchar_t c[]={L"abcdefg"};
wchar_t* a = wcsstr(c,L"cd);,结果为cdefg,如果未找到,那么这个指针就是0
printf("%d",a);

 

 

wcsstr(char_t*s1,char_t*s2,INT count) 查找字符串,把s2的N个数字加到s1末尾上

char d[20]="Golden Global";
char *s=" View WinIDE Library";
strncat(d,s,7);//Golden Global View W
printf("%s",d);
getchar();

 

_strnicmp(char_t*s1,char_t*s2,INT count) //比较2个字符串前面的几个字母,如果相等则返回0

char *buf1 = "aaa", *buf2 = "AAAAA";
int nResult;
nResult = _strnicmp(buf2, buf1, 3);
if (nResult > 0)
printf("buffer 2 is greater than buffer 1\n");
if (nResult < 0)
printf("buffer 2 is less than buffer 1\n");
if (nResult == 0)
printf("buffer 2 equals buffer 1\n");
getchar();

 

 

RtlInitUnicodeString(&functionName,ZwFunctionName);//赋值字符串

 

ANSI_STRING astr;//ansi字符串
RtlInitUnicodeString(&us,(PCWSTR)buff);//初始化UNICODE

RtlUnicodeStringToAnsiString(&astr,&us,TRUE);//把UNICODE字符串转换为ANSI,这里的ANSI码的缓冲区是堆上申请的,我们得释放她

DbgPrint("The string is: %Z\n",&astr);//打印她 
RtlFreeAnsiString(&astr);//释放她

 

 

(ULONG_PTR)MmGetSystemRoutineAddress(&functionName);//获取导出函数的首地址

 

 

******************************************************

if (_stricmp((char*)PsGetProcessImageFileName(EProcess),"abcdefg.exe") == 0)
{
return TRUE;
}
return FALSE;

PsGetProcessImageFileName(EPocess);//通过进程结构体返回一个进程的名字

******************************************************

 

PDRIVER_OBJECT 驱动对象

PUNICODE_STRING UNICODE字符串指针,她是一个结构体

KdPrint  调试打印

DriverObject->DriverUnload=DDK_UnLoad;//设置卸载驱动函数

PEPROCESS  进程的结构体,每个进程都有这个结构

NTSTATUS  她是一个Long类型

******************************************************

NTSTATUS rc;

//从函数可以得知这个函数是通过pid获得eprocess的

rc=PsLookupProcessByProcessId(PId,&Eprocess);//获取EPROCESS

if (!NT_SUCCESS(rc))
{
return ;
}

//调用PsLookupProcessByProcessId之后,记得要释放引用计数
ObDereferenceObject(Eprocess);

*****************************************************

*******************************************************

//进程创建回调通知
PsSetCreateProcessNotifyRoutine(GameGuardNotifyRoutine, FALSE);//如果为true就表示移除回调

VOID GameGuardNotifyRoutine(IN HANDLE hparentId, IN HANDLE PId,IN BOOLEAN bCreate){

bCreate如果为TRUE就表示创建,FALSE表示进程结束

}

*******************************************************

 

 

 

 

 

 

SRV*D:\symbols*http://msdl.microsoft.com/download/symbols  加载符号

extern "C"  以C的方式编译
DWORD   unsigned long 无符号的long类型
BOOLEAN UCHAR  unsigned char  无符号的字节
ULONG unsigned long
无符号的long类型
PULONG unsigned long* 一个无符号LONG类型的指针
PVOID void* 任何指针类型
LPCSTR, PCSTR CONST CHAR * 常量字符指针
WCHAR   wchar_t   宽字符
BOOL   BOOLEAN
 

 FALSE 0
 TRUE 1

NULL    0

 


//一个纯净的函数
__declspec(naked) void ZwQuerySystemInformationHookZone(...)
{
}
定义函数指针
typedef void (__stdcall *GETCODELENGTH)(PVOID code,DWORD *len);
 
定义枚举,枚举的第一个从0开始的
typedef enum WIN_VER_DETAIL {
    WINDOWS_VERSION_NONE,       //  0
    WINDOWS_VERSION_2K,
    WINDOWS_VERSION_XP,
    WINDOWS_VERSION_2K3,
    WINDOWS_VERSION_2K3_SP1_SP2,
    WINDOWS_VERSION_VISTA_2008,
    WINDOWS_VERSION_7_7600_UP,
    WINDOWS_VERSION_7_7000
} WIN_VER_DETAIL;

 

#ifdef __cplusplus   //如果是C++编译的话就进入下面这个块中
extern "C" NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath); 

#endif

 

 

 

posted @ 2013-09-20 14:36  宝贝,我永远都在  阅读(263)  评论(0)    收藏  举报