mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
BfpProcess_GetById pid check
This commit is contained in:
parent
e4f1906627
commit
4129c38bb2
2 changed files with 10 additions and 2 deletions
|
@ -172,6 +172,7 @@ enum BfpProcessResult
|
||||||
BfpProcessResult_Ok = BfpResult_Ok,
|
BfpProcessResult_Ok = BfpResult_Ok,
|
||||||
BfpProcessResult_UnknownError = BfpResult_UnknownError,
|
BfpProcessResult_UnknownError = BfpResult_UnknownError,
|
||||||
BfpProcessResult_InsufficientBuffer = BfpResult_InsufficientBuffer,
|
BfpProcessResult_InsufficientBuffer = BfpResult_InsufficientBuffer,
|
||||||
|
BfpProcessResult_NotFound = BfpResult_NotFound
|
||||||
};
|
};
|
||||||
|
|
||||||
BFP_EXPORT intptr BFP_CALLTYPE BfpProcess_GetCurrentId();
|
BFP_EXPORT intptr BFP_CALLTYPE BfpProcess_GetCurrentId();
|
||||||
|
|
|
@ -1295,6 +1295,13 @@ BFP_EXPORT bool BFP_CALLTYPE BfpProcess_IsRemoteMachine(const char* machineName)
|
||||||
|
|
||||||
BFP_EXPORT BfpProcess* BFP_CALLTYPE BfpProcess_GetById(const char* machineName, int processId, BfpProcessResult* outResult)
|
BFP_EXPORT BfpProcess* BFP_CALLTYPE BfpProcess_GetById(const char* machineName, int processId, BfpProcessResult* outResult)
|
||||||
{
|
{
|
||||||
|
HANDLE hProc = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
|
||||||
|
if (hProc == NULL)
|
||||||
|
{
|
||||||
|
OUTRESULT(BfpProcessResult_NotFound);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
BfpProcess* process = new BfpProcess();
|
BfpProcess* process = new BfpProcess();
|
||||||
process->mProcessId = processId;
|
process->mProcessId = processId;
|
||||||
process->mInfo = NULL;
|
process->mInfo = NULL;
|
||||||
|
@ -1495,9 +1502,9 @@ BFP_EXPORT void BFP_CALLTYPE BfpProcess_GetProcessName(BfpProcess* process, char
|
||||||
if (process->mImageName.IsEmpty())
|
if (process->mImageName.IsEmpty())
|
||||||
{
|
{
|
||||||
HANDLE hProc = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process->mProcessId);
|
HANDLE hProc = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process->mProcessId);
|
||||||
if (hProc == INVALID_HANDLE_VALUE)
|
if (hProc == NULL)
|
||||||
{
|
{
|
||||||
OUTRESULT(BfpProcessResult_UnknownError);
|
OUTRESULT(BfpProcessResult_NotFound);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WCHAR wName[MAX_PATH] = { 0 };
|
WCHAR wName[MAX_PATH] = { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue