• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LoadLibraryW函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LoadLibraryW函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadLibraryW函数的具体用法?C++ LoadLibraryW怎么用?C++ LoadLibraryW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LoadLibraryW函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CWE114_Process_Control__w32_wchar_t_listen_socket_02_bad

void CWE114_Process_Control__w32_wchar_t_listen_socket_02_bad()
{
    wchar_t * data;
    wchar_t dataBuffer[100] = L"";
    data = dataBuffer;
    if(1)
    {
        {
#ifdef _WIN32
            WSADATA wsaData;
            int wsaDataInit = 0;
#endif
            int recvResult;
            struct sockaddr_in service;
            wchar_t *replace;
            SOCKET listenSocket = INVALID_SOCKET;
            SOCKET acceptSocket = INVALID_SOCKET;
            size_t dataLen = wcslen(data);
            do
            {
#ifdef _WIN32
                if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
                {
                    break;
                }
                wsaDataInit = 1;
#endif
                /* POTENTIAL FLAW: Read data using a listen socket */
                listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                if (listenSocket == INVALID_SOCKET)
                {
                    break;
                }
                memset(&service, 0, sizeof(service));
                service.sin_family = AF_INET;
                service.sin_addr.s_addr = INADDR_ANY;
                service.sin_port = htons(TCP_PORT);
                if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
                {
                    break;
                }
                if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR)
                {
                    break;
                }
                acceptSocket = accept(listenSocket, NULL, NULL);
                if (acceptSocket == SOCKET_ERROR)
                {
                    break;
                }
                /* Abort on error or the connection was closed */
                recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(wchar_t) * (100 - dataLen - 1), 0);
                if (recvResult == SOCKET_ERROR || recvResult == 0)
                {
                    break;
                }
                /* Append null terminator */
                data[dataLen + recvResult / sizeof(wchar_t)] = L'\0';
                /* Eliminate CRLF */
                replace = wcschr(data, L'\r');
                if (replace)
                {
                    *replace = L'\0';
                }
                replace = wcschr(data, L'\n');
                if (replace)
                {
                    *replace = L'\0';
                }
            }
            while (0);
            if (listenSocket != INVALID_SOCKET)
            {
                CLOSE_SOCKET(listenSocket);
            }
            if (acceptSocket != INVALID_SOCKET)
            {
                CLOSE_SOCKET(acceptSocket);
            }
#ifdef _WIN32
            if (wsaDataInit)
            {
                WSACleanup();
            }
#endif
        }
    }
    {
        HMODULE hModule;
        /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to
         * replace his own file with the intended library */
        hModule = LoadLibraryW(data);
        if (hModule != NULL)
        {
            FreeLibrary(hModule);
            printLine("Library loaded and freed successfully");
        }
        else
        {
            printLine("Unable to load library");
//.........这里部分代码省略.........
开发者ID:gpwi970725,项目名称:testJuliet1,代码行数:101,代码来源:CWE114_Process_Control__w32_wchar_t_listen_socket_02.c


示例2: Init

	bool Init(struct CET_Init* pInit)
	{
		bool result = false;
		nErrNumber = 0;
		//pszPluginKey = pInit->pRegKey;
		//ReloadConfig();
		HRESULT hrCoInitialized = CoInitialize(NULL);
		bCoInitialized = SUCCEEDED(hrCoInitialized);
		wchar_t FullPath[MAX_PATH*2+15]; FullPath[0] = 0;
		//if (ghModule)
		//{
		//	PVDSettings::FindFile(L"GdiPlus.dll", FullPath, sizeofarray(FullPath));
		//	hGDIPlus = LoadLibraryW(FullPath);
		//}
		//if (!hGDIPlus)
		hGDIPlus = LoadLibraryW(L"GdiPlus.dll");

		if (!hGDIPlus)
		{
			nErrNumber = PGE_DLL_NOT_FOUND;
		}
		else
		{
			DllGetFunction(hGDIPlus, GdiplusStartup);
			DllGetFunction(hGDIPlus, GdiplusShutdown);
			DllGetFunction(hGDIPlus, GdipCreateBitmapFromFile);
			DllGetFunction(hGDIPlus, GdipGetImageThumbnail);
			//DllGetFunction(hGDIPlus, GdipCreateBitmapFromFileICM);
			//DllGetFunction(hGDIPlus, GdipCreateBitmapFromStream);
			//DllGetFunction(hGDIPlus, GdipCreateBitmapFromStreamICM);
			DllGetFunction(hGDIPlus, GdipGetImageWidth);
			DllGetFunction(hGDIPlus, GdipGetImageHeight);
			DllGetFunction(hGDIPlus, GdipGetImagePixelFormat);
			//DllGetFunction(hGDIPlus, GdipBitmapLockBits);
			//DllGetFunction(hGDIPlus, GdipBitmapUnlockBits);
			DllGetFunction(hGDIPlus, GdipDisposeImage);
			DllGetFunction(hGDIPlus, GdipImageGetFrameCount);
			DllGetFunction(hGDIPlus, GdipImageSelectActiveFrame);
			DllGetFunction(hGDIPlus, GdipGetPropertyItemSize);
			DllGetFunction(hGDIPlus, GdipGetPropertyItem);
			DllGetFunction(hGDIPlus, GdipImageRotateFlip);
			DllGetFunction(hGDIPlus, GdipGetImageRawFormat);
			//DllGetFunction(hGDIPlus, GdipGetImageFlags);
			//DllGetFunction(hGDIPlus, GdipGetImagePalette);
			//DllGetFunction(hGDIPlus, GdipGetImagePaletteSize);
			DllGetFunction(hGDIPlus, GdipCreateFromHDC);
			DllGetFunction(hGDIPlus, GdipDeleteGraphics);
			DllGetFunction(hGDIPlus, GdipDrawImageRectRectI);
			//DllGetFunction(hGDIPlus, GdipCreateBitmapFromScan0);
			//DllGetFunction(hGDIPlus, GdipFillRectangleI);
			//DllGetFunction(hGDIPlus, GdipCreateSolidFill);
			//DllGetFunction(hGDIPlus, GdipDeleteBrush);
			//DllGetFunction(hGDIPlus, GdipCloneBitmapAreaI);
			//DllGetFunction(hGDIPlus, GdipSetImagePalette);

			if (GdiplusStartup && GdiplusShutdown && GdipCreateBitmapFromFile && GdipGetImageThumbnail
			        && GdipGetImageWidth && GdipGetImageHeight && GdipGetImagePixelFormat && GdipGetImageRawFormat
			        //&& GdipBitmapLockBits && GdipBitmapUnlockBits
			        && GdipDisposeImage && GdipImageGetFrameCount && GdipImageSelectActiveFrame
			        && GdipGetPropertyItemSize && GdipGetPropertyItem && GdipImageRotateFlip
			        //&& GdipGetImagePalette && GdipGetImagePaletteSize && GdipCloneBitmapAreaI && GdipGetImageFlags
			        && GdipCreateFromHDC && GdipDeleteGraphics && GdipDrawImageRectRectI
			        //&& GdipCreateBitmapFromScan0 && GdipFillRectangleI && GdipCreateSolidFill && GdipDeleteBrush
			        //&& GdipSetImagePalette
			  )
			{
				Gdiplus::GdiplusStartupInput gdiplusStartupInput;
				Gdiplus::Status lRc = GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
				result = (lRc == Gdiplus::Ok);

				if (!result)
				{
					nLastError = GetLastError();
					GdiplusShutdown(gdiplusToken); bTokenInitialized = false;
					nErrNumber = PGE_ERROR_BASE + (DWORD)lRc;
				}
				else
				{
					bTokenInitialized = true;
				}
			}
			else
			{
				nErrNumber = PGE_FUNCTION_NOT_FOUND;
			}

			if (!result)
				FreeLibrary(hGDIPlus);
		}

		if (result)
		{
			pInit->pContext = this;
			pInit->nModuleID = MODULE_GDIP;
		}

		return result;
	};
开发者ID:BigVal71,项目名称:ConEmu,代码行数:98,代码来源:gdip.cpp


示例3: switch


//.........这里部分代码省略.........
				else
				{
					return false;
				}
			}
			return true;

		case WM_NCLBUTTONDBLCLK:
			{
				BOOL bCaption = FALSE;
				if((m_lWndFlag & (enum_GGWndResizeHint | enum_GGWndMaximizeButtonHint)))
				{
					QPoint absPos(LOWORD(msg->lParam), HIWORD(msg->lParam));
					QPoint pos = mapFromGlobal(absPos);
					int x = pos.x();
					int y = pos.y();
					int w = width();
					int h = height();
					if(y < TITLE_HEIGHT && x >= DEF_NOCLIENT_SIZE && x <= w - DEF_NOCLIENT_SIZE)
					{
						if(m_pTitleLabel)
						{
							const QRect rcTitle = m_pTitleLayout->geometry();
							if(x > rcTitle.x() && x < rcTitle.right() && y > rcTitle.y() && y < rcTitle.bottom())
							{
								bCaption = TRUE;
							}
						}
					}
				}

				if(bCaption)
				{
					if(isMaximized())
					{
						showNormal();
					}
					else if(isMinimized())
					{
						showNormal();
					}
					else
					{
						showMaximized();
					}
				}
			}
			return true;

		case WM_NCLBUTTONDOWN:
			if(isMaximized())
			{
				if(!COSInfo::IsAboveWinXP())
					return true;
			}
			break;

		case WM_NCCALCSIZE:
			if(msg->wParam)
			{
				NCCALCSIZE_PARAMS* lpncsp = (NCCALCSIZE_PARAMS*)msg->lParam;
				if(lpncsp->rgrc[0].right - lpncsp->rgrc[0].left > 10)
				{
					lpncsp->rgrc[0].left += 1;
					lpncsp->rgrc[0].top += 1;
					lpncsp->rgrc[0].right -= 1;
					lpncsp->rgrc[0].bottom -= 1;
				}
				//*result = WVR_ALIGNTOP | WVR_ALIGNLEFT | WVR_ALIGNBOTTOM | WVR_ALIGNRIGHT;
			}
			*result = 0;
			return true;

		case WM_ACTIVATE:
			{
				MARGINS margins = {-1};
				HINSTANCE hInst = LoadLibraryW(L"dwmapi.dll");
				if (hInst)
				{
					typedef HRESULT (WINAPI * TmpFun)(HWND,MARGINS*);
					TmpFun DwmExtendFrameIntoClientArea = (TmpFun)::GetProcAddress(hInst, "DwmExtendFrameIntoClientArea");
					if (DwmExtendFrameIntoClientArea)
					{
						DwmExtendFrameIntoClientArea(winId(),&margins);
					}
					FreeLibrary(hInst);
				}
				::SetWindowLongA(winId(),GWL_EXSTYLE, WS_EX_LEFT);
			}
			break;

		case WM_NCACTIVATE:
		case 0x00AE:
		case 0x00AF:
			*result = 0;
			return false;
	}

	return false;
}
开发者ID:ACEZLY,项目名称:openmeeting2,代码行数:101,代码来源:ccommonwidget.cpp


示例4: sizeof

CWindowsVersion::CWindowsVersion()
{
	m_osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  
    if(!GetVersionEx(&m_osv))
    {
        ASSERT(0);
        // make sure nothing bad will happen trying to interpret OSVERSIONINFO
        memset((void*)&m_osv, 0, sizeof(m_osv));
    }
    else
    {
        switch(m_osv.dwPlatformId)
        {
        case VER_PLATFORM_WIN32s: //Win32s on Windows 3.1. 
            m_winVer = WV_32S;
            break;

        case VER_PLATFORM_WIN32_WINDOWS: //WIN32 on 95 or 98 or ME
            if(m_osv.dwMinorVersion == 0)
            {
                m_winVer = WV_95;
            }
            else if(m_osv.dwMinorVersion == 10)
            {
                m_winVer = WV_98;
            }
            if(m_osv.dwMinorVersion == 90)
            {
                m_winVer = WV_ME;
            }
            break;

        case VER_PLATFORM_WIN32_NT: //Win32 on Windows NT. 

            if(m_osv.dwMajorVersion == 4) 
            {
                m_winVer = WV_NT4;
            }
            else if(m_osv.dwMajorVersion >= 5)
            {
                m_winVer = WV_2K;
            }
            break;

        default: 
            m_winVer = WV_UNKNOWN;
            break;
        }
    }

    // get the language
    m_UILang = 0;
    switch(m_winVer)
    {
    case WV_2K:
        {
        // Disable this section to emulate Windows NT before Windows 2000, when testing
        // on Windows 2000
        // Use GetUserDefaultUILanguage to find the user's prefered UI language

        // Declare function pointer
        LANGID (WINAPI *pfnGetUserDefaultUILanguage) () = NULL ;

        HMODULE hMKernel32 = LoadLibraryW(L"kernel32.dll") ;
        
        pfnGetUserDefaultUILanguage = 
            (unsigned short (WINAPI *)(void)) 
                GetProcAddress(hMKernel32, "GetUserDefaultUILanguage") ;

        if(NULL != pfnGetUserDefaultUILanguage)
            m_UILang = pfnGetUserDefaultUILanguage() ;
        }
        break;
    case WV_NT4:
        {
            // Running on Windows NT 4.0 or earlier. Get UI language
            // from locale of .default user in registry:
            // HKEY_USERS\.DEFAULT\Control Panel\International\Locale
            CRegKeyEx key;
            if(ERROR_SUCCESS == key.Open(HKEY_USERS, _T(".DEFAULT\\Control Panel\\International"), KEY_READ))
            {
                CString value = key.QueryValueString(_T("Locale"));
                m_UILang = (LANGID)_tcstol(value,NULL,16);
            };
            
        }
        break;
    case WV_95:
    case WV_98:
    case WV_ME:
        {
            // Running on Windows 9x. Get the system UI language from registry:
            CRegKeyEx key;
            if(ERROR_SUCCESS == key.Open(HKEY_USERS, _T(".Default\\Control Panel\\desktop\\ResourceLocale"), KEY_READ))
            {
                CString value = key.QueryValueString(_T(""));
                m_UILang = (LANGID)_tcstol(value, 0, 16);
            };
            
//.........这里部分代码省略.........
开发者ID:danieljennings,项目名称:p4win,代码行数:101,代码来源:WindowsVersion.cpp


示例5: LoadInstallableVDD

BOOL LoadInstallableVDD(VOID)
{
#define ERROR_MEMORYVDD L"Insufficient memory to load installable Virtual Device Drivers."
#define ERROR_REGVDD    L"Virtual Device Driver format in the registry is invalid."
#define ERROR_LOADVDD   L"An installable Virtual Device Driver failed Dll initialization."

    BOOL  Success = TRUE;
    LONG  Error   = 0;
    DWORD Type    = 0;
    DWORD BufSize = 0;

    HKEY    hVDDKey;
    LPCWSTR VDDKeyName   = L"SYSTEM\\CurrentControlSet\\Control\\VirtualDeviceDrivers";
    LPWSTR  VDDValueName = L"VDD";
    LPWSTR  VDDList      = NULL;

    HANDLE hVDD;

    /* Try to open the VDD registry key */
    Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                          VDDKeyName,
                          0,
                          KEY_QUERY_VALUE,
                          &hVDDKey);
    if (Error == ERROR_FILE_NOT_FOUND)
    {
        /* If the key just doesn't exist, don't do anything else */
        return TRUE;
    }
    else if (Error != ERROR_SUCCESS)
    {
        /* The key exists but there was an access error: display an error and quit */
        DisplayMessage(ERROR_REGVDD);
        return FALSE;
    }

    /*
     * Retrieve the size of the VDD registry value
     * and check that it's of REG_MULTI_SZ type.
     */
    Error = RegQueryValueExW(hVDDKey,
                             VDDValueName,
                             NULL,
                             &Type,
                             NULL,
                             &BufSize);
    if (Error == ERROR_FILE_NOT_FOUND)
    {
        /* If the value just doesn't exist, don't do anything else */
        Success = TRUE;
        goto Quit;
    }
    else if (Error != ERROR_SUCCESS || Type != REG_MULTI_SZ)
    {
        /*
         * The value exists but there was an access error or
         * is of the wrong type: display an error and quit.
         */
        DisplayMessage(ERROR_REGVDD);
        Success = FALSE;
        goto Quit;
    }

    /* Allocate the buffer */
    BufSize = (BufSize < 2*sizeof(WCHAR) ? 2*sizeof(WCHAR) : BufSize);
    VDDList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufSize);
    if (VDDList == NULL)
    {
        DisplayMessage(ERROR_MEMORYVDD);
        Success = FALSE;
        goto Quit;
    }

    /* Retrieve the list of VDDs to load */
    if (RegQueryValueExW(hVDDKey,
                         VDDValueName,
                         NULL,
                         NULL,
                         (LPBYTE)VDDList,
                         &BufSize) != ERROR_SUCCESS)
    {
        DisplayMessage(ERROR_REGVDD);
        Success = FALSE;
        goto Quit;
    }

    /* Load the VDDs */
    VDDValueName = VDDList;
    while (*VDDList)
    {
        DPRINT1("Loading VDD '%S'...", VDDList);
        hVDD = LoadLibraryW(VDDList);
        if (hVDD == NULL)
        {
            DbgPrint("Failed\n");
            DisplayMessage(ERROR_LOADVDD);
        }
        else
        {
            DbgPrint("Succeeded\n");
//.........这里部分代码省略.........
开发者ID:hackbunny,项目名称:reactos,代码行数:101,代码来源:vddsup.c


示例6: register_server

static HRESULT register_server(BOOL do_register)
{
    HRESULT hres;
    HMODULE hAdvpack;
    HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
    STRTABLEA strtable;
    STRENTRYA pse[35];
    static CLSID const *clsids[35];
    unsigned int i = 0;

    static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};

    TRACE("(%x)\n", do_register);

    INF_SET_CLSID(AboutProtocol);
    INF_SET_CLSID(CAnchorBrowsePropertyPage);
    INF_SET_CLSID(CBackgroundPropertyPage);
    INF_SET_CLSID(CCDAnchorPropertyPage);
    INF_SET_CLSID(CCDGenericPropertyPage);
    INF_SET_CLSID(CDocBrowsePropertyPage);
    INF_SET_CLSID(CDwnBindInfo);
    INF_SET_CLSID(CHiFiUses);
    INF_SET_CLSID(CHtmlComponentConstructor);
    INF_SET_CLSID(CImageBrowsePropertyPage);
    INF_SET_CLSID(CInlineStylePropertyPage);
    INF_SET_CLSID(CPeerHandler);
    INF_SET_CLSID(CRecalcEngine);
    INF_SET_CLSID(CSvrOMUses);
    INF_SET_CLSID(CrSource);
    INF_SET_CLSID(ExternalFrameworkSite);
    INF_SET_CLSID(HTADocument);
    INF_SET_CLSID(HTMLDocument);
    INF_SET_CLSID(HTMLLoadOptions);
    INF_SET_CLSID(HTMLPluginDocument);
    INF_SET_CLSID(HTMLPopup);
    INF_SET_CLSID(HTMLPopupDoc);
    INF_SET_CLSID(HTMLServerDoc);
    INF_SET_CLSID(HTMLWindowProxy);
    INF_SET_CLSID(IImageDecodeFilter);
    INF_SET_CLSID(IImgCtx);
    INF_SET_CLSID(IntDitherer);
    INF_SET_CLSID(JSProtocol);
    INF_SET_CLSID(MHTMLDocument);
    INF_SET_CLSID(MailtoProtocol);
    INF_SET_CLSID(ResProtocol);
    INF_SET_CLSID(Scriptlet);
    INF_SET_CLSID(SysimageProtocol);
    INF_SET_CLSID(TridentAPI);
    INF_SET_ID(LIBID_MSHTML);

    for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++) {
        pse[i].pszValue = heap_alloc(39);
        sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
                clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
                clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
                clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
    }

    strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
    strtable.pse = pse;

    hAdvpack = LoadLibraryW(wszAdvpack);
    pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");

    hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);

    for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
        heap_free(pse[i].pszValue);

    if(FAILED(hres)) {
        ERR("RegInstall failed: %08x\n", hres);
        return hres;
    }

    if(do_register) {
        ITypeLib *typelib;

        static const WCHAR wszMSHTML[] = {'m','s','h','t','m','l','.','t','l','b',0};

        hres = LoadTypeLibEx(wszMSHTML, REGKIND_REGISTER, &typelib);
        if(SUCCEEDED(hres))
            ITypeLib_Release(typelib);
    }else {
        hres = UnRegisterTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, SYS_WIN32);
    }

    if(FAILED(hres))
        ERR("typelib registration failed: %08x\n", hres);

    return hres;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:91,代码来源:main.c


示例7: wmain

int wmain()
{
    HMODULE Module;
    HANDLE File = { 0 };
    BYTE* MappedFile = { 0 };
    BYTE* MappedFile_End = { 0 };
    HANDLE FileMapping = { 0 };
    ULARGE_INTEGER FileSize;
    DWORD Error = { 0 };
    IMAGE_NT_HEADERS* NtHeaders = { 0 };
    IMAGE_DOS_HEADER* DosHeader = { 0 };
    size_t OffsetToPE = { 0 };
    IMAGE_RESOURCE_DIRECTORY* TopDirectory = { 0 };
    ULONG ResourcesSize = { 0 };

    Module = LoadLibraryW(L".\\notepad.exe");
    if (!EnumResourceTypesW(Module, EnumTypesProc, 0))
    {
        DWORD Error = GetLastError();
        wprintf(L"EnumResourceTypes failed %x\n", Error);
    }
    FreeLibrary(Module);

    File = CreateFileW(L".\\notepad.exe", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
    if (INVALID_HANDLE_VALUE == File)
    {
        Error = GetLastError();
        wprintf(L"CreateFile fails with error: %u", Error);
        goto Exit;
    }

    FileSize.LowPart = GetFileSize(File, &FileSize.HighPart);
    if ((FileSize.LowPart == -1) && ((Error = GetLastError()) != 0))
    {
        wprintf(L"GetFileSize failed with error %u\n", Error);
        goto Exit;
    }
    if (FileSize.HighPart != 0)
    {
        wprintf(L"file too large\n");
        goto Exit;
    }
    if (FileSize.QuadPart <= (sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS)))
    {
        wprintf(L"file too small\n");
        goto Exit;
    }
    
    FileMapping = CreateFileMappingW(File, NULL, PAGE_READONLY, 0, 0, NULL);
    if (FileMapping == NULL)
    {
        Error = GetLastError();
        wprintf(L"CreateFileMapping fails with error: %u", Error);
        goto Exit;
    }

    MappedFile = (BYTE*) MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 0);
    if (MappedFile == NULL)
        goto Exit;

    wprintf(L"MappedFile:%p\n", MappedFile);
    MappedFile_End = (MappedFile + FileSize.QuadPart);
    DosHeader = (IMAGE_DOS_HEADER*) MappedFile;
    if (DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
    {
        wprintf(L"invalid file");
        goto Exit;
    }

    OffsetToPE = DosHeader->e_lfanew;
    if (OffsetToPE >= FileSize.QuadPart)
    {
        wprintf(L"invalid file");
        goto Exit;
    }
    if ((OffsetToPE + sizeof(IMAGE_NT_HEADERS)) >= FileSize.QuadPart)
    {
        wprintf(L"invalid file");
        goto Exit;
    }
    NtHeaders = (IMAGE_NT_HEADERS*) (MappedFile + OffsetToPE);
    if (NtHeaders->Signature != IMAGE_NT_SIGNATURE)
    {
        wprintf(L"invalid file");
        goto Exit;
    }
    if (NtHeaders->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)
    {
        wprintf(L"invalid file");
        goto Exit;
    }
    if (NtHeaders->OptionalHeader.NumberOfRvaAndSizes < IMAGE_DIRECTORY_ENTRY_RESOURCE)
    {
        wprintf(L"no resources");
        goto Exit;
    }
    if (NtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress == 0)
    {
        wprintf(L"no resources");
        goto Exit;
//.........这里部分代码省略.........
开发者ID:jaykrell,项目名称:j,代码行数:101,代码来源:enum.c


示例8: sizeof

static void *_load_jvm_win32(const char **p_java_home)
{
    static char java_home[256] = "";

    wchar_t buf_loc[4096] = L"SOFTWARE\\JavaSoft\\Java Runtime Environment\\";
    wchar_t buf_vers[128];

    char strbuf[256];

    LONG r;
    DWORD lType;
    DWORD dSize = sizeof(buf_vers);
    HKEY hkey;

    r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buf_loc, 0, KEY_READ, &hkey);
    if (r != ERROR_SUCCESS) {
        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Error opening registry key SOFTWARE\\JavaSoft\\Java Runtime Environment\\");
        return NULL;
    }

    r = RegQueryValueExW(hkey, L"CurrentVersion", NULL, &lType, (LPBYTE)buf_vers, &dSize);
    RegCloseKey(hkey);
    if (r != ERROR_SUCCESS) {
        BD_DEBUG(DBG_BDJ | DBG_CRIT, "CurrentVersion registry value not found");
        return NULL;
    }

    if (debug_mask & DBG_BDJ) {
        WideCharToMultiByte(CP_UTF8, 0, buf_vers, -1, strbuf, sizeof(strbuf), NULL, NULL);
        BD_DEBUG(DBG_BDJ, "JRE version: %s\n", strbuf);
    }
    wcscat(buf_loc, buf_vers);

    dSize = sizeof(buf_loc);
    r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buf_loc, 0, KEY_READ, &hkey);
    if (r != ERROR_SUCCESS) {
        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Error opening JRE version-specific registry key");
        return NULL;
    }

    r = RegQueryValueExW(hkey, L"JavaHome", NULL, &lType, (LPBYTE)buf_loc, &dSize);

    if (r == ERROR_SUCCESS) {
        /* do not fail even if not found */
        WideCharToMultiByte(CP_UTF8, 0, buf_loc, -1, java_home, sizeof(java_home), NULL, NULL);
        *p_java_home = java_home;
        BD_DEBUG(DBG_BDJ, "JavaHome: %s\n", java_home);
    }

    dSize = sizeof(buf_loc);
    r = RegQueryValueExW(hkey, L"RuntimeLib", NULL, &lType, (LPBYTE)buf_loc, &dSize);
    RegCloseKey(hkey);

    if (r != ERROR_SUCCESS) {
        BD_DEBUG(DBG_BDJ | DBG_CRIT, "RuntimeLib registry value not found");
        return NULL;
    }

    void *result = LoadLibraryW(buf_loc);

    WideCharToMultiByte(CP_UTF8, 0, buf_loc, -1, strbuf, sizeof(strbuf), NULL, NULL);
    if (!result) {
        BD_DEBUG(DBG_BDJ | DBG_CRIT, "can't open library '%s'\n", strbuf);
    } else {
        BD_DEBUG(DBG_BDJ, "Using JRE library %s\n", strbuf);
    }

    return result;
}
开发者ID:ggervasio,项目名称:mythtv,代码行数:69,代码来源:bdj.c


示例9: IntInitializeImmEntryTable

/*
 * @unimplemented
 */
BOOL WINAPI IntInitializeImmEntryTable(VOID)
{
    WCHAR ImmFile[MAX_PATH];
    HMODULE imm32 = ghImm32;

    if (gImmApiEntries.pImmIsIME != 0)
    {
       ERR("Imm Api Table Init 1\n");
       return TRUE;
    }

    GetImmFileName(ImmFile, sizeof(ImmFile));
    TRACE("File %ws\n",ImmFile);

    if (imm32 == NULL)
    {
       imm32 = GetModuleHandleW(ImmFile);
    }

    if (imm32 == NULL)
    {
        imm32 = ghImm32 = LoadLibraryW(ImmFile);
        if (imm32 == NULL)
        {
           ERR("Did not load!\n");
           return FALSE;
        }
        return TRUE;
    }

    if (ImmApiTableZero)
    {
       ImmApiTableZero = FALSE;
       ZeroMemory(&gImmApiEntries, sizeof(Imm32ApiTable));
    }

    gImmApiEntries.pImmIsIME = (BOOL (WINAPI*)(HKL)) GetProcAddress(imm32, "ImmIsIME");
    if (!gImmApiEntries.pImmIsIME)
        gImmApiEntries.pImmIsIME = IMM_ImmIsIME;

    gImmApiEntries.pImmEscapeA = (LRESULT (WINAPI*)(HKL, HIMC, UINT, LPVOID)) GetProcAddress(imm32, "ImmEscapeA");
    if (!gImmApiEntries.pImmEscapeA)
        gImmApiEntries.pImmEscapeA = IMM_ImmEscapeAW;

    gImmApiEntries.pImmEscapeW = (LRESULT (WINAPI*)(HKL, HIMC, UINT, LPVOID)) GetProcAddress(imm32, "ImmEscapeW");
    if (!gImmApiEntries.pImmEscapeW)
        gImmApiEntries.pImmEscapeW = IMM_ImmEscapeAW;

    gImmApiEntries.pImmGetCompositionStringA = (LONG (WINAPI*)(HIMC, DWORD, LPVOID, DWORD)) GetProcAddress(imm32, "ImmGetCompositionStringA");
    if (!gImmApiEntries.pImmGetCompositionStringA)
        gImmApiEntries.pImmGetCompositionStringA = IMM_ImmGetCompositionStringAW;

    gImmApiEntries.pImmGetCompositionStringW = (LONG (WINAPI*)(HIMC, DWORD, LPVOID, DWORD)) GetProcAddress(imm32, "ImmGetCompositionStringW");
    if (!gImmApiEntries.pImmGetCompositionStringW)
        gImmApiEntries.pImmGetCompositionStringW = IMM_ImmGetCompositionStringAW;

    gImmApiEntries.pImmGetCompositionFontA = (BOOL (WINAPI*)(HIMC, LPLOGFONTA)) GetProcAddress(imm32, "ImmGetCompositionFontA");
    if (!gImmApiEntries.pImmGetCompositionFontA)
        gImmApiEntries.pImmGetCompositionFontA = IMM_ImmGetCompositionFontA;

    gImmApiEntries.pImmGetCompositionFontW = (BOOL (WINAPI*)(HIMC, LPLOGFONTW)) GetProcAddress(imm32, "ImmGetCompositionFontW");
    if (!gImmApiEntries.pImmGetCompositionFontW)
        gImmApiEntries.pImmGetCompositionFontW = IMM_ImmGetCompositionFontW;

    gImmApiEntries.pImmSetCompositionFontA = (BOOL (WINAPI*)(HIMC, LPLOGFONTA)) GetProcAddress(imm32, "ImmSetCompositionFontA");
    if (!gImmApiEntries.pImmSetCompositionFontA)
        gImmApiEntries.pImmSetCompositionFontA = IMM_ImmSetCompositionFontA;

    gImmApiEntries.pImmSetCompositionFontW = (BOOL (WINAPI*)(HIMC, LPLOGFONTW)) GetProcAddress(imm32, "ImmSetCompositionFontW");
    if (!gImmApiEntries.pImmSetCompositionFontW)
        gImmApiEntries.pImmSetCompositionFontW = IMM_ImmSetCompositionFontW;

    gImmApiEntries.pImmGetCompositionWindow = (BOOL (WINAPI*)(HIMC, LPCOMPOSITIONFORM)) GetProcAddress(imm32, "ImmGetCompositionWindow");
    if (!gImmApiEntries.pImmGetCompositionWindow)
        gImmApiEntries.pImmGetCompositionWindow = IMM_ImmSetGetCompositionWindow;

    gImmApiEntries.pImmSetCompositionWindow = (BOOL (WINAPI*)(HIMC, LPCOMPOSITIONFORM)) GetProcAddress(imm32, "ImmSetCompositionWindow");
    if (!gImmApiEntries.pImmSetCompositionWindow)
        gImmApiEntries.pImmSetCompositionWindow = IMM_ImmSetGetCompositionWindow;

    gImmApiEntries.pImmAssociateContext = (HIMC (WINAPI*)(HWND, HIMC)) GetProcAddress(imm32, "ImmAssociateContext");
    if (!gImmApiEntries.pImmAssociateContext)
        gImmApiEntries.pImmAssociateContext = IMM_ImmAssociateContext;

    gImmApiEntries.pImmReleaseContext = (BOOL (WINAPI*)(HWND, HIMC)) GetProcAddress(imm32, "ImmReleaseContext");
    if (!gImmApiEntries.pImmReleaseContext)
        gImmApiEntries.pImmReleaseContext = IMM_ImmReleaseContext;

    gImmApiEntries.pImmGetContext = (HIMC (WINAPI*)(HWND)) GetProcAddress(imm32, "ImmGetContext");
    if (!gImmApiEntries.pImmGetContext)
        gImmApiEntries.pImmGetContext = IMM_ImmGetContext;

    gImmApiEntries.pImmGetDefaultIMEWnd = (HWND (WINAPI*)(HWND)) GetProcAddress(imm32, "ImmGetDefaultIMEWnd");
    if (!gImmApiEntries.pImmGetDefaultIMEWnd)
        gImmApiEntries.pImmGetDefaultIMEWnd = IMM_ImmGetDefaultIMEWnd;

    gImmApiEntries.pImmNotifyIME = (BOOL (WINAPI*)(HIMC, DWORD, DWORD, DWORD)) GetProcAddress(imm32, "ImmNotifyIME");
//.........这里部分代码省略.........
开发者ID:Moteesh,项目名称:reactos,代码行数:101,代码来源:imm.c


示例10: ViewTree_LoadTree

static BOOL
ViewTree_LoadTree(HKEY hKey, LPCWSTR pszKeyName, DWORD dwParentID)
{
    DWORD dwIndex;
    WCHAR szKeyName[64], szText[MAX_PATH], *pch;
    DWORD Size, Value;
    PVIEWTREE_ENTRY pAllocated;

    // resize s_ViewTreeEntries
    Size = (s_ViewTreeEntryCount + 1) * sizeof(VIEWTREE_ENTRY);
    pAllocated = (PVIEWTREE_ENTRY)realloc(s_ViewTreeEntries, Size);
    if (pAllocated == NULL)
        return FALSE;   // failure
    else
        s_ViewTreeEntries = pAllocated;

    PVIEWTREE_ENTRY pEntry = &s_ViewTreeEntries[s_ViewTreeEntryCount];

    // dwID, dwParentID, szKeyName
    pEntry->dwID = s_ViewTreeEntryCount;
    pEntry->dwParentID = dwParentID;
    lstrcpynW(pEntry->szKeyName, pszKeyName, _countof(pEntry->szKeyName));

    // Text, ResourceID
    pEntry->szText[0] = 0;
    pEntry->dwResourceID = 0;
    szText[0] = 0;
    Size = sizeof(szText);
    RegQueryValueExW(hKey, L"Text", NULL, NULL, LPBYTE(szText), &Size);
    if (szText[0] == L'@')
    {
        pch = wcsrchr(szText, L',');
        if (pch)
        {
            *pch = 0;
            dwIndex = abs(_wtoi(pch + 1));
            pEntry->dwResourceID = dwIndex;
        }
        HINSTANCE hInst = LoadLibraryW(&szText[1]);
        LoadStringW(hInst, dwIndex, szText, _countof(szText));
        FreeLibrary(hInst);
    }
    else
    {
        pEntry->dwResourceID = DWORD(-1);
    }
    lstrcpynW(pEntry->szText, szText, _countof(pEntry->szText));

    // Type
    szText[0] = 0;
    RegQueryValueExW(hKey, L"Type", NULL, NULL, LPBYTE(szText), &Size);
    if (lstrcmpiW(szText, L"checkbox") == 0)
        pEntry->dwType = AETYPE_CHECKBOX;
    else if (lstrcmpiW(szText, L"radio") == 0)
        pEntry->dwType = AETYPE_RADIO;
    else if (lstrcmpiW(szText, L"group") == 0)
        pEntry->dwType = AETYPE_GROUP;
    else
        return FALSE;   // failure

    pEntry->nIconID = -1;
    if (pEntry->dwType == AETYPE_GROUP)
    {
        // Bitmap (Icon)
        UINT nIconIndex = 0;
        Size = sizeof(szText);
        szText[0] = 0;
        RegQueryValueExW(hKey, L"Bitmap", NULL, NULL, LPBYTE(szText), &Size);

        WCHAR szExpanded[MAX_PATH];
        ExpandEnvironmentStringsW(szText, szExpanded, _countof(szExpanded));
        pch = wcsrchr(szExpanded, L',');
        if (pch)
        {
            *pch = 0;
            nIconIndex = abs(_wtoi(pch + 1));
        }
        pEntry->nIconID = ViewTree_AddIcon(szExpanded, nIconIndex);
    }

    if (pEntry->dwType == AETYPE_GROUP)
    {
        pEntry->hkeyRoot = NULL;
        pEntry->szRegPath[0] = 0;
        pEntry->szValueName[0] = 0;
        pEntry->dwCheckedValue = 0;
        pEntry->bHasUncheckedValue = FALSE;
        pEntry->dwUncheckedValue = 0;
        pEntry->dwDefaultValue = 0;
        pEntry->hItem = NULL;
        pEntry->bGrayed = FALSE;
        pEntry->bChecked = FALSE;
    }
    else
    {
        // HKeyRoot
        HKEY HKeyRoot = HKEY_CURRENT_USER;
        Size = sizeof(HKeyRoot);
        RegQueryValueExW(hKey, L"HKeyRoot", NULL, NULL, LPBYTE(&HKeyRoot), &Size);
        pEntry->hkeyRoot = HKeyRoot;
//.........这里部分代码省略.........
开发者ID:Moteesh,项目名称:reactos,代码行数:101,代码来源:view.cpp


示例11: InitDbgHelp

static bool InitDbgHelp()
{
	static bool doinit = true;
	static bool ret = false;

	if(!doinit)
		return ret;

	doinit = false;

	HMODULE module = NULL;
	
	// can't reliably co-exist with dbghelp already being used in the process
	if(GetModuleHandleA("dbghelp.dll") != NULL)
	{
		ret = false;
		return false;
	}
	else
	{
		wchar_t path[MAX_PATH] = {0};
		GetModuleFileNameW(GetModuleHandleA("renderdoc.dll"), path, MAX_PATH-1);

		wchar_t *slash = wcsrchr(path, '\\');

		if(slash)
		{
			*slash = 0;
		}
		else
		{
			slash = wcsrchr(path, '/');

			if(slash == 0)
			{
				ret = false;
				return false;
			}

			*slash = 0;
		}

#if defined(WIN64)
		wcscat_s(path, L"/pdblocate/x64/dbghelp.dll");
#else
		wcscat_s(path, L"/pdblocate/x86/dbghelp.dll");
#endif

		module = LoadLibraryW(path);
	}

	if(!module)
	{
		RDCWARN("Couldn't open dbghelp.dll");
		ret = false;
		return false;
	}

	dynSymInitializeW = (PSYMINITIALIZEW)GetProcAddress(module, "SymInitializeW");
	dynSymEnumerateModules64W = (PSYMENUMERATEMODULES64W)GetProcAddress(module, "SymEnumerateModulesW64");
	dynSymGetModuleInfo64W = (PSYMGETMODULEINFO64W)GetProcAddress(module, "SymGetModuleInfoW64");
	
	if(!dynSymInitializeW ||
		!dynSymEnumerateModules64W ||
		!dynSymGetModuleInfo64W)
	{
		RDCERR("Couldn't get some dbghelp function");
		ret = false;
		return ret;
	}

	dynSymInitializeW(GetCurrentProcess(), L".", TRUE);
	
	HMODULE hModule = NULL;
	GetModuleHandleEx(
		GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
		(LPCTSTR)&dllLocator,
		&hModule);

	if(hModule != NULL)
	{
		MODULEINFO modinfo = { 0 };

		BOOL result = GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(modinfo));

		if(result != FALSE)
		{
			renderdocBase = modinfo.lpBaseOfDll;
			renderdocSize = modinfo.SizeOfImage;
		}
	}
		 
	ret = true;
	return ret;
}
开发者ID:RangerWu,项目名称:renderdoc,代码行数:95,代码来源:win32_callstack.cpp


示例12: ZeroMemory

bool
DeviceManagerD3D9::Init()
{
  WNDCLASSW wc;
  HRESULT hr;

  if (!GetClassInfoW(GetModuleHandle(NULL), kClassName, &wc)) {
      ZeroMemory(&wc, sizeof(WNDCLASSW));
      wc.hInstance = GetModuleHandle(NULL);
      wc.lpfnWndProc = ::DefWindowProc;
      wc.lpszClassName = kClassName;
      if (!RegisterClassW(&wc)) {
          NS_WARNING("Failed to register window class for DeviceManager.");
          return false;
      }
  }

  mFocusWnd = ::CreateWindowW(kClassName, L"D3D9Window", WS_OVERLAPPEDWINDOW,
                              CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL,
                              NULL, GetModuleHandle(NULL), NULL);

  if (!mFocusWnd) {
    NS_WARNING("Failed to create DeviceManagerD3D9 Window.");
    return false;
  }

  /* Create an Nv3DVUtils instance */ 
  if (!mNv3DVUtils) { 
    mNv3DVUtils = new Nv3DVUtils(); 
    if (!mNv3DVUtils) { 
      NS_WARNING("Could not create a new instance of Nv3DVUtils.\n"); 
    } 
  } 

  /* Initialize the Nv3DVUtils object */ 
  if (mNv3DVUtils) { 
    mNv3DVUtils->Initialize(); 
  } 

  HMODULE d3d9 = LoadLibraryW(L"d3d9.dll");
  Direct3DCreate9Func d3d9Create = (Direct3DCreate9Func)
    GetProcAddress(d3d9, "Direct3DCreate9");
  Direct3DCreate9ExFunc d3d9CreateEx = (Direct3DCreate9ExFunc)
    GetProcAddress(d3d9, "Direct3DCreate9Ex");
  
#ifdef USE_D3D9EX
  if (d3d9CreateEx) {
    hr = d3d9CreateEx(D3D_SDK_VERSION, getter_AddRefs(mD3D9Ex));
    if (SUCCEEDED(hr)) {
      mD3D9 = mD3D9Ex;
    }
  }
#endif

  if (!mD3D9) {
    if (!d3d9Create) {
      return false;
    }

    mD3D9 = dont_AddRef(d3d9Create(D3D_SDK_VERSION));

    if (!mD3D9) {
      return false;
    }
  }

  D3DADAPTER_IDENTIFIER9 ident;
  hr = mD3D9->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &ident);

  if (FAILED(hr)) {
    return false;
  }

  if (!PL_strncasecmp(ident.Driver, "nvumdshim.dll", PL_strlen(ident.Driver))) {
    // XXX - This is a device using NVidia Optimus. We have no idea how to do
    // interop here so let's fail and use BasicLayers. See bug 597320.
    return false;
  }

  D3DPRESENT_PARAMETERS pp;
  memset(&pp, 0, sizeof(D3DPRESENT_PARAMETERS));

  pp.BackBufferWidth = 1;
  pp.BackBufferHeight = 1;
  pp.BackBufferFormat = D3DFMT_A8R8G8B8;
  pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  pp.Windowed = TRUE;
  pp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
  pp.hDeviceWindow = mFocusWnd;

  if (mD3D9Ex) {
    hr = mD3D9Ex->CreateDeviceEx(D3DADAPTER_DEFAULT,
                                 D3DDEVTYPE_HAL,
                                 mFocusWnd,
                                 D3DCREATE_FPU_PRESERVE |
                                 D3DCREATE_MULTITHREADED |
                                 D3DCREATE_MIXED_VERTEXPROCESSING,
                                 &pp,
                                 NULL,
                                 getter_AddRefs(mDeviceEx));
//.........这里部分代码省略.........
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:101,代码来源:DeviceManagerD3D9.cpp


示例13: LoadLibraryW

Sys::DLLHandle Sys::LoadDLL(const wchar_t* path) 
{
	auto value = LoadLibraryW(path);
	return value;
}
开发者ID:swordlegend,项目名称:ExcessiveTeam,代码行数:5,代码来源:Sys_win.cpp


示例14: __apxLoadJvmDll

static BOOL __apxLoadJvmDll(LPCWSTR szJvmDllPath)
{
    UINT errMode;
    WCHAR  jreAltPath[SIZ_PATHLEN];
    LPWSTR dllJvmPath = (LPWSTR)szJvmDllPath;
    DYNLOAD_FPTR_DECLARE(SetDllDirectoryW);

    if (!IS_INVALID_HANDLE(_st_sys_jvmDllHandle))
        return TRUE;    /* jvm.dll is already loaded */

    if (dllJvmPath && *dllJvmPath) {
        /* Explicit JVM path.
         * Check if provided argument is valid
         */
        if (GetFileAttributesW(dllJvmPath) == INVALID_FILE_ATTRIBUTES) {
            /* DAEMON-247: Invalid RuntimeLib explicitly specified is error.
             */
            apxLogWrite(APXLOG_MARK_DEBUG "Invalid RuntimeLib specified '%S'", dllJvmPath);
            return FALSE;
        }
    }
    else {
        dllJvmPath = apxGetJavaSoftRuntimeLib(NULL);
        if (!dllJvmPath)
            return FALSE;
    }
    if (GetFileAttributesW(dllJvmPath) == INVALID_FILE_ATTRIBUTES) {
        /* DAEMON-184: RuntimeLib registry key is invalid.
         * Check from Jre JavaHome directly
         */
        LPWSTR szJreHome = apxGetJavaSoftHome(NULL, TRUE);
        apxLogWrite(APXLOG_MARK_DEBUG "Invalid RuntimeLib '%S'", dllJvmPath);
        if (szJreHome) {
            apxLogWrite(APXLOG_MARK_DEBUG "Using Jre JavaHome '%S'", szJreHome);
            lstrlcpyW(jreAltPath, SIZ_PATHLEN, szJreHome);
            lstrlcatW(jreAltPath, SIZ_PATHLEN, L"\\bin\\server\\jvm.dll");
            dllJvmPath = jreAltPath;
        }
    }
    /* Suppress the not found system popup message */
    errMode = SetErrorMode(SEM_FAILCRITICALERRORS);

    apxLogWrite(APXLOG_MARK_DEBUG "loading jvm '%S'", dllJvmPath);
    _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL, 0);
    if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle) &&
        GetFileAttributesW(dllJvmPath) != INVALID_FILE_ATTRIBUTES) {
        /* There is a file but cannot be loaded.
         * Try to load the MSVCRTxx.dll before JVM.dll
         */
        WCHAR  jreBinPath[SIZ_PATHLEN];
        WCHAR  crtBinPath[SIZ_PATHLEN];
        DWORD  i, l = 0;

        lstrlcpyW(jreBinPath, SIZ_PATHLEN, dllJvmPath);
        for (i = lstrlenW(jreBinPath); i > 0, l < 2; i--) {
            if (jreBinPath[i] == L'\\' || jreBinPath[i] == L'/') {
                jreBinPath[i] = L'\0';
                lstrlcpyW(crtBinPath, SIZ_PATHLEN, jreBinPath);
                lstrlcatW(crtBinPath, SIZ_PATHLEN, MSVCRT71_DLLNAME);
                if (GetFileAttributesW(crtBinPath) != INVALID_FILE_ATTRIBUTES) {
                    if (LoadLibraryW(crtBinPath)) {
                        /* Found MSVCRTxx.dll
                         */
                        apxLogWrite(APXLOG_MARK_DEBUG "preloaded '%S'",
                                    crtBinPath);
                        break;
                    }
                }
                l++;
            }
        }
    }
    /* This shuldn't happen, but try to search in %PATH% */
    if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle))
        _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL,
                                              LOAD_WITH_ALTERED_SEARCH_PATH);

    if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle)) {
        WCHAR  jreBinPath[SIZ_PATHLEN];
        DWORD  i, l = 0;

        lstrlcpyW(jreBinPath, SIZ_PATHLEN, dllJvmPath);
        DYNLOAD_FPTR_ADDRESS(SetDllDirectoryW, KERNEL32);
        for (i = lstrlenW(jreBinPath); i > 0, l < 2; i--) {
            if (jreBinPath[i] == L'\\' || jreBinPath[i] == L'/') {
                jreBinPath[i] = L'\0';
                DYNLOAD_CALL(SetDllDirectoryW)(jreBinPath);
                apxLogWrite(APXLOG_MARK_DEBUG "Setting DLL search path to '%S'",
                            jreBinPath);
                l++;
            }
        }
        _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL, 0);
        if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle))
            _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL,
                                                  LOAD_WITH_ALTERED_SEARCH_PATH);
    }
    /* Restore the error mode signalization */
    SetErrorMode(errMode);
    if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle)) {
//.........这里部分代码省略.........
开发者ID:GabrielNicolasAvellaneda,项目名称:boundary-event-sdk,代码行数:101,代码来源:javajni.c


示例15: Sutf8_to_wide

void *S_ntdlopen(const char *path) {
  wchar_t *pathw = Sutf8_to_wide(path);
  void *r = (void *)LoadLibraryW(pathw);
  free(pathw);
  return r;
}
开发者ID:chpwang,项目名称:ChezScheme,代码行数:6,代码来源:windows.c


示例16: vboxDispKmtCallbacksInit

HRESULT vboxDispKmtCallbacksInit(PVBOXDISPKMT_CALLBACKS pCallbacks)
{
    HRESULT hr = S_OK;

    memset(pCallbacks, 0, sizeof (*pCallbacks));

    pC 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LoadMenu函数代码示例发布时间:2022-05-30
下一篇:
C++ LoadLibraryExW函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap