// skip the fucking head "顶"
// ""
Find Function In Exports
/* 0*/ #include <tchar.h>
/* 1*/ #include <windows.h>
/* 2*/ #include <string>
/* 3*/ #include <vector>
/* 4*/ #include <iostream>
/* 5*/ #include <fstream>
/* 6*/
/* 7*/
/* 8*/ template<typename F>
/* 9*/ void IterDirectory(F& f)
/*10*/ {
/*11*/ WIN32_FIND_DATA findData;
/*12*/ HANDLE handle = FindFirstFile(f.mDirectory.c_str(), &findData);
/*13*/ if (handle != INVALID_HANDLE_VALUE) {
/*14*/ do {
/*15*/ f(findData.cFileName);
/*16*/ } while (FindNextFile(handle, &findData) != 0);
/*17*/ }
/*18*/
/*19*/ DWORD dwError = GetLastError();
/*20*/ if (dwError != ERROR_NO_MORE_FILES)
/*21*/ std::wcout << std::wstring(L"FindNextFile error: ").c_str() << dwError << std::endl;
/*22*/ FindClose(handle);
/*23*/ }
/*24*/
/*25*/ class Find
/*26*/ {
/*27*/ public:
/*28*/ Find(const wchar_t* directory, const wchar_t* matchString)
/*29*/ : mDirectory(directory)
/*30*/ , mMatchString(matchString)
/*31*/ , mSpace(70, L' ')
/*32*/ {}
/*33*/
/*34*/ void operator()(const wchar_t* name)
/*35*/ {
/*36*/ std::wcout << L'/r' << mSpace << L'/r' << name;
/*37*/ if (dumpToFile(name))
/*38*/ findInFile(name);
/*39*/ std::wcout << L'/r' << mSpace;
/*40*/ }
/*41*/
/*42*/ std::wstring mDirectory;
/*43*/
/*44*/ private:
/*45*/ bool dumpToFile(const wchar_t* name)
/*46*/ {
/*47*/ std::wstring fileName(name);
/*48*/
/*49*/ if (fileName.size() < 4)
/*50*/ return false;
/*51*/ std::wstring type = fileName.substr(fileName.size() - 4);
/*52*/ if (type != L".lib" && type != L".dll" && type != L".arx" && type != L".dbx" && type != L".exe")
/*53*/ return false;
/*54*/
/*55*/ STARTUPINFO si;
/*56*/ PROCESS_INFORMATION pi;
/*57*/
/*58*/ ZeroMemory( &si, sizeof(si) );
/*59*/ si.cb = sizeof(si);
/*60*/ ZeroMemory( &pi, sizeof(pi) );
/*61*/
/*62*/ std::wstring command = L"dumpbin.exe -EXPORTS /"" + mDirectory + fileName + L"/" /OUT:C://a.txt";
/*63*/
/*64*/ if(!CreateProcess(NULL, (wchar_t*)command.c_str(), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
/*65*/ std::wcout << L"CreateProcess failed " << GetLastError() << std::endl;
/*66*/ return false;
/*67*/ }
/*68*/
/*69*/ WaitForSingleObject( pi.hProcess, INFINITE );
/*70*/ CloseHandle( pi.hProcess );
/*71*/ CloseHandle( pi.hThread );
/*72*/ return true;
/*73*/ }
/*74*/
/*75*/ bool findInFile(const wchar_t* name)
/*76*/ {
/*77*/ std::wifstream input(L"c://a.txt");
/*78*/ std::wstring world;
/*79*/ while (input >> world) {
/*80*/ if(world.find(mMatchString) != std::wstring::npos) {
/*81*/ std::wcout << L'/r' << mSpace << L'/r' << name
/*82*/ << L'/t' << world << std::endl;
/*83*/ return true;
/*84*/ }
/*85*/ }
/*86*/ return false;
/*87*/ }
/*88*/
/*89*/ std::wstring mMatchString;
/*90*/ std::wstring mSpace;
/*91*/ };
/*92*/
/*93*/ int _tmain(int argc, _TCHAR* argv[])
/*94*/ {
/*95*/ wchar_t envVar[512];
/*96*/ if (argc > 1 && GetEnvironmentVariable(L"FF_PATH", envVar, 512) < 512)
/*97*/ IterDirectory(Find(envVar, argv[1]));
/*98*/ return 0;
/*99*/ }
Add Line Number
/* 0*/ #include <tchar.h>
/* 1*/ #include <fstream>
/* 2*/
/* 3*/ int main()
/* 4*/ {
/* 5*/ std::wifstream ifstream("source.cpp");
/* 6*/ std::wofstream ofstream("addLineNumber.cpp");
/* 7*/ std::wifstream::char_type line[1024];
/* 8*/ int i = 0;
/* 9*/ while (ifstream.getline(line, 1024)) {
/*10*/ ofstream << _T("/*");
/*11*/ ofstream.width(2);
/*12*/ ofstream << i++ << _T("*/ ") << line << _T('/n');
/*13*/ }
/*14*/ }