DWORD FindWDIGEST_dll_2() { unsigned char digest2[] = "\x8B\xFF\x55\x8B\xEC\x56\xBE\x00" "\x56\xFF\x00\x00\x8B\x0D\x00\x00\x8B\x45\x08\x89\x08\xC7\x40\x04"; HMODULE hModule = LoadLibraryA("wdigest.dll"); if (!hModule) { return 0; } MODULEINFO modinfo; if (!GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO))) { return 0; } DWORD dwRet = 0, dwResult = 0; DWORD dwDllBase = (DWORD)modinfo.lpBaseOfDll; BOOL bNext = FALSE; for (DWORD i = 0; ; ++i) { if (i < modinfo.SizeOfImage) { if (IsBadReadPtr((const void *)(i + dwDllBase), 7)) continue; if (!memcmp((const void *)(i + dwDllBase), digest2, 7)) { bNext = TRUE; } if (!bNext) continue; bNext = FALSE; void *lp = (void *)(i + dwDllBase + 7 + 4); if (IsBadReadPtr((const void *)(i + dwDllBase + 7 + 4), 2) ) continue; if (!memcmp(lp, digest2 + 8, 2) ) bNext = TRUE; if (!bNext) continue; bNext = FALSE; lp = (char *)lp + 2 + 5; if (IsBadReadPtr(lp, 2u)) continue; if (!memcmp(lp, digest2 + 0xc, 2u)) bNext = TRUE; if (!bNext) continue; bNext = FALSE; dwResult = *(_DWORD *)((char *)lp + 2); lp = (char *)lp + 6; if (IsBadReadPtr(lp, 8u)) continue; if (!memcmp(lp, digest2 + 0x10, 8u)) { bNext = TRUE; } if (!bNext) continue; DWORD v7 = *((_DWORD *)lp + 2); if (!bNext) continue; } break; } if (bNext) dwRet = dwResult; return dwRet; }
void SuDeleteGarbageInfsInner() { char *base_key_name = "DRIVERS\\DriverDatabase\\DriverPackages"; TOKEN_LIST *keys; HINSTANCE hSetupApiDll = NULL; BOOL (WINAPI *_SetupUninstallOEMInfA)(PCSTR, DWORD, PVOID) = NULL; if (MsIsWindows10() == false) { return; } hSetupApiDll = LoadLibraryA("setupapi.dll"); if (hSetupApiDll == NULL) { return; } _SetupUninstallOEMInfA = (UINT (__stdcall *)(PCSTR,DWORD,PVOID)) GetProcAddress(hSetupApiDll, "SetupUninstallOEMInfA"); if (_SetupUninstallOEMInfA != NULL) { keys = MsRegEnumKeyEx2(REG_LOCAL_MACHINE, base_key_name, false, true); if (keys != NULL) { char full_key[MAX_PATH]; UINT i; for (i = 0;i < keys->NumTokens;i++) { char *oem_name, *inf_name, *provider; Format(full_key, sizeof(full_key), "%s\\%s", base_key_name, keys->Token[i]); oem_name = MsRegReadStrEx2(REG_LOCAL_MACHINE, full_key, "", false, true); inf_name = MsRegReadStrEx2(REG_LOCAL_MACHINE, full_key, "InfName", false, true); provider = MsRegReadStrEx2(REG_LOCAL_MACHINE, full_key, "Provider", false, true); if (IsEmptyStr(oem_name) == false && IsEmptyStr(inf_name) == false) { if (StartWith(oem_name, "oem")) { if (StartWith(inf_name, "selow")) { if (InStr(provider, "softether")) { Debug("Delete OEM INF %s (%s): %u\n", oem_name, inf_name, _SetupUninstallOEMInfA(oem_name, 0x00000001, NULL)); } } } } Free(oem_name); Free(inf_name); Free(provider); } FreeToken(keys); } } if (hSetupApiDll != NULL) { FreeLibrary(hSetupApiDll); } }
/***************************************************************************** * QTAudioInit: *****************************************************************************/ static int QTAudioInit( decoder_t *p_dec ) { decoder_sys_t *p_sys = p_dec->p_sys; #ifdef __APPLE__ p_sys->SoundConverterOpen = (void*)SoundConverterOpen; p_sys->SoundConverterClose = (void*)SoundConverterClose; p_sys->SoundConverterSetInfo = (void*)SoundConverterSetInfo; p_sys->SoundConverterGetBufferSizes = (void*)SoundConverterGetBufferSizes; p_sys->SoundConverterConvertBuffer = (void*)SoundConverterConvertBuffer; p_sys->SoundConverterBeginConversion= (void*)SoundConverterBeginConversion; p_sys->SoundConverterEndConversion = (void*)SoundConverterEndConversion; #else #ifdef LOADER p_sys->ldt_fs = Setup_LDT_Keeper(); #endif /* LOADER */ p_sys->qts = LoadLibraryA( "QuickTime.qts" ); if( p_sys->qts == NULL ) { msg_Dbg( p_dec, "failed loading QuickTime.qts" ); return VLC_EGENERIC; } p_sys->qtml = LoadLibraryA( "qtmlClient.dll" ); if( p_sys->qtml == NULL ) { msg_Dbg( p_dec, "failed loading qtmlClient.dll" ); return VLC_EGENERIC; } p_sys->InitializeQTML = (void *)GetProcAddress( p_sys->qtml, "InitializeQTML" ); p_sys->TerminateQTML = (void *)GetProcAddress( p_sys->qtml, "TerminateQTML" ); p_sys->SoundConverterOpen = (void *)GetProcAddress( p_sys->qtml, "SoundConverterOpen" ); p_sys->SoundConverterClose = (void *)GetProcAddress( p_sys->qtml, "SoundConverterClose" ); p_sys->SoundConverterSetInfo = (void *)GetProcAddress( p_sys->qtml, "SoundConverterSetInfo" ); p_sys->SoundConverterGetBufferSizes = (void *)GetProcAddress( p_sys->qtml, "SoundConverterGetBufferSizes" ); p_sys->SoundConverterConvertBuffer = (void *)GetProcAddress( p_sys->qtml, "SoundConverterConvertBuffer" ); p_sys->SoundConverterEndConversion = (void *)GetProcAddress( p_sys->qtml, "SoundConverterEndConversion" ); p_sys->SoundConverterBeginConversion= (void *)GetProcAddress( p_sys->qtml, "SoundConverterBeginConversion"); if( p_sys->InitializeQTML == NULL ) { msg_Err( p_dec, "failed getting proc address InitializeQTML" ); return VLC_EGENERIC; } if( p_sys->SoundConverterOpen == NULL || p_sys->SoundConverterClose == NULL || p_sys->SoundConverterSetInfo == NULL || p_sys->SoundConverterGetBufferSizes == NULL || p_sys->SoundConverterConvertBuffer == NULL || p_sys->SoundConverterEndConversion == NULL || p_sys->SoundConverterBeginConversion == NULL ) { msg_Err( p_dec, "failed getting proc address" ); return VLC_EGENERIC; } msg_Dbg( p_dec, "standard init done" ); #endif /* else __APPLE__ */ return VLC_SUCCESS; }
bool os_msw::is_named_process_running( const wxString& process_name ) { // A more wxWindows type interface const char *szToTerminate = process_name.c_str(); // Created: 6/23/2000 (RK) // Last modified: 3/10/2002 (RK) // Please report any problems or bugs to [email protected] // The latest version of this routine can be found at: // http://www.neurophys.wisc.edu/ravi/software/killproc/ // Terminate the process "szToTerminate" if it is currently running // This works for Win/95/98/ME and also Win/NT/2000/XP // The process name is case-insensitive, i.e. "notepad.exe" and "NOTEPAD.EXE" // will both work (for szToTerminate) // Return codes are as follows: // 0 = Process was successfully terminated // 603 = Process was not currently running // 604 = No permission to terminate process // 605 = Unable to load PSAPI.DLL // 602 = Unable to terminate process for some other reason // 606 = Unable to identify system type // 607 = Unsupported OS // 632 = Invalid process name // 700 = Unable to get procedure address from PSAPI.DLL // 701 = Unable to get process list, EnumProcesses failed // 702 = Unable to load KERNEL32.DLL // 703 = Unable to get procedure address from KERNEL32.DLL // 704 = CreateToolhelp32Snapshot failed // Change history: // modified 3/8/2002 - Borland-C compatible if BORLANDC is defined as // suggested by Bob Christensen // modified 3/10/2002 - Removed memory leaks as suggested by // Jonathan Richard-Brochu (handles to Proc and Snapshot // were not getting closed properly in some cases) BOOL bResult,bResultm; DWORD aiPID[1000],iCb=1000,iNumProc,iV2000=0; DWORD iCbneeded,i,iFound=0; char szName[MAX_PATH],szToTermUpper[MAX_PATH]; HANDLE hProc,hSnapShot,hSnapShotm; OSVERSIONINFO osvi; HINSTANCE hInstLib; int iLen,iLenP,indx; HMODULE hMod; PROCESSENTRY32 procentry; MODULEENTRY32 modentry; // Transfer Process name into "szToTermUpper" and // convert it to upper case iLenP=strlen(szToTerminate); if(iLenP<1 || iLenP>MAX_PATH) return FALSE; for(indx=0;indx<iLenP;indx++) szToTermUpper[indx]=toupper(szToTerminate[indx]); szToTermUpper[iLenP]=0; // PSAPI Function Pointers. BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * ); BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *, DWORD, LPDWORD ); DWORD (WINAPI *lpfGetModuleBaseName)( HANDLE, HMODULE, LPTSTR, DWORD ); // ToolHelp Function Pointers. HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfModule32First)(HANDLE,LPMODULEENTRY32) ; BOOL (WINAPI *lpfModule32Next)(HANDLE,LPMODULEENTRY32) ; // First check what version of Windows we're in osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); bResult=GetVersionEx(&osvi); if(!bResult) // Unable to identify system version return FALSE; // At Present we only support Win/NT/2000/XP or Win/9x/ME if((osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)) return FALSE; if(osvi.dwPlatformId==VER_PLATFORM_WIN32_NT) { // Win/NT or 2000 or XP // Load library and get the procedures explicitly. We do // this so that we don't have to worry about modules using // this code failing to load under Windows 9x, because // it can't resolve references to the PSAPI.DLL. hInstLib = LoadLibraryA("PSAPI.DLL"); if(hInstLib == NULL) return FALSE; // Get procedure addresses. lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) GetProcAddress( hInstLib, "EnumProcesses" ) ; lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD)) GetProcAddress( hInstLib, "EnumProcessModules" ) ; lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, LPTSTR, DWORD )) GetProcAddress( hInstLib, "GetModuleBaseNameA" ) ; if(lpfEnumProcesses == NULL || lpfEnumProcessModules == NULL || lpfGetModuleBaseName == NULL) { FreeLibrary(hInstLib); return FALSE; } bResult=lpfEnumProcesses(aiPID,iCb,&iCbneeded); if(!bResult) { // Unable to get process list, EnumProcesses failed FreeLibrary(hInstLib); return FALSE; } // How many processes are there? iNumProc=iCbneeded/sizeof(DWORD); // Get and match the name of each process for(i=0;i<iNumProc;i++) { // Get the (module) name for this process strcpy(szName,"Unknown"); // First, get a handle to the process hProc=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE, aiPID[i]); // Now, get the process name if(hProc) { if(lpfEnumProcessModules(hProc,&hMod,sizeof(hMod),&iCbneeded) ) { iLen=lpfGetModuleBaseName(hProc,hMod,szName,MAX_PATH); } } CloseHandle(hProc); // We will match regardless of lower or upper case #ifdef __BORLANDC__ if(strcmp(strupr(szName),szToTermUpper)==0) #else if(strcmp(_strupr(szName),szToTermUpper)==0) #endif { // Process found iFound=1; FreeLibrary(hInstLib); return TRUE; } } } if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) { // Win/95 or 98 or ME hInstLib = LoadLibraryA("Kernel32.DLL"); if( hInstLib == NULL ) return FALSE; // Get procedure addresses. // We are linking to these functions of Kernel32 // explicitly, because otherwise a module using // this code would fail to load under Windows NT, // which does not have the Toolhelp32 // functions in the Kernel 32. lpfCreateToolhelp32Snapshot= (HANDLE(WINAPI *)(DWORD,DWORD)) GetProcAddress( hInstLib, "CreateToolhelp32Snapshot" ) ; lpfProcess32First= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32First" ) ; lpfProcess32Next= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32Next" ) ; lpfModule32First= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32First" ) ; lpfModule32Next= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32Next" ) ; if( lpfProcess32Next == NULL || lpfProcess32First == NULL || lpfModule32Next == NULL || lpfModule32First == NULL || lpfCreateToolhelp32Snapshot == NULL ) { FreeLibrary(hInstLib); return FALSE; } // The Process32.. and Module32.. routines return names in all uppercase // Get a handle to a Toolhelp snapshot of all the systems processes. hSnapShot = lpfCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ; if( hSnapShot == INVALID_HANDLE_VALUE ) { FreeLibrary(hInstLib); return FALSE; } // Get the first process' information. procentry.dwSize = sizeof(PROCESSENTRY32); bResult=lpfProcess32First(hSnapShot,&procentry); // While there are processes, keep looping and checking. while(bResult) { // Get a handle to a Toolhelp snapshot of this process. hSnapShotm = lpfCreateToolhelp32Snapshot( TH32CS_SNAPMODULE, procentry.th32ProcessID) ; if( hSnapShotm == INVALID_HANDLE_VALUE ) { CloseHandle(hSnapShot); FreeLibrary(hInstLib); return FALSE; } // Get the module list for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32First(hSnapShotm,&modentry); // While there are modules, keep looping and checking while(bResultm) { if(strcmp(modentry.szModule,szToTermUpper)==0) { // Process found iFound=1; // Found one, return TRUE CloseHandle(hSnapShotm); CloseHandle(hSnapShot); FreeLibrary(hInstLib); return TRUE; } else { // Look for next modules for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32Next(hSnapShotm,&modentry); } } //Keep looking CloseHandle(hSnapShotm); procentry.dwSize = sizeof(PROCESSENTRY32); bResult = lpfProcess32Next(hSnapShot,&procentry); } CloseHandle(hSnapShot); } if(iFound==0) { FreeLibrary(hInstLib); return FALSE; } FreeLibrary(hInstLib); return FALSE; }
static BOOL SB_Init(void) { HRESULT result; if (!lpdsound) { hmodule = LoadLibraryA("dsound.dll"); if (!hmodule) { ERR("Can't load dsound.dll !\n"); return 0; } lpDirectSoundCreate = (fnDirectSoundCreate)GetProcAddress(hmodule,"DirectSoundCreate"); if (!lpDirectSoundCreate) { /* CloseHandle(hmodule); */ ERR("Can't find DirectSoundCreate function !\n"); return 0; } result = (*lpDirectSoundCreate)(NULL,&lpdsound,NULL); if (result != DS_OK) { ERR("Unable to initialize Sound Subsystem err = %lx !\n",result); return 0; } /* FIXME: To uncomment when : - SetCooperative level is correctly implemented - an always valid and non changing handle to a windows (vga_hwnd) is available (this surely needs some work in vga.c) result = IDirectSound_SetCooperativeLevel(lpdsound,vga_hwnd,DSSCL_EXCLUSIVE|DSSCL_PRIORITY); if (result != DS_OK) { ERR("Can't set cooperative level !\n"); return 0; } */ /* Default format */ wav_fmt.wFormatTag = WAVE_FORMAT_PCM; wav_fmt.nChannels = 1; wav_fmt.nSamplesPerSec = 22050; wav_fmt.nAvgBytesPerSec = 22050; wav_fmt.nBlockAlign = 1; wav_fmt.wBitsPerSample = 8; wav_fmt.cbSize = 0; memset(&buf_desc,0,sizeof(DSBUFFERDESC)); buf_desc.dwSize = sizeof(DSBUFFERDESC); buf_desc.dwBufferBytes = DSBUFLEN; buf_desc.lpwfxFormat = &wav_fmt; result = IDirectSound_CreateSoundBuffer(lpdsound,&buf_desc,&lpdsbuf,NULL); if (result != DS_OK) { ERR("Can't create sound buffer !\n"); return 0; } result = IDirectSoundBuffer_Play(lpdsbuf,0, 0, DSBPLAY_LOOPING); if (result != DS_OK) { ERR("Can't start playing !\n"); return 0; } buf_off = 0; end_sound_loop = 0; SB_Thread = CreateThread(NULL, 0, SB_Poll, NULL, 0, NULL); TRACE("thread\n"); if (!SB_Thread) { ERR("Can't create thread !\n"); return 0; } } return 1; }
static void * xmlModulePlatformOpen(const char *name) { return LoadLibraryA(name); }
ReplayCreateStatus D3D12_CreateReplayDevice(const char *logfile, IReplayDriver **driver) { RDCDEBUG("Creating a D3D12 replay device"); WrappedIDXGISwapChain3::RegisterD3DDeviceCallback(GetD3D12DeviceIfAlloc); HMODULE lib = NULL; lib = LoadLibraryA("d3d12.dll"); if(lib == NULL) { RDCERR("Failed to load d3d12.dll"); return eReplayCreate_APIInitFailed; } lib = LoadLibraryA("dxgi.dll"); if(lib == NULL) { RDCERR("Failed to load dxgi.dll"); return eReplayCreate_APIInitFailed; } if(GetD3DCompiler() == NULL) { RDCERR("Failed to load d3dcompiler_??.dll"); return eReplayCreate_APIInitFailed; } D3D12InitParams initParams; RDCDriver driverFileType = RDC_D3D12; string driverName = "D3D12"; if(logfile) { auto status = RenderDoc::Inst().FillInitParams(logfile, driverFileType, driverName, (RDCInitParams *)&initParams); if(status != eReplayCreate_Success) return status; } // initParams.SerialiseVersion is guaranteed to be valid/supported since otherwise the // FillInitParams (which calls D3D12InitParams::Serialise) would have failed above, so no need to // check it here. if(initParams.MinimumFeatureLevel < D3D_FEATURE_LEVEL_11_0) initParams.MinimumFeatureLevel = D3D_FEATURE_LEVEL_11_0; ID3D12Device *dev = NULL; HRESULT hr = RENDERDOC_CreateWrappedD3D12Device(NULL, initParams.MinimumFeatureLevel, __uuidof(ID3D12Device), (void **)&dev); if(FAILED(hr)) { RDCERR("Couldn't create a d3d12 device :(."); return eReplayCreate_APIHardwareUnsupported; } WrappedID3D12Device *wrappedDev = (WrappedID3D12Device *)dev; if(logfile) wrappedDev->SetLogFile(logfile); wrappedDev->SetLogVersion(initParams.SerialiseVersion); RDCLOG("Created device."); D3D12Replay *replay = wrappedDev->GetReplay(); replay->SetProxy(logfile == NULL); *driver = (IReplayDriver *)replay; return eReplayCreate_Success; }
static void *ll_load (lua_State *L, const char *path) { HINSTANCE lib = LoadLibraryA(path); if (lib == NULL) pusherror(L); return lib; }
void set_low_priority(file_handle const& f) { // file prio is only supported on vista and up // so load the functions dynamically typedef enum _FILE_INFO_BY_HANDLE_CLASS { FileBasicInfo, FileStandardInfo, FileNameInfo, FileRenameInfo, FileDispositionInfo, FileAllocationInfo, FileEndOfFileInfo, FileStreamInfo, FileCompressionInfo, FileAttributeTagInfo, FileIdBothDirectoryInfo, FileIdBothDirectoryRestartInfo, FileIoPriorityHintInfo, FileRemoteProtocolInfo, MaximumFileInfoByHandleClass } FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS; typedef enum _PRIORITY_HINT { IoPriorityHintVeryLow = 0, IoPriorityHintLow, IoPriorityHintNormal, MaximumIoPriorityHintType } PRIORITY_HINT; typedef struct _FILE_IO_PRIORITY_HINT_INFO { PRIORITY_HINT PriorityHint; } FILE_IO_PRIORITY_HINT_INFO, *PFILE_IO_PRIORITY_HINT_INFO; typedef BOOL (WINAPI *SetFileInformationByHandle_t)(HANDLE hFile, FILE_INFO_BY_HANDLE_CLASS FileInformationClass, LPVOID lpFileInformation, DWORD dwBufferSize); static SetFileInformationByHandle_t SetFileInformationByHandle = NULL; static bool failed_kernel_load = false; if (failed_kernel_load) return; if (SetFileInformationByHandle == NULL) { HMODULE kernel32 = LoadLibraryA("kernel32.dll"); if (kernel32 == NULL) { failed_kernel_load = true; return; } SetFileInformationByHandle = (SetFileInformationByHandle_t)GetProcAddress(kernel32, "SetFileInformationByHandle"); if (SetFileInformationByHandle == NULL) { failed_kernel_load = true; return; } } TORRENT_ASSERT(SetFileInformationByHandle); FILE_IO_PRIORITY_HINT_INFO io_hint; io_hint.PriorityHint = IoPriorityHintLow; SetFileInformationByHandle(f->native_handle(), FileIoPriorityHintInfo, &io_hint, sizeof(io_hint)); }
/* load the graphics driver */ static const USER_DRIVER *load_driver(void) { char buffer[MAX_PATH], libname[32], *name, *next; HKEY hkey; void *ptr; HMODULE graphics_driver; USER_DRIVER *driver, *prev; strcpy( buffer, "x11" ); /* default value */ /* @@ Wine registry key: HKCU\Software\Wine\Drivers */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey )) { DWORD type, count = sizeof(buffer); RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count ); RegCloseKey( hkey ); } name = buffer; while (name) { next = strchr( name, ',' ); if (next) *next++ = 0; snprintf( libname, sizeof(libname), "wine%s.drv", name ); if ((graphics_driver = LoadLibraryA( libname )) != 0) break; name = next; } if (!graphics_driver) driver_load_error = GetLastError(); driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) ); *driver = null_driver; if (graphics_driver) { #define GET_USER_FUNC(name) \ do { if ((ptr = GetProcAddress( graphics_driver, #name ))) driver->p##name = ptr; } while(0) GET_USER_FUNC(ActivateKeyboardLayout); GET_USER_FUNC(Beep); GET_USER_FUNC(GetAsyncKeyState); GET_USER_FUNC(GetKeyNameText); GET_USER_FUNC(GetKeyboardLayout); GET_USER_FUNC(GetKeyboardLayoutList); GET_USER_FUNC(GetKeyboardLayoutName); GET_USER_FUNC(LoadKeyboardLayout); GET_USER_FUNC(MapVirtualKeyEx); GET_USER_FUNC(SendInput); GET_USER_FUNC(ToUnicodeEx); GET_USER_FUNC(UnloadKeyboardLayout); GET_USER_FUNC(VkKeyScanEx); GET_USER_FUNC(SetCursor); GET_USER_FUNC(GetCursorPos); GET_USER_FUNC(SetCursorPos); GET_USER_FUNC(ClipCursor); GET_USER_FUNC(GetScreenSaveActive); GET_USER_FUNC(SetScreenSaveActive); GET_USER_FUNC(AcquireClipboard); GET_USER_FUNC(EmptyClipboard); GET_USER_FUNC(SetClipboardData); GET_USER_FUNC(GetClipboardData); GET_USER_FUNC(CountClipboardFormats); GET_USER_FUNC(EnumClipboardFormats); GET_USER_FUNC(IsClipboardFormatAvailable); GET_USER_FUNC(RegisterClipboardFormat); GET_USER_FUNC(GetClipboardFormatName); GET_USER_FUNC(EndClipboardUpdate); GET_USER_FUNC(ChangeDisplaySettingsEx); GET_USER_FUNC(EnumDisplayMonitors); GET_USER_FUNC(EnumDisplaySettingsEx); GET_USER_FUNC(GetMonitorInfo); GET_USER_FUNC(CreateDesktopWindow); GET_USER_FUNC(CreateWindow); GET_USER_FUNC(DestroyWindow); GET_USER_FUNC(GetDC); GET_USER_FUNC(MsgWaitForMultipleObjectsEx); GET_USER_FUNC(ReleaseDC); GET_USER_FUNC(ScrollDC); GET_USER_FUNC(SetCapture); GET_USER_FUNC(SetFocus); GET_USER_FUNC(SetParent); GET_USER_FUNC(SetWindowPos); GET_USER_FUNC(SetWindowRgn); GET_USER_FUNC(SetWindowIcon); GET_USER_FUNC(SetWindowStyle); GET_USER_FUNC(SetWindowText); GET_USER_FUNC(SysCommand); GET_USER_FUNC(WindowMessage); #undef GET_USER_FUNC } prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver ); if (prev != &lazy_load_driver) { /* another thread beat us to it */ HeapFree( GetProcessHeap(), 0, driver ); FreeLibrary( graphics_driver ); driver = prev; } return driver; }
HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device) { IDXGIFactory *factory; HRESULT hr; TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d, device %p\n", adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version, device); if (adapter) { IDXGIAdapter_AddRef(adapter); hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); if (FAILED(hr)) { WARN("Failed to get dxgi factory, returning %#x\n", hr); return hr; } } else { hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory); if (FAILED(hr)) { WARN("Failed to create dxgi factory, returning %#x\n", hr); return hr; } switch(driver_type) { case D3D10_DRIVER_TYPE_HARDWARE: { hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter); if (FAILED(hr)) { WARN("No adapters found, returning %#x\n", hr); IDXGIFactory_Release(factory); return hr; } break; } case D3D10_DRIVER_TYPE_NULL: FIXME("NULL device not implemented, falling back to refrast\n"); case D3D10_DRIVER_TYPE_REFERENCE: { HMODULE refrast = LoadLibraryA("d3d10ref.dll"); if (!refrast) { WARN("Failed to load refrast, returning E_FAIL\n"); IDXGIFactory_Release(factory); return E_FAIL; } hr = IDXGIFactory_CreateSoftwareAdapter(factory, refrast, &adapter); FreeLibrary(refrast); if (FAILED(hr)) { WARN("Failed to create a software adapter, returning %#x\n", hr); IDXGIFactory_Release(factory); return hr; } break; } case D3D10_DRIVER_TYPE_SOFTWARE: { if (!swrast) { WARN("Software device requested, but NULL swrast passed, returning E_FAIL\n"); IDXGIFactory_Release(factory); return E_FAIL; } hr = IDXGIFactory_CreateSoftwareAdapter(factory, swrast, &adapter); if (FAILED(hr)) { WARN("Failed to create a software adapter, returning %#x\n", hr); IDXGIFactory_Release(factory); return hr; } break; } } } hr = D3D10CoreCreateDevice(factory, adapter, flags, 0, device); IDXGIAdapter_Release(adapter); IDXGIFactory_Release(factory); if (FAILED(hr)) { WARN("Failed to create a device, returning %#x\n", hr); return hr; } TRACE("Created ID3D10Device %p\n", *device); return hr; }
bool xGL2RenderApi::__createD10Device() { HRESULT hr = S_OK;; UINT width = m_Width; UINT height = m_Height; if(width == 0 || height == 0) { RECT rc; GetClientRect( m_hMainWnd, &rc ); width = rc.right - rc.left; height = rc.bottom - rc.top; m_Width = width; m_Height = height; } UINT createDeviceFlags = 0; #ifdef _DEBUG createDeviceFlags |= GL2_CREATE_DEVICE_DEBUG; #endif GL2_DRIVER_TYPE driverTypes[] = { GL2_DRIVER_TYPE_HARDWARE, GL2_DRIVER_TYPE_REFERENCE, GL2_DRIVER_TYPE_REFERENCE, GL2_DRIVER_TYPE_REFERENCE, GL2_DRIVER_TYPE_REFERENCE, GL2_DRIVER_TYPE_REFERENCE, }; HMODULE hDriverModule[]= { NULL, LoadLibraryA( "GL2WARP_beta.DLL" ), LoadLibraryW( _XEVOL_ABSPATH_(L"GL2WARP_beta.DLL") ), LoadLibraryA( "GL2WARP.DLL" ), LoadLibraryW( _XEVOL_ABSPATH_(L"GL2WARP.DLL" ) ), NULL, }; UINT numDriverTypes = sizeof(driverTypes) / sizeof(driverTypes[0]); m_Width = width; m_Height = height; ZeroMemory( &m_swapChainDesc, sizeof(m_swapChainDesc) ); m_swapChainDesc.BufferCount = 1; m_swapChainDesc.BufferDesc.Width = width; m_swapChainDesc.BufferDesc.Height = height; m_swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; m_swapChainDesc.BufferDesc.RefreshRate.Numerator = 60; m_swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; m_swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; m_swapChainDesc.OutputWindow = m_hMainWnd; m_swapChainDesc.SampleDesc.Count = 1; m_swapChainDesc.SampleDesc.Quality = 0; m_swapChainDesc.Windowed = TRUE; //Find all Adapter IDXGIAdapter * pAdapter; std::vector<IDXGIAdapter*> vAdapters; IDXGIFactory* pDXGIFactory = NULL; hr = CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pDXGIFactory) ); while(pDXGIFactory->EnumAdapters(vAdapters.size(), &pAdapter) != DXGI_ERROR_NOT_FOUND) { vAdapters.push_back(pAdapter); } for(int i = 0 ; i < vAdapters.size() ; i ++) { IDXGIAdapter* pAdapter = vAdapters[i]; DXGI_ADAPTER_DESC desc; pAdapter->GetDesc(&desc); std::vector<IDXGIOutput*> vOutputers; IDXGIOutput* pOutputer = NULL; while(pAdapter->EnumOutputs(vOutputers.size(), &pOutputer) != DXGI_ERROR_NOT_FOUND) { vOutputers.push_back(pOutputer); DXGI_OUTPUT_DESC odesc; pOutputer->GetDesc(&odesc); continue; } for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) { m_driverType = driverTypes[driverTypeIndex]; HMODULE hModule = hDriverModule[driverTypeIndex]; hr = GL2CreateDeviceAndSwapChain( pAdapter, m_driverType, hModule , createDeviceFlags, GL2_SDK_VERSION, &m_swapChainDesc, &m_pSwapChain, &m_pGL2Device ); if( SUCCEEDED( hr ) ) break; } if(m_pGL2Device && m_pSwapChain) { break; } } if( FAILED(hr) ) return false; m_RenderWindow = new xGL2RenderWindow(m_hMainWnd , this); m_RenderWindow->create(m_pSwapChain , width , height); __resetViewPort(); setRenderView(m_RenderWindow); GL2_BLEND_DESC BlendState; ZeroMemory(&BlendState, sizeof(GL2_BLEND_DESC)); BlendState.BlendEnable[0] = FALSE; BlendState.RenderTargetWriteMask[0] = GL2_COLOR_WRITE_ENABLE_ALL; ID3D10BlendState* g_pBlendStateNoBlend = NULL; ID3D10RasterizerState* g_pRasterizerStateNoCull = NULL; m_pGL2Device->CreateBlendState(&BlendState, &g_pBlendStateNoBlend) ; // Create a rasterizer state to disable culling GL2_RASTERIZER_DESC RSDesc; RSDesc.FillMode = GL2_FILL_SOLID; RSDesc.CullMode = GL2_CULL_NONE; RSDesc.FrontCounterClockwise = TRUE; RSDesc.DepthBias = 0; RSDesc.DepthBiasClamp = 0; RSDesc.SlopeScaledDepthBias = 0; RSDesc.ScissorEnable = FALSE; RSDesc.MultisampleEnable = TRUE; RSDesc.AntialiasedLineEnable = FALSE; m_pGL2Device->CreateRasterizerState(&RSDesc, &g_pRasterizerStateNoCull) ; m_pGL2Device->OMSetBlendState(g_pBlendStateNoBlend, 0, 0xffffffff); m_pGL2Device->RSSetState(g_pRasterizerStateNoCull); return true; }
// Load necessary libraries (DLLs) // static GLFWbool loadLibraries(void) { _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll"); if (!_glfw.win32.winmm.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to load winmm.dll"); return GLFW_FALSE; } _glfw.win32.winmm.GetTime = (PFN_timeGetTime) GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime"); _glfw.win32.user32.instance = LoadLibraryA("user32.dll"); if (!_glfw.win32.user32.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to load user32.dll"); return GLFW_FALSE; } _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware) GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware"); _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx) GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling) GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext) GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext"); _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow) GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow"); _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi) GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi"); _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll"); if (_glfw.win32.dinput8.instance) { _glfw.win32.dinput8.Create = (PFN_DirectInput8Create) GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create"); } { int i; const char* names[] = { "xinput1_4.dll", "xinput1_3.dll", "xinput9_1_0.dll", "xinput1_2.dll", "xinput1_1.dll", NULL }; for (i = 0; names[i]; i++) { _glfw.win32.xinput.instance = LoadLibraryA(names[i]); if (_glfw.win32.xinput.instance) { _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities) GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities"); _glfw.win32.xinput.GetState = (PFN_XInputGetState) GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState"); break; } } } _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll"); if (_glfw.win32.dwmapi.instance) { _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled) GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled"); _glfw.win32.dwmapi.Flush = (PFN_DwmFlush) GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush"); _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow) GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow"); } _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll"); if (_glfw.win32.shcore.instance) { _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness) GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness"); _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor) GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor"); } _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll"); if (_glfw.win32.ntdll.instance) { _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo) GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo"); } return GLFW_TRUE; }
DWORD FindWDIGEST_dll() { unsigned char digest1[] = "\x8B\xFF\x55\x8B\xEC\x56\xBE\x00\x56\xFF" "\x00\x00\x8B\x0D\x00\x00\x8B\x45\x08\x89\x08\xC7\x40\x04"; DWORD v4 = 0; // [sp+8h] [bp-48h]@1 int v9; // [sp+30h] [bp-20h]@1 HMODULE hModule = LoadLibraryA("wdigest.dll"); if (!hModule) { return 0; } MODULEINFO modinfo; if (!GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO))) { return 0; } DWORD dwRet = 0; DWORD dwDllBase = (DWORD)modinfo.lpBaseOfDll; for (DWORD i = 0; i < 2; ++i) { int ucb = 7; BOOL bNext = FALSE; DWORD j = 0; for (j = 0; ; ++j) { if (j < modinfo.SizeOfImage) { if (IsBadReadPtr((const void *)(j + dwDllBase), 7)) { continue; } if (!memcmp((const void *)(j + dwDllBase), digest1, 7)) { bNext = TRUE; } if (!bNext) { continue; } bNext = FALSE; void *lp = (void *)(j + dwDllBase + 7 + 4); if (IsBadReadPtr((const void *)(j + dwDllBase + 7 + 4), 2)) { continue; } if (!memcmp(lp, digest1 + 8, 2)) { bNext = TRUE; } if (!bNext) continue; bNext = FALSE; lp = (char *)lp + 2 + 5; if (IsBadReadPtr(lp, 2u)) continue; if (!memcmp(lp, digest1 + 0xc, 2u)) { bNext = TRUE; } if (!bNext) continue; v4 = *(DWORD *)((char *)lp + 2); bNext = FALSE; lp = (char *)lp + 6; if (IsBadReadPtr(lp, 8u)) continue; if (!memcmp(lp, digest1 + 0x10, 8u)) bNext = TRUE; if (!bNext) continue; v9 = *((DWORD *)lp + 2); if (!bNext) continue; } break; } if (!bNext) { return 0; } else { dwDllBase += j + 110; } } dwRet = v4; return dwRet; }
// address: 0x401000 void _start(unsigned int param1, __size32 param2) { unsigned char cl; // r9 __size32 eax; // r24 __size32 eax_1; // r24{27} int eax_2; // r24{245} int eax_3; // r24{162} __size32 ebp; // r29 unsigned int ebx; // r27 unsigned short *ebx_1; // r27 unsigned int ebx_10; // r27{261} union { unsigned int x11; unsigned short * x12; } ebx_11; // r27{335} __size32 ebx_12; // r27{300} union { unsigned int x11; unsigned short * x12; } ebx_13; // r27{323} union { unsigned int x11; unsigned short * x12; } ebx_14; // r27{292} union { unsigned int x11; void * x12; } ebx_15; // r27{347} unsigned int ebx_2; // r27{34} unsigned int ebx_3; // r27{44} unsigned int ebx_4; // r27{112} __size32 ebx_5; // r27{168} __size32 ebx_6; // r27{172} unsigned short *ebx_7; // r27{305} unsigned int ebx_8; // r27{239} unsigned int ebx_9; // r27{282} int ecx; // r25 __size32 *ecx_1; // r25 __size32 *ecx_2; // r25{259} __size32 edi; // r31 int edx; // r26 void *edx_1; // r26 __size32 esi; // r30 __size32 esi_1; // r30{12} __size32 *esi_10; // r30{221} __size32 *esi_11; // r30{219} __size32 *esi_12; // r30{214} __size32 esi_13; // r30{83} unsigned int esi_14; // r30{283} unsigned int esi_15; // r30{270} unsigned int esi_16; // r30{262} __size32 *esi_17; // r30{337} __size32 *esi_18; // r30{307} __size32 *esi_19; // r30{294} __size32 esi_2; // r30{72} __size32 *esi_20; // r30{349} __size32 esi_3; // r30{253} unsigned int esi_4; // r30{94} unsigned int esi_5; // r30{108} unsigned int esi_6; // r30{132} __size32 *esi_7; // r30{150} __size32 esi_8; // r30{177} __size32 *esi_9; // r30{180} int esp; // r28 int local1; // m[esp - 52] int local12; // m[esp - 48] __size32 *local2; // m[esp - 52] int local21; // m[esp - 52]{355} __size32 *local22; // m[esp - 52]{374} unsigned int local23; // m[esp - 84]{377} unsigned int local24; // ebx_8{239} __size32 local25; // esi_13{247} __size32 local26; // esi_3{253} unsigned int local27; // ebx_10{261} unsigned int local28; // esi_16{262} unsigned int local29; // esi_15{270} unsigned int local3; // m[esp - 84] unsigned int local30; // ebx_9{282} unsigned int local31; // esi_14{283} union { unsigned int x11; unsigned short * x12; } local32; // ebx_14{292} __size32 *local33; // esi_19{294} unsigned int local34; // param1{360} __size32 local35; // ebx_12{300} __size32 *local36; // esi_18{307} unsigned int local37; // local3{369} union { unsigned int x11; unsigned short * x12; } local38; // ebx_11{335} __size32 *local39; // esi_17{337} unsigned int local40; // local3{372} int local41; // eax_3{344} union { unsigned int x11; void * x12; } local42; // ebx_15{347} __size32 *local43; // esi_20{349} union { void * x13; int x14; } local5; // m[esp - 80] esi_1 = 0; eax_1 = AddAce(); local25 = esi_1; local34 = param1; ebx_2 = eax_1 + 37; eax = AreAllAccessesGranted(); local24 = ebx_2; if (eax == 0) { ebx_3 = eax_1 + 3; local24 = ebx_3; } ebx_8 = local24; CloseHandle(89); local27 = ebx_8; ecx = VirtualProtect(); /* Warning: also results in edx */ eax = 0; edi = param2; do { eax_2 = eax; esi_13 = local25; local26 = esi_13; if (esi_13 == ebx_8) { esi_2 = 0; local26 = esi_2; } esi_3 = local26; edi += edx * 9; cl = *(esi_3 + 0x404000); ecx = ecx >> 8 & 0xffffff | (cl); *(char*)(eax_2 + 0x401278) = *(eax_2 + 0x401278) ^ cl; eax = eax_2 + 1; esi_13 = esi_3 + 1; local25 = esi_13; } while (eax_2 + 1 < 0x1420); ecx_1 = 0x402558; esi_4 = ebx_8 + (esi_3 + 1) * 4; edi = 0xf0400ff8; local1 = 0; local28 = esi_4; do { ecx_2 = ecx_1; ebx_10 = local27; esi_16 = local28; local21 = local1; eax = *(ecx_2 + 4); edx_1 = ecx_2 + 8; local30 = ebx_10; local31 = esi_16; if ((int)((eax - 8) / 2) > 0) { esi_5 = (eax - 8) / 2; local29 = esi_5; do { esi_15 = local29; eax = *(unsigned short*)edx_1; ebx_4 = eax & 0xf000; local30 = ebx_4; if ((eax & 0xf000) == 0x3000) { eax = (eax & 0xfff) + *ecx_2; *(__size32*)(eax + 0x400ff8) = *(eax + 0x400ff8) - 0xfbff008; } edx_1++; esi_6 = esi_15 - 1; local29 = esi_6; local31 = esi_6; } while (esi_15 != 1); } ebx_9 = local30; esi_14 = local31; eax = *(ecx_2 + 4); ecx_1 = ecx_2 + eax; cl = (unsigned char) ecx_2 + eax; local1 = local21 + eax; local27 = ebx_9; local28 = esi_14; local32 = ebx_9; local41 = eax; local42 = ebx_9; } while ((unsigned int)(local21 + eax) < 228); flags = SUBFLAGS32(*0x401d64, 0, global11); esi_7 = 0x401d54; local2 = 0x401d54; local33 = esi_7; local43 = esi_7; if (*0x401d64 != 0) { do { ebx_14 = local32; esi_19 = local33; param1 = local34; edx = *(esi_19 + 12); eax_3 = LoadLibraryA(edx + 0x400ff8); /* Warning: also results in ecx_1 */ local37 = param1; local38 = ebx_14; local39 = esi_19; local40 = param1; edi = eax_3; if (eax_3 != 0) { ebx_5 = *esi_19; local35 = ebx_5; if (ebx_5 == 0) { ebx_6 = *(esi_19 + 16); local35 = ebx_6; } ebx_12 = local35; ebx_1 = ebx_12 + 0x400ff8; esi_8 = *(esi_19 + 16); eax = *(ebx_12 + 0x400ff8); esi_9 = esi_8 + 0x400ff8; flags = LOGICALFLAGS32(eax); local36 = esi_9; if (eax != 0) { do { ebx_7 = ebx_1; esi_18 = local36; if (flags) { cl = (unsigned char) eax + 0x400ffa; eax = GetProcAddress(edi, eax + 0x400ffa); /* Warning: also results in ecx_1 */ } else { eax = *(unsigned short*)ebx_7; eax = GetProcAddress(edi, eax); /* Warning: also results in ecx_1 */ edi = eax_3; } ebx_1 = ebx_7 + 4; *(__size32*)esi_18 = eax; eax = *(ebx_7 + 4); esi_12 = esi_18 + 4; flags = LOGICALFLAGS32(eax); local36 = esi_12; local37 = local3; } while (eax != 0); } eax_3 = eax; ebx_13 = ebx_1; local3 = local37; esi_11 = local2; local38 = ebx_13; local39 = esi_11; local40 = local3; } ebx_11 = local38; esi_17 = local39; local3 = local40; esi_10 = esi_17 + 20; tmp1 = *(esi_17 + 36); flags = SUBFLAGS32(*(esi_17 + 36), 0, tmp1); local2 = esi_17 + 20; local32 = ebx_11; local33 = esi_10; local34 = local3; local41 = eax_3; local42 = ebx_11; local43 = esi_10; } while (*(esi_17 + 36) != 0); } eax_3 = local41; ebx_15 = local42; esi_20 = local43; (*0x401a48)(local23, local5, pc, 0x401000, 0x3000, 64, esp - 40, -1, local22, local12, 0, 0, 0, 0, param2, esi, ebp, ebx, cl, eax_3, ecx_1, 0x401a48, ebx_15, 0x400ff8, esi_20, edi, flags, ZF, CF); *(__size32*)(esp - 4) = 0; ExitProcess(*(esp - 4)); return; }
// Load necessary libraries (DLLs) // static GLFWbool loadLibraries(void) { _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll"); if (!_glfw.win32.winmm.instance) { _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to load winmm.dll"); return GLFW_FALSE; } _glfw.win32.winmm.timeGetTime = (TIMEGETTIME_T) GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime"); _glfw.win32.user32.instance = LoadLibraryA("user32.dll"); if (!_glfw.win32.user32.instance) { _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to load user32.dll"); return GLFW_FALSE; } _glfw.win32.user32.SetProcessDPIAware = (SETPROCESSDPIAWARE_T) GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware"); _glfw.win32.user32.ChangeWindowMessageFilterEx = (CHANGEWINDOWMESSAGEFILTEREX_T) GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll"); if (_glfw.win32.dinput8.instance) { _glfw.win32.dinput8.DirectInput8Create = (DIRECTINPUT8CREATE_T) GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create"); } { int i; const char* names[] = { "xinput1_4.dll", "xinput1_3.dll", "xinput9_1_0.dll", "xinput1_2.dll", "xinput1_1.dll", NULL }; for (i = 0; names[i]; i++) { _glfw.win32.xinput.instance = LoadLibraryA(names[i]); if (_glfw.win32.xinput.instance) { _glfw.win32.xinput.XInputGetCapabilities = (XINPUTGETCAPABILITIES_T) GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities"); _glfw.win32.xinput.XInputGetState = (XINPUTGETSTATE_T) GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState"); break; } } } _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll"); if (_glfw.win32.dwmapi.instance) { _glfw.win32.dwmapi.DwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED_T) GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled"); _glfw.win32.dwmapi.DwmFlush = (DWMFLUSH_T) GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush"); } _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll"); if (_glfw.win32.shcore.instance) { _glfw.win32.shcore.SetProcessDpiAwareness = (SETPROCESSDPIAWARENESS_T) GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness"); } return GLFW_TRUE; }
static bool SSL_library_load(void) { /* Load Library Pointers */ if (bSslInitDone) return true; WaitForSingleObject(g_hSslMutex, INFINITE); if (!bSslInitDone) { g_hOpenSSLCrypto = LoadLibraryA("libeay32.dll"); g_hOpenSSL = LoadLibraryA("ssleay32.dll"); if (g_hOpenSSL && g_hOpenSSLCrypto) { // load function pointers #define LOAD_FN(struc,lib, name) struc.##name = (pfn##name)GetProcAddress(lib, #name); LOAD_FN(g_OpenSSL, g_hOpenSSLCrypto, RAND_screen); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_connect); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_free); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_get_error); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_library_init); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_load_error_strings); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_new); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_peek); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_pending); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_read); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_write); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_set_fd); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_shutdown); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_CTX_free); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_CTX_new); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_CTX_ctrl); LOAD_FN(g_OpenSSL, g_hOpenSSLCrypto, CRYPTO_set_mem_functions); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSLv23_client_method); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_get_current_cipher); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_CIPHER_get_name); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_get_peer_certificate); LOAD_FN(g_OpenSSL, g_hOpenSSL, SSL_get_peer_cert_chain); LOAD_FN(g_OpenSSL, g_hOpenSSLCrypto, CRYPTO_free); LOAD_FN(g_OpenSSL, g_hOpenSSLCrypto, X509_free); LOAD_FN(g_OpenSSL, g_hOpenSSLCrypto, i2d_X509); HINSTANCE hCrypt = LoadLibraryA("crypt32.dll"); if (hCrypt) { LOAD_FN(g_Crypt, hCrypt, CertGetCertificateChain); LOAD_FN(g_Crypt, hCrypt, CertFreeCertificateChain); LOAD_FN(g_Crypt, hCrypt, CertFreeCertificateContext); LOAD_FN(g_Crypt, hCrypt, CertVerifyCertificateChainPolicy); LOAD_FN(g_Crypt, hCrypt, CertOpenStore); LOAD_FN(g_Crypt, hCrypt, CertCloseStore); LOAD_FN(g_Crypt, hCrypt, CertAddCertificateContextToStore); LOAD_FN(g_Crypt, hCrypt, CertCreateCertificateContext); } // init OpenSSL g_OpenSSL.SSL_library_init(); g_OpenSSL.SSL_load_error_strings(); g_OpenSSL.CRYPTO_set_mem_functions(mir_calloc, mir_realloc, mir_free); // FIXME check errors bSslInitDone = true; } else { SSL_library_unload(); } } ReleaseMutex(g_hSslMutex); return bSslInitDone; }
void uv_winapi_init() { HMODULE ntdll_module; HMODULE kernel32_module; HMODULE powrprof_module; ntdll_module = GetModuleHandleA("ntdll.dll"); if (ntdll_module == NULL) { uv_fatal_error(GetLastError(), "GetModuleHandleA"); } pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( ntdll_module, "RtlNtStatusToDosError"); if (pRtlNtStatusToDosError == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } pNtDeviceIoControlFile = (sNtDeviceIoControlFile) GetProcAddress( ntdll_module, "NtDeviceIoControlFile"); if (pNtDeviceIoControlFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress( ntdll_module, "NtQueryInformationFile"); if (pNtQueryInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress( ntdll_module, "NtSetInformationFile"); if (pNtSetInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryVolumeInformationFile = (sNtQueryVolumeInformationFile) GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile"); if (pNtQueryVolumeInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryDirectoryFile = (sNtQueryDirectoryFile) GetProcAddress(ntdll_module, "NtQueryDirectoryFile"); if (pNtQueryVolumeInformationFile == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress( ntdll_module, "NtQuerySystemInformation"); if (pNtQuerySystemInformation == NULL) { uv_fatal_error(GetLastError(), "GetProcAddress"); } kernel32_module = GetModuleHandleA("kernel32.dll"); if (kernel32_module == NULL) { uv_fatal_error(GetLastError(), "GetModuleHandleA"); } pGetQueuedCompletionStatusEx = (sGetQueuedCompletionStatusEx) GetProcAddress( kernel32_module, "GetQueuedCompletionStatusEx"); pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes) GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes"); pCreateSymbolicLinkW = (sCreateSymbolicLinkW) GetProcAddress(kernel32_module, "CreateSymbolicLinkW"); pCancelIoEx = (sCancelIoEx) GetProcAddress(kernel32_module, "CancelIoEx"); pInitializeConditionVariable = (sInitializeConditionVariable) GetProcAddress(kernel32_module, "InitializeConditionVariable"); pSleepConditionVariableCS = (sSleepConditionVariableCS) GetProcAddress(kernel32_module, "SleepConditionVariableCS"); pSleepConditionVariableSRW = (sSleepConditionVariableSRW) GetProcAddress(kernel32_module, "SleepConditionVariableSRW"); pWakeAllConditionVariable = (sWakeAllConditionVariable) GetProcAddress(kernel32_module, "WakeAllConditionVariable"); pWakeConditionVariable = (sWakeConditionVariable) GetProcAddress(kernel32_module, "WakeConditionVariable"); pCancelSynchronousIo = (sCancelSynchronousIo) GetProcAddress(kernel32_module, "CancelSynchronousIo"); pGetFinalPathNameByHandleW = (sGetFinalPathNameByHandleW) GetProcAddress(kernel32_module, "GetFinalPathNameByHandleW"); powrprof_module = LoadLibraryA("powrprof.dll"); if (powrprof_module != NULL) { pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification) GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); } }
/************************************************************************* * InternalExtractIcon [SHELL.39] * * This abortion is called directly by Progman */ HGLOBAL16 WINAPI InternalExtractIcon16(HINSTANCE16 hInstance, LPCSTR lpszExeFileName, UINT16 nIconIndex, WORD n ) { HGLOBAL16 hRet = 0; HICON16 *RetPtr = NULL; OFSTRUCT ofs; HFILE hFile; TRACE("(%04x,file %s,start %d,extract %d\n", hInstance, lpszExeFileName, nIconIndex, n); if( !n ) return 0; hFile = OpenFile( lpszExeFileName, &ofs, OF_READ|OF_EXIST ); hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n); RetPtr = (HICON16*)GlobalLock16(hRet); if (hFile == HFILE_ERROR) { /* not found - load from builtin module if available */ HINSTANCE hInst = (HINSTANCE)LoadLibrary16(lpszExeFileName); if (hInst < 32) /* hmm, no Win16 module - try Win32 :-) */ hInst = LoadLibraryA(lpszExeFileName); if (hInst) { int i; for (i=nIconIndex; i < nIconIndex + n; i++) RetPtr[i-nIconIndex] = (HICON16)LoadIconA(hInst, (LPCSTR)(DWORD)i); FreeLibrary(hInst); return hRet; } GlobalFree16( hRet ); return 0; } if (nIconIndex == (UINT16)-1) /* get number of icons */ { RetPtr[0] = PrivateExtractIconsA( ofs.szPathName, -1, 0, 0, NULL, 0, 0, 0 ); } else { HRESULT res; HICON *icons; icons = HeapAlloc( GetProcessHeap(), 0, n * sizeof(*icons) ); res = PrivateExtractIconsA( ofs.szPathName, nIconIndex, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), icons, 0, n, 0 ); if (!res) { int i; for (i = 0; i < n; i++) RetPtr[i] = (HICON16)icons[i]; } else { GlobalFree16( hRet ); hRet = 0; } HeapFree( GetProcessHeap(), 0, icons ); } return hRet; }
//============================================================================= // エントリー関数 //============================================================================= int APIENTRY WinMain(HINSTANCE _instanceHandle ,HINSTANCE _instanceHandlePrev, LPSTR _cmdLine, int _cmdShow) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); UNREFERENCED_PARAMETER(_instanceHandlePrev); UNREFERENCED_PARAMETER(_cmdLine); DWORD execLastTime; DWORD LastTimeFPS; DWORD currentTime; DWORD flameCount; WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0, 0, _instanceHandle, NULL, LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_WINDOW + 1), NULL, CLASS_NAME, NULL }; HWND windowHandle; MSG msg; // ウィンドウクラスの登録 RegisterClassEx(&wcex); // ウィンドウの作成 windowHandle = CreateWindowEx(0, CLASS_NAME, WINDOW_NAME, WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME, CW_USEDEFAULT, CW_USEDEFAULT, static_cast<int>(SCREEN_WIDTH + GetSystemMetrics(SM_CXDLGFRAME) * 2), static_cast<int>(SCREEN_HEIGHT + GetSystemMetrics(SM_CXDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION)), NULL, NULL, _instanceHandle, NULL); // フレームカウント初期化 timeBeginPeriod(1); // 分解能を設定 execLastTime = LastTimeFPS = timeGetTime(); currentTime = flameCount = 0; // ウインドウの表示(初期化処理の後に呼ばないと駄目) ShowWindow(windowHandle, _cmdShow); UpdateWindow(windowHandle); #ifndef _DEBUG LoadLibraryA("WiiYourself.dll"); #else LoadLibraryA("WiiYourself_debug.dll"); #endif LPDIRECT3D9 direct3D; // Direct3D9用デバイス LPDIRECT3DDEVICE9 device; // _deviceオブジェクト(描画に必要) D3DDISPLAYMODE displayMode; D3DPRESENT_PARAMETERS presentParameter; // Direct3Dオブジェクトの作成 direct3D = Direct3DCreate9(D3D_SDK_VERSION); direct3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode); // デバイスのプレゼンテーションパラメータの設定 //-------------------------------------------------------------------- // ワークをゼロクリア ZeroMemory(&presentParameter, sizeof(presentParameter)); // バックバッファの数をセット presentParameter.BackBufferCount = 1; //ゲーム画面サイズ presentParameter.BackBufferWidth = static_cast<int>SCREEN_WIDTH; presentParameter.BackBufferHeight = static_cast<int>SCREEN_HEIGHT; // バックバッファフォーマットはディスプレイモードに合わせて使う presentParameter.BackBufferFormat = displayMode.Format; // 映像信号に同期してフリップする presentParameter.SwapEffect = D3DSWAPEFFECT_DISCARD; // ウィンドウモード presentParameter.Windowed = TRUE; // デプスバッファ(Zバッファ)とステンシルバッファを作成 presentParameter.EnableAutoDepthStencil = TRUE; // デプスバッファの利用方法 // D3DFMT_D16 デプスバッファのみを16bitとして扱う // D3DFMT_D24S8 デプスバッファを24bit ステンシルバッファを8bitとして扱う presentParameter.AutoDepthStencilFormat = D3DFMT_D24S8; // ウィンドウモード presentParameter.FullScreen_RefreshRateInHz = 0; presentParameter.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //-------------------------------------------------------------------- direct3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, windowHandle, D3DCREATE_HARDWARE_VERTEXPROCESSING, &presentParameter, &device); CDebug* debug = new CDebug(); debug->Init(device); CKeyboard* keyboard = new CKeyboard(); keyboard->Init(_instanceHandle, windowHandle); CMouse* mouse = new CMouse(); mouse->Init(_instanceHandle, windowHandle); CWiiController* wiiController = new CWiiController(); // メッセージループ for (;;) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { // PostQuitMessage()が呼ばれたらループ終了 break; } else { // メッセージの翻訳とディスパッチ TranslateMessage(&msg); DispatchMessage(&msg); } } else { currentTime = timeGetTime(); if ((currentTime - LastTimeFPS) >= 500) { #ifdef _DEBUG countFPS = flameCount * 1000 / (currentTime - LastTimeFPS); #endif LastTimeFPS = currentTime; flameCount = 0; } if ((currentTime - execLastTime) >= (1000 / 60)) { execLastTime = currentTime ; keyboard->Update(); mouse->Update(); wiiController->update(); { // 本体 { debug->SetDebug("本体の加速度X [%f]\n", wiiController->getAccelerationX()); debug->SetDebug("本体の加速度Y [%f]\n", wiiController->getAccelerationY()); debug->SetDebug("本体の加速度Z [%f]\n", wiiController->getAccelerationZ()); debug->SetDebug("本体の回転角X [%f]\n", wiiController->getRotX()); debug->SetDebug("本体の回転角Y [%f]\n", wiiController->getRotY()); debug->SetDebug("本体の回転角Z [%f]\n", wiiController->getRotZ()); debug->SetDebug("本体の回転角の変異X [%f]\n", wiiController->getChangeRotX()); debug->SetDebug("本体の回転角の変異Y [%f]\n", wiiController->getChangeRotY()); debug->SetDebug("本体の回転角の変異Z [%f]\n", wiiController->getChangeRotZ()); debug->SetDebug("本体の角速度X [%f]\n", wiiController->getRotSpeedX()); debug->SetDebug("本体の角速度Y [%f]\n", wiiController->getRotSpeedY()); debug->SetDebug("本体の角速度Z [%f]\n", wiiController->getRotSpeedZ()); } // ヌンチャク { debug->SetDebug("ヌンチャクの加速度X [%f]\n", wiiController->getAccelerationNX()); debug->SetDebug("ヌンチャクの加速度Y [%f]\n", wiiController->getAccelerationNY()); debug->SetDebug("ヌンチャクの加速度Z [%f]\n", wiiController->getAccelerationNZ()); debug->SetDebug("ヌンチャクの回転角X [%f]\n", wiiController->getRotNX()); debug->SetDebug("ヌンチャクの回転角Y [%f]\n", wiiController->getRotNY()); debug->SetDebug("ヌンチャクの回転角Z [%f]\n", wiiController->getRotNZ()); debug->SetDebug("ヌンチャクの位置X [%f]\n", wiiController->getJoystick().x); debug->SetDebug("ヌンチャクの位置Y [%f]\n", wiiController->getJoystick().y); } // 赤外線 { debug->SetDebug("赤外線X [%f]\n", wiiController->getIR().x); debug->SetDebug("赤外線Y [%f]\n", wiiController->getIR().y); } debug->SetDebug("バッテリー残量[%d%]\n", wiiController->battery()); debug->SetDebug("モーションPlusの接続状態[%d]\n", wiiController->getMotionConnect()); /*if (wiiController->getTrigger(WC_A)) wiiController->rumble(true); if (wiiController->getTrigger(WC_B)) wiiController->rumble(false); if (wiiController->getTrigger(WC_UP)) wiiController->rumble((unsigned int)1000);*/ // Aボタン { if (wiiController->getPress(WC_A)) debug->SetDebug("A [ON]\n"); else debug->SetDebug("A [OFF]\n"); } // Bボタン { if (wiiController->getPress(WC_B)) debug->SetDebug("B [ON]\n"); else debug->SetDebug("B [OFF]\n"); } // Cボタン { if (wiiController->getPress(WC_C)) debug->SetDebug("C [ON]\n"); else debug->SetDebug("C [OFF]\n"); } // Zボタン { if (wiiController->getPress(WC_Z)) debug->SetDebug("Z [ON]\n"); else debug->SetDebug("Z [OFF]\n"); } // ↑ボタン { if (wiiController->getPress(WC_UP)) debug->SetDebug("UP [ON]\n"); else debug->SetDebug("UP [OFF]\n"); } // ↓ボタン { if (wiiController->getPress(WC_DOWN)) debug->SetDebug("DOWN [ON]\n"); else debug->SetDebug("DOWN [OFF]\n"); } // ←ボタン { if (wiiController->getPress(WC_LEFT)) debug->SetDebug("LEFT [ON]\n"); else debug->SetDebug("LEFT [OFF]\n"); } // →ボタン { if (wiiController->getPress(WC_RIGHT)) debug->SetDebug("RIGHT [ON]\n"); else debug->SetDebug("RIGHT [OFF]\n"); } // -ボタン { if (wiiController->getPress(WC_MINUS)) debug->SetDebug("MINUS [ON]\n"); else debug->SetDebug("MINUS [OFF]\n"); if(wiiController->getTrigger(WC_MINUS)) wiiController->rotSpeedCalibration(); } // +ボタン { if (wiiController->getPress(WC_PLUS)) debug->SetDebug("PLUS [ON]\n"); else debug->SetDebug("PLUS [OFF]\n"); if(wiiController->getTrigger(WC_PLUS)) wiiController->rotReset(); } // 1ボタン { if (wiiController->getPress(WC_ONE)) debug->SetDebug("ONE [ON]\n"); else debug->SetDebug("ONE [OFF]\n"); } // 2ボタン { if (wiiController->getPress(WC_TWO)) debug->SetDebug("TWO [ON]\n"); else debug->SetDebug("TWO [OFF]\n"); } // HOMEボタン { if (wiiController->getPress(WC_HOME)) debug->SetDebug("HOME [ON]\n"); else debug->SetDebug("HOME [OFF]\n"); } } // バックバッファ&Zバッファのクリア device->Clear(0, NULL, (D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER), D3DCOLOR_RGBA(255, 255, 255, 255), 1.0f, 0); // Direct3Dによる描画の開始 if (SUCCEEDED(device->BeginScene())) { CDebug::Draw(); // Direct3Dによる描画の終了 device->EndScene(); } // バックバッファとフロントバッファの入れ替える device->Present(NULL, NULL, NULL, NULL); flameCount++; } } } SAFE_DELETE(wiiController); SAFE_DELETE(keyboard); SAFE_DELETE(mouse); SAFE_DELETE(debug); // ウィンドウクラスの登録を解除 UnregisterClass(CLASS_NAME, wcex.hInstance); timeEndPeriod(1); // 分解能を戻す return static_cast<int>(msg.wParam); }
Direct3DBlitter::Direct3DBlitter(VideoBufferLocker vbl, QWidget *parent) : BlitterWidget(vbl, "Direct3D", 2, parent), confWidget(new QWidget), adapterSelector(new QComboBox), vblankblit_(new QCheckBox("Wait for vertical blank"), "direct3dblitter/vblankblit", false), flipping_(new QCheckBox("Exclusive full screen"), "direct3dblitter/flipping", false), vblankflip_(new QCheckBox("Flip during vertical blank"), "direct3dblitter/vblankflip", true), triplebuf_(new QCheckBox("Triple buffering"), "direct3dblitter/triplebuf", false), bf_(new QCheckBox("Bilinear filtering"), "direct3dblitter/bf", true), d3d9handle(NULL), d3d(NULL), device(NULL), vertexBuffer(NULL), stexture(NULL), vtexture(NULL), lastblank(0), backBufferWidth(1), backBufferHeight(1), clear(0), dhz(600), swapInterval(0), adapterIndex(0), exclusive(false), windowed(false), drawn(false) { setAttribute(Qt::WA_PaintOnScreen, true); if ((d3d9handle = LoadLibraryA("d3d9.dll"))) { typedef IDirect3D9* (WINAPI *Direct3DCreate9Ptr)(UINT); if (const Direct3DCreate9Ptr direct3DCreate9 = (Direct3DCreate9Ptr) GetProcAddress(d3d9handle, "Direct3DCreate9")) { if ((d3d = direct3DCreate9(D3D_SDK_VERSION))) { const unsigned adapterCount = d3d->GetAdapterCount(); D3DADAPTER_IDENTIFIER9 adapterId; for (unsigned i = 0; i < adapterCount; ++i) { if (FAILED(d3d->GetAdapterIdentifier(i, 0, &adapterId))) break; adapterSelector->addItem(adapterId.Description); } } } } if (adapterSelector->count() < 1) adapterSelector->addItem(QString()); QSettings settings; settings.beginGroup("direct3dblitter"); if ((adapterIndex = settings.value("adapterIndex", adapterIndex).toUInt()) >= static_cast<unsigned>(adapterSelector->count())) adapterIndex = 0; settings.endGroup(); { QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(0); if (adapterSelector->count() > 1) { QHBoxLayout *const hlayout = new QHBoxLayout; hlayout->addWidget(new QLabel(QString(tr("Direct3D adapter:")))); hlayout->addWidget(adapterSelector); mainLayout->addLayout(hlayout); } mainLayout->addWidget(vblankblit_.checkBox()); vblankblit_.checkBox()->setToolTip(tr("Prevents tearing. Does not work well on all systems.\n" "Ignored when exclusive full screen or DWM composition is active.")); mainLayout->addWidget(flipping_.checkBox()); flipping_.checkBox()->setToolTip(tr("Grabs device for better performance when full screen.")); { QHBoxLayout *const l = new QHBoxLayout; l->addSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin)); l->addWidget(vblankflip_.checkBox()); vblankflip_.checkBox()->setToolTip(tr("Prevents tearing. Recommended.")); mainLayout->addLayout(l); } mainLayout->addWidget(triplebuf_.checkBox()); triplebuf_.checkBox()->setToolTip(tr("Attempts to improve video flow at the cost of increased latency.")); mainLayout->addWidget(bf_.checkBox()); confWidget->setLayout(mainLayout); } vblankflip_.checkBox()->setEnabled(flipping_.checkBox()->isChecked()); connect(flipping_.checkBox(), SIGNAL(toggled(bool)), vblankflip_.checkBox(), SLOT(setEnabled(bool))); rejectSettings(); }
void functionHookedByCuckoo() { string functions[12][100]; string res(reinterpret_cast< char const* >(readResource(IDR_TEXT3))); vector<string> sep = split(res, '\n'); for (int i = 0; i < sep.size(); i++) { replace(sep[i], "\r", ""); string buf; stringstream ss(sep[i]); string d_f[2]; while (ss >> buf) { if (buf.find(",") != std::string::npos) { buf.erase(buf.end() - 1); d_f[0] = buf + ".dll"; } else d_f[1] = buf; } bool flag = false; for (size_t i = 0; i < 12; i++) { if (d_f[0] == functions[i][0]) { for (size_t j = 0; j < 100; j++) { if (functions[i][j] == "") { functions[i][j] = d_f[1]; break; } } flag = true; break; } } if (!flag) { for (size_t i = 0; i < 12; i++) { if (functions[i][0] == "") { functions[i][0] = d_f[0]; functions[i][1] = d_f[1]; break; } } } } /* ifstream myfile("dllandFunctions.txt"); string line; if (myfile.is_open()) { while (getline(myfile, line)) { string buf; stringstream ss(line); string d_f[2]; while (ss >> buf) { if (buf.find(",") != std::string::npos) { buf.erase(buf.end() - 1); d_f[0] = buf + ".dll"; } else d_f[1] = buf; } bool flag = false; for (size_t i = 0; i < 12; i++) { if (d_f[0] == functions[i][0]) { for (size_t j = 0; j < 100; j++) { if (functions[i][j] == "") { functions[i][j] = d_f[1]; break; } } flag = true; break; } } if (!flag) { for (size_t i = 0; i < 12; i++) { if (functions[i][0] == "") { functions[i][0] = d_f[0]; functions[i][1] = d_f[1]; break; } } } } myfile.close(); } */ FARPROC addr; try { for (size_t i = 0; i < 12; i++) { for (size_t j = 0; j < 100; j++) { if (functions[i][j] != "") { addr = GetProcAddress(LoadLibraryA(functions[i][0].c_str()), functions[i][j].c_str()); if (addr == 0x00000000) continue; else if (*(BYTE *)addr == 0xE9) { createAndWriteFile("functionHookedByCuckoo.txt"); printf("Cuckoo detected (Function hook)!!\n"); break; } } } } } catch (int e) { perror("ERROR"); } }
int os_msw::terminate_process_by_name( const wxString& named_process_to_terminate ) { // A more wxWindows type interface const char *szToTerminate = named_process_to_terminate.c_str(); // See notes to is_named_process_running for credits and info. BOOL bResult,bResultm; DWORD aiPID[1000],iCb=1000,iNumProc,iV2000=0; DWORD iCbneeded,i,iFound=0; char szName[MAX_PATH],szToTermUpper[MAX_PATH]; HANDLE hProc,hSnapShot,hSnapShotm; OSVERSIONINFO osvi; HINSTANCE hInstLib; int iLen,iLenP,indx; HMODULE hMod; PROCESSENTRY32 procentry; MODULEENTRY32 modentry; // Transfer Process name into "szToTermUpper" and // convert it to upper case iLenP=strlen(szToTerminate); if(iLenP<1 || iLenP>MAX_PATH) return 632; for(indx=0;indx<iLenP;indx++) szToTermUpper[indx]=toupper(szToTerminate[indx]); szToTermUpper[iLenP]=0; // PSAPI Function Pointers. BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * ); BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *, DWORD, LPDWORD ); DWORD (WINAPI *lpfGetModuleBaseName)( HANDLE, HMODULE, LPTSTR, DWORD ); // ToolHelp Function Pointers. HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; BOOL (WINAPI *lpfModule32First)(HANDLE,LPMODULEENTRY32) ; BOOL (WINAPI *lpfModule32Next)(HANDLE,LPMODULEENTRY32) ; // First check what version of Windows we're in osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); bResult=GetVersionEx(&osvi); if(!bResult) // Unable to identify system version return 606; // At Present we only support Win/NT/2000/XP or Win/9x/ME if((osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) && (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)) return 607; if(osvi.dwPlatformId==VER_PLATFORM_WIN32_NT) { // Win/NT or 2000 or XP // Load library and get the procedures explicitly. We do // this so that we don't have to worry about modules using // this code failing to load under Windows 9x, because // it can't resolve references to the PSAPI.DLL. hInstLib = LoadLibraryA("PSAPI.DLL"); if(hInstLib == NULL) return 605; // Get procedure addresses. lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) GetProcAddress( hInstLib, "EnumProcesses" ) ; lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD)) GetProcAddress( hInstLib, "EnumProcessModules" ) ; lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, LPTSTR, DWORD )) GetProcAddress( hInstLib, "GetModuleBaseNameA" ) ; if(lpfEnumProcesses == NULL || lpfEnumProcessModules == NULL || lpfGetModuleBaseName == NULL) { FreeLibrary(hInstLib); return 700; } bResult=lpfEnumProcesses(aiPID,iCb,&iCbneeded); if(!bResult) { // Unable to get process list, EnumProcesses failed FreeLibrary(hInstLib); return 701; } // How many processes are there? iNumProc=iCbneeded/sizeof(DWORD); // Get and match the name of each process for(i=0;i<iNumProc;i++) { // Get the (module) name for this process strcpy(szName,"Unknown"); // First, get a handle to the process hProc=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE, aiPID[i]); // Now, get the process name if(hProc) { if(lpfEnumProcessModules(hProc,&hMod,sizeof(hMod),&iCbneeded) ) { iLen=lpfGetModuleBaseName(hProc,hMod,szName,MAX_PATH); } } CloseHandle(hProc); // We will match regardless of lower or upper case #ifdef __BORLANDC__ if(strcmp(strupr(szName),szToTermUpper)==0) #else if(strcmp(_strupr(szName),szToTermUpper)==0) #endif { // Process found, now terminate it iFound=1; // First open for termination hProc=OpenProcess(PROCESS_TERMINATE,FALSE,aiPID[i]); if(hProc) { if(TerminateProcess(hProc,0)) { // process terminated CloseHandle(hProc); FreeLibrary(hInstLib); return 0; } else { // Unable to terminate process CloseHandle(hProc); FreeLibrary(hInstLib); return 602; } } else { // Unable to open process for termination FreeLibrary(hInstLib); return 604; } } } } if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) { // Win/95 or 98 or ME hInstLib = LoadLibraryA("Kernel32.DLL"); if( hInstLib == NULL ) return 702; // Get procedure addresses. // We are linking to these functions of Kernel32 // explicitly, because otherwise a module using // this code would fail to load under Windows NT, // which does not have the Toolhelp32 // functions in the Kernel 32. lpfCreateToolhelp32Snapshot= (HANDLE(WINAPI *)(DWORD,DWORD)) GetProcAddress( hInstLib, "CreateToolhelp32Snapshot" ) ; lpfProcess32First= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32First" ) ; lpfProcess32Next= (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) GetProcAddress( hInstLib, "Process32Next" ) ; lpfModule32First= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32First" ) ; lpfModule32Next= (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) GetProcAddress( hInstLib, "Module32Next" ) ; if( lpfProcess32Next == NULL || lpfProcess32First == NULL || lpfModule32Next == NULL || lpfModule32First == NULL || lpfCreateToolhelp32Snapshot == NULL ) { FreeLibrary(hInstLib); return 703; } // The Process32.. and Module32.. routines return names in all uppercase // Get a handle to a Toolhelp snapshot of all the systems processes. hSnapShot = lpfCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ; if( hSnapShot == INVALID_HANDLE_VALUE ) { FreeLibrary(hInstLib); return 704; } // Get the first process' information. procentry.dwSize = sizeof(PROCESSENTRY32); bResult=lpfProcess32First(hSnapShot,&procentry); // While there are processes, keep looping and checking. while(bResult) { // Get a handle to a Toolhelp snapshot of this process. hSnapShotm = lpfCreateToolhelp32Snapshot( TH32CS_SNAPMODULE, procentry.th32ProcessID) ; if( hSnapShotm == INVALID_HANDLE_VALUE ) { CloseHandle(hSnapShot); FreeLibrary(hInstLib); return 704; } // Get the module list for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32First(hSnapShotm,&modentry); // While there are modules, keep looping and checking while(bResultm) { if(strcmp(modentry.szModule,szToTermUpper)==0) { // Process found, now terminate it iFound=1; // First open for termination hProc=OpenProcess(PROCESS_TERMINATE,FALSE,procentry.th32ProcessID); if(hProc) { //ROB: Replaced with best_terminate_process //if(TerminateProcess(hProc,0)) if ( best_terminate_process( hProc, 0 ) ) { // process terminated CloseHandle(hSnapShotm); CloseHandle(hSnapShot); CloseHandle(hProc); FreeLibrary(hInstLib); return 0; } else { // Unable to terminate process CloseHandle(hSnapShotm); CloseHandle(hSnapShot); CloseHandle(hProc); FreeLibrary(hInstLib); return 602; } } else { // Unable to open process for termination CloseHandle(hSnapShotm); CloseHandle(hSnapShot); FreeLibrary(hInstLib); return 604; } } else { // Look for next modules for this process modentry.dwSize=sizeof(MODULEENTRY32); bResultm=lpfModule32Next(hSnapShotm,&modentry); } } //Keep looking CloseHandle(hSnapShotm); procentry.dwSize = sizeof(PROCESSENTRY32); bResult = lpfProcess32Next(hSnapShot,&procentry); } CloseHandle(hSnapShot); } if(iFound==0) { FreeLibrary(hInstLib); return 603; } FreeLibrary(hInstLib); return 0; }
/* DG_CONTROL/DAT_IDENTITY/MSG_OPENDS */ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData) { TW_UINT16 i = 0; pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData; activeDS *newSource; const char *modname = NULL; HMODULE hmod; TRACE("DG_CONTROL/DAT_IDENTITY/MSG_OPENDS\n"); TRACE("pIdentity is %s\n", pIdentity->ProductName); if (!DSM_initialized) { FIXME("seq error\n"); DSM_twCC = TWCC_SEQERROR; return TWRC_FAILURE; } twain_autodetect(); if (!nrdevices) { FIXME("no devs.\n"); DSM_twCC = TWCC_NODS; return TWRC_FAILURE; } if (pIdentity->ProductName[0] != '\0') { /* Make sure the source to be opened exists in the device list */ for (i = 0; i<nrdevices; i++) if (!strcmp (devices[i].identity.ProductName, pIdentity->ProductName)) break; if (i == nrdevices) i = 0; } /* else use the first device */ /* the source is found in the device list */ newSource = HeapAlloc (GetProcessHeap(), 0, sizeof (activeDS)); if (!newSource) { DSM_twCC = TWCC_LOWMEMORY; FIXME("Out of memory.\n"); return TWRC_FAILURE; } hmod = LoadLibraryA(devices[i].modname); if (!hmod) { ERR("Failed to load TWAIN Source %s\n", modname); DSM_twCC = TWCC_OPERATIONERROR; HeapFree(GetProcessHeap(), 0, newSource); return TWRC_FAILURE; } newSource->hmod = hmod; newSource->dsEntry = (DSENTRYPROC)GetProcAddress(hmod, "DS_Entry"); if (TWRC_SUCCESS != newSource->dsEntry (pOrigin, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, pIdentity)) { DSM_twCC = TWCC_OPERATIONERROR; HeapFree(GetProcessHeap(), 0, newSource); return TWRC_FAILURE; } /* Assign name and id for the opened data source */ pIdentity->Id = DSM_sourceId ++; /* add the data source to an internal active source list */ newSource->next = activeSources; newSource->identity.Id = pIdentity->Id; strcpy (newSource->identity.ProductName, pIdentity->ProductName); activeSources = newSource; DSM_twCC = TWCC_SUCCESS; return TWRC_SUCCESS; }
int mmap_filename(void* map, stralloc* sa) { #if WINDOWS_NATIVE typedef DWORD(WINAPI get_mmaped_filename_fn)(HANDLE, LPVOID, LPSTR, DWORD); static get_mmaped_filename_fn* get_mmaped_filename; if(get_mmaped_filename == 0) { HINSTANCE psapi = LoadLibraryA("psapi.dll"); if((get_mmaped_filename = (get_mmaped_filename_fn*)GetProcAddress(psapi, "GetMappedFileNameA")) == 0) return 0; } stralloc_ready(sa, MAX_PATH + 1); if((sa->len = (size_t) (*get_mmaped_filename)(GetCurrentProcess(), map, sa->s, sa->a))) { /* Translate path with device name to drive letters. */ char szTemp[BUFSIZE]; szTemp[0] = '\0'; if(GetLogicalDriveStringsA(BUFSIZE - 1, szTemp)) { char szName[MAX_PATH]; char szDrive[3] = " :"; BOOL bFound = FALSE; char* p = szTemp; do { /* Copy the drive letter to the template string */ *szDrive = *p; /* Look up each device name */ if(QueryDosDevice(szDrive, szName, MAX_PATH)) { size_t uNameLen = str_len(szName); if(uNameLen < MAX_PATH) { bFound = strnicmp(sa->s, szName, uNameLen) == 0 && *(sa->s + uNameLen) == '\\'; if(bFound) { /* Reconstruct sa->s using szTempFile Replace device path with DOS path */ stralloc_remove(sa, 0, uNameLen); stralloc_prepends(sa, szDrive); break; } } } /* Go to the next NULL character. */ while(*p++) ; } while(!bFound && *p); /* end of string */ } } return sa->len > 0; #else char buf[1024]; buffer b = BUFFER_INIT(read, open("/proc/self/maps", O_RDONLY), buf, sizeof(buf)); char line[73 + PATH_MAX + 1]; ssize_t n; int ret = 0; while((n = buffer_getline(&b, line, sizeof(line))) > 0) { char* p = line; uint64 start, end; p += scan_xlonglong(p, &start); if(*p == '-') { char* e = line + n - 1; int i = 4; ++p; p += scan_xlonglong(p, &end); while(i--) { p += scan_whitenskip(p, e - p); p += scan_nonwhitenskip(p, e - p); } p += scan_whitenskip(p, e - p); if((uint64)map >= start && (uint64)map < end) { stralloc_copyb(sa, p, e - p); ret = 1; break; } } } buffer_close(&b); return ret; #endif }
object_t library_load( const char* name ) { library_t* library; hash_t namehash; unsigned int i, size; uint64_t id; #if FOUNDATION_PLATFORM_WINDOWS char* dllname; HANDLE dll; #endif //Locate already loaded library library = 0; namehash = string_hash( name ); for( i = 0, size = objectmap_size( _library_map ); i < size; ++i ) { library = objectmap_raw_lookup( _library_map, i ); if( library && ( library->namehash == namehash ) ) { FOUNDATION_ASSERT( string_equal( library->name, name ) ); atomic_incr32( &library->ref ); return library->id; } } error_context_push( "loading library", name ); //Try loading library #if FOUNDATION_PLATFORM_WINDOWS dllname = string_format( "%s.dll", name ); dll = LoadLibraryA( dllname ); if( !dll ) { #if FOUNDATION_PLATFORM_ARCH_X86 string_deallocate( dllname ); dllname = string_format( "%s32.dll", name ); dll = LoadLibraryA( dllname ); #elif FOUNDATION_PLATFORM_ARCH_X86_64 string_deallocate( dllname ); dllname = string_format( "%s64.dll", name ); dll = LoadLibraryA( dllname ); #endif } string_deallocate( dllname ); if( !dll ) { log_warnf( 0, WARNING_SUSPICIOUS, "Unable to load DLL '%s': %s", name, system_error_message( 0 ) ); error_context_pop(); return 0; } #elif FOUNDATION_PLATFORM_POSIX # if FOUNDATION_PLATFORM_APPLE char* libname = string_format( "lib%s.dylib", name ); # else char* libname = string_format( "lib%s.so", name ); # endif void* lib = dlopen( libname, RTLD_LAZY ); string_deallocate( libname ); #if FOUNDATION_PLATFORM_ANDROID if( !lib ) { libname = string_format( "%s/lib%s.so", environment_executable_directory(), name ); lib = dlopen( libname, RTLD_LAZY ); string_deallocate( libname ); } #endif if( !lib ) { log_warnf( 0, WARNING_SUSPICIOUS, "Unable to load dynamic library '%s': %s", name, dlerror() ); error_context_pop(); return 0; } #else log_errorf( 0, ERROR_NOT_IMPLEMENTED, "Dynamic library loading not implemented for this platform: %s", name ); error_context_pop(); return 0; #endif id = objectmap_reserve( _library_map ); if( !id ) { #if FOUNDATION_PLATFORM_WINDOWS FreeLibrary( dll ); #elif FOUNDATION_PLATFORM_POSIX dlclose( lib ); #endif log_errorf( 0, ERROR_OUT_OF_MEMORY, "Unable to allocate new library '%s', map full", name ); error_context_pop(); return 0; } library = memory_allocate_zero( sizeof( library_t ), 0, MEMORY_PERSISTENT ); library->ref = 1; library->id = id; library->namehash = string_hash( name ); string_copy( library->name, name, 32 ); #if FOUNDATION_PLATFORM_WINDOWS library->dll = dll; #elif FOUNDATION_PLATFORM_POSIX library->lib = lib; #endif objectmap_set( _library_map, id, library ); error_context_pop(); return library->id; }
/***************************************************************************** * QTVideoInit: *****************************************************************************/ static int QTVideoInit( decoder_t *p_dec ) { decoder_sys_t *p_sys = p_dec->p_sys; #ifdef __APPLE__ p_sys->FindNextComponent = (void*)FindNextComponent; p_sys->OpenComponent = (void*)OpenComponent; p_sys->ImageCodecInitialize = (void*)ImageCodecInitialize; p_sys->ImageCodecGetCodecInfo = (void*)ImageCodecGetCodecInfo; p_sys->ImageCodecPreDecompress = (void*)ImageCodecPreDecompress; p_sys->ImageCodecBandDecompress = (void*)ImageCodecBandDecompress; p_sys->GetGWorldPixMap = (void*)GetGWorldPixMap; p_sys->QTNewGWorldFromPtr = (void*)QTNewGWorldFromPtr; p_sys->NewHandleClear = (void*)NewHandleClear; #else #ifdef LOADER p_sys->ldt_fs = Setup_LDT_Keeper(); #endif /* LOADER */ p_sys->qts = LoadLibraryA( "QuickTime.qts" ); if( p_sys->qts == NULL ) { msg_Dbg( p_dec, "failed loading QuickTime.qts" ); return VLC_EGENERIC; } msg_Dbg( p_dec, "QuickTime.qts loaded" ); p_sys->qtml = LoadLibraryA( "qtmlClient.dll" ); if( p_sys->qtml == NULL ) { msg_Dbg( p_dec, "failed loading qtmlClient.dll" ); return VLC_EGENERIC; } msg_Dbg( p_dec, "qtmlClient.dll loaded" ); /* (void*) to shut up gcc */ p_sys->InitializeQTML = (void*)GetProcAddress( p_sys->qtml, "InitializeQTML" ); p_sys->FindNextComponent = (void*)GetProcAddress( p_sys->qtml, "FindNextComponent" ); p_sys->OpenComponent = (void*)GetProcAddress( p_sys->qtml, "OpenComponent" ); p_sys->ImageCodecInitialize = (void*)GetProcAddress( p_sys->qtml, "ImageCodecInitialize" ); p_sys->ImageCodecGetCodecInfo = (void*)GetProcAddress( p_sys->qtml, "ImageCodecGetCodecInfo" ); p_sys->ImageCodecPreDecompress = (void*)GetProcAddress( p_sys->qtml, "ImageCodecPreDecompress" ); p_sys->ImageCodecBandDecompress = (void*)GetProcAddress( p_sys->qtml, "ImageCodecBandDecompress" ); p_sys->GetGWorldPixMap = (void*)GetProcAddress( p_sys->qtml, "GetGWorldPixMap" ); p_sys->QTNewGWorldFromPtr = (void*)GetProcAddress( p_sys->qtml, "QTNewGWorldFromPtr" ); p_sys->NewHandleClear = (void*)GetProcAddress( p_sys->qtml, "NewHandleClear" ); if( p_sys->InitializeQTML == NULL ) { msg_Dbg( p_dec, "failed getting proc address InitializeQTML" ); return VLC_EGENERIC; } if( p_sys->FindNextComponent == NULL || p_sys->OpenComponent == NULL || p_sys->ImageCodecInitialize == NULL || p_sys->ImageCodecGetCodecInfo == NULL || p_sys->ImageCodecPreDecompress == NULL || p_sys->ImageCodecBandDecompress == NULL || p_sys->GetGWorldPixMap == NULL || p_sys->QTNewGWorldFromPtr == NULL || p_sys->NewHandleClear == NULL ) { msg_Err( p_dec, "failed getting proc address" ); return VLC_EGENERIC; } #endif /* __APPLE__ */ return VLC_SUCCESS; }
/** * Runtime-load the libpcap shared-object or the winpcap DLL. We * load at runtime rather than loadtime to allow this program to * be used to process offline content, and to provide more helpful * messages to people who don't realize they need to install PCAP. */ void pcaplive_init(struct PCAPLIVE *pl) { #ifdef WIN32 HMODULE hPacket; HMODULE hLibpcap; HMODULE hAirpcap; pl->is_available = 0; pl->is_printing_debug = 1; /* Look for the Packet.dll */ hPacket = LoadLibraryA("Packet.dll"); if (hPacket == NULL) { if (pl->is_printing_debug) switch (GetLastError()) { case ERROR_MOD_NOT_FOUND: fprintf(stderr, "%s: not found\n", "Packet.dll"); return; default: fprintf(stderr, "%s: couldn't load %d\n", "Packet.dll", (int)GetLastError()); return; } } /* Look for the Packet.dll */ hLibpcap = LoadLibraryA("wpcap.dll"); if (hLibpcap == NULL) { if (pl->is_printing_debug) fprintf(stderr, "%s: couldn't load %d\n", "wpcap.dll", (int)GetLastError()); return; } /* Look for the Packet.dll */ hAirpcap = LoadLibraryA("airpcap.dll"); if (hLibpcap == NULL) { if (pl->is_printing_debug) fprintf(stderr, "%s: couldn't load %d\n", "airpcap.dll", (int)GetLastError()); return; } #define DOLINK(PCAP_DATALINK, datalink) \ pl->datalink = (PCAP_DATALINK)GetProcAddress(hLibpcap, "pcap_"#datalink); \ if (pl->datalink == NULL) pl->func_err=1, pl->datalink = null_##PCAP_DATALINK; #endif #ifndef WIN32 #ifndef STATICPCAP void *hLibpcap; unsigned initial_failure=0; pl->is_available = 0; pl->is_printing_debug = 1; hLibpcap = dlopen("libpcap.so", RTLD_LAZY); if (hLibpcap == NULL) { fprintf(stderr, "%s: %s\n", "libpcap.so", dlerror()); fprintf(stderr, "Searching elsewhere for libpcap\n"); initial_failure = 1; } if (hLibpcap==NULL) hLibpcap = dlopen("libpcap.so.0.9.5", RTLD_LAZY); if (hLibpcap==NULL) hLibpcap = dlopen("libpcap.so.0.9.4", RTLD_LAZY); if (hLibpcap==NULL) hLibpcap = dlopen("libpcap.so.0.8", RTLD_LAZY); if (hLibpcap==NULL) hLibpcap = dlopen("libpcap.A.dylib", RTLD_LAZY); if (hLibpcap == NULL) { if (pl->is_printing_debug) { fprintf(stderr, "%s: couldn't load %d (%s)\n", "libpcap.so", errno, strerror(errno)); } } else if (initial_failure) { fprintf(stderr, "Found libpcap\n"); } #define DOLINK(PCAP_DATALINK, datalink) \ pl->datalink = (PCAP_DATALINK)dlsym(hLibpcap, "pcap_"#datalink); \ if (pl->datalink == NULL) pl->func_err=1, pl->datalink = null_##PCAP_DATALINK; #else #define DOLINK(PCAP_DATALINK, datalink) \ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK; #endif #endif #ifdef WIN32 DOLINK(PCAP_GET_AIRPCAP_HANDLE, get_airpcap_handle); if (pl->func_err) { pl->func_err = 0; } if (hAirpcap) { pl->airpcap_set_device_channel = (AIRPCAP_SET_DEVICE_CHANNEL)GetProcAddress(hAirpcap, "AirpcapSetDeviceChannel"); if (pl->airpcap_set_device_channel == NULL) pl->airpcap_set_device_channel = null_AIRPCAP_SET_DEVICE_CHANNEL; } #endif DOLINK(PCAP_CLOSE , close); DOLINK(PCAP_DATALINK , datalink); DOLINK(PCAP_DISPATCH , dispatch); DOLINK(PCAP_FINDALLDEVS , findalldevs); DOLINK(PCAP_FREEALLDEVS , freealldevs); DOLINK(PCAP_LIB_VERSION , lib_version); DOLINK(PCAP_LOOKUPDEV , lookupdev); DOLINK(PCAP_MAJOR_VERSION , major_version); DOLINK(PCAP_MINOR_VERSION , minor_version); DOLINK(PCAP_OPEN_LIVE , open_live); //DOLINK(PCAP_OPEN_LIVE , open_live); pl->can_transmit = null_CAN_TRANSMIT; if (!pl->func_err) pl->is_available = 1; else pl->is_available = 0; }
void set_user_data_dir(std::string path) { #ifdef _WIN32 if(path.empty()) { user_data_dir = get_cwd() + "/userdata"; } else if (path.size() > 2 && path[1] == ':') { //allow absolute path override user_data_dir = path; } else { typedef BOOL (WINAPI *SHGSFPAddress)(HWND, LPSTR, int, BOOL); SHGSFPAddress SHGetSpecialFolderPathA; HMODULE module = LoadLibraryA("shell32"); SHGetSpecialFolderPathA = reinterpret_cast<SHGSFPAddress>(GetProcAddress(module, "SHGetSpecialFolderPathA")); if(SHGetSpecialFolderPathA) { LOG_FS << "Using SHGetSpecialFolderPath to find My Documents\n"; char my_documents_path[MAX_PATH]; if(SHGetSpecialFolderPathA(NULL, my_documents_path, 5, 1)) { std::string mygames_path = std::string(my_documents_path) + "/" + "My Games"; boost::algorithm::replace_all(mygames_path, std::string("\\"), std::string("/")); create_directory_if_missing(mygames_path); user_data_dir = mygames_path + "/" + path; } else { WRN_FS << "SHGetSpecialFolderPath failed\n"; user_data_dir = get_cwd() + "/" + path; } } else { LOG_FS << "Failed to load SHGetSpecialFolderPath function\n"; user_data_dir = get_cwd() + "/" + path; } } #else /*_WIN32*/ #ifdef PREFERENCES_DIR if (path.empty()) path = PREFERENCES_DIR; #endif std::string path2 = ".wesnoth" + get_version_path_suffix(); #ifdef _X11 const char *home_str = getenv("HOME"); if (path.empty()) { char const *xdg_data = getenv("XDG_DATA_HOME"); if (!xdg_data || xdg_data[0] == '\0') { if (!home_str) { path = path2; goto other; } user_data_dir = home_str; user_data_dir += "/.local/share"; } else user_data_dir = xdg_data; user_data_dir += "/wesnoth/"; user_data_dir += get_version_path_suffix(); create_directory_if_missing_recursive(user_data_dir); } else { other: std::string home = home_str ? home_str : "."; if (path[0] == '/') user_data_dir = path; else user_data_dir = home + "/" + path; } #else if (path.empty()) path = path2; const char* home_str = getenv("HOME"); std::string home = home_str ? home_str : "."; if (path[0] == '/') user_data_dir = path; else user_data_dir = home + std::string("/") + path; #endif #endif /*_WIN32*/ setup_user_data_dir(); }
/* * @implemented */ intptr_t _loaddll(char* name) { return (intptr_t) LoadLibraryA(name); }