[+] added: !py windbg command can work without python script file extension ".py"

git-svn-id: https://pykd.svn.codeplex.com/svn@56558 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2010-10-28 05:59:57 +00:00
parent 58953f5a81
commit 597af76fd6

View File

@ -62,7 +62,40 @@ DbgPythonPath::findPath(
std::string &fullFileName, std::string &fullFileName,
std::string &filePath ) const std::string &filePath ) const
{ {
bool result = false; bool pyExt = fileName.rfind( ".py" ) == fileName.length() - 3;
// 1. Èùåì â ðàáî÷åé äèðåêòîðèè
DWORD bufSize =
SearchPathA(
NULL,
fileName.c_str(),
pyExt ? NULL : ".py",
0,
NULL,
NULL );
if ( bufSize > 0 )
{
char *fullFileNameCStr = new char[ bufSize ];
char *partFileNameCStr = NULL;
SearchPathA(
NULL,
fileName.c_str(),
pyExt ? NULL : ".py",
bufSize,
fullFileNameCStr,
&partFileNameCStr );
fullFileName = std::string( fullFileNameCStr );
filePath = std::string( fullFileNameCStr, partFileNameCStr );
delete[] fullFileNameCStr;
return true;
}
// 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
std::vector<std::string>::const_iterator it = m_pathList.begin(); std::vector<std::string>::const_iterator it = m_pathList.begin();
@ -72,7 +105,7 @@ DbgPythonPath::findPath(
SearchPathA( SearchPathA(
(*it).c_str(), (*it).c_str(),
fileName.c_str(), fileName.c_str(),
NULL, pyExt ? NULL : ".py",
0, 0,
NULL, NULL,
NULL ); NULL );
@ -85,7 +118,7 @@ DbgPythonPath::findPath(
SearchPathA( SearchPathA(
(*it).c_str(), (*it).c_str(),
fileName.c_str(), fileName.c_str(),
NULL, pyExt ? NULL : ".py",
bufSize, bufSize,
fullFileNameCStr, fullFileNameCStr,
&partFileNameCStr ); &partFileNameCStr );
@ -95,24 +128,11 @@ DbgPythonPath::findPath(
delete[] fullFileNameCStr; delete[] fullFileNameCStr;
result = true; return true;
break;
} }
} }
return result; return false;
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// DWORD SearchPath(
// LPCTSTR lpPath,
// LPCTSTR lpFileName,
// LPCTSTR lpExtension,
// DWORD nBufferLength,
// LPTSTR lpBuffer,
// LPTSTR* lpFilePart
//);