本文整理汇总了C++中GetModuleBaseName函数的典型用法代码示例。如果您正苦于以下问题:C++ GetModuleBaseName函数的具体用法?C++ GetModuleBaseName怎么用?C++ GetModuleBaseName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetModuleBaseName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ret
HMODULE ChildProcessManager::GetChildProcessMainModule() const
{
HMODULE ret(NULL);
if (IsChildProcessCreated())
{
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE,
m_piProcInfo->dwProcessId
);
if (hProcess != INVALID_HANDLE_VALUE)
{
char lpBaseName[MAX_PATH];
CProcessModuleIterator pmi(m_piProcInfo->dwProcessId);
for (HMODULE hModule = pmi.First(); hModule; hModule = pmi.Next())
{
if (GetModuleBaseName(hProcess, hModule, lpBaseName, MAX_PATH))
{
std::string moduleName(lpBaseName);
if (moduleName.find(".exe") != std::string::npos)
{
ret = hModule;
break;
}
}
}
CloseHandle(hProcess);
}
}
return ret;
}
开发者ID:kbac70,项目名称:bridge-for-skype-extras,代码行数:35,代码来源:ChildProcessManager.cpp
示例2: GetProcessID
ULONG GetProcessID(LPCSTR TargetProcessName)
{
DWORD nSize = MAX_PATH;
HANDLE hCurrentProcess;
CHAR BaseName[MAX_PATH];
DWORD aProcesses[1024], cbNeeded;
unsigned int i;
if (!EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded))
return FALSE;
// NumberProcesses = nSize = cbNeeded / sizeof(DWORD);
for (i = 0; i <= nSize; i++)
{
if(NULL != (hCurrentProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, aProcesses[i])))
{
GetModuleBaseName(hCurrentProcess, NULL, BaseName, sizeof(BaseName));
if(0 == stricmp(BaseName, TargetProcessName))
{
CloseHandle(hCurrentProcess);
return aProcesses[i];
}
}
CloseHandle(hCurrentProcess);
}
return FALSE;
}
开发者ID:Artorios,项目名称:rootkit.com,代码行数:33,代码来源:ShadowTableHook_Control.cpp
示例3: getModuleBase
DWORD getModuleBase(const std::string& sModuleName, HANDLE hProc)
{
HMODULE *hModules = nullptr;
char buffer[64];
DWORD modules_size;
DWORD result = -1;
if (!EnumProcessModules(hProc, hModules, 0, &modules_size))
{
std::cout << "Error: EnumProcessModules failed: " << GetLastError() << std::endl;
return 0;
}
hModules = new HMODULE[modules_size / sizeof(HMODULE)];
if (EnumProcessModules(hProc, hModules, modules_size / sizeof(HMODULE), &modules_size))
{
for (unsigned int i = 0; i < modules_size / sizeof(HMODULE); i++)
{
if (GetModuleBaseName(hProc, hModules[i], buffer, sizeof(buffer)))
{
if (strcmp(sModuleName.c_str(), buffer) == 0)
{
result = (DWORD)hModules[i];
break;
}
}
}
}
delete[] hModules;
return result;
}
开发者ID:drupalhunter-team,项目名称:CheatFramework,代码行数:33,代码来源:Cheats.cpp
示例4: PrintProcessNameAndID
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
else return;
}
else return;
// Print the process name and identifier.
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
开发者ID:kannanbalu,项目名称:vTaskManager,代码行数:33,代码来源:test.cpp
示例5: printProcessInfo
void printProcessInfo(DWORD processID)
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if (NULL != hProcess) {
HMODULE hMod; // An array that receives the list of module handles.
DWORD cbNeeded; //The number of bytes required to store all module handles in the Module array
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
GetModuleBaseName(hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR));
}
}
// Print the process name and identifier of matching strings, ignoring case
_tprintf(TEXT("%s (PID: %u)\n"), szProcessName, processID);
// Release the handle to the process.
CloseHandle( hProcess );
}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:26,代码来源:main.cpp
示例6: GetProcessId
int GetProcessId(const char* file_name)
{
const int maximum_processes = 1024;
LPDWORD process_ids;
LPTSTR base_name;
HANDLE process;
DWORD i, processes, process_id = 0;
process_ids = (LPDWORD)HeapAlloc(GetProcessHeap(), 0, maximum_processes * sizeof(DWORD));
if(process_ids != NULL) {
if(EnumProcesses(process_ids, maximum_processes * sizeof(DWORD), &processes)) {
base_name = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(TCHAR));
if(base_name != NULL) {
processes = processes / sizeof(DWORD);
for(i = 0; i < processes; i++) {
process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_ids[i]);
if(process != NULL) {
if(GetModuleBaseName(process, NULL, base_name, MAX_PATH) > 0) {
if(!lstrcmpi(base_name, file_name)) {
process_id = process_ids[i];
CloseHandle(process);
break;
}
}
CloseHandle(process);
}
}
HeapFree(GetProcessHeap(), 0, (LPVOID)base_name);
}
}
HeapFree(GetProcessHeap(), 0, (LPVOID)process_ids);
}
return process_id;
}
开发者ID:CoolOppo,项目名称:dllinjector,代码行数:35,代码来源:dllinject.cpp
示例7: startDaemonScan
void startDaemonScan()
{
PVOID buffer = VirtualAlloc(NULL, 1024 * 1024, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
while (1)
{
DWORD procIDsBuffer[MAX_PROCESSES];
DWORD size_returned;
EnumProcesses(procIDsBuffer, sizeof(procIDsBuffer), &size_returned);
int numProc = size_returned / sizeof(DWORD);
int i;
TCHAR strBuffer[MAX_PATH];
for (i = 0; i < numProc; i++)
{
DWORD curr_pid = (int)procIDsBuffer[i];
HANDLE Handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, TRUE, curr_pid);
GetModuleBaseName(Handle, NULL, strBuffer, MAX_PATH);
if ((Handle) && isInFrobProcList(strBuffer))
reactToProcess(curr_pid, strBuffer);
CloseHandle(Handle);
}
updateList();
}
}
开发者ID:LucaBongiorni,项目名称:ProcessHider,代码行数:25,代码来源:Daemon.cpp
示例8: kill_process
void kill_process(string name)
{
#ifdef _WIN32
CHAR szProcBuff[101];
DWORD pIDs[300], dwBytesReturned;
HANDLE hProcess;
INT i, procCount;
EnumProcesses(pIDs, sizeof(pIDs), &dwBytesReturned);
procCount = dwBytesReturned / sizeof(DWORD);
for (i = 0; i < procCount; i++)
if (pIDs[i] != 0)
{
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, 0, pIDs[i]);
GetModuleBaseName(hProcess, 0, szProcBuff, 100);
if (strcmp(szProcBuff, name.c_str()) == 0)
TerminateProcess(hProcess, EXIT_SUCCESS);
CloseHandle(hProcess);
}
#elif __APPLE__
string command = "killall -kill " + name;
system(command.c_str());
#endif
while (process_running(name.c_str()) > 0)
Sleep(1);
}
开发者ID:roijo,项目名称:touch_plus_source_code,代码行数:31,代码来源:processes.cpp
示例9: MatcProcessImageName
bool MatcProcessImageName(DWORD dwProcId,const TCHAR* tcImageName, bool bTestRunning=false)
{
if(NULL == tcImageName) return false;
HANDLE hProc = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcId );
bool bHasName= false;
bool bResult = false;
TCHAR tcModuleName[MAX_PATH];
if (NULL != hProc ) {
if(bTestRunning) {
DWORD ExitCode = 0;
if(GetExitCodeProcess(hProc, &ExitCode)) {
if (STILL_ACTIVE != ExitCode) return false;
} else {
if(WAIT_TIMEOUT != WaitForSingleObject(hProc, 0)) return false;
}
}
HMODULE hMod;
DWORD nRetCountMod = 0;
if(EnumProcessModules(hProc, &hMod, sizeof(hMod), &nRetCountMod)){
bHasName = (0 != GetModuleBaseName( hProc, hMod, tcModuleName, sizeof(tcModuleName)/sizeof(TCHAR) ) );
} else {
bHasName = (0 != GetProcessImageFileName(hProc, tcModuleName, sizeof(tcModuleName)/sizeof(TCHAR)) ) ;
}
}
if(bHasName) {
const TCHAR *pExeName = _tcsrchr(tcModuleName, TEXT('\\'));
pExeName = (pExeName) ? ++pExeName : tcModuleName;
bResult = (0 == StrCmpI(pExeName,tcImageName));
}
CloseHandle(hProc);
return bResult;
}
开发者ID:Kerogi,项目名称:swas,代码行数:32,代码来源:swas.cpp
示例10: sizeof
bool CallStack::loadAllModules()
{
#ifdef WIN32
DWORD dwNeeded = 0;
if (!EnumProcessModules(hProcess, hModule, sizeof(hModule), &dwNeeded)) return false;
const int iCount = dwNeeded / sizeof(HMODULE);
for (int i = 0; i < iCount; ++i)
{
MODULEINFO info;
GetModuleInformation(hProcess, hModule[i], &info, sizeof(info));
GetModuleFileNameEx(hProcess, hModule[i], szImageName, iMax);
GetModuleBaseName(hProcess, hModule[i], szModuleName, iMax);
#ifdef X64
SymLoadModule64(hProcess, hModule[i], szImageName, szModuleName, (DWORD64)info.lpBaseOfDll, info.SizeOfImage);
#else
SymLoadModule(hProcess, hModule[i], szImageName, szModuleName, (DWORD)info.lpBaseOfDll, info.SizeOfImage);
#endif
}
#endif
return true;
}
开发者ID:lwch,项目名称:QLanguage,代码行数:25,代码来源:callstack.cpp
示例11: process_name
NSHARE::CText process_name(int processID)
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
// Get a handle to the process.
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE, processID);
// Get the process name.
if (INVALID_HANDLE_VALUE != hProcess)
{
HMODULE hMod;
DWORD cbNeeded;
//Given a handle to a process, this returns all the modules running within the process.
//The first module is the executable running the process,
//and subsequent handles describe DLLs loaded into the process.
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
{
//This function returns the short name for a module,
//typically the file name portion of the EXE or DLL
GetModuleBaseName(hProcess, hMod, szProcessName,
sizeof(szProcessName) / sizeof(TCHAR));
}
}
NSHARE::CText _text(szProcessName);
//close the process handle
CloseHandle(hProcess);
return _text;
}
开发者ID:CrazyLauren,项目名称:UDT,代码行数:30,代码来源:tasks.cpp
示例12: PrintProcessNameAndID
void PrintProcessNameAndID( DWORD processID )
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
TCHAR szFilename[MAX_PATH] = TEXT("<unknown>");
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID);
if (hProcess != NULL)
{
HMODULE hModule;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hModule, sizeof(hModule), &cbNeeded) )
{
GetModuleBaseName( hProcess, hModule, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
GetModuleFileNameEx( hProcess, hModule, szFilename, sizeof(szFilename)/sizeof(TCHAR) );
}
CloseHandle( hProcess );
}
_tprintf( TEXT(" %16s %-60s (PID: %u)\n"), szProcessName, szFilename, processID );
}
开发者ID:Grumbel,项目名称:processwatch,代码行数:25,代码来源:processwatch.cpp
示例13: EnumProcesses
BOOL CSelectProcessDlg::OnInitDialog(void)
{
CDialog::OnInitDialog();
// initialization
DWORD cbNeeded;
EnumProcesses(procs, sizeof(procs), &cbNeeded);
numprocs = cbNeeded / sizeof(DWORD);
HANDLE hProcess;
HMODULE hMod;
wchar_t str[255];
for (int i = 0; i < numprocs; i++)
{
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, procs[i]);
if (hProcess)
{
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
{
GetModuleBaseName(hProcess, hMod, str, 255);
m_cmbProcesses.AddString(str);
m_cmbProcesses.SetItemDataPtr(m_cmbProcesses.GetCount() - 1, (void*)&procs[i]);
}
CloseHandle(hProcess);
}
}
return TRUE;
}
开发者ID:silvansky,项目名称:MemoryWatcher,代码行数:26,代码来源:SelectProcessDlg.cpp
示例14: TEXT
void ProcessFinder::PrintProcessNameAndID( DWORD processID )
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR) );
}
}
// Print the process name and identifier.
std::map<std::string,int>::iterator it = processes.find(szProcessName);
if(it!=processes.end())
{
(*it).second++;
}
else
{
std::pair<std::string,int> elem;
elem.first = szProcessName;
elem.second = 1;
processes.insert(elem);
}
CloseHandle( hProcess );
}
开发者ID:ayelkawar2,项目名称:HTML5basedCrossPlatformSniffer,代码行数:35,代码来源:ProcessFinder.cpp
示例15: GetDestinationFileName
std::wstring GetDestinationFileName()
{
std::wstring baseName;
//get from file name of this executable
{
std::wstring moduleBaseName = GetModuleBaseName();
std::wstring moduleBaseNameLower = moduleBaseName;
for(int n = 0; n < (int)moduleBaseNameLower.length(); n++)
moduleBaseNameLower[n] = tolower(moduleBaseNameLower[n]);
int index = (int)moduleBaseNameLower.find(_T("_mono"));
if(index == -1)
{
MessageBox(0, _T("Invalid executable file name.\n\nDemands file name in format \"{destination base file name}_mono[any characters].exe\"."),
_T("Mono launcher error"),
MB_OK | MB_ICONEXCLAMATION);
return _T("");
}
baseName = moduleBaseName.substr(0, index);
}
return baseName + _T(".exe");
//return GetModuleFullDirectory() + _T("\\") + baseName + _T(".exe");
}
开发者ID:DarrenHassan,项目名称:GDM4242-GroupD,代码行数:27,代码来源:MonoRuntimeLauncher.cpp
示例16: test_exist_process
// Determine le nombre de processus du nom de "monProcess" en cours d'éxécution
int test_exist_process(const char* monProcess)
{
int nombreTrouves = 0;
DWORD processes[MAX_TAB], nb_processes;
char process_name[MAX_TAB];
int i;
HANDLE hprocess;
EnumProcesses(processes, sizeof(processes), &nb_processes);
//On teste tous les processus pour voir si leur nom correspond
for(i = 0 ; i < nb_processes / sizeof(DWORD) ; i++)
{
hprocess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processes[i]);
//Prend le nom du processus et le met dans process_name
GetModuleBaseName(hprocess, NULL, process_name, sizeof(process_name));
CloseHandle(hprocess);
if(strcmp(process_name, monProcess) == 0)
{
nombreTrouves++;
}
}
return nombreTrouves;
}
开发者ID:CokieForever,项目名称:XCopy,代码行数:26,代码来源:fonctions_process.c
示例17: IsExeRunning
bool IsExeRunning(char* pName)
{
unsigned long aProcesses[1024], cbNeeded, cProcesses;
if(!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
return false;
unsigned long curPID = GetCurrentProcessId();
cProcesses = cbNeeded / sizeof(unsigned long);
for (unsigned int i = 0; i < cProcesses; i++)
{
if(aProcesses[i] == 0)
continue;
if (aProcesses[i] == curPID)
continue;
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]);
if (!hProcess)
continue;
char buffer[50] = {0};
GetModuleBaseName(hProcess, 0, buffer, 50);
CloseHandle(hProcess);
if(strcmp(pName, buffer)==0)
return true;
}
return false;
}
开发者ID:matthiaskrgr,项目名称:Desurium,代码行数:32,代码来源:UtilBootloader.cpp
示例18: ScanModules
bool ScanModules (DWORD processID) {
HMODULE hMods[1024];
HANDLE hProcess;
DWORD cbNeeded;
// Get a list of all the modules in this process.
hProcess=OpenProcess(
PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID
);
if (NULL==hProcess) return 0;
if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
for (unsigned int i=0; i<cbNeeded/sizeof(HMODULE) && i<1024; i++) {
TCHAR szModName[MAX_PATH];
if (GetModuleBaseName(
hProcess, hMods[i], szModName, sizeof(szModName)/sizeof(TCHAR)
)) {
if (0==_wcsicmp(szModName, _T("npswf32.dll")) ||
0==_wcsicmp(szModName, _T("flash9c.ocx"))
) {
CloseHandle(hProcess);
return 1;
}
}
}
}
CloseHandle(hProcess);
return 0;
}
开发者ID:johan,项目名称:svn.arantius.com,代码行数:31,代码来源:flash.cpp
示例19: GetModules
BOOL GetModules(HANDLE hProcess, char* Strings)
{
DWORD processid[1024], needed, processcount, modulecount;
HMODULE hModule[1024];
DWORD cb = 0;
BOOL ret = 1;
char path[MAX_PATH] = "", temp[MAX_PATH], basename[MAX_PATH];
EnumProcesses(processid, sizeof(processid), &needed);
processcount = 1;// needed/sizeof(DWORD);
for (DWORD i = 0; i< processcount; i++) // 列举一下explorer下的模块
{
if (hProcess)
{
EnumProcessModules(hProcess, hModule, sizeof(hModule), &needed);
modulecount = needed / sizeof(DWORD);
//_itoa(processid[i], temp, 10);
for (DWORD j = 0; j < modulecount; j++)
{
GetModuleFileNameEx(hProcess, hModule[j], path, sizeof(path));
GetModuleBaseName(hProcess, hModule[j], basename, sizeof(basename));
GetShortPathName(path, path, 256);
if(!strcmp(basename, Strings))
{
ret = 1;
}
printf("%s\t\t%s\n", basename, path);
}
}
}
return ret;
}
开发者ID:zephyrer,项目名称:ab-mfc,代码行数:35,代码来源:Taskmgr.cpp
示例20: TEXT
//lookup process name of process with processID
//compare to processName
int Application_InternetExplorer::compareName(DWORD processID, std::wstring processName)
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR) );
}
CloseHandle( hProcess );
}
//_tprintf( TEXT("%s (PID: %u)\n"), szProcessName, processID );
int comparison;
comparison = wcsicmp(szProcessName, processName.c_str());
return comparison;
}
开发者ID:340211173,项目名称:capture-hpc,代码行数:35,代码来源:Application_InternetExplorer.cpp
注:本文中的GetModuleBaseName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论