Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support Functions for Fuzzing Attached Processes and Fix a False Hang issue in attached processes #61

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
40 changes: 21 additions & 19 deletions common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,27 @@ int GetIntOption(const char *name, int argc, char** argv, int default_value) {
return (int)strtol(option, NULL, 0);
}

DWORD FindProcessId(char * process_name)
{
PROCESSENTRY32 entry;
entry.dwSize = sizeof(PROCESSENTRY32);

HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

if (Process32First(snapshot, &entry) == TRUE)
{
while (Process32Next(snapshot, &entry) == TRUE)
{
if (stricmp(entry.szExeFile, process_name) == 0)
{
CloseHandle(snapshot);
return entry.th32ProcessID;
}
}
}
}
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
DWORD FindProcessId(char * process_name)
{
PROCESSENTRY32 entry;
entry.dwSize = sizeof(PROCESSENTRY32);

HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

if (Process32First(snapshot, &entry) == TRUE)
{
while (Process32Next(snapshot, &entry) == TRUE)
{
if (stricmp(entry.szExeFile, process_name) == 0)
{
CloseHandle(snapshot);
return entry.th32ProcessID;
}
}
}
}
#endif

//quoting on Windows is weird
size_t ArgvEscapeWindows(char *in, char *out) {
Expand Down
4 changes: 3 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ uint64_t GetCurTime(void);
char *GetOption(const char *name, int argc, char** argv);
void GetOptionAll(const char *name, int argc, char** argv, std::list<char *> *results);
bool GetBinaryOption(const char *name, int argc, char** argv, bool default_value);
DWORD FindProcessId(char * process_name);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
DWORD FindProcessId(char * process_name);
#endif
int GetIntOption(const char *name, int argc, char** argv, int default_value);

char *ArgvToCmd(int argc, char** argv);
Expand Down
Loading