我在64位Windows安裝Mozilla FireFox x64
加載32位的DLL,現在我想LoadLibrary(mozglue.dll)
,但我收到錯誤號193如何在64位Windows
LoadLibrary(mozglue.dll)
做工不錯的32位Windows與Mozilla FireFox 86
我使用此代碼:
#include <Windows.h>
#include <strsafe.h>
int main()
{
HMODULE hndl;
DWORD dwError = 0;
WCHAR errorBuff[MAX_PATH] = {};
hndl = LoadLibraryW(L"C:\\Program Files\\Mozilla Firefox\\mozglue.dll");
dwError = GetLastError();
StringCbPrintfW(errorBuff, MAX_PATH, L"%d", dwError);
MessageBoxW(NULL, errorBuff, L"GetLastError", MB_OK);
FreeLibrary(hndl);
return 0;
}
這段代碼有什麼問題?
編輯:
我使用:的
LoadLibraryExW(L"C:\\Program Files\\Mozilla Firefox\\mozglue.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
代替:
LoadLibraryW(L"C:\\Program Files\\Mozilla Firefox\\mozglue.dll");
現在GetLastError
返回0,但GetProcAddress
失敗...
#include <Windows.h>
#include <strsafe.h>
typedef enum SECItemType {
siBuffer = 0,
siClearDataBuffer = 1,
siCipherDataBuffer,
siDERCertBuffer,
siEncodedCertBuffer,
siDERNameBuffer,
siEncodedNameBuffer,
siAsciiNameString,
siAsciiString,
siDEROID,
siUnsignedInteger,
siUTCTime,
siGeneralizedTime
};
struct SECItem {
SECItemType type;
unsigned char *data;
size_t len;
};
typedef enum SECStatus {
SECWouldBlock = -2,
SECFailure = -1,
SECSuccess = 0
};
typedef struct PK11SlotInfoStr PK11SlotInfo;
typedef SECStatus(*NSS_Init) (const char *);
typedef SECStatus(*NSS_Shutdown) (void);
typedef PK11SlotInfo * (*PK11_GetInternalKeySlot) (void);
typedef void(*PK11_FreeSlot) (PK11SlotInfo *);
typedef SECStatus(*PK11_Authenticate) (PK11SlotInfo *, int, void *);
typedef SECStatus(*PK11SDR_Decrypt) (SECItem *, SECItem *, void *);
PK11_GetInternalKeySlot PK11GetInternalKeySlot;
PK11_FreeSlot PK11FreeSlot;
PK11_Authenticate PK11Authenticate;
PK11SDR_Decrypt PK11SDRDecrypt;
NSS_Init fpNSS_INIT;
NSS_Shutdown fpNSS_Shutdown;
BOOL loadFunc()
{
HMODULE hndl;
DWORD dwError = 0;
WCHAR errorBuff[MAX_PATH] = {};
BOOL retVal = FALSE;
hndl = LoadLibraryExW(L"C:\\Program Files\\Mozilla Firefox\\mozglue.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
dwError = GetLastError();
StringCbPrintfW(errorBuff, MAX_PATH, L"%d", dwError);
MessageBoxW(NULL, errorBuff, L"GetLastError", MB_OK);
hndl = LoadLibraryExW(L"C:\\Program Files\\Mozilla Firefox\\nss3.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
dwError = GetLastError();
StringCbPrintfW(errorBuff, MAX_PATH, L"%d", dwError);
MessageBoxW(NULL, errorBuff, L"GetLastError", MB_OK);
if (hndl)
{
fpNSS_INIT = (NSS_Init)GetProcAddress(hndl, "NSS_Init");
fpNSS_Shutdown = (NSS_Shutdown)GetProcAddress(hndl, "NSS_Shutdown");
PK11GetInternalKeySlot = (PK11_GetInternalKeySlot)GetProcAddress(hndl, "PK11_GetInternalKeySlot");
PK11FreeSlot = (PK11_FreeSlot)GetProcAddress(hndl, "PK11_FreeSlot");
PK11Authenticate = (PK11_Authenticate)GetProcAddress(hndl, "PK11_Authenticate");
PK11SDRDecrypt = (PK11SDR_Decrypt)GetProcAddress(hndl, "PK11SDR_Decrypt");
}
return !(!fpNSS_INIT || !fpNSS_Shutdown || !PK11GetInternalKeySlot || !PK11Authenticate || !PK11SDRDecrypt || !PK11FreeSlot);
}
int main()
{
if (loadFunc())
{
MessageBoxW(NULL, L"OK", L"", MB_OK);
}
else
{
MessageBoxW(NULL, L"NO", L"", MB_OK);
}
return 0;
}
你是如何編譯你的代碼的?你編譯過64位嗎?你在這裏安裝的mozglue最有可能是64位的Firefox,如果你的可執行文件是32位的,它不能加載它。 –
您可以在64位Windows上將32位DLL加載到32位***進程***中,但無法將其加載到64位進程中。所以你必須安裝32位的Firefox。 –
我編譯一次32位,一次64位,但都得到錯誤193 –