MCPcopy Create free account
hub / github.com/ConEmu/ConEmu / GetModulePathName

Function GetModulePathName

src/common/WObjects.cpp:532–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530}
531
532DWORD GetModulePathName(HMODULE hModule, CEStr& lsPathName)
533{
534 DWORD cchMax = MAX_PATH;
535 wchar_t* pszData = lsPathName.GetBuffer(cchMax);
536 if (!pszData)
537 return 0; // Memory allocation error
538
539 DWORD nRc = GetModuleFileName(hModule, pszData, cchMax);
540 if (!nRc)
541 return 0;
542
543 const DWORD errCode = GetLastError();
544
545 // Not enough space?
546 if (nRc == cchMax || errCode == ERROR_INSUFFICIENT_BUFFER)
547 {
548 cchMax = MAX_WIDE_PATH_LENGTH;
549 pszData = lsPathName.GetBuffer(cchMax);
550 if (!pszData)
551 return 0; // Memory allocation error
552 nRc = GetModuleFileName(hModule, pszData, cchMax);
553 if (!nRc || (nRc == cchMax))
554 return 0;
555 }
556
557 return nRc;
558}
559
560#ifndef __GNUC__
561extern "C" IMAGE_DOS_HEADER __ImageBase;

Callers 9

ShowInjectsMsgBoxFunction · 0.85
RunLineFeedTestParentFunction · 0.85
RunXTermTestParentFunction · 0.85
TESTFunction · 0.85
InitConEmuPathVarsFunction · 0.85
FileExistsSearchFunction · 0.85
GetCurrentModulePathNameFunction · 0.85
FindForksMethod · 0.85

Calls 1

GetBufferMethod · 0.80

Tested by 4

RunLineFeedTestParentFunction · 0.68
RunXTermTestParentFunction · 0.68
TESTFunction · 0.68
InitConEmuPathVarsFunction · 0.68