#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>

long ProcessNameToPid(char ProcessName[])
{
	PROCESSENTRY32 uProcess;
	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	
	if(hSnapshot == INVALID_HANDLE_VALUE)
		return -1;
	
	uProcess.dwSize = sizeof(uProcess);
	
	if(!Process32First(hSnapshot, &uProcess))
		return -1;
	
	if(!strcmp(uProcess.szExeFile, ProcessName))
		return uProcess.th32ProcessID;
		
	while(Process32Next(hSnapshot, &uProcess))
	{
		if(!strcmp(uProcess.szExeFile, ProcessName))
			return uProcess.th32ProcessID;
	}
	
	return 0;
}

int main(void)
{
	long pid = ProcessNameToPid("csrss.exe");
	
	printf("[+]Csrss Pid : %x\n", pid);
	
	return 0;
}