HProcessId=OpenProcess (PROCESS_ALL_ACCESS, FALSE, dwProcessId);
If (hProcessId==NULL)
{
MessageBox (_T (OpenProcess failed! "" ));
}
HRemoteDllPath=VirtualAllocEx (hProcessId, NULL, strlen (Dllname), MEM_COMMIT, PAGE_READWRITE);
If (hRemoteDllPath==NULL)
{
MessageBox (_T (VirtualAlocEc failed! "" ));
}
If (WriteProcessMemory (hProcessId, hRemoteDllPath Dllname, strlen (Dllname), & amp; NSize)==0)//error 487 in front of all
{
DWORD Derror=GetLastError ();
MessageBox (_T (WriteProcessMemory failed! "" ));
}
CodePudding user response:
bool AdjustPrivileges () {
HANDLE hToken;
The TOKEN_PRIVILEGES tp;
The TOKEN_PRIVILEGES oldtp;
DWORD dwSize=sizeof (TOKEN_PRIVILEGES);
LUID LUID;
if (! OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, & amp; HToken)) {
If (GetLastError ()==ERROR_CALL_NOT_IMPLEMENTED) return true;
The else return false;
}
if (! LookupPrivilegeValue (NULL, SE_DEBUG_NAME, & amp; Luid)) {
The CloseHandle (hToken);
return false;
}
ZeroMemory (& amp; Tp, sizeof (tp));
Tp. PrivilegeCount=1;
Tp. Privileges [0]. Luid=Luid;
Tp. Privileges [0]. Attributes=SE_PRIVILEGE_ENABLED;
/* Adjust Token Privileges */
if (! AdjustTokenPrivileges (hToken, FALSE, & amp; Tp, sizeof (TOKEN_PRIVILEGES), & amp; Oldtp, & amp; DwSize)) {
The CloseHandle (hToken);
return false;
}
//close handles
The CloseHandle (hToken);
return true;
}
CodePudding user response:
Experiment with other process, such as notepad, calculator, IE, see whether this error,Right-click administrator privileges to run, look to whether or this error,
The above control experiment are carried out to determine whether permission problems,
General permission problems GetLastError is 5
CodePudding user response:
If your application is 32 bit, whether the target process is 64, if so, error is normal