summaryrefslogtreecommitdiffstats
path: root/third_party/npapi
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 21:36:53 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 21:36:53 +0000
commit1d1c3263f9e360765b49c33f6e232e98ecc49338 (patch)
treee6db2e226a167ab55926b85f88b9f948dd185c26 /third_party/npapi
parent9e3d8b9ab8f5d4da09f2894866d369aba0f0d005 (diff)
downloadchromium_src-1d1c3263f9e360765b49c33f6e232e98ecc49338.zip
chromium_src-1d1c3263f9e360765b49c33f6e232e98ecc49338.tar.gz
chromium_src-1d1c3263f9e360765b49c33f6e232e98ecc49338.tar.bz2
make npspy look for flash binaries
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/npapi')
-rw-r--r--third_party/npapi/npspy/common/plugload.cpp126
1 files changed, 68 insertions, 58 deletions
diff --git a/third_party/npapi/npspy/common/plugload.cpp b/third_party/npapi/npspy/common/plugload.cpp
index 1bb9ecd..da6ae66 100644
--- a/third_party/npapi/npspy/common/plugload.cpp
+++ b/third_party/npapi/npspy/common/plugload.cpp
@@ -35,6 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
+#include <vector>
+
#include "xp.h"
#include "logger.h"
@@ -101,80 +103,88 @@ XP_HLIB LoadRealPlugin(char * mimetype)
}
strcpy(szFileName, szPath);
- strcat(szFileName, "\\*");
-
- HANDLE handle = FindFirstFile(szFileName, &ffdataStruct);
- if(handle == INVALID_HANDLE_VALUE)
- {
- FindClose(handle);
- return NULL;
- }
- DWORD versize = 0L;
- DWORD zero = 0L;
- char * verbuf = NULL;
-
- do
- {
- strcpy(szFileName, szPath);
- strcat(szFileName, "\\");
- strcat(szFileName, ffdataStruct.cFileName);
- if(!(ffdataStruct. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- strstr(szFileName, "npspy.dll") == NULL)
- {
- versize = GetFileVersionInfoSize(szFileName, &zero);
- if (versize > 0)
- verbuf = new char[versize];
- else
- continue;
+ std::vector<std::string> directories;
- if(!verbuf)
- continue;
+ directories.push_back(szFileName);
+ directories.push_back("C:\\Windows\\System32\\Macromed\\Flash");
- GetFileVersionInfo(szFileName, NULL, versize, verbuf);
+ for (size_t i = 0; i < directories.size(); ++i) {
+ std::string search_path = directories[i];
+ search_path = search_path.append("\\np*.dll");
+ HANDLE handle = FindFirstFile(search_path.c_str(), &ffdataStruct);
+ if(handle == INVALID_HANDLE_VALUE)
+ {
+ FindClose(handle);
+ return NULL;
+ }
- char *mimetypes = NULL;
- UINT len = 0;
+ DWORD versize = 0L;
+ DWORD zero = 0L;
+ char * verbuf = NULL;
- if(!VerQueryValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType", (void **)&mimetypes, &len)
- || !mimetypes || !len)
+ do
+ {
+ std::string cur_file = directories[i];
+ cur_file = cur_file.append("\\");
+ cur_file = cur_file.append(ffdataStruct.cFileName);
+ if(!(ffdataStruct. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
+ strstr(cur_file.c_str(), "npspy.dll") == NULL)
{
- delete [] verbuf;
- continue;
- }
+ versize = GetFileVersionInfoSize(cur_file.c_str(), &zero);
+ if (versize > 0)
+ verbuf = new char[versize];
+ else
+ continue;
- // browse through a string of mimetypes
- mimetypes[len] = '\0';
- char * type = mimetypes;
+ if(!verbuf)
+ continue;
- BOOL more = TRUE;
- while(more)
- {
- char * p = strchr(type, '|');
- if(p)
- *p = '\0';
- else
- more = FALSE;
+ GetFileVersionInfo(cur_file.c_str(), NULL, versize, verbuf);
+
+ char *mimetypes = NULL;
+ UINT len = 0;
- if(0 == _stricmp(mimetype, type))
+ if(!VerQueryValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType", (void **)&mimetypes, &len)
+ || !mimetypes || !len)
{
- // this is it!
delete [] verbuf;
- FindClose(handle);
- HINSTANCE hLib = LoadLibrary(szFileName);
- return hLib;
+ continue;
}
- type = p;
- type++;
- }
+ // browse through a string of mimetypes
+ mimetypes[len] = '\0';
+ char * type = mimetypes;
- delete [] verbuf;
- }
+ BOOL more = TRUE;
+ while(more)
+ {
+ char * p = strchr(type, '|');
+ if(p)
+ *p = '\0';
+ else
+ more = FALSE;
+
+ if(0 == _stricmp(mimetype, type))
+ {
+ // this is it!
+ delete [] verbuf;
+ FindClose(handle);
+ HINSTANCE hLib = LoadLibrary(cur_file.c_str());
+ return hLib;
+ }
+
+ type = p;
+ type++;
+ }
- } while(FindNextFile(handle, &ffdataStruct));
+ delete [] verbuf;
+ }
+
+ } while(FindNextFile(handle, &ffdataStruct));
- FindClose(handle);
+ FindClose(handle);
+ }
#endif