Exemple #1
0
Graphics::Graphics(Window *_window, E_RENDER_DRIVER driverFlag)
{
	window = _window; 

	currentDriver = LoadDriver(driverFlag);

	if (currentDriver == NULL)
	{
		printf("%s not found, loading default driver instead...\n", GetRenderDriverAlias(driverFlag));

		int drvIndex = 0;
		while (drvIndex <= E_SoftwareDriver && (currentDriver = LoadDriver(E_RENDER_DRIVER(drvIndex))) == NULL)
		{
			++drvIndex;
		}
	} 
	
	if (currentDriver == NULL)
	{
		printf("No graphics driver available. now exit\n", GetRenderDriverAlias(driverFlag));
		return;
	}

	this->Startup();
}
Exemple #2
0
/* Open a graphics device with file node. */
HDEVICE OpenDeviceFromFD(int fd)
{
	struct drm_version version = { 0 };
	if (ioctl(fd, DRM_IOCTL_VERSION, &version)) {
		return NULL;
	}

	struct stat data;
	data.st_rdev = 0;
	if (fstat(fd, &data)) {
	}

	struct drm_auth auth;
	if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) {
		return NULL;
	}

	struct IDevice *device = NULL;
	if (!(device = (struct IDevice*)calloc(1, sizeof(struct IDevice)))) {
		return NULL;
	}

	device->fd = fd;
	device->dev = data.st_rdev;
	device->magic = auth.magic;
	device->driver.device = device;
	device->driver.fd = fd;
	IListAdd(&device->node, &devlist);
	GetResources(device);
	LoadDriver(device);
	return (HDEVICE)device;
}
Exemple #3
0
struct jpeg_error_mgr * PMAPI jpeg_std_error(
	struct jpeg_error_mgr * err)
{
	if (LoadDriver())
		return _JPEG_exports.jpeg_std_error(err);
	return NULL;
}
Exemple #4
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    GA_devCtx       *dc = NULL;
    GA_configInfo   info;
    N_uint8         capabilities = 0;
    N_int32         numMonitorPorts;
    GA_SCIFuncs     sci;
    uchar           edid[128];
    EDID_record     rec;
    N_int32         channel = SCI_channelMonitorPrimary;

    /* Get command line option for SNAP DDC channel */
    if (argc > 1)
        channel = atoi(argv[1]);

    /* Now handle the query */
    dc = LoadDriver(0);
    if (!dc) {
        printf("Unable to load SNAP DDC driver!\n");
        return -1;
        }

    /* Display graphics driver info */
    banner();
    info.dwSize = sizeof(info);
    init.GetConfigInfo(&info);
    printf("Doing DDC for %s %s (device %d) on channel %d:\n\n",
        info.ManufacturerName, info.ChipsetName,
        dc->DeviceIndex, channel);

    /* Detect if the SCI interface is active */
    sci.dwSize = sizeof(sci);
    if (GA_queryFunctions(dc,GA_GET_SCIFUNCS,&sci) && sci.SCIdetect(&capabilities,&numMonitorPorts)) {
        /* Initialise DDC2B communications */
        if (DDC_initExt(dc,channel) == 0) {
            /* Read EDID data */
            DDC_readEDID(0xA0,edid,sizeof(edid),0,channel);
            /* Parse EDID data and dump into formatted text file */
            if (!EDID_parse(edid,&rec,false))
                printf("Unable to parse EDID data!\n");
            else if (!EDID_format(&rec,EDID_FILENAME))
                printf("Unable to format EDID data!\n");
            else
                printf("EDID data formatted into text file " EDID_FILENAME " \n");
            printf("DDC channel %d EDID: %s %s\n",channel,rec.mfrName,rec.modelName);
            }
        else {
            printf("Could not perform DDC2B communications!\n");
            }
        }
    else {
        printf("No DDC services available in driver!\n");
        }

    /* Unload SNAP and exit */
    GA_unloadDriver(dc);
    return 0;
}
Exemple #5
0
static bool_t LoadDriver(gapi* p)
{
	HMODULE GX;
	tchar_t Path[MAXPATH];

	if (p->Windows)
		GetSystemPath(Path,TSIZEOF(Path),T("gx.dll"));
	else
		tcscpy_s(Path,TSIZEOF(Path),T("gx.dll"));

	if ((GX = LoadLibrary(Path))==NULL)
	{
		if (!p->Windows)
		{
			p->Windows = 1;
			return LoadDriver(p);
		}
		return 0;
	}

	if (p->GX)
		FreeLibrary(p->GX);
	p->GX = GX;

	GetProc(&p->GX,&p->GXOpenDisplay,T("?GXOpenDisplay@@YAHPAUHWND__@@K@Z"),0);
	GetProc(&p->GX,&p->GXCloseDisplay,T("?GXCloseDisplay@@YAHXZ"),0);
	GetProc(&p->GX,&p->GXBeginDraw,T("?GXBeginDraw@@YAPAXXZ"),0);
	GetProc(&p->GX,&p->GXEndDraw,T("?GXEndDraw@@YAHXZ"),0);
	GetProc(&p->GX,&p->GXGetDisplayProperties,T("?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ"),0);
	GetProc(&p->GX,&p->GXSetViewport,T("?GXSetViewport@@YAHKKKK@Z"),1);
	GetProc(&p->GX,&p->GXIsDisplayDRAMBuffer,T("?GXIsDisplayDRAMBuffer@@YAHXZ"),1);

	return p->GX!=NULL;
}
//Load VXM Driver - Load VXM driver into memory
//Input: None
int stepperDriver::LoadVXMDriver()
{

	int temp = LoadDriver(L"..\\Libraries\\VXM_Stepper\\VxmDriver.dll"); //Location of driver relative to exe.

//	int temp = LoadDriver(L".\\VxmDriver.dll"); //Location of driver needed in project ex.  ".\\VxmDriver.dll"
	return temp;
}
Exemple #7
0
static LoadUnloadTestDriverReverseOrder()
{
	CFIX_ASSERT_EQUALS_DWORD( ERROR_SUCCESS, LoadReflector() );
	CFIX_ASSERT_EQUALS_DWORD( ERROR_SUCCESS, LoadDriver( L"testklib1", L"testklib1.sys" ) );

	UnloadDriver( L"cfixkr" );
	UnloadDriver( L"testklib1" );
}
Exemple #8
0
DWORD LoadReflector()
{
	SYSTEM_INFO SystemInfo;

	CfixklGetNativeSystemInfo( &SystemInfo );
	switch ( SystemInfo.wProcessorArchitecture  )
	{
	case PROCESSOR_ARCHITECTURE_INTEL:
		return LoadDriver( L"cfixkr", L"cfixkr32.sys" );

	case PROCESSOR_ARCHITECTURE_AMD64:
		return LoadDriver( L"cfixkr", L"cfixkr64.sys" );

	default:
		CFIX_ASSERT( !"Unsupported processor architecture" );
		return ERROR_FUNCTION_FAILED;
	}
}
/* Attach API implementations */
int AthBtFilter_Attach(ATH_BT_FILTER_INSTANCE *pInstance)
{
#ifdef ATH_USE_DLL
    int     retVal = 0;
    LONG    newVal;
    
    pInstance->Attached = TRUE;
    
    newVal = InterlockedIncrement(&g_FilterRefCount);
    
    do {
                
        if (newVal != 1) {
                /* already loaded, nothing else to do */
            break;   
        }  
            /* set failure status */
        retVal = -1;
        
            /* try to load the filter DLL */
        g_hDLL = LoadDriver(TEXT("athbtfilter.dll"));
        
        if (NULL == g_hDLL) {
            RETAILMSG(1, (TEXT("Failed to load athbt filter (winerror:%d) \r\n"), GetLastError()));
            break;    
        }        
            /* get the API entry points */
        g_pCreate = (ATHBT_FILTER_DLL_CREATE_ENTRY) GetProcAddress(g_hDLL, TEXT("AthBtFilter_Create"));
        if (NULL == g_pCreate) {
            RETAILMSG(1, (TEXT("Failed to get Create API from athbt filter (winerror:%d) \r\n"), GetLastError()));   
            break; 
        }        
        g_pDestroy = (ATHBT_FILTER_DLL_DESTROY_ENTRY) GetProcAddress(g_hDLL, TEXT("AthBtFilter_Destroy"));
        if (NULL == g_pDestroy) {
            RETAILMSG(1, (TEXT("Failed to get Create API from athbt filter (winerror:%d) \r\n"), GetLastError()));  
            break;    
        }
       
            /* if we reach here, everything is OK */
        retVal = 0;
        
    } while (FALSE); 
     
    if (0 == retVal) {
            /* call filter library creation API */
        retVal = g_pCreate(pInstance);     
    }
    
    if (retVal < 0) {
        AthBtFilter_Detach(pInstance);    
    }
    
    return retVal;
#else
    return AthBtFilter_Create(pInstance);
#endif
}
Exemple #10
0
void ListModulesExpectOverflow()
{
	HANDLE Dev;
	DWORD Cb;
	CFIXKR_IOCTL_GET_MODULES Res;
	
	CFIX_ASSERT_EQUALS_DWORD( ERROR_SUCCESS, LoadReflector() );
	CFIX_ASSERT_EQUALS_DWORD( ERROR_SUCCESS, LoadDriver( L"testklib1", L"testklib1.sys" ) );
	CFIX_ASSERT_EQUALS_DWORD( ERROR_SUCCESS, LoadDriver( L"testklib2", L"testklib2.sys" ) );
	__try
	{
		Dev = CreateFile(
			L"\\\\.\\Cfixkr",
			GENERIC_READ | GENERIC_WRITE,
			0,
			NULL,
			OPEN_EXISTING,
			FILE_ATTRIBUTE_NORMAL,
			NULL );
		CFIX_ASSERT( Dev != INVALID_HANDLE_VALUE );

		CFIX_ASSERT( ! DeviceIoControl(
			Dev,
			CFIXKR_IOCTL_GET_TEST_MODULES,
			NULL,
			0,
			&Res,
			sizeof( Res ),
			&Cb,
			NULL ) );
		CFIX_ASSERT_EQUALS_DWORD( ERROR_MORE_DATA, GetLastError() );
		CFIX_ASSERT( CloseHandle( Dev ) );
		CFIX_ASSERT_EQUALS_DWORD( sizeof( Res ), Cb );
		CFIX_ASSERT_EQUALS_DWORD( 2, Res.Count );
		CFIX_ASSERT( Res.DriverLoadAddress[ 0 ] & 0x80000000 );
		CFIX_ASSERT( ( Res.DriverLoadAddress[ 0 ] & 0x00000FFF ) == 0 );
	}
	__finally
	{
		UnloadDriver( L"cfixkr" );
		UnloadDriver( L"testklib1" );
		UnloadDriver( L"testklib2" );
	}
}
Exemple #11
0
//Function to load the driver
DWORD TDriver::LoadDriver(LPCTSTR path, BOOL start)
{
	//first initialized it
	DWORD retCode = InitDriver(path);

	//then load
	if(retCode == DRV_SUCCESS)
		retCode = LoadDriver(start);

	return retCode;
}
Exemple #12
0
DWORD MyDriver::LoadDriver(char * name, char * path, char * dosName, BOOL start)
{

	DWORD retCode = IniMyDriver(name, path, dosName);


	if(retCode == DRV_SUCCESS)
		retCode = LoadDriver(start);

	return retCode;
}
Exemple #13
0
DWORD MyDriver::LoadDriver(char * path, BOOL start)
{
	
	DWORD retCode = IniMyDriver(path);


	if(retCode == DRV_SUCCESS)
		retCode = LoadDriver(start);

	return retCode;
}
Exemple #14
0
//Function to Load the driver.
DWORD TDriver::LoadDriver(LPCTSTR name, LPCTSTR path, LPCTSTR dosName, BOOL start)
{
	//first initialized it
	DWORD	retCode = InitDriver(name, path, dosName);

	//then load
	if(retCode == DRV_SUCCESS)
	{
		retCode = LoadDriver(start);
	}

	return(retCode);
}
Exemple #15
0
// put the driver through its paces to make sure it's there and active
static void DiagRDPMC(void)
{    
    HANDLE hDriver;
    unsigned __int64 i;

    // Try opening a static device driver. 
    hDriver = LoadDriver();
    if (hDriver != (INVALID_HANDLE_VALUE)) {
	printf("Ready to execute RDPMC from user space...\n");
    i = __readpmc(0);
    printf("We have successfully executed RDPMC from user space: 0x%x!\n", i);
	CloseHandle(hDriver);
    }
}
Exemple #16
0
/// <summary>
/// Reload driver
/// </summary>
/// <param name="path">Path to the driver file</param>
/// <returns>Status code</returns>
NTSTATUS DriverControl::Reload( std::wstring path /*= L"" */ )
{
    NTSTATUS status = STATUS_SUCCESS;

    Unload();

    // Use default path
    if (path.empty())
    {
        const wchar_t* filename = nullptr;

        if (IsWindows10OrGreater())
            filename = L"BlackBoneDrv10.sys";
        else if (IsWindows8Point1OrGreater())
            filename = L"BlackBoneDrv81.sys";
        else if (IsWindows8OrGreater())
            filename = L"BlackBoneDrv8.sys";
        else if (IsWindows7OrGreater())
            filename = L"BlackBoneDrv7.sys";
        else
            filename = L"BlackBoneDrv.sys";

        path = Utils::GetExeDirectory() + L"\\" + filename;
    }

    status = _loadStatus = LoadDriver( DRIVER_SVC_NAME, path );
    if (!NT_SUCCESS( status ))
    {
        BLACBONE_TRACE( L"Failed to load driver %ls. Status 0x%X", path.c_str(), status );
        return LastNtStatus( status );
    }

    _hDriver = CreateFileW(
                   BLACKBONE_DEVICE_FILE,
                   GENERIC_READ | GENERIC_WRITE,
                   FILE_SHARE_READ | FILE_SHARE_WRITE,
                   NULL, OPEN_EXISTING, 0, NULL
               );

    if (_hDriver == INVALID_HANDLE_VALUE)
    {
        status = LastNtStatus();
        BLACBONE_TRACE( L"Failed to open driver handle. Status 0x%X", status );
        return status;
    }

    return status;
}
Exemple #17
0
/// <summary>
/// Reload driver
/// </summary>
/// <param name="path">Path to the driver file</param>
/// <returns>Status code</returns>
NTSTATUS DriverControl::Reload( std::wstring path /*= L"" */ )
{
    Unload();

    // Use default path
    if (path.empty())
    {
        const wchar_t* filename = nullptr;

        if (IsWindows10OrGreater())
            filename = BLACKBONE_FILE_NAME_10;
        else if (IsWindows8Point1OrGreater())
            filename = BLACKBONE_FILE_NAME_81;
        else if (IsWindows8OrGreater())
            filename = BLACKBONE_FILE_NAME_8;
        else if (IsWindows7OrGreater())
            filename = BLACKBONE_FILE_NAME_7;
        else
            filename = BLACKBONE_FILE_NAME;

        path = Utils::GetExeDirectory() + L"\\" + filename;
    }

    _loadStatus = LoadDriver( DRIVER_SVC_NAME, path );
    if (!NT_SUCCESS( _loadStatus ))
    {
        BLACKBONE_TRACE( L"Failed to load driver %ls. Status 0x%X", path.c_str(), _loadStatus );
        return _loadStatus;
    }

    _hDriver = CreateFileW( 
        BLACKBONE_DEVICE_FILE, 
        GENERIC_READ | GENERIC_WRITE, 
        FILE_SHARE_READ | FILE_SHARE_WRITE,
        NULL, OPEN_EXISTING, 0, NULL
        );

    if (!_hDriver)
    {
        _loadStatus = LastNtStatus();
        BLACKBONE_TRACE( L"Failed to open driver handle. Status 0x%X", _loadStatus );
        return _loadStatus;
    }

    return _loadStatus;
}
int _tmain(int argc, _TCHAR* argv[])
{
	/*if (extract_binaries()){
		LoadDriver(_T("NPF"), _T("npf.sys"));
		StartDriver(_T("NPF"));
		WinExec("Example_Project.exe", SW_SHOW);
	}*/

	/*TCHAR path[BUFF_PATH_SIZE] = _T("");
	get_exe_directory(path);
	_tprintf(_T("location: %s\n"),path);
	get_file_dir(path);
	_tprintf(_T("location: %s\n"), path);
	get_exe_name(path);
	_tprintf(_T("name: %s\n"), path);*/


	/*TCHAR dir[BUFF_PATH_SIZE] = _T("");
	size_t len = 0;
	get_file_dir(dir);
	len = _tcslen(dir);
	dir[len] = _T('\\');
	get_exe_name(&dir[len+1]);
	_tprintf(_T("full path: %s\n"), dir);*/


	/*TCHAR dir[BUFF_PATH_SIZE] = _T("");
	get_full_working_path(dir, _T("test.sys"));
	_tprintf(_T("location: %s\n"), dir);*/

	TCHAR dir[BUFF_PATH_SIZE] = _T("");
	get_full_working_path(dir, _T("npf.sys"));

	if (extract_binaries()){
		StopDriver(_T("NPF"));
		unLoadDriver(_T("NPF"));
		LoadDriver(_T("NPF"), dir);
		StartDriver(_T("NPF"));
		WinExec("Example_Project.exe", SW_SHOW);
	}

	//system("pause");
	return 0;
}
Exemple #19
0
std::shared_ptr<Driver>
DriverManager::GetDriverWithName(const std::string& driver_name) {
  if (!_drivers_loaded) {
    LoadDrivers();
  }

  auto found = _drivers.find(driver_name);
  if (found != _drivers.end()) {
    return found->second;
  }

  auto found_lib = _driver_libraries.find(driver_name);
  if (found_lib != _driver_libraries.end()) {
    return LoadDriver(found_lib->second, driver_name);
  }

  std::cerr << "[DriverManager::GetDriverWithName] WARNING Driver with name '" << driver_name << "' not found." << std::endl;
  return nullptr;
}
Exemple #20
0
/* Open a graphics device */
HDEVICE OpenDevice(const char *devname)
{
	int handle = -1;
	const char *filename;
	filename = (devname == NULL ? DEFAULT_DEVICE : devname);
	if ((handle = open(filename, O_RDWR, 0)) < 0) {
		return NULL;
	}

	struct drm_version version = { 0 };
	if (ioctl(handle, DRM_IOCTL_VERSION, &version)) {
		close(handle);
		return NULL;
	}

	struct stat data;
	data.st_rdev = 0;
	if (fstat(handle, &data)) {
	}

	struct drm_auth auth;
	if (ioctl(handle, DRM_IOCTL_GET_MAGIC, &auth)) {
		close(handle);
		return NULL;
	}

	struct IDevice *device = NULL;
	if (!(device = (struct IDevice*)calloc(1, sizeof(struct IDevice)))) {
		close(handle);
		return NULL;
	}

	device->fd = handle;
	device->dev = data.st_rdev;
	device->magic = auth.magic;
	device->driver.device = device;
	device->driver.fd = handle;
	IListAdd(&device->node, &devlist);
	GetResources(device);
	LoadDriver(device);
	return (HDEVICE)device;
}
Exemple #21
0
// get the driver version string; also makes sure it's there and active
static void getDriverVersion(char *version, int size)
{    
    HANDLE hDriver;
    DWORD dwBytesReturned;
    BOOL  bReturnCode = FALSE;

    // Try opening a static device driver. 
    hDriver = LoadDriver();

    if (hDriver != INVALID_HANDLE_VALUE) {

	// Dispatch the PMC_VERSION_STRING IOCTL to our NT driver.
	bReturnCode = DeviceIoControl(hDriver,
				  IOCTL_PMC_VERSION_STRING,
				  NULL, 0, (int *)version, size,
				  &dwBytesReturned, NULL);
	CloseHandle(hDriver);
	version[dwBytesReturned-2] = 0; // make sure it's terminated
    } else version[0] = 0;
}
Exemple #22
0
// put the driver through its paces to make sure it's there and active
static void HelloTest(void)
{    
    HANDLE hDriver;
    DWORD dwBytesReturned;
    BOOL  bReturnCode = FALSE;
    int iobuf[256];     // I/O buffer

    // Try opening a static device driver. 
    hDriver = LoadDriver();

    if (hDriver != INVALID_HANDLE_VALUE) {
	// Send a request to the driver. The request code is HELLO, no parameters
	bReturnCode = DeviceIoControl(hDriver, HELLO, NULL, 0, iobuf, sizeof(iobuf), &dwBytesReturned, NULL);
	if (bReturnCode) {
		printf("HELLO RETURNED %d bytes: >%s<\n", dwBytesReturned, iobuf);
	}
	else 	printf("HELLO failed.\n");
	CloseHandle(hDriver);
    }
}
Exemple #23
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    /* Now handle the query */
    if (argc >= 2 && stricmp(argv[1],"show") == 0)
        ShowSettings(0);
    else if (argc >= 3) {
        LoadDriver(0);
        opt.LCDPanelWidth = atoi(argv[1]);
        opt.LCDPanelHeight = atoi(argv[2]);
        init.SetOptions(&opt);
        GA_saveOptions(dc,&opt);
        ShowSettings(0);
        }
    else
        help();
    if (dc)
        GA_unloadDriver(dc);
    return 0;
}
Exemple #24
0
BOOL
load_real_driver(PSplitterContext ctx, PSplitterSettings settings, ULONG Identifier) {
	ctx->real_port_driver = LoadDriver(settings->real_driver_path);
	if (ctx->real_port_driver != NULL) {
		if (get_real_driver_functions(ctx)) {
			ctx->real_port_init_context = ctx->real_port_functions.COM_Init(Identifier);
			if (ctx->real_port_init_context != NULL) {
				return TRUE;
			} else {
				MessageBox(NULL, L"failed to init real driver", L"splitter driver", MB_OK | MB_TOPMOST);
			}
		} else {
			MessageBox(NULL, L"failed to get driver functions", L"splitter driver", MB_OK | MB_TOPMOST);
		}

		FreeLibrary(ctx->real_port_driver);
	} else {
		MessageBox(NULL, L"failed to load real driver dll", L"splitter driver", MB_OK | MB_TOPMOST);
	}

	return FALSE;
}
bool CDriverLoader::MyZwLoadDriver(char * szDrvName, char * szDrvPath)
{

	if(!GetLoadDriverPriv())
	{
		return FALSE;
	}

	if (strrchr(szDrvPath,'\\')==NULL)
	{
		char path[512];	//无完整路径
		GetModuleFileName(NULL, path, 512);
		strncpy(strrchr(path, '\\')+1, szDrvPath, strlen(szDrvPath)+1);
		szDrvPath	=	path;
	}
	if (0xFFFFFFFF == ::GetFileAttributes(szDrvPath))
	{
		MessageBoxA(NULL,szDrvPath,"文件不存在",NULL);
		return false;
	}
	m_szDrvName	=	szDrvName;
	m_szDrvPath	=	szDrvPath;
	HMODULE hNtdll = NULL;
	hNtdll = LoadLibrary( "ntdll.dll" ); 
	RtlAnsiStringToUnicodeString = (RTLANSISTRINGTOUNICODESTRING) GetProcAddress( hNtdll, "RtlAnsiStringToUnicodeString");
	RtlFreeUnicodeString = (RTLFREEUNICODESTRING) GetProcAddress( hNtdll, "RtlFreeUnicodeString");
	ZwLoadDriver = (ZWLOADDRIVER) GetProcAddress( hNtdll, "ZwLoadDriver");
	ZwUnloadDriver = (ZWLOADDRIVER) GetProcAddress( hNtdll, "ZwUnloadDriver");
	//注册驱动程衼E
	if(LoadDriver(szDrvName, szDrvPath) == false)
	{
		FreeLibrary(hNtdll);
		return false;
	}
	bDriverLoaded	=	true;
	FreeLibrary(hNtdll);
	return true;
}
Exemple #26
0
// put the driver through its paces to make sure it's there and active
static void HelloNumTest(void)
{    
    HANDLE hDriver;
    DWORD dwBytesReturned;
    BOOL  bReturnCode = FALSE;
    char szString[256]; // character buffer
    int iobuf[256];     // I/O buffer

    // Try opening a static device driver. 
    hDriver = LoadDriver();

    if (hDriver != INVALID_HANDLE_VALUE) {
	// Send a request to the driver. The request code is HELLONUM, one integer parameter
	iobuf[0] = 319;    // my favorite number :-)
	bReturnCode = DeviceIoControl(hDriver, HELLONUM, iobuf, sizeof(int), iobuf, sizeof(iobuf), &dwBytesReturned, NULL);
	if (bReturnCode) {
	  sprintf(szString, "HELLONUM RETURNED %d bytes: >%s<\n", dwBytesReturned, iobuf);
		printf("HELLONUM RETURNED %d bytes: >%s<\n", dwBytesReturned, iobuf);
	}
	else 	printf("HELLONUM failed.\n");
	CloseHandle(hDriver);
    }
}
Exemple #27
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    GA_devCtx *dc = NULL;

    /* Now handle the query */
    if (argc >= 2 && stricmp(argv[1],"show") == 0) {
        dc = LoadDriver((argc > 2) ? atoi(argv[2]) : 0);
        ShowSettings(dc);
        }
    else if (argc >= 2 && stricmp(argv[1],"showvbe") == 0) {
        dc = LoadDriver((argc > 2) ? atoi(argv[2]) : 0);
        ShowVBESettings(dc);
        }
    else if (argc >= 5 && stricmp(argv[1],"add") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        AddMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 5 && stricmp(argv[1],"addref") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        AddRefresh(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 5 && stricmp(argv[1],"del") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        DelMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 6 && stricmp(argv[1],"set") == 0) {
        dc = LoadDriver((argc > 6) ? atoi(argv[6]) : 0);
        SetMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]),
            (argc > 7) ? atoi(argv[7]) : 0);
        }
    else
        help();
    if (dc)
        GA_unloadDriver(dc);
    return 0;
}
Exemple #28
0
/****************************************************************************
REMARKS:
Show the current settings for the chipset specific options LCD panel size.
Chipset specific options require that the SNAP Graphics driver be loaded.
****************************************************************************/
static void ShowSettings(
    int deviceIndex)
{
    LoadDriver(deviceIndex);
    printf("Panel size is currently set to %d x %d\n\n", opt.LCDPanelWidth, opt.LCDPanelHeight);
}
Exemple #29
0
void Graphics::ResetDefaultDriver()
{
	currentDriver = LoadDriver();
}
Exemple #30
0
// This routine initializes the power manager and notifies the system that
// its api set is ready to be used.  It returns TRUE if successful and FALSE
// if there's a problem.
EXTERN_C BOOL WINAPI
PmInit(VOID)
{
    BOOL fOk = TRUE;
    HANDLE hevPnPReady = NULL, hevResumeReady = NULL, hevSystemReady = NULL;
    HANDLE hevActivityTimersReady = NULL, hevDummy = NULL;

#ifndef SHIP_BUILD
    SETFNAME(_T("PmInit"));
#endif

    PMLOGMSG(ZONE_INIT || ZONE_API, (_T("+%s\r\n"), pszFname));

    // set up globals
    InitializeCriticalSection(&gcsPowerManager);
    InitializeCriticalSection(&gcsDeviceUpdateAPIs);
    gpFloorDx = NULL;
    gpCeilingDx = NULL;
    gpPowerNotifications = NULL;
    gpSystemPowerState = NULL;
    ghPmHeap = GetProcessHeap();
    gpDeviceLists = NULL;
    gppActivityTimers = NULL;
    ghevPowerManagerReady = NULL;
    ghevResume = NULL;
    ghevTimerResume = NULL;
    ghtPnP = NULL;
    ghtResume = NULL;
    ghtActivityTimers = NULL;
    ghtSystem = NULL;

    // cleanup event (hopefully never used)
    ghevPmShutdown = CreateEvent(NULL, TRUE, FALSE, NULL);
    if(ghevPmShutdown == NULL) {
        PMLOGMSG(ZONE_ERROR, (_T("%s: CreateEvent() failed for shutdown event\r\n"), pszFname));
        fOk = FALSE;
    } 

    // validate the power management registry settings.  OEM code should use this
    // routine to make sure that registry settings are present for all the power
    // states they expect to support.  If the registry is not configured, the OEM
    // code can treat it as a fatal error or perform its own initialization.
    if(fOk) {
        DWORD dwStatus = PlatformValidatePMRegistry();
        if(dwStatus != ERROR_SUCCESS) {
            PMLOGMSG(ZONE_ERROR, (_T("%s: PlatformValidatePMRegistry() failed %d\r\n"), 
                pszFname, dwStatus));
            fOk = FALSE;
        } else {
            // read the list of interface types we will monitor
            fOk = DeviceListsInit();
        }
    }

    // create events
    if(fOk) {
        ghevPowerManagerReady = CreateEvent(NULL, TRUE, FALSE, _T("SYSTEM/PowerManagerReady"));
        ghevResume = CreateEvent(NULL, FALSE, FALSE, NULL);
        ghevTimerResume = CreateEvent(NULL, FALSE, FALSE, NULL);
        hevPnPReady = CreateEvent(NULL, FALSE, FALSE, NULL);
        hevResumeReady = CreateEvent(NULL, FALSE, FALSE, NULL);
        hevSystemReady = CreateEvent(NULL, FALSE, FALSE, NULL);
        hevActivityTimersReady = CreateEvent(NULL, FALSE, FALSE, NULL);
        hevDummy = CreateEvent(NULL, FALSE, FALSE, NULL);

        // check everything
        if(hevPnPReady == NULL
        || hevResumeReady == NULL 
        || hevSystemReady == NULL
        || hevActivityTimersReady == NULL
        || hevDummy == NULL
        || ghevPowerManagerReady == NULL
        || ghevTimerResume == NULL
        || ghevResume == NULL) {
            PMLOGMSG(ZONE_ERROR, (_T("%s: event creation failure\r\n"), pszFname));
            fOk = FALSE;
        }
    }

    // start threads
    if(fOk) {
        ghtPnP = CreateThread(NULL, 0, PnpThreadProc, (LPVOID) hevPnPReady, 0, NULL);
        ghtResume = CreateThread(NULL, 0, ResumeThreadProc, (LPVOID) hevResumeReady, 0, NULL);
        ghtActivityTimers = CreateThread(NULL, 0, ActivityTimersThreadProc, 
            (LPVOID) hevActivityTimersReady, 0, NULL);
        
        // check everything
        if(ghtPnP == NULL 
        || ghtResume == NULL 
        || ghtActivityTimers == NULL) {
            PMLOGMSG(ZONE_ERROR, (_T("%s: thread creation failure\r\n"), pszFname));
            fOk = FALSE;
        }
    }

    // wait for threads to initialize (or fail to initialize)
    #define NUM_OF_READY_EXIT_PAIR 3
    HANDLE hEvents[] = { hevPnPReady, hevResumeReady, hevActivityTimersReady, 
        ghtPnP, ghtResume, ghtActivityTimers };
    int iReady = 0;
    while( iReady < NUM_OF_READY_EXIT_PAIR  && fOk) {
        DWORD dwStatus = WaitForMultipleObjects(dim(hEvents), hEvents, FALSE, INFINITE);
        switch(dwStatus) {
        // thread ready events
        case (WAIT_OBJECT_0 + 0):   // pnp ready
        case (WAIT_OBJECT_0 + 1):   // resume ready
        case (WAIT_OBJECT_0 + 2):   // activity timers ready
            // don't watch for the thread exiting now -- some may do
            // so if they don't have work to do.
            hEvents[dwStatus - WAIT_OBJECT_0 + NUM_OF_READY_EXIT_PAIR] = hevDummy;
            iReady++;
            break;

        // thread exiting events
        case (WAIT_OBJECT_0 + 3):   // pnp exited
        case (WAIT_OBJECT_0 + 4):   // resume exited
        case (WAIT_OBJECT_0 + 5):   // activity timers exited
            PMLOGMSG(ZONE_ERROR, (_T("%s: thread initialization failure\r\n"), pszFname));
            fOk = FALSE;
            break;
        default:
            PMLOGMSG(ZONE_ERROR, (_T("%s: WaitForMultipleObjects() returnd %d, status is %d\r\n"),
                pszFname, GetLastError()));
            fOk = FALSE;
            break;
        }
    }

    // load PMExt DLL, call init
    if (fOk) {
        TCHAR DevDll[DEVDLL_LEN];
        DWORD cbData;
        DWORD Flags;
        HKEY hKey;

        gpPMExtInit = NULL;
        gpPMExtDeinit = NULL;;

        // Note: TEXT("\\Omap") is appended to the PMExt_Registry_Root because this is the only PMExt that we support
        if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, PMExt_Registry_Root TEXT("\\Omap"), 0, 0, &hKey)) {
            cbData = sizeof(DevDll);
            if (ERROR_SUCCESS == RegQueryValueEx(hKey, DEVLOAD_DLLNAME_VALNAME, NULL, NULL, (LPBYTE) DevDll, &cbData)) {
                cbData = sizeof(Flags);
                if (ERROR_SUCCESS != RegQueryValueEx(hKey, DEVLOAD_FLAGS_VALNAME, NULL, NULL, (LPBYTE) &Flags, &cbData)) {
                    Flags = DEVFLAGS_NONE;
                }
                ghPMExtLib = (Flags & DEVFLAGS_LOADLIBRARY) ? LoadLibrary(DevDll) : LoadDriver(DevDll);
                if (!ghPMExtLib) {
                    PMLOGMSG(ZONE_ERROR, (_T("%s: couldn't load PMExt \"%s\" -- error %d\r\n"), pszFname, DevDll, GetLastError()));
                } 
                else {
                    gpPMExtInit = (PFN_PMExt_Init) GetProcAddress(ghPMExtLib, PMExt_Init_NAME);
                    if (!gpPMExtInit)
                        PMLOGMSG(ZONE_ERROR, (_T("%s: \"%s\" can't GetProcAddress\r\n"), pszFname, PMExt_Init_NAME));

                    gpPMExtDeinit = (PFN_PMExt_DeInit) GetProcAddress(ghPMExtLib, PMExt_DeInit_NAME);
                }
            }
            else {
                PMLOGMSG(ZONE_INIT, (_T("%s: can't get value \"%s\" in key \"%s\"\r\n"), pszFname, DEVLOAD_DLLNAME_VALNAME, PMExt_Registry_Root TEXT("\\Omap")));
            }
            if (gpPMExtInit && gpPMExtDeinit) {
#ifdef DEBUG
               gdwPMExtContext = gpPMExtInit(HKEY_LOCAL_MACHINE, PMExt_Registry_Root TEXT("\\Omap"));
#else
                __try {
                    gdwPMExtContext = gpPMExtInit(HKEY_LOCAL_MACHINE, PMExt_Registry_Root TEXT("\\Omap"));
                }
                __except(EXCEPTION_EXECUTE_HANDLER) {
                    gdwPMExtContext = 0;
                }
#endif
                if (!gdwPMExtContext)
                    PMLOGMSG(ZONE_ERROR, (_T("%s: \"%s\" failed\r\n"), pszFname, PMExt_Init_NAME));
                else
                    PMLOGMSG(ZONE_INIT, (_T("%s: \"%s\" success\r\n"), pszFname, PMExt_Init_NAME));
            }
            RegCloseKey(hKey);
        }