int _tmain(int argc, _TCHAR* argv[]) { HINSTANCE hInst = LoadLibrary(TEXT("MVSIP.DLL")); typeRegMVSIP regMVSIP = (typeRegMVSIP)GetProcAddressW( hInst, TEXT("DllRegisterServer")); typeUnregMVSIP unregMVSIP = (typeUnregMVSIP)GetProcAddressW( hInst, TEXT("DllUnregisterServer")); if(argc && !_wcsicmp(argv[0],TEXT("/u"))) { //Unregister server if(unregMVSIP() == S_OK) MessageBox(NULL,TEXT("Unregister MobileVanilla successed."), TEXT("RegMV"), MB_OK); else MessageBox(NULL,TEXT("Unregister MobileVanilla failed."), TEXT("RegMV"), MB_OK); } else //Register server { if(regMVSIP()== S_OK) MessageBox(NULL,TEXT("Register MobileVanilla successed."), TEXT("RegMV"), MB_OK); else MessageBox(NULL,TEXT("Register MobileVanilla failed."), TEXT("RegMV"), MB_OK); } return 0; }
int _tmain(int argc, _TCHAR* argv[]) { HINSTANCE hInst = LoadLibrary(TEXT("MVSIP.DLL")); typeRegMVSIP regMVSIP = (typeRegMVSIP)GetProcAddressW( hInst, TEXT("DllRegisterServer")); typeUnregMVSIP unregMVSIP = (typeUnregMVSIP)GetProcAddressW( hInst, TEXT("DllUnregisterServer")); if(argc && !_wcsicmp(argv[0],TEXT("/"))) {//Register server if(regMVSIP()== S_OK) MessageBox(NULL,TEXT("Register MobileVanilla successed."), TEXT("RegMV"), MB_OK); else MessageBox(NULL,TEXT("Register MobileVanilla failed."), TEXT("RegMV"), MB_OK); } else { //Unregister server /* HRESULT hr=S_OK; wchar_t wbuf[256]; swprintf(wbuf, TEXT("%s\\InprocServer32"), IMClsidKey); if (ERROR_SUCCESS != RegDeleteKey(HKEY_CLASSES_ROOT, wbuf)) hr = E_FAIL; swprintf(wbuf, TEXT("%s\\DefaultIcon"), IMClsidKey); if (ERROR_SUCCESS != RegDeleteKey(HKEY_CLASSES_ROOT, wbuf)) hr = E_FAIL; swprintf(wbuf, TEXT("%s\\IsSIPInputMethod"), IMClsidKey); if (ERROR_SUCCESS != RegDeleteKey(HKEY_CLASSES_ROOT, wbuf)) hr = E_FAIL; if (ERROR_SUCCESS != RegDeleteKey(HKEY_CLASSES_ROOT, IMClsidKey)) hr = E_FAIL; swprintf(wbuf, TEXT("Control Panel\\Input Method\\Hot Keys\\%s"), MVHotKey); if (ERROR_SUCCESS != RegDeleteKey(HKEY_CURRENT_USER, wbuf)) hr = E_FAIL; */ if(unregMVSIP() == S_OK) // if(hr == S_OK) MessageBox(NULL,TEXT("Unregister MobileVanilla successed."), TEXT("UnRegMV"), MB_OK); else MessageBox(NULL,TEXT("Unregister MobileVanilla failed."), TEXT("UnRegMV"), MB_OK); } return 0; }
APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, struct apr_dso_handle_t *handle, const char *symname) { #ifdef _WIN32_WCE apr_size_t symlen = strlen(symname) + 1; apr_size_t wsymlen = 256; apr_wchar_t wsymname[256]; apr_status_t rv; rv = apr_conv_utf8_to_ucs2(wsymname, &wsymlen, symname, &symlen); if (rv != APR_SUCCESS) { return rv; } else if (symlen) { return APR_ENAMETOOLONG; } *ressym = (apr_dso_handle_sym_t)GetProcAddressW(handle->handle, wsymname); #else *ressym = (apr_dso_handle_sym_t)GetProcAddress(handle->handle, symname); #endif if (!*ressym) { return apr_get_os_error(); } return APR_SUCCESS; }
static NOINLINE bool_t FindCeSetThreadQuantum() { // slow, but multithread safe HMODULE CoreDLL = GetModuleHandleW(L"coredll.dll"); if (CoreDLL) *(FARPROC*)(void*)&FuncCeSetThreadQuantum = GetProcAddressW(CoreDLL,L"CeSetThreadQuantum"); return FuncCeSetThreadQuantum != NULL; }
FARPROC GetProcAddressA(HMODULE hModule, LPCSTR lpProcName) { FARPROC p; LPWSTR lpwProcName; lpwProcName = wce_mbtowc( lpProcName ); p = GetProcAddressW( hModule, lpwProcName ); free( lpwProcName ); return p; }
static FARPROC GetProcAddressA(HMODULE hModule,LPCSTR lpProcName) { WCHAR lpProcNameW[64]; int i; for (i=0;lpProcName[i] && i<64;i++) lpProcNameW[i] = (WCHAR)lpProcName[i]; if (i==64) return NULL; lpProcNameW[i] = 0; return GetProcAddressW(hModule,lpProcNameW); }
void* SharedLibraryImpl::findSymbolImpl(const std::string& name) { FastMutex::ScopedLock lock(_mutex); if (_handle) { #if defined(_WIN32_WCE) std::wstring uname; UnicodeConverter::toUTF16(name, uname); return (void*) GetProcAddressW((HMODULE) _handle, uname.c_str()); #else return (void*) GetProcAddress((HMODULE) _handle, name.c_str()); #endif } else return 0; }
HRESULT Text_Send(LPVOID smsmcCookie, const BYTE* pbData, DWORD dwDataSize, const BYTE* pbProviderSpecificData, DWORD dwProviderSpecificDataSize, LPVOID smsdeDesiredDataEncoding, LPVOID prilmTemplate, LPVOID smsmsmSendMessageFunction) { RETAILMSG(1, (L"[SMS_Providers_Ultra] Text_Send++\r\n")); HRESULT hr = E_FAIL; if (textSend == NULL) { HMODULE hLibrary = NULL; #ifdef FORHTC hLibrary = LoadLibrary(L"SMS_Providers_OEM.dll"); #elif FORSAMSUNG hLibrary = LoadLibrary(L"Mits_SMS_Providers.dll"); #else // failsafe hLibrary = LoadLibrary(L"sms_providers.dll"); #endif textSend = (TEXT_SEND)GetProcAddressW(hLibrary, L"Text_Send"); } if (textSend) hr = textSend(smsmcCookie, pbData, dwDataSize, pbProviderSpecificData, dwProviderSpecificDataSize, smsdeDesiredDataEncoding, prilmTemplate, smsmsmSendMessageFunction); if (prilmTemplate) { RILMESSAGEFAKE *ril = (RILMESSAGEFAKE*)prilmTemplate; if (ril->dwType == RIL_MSGTYPE_OUT_SUBMIT) { HANDLE hFile = CreateFile(L"PHT1:", 0, 0, NULL, 0, 3, NULL); if (hFile && hFile != INVALID_HANDLE_VALUE) { NOKIAPHONETOOLSMSG msg; memset(&msg, 0, sizeof(msg)); msg.dwSize = 0x1; wcscpy_s(msg.wszAddress, 0x100, ril->raDestAddress.wszAddress); DeviceIoControl(hFile, 0x2000044, &msg, sizeof(NOKIAPHONETOOLSMSG), NULL, NULL, 0,0); CloseHandle(hFile); } } } RETAILMSG(1, (L"[SMS_Providers_Ultra] Text_Send-- hr = %X\r\n", hr)); return hr; }
FARPROC CE_GetProcAddressA(HMODULE hModule, LPCSTR lpProcName) { FARPROC proc = NULL; size_t nLen = 0; LPTSTR pszWideStr = 0; /* Covert filename buffer to Unicode. */ nLen = MultiByteToWideChar (CP_ACP, 0, lpProcName, -1, NULL, 0) ; pszWideStr = (wchar_t*)malloc(sizeof(wchar_t) * nLen); MultiByteToWideChar(CP_ACP, 0, lpProcName, -1, pszWideStr, nLen); proc = GetProcAddressW(hModule, pszWideStr); /* Free me! */ free(pszWideStr); return proc; }
static int h_plugin(int argc, unsigned char **argv){ #ifdef NOPLUGINS return 999; #else #ifdef _WIN32 HINSTANCE hi; FARPROC fp; #ifdef _WINCE hi = LoadLibraryW((LPCWSTR)CEToUnicode(argv[1])); #else hi = LoadLibrary((char *)argv[1]); #endif if(!hi) { fprintf(stderr, "Failed to load %s, code %d\n", argv[1], (int)GetLastError()); return 1; } #ifdef _WINCE fp = GetProcAddressW(hi, (LPCWSTR)CEToUnicode(argv[2])); #else fp = GetProcAddress(hi, (char *)argv[2]); #endif if(!fp) { printf("%s not found in %s, code: %d\n", argv[2], argv[1], (int)GetLastError()); return 2; } return (*(PLUGINFUNC)fp)(&pluginlink, argc - 2, (char **)argv + 2); #else void *hi, *fp; hi = dlopen((char *)argv[1], RTLD_LAZY); if(!hi) return 1; fp = dlsym(hi, (char *)argv[2]); if(!fp) return 2; return (*(PLUGINFUNC)fp)(&pluginlink, argc - 2, (char **)argv + 2); #endif #endif }
BOOL LoadCAPI2(void) { if (InterlockedIncrement(&g_refCount) != 1) return g_hCrypt32 != 0; DEBUGCHK(g_hCrypt32 == NULL); g_hCoredll = GetModuleHandleW(L"coredll.dll"); g_hCrypt32 = LoadLibraryW(L"crypt32.dll"); if (g_hCoredll && g_hCrypt32) { pCryptEnumProvidersW = (PFNCRYPTENUMPROVIDERSW) GetProcAddressW(g_hCoredll, L"CryptEnumProvidersW"); pCryptGetProvParam = (PFNCRYPTGETPROVPARAM) GetProcAddressW(g_hCoredll, L"CryptGetProvParam"); pCryptAcquireContextW = (PFNCRYPTACQUIRECONTEXTW) GetProcAddressW(g_hCoredll, L"CryptAcquireContextW"); pCryptReleaseContext = (PFNCRYPTRELEASECONTEXT) GetProcAddressW(g_hCoredll, L"CryptReleaseContext"); pCryptGetUserKey = (PFNCRYPTGETUSERKEY) GetProcAddressW(g_hCoredll, L"CryptGetUserKey"); pCryptGetKeyParam = (PFNCRYPTGETKEYPARAM) GetProcAddressW(g_hCoredll, L"CryptGetKeyParam"); pCryptDestroyKey = (PFNCRYPTDESTROYKEY) GetProcAddressW(g_hCoredll, L"CryptDestroyKey"); pCertCreateCertificateContext = (PFNCERTCREATECERTIFICATECONTEXT) GetProcAddressW(g_hCrypt32, L"CertCreateCertificateContext"); pCertFreeCertificateContext = (PFNCERTFREECERTIFICATECONTEXT)GetProcAddressW(g_hCrypt32, L"CertFreeCertificateContext"); pCertDuplicateCertificateContext = (PFNCERTDUPLICATECERTIFICATECONTEXT)GetProcAddressW(g_hCrypt32, L"CertDuplicateCertificateContext"); pCertOpenStore = (PFNCERTOPENSTORE)GetProcAddressW(g_hCrypt32, L"CertOpenStore"); pCertCloseStore = (PFNCERTCLOSESTORE)GetProcAddressW(g_hCrypt32, L"CertCloseStore"); pCertEnumCertificatesInStore = (PFNCERTENUMCERTIFICATESINSTORE)GetProcAddressW(g_hCrypt32, L"CertEnumCertificatesInStore"); pCertFindCertificateInStore = (PFNCERTFINDCERTIFICATEINSTORE)GetProcAddressW(g_hCrypt32, L"CertFindCertificateInStore"); pCertGetNameStringW = (PFNCERTGETNAMESTRINGW)GetProcAddressW(g_hCrypt32, L"CertGetNameStringW"); pCertGetCertificateContextProperty = (PFNCERTGETCERTIFICATECONTEXTPROPERTY)GetProcAddressW(g_hCrypt32, L"CertGetCertificateContextProperty"); pCertSetCertificateContextProperty = (PFNCERTSETCERTIFICATECONTEXTPROPERTY)GetProcAddressW(g_hCrypt32, L"CertSetCertificateContextProperty"); pCertAddEncodedCertificateToStore = (PFNCERTADDENCODEDCERTIFICATETOSTORE)GetProcAddressW(g_hCrypt32, L"CertAddEncodedCertificateToStore"); pCertAddCertificateContextToStore = (PFNCERTADDCERTIFICATECONTEXTTOSTORE) GetProcAddressW(g_hCrypt32, L"CertAddCertificateContextToStore"); pCertCompareCertificateName = (PFNCERTCOMPARECERTIFICATENAME)GetProcAddressW(g_hCrypt32, L"CertCompareCertificateName"); pCertNameToStrW = (PFNCERTNAMETOSTRW)GetProcAddressW(g_hCrypt32, L"CertNameToStrW"); pCertGetEnhancedKeyUsage = (PFNCERTGETENHANCEDKEYUSAGE)GetProcAddressW(g_hCrypt32, L"CertGetEnhancedKeyUsage"); pCryptFindOIDInfo = (PFNCRYPTFINDOIDINFO)GetProcAddressW(g_hCrypt32, L"CryptFindOIDInfo"); if ( !pCryptAcquireContextW || !pCryptReleaseContext || !pCryptGetUserKey || !pCryptEnumProvidersW || !pCryptGetProvParam || !pCryptGetKeyParam || !pCryptDestroyKey || !pCertCreateCertificateContext || !pCertFreeCertificateContext || !pCertDuplicateCertificateContext || !pCertOpenStore || !pCertCloseStore || !pCertEnumCertificatesInStore || !pCertGetNameStringW || !pCertNameToStrW || !pCertGetCertificateContextProperty || !pCertSetCertificateContextProperty || !pCertAddCertificateContextToStore || !pCertCompareCertificateName || !pCertNameToStrW || !pCertGetEnhancedKeyUsage || !pCryptFindOIDInfo ) { FreeLibrary(g_hCrypt32); g_hCrypt32 = 0; } } return (g_hCrypt32 != 0); }
void SSLManager::loadSecurityLibrary() { if (_hSecurityModule) return; OSVERSIONINFO VerInfo; std::wstring dllPath; // Find out which security DLL to use, depending on // whether we are on Win2k, NT or Win9x VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx(&VerInfo)) throw Poco::SystemException("Cannot determine OS version"); #if defined(_WIN32_WCE) dllPath = L"Secur32.dll"; #else if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VerInfo.dwMajorVersion == 4) { dllPath = L"Security.dll"; } else if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS || VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) { dllPath = L"Secur32.dll"; } else { throw Poco::SystemException("Cannot determine which security DLL to use"); } #endif // // Load Security DLL // _hSecurityModule = LoadLibraryW(dllPath.c_str()); if(_hSecurityModule == 0) { throw Poco::SystemException("Failed to load security DLL"); } #if defined(_WIN32_WCE) INIT_SECURITY_INTERFACE pInitSecurityInterface = (INIT_SECURITY_INTERFACE)GetProcAddressW( _hSecurityModule, L"InitSecurityInterfaceW"); #else INIT_SECURITY_INTERFACE pInitSecurityInterface = (INIT_SECURITY_INTERFACE)GetProcAddress( _hSecurityModule, "InitSecurityInterfaceW"); #endif if (!pInitSecurityInterface) { FreeLibrary(_hSecurityModule); _hSecurityModule = 0; throw Poco::SystemException("Failed to initialize security DLL (no init function)"); } PSecurityFunctionTable pSecurityFunc = pInitSecurityInterface(); if (!pSecurityFunc) { FreeLibrary(_hSecurityModule); _hSecurityModule = 0; throw Poco::SystemException("Failed to initialize security DLL (no function table)"); } CopyMemory(&_securityFunctions, pSecurityFunc, sizeof(_securityFunctions)); }