Я использую следующую функцию в моем x32 InitInstance, но она не работает. Param.CommandLine.Buffer был изменен на пустой, поскольку в диспетчере задач по-прежнему отображается командная строка. Есть ошибка?
#include <Windows.h>
#include <Winternl.h>
#include <stdio.h>
#include <tchar.h>
typedef NTSTATUS (NTAPI *PFN_NT_QUERY_INFORMATION_PROCESS) (
IN HANDLE ProcessHandle,
IN PROCESSINFOCLASS ProcessInformationClass,
OUT PVOID ProcessInformation,
IN ULONG ProcessInformationLength,
OUT PULONG ReturnLength OPTIONAL);
void ClearCommandLine()
{
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS,
FALSE, GetCurrentProcessId());
PROCESS_BASIC_INFORMATION pbi = {0};
RTL_USER_PROCESS_PARAMETERS Param = {0};
PFN_NT_QUERY_INFORMATION_PROCESS pfnNtQueryInformationProcess =
(PFN_NT_QUERY_INFORMATION_PROCESS) GetProcAddress (
GetModuleHandle(TEXT("ntdll.dll")), "NtQueryInformationProcess");
NTSTATUS status = pfnNtQueryInformationProcess (
hProcess, ProcessBasicInformation,
(PVOID)&pbi, sizeof(pbi), NULL);
wchar_t* lpwszCmd=L"";
USHORT usCmdLen = 2 + 2 * (wcslen(lpwszCmd));
ReadProcessMemory(hProcess, pbi.PebBaseAddress, &peb, sizeof(peb), NULL);
ReadProcessMemory(hProcess, peb.ProcessParameters, &Param, sizeof(Param), NULL);
WriteProcessMemory(hProcess, Param.CommandLine.Buffer, lpwszCmd, usCmdLen,NULL);
WriteProcessMemory(hProcess,&Param.CommandLine.Length, &usCmdLen, sizeof(usCmdLen), NULL);
CloseHandle(hProcess);
}