且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NPAPI插件不会在Firefox中加载

更新时间:2022-10-20 23:30:47

这是Chris从 conedogers ,很高兴看到你发现我的博客很有用。



Georg是正确的。 Firefox不在寻找Windows语言环境。它看起来像Mozilla有自己的国际化,这是有道理的,因为他们的代码是为多个平台编写的。



这里发生了什么是BLOCK040904e4告诉二进制文件如何处理下面包含的字符串。版本信息不使用C风格结构来包含字符串。块信息用于计算字节偏移量和字符串字符类型,因此您可以提取字符串。

似乎Firefox已经为en-western构建,所以你需要做相同的事情,正如你发现的那样,Firefox将无法加载版本信息检索MIME类型和描述字符串。

MSDN文章


I'm writing an plugin and it gets into [INVALID] section in pluginreg.dat file on Windows. I think there is a problem in my npplugin.rc file.

In npplugin.def file everything is correct:

LIBRARY
EXPORTS
    NP_GetEntryPoints @1
    NP_Initialize @2
    NP_Shutdown @3

But neither NP_GetEntryPoints nor NP_Initialize is called.

To install plugin I put it into %APPDATA%/Mozilla/plugins directory.

Here is npplugin.rc code:

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

#if 0
/////////////////////////////////////////////////////////////////////////////
// Russian (Russia) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED

#endif    // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
#endif

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 4,5
 PRODUCTVERSION 4,5
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "CompanyName", "MyCompany Ltd."
            VALUE "FileExtents", "myext"
            VALUE "FileOpenName", "My File"
            VALUE "FileDescription", "NPPlugin for me"
            VALUE "FileVersion", "4.5"
            VALUE "InternalName", "npMyPlugin"
            VALUE "Language", "English (United States)"
            VALUE "LegalCopyright", "Copyright (C) MyCompany Ltd. 2012"
            VALUE "MIMEType", "application/x-myplugin"
            VALUE "OriginalFilename", "npMyPlugin.dll"
            VALUE "ProductName", "My NPPlugin"
            VALUE "ProductVersion", "4.5"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

#endif    // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

My question is where is an error or what is missing?

This is Chris from conedogers, glad to see that you found my blog useful.

Georg is correct. Firefox is not looking for a windows locale. It looks like Mozilla has their own internationalization which makes sense because their code is written for multiple platforms.

What is happening here is the BLOCK "040904e4" tells the binary how to process the strings contained below. Version information does not use C style struct to contain the strings. the block information is used to calculate the byte offsets and string characters types so you can extract the strings.

It appears that Firefox has been built for en-western so you need to do the same otherwise, as you found out, Firefox will not be able to load the version info to retrieve the mime-type and description strings.

MSDN article