我需要用PEB找到程序的命令行。用PEB找到程序的命令行?
我用FS:[的0x30]找到PEB
int wmain(int argc, WCHAR *argv[])
{
PVOID pebAddress =(void *) __readfsdword(0x30); /* get the PEB address */
PVOID rtlUserProcParamsAddress;
ReadProcessMemory(GetCurrentProcess(),(PCHAR)pebAddress+ 0x10,
&rtlUserProcParamsAddress, /* we'll just read directly into our variable */
sizeof(PVOID),
NULL
);
UNICODE_STRING commandLine;
ReadProcessMemory(GetCurrentProcess(), (PCHAR)rtlUserProcParamsAddress + 0x40,&commandLine, sizeof(commandLine), NULL);
WCHAR * commandLineContents;
commandLineContents = (WCHAR *)malloc(commandLine.Length);
ReadProcessMemory(GetCurrentProcess(), commandLine.Buffer,commandLineContents, commandLine.Length, NULL);
printf("%.*S\n", commandLine.Length/2, commandLineContents);
}
,但它不工作。我只需要使用PEB而不是GetCommandLine(void);
」「順便說一句,當你從自己的過程中讀取時,不需要使用ReadProcessMemory。」「怎麼樣? – maysam 2010-11-15 09:32:09
您從__readfsdword獲得的地址位於您自己的過程中。只要把它當作一個指針和取消引用/ memcpy。 PUNICODE_STRING cl =(PUNICODE_STRING)((*(LPBYTE *)((LPBYTE)__ readfsdword(0x30)+ 0x10))+ 0x40);' – kichik 2010-11-15 09:42:34