Beispiel #1
0
extern "C" int __declspec(dllexport) CListInitialise(PLUGINLINK * link)
{
	int rc = 0;
	DBVARIANT dbv;
	int       i;
	char	  szProfilePath[MAX_PATH];

	pluginLink = link;
#ifdef _DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

	mir_getMMI(&mmi);
	mir_getLI(&li);
	mir_getTMI(&tmi);
	mir_getLP( &pluginInfo );

	API::onInit();
	LoadCLCButtonModule();
	RegisterCLUIFrameClasses();

	ZeroMemory((void*) &cfg::dat, sizeof(cfg::dat));

	int iCount = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);

	iCount += 20;
	if( iCount < 300 )
		iCount = 300;

	cfg::eCache = reinterpret_cast<TExtraCache *>(malloc(sizeof(TExtraCache) * iCount));
	ZeroMemory(cfg::eCache, sizeof(struct TExtraCache) * iCount);
	cfg::nextCacheEntry = 0;
	cfg::maxCacheEntry = iCount;
	cfg::init();

	cfg::dat.toolbarVisibility = 		cfg::getDword("CLUI", "TBVisibility", DEFAULT_TB_VISIBILITY);
	cfg::dat.hMenuButtons = 			GetSubMenu(LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)), 3);
	cfg::dat.hMenuNotify = 				CreatePopupMenu();
	cfg::dat.wNextMenuID = 				1;
	cfg::dat.sortTimer = 				cfg::getDword("CLC", "SortTimer", 150);
	cfg::dat.szNoEvents = 				TranslateTS(szNoevents);
	cfg::dat.avatarBorder = 			(COLORREF)cfg::getDword("CLC", "avatarborder", 0);
	cfg::dat.avatarRadius = 			(COLORREF)cfg::getDword("CLC", "avatarradius", 4);
	cfg::dat.hBrushAvatarBorder = 		CreateSolidBrush(cfg::dat.avatarBorder);
	cfg::dat.avatarSize = 				cfg::getWord("CList", "AvatarSize", 24);
	cfg::dat.dualRowMode = 				cfg::getByte("CLC", "DualRowMode", 0);
	cfg::dat.avatarPadding = 			cfg::getByte("CList", "AvatarPadding", 0);
	cfg::dat.isTransparent = 			cfg::getByte("CList", "Transparent", 0);
	cfg::dat.alpha = 					cfg::getByte("CList", "Alpha", SETTING_ALPHA_DEFAULT);
	cfg::dat.autoalpha = 				cfg::getByte("CList", "AutoAlpha", SETTING_ALPHA_DEFAULT);
	cfg::dat.fadeinout = 				cfg::getByte("CLUI", "FadeInOut", 0);
	cfg::dat.autosize = 				cfg::getByte("CLUI", "AutoSize", 0);
	cfg::dat.dwExtraImageMask = 		cfg::getDword("CLUI", "ximgmask", 0);
	cfg::dat.bNoOfflineAvatars = 		cfg::getByte("CList", "NoOfflineAV", 1);
	cfg::dat.bFullTransparent = 		cfg::getByte("CLUI", "fulltransparent", 0);
	cfg::dat.bDblClkAvatars = 			cfg::getByte("CLC", "dblclkav", 0);
	cfg::dat.bEqualSections = 			cfg::getByte("CLUI", "EqualSections", 0);
	cfg::dat.bCenterStatusIcons = 		cfg::getByte("CLC", "si_centered", 1);
	cfg::dat.boldHideOffline = 			-1;
	cfg::dat.bSecIMAvail = 				ServiceExists("SecureIM/IsContactSecured") ? 1 : 0;
	cfg::dat.bNoTrayTips = 				cfg::getByte("CList", "NoTrayTips", 0);
	cfg::dat.bShowLocalTime = 			cfg::getByte("CLC", "ShowLocalTime", 1);
	cfg::dat.bShowLocalTimeSelective = 	cfg::getByte("CLC", "SelectiveLocalTime", 1);
	cfg::dat.bDontSeparateOffline = 	cfg::getByte("CList", "DontSeparateOffline", 0);
	cfg::dat.bShowXStatusOnSbar = 		cfg::getByte("CLUI", "xstatus_sbar", 0);
	cfg::dat.bLayeredHack = 			cfg::getByte("CLUI", "layeredhack", 1);
	cfg::dat.bFirstRun = 				cfg::getByte("CLUI", "firstrun", 1);
	cfg::dat.langPackCP = 				CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
	cfg::dat.realTimeSaving = 			cfg::getByte("CLUI", "save_pos_always", 0);

	DWORD sortOrder = cfg::getDword("CList", "SortOrder", SORTBY_NAME);
	cfg::dat.sortOrder[0] = LOBYTE(LOWORD(sortOrder));
	cfg::dat.sortOrder[1] = HIBYTE(LOWORD(sortOrder));
	cfg::dat.sortOrder[2] = LOBYTE(HIWORD(sortOrder));

	if(cfg::dat.bFirstRun)
		cfg::writeByte("CLUI", "firstrun", 0);

	if(!cfg::getString(NULL, "CLUI", "exIconOrder", &dbv)) {
		if(lstrlenA(dbv.pszVal) < EXICON_COUNT) {
			for(i = 1; i <= EXICON_COUNT; i++)
				cfg::dat.exIconOrder[i - 1] = i;
		} else {
			for(i = 0; i < EXICON_COUNT; i++)
				if(dbv.pszVal[i] < EXICON_COUNT+1 && dbv.pszVal[i] >0)
					cfg::dat.exIconOrder[i] = dbv.pszVal[i];
				else
					cfg::dat.exIconOrder[i] = i+1;
		}
		DBFreeVariant(&dbv);
	} else {
		for(i = 1; i <= EXICON_COUNT; i++)
			cfg::dat.exIconOrder[i - 1] = i;
	}
	ReloadThemedOptions();
	FLT_ReadOptions();
	Reload3dBevelColors();
	himlExtraImages = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 30, 2);
	ImageList_SetIconSize(himlExtraImages, cfg::dat.exIconScale, cfg::dat.exIconScale);

	cfg::dat.dwFlags = cfg::getDword("CLUI", "Frameflags", CLUI_FRAME_SHOWTOPBUTTONS | CLUI_FRAME_STATUSICONS |
                                                  CLUI_FRAME_SHOWBOTTOMBUTTONS | CLUI_FRAME_BUTTONSFLAT | CLUI_FRAME_CLISTSUNKEN);
	cfg::dat.dwFlags |= (cfg::getByte("CLUI", "ShowSBar", 1) ? CLUI_FRAME_SBARSHOW : 0);
	cfg::dat.soundsOff = cfg::getByte("CLUI", "NoSounds", 0);

	CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szProfilePath);

#if defined(_UNICODE)
	MultiByteToWideChar(CP_ACP, 0, szProfilePath, MAX_PATH, cfg::dat.tszProfilePath, MAX_PATH);
	cfg::dat.tszProfilePath[MAX_PATH - 1] = 0;
#else
	mir_sntprintf(cfg::dat.tszProfilePath, MAX_PATH, "%s", szProfilePath);
#endif

	_tcslwr(cfg::dat.tszProfilePath);

	if(cfg::getByte("Skin", "UseSound", 0) != cfg::dat.soundsOff)
		cfg::writeByte("Skin", "UseSound", (BYTE)(cfg::dat.soundsOff ? 0 : 1));

	// get the clist interface
	pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)g_hInst);
	if ( (INT_PTR)pcli == CALLSERVICE_NOTFOUND ) {
LBL_Error:
		MessageBoxA( NULL, "This plugin requires Miranda IM 0.8.0.9 or later", "Fatal error", MB_OK );
		return 1;
	}
	if ( pcli->version < 6 ) // don't join it with the previous if()
		goto LBL_Error;

	pcli->pfnBuildGroupPopupMenu = BuildGroupPopupMenu;
	pcli->pfnCluiProtocolStatusChanged = CluiProtocolStatusChanged;
	pcli->pfnCompareContacts = CompareContacts;
	pcli->pfnCreateClcContact = CreateClcContact;
	pcli->pfnCreateEvent = fnCreateEvent;
	pcli->pfnDocking_ProcessWindowMessage = Docking_ProcessWindowMessage;
	pcli->pfnGetDefaultFontSetting = GetDefaultFontSetting;
	pcli->pfnGetRowBottomY = RowHeight::getItemBottomY;
	pcli->pfnGetRowHeight = RowHeight::getHeight;
	pcli->pfnGetRowTopY = RowHeight::getItemTopY;
	pcli->pfnGetRowTotalHeight = RowHeight::getTotalHeight;
	pcli->pfnGetWindowVisibleState = GetWindowVisibleState;
	pcli->pfnHitTest = HitTest;
	pcli->pfnLoadContactTree = LoadContactTree;
	pcli->pfnOnCreateClc = LoadCLUIModule;
	pcli->pfnPaintClc = PaintClc;
	pcli->pfnRebuildEntireList = RebuildEntireList;
	pcli->pfnRowHitTest = RowHeight::hitTest;
	pcli->pfnScrollTo = ScrollTo;
	pcli->pfnTrayIconUpdateBase = TrayIconUpdateBase;
	pcli->pfnSetHideOffline = SetHideOffline;
	pcli->pfnShowHide = ShowHide;

	saveAddContactToGroup = pcli->pfnAddContactToGroup; pcli->pfnAddContactToGroup = AddContactToGroup;
	saveRemoveItemFromGroup = pcli->pfnRemoveItemFromGroup; pcli->pfnRemoveItemFromGroup = RemoveItemFromGroup;

	saveAddEvent = pcli->pfnAddEvent; pcli->pfnAddEvent = AddEvent;
	saveRemoveEvent = pcli->pfnRemoveEvent; pcli->pfnRemoveEvent = RemoveEvent;

	saveAddGroup = pcli->pfnAddGroup; pcli->pfnAddGroup = AddGroup;
	saveAddInfoItemToGroup = pcli->pfnAddInfoItemToGroup; pcli->pfnAddInfoItemToGroup = AddInfoItemToGroup;
	saveContactListControlWndProc = pcli->pfnContactListControlWndProc; pcli->pfnContactListControlWndProc = ContactListControlWndProc;
	saveContactListWndProc = pcli->pfnContactListWndProc; pcli->pfnContactListWndProc = ContactListWndProc;
	saveIconFromStatusMode = pcli->pfnIconFromStatusMode; pcli->pfnIconFromStatusMode = fnIconFromStatusMode;
	saveLoadClcOptions = pcli->pfnLoadClcOptions; pcli->pfnLoadClcOptions = LoadClcOptions;
	saveProcessExternalMessages = pcli->pfnProcessExternalMessages; pcli->pfnProcessExternalMessages = ProcessExternalMessages;
	saveRecalcScrollBar = pcli->pfnRecalcScrollBar; pcli->pfnRecalcScrollBar = RecalcScrollBar;
	saveTrayIconProcessMessage = pcli->pfnTrayIconProcessMessage; pcli->pfnTrayIconProcessMessage = TrayIconProcessMessage;

	rc = LoadContactListModule();
	if (rc == 0)
		rc = LoadCLCModule();
	HookEvent(ME_SYSTEM_MODULESLOADED, systemModulesLoaded);
	return rc;
}
Beispiel #2
0
/**************************************************************************
 * 			DriverProc (MCICDA.@)
 */
LRESULT CALLBACK MCICDA_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
                                   LPARAM dwParam1, LPARAM dwParam2)
{
    switch(wMsg) {
    case DRV_LOAD:		return 1;
    case DRV_FREE:		return 1;
    case DRV_OPEN:		return MCICDA_drvOpen((LPCWSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSW)dwParam2);
    case DRV_CLOSE:		return MCICDA_drvClose(dwDevID);
    case DRV_ENABLE:		return 1;
    case DRV_DISABLE:		return 1;
    case DRV_QUERYCONFIGURE:	return 1;
    case DRV_CONFIGURE:		MessageBoxA(0, "MCI audio CD driver !", "Wine Driver", MB_OK); return 1;
    case DRV_INSTALL:		return DRVCNF_RESTART;
    case DRV_REMOVE:		return DRVCNF_RESTART;
    }

    if (dwDevID == 0xFFFFFFFF) return MCIERR_UNSUPPORTED_FUNCTION;

    switch (wMsg) {
    case MCI_OPEN_DRIVER:	return MCICDA_Open(dwDevID, dwParam1, (LPMCI_OPEN_PARMSW)dwParam2);
    case MCI_CLOSE_DRIVER:	return MCICDA_Close(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
    case MCI_GETDEVCAPS:	return MCICDA_GetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2);
    case MCI_INFO:		return MCICDA_Info(dwDevID, dwParam1, (LPMCI_INFO_PARMSW)dwParam2);
    case MCI_STATUS:		return MCICDA_Status(dwDevID, dwParam1, (LPMCI_STATUS_PARMS)dwParam2);
    case MCI_SET:		return MCICDA_Set(dwDevID, dwParam1, (LPMCI_SET_PARMS)dwParam2);
    case MCI_PLAY:		return MCICDA_Play(dwDevID, dwParam1, (LPMCI_PLAY_PARMS)dwParam2);
    case MCI_STOP:		return MCICDA_Stop(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
    case MCI_PAUSE:		return MCICDA_Pause(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
    case MCI_RESUME:		return MCICDA_Resume(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
    case MCI_SEEK:		return MCICDA_Seek(dwDevID, dwParam1, (LPMCI_SEEK_PARMS)dwParam2);
    /* commands that should report an error as they are not supported in
     * the native version */
    case MCI_SET_DOOR_CLOSED:
    case MCI_SET_DOOR_OPEN:
    case MCI_LOAD:
    case MCI_SAVE:
    case MCI_FREEZE:
    case MCI_PUT:
    case MCI_REALIZE:
    case MCI_UNFREEZE:
    case MCI_UPDATE:
    case MCI_WHERE:
    case MCI_STEP:
    case MCI_SPIN:
    case MCI_ESCAPE:
    case MCI_COPY:
    case MCI_CUT:
    case MCI_DELETE:
    case MCI_PASTE:
    case MCI_WINDOW:
	TRACE("Unsupported command [0x%x]\n", wMsg);
	break;
    case MCI_OPEN:
    case MCI_CLOSE:
	ERR("Shouldn't receive a MCI_OPEN or CLOSE message\n");
	break;
    default:
	TRACE("Sending msg [0x%x] to default driver proc\n", wMsg);
	return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
    }
    return MCIERR_UNRECOGNIZED_COMMAND;
}
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
    MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
Beispiel #4
0
bool
D3D11Config::enumerateDisplaysCreateD3DDevice(oapi::GraphicsClient::VIDEODATA *vdata)
{
    oapiWriteLogV("D3D11Config::enumerateDisplaysCreateD3DDevice");
	
    DXGI_ADAPTER_DESC adapterDesc;
    DXGI_OUTPUT_DESC outputDesc;

    // First enumerate the monitors
    PHYSICAL_MONITOR monitor;
    UINT adapterCount = 0, outputCount = 0;
    char *line, cbuf[128];
    HR( CreateDXGIFactory1( __uuidof(IDXGIFactory1), (void**)(&m_dxgiFactory) ) );
    if (!m_dxgiFactory) {
        SHOW_MESSAGE("Initialization error", "CreateDXGIFactory1 failed");
        return false;
    }
    while ( m_dxgiFactory->EnumAdapters1( adapterCount, &dxgiAdapter ) == S_OK ) {
        dxgiAdapter->GetDesc( &adapterDesc );
        while ( dxgiAdapter->EnumOutputs( outputCount, &dxgiOutput ) == S_OK ) {
			dxgiOutput->GetDesc(&outputDesc);

            GetPhysicalMonitorsFromHMONITOR( outputDesc.Monitor, 1, &monitor );
            wcstombs( cbuf, monitor.szPhysicalMonitorDescription, 128 );
            DestroyPhysicalMonitors( 1, &monitor );

            line = new char [128];
            vecDXGIAdapterOutputDesc.push_back( line );
			wcstombs(vecDXGIAdapterOutputDesc[outputCount], adapterDesc.Description, 128);
			strcat(vecDXGIAdapterOutputDesc[outputCount], cbuf);

            vecDXGIOutputs.push_back( dxgiOutput );
            ++outputCount;
        }

        vecDXGIAdapters.push_back( dxgiAdapter );
        ++adapterCount;
    }
    UINT numOutputs = outputCount;

    if ( vdata->deviceidx < 0 || (UINT)vdata->deviceidx > outputCount ) {
        vdata->deviceidx = 0;
    }

    UINT numModes;
    vecDXGIOutputs[vdata->deviceidx]->GetDisplayModeList( DXGI_FORMAT_B8G8R8A8_UNORM,
                                                          0, &numModes, NULL );
    DXGI_MODE_DESC *modes = new DXGI_MODE_DESC [numModes];
    vecDXGIOutputs[vdata->deviceidx]->GetDisplayModeList( DXGI_FORMAT_B8G8R8A8_UNORM,
                                                          0, &numModes, modes );

    dxgiAdapter = vecDXGIAdapters[vdata->deviceidx];
    dxgiOutput = vecDXGIOutputs[vdata->deviceidx];
    dxgiMode = modes[vdata->modeidx];

    //FullScreenWindow = vdata->pageflip;
    driverType = /*vdata->forceenum ? D3D_DRIVER_TYPE_REFERENCE : */D3D_DRIVER_TYPE_UNKNOWN;
    bFullScreenWindow = vdata->fullscreen;
    dwWidth = vdata->winw;
    dwHeight = vdata->winh;

    D3D_FEATURE_LEVEL featureLevels[ ] = {
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0,
        D3D_FEATURE_LEVEL_9_3,
        D3D_FEATURE_LEVEL_9_2,
        D3D_FEATURE_LEVEL_9_1
    };

    UINT createDeviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef _DEBUG
    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

    HRESULT result = D3D11CreateDevice(
        dxgiAdapter,
        driverType,  // Not unknown
        0,                              // no software device
        createDeviceFlags,
        featureLevels,
        3,                              // Why 3 ? !!
        D3D11_SDK_VERSION,
        &m_d3dDevice,
        &(succeededFeatureLevel),
        &m_d3dImmContext);

    if (!m_d3dDevice) {
        char errMsg[200];
        sprintf(errMsg, "Device creation failed.\nError code: 0x%08p", result);
        MessageBoxA( m_GraphicsClient.m_hWindow, errMsg, "Critical error.",
                     MB_ICONERROR | MB_OK );
    }

    // D3D11 Debugging
  //  m_d3dDevice->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_d3dDebug));

	return true;
}
Beispiel #5
0
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR szCmdLine, int iCmdShow)
{
	WNDCLASSEX winClass ;

	winClass.lpszClassName = L"Sphere";
	winClass.cbSize        = sizeof(WNDCLASSEX);
	winClass.style         = CS_HREDRAW | CS_VREDRAW;
	winClass.lpfnWndProc   = MsgProc;
	winClass.hInstance     = hInstance;
	winClass.hIcon	       = NULL ;
	winClass.hIconSm	   = NULL ;
	winClass.hCursor       = LoadCursor(NULL, IDC_ARROW) ;
	winClass.hbrBackground = NULL ;
	winClass.lpszMenuName  = NULL ;
	winClass.cbClsExtra    = 0;
	winClass.cbWndExtra    = 0;

	RegisterClassEx (&winClass) ;  

	HWND hWnd = CreateWindowEx(NULL,  
		winClass.lpszClassName,		// window class name
		L"Sphere",				// window caption
		WS_OVERLAPPEDWINDOW, 		// window style
		32,							// initial x position
		32,							// initial y position
		800,						// initial window width
		600,						// initial window height
		NULL,						// parent window handle
		NULL,						// window menu handle
		hInstance,					// program instance handle
		NULL) ;						// creation parameters

	// Create window failed
	if(hWnd == NULL)
	{
		MessageBoxA(hWnd, "Create Window failed!", "Error", 0) ;
		return -1 ;
	}

	// Initialize Direct3D
	if( SUCCEEDED(InitD3D(hWnd)))
	{ 
		// Show the window
		ShowWindow( hWnd, SW_SHOWDEFAULT );
		UpdateWindow( hWnd );

		MSG msg ; 
		ZeroMemory( &msg, sizeof(msg) );
		PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE );

		// Get last time
		static DWORD lastTime = timeGetTime();

		while (msg.message != WM_QUIT)  
		{
			if(PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) != 0)
			{
				TranslateMessage (&msg) ;
				DispatchMessage (&msg) ;
			}
			else // Render the game if there is no message to process
			{
				// Get current time
				DWORD currTime  = timeGetTime();

				// Calculate time elapsed
				float timeDelta = (currTime - lastTime) * 0.001f;

				// Render
				Render(timeDelta) ;

				// Update last time to current time for next loop
				lastTime = currTime;
			}
		}
	}

	UnregisterClass(winClass.lpszClassName, hInstance) ;
	return 0;
}
Beispiel #6
0
BOOL APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	PCHAR pszDllPath = "Accelerator.dll";

	CHAR szDllPath[1024];
    PCHAR pszFilePart = NULL;

	if (!GetFullPathName(pszDllPath, ARRAYSIZE(szDllPath), szDllPath, &pszFilePart)) 
	{
        MessageBoxA(NULL, "GetFullPathName Failed\n", "Error", MB_OK);
        return false;
    }

	HMODULE hDll = LoadLibraryEx(pszDllPath, NULL, DONT_RESOLVE_DLL_REFERENCES);
    if (hDll == NULL) 
	{
		MessageBoxA(NULL, "Failed to load dll\n", "Error", MB_OK);
        return false;
    }

	ExportContext ec;
    ec.fHasOrdinal1 = FALSE;
    ec.nExports = 0;
    DetourEnumerateExports(hDll, &ec, ExportCallback);
    FreeLibrary(hDll);

	if (!ec.fHasOrdinal1) 
	{
		MessageBoxA(NULL, "This dll does not export ordinal #1.\n", "Error", MB_OK);
        return false;
    }
	//////////////////////////////////////////////////////////////////////////////////
	STARTUPINFO si;
    PROCESS_INFORMATION pi;
    CHAR szCommand[2048];
    CHAR szExe[1024];
    CHAR szFullExe[1024] = "\0";
    PCHAR pszFileExe = NULL;

    ZeroMemory(&si, sizeof(si));
    ZeroMemory(&pi, sizeof(pi));
    si.cb = sizeof(si);

    szCommand[0] = L'\0';
	strcpy(szExe, "Natsu.exe");
	strcpy(szCommand, "Natsu.exe");
	//////////////////////////////////////////////////////////////////////////////////
	DWORD dwFlags = CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED;

    SetLastError(0);
    SearchPath(NULL, szExe, ".exe", ARRAYSIZE(szFullExe), szFullExe, &pszFileExe);
    if (!DetourCreateProcessWithDllEx(szFullExe[0] ? szFullExe : NULL, szCommand,
                                      NULL, NULL, TRUE, dwFlags, NULL, NULL,
                                      &si, &pi, szDllPath, NULL)) 
	{
        DWORD dwError = GetLastError();
		MessageBoxA(NULL, "DetourCreateProcessWithDllEx failed\n", "Error", MB_OK);
        
        if (dwError == ERROR_INVALID_HANDLE)
		{
#if DETOURS_64BIT
			MessageBoxA(NULL, " Can't detour a 32-bit target process from a 64-bit parent process.\n", "Error", MB_OK);
            
#else
			MessageBoxA(NULL, " Can't detour a 64-bit target process from a 32-bit parent process.\n", "Error", MB_OK);
#endif
        }
        ExitProcess(9009);
    }

    ResumeThread(pi.hThread);

    WaitForSingleObject(pi.hProcess, INFINITE);

    DWORD dwResult = 0;
    if (!GetExitCodeProcess(pi.hProcess, &dwResult)) 
	{
		MessageBoxA(NULL, "GetExitCodeProcess failed\n", "Error", MB_OK);
        return false;
    }

    return true;
}
Beispiel #7
0
DWORD ServerHandler()
{

    bool running = true;

    // Socket handler
    SOCKET socketHnd;
    // Winsock data
    WSADATA wsaData;

    // Check for error
    if (WSAStartup(WSCK_V2, &wsaData))
    {
        errorFlags &= ERR_STARTUP;
        running = false;
    }

    // We want version 2
    if (wsaData.wVersion != WSCK_V2)
    {
        errorFlags &= ERR_WRONGVERSION;
        running = false;
    }

    // For TCP...
    SOCKADDR_IN sckAddr;
    sckAddr.sin_family = AF_INET;
    sckAddr.sin_port = htons(9009);	// Port 9009, will probably change to load from a config file later
    sckAddr.sin_addr.s_addr = htonl(INADDR_ANY); // Listen from connections from ANY computer

    // Create the socket
    socketHnd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    if (socketHnd == INVALID_SOCKET)
    {
        errorFlags &= ERR_SOCKETERR;
        running = false;
    }

    if (bind(socketHnd, (LPSOCKADDR)&sckAddr, sizeof(sckAddr)) == SOCKET_ERROR)
    {
        errorFlags &= ERR_BINDERR;
        running = false;
    }

    if (running && errorFlags == 0)
    {
        MessageBoxA(NULL, "Server initialized, close this window to begin listening!", "Info", MB_ICONINFORMATION);
        // Listen with one backlog max
        listen(socketHnd, 1);
    }

    // player X and Y, 4 bytes at 0049E654 and 0049E658
    DWORD *playerX;
    DWORD *playerY;

    DWORD *playerMapID;

    PACKETHEADER PID;
    while (running)
    {
        playerX = (DWORD*)0x0049E654;
        playerY = (DWORD*)0x0049E658;

        playerMapID = (DWORD*)0x004A57F0;

        // Ctrl + F12 unloads the DLL
        if (GetKeyState(VK_CONTROL) && GetKeyState(VK_F12))
            running = false;

        // If polled to exit then stop running
        if (poll_exit)
            running = false;

        /*=========================================
        /* Data sending
        /*=========================================*/
        Buffer buf(13);	// 13 bytes in length
        buf.WriteByte(ID_LOC);
        buf.WriteInt((int)&playerX);
        buf.WriteInt((int)&playerY);
        buf.WriteInt((int)&playerMapID);

        send(socketHnd, (char*)buf.GetBytes(), buf.GetLength(), 0);
        //buf.Clear();

        Buffer buf2(80);
        // Pass the old buffer pointer
        recv(socketHnd, (char*)buf2.GetBytes(), sizeof(buf2.GetBytes())-1, 0);

        // Sleep to allow execution of other threads (and limit actions to about 30 FPS)
        Sleep(34);
    }

    //MessageBoxA(NULL, "test", "test", NULL);

    WSACleanup();

    //if (errorFlags > 0)
    //{
    //	char errMsg[1024];
    //	strcpy(errMsg, "There were error(s):\n");

    //	if (errorFlags & ERR_STARTUP)
    //		strcat(errMsg, "An error occurred while WinSock was initializing\n");
    //	if (errorFlags & ERR_WRONGVERSION)
    //		strcat(errMsg, "WinSock initialized the wrong version\n");
    //	if (errorFlags & ERR_SOCKETERR)
    //		strcat(errMsg, "Socket creation failed\n");
    //	if (errorFlags & ERR_BINDERR)
    //		strcat(errMsg, "Socket bind failed\n");
    //
    //	MessageBoxA(NULL, errMsg, "Error", MB_ICONERROR);
    //}

    return 0;
}
Beispiel #8
0
		void init()
		{
			input_handler = 0;
			init_keytable();

			//_ui_events.reserve(40);

			_ui_key = 0;

			WNDCLASS wc = { 0 };
			wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
			wc.lpfnWndProc = wnd_proc;
			wc.hInstance = GetModuleHandle(0);
			wc.hIcon = LoadIcon(0, IDI_WINLOGO);
			wc.hCursor = LoadCursor(0, IDC_ARROW);
			wc.lpszClassName = "shiva_wc";

			if (!RegisterClass(&wc)) {
				TRACE("Failed to register window class\n");
				return;
			}

			init_gl();

			DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW;
			DWORD xstyle = WS_EX_APPWINDOW;

			PIXELFORMATDESCRIPTOR pfd = {
				sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
				PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
			};



			if (0/*fulscreen*/) {
				style = WS_POPUP | WS_MAXIMIZE;
				xstyle |= WS_EX_TOPMOST;

				DEVMODE deviceMode = { 0 };
				deviceMode.dmSize = sizeof(DEVMODE);
				EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &deviceMode);

				if (ChangeDisplaySettings(&deviceMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
					TRACE("Failed to set fullscreen window");
				}
			}

			RECT wr = { 0, 0, 800, 600 };
			AdjustWindowRectEx(&wr, style, 0, xstyle);
			int w = wr.right - wr.left;
			int h = wr.bottom - wr.top;

			wnd = CreateWindowEx(xstyle, wc.lpszClassName, "OpenVG", style, 10, 10, w, h, 0, 0, wc.hInstance, 0);
			if (!wnd) {
				TRACE("Failed to create system window!\n");
				return;
			}

			dc = GetDC(wnd);

			int pixelFormat;
			BOOL valid;
			UINT numFormats;
			int iAttributes[] = {
				WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
				WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
				WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
				WGL_COLOR_BITS_ARB, 24,
				WGL_ALPHA_BITS_ARB, 8,
				WGL_DEPTH_BITS_ARB, 24,
				WGL_STENCIL_BITS_ARB, 8,
				WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
				0, 0 };

			    // WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
				// WGL_SAMPLES_ARB, 4,                        // Check For 4x Multisampling


			if (wglChoosePixelFormatARB == NULL)
			{
				if (wglGetCurrentContext() == NULL) {
					// 
					MessageBoxA(0, (char*)glGetString(GL_VERSION), "Context lost", 0);

				}


				MessageBoxA(0, (char*)glGetString(GL_VERSION), "Cannot find extension, wglChoosePixelFormatARB", 0);
			}
			else
			{

				valid = wglChoosePixelFormatARB(dc, iAttributes, 0, 1, &pixelFormat, &numFormats);

				int pf = ChoosePixelFormat(dc, &pfd);
				BOOL ok = SetPixelFormat(dc, pixelFormat, &pfd);

			}

			int attr[] = {
				WGL_CONTEXT_MAJOR_VERSION_ARB, 1,
				WGL_CONTEXT_MINOR_VERSION_ARB, 2,
				WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
				WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
				WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
				0
			};

			                                                                 
			if (wglCreateContextAttribsARB == NULL)
			{
				MessageBoxA(0, (char*)glGetString(GL_VERSION), "Cannot find extension, wglCreateContextAttribsARB", 0);
				return;
			}


			glrc = wglCreateContextAttribsARB(dc, 0, attr);

			/*
			for (int i = 0; i < 2; ++i) {
			GLuint swap_group = 1;
			if (!wglJoinSwapGroupNV(context.channels[i].dc, swap_group)) {
			TRACE("ERROR: failed to join sawp group");
			}
			if (!wglBindSwapBarrierNV(swap_group, 1)) {
			TRACE("ERROR: failed to bind sawp barrier");
			}
			}
			*/

			// set channel 0 to current so graphics can initiate correctly
			wglMakeCurrent(dc, glrc);

			glDebugMessageCallbackARB = (PFGLDEBUGMESSAGECALLBACKARB) wglGetProcAddress("glDebugMessageCallbackARB");
			if (glDebugMessageCallbackARB == NULL)
			{
				MessageBoxA(0, (char*)glGetString(GL_VERSION), "Unimplemented glDebugMessageCallbackARB", 0);
			}
			else
			{
				glDebugMessageCallbackARB(&gl_debug_msg_proc, 0);
				glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
			}

			ShowWindow(wnd, SW_SHOW);
			UpdateWindow(wnd);

			vgCreateContextSH(800, 600);
		}
Beispiel #9
0
_MonoObject* my_mono_jit_runtime_invoke(_MonoMethod *method, void *obj, void **params, _MonoObject **exc, _MonoError *error)
{
	MessageBoxA(NULL, "my_mono_jit_runtime_invoke", "my_mono_jit_runtime_invoke", MB_OK);
}
Beispiel #10
0
void CMyOGLApp::Init()
{
	// törlési szín legyen kékes
	glClearColor(0.125f, 0.25f, 0.5f, 1.0f);

	glEnable(GL_CULL_FACE); // kapcsoljuk be a hatrafele nezo lapok eldobasat
	glEnable(GL_DEPTH_TEST); // mélységi teszt bekapcsolása (takarás)

	//
	// geometria letrehozasa
	//

	Vertex vert[] =
	{ 
		{glm::vec3(-1, -1, 0), glm::vec3(1, 0, 0)},
		{glm::vec3(-1,  1, 0), glm::vec3(0, 0, 1)},
		{glm::vec3( 1, -1, 0), glm::vec3(0, 1, 0)},
		{glm::vec3( 1,  1, 0), glm::vec3(1, 1, 1)},
	};

	// 1 db VAO foglalasa
	glGenVertexArrays(1, &m_vaoID);
	// a frissen generált VAO beallitasa aktívnak
	glBindVertexArray(m_vaoID);
	
	// hozzunk létre egy új VBO erõforrás nevet
	glGenBuffers(1, &m_vboID); 
	glBindBuffer(GL_ARRAY_BUFFER, m_vboID); // tegyük "aktívvá" a létrehozott VBO-t
	// töltsük fel adatokkal az aktív VBO-t
	glBufferData( GL_ARRAY_BUFFER,	// az aktív VBO-ba töltsünk adatokat
				  sizeof(vert),		// ennyi bájt nagyságban
				  vert,	// errõl a rendszermemóriabeli címrõl olvasva
				  GL_STATIC_DRAW);	// úgy, hogy a VBO-nkba nem tervezünk ezután írni és minden kirajzoláskor felhasnzáljuk a benne lévõ adatokat
	

	// VAO-ban jegyezzük fel, hogy a VBO-ban az elsõ 3 float sizeof(Vertex)-enként lesz az elsõ attribútum (pozíció)
	glEnableVertexAttribArray(0); // ez lesz majd a pozíció
	glVertexAttribPointer(
		(GLuint)0,				// a VB-ben található adatok közül a 0. "indexû" attribútumait állítjuk be
		3,				// komponens szam
		GL_FLOAT,		// adatok tipusa
		GL_FALSE,		// normalizalt legyen-e
		sizeof(Vertex),	// stride (0=egymas utan)
		0				// a 0. indexû attribútum hol kezdõdik a sizeof(Vertex)-nyi területen belül
	); 

	// a második attribútumhoz pedig a VBO-ban sizeof(Vertex) ugrás után sizeof(glm::vec3)-nyit menve újabb 3 float adatot találunk (szín)
	glEnableVertexAttribArray(1); // ez lesz majd a szín
	glVertexAttribPointer(
		(GLuint)1,
		3, 
		GL_FLOAT,
		GL_FALSE,
		sizeof(Vertex),
		(void*)(sizeof(glm::vec3)) );

	glBindVertexArray(0); // feltöltüttük a VAO-t, kapcsoljuk le
	glBindBuffer(GL_ARRAY_BUFFER, 0); // feltöltöttük a VBO-t is, ezt is vegyük le

	//
	// shaderek betöltése
	//
	GLuint vs_ID = loadShader(GL_VERTEX_SHADER,		"myVert.vert");
	GLuint fs_ID = loadShader(GL_FRAGMENT_SHADER,	"myFrag.frag");

	// a shadereket tároló program létrehozása
	m_programID = glCreateProgram();

	// adjuk hozzá a programhoz a shadereket
	glAttachShader(m_programID, vs_ID);
	glAttachShader(m_programID, fs_ID);

	// attributomok osszerendelese a VAO es shader kozt
	glBindAttribLocation( m_programID, 0, "vs_in_pos");
	glBindAttribLocation( m_programID, 1, "vs_in_col");

	// illesszük össze a shadereket (kimenõ-bemenõ változók összerendelése stb.)
	glLinkProgram(m_programID);

	// linkeles ellenorzese
	GLint infoLogLength = 0, result = 0;

	glGetProgramiv(m_programID, GL_LINK_STATUS, &result);
	glGetProgramiv(m_programID, GL_INFO_LOG_LENGTH, &infoLogLength);
	if ( infoLogLength > 1)
	{
		std::vector<char> ProgramErrorMessage( infoLogLength );
		glGetProgramInfoLog(m_programID, infoLogLength, NULL, &ProgramErrorMessage[0]);
		fprintf(stdout, "%s\n", &ProgramErrorMessage[0]);
		
		char* aSzoveg = new char[ProgramErrorMessage.size()];
		memcpy( aSzoveg, &ProgramErrorMessage[0], ProgramErrorMessage.size());

		MessageBoxA(0, aSzoveg, "Sáder Huba panasza", 0);

		delete aSzoveg;
	}

	// mar nincs ezekre szukseg
	glDeleteShader( vs_ID );
	glDeleteShader( fs_ID );

	//
	// egyéb inicializálás
	//

	// vetítési mátrix létrehozása
	m_matProj = glm::perspective( 45.0f, m_client_width/(float)m_client_height, 1.0f, 1000.0f );

	// shader-beli transzformációs mátrixok címének lekérdezése
	m_loc_world = glGetUniformLocation( m_programID, "world");
	m_loc_view  = glGetUniformLocation( m_programID, "view" );
	m_loc_proj  = glGetUniformLocation( m_programID, "proj" );

}
Beispiel #11
0
void Graphics::Display::ShowWarning(std::string warning)
{
#if defined(_WIN32)
    MessageBoxA(NULL, warning.c_str(), "Warning", MB_ICONWARNING);
#endif
}
Beispiel #12
0
 // Raises that an error happened
 void Raise()
 {
     MessageBoxA(0, "Fatal error on ControllerBlockManager", "Plugin SDK", MB_ICONERROR);
     ExitProcess(222);
 }
Beispiel #13
0
// Handles all networking events
DWORD WINAPI HandleNetworking( LPVOID )
{
    // Create RakNet interfaces
    RakNet::RakPeerInterface *peer;
    RakNet::Packet *packet;

    // Initialize networking
    peer = RakNet::RakPeerInterface::GetInstance();

    // Rev up your engines
    RakNet::SocketDescriptor sd( 0, "127.0.0.1" );
    peer->Startup( 1, &sd, 1 );

    // GO GO GO
    RakNet::ConnectionAttemptResult attempt = peer->Connect( "127.0.0.1", 5187, NULL, 0 );

    // Success?
    if( attempt != RakNet::CONNECTION_ATTEMPT_STARTED )
    {
        // Nope
        switch( attempt )
        {
        // None of these should happen, EVER.
        case RakNet::ALREADY_CONNECTED_TO_ENDPOINT:
            MessageBoxA
            (
                NULL,
                "A connection attempt was made to a server we're already connected to.\nPlease contact a developer.",
                "SC4Multi -- Network Error",
                MB_OK | MB_ICONERROR
            );
            break;
        case RakNet::CANNOT_RESOLVE_DOMAIN_NAME:
            MessageBoxA
            (
                NULL,
                "The given domain name could not be resolved.",
                "SC4Multi -- Network Error",
                MB_OK | MB_ICONERROR
            );
            break;
        case RakNet::CONNECTION_ATTEMPT_ALREADY_IN_PROGRESS:
            MessageBoxA
            (
                NULL,
                "Two connection attempts were being made at once by SC4Multi.\nPlease contact a developer.",
                "SC4Multi -- Network Error",
                MB_OK | MB_ICONERROR
            );
            break;
        case RakNet::INVALID_PARAMETER:
            MessageBoxA
            (
                NULL,
                "An invalid parameter was passed by SC4Multi. Please contact a developer.",
                "SC4Multi -- Network Error",
                MB_OK | MB_ICONERROR
            );
            break;
        case RakNet::SECURITY_INITIALIZATION_FAILED:
            MessageBoxA
            (
                NULL,
                "Security initialization failed. Something is terribly wrong,\nplease contact a developer.",
                "SC4Multi -- Network Error",
                MB_OK | MB_ICONERROR
            );
            break;
        default:
            MessageBoxA
            (
                NULL,
                "Something went wrong during network initialization,\nand we don't know what.",
                "SC4Multi -- Network Error",
                MB_OK | MB_ICONERROR
            );
            break;
        }

        // Terminate via ugly hacks
        exit( 1 );
    }

    // Forever and ever and ever and ever and ever and...
    while( isRunning )
    {
        // If there are any packets, read it
        for( packet = peer->Receive(); packet; peer->DeallocatePacket( packet ), packet = peer->Receive() )
        {
            // Get the packet type ID
            switch( packet->data[0] )
            {
            case ID_REMOTE_DISCONNECTION_NOTIFICATION:
                MessageBoxA( NULL, "Other client quit", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            case ID_REMOTE_CONNECTION_LOST:
                MessageBoxA( NULL, "Other client timeout", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            case ID_REMOTE_NEW_INCOMING_CONNECTION:
                MessageBoxA( NULL, "Other client connection", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            case ID_CONNECTION_REQUEST_ACCEPTED:
            {
                MessageBoxA( NULL, "Our connection succeeded", "SC4Multi", MB_OK | MB_ICONINFORMATION );

                // Read the machine GUID generated by Windows
                char guid_net[255];
                bool isGuidNull = false;
                {
                    // Create a wide-char GUID buffer
                    wchar_t guid[255];

                    // Registry stuff
                    HKEY hKey    = 0;
                    DWORD dwType = 0;

                    // Get the size of our buffer
                    DWORD dwBufSize = sizeof( guid );

                    // Define the subkey
                    const wchar_t* subkey = L"Software\\Microsoft\\Cryptography";

                    // Open the registry
                    if( RegOpenKey( HKEY_LOCAL_MACHINE, subkey, &hKey ) == ERROR_SUCCESS )
                    {
                        // We're looking for a string
                        dwType = REG_SZ;

                        // Read to our buffer
                        if( !RegQueryValueEx( hKey, L"MachineGuid", 0, &dwType, (BYTE *)guid, &dwBufSize ) == ERROR_SUCCESS )
                        {
                            // Fall back to a null GUID
                            isGuidNull = true;
                        }
                        else
                        {
                            // Convert the wide char buffer into a char buffer
                            wcstombs( guid_net, guid, 255 );
                        }
                    }
                    else
                    {
                        // Fall back to a null GUID
                        isGuidNull = true;
                    }
                }

                // Initialize a bitstream
                RakNet::BitStream bsOut;

                // Send our user data to the server
                {
                    // Packet ID
                    bsOut.Write( (RakNet::MessageID)ID_SC4_CONNECTION_DATA );

                    // Nickname
                    bsOut.Write( "Stormeus" );

                    // Unique GUID, or a null one
                    if( isGuidNull )
                        bsOut.Write( 0 );
                    else
                    {
#ifdef DEBUG
                        MessageBoxA( NULL, guid_net, "SC4Multi -- GUID", MB_ICONINFORMATION | MB_OK );
#endif

                        bsOut.Write( guid_net );
                    }

                    // City taken
                    bsOut.Write( "Unknown City" );
                }

                // Priority shipping to the server
                peer->Send
                (
                    &bsOut,
                    HIGH_PRIORITY,
                    RELIABLE_ORDERED,
                    0,
                    packet->systemAddress,
                    false
                );

                break;
            }
            case ID_NEW_INCOMING_CONNECTION:
                MessageBoxA( NULL, "Incoming connection", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            case ID_NO_FREE_INCOMING_CONNECTIONS:
                MessageBoxA( NULL, "Server is full", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            case ID_DISCONNECTION_NOTIFICATION:
                MessageBoxA( NULL, "We disconnected", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            case ID_CONNECTION_LOST:
                MessageBoxA( NULL, "We lost connection", "SC4Multi", MB_OK | MB_ICONINFORMATION );
                break;
            }
        }
    }

    // Destroy this instance
    RakNet::RakPeerInterface::DestroyInstance( peer );

    // And we're done here.
    MessageBoxA( NULL, "Destroyed RakNet instance.", "SC4Multi -- Networking Debug", MB_OK | MB_ICONEXCLAMATION );

    return 1;
}
Beispiel #14
0
HANDLE TwitterProto::ChangeInfo(int type,void *info_data)
{
	MessageBoxA(0,"ChangeInfo","",0);
	return 0;
}
Beispiel #15
0
/*
 * DlgProcYahooOpts - Connection Options Dialog
 */
static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	YList *l;
	CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );

	switch ( msg ) {
	case WM_INITDIALOG:
		TranslateDialogDefault( hwndDlg );

		ppro = ( CYahooProto* )lParam;
		SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );

		if ( ppro->GetByte( "IgnoreUnknown", 0 )) {
			CheckDlgButton(hwndDlg, IDC_OPT_IGN_UNKNOWN, 1);

			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), 0);
			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), 0);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), 0);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), 0);
		}
		else CheckDlgButton(hwndDlg, IDC_OPT_IGN_LIST, 1);

		/* show our current ignore list */
		LOG(("[DlgProcYahooOptsIgnore] Grabbing current ignore list..."))
		l = (YList *)ppro->GetIgnoreList();
		while (l != NULL) {
			struct yahoo_buddy *b = (struct yahoo_buddy *) l->data;

			LOG(("[DlgProcYahooOptsIgnore] Buddy: %s", b->id ))
			SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)b->id);
			l = l->next;
		}
		LOG(("[DlgProcYahooOptsIgnore] End of Ignore List..."))
		
		return TRUE;

	case WM_COMMAND:
		switch ( LOWORD( wParam )) {
		case IDC_OPT_IGN_UNKNOWN:
		case IDC_OPT_IGN_LIST:
			if (( HWND )lParam != GetFocus()) return 0;

			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), LOWORD( wParam ) == IDC_OPT_IGN_LIST);

			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_IGN_ADD: 
			if (!ppro->m_bLoggedIn)
				MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to add to Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
			else {
				char id[128];
				int i = GetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, id, sizeof( id ));

				if (i < 3) {
					MessageBoxA(hwndDlg, Translate("Please enter a valid buddy name to ignore."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
					break;
				}

				i = SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_FINDSTRINGEXACT,(WPARAM) -1, (LPARAM)id);
				if (i != LB_ERR ) {
					MessageBoxA(hwndDlg, Translate("The buddy is already on your ignore list. "), Translate("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION);
					break;
				}
				ppro->IgnoreBuddy(id, 0);
				SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)id);
				SetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, "" );
			}
			break;

		case IDC_IGN_REMOVE:
			{
				int i;
				char id[128];

				if (!ppro->m_bLoggedIn) {
					MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to remove from the Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
					break;
				}

				i = SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETCURSEL, 0, 0);
				if (i == LB_ERR) {
					MessageBoxA(hwndDlg, Translate("Please select a buddy on the ignore list to remove."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
					break;
				}

				SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETTEXT, i, (LPARAM)id);

				ppro->IgnoreBuddy(id, 1);
				SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_DELETESTRING, i, 0);
			}	
		}
		break;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
			ppro->SetByte("IgnoreUnknown", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_OPT_IGN_UNKNOWN ));
			return TRUE;
		}
		break;
	}

	return FALSE;
}
Beispiel #16
0
static bool OnCrash(const wchar_t * dumpPath,
                    const wchar_t * miniDumpId,
                    void * context,
                    EXCEPTION_POINTERS * exinfo,
                    MDRawAssertionInfo * assertion,
                    bool succeeded)
{
    if (!succeeded)
    {
        constexpr const char * DumpFailedMessage = "Failed to create the dump. Please file an issue with OpenRCT2 on GitHub and provide latest save, and provide information about what you did before the crash occured.";
        printf("%s\n", DumpFailedMessage);
        if (!gOpenRCT2SilentBreakpad)
        {
            MessageBoxA(NULL, DumpFailedMessage, OPENRCT2_NAME, MB_OK | MB_ICONERROR);
        }
        return succeeded;
    }

    // Get filenames
    wchar_t dumpFilePath[MAX_PATH];
    wchar_t saveFilePath[MAX_PATH];
    swprintf_s(dumpFilePath, sizeof(dumpFilePath), L"%s%s.dmp", dumpPath, miniDumpId);
    swprintf_s(saveFilePath, sizeof(saveFilePath), L"%s%s.sv6", dumpPath, miniDumpId);

    // Try to rename the files
    wchar_t dumpFilePathNew[MAX_PATH];
    swprintf_s(dumpFilePathNew, sizeof(dumpFilePathNew), L"%s%s(%s_%s).dmp", dumpPath, miniDumpId, _wszCommitSha1Short, _wszArchitecture);
    if (_wrename(dumpFilePath, dumpFilePathNew) == 0)
    {
        std::wcscpy(dumpFilePath, dumpFilePathNew);
    }

    // Log information to output
    wprintf(L"Dump Path: %s\n", dumpPath);
    wprintf(L"Dump File Path: %s\n", dumpFilePath);
    wprintf(L"Dump Id: %s\n", miniDumpId);
    wprintf(L"Version: %s\n", WSZ(OPENRCT2_VERSION));
    wprintf(L"Commit: %s\n", _wszCommitSha1Short);

    utf8 * saveFilePathUTF8 = widechar_to_utf8(saveFilePath);
    SDL_RWops * rw = SDL_RWFromFile(saveFilePathUTF8, "wb+");
    free(saveFilePathUTF8);

    bool savedGameDumped = false;
    if (rw != NULL) {
        scenario_save(rw, 0x80000000);
        savedGameDumped = true;
        SDL_RWclose(rw);
    }

    if (gOpenRCT2SilentBreakpad)
    {
        return succeeded;
    }
    constexpr const wchar_t * MessageFormat = L"A crash has occurred and a dump was created at\n%s.\n\nPlease file an issue with OpenRCT2 on GitHub, and provide the dump and saved game there.\n\nVersion: %s\nCommit: %s";
    wchar_t message[MAX_PATH * 2];
    swprintf_s(message,
               MessageFormat,
               dumpFilePath,
               WSZ(OPENRCT2_VERSION),
               _wszCommitSha1Short);

    // Cannot use platform_show_messagebox here, it tries to set parent window already dead.
    MessageBoxW(NULL, message, WSZ(OPENRCT2_NAME), MB_OK | MB_ICONERROR);
    HRESULT coInitializeResult = CoInitialize(NULL);
    if (SUCCEEDED(coInitializeResult))
    {
        LPITEMIDLIST pidl = ILCreateFromPathW(dumpPath);
        LPITEMIDLIST files[2];
        uint32 numFiles = 0;

        files[numFiles++] = ILCreateFromPathW(dumpFilePath);
        if (savedGameDumped)
        {
            files[numFiles++] = ILCreateFromPathW(saveFilePath);
        }
        if (pidl != nullptr) {
            HRESULT result = SHOpenFolderAndSelectItems(pidl, numFiles, (LPCITEMIDLIST *)files, 0);
            ILFree(pidl);
            for (uint32 i = 0; i < numFiles; i++)
            {
                ILFree(files[i]);
            }
        }
        CoUninitialize();
    }

    // Return whether the dump was successful
    return succeeded;
}
Beispiel #17
0
/*
 * DlgProcYahooOpts - Account Options Dialog
 */
static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	DBVARIANT dbv;
	CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );

	switch ( msg ) {
	case WM_INITDIALOG: 
		TranslateDialogDefault( hwndDlg );

		ppro = (CYahooProto*)lParam;
		SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );

		if ( !ppro->GetString( YAHOO_LOGINID, &dbv )) {
			SetDlgItemTextA(hwndDlg,IDC_HANDLE,dbv.pszVal);
			DBFreeVariant(&dbv);
		}

		if ( !ppro->GetString( "Nick", &dbv )) {
			SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal);
			DBFreeVariant(&dbv);
		}

		if ( !ppro->GetString( YAHOO_PASSWORD, &dbv )) {
			//bit of a security hole here, since it's easy to extract a password from an edit box
			YAHOO_CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, ( LPARAM )dbv.pszVal );
			SetDlgItemTextA( hwndDlg, IDC_PASSWORD, dbv.pszVal );
			DBFreeVariant( &dbv );
		}

		//SetButtonCheck( hwndDlg, IDC_DISABLE_UTF8, ppro->GetByte( "DisableUTF8", 0 )); 
		SetButtonCheck( hwndDlg, IDC_USE_YAB, ppro->GetByte( "UseYAB", 1 )); 
		SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, ppro->GetByte( "ShowAvatars", 1 )); 
		SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->GetByte( "MailAutoLogin", 1 )); 
		SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->GetByte( "DisableYahoomail", 0 ));
		SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, ppro->GetByte( "ShowErrors", 1 )); 

		return TRUE;

	case WM_COMMAND: 
		
		switch ( LOWORD( wParam )) {
		case IDC_NEWYAHOOACCOUNTLINK:
			YAHOO_CallService( MS_UTILS_OPENURL, 1, 
				ppro->GetByte( "YahooJapan", 0 ) ?
					(LPARAM)"http://edit.yahoo.co.jp/config/eval_register" :
					(LPARAM)"http://edit.yahoo.com/config/eval_register" );
			return TRUE;
 
		//case IDC_DISABLE_UTF8: 
		case IDC_USE_YAB:	
		case IDC_SHOW_AVATARS:
		case IDC_MAIL_AUTOLOGIN:
		case IDC_SHOW_ERRORS:
		case IDC_DISABLEYAHOOMAIL:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}    

		if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
			switch( LOWORD( wParam )) {
			case IDC_HANDLE:			
			case IDC_PASSWORD:			
			case IDC_NICK:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}

		break;

	case WM_NOTIFY: 
		
		if (((LPNMHDR)lParam)->code == (UINT) PSN_APPLY ) {
			BOOL reconnectRequired = FALSE;

			char str[128];
			GetDlgItemTextA( hwndDlg, IDC_HANDLE, str, sizeof( str ));
			dbv.pszVal = NULL;
			
			if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal ))
				reconnectRequired = TRUE;
				
			if ( dbv.pszVal != NULL )
				DBFreeVariant( &dbv );
			
			ppro->SetString( YAHOO_LOGINID, str );

			GetDlgItemTextA( hwndDlg, IDC_PASSWORD, str, sizeof( str ));
			YAHOO_CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),( LPARAM )str );
			dbv.pszVal = NULL;
			if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal ))
				reconnectRequired = TRUE;
			if ( dbv.pszVal != NULL )
				DBFreeVariant( &dbv );
			
			ppro->SetString( YAHOO_PASSWORD, str );
			GetDlgItemTextA( hwndDlg, IDC_NICK, str, sizeof( str ));
			
			
			if (str[0] == '\0') {
				/* Check for empty Nick, if so delete the key in the DB */
				DBDeleteContactSetting( NULL, ppro->m_szModuleName, "Nick" );
			} else {
				/* otherwise save the new Nick */
				ppro->SetString( "Nick", str );
			}

			//ppro->SetByte("DisableUTF8", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_DISABLE_UTF8 )); 
			ppro->SetByte("UseYAB", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_USE_YAB )); 
			ppro->SetByte("ShowAvatars", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_AVATARS )); 
			ppro->SetByte("MailAutoLogin", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_MAIL_AUTOLOGIN )); 
			ppro->SetByte("DisableYahoomail", ( BYTE )!IsDlgButtonChecked( hwndDlg, IDC_DISABLEYAHOOMAIL ));
			ppro->SetByte("ShowErrors", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_SHOW_ERRORS )); 

			if (reconnectRequired ) {
				DBDeleteContactSetting(NULL, ppro->m_szModuleName, YAHOO_PWTOKEN);
			}
			
			/*if ( restartRequired )
				MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK );
			else */
			if ( reconnectRequired && ppro->m_bLoggedIn )
				MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK );

			return TRUE;
		  }
		
		break;
	}
	return FALSE;
}
Beispiel #18
0
/**************************************************************************
 * 			DriverProc (MSACM32.@)
 */
LRESULT CALLBACK PCM_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
				       LPARAM dwParam1, LPARAM dwParam2)
{
    TRACE("(%08lx %p %u %08lx %08lx);\n",
          dwDevID, hDriv, wMsg, dwParam1, dwParam2);

    switch (wMsg) {
    case DRV_LOAD:		return 1;
    case DRV_FREE:		return 1;
    case DRV_OPEN:		return PCM_drvOpen((LPSTR)dwParam1, (PACMDRVOPENDESCW)dwParam2);
    case DRV_CLOSE:		return PCM_drvClose(dwDevID);
    case DRV_ENABLE:		return 1;
    case DRV_DISABLE:		return 1;
    case DRV_QUERYCONFIGURE:	return 1;
    case DRV_CONFIGURE:		MessageBoxA(0, "MSACM PCM filter !", "Wine Driver", MB_OK); return 1;
    case DRV_INSTALL:		return DRVCNF_RESTART;
    case DRV_REMOVE:		return DRVCNF_RESTART;

    case ACMDM_DRIVER_NOTIFY:
	/* no caching from other ACM drivers is done so far */
	return MMSYSERR_NOERROR;

    case ACMDM_DRIVER_DETAILS:
	return PCM_DriverDetails((PACMDRIVERDETAILSW)dwParam1);

    case ACMDM_FORMATTAG_DETAILS:
	return PCM_FormatTagDetails((PACMFORMATTAGDETAILSW)dwParam1, dwParam2);

    case ACMDM_FORMAT_DETAILS:
	return PCM_FormatDetails((PACMFORMATDETAILSW)dwParam1, dwParam2);

    case ACMDM_FORMAT_SUGGEST:
	return PCM_FormatSuggest((PACMDRVFORMATSUGGEST)dwParam1);

    case ACMDM_STREAM_OPEN:
	return PCM_StreamOpen((PACMDRVSTREAMINSTANCE)dwParam1);

    case ACMDM_STREAM_CLOSE:
	return PCM_StreamClose((PACMDRVSTREAMINSTANCE)dwParam1);

    case ACMDM_STREAM_SIZE:
	return PCM_StreamSize((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMSIZE)dwParam2);

    case ACMDM_STREAM_CONVERT:
	return PCM_StreamConvert((PACMDRVSTREAMINSTANCE)dwParam1, (PACMDRVSTREAMHEADER)dwParam2);

    case ACMDM_HARDWARE_WAVE_CAPS_INPUT:
    case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT:
	/* this converter is not a hardware driver */
    case ACMDM_FILTERTAG_DETAILS:
    case ACMDM_FILTER_DETAILS:
	/* this converter is not a filter */
    case ACMDM_STREAM_RESET:
	/* only needed for asynchronous driver... we aren't, so just say it */
    case ACMDM_STREAM_PREPARE:
    case ACMDM_STREAM_UNPREPARE:
	/* nothing special to do here... so don't do anything */
	return MMSYSERR_NOTSUPPORTED;

    default:
	return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
    }
}
Beispiel #19
0
INT_PTR ImportContacts(WPARAM, LPARAM)
{
	MCONTACT hContact;
	char name[256] = "", program[256] = "", programparam[256] = "", group[256] = "", line[2001] = "";
	int icon = 40072, usetimer = 0, minutes = 1, timer = 0;
	char fn[MAX_PATH];
	int i, j, contactDone = 0;
	if (!Openfile(fn, 1))
		return 1;

	FILE *file = fopen(fn, "r");
	if (!file)
		return 1;

	CMStringA tooltip;

	while (fgets(line, 2000, file)) {
		if (!mir_strcmp(line, "\r\n\0"))
			continue;
		if (!mir_strcmp(line, "[Non-IM Contact]\r\n"))
			contactDone = 0;
		else if (!strncmp(line, "Name=", mir_strlen("Name="))) {
			i = (int)mir_strlen("Name="); j = 0;
			while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
				name[j] = line[i++];
				name[++j] = '\0';
			}
			contactDone = 1;
		}
		else if (!strncmp(line, "ProgramString=", mir_strlen("ProgramString="))) {
			i = (int)mir_strlen("ProgramString="); j = 0;
			while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
				program[j] = line[i++];
				program[++j] = '\0';
			}
		}
		else if (!strncmp(line, "ProgramParamString=", mir_strlen("ProgramParamString="))) {
			i = (int)mir_strlen("ProgramParamString="); j = 0;
			while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
				programparam[j] = line[i++];
				programparam[++j] = '\0';
			}
		}
		else if (!strncmp(line, "Group=", mir_strlen("Group="))) {
			i = (int)mir_strlen("Group="); j = 0;
			while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
				group[j] = line[i++];
				group[++j] = '\0';
			}
		}
		else if (!strncmp(line, "ToolTip=", mir_strlen("ToolTip="))) {
			i = (int)mir_strlen("ToolTip=");
			tooltip = &line[i];
			fgets(line, 2000, file);
			while (!strstr(line, "</tooltip>\r\n")) {
				tooltip.Append(line);
				fgets(line, 2000, file);
			}
			// the line that has the </tooltip>
			tooltip.Append(line);
		}
		else if (!strncmp(line, "Icon=", mir_strlen("Icon="))) {
			i = (int)mir_strlen("Icon=");
			sscanf(&line[i], "%d", &icon);
		}
		else if (!strncmp(line, "UseTimer=", mir_strlen("UseTimer="))) {
			i = (int)mir_strlen("UseTimer=");
			sscanf(&line[i], "%d", &usetimer);
		}
		else if (!strncmp(line, "Timer=", mir_strlen("Timer="))) {
			i = (int)mir_strlen("Timer=");
			sscanf(&line[i], "%d", &timer);
		}
		else if (!strncmp(line, "Minutes=", mir_strlen("Minutes="))) {
			i = (int)mir_strlen("Minutes=");
			sscanf(&line[i], "%d", &minutes);
		}
		else if (contactDone && !mir_strcmp(line, "[/Non-IM Contact]\r\n")) {
			if (!name) continue;
			size_t size = mir_strlen(name) + mir_strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1;
			char *msg = (char*)malloc(size);
			mir_snprintf(msg, size, "Do you want to import this Non-IM Contact?\r\n\r\nName: %s\r\n", name);
			if (program[0] != '\0') {
				msg = (char*)realloc(msg, mir_strlen(msg) + mir_strlen(program) + mir_strlen("Program: \r\n") + 1);
				mir_strcat(msg, "Program: ");
				mir_strcat(msg, program);
				mir_strcat(msg, "\r\n");
			}
			if (programparam[0] != '\0') {
				msg = (char*)realloc(msg, mir_strlen(msg) + mir_strlen(programparam) + mir_strlen("Program Parameters: \r\n") + 1);
				mir_strcat(msg, "Program Parameters: ");
				mir_strcat(msg, programparam);
				mir_strcat(msg, "\r\n");
			}
			if (tooltip) {
				msg = (char*)realloc(msg, mir_strlen(msg) + mir_strlen(tooltip) + mir_strlen("ToolTip: \r\n") + 1);
				mir_strcat(msg, "ToolTip: ");
				mir_strcat(msg, tooltip);
				mir_strcat(msg, "\r\n");
			}
			if (group[0] != '\0') {
				msg = (char*)realloc(msg, mir_strlen(msg) + mir_strlen(group) + mir_strlen("Group: \r\n") + 1);
				mir_strcat(msg, "Group: ");
				mir_strcat(msg, group);
				mir_strcat(msg, "\r\n");
			}
			if (icon) {
				char tmp[64];
				if (icon == ID_STATUS_ONLINE)
					mir_snprintf(tmp, "Icon: Online\r\n");
				else if (icon == ID_STATUS_AWAY)
					mir_snprintf(tmp, "Icon: Away\r\n");
				else if (icon == ID_STATUS_NA)
					mir_snprintf(tmp, "Icon: NA\r\n");
				else if (icon == ID_STATUS_DND)
					mir_snprintf(tmp, "Icon: DND\r\n");
				else if (icon == ID_STATUS_OCCUPIED)
					mir_snprintf(tmp, "Icon: Occupied\r\n");
				else if (icon == ID_STATUS_FREECHAT)
					mir_snprintf(tmp, "Icon: Free For Chat\r\n");
				else if (icon == ID_STATUS_INVISIBLE)
					mir_snprintf(tmp, "Icon: Invisible\r\n");
				else if (icon == ID_STATUS_ONTHEPHONE)
					mir_snprintf(tmp, "Icon: On The Phone\r\n");
				else if (icon == ID_STATUS_OUTTOLUNCH)
					mir_snprintf(tmp, "Icon: Out To Lunch\r\n");
				else {
					free(msg);
					continue;
				}
				char *msgtemp = (char*)realloc(msg, mir_strlen(msg) + mir_strlen(tmp) + 1);
				if (msgtemp) {
					msg = msgtemp;
					mir_strcat(msg, tmp);
				}
			}
			if (usetimer && timer) {
				char tmp[64], tmp2[8];
				if (minutes)
					mir_strcpy(tmp2, "Minutes");
				else mir_strcpy(tmp2, "Seconds");
				mir_snprintf(tmp, "UseTimer: Yes\r\nTimer: %d %s", timer, tmp2);
				char *msgtemp = (char*)realloc(msg, mir_strlen(msg) + mir_strlen(tmp) + 1);
				if (msgtemp) {
					msg = msgtemp;
					mir_strcat(msg, tmp);
				}
			}

			if (MessageBoxA(0, msg, modFullname, MB_YESNO) == IDYES) {
				if (!(hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0))) {
					msg("contact did get created", "");
					continue;
				}
				Proto_AddToContact(hContact, MODNAME);
				CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
				db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
				db_set_s(hContact, MODNAME, "Name", name);
				db_set_s(hContact, MODNAME, "ProgramString", program);
				// copy the ProgramParamString
				db_set_s(hContact, MODNAME, "ProgramParamString", programparam);
				// copy the group
				db_set_s(hContact, "CList", "Group", group);
				// copy the ToolTip
				db_set_s(hContact, MODNAME, "ToolTip", tooltip);
				// timer
				db_set_b(hContact, MODNAME, "UseTimer", (BYTE)usetimer);
				db_set_b(hContact, MODNAME, "Minutes", (BYTE)minutes);
				db_set_w(hContact, MODNAME, "Timer", (WORD)timer);
				//icon
				db_set_w(hContact, MODNAME, "Icon", (WORD)icon);
				replaceAllStrings(hContact);
			}
			free(msg);
			contactDone = 0;
			name[0] = '\0';
			program[0] = '\0';
			programparam[0] = '\0';
			group[0] = '\0';
			line[0] = '\0';
			tooltip.Empty();
			icon = 40072;
			usetimer = 0;
			minutes = 1;
			timer = 0;
		}
	}
	fclose(file);

	return 1;
}
// Main Callbacks
INT_PTR CALLBACK MainProc ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	hWnd = hWndDlg;

	switch ( uMsg )
	{
		case WM_COMMAND:
		{
			switch ( wParam )
			{
			// Browse.
			case IDC_BUTTON1:
				{
					// Create variables
					OPENFILENAME ofn;
					char szBuffer [260];

					// Initialize OPENFILENAME
					ZeroMemory ( &ofn, sizeof(ofn) );

					ofn.lStructSize = sizeof ( ofn );
					ofn.hwndOwner = hWnd;
					ofn.lpstrFile = szBuffer;
					ofn.lpstrFile[0] = '\0';
					ofn.nMaxFile = sizeof ( szBuffer );
					ofn.lpstrFilter = ".DLL File\0*.dll*\0\0";
					ofn.nFilterIndex = 1;
					ofn.lpstrFileTitle = "Select your .DLL File";
					ofn.nMaxFileTitle = 0;
					ofn.lpstrInitialDir = "C:\\";
					ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

					// Open the dialog
					if ( GetOpenFileName (&ofn) == TRUE )
					{
						if ( strcmp ( szBuffer, "" ) != 0 )
						{
							SetWindowText ( GetDlgItem ( hWnd, IDC_EDIT1 ), szBuffer );

							// Obtain the dll name
							string dllName;
							dllName += (LPSTR) szBuffer;
							dllName = dllName.substr ( dllName.find_last_of ( "\\" ) + 1, dllName.length () );

							// Set the new window title
							SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), dllName.c_str () );
						}
					}
				}
				break;

			// Certify.
			case IDC_BUTTON2:
				{
					// Obtain the dll path
					char szBuffer [256];
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), szBuffer, 256 );

					if ( strcmp ( szBuffer, "" ) != 0 )
					{
						// Convert into string.
						string dllPathway;
						dllPathway += szBuffer;

						// Certify.
						int certifyLib = Certify ( dllPathway );

						// Check results.
						if ( certifyLib == 0 )
							MessageBoxA ( hWndDlg, "Something went wrong!", "Error 0x001", MB_ICONERROR );
						else if ( certifyLib == 1 )
							MessageBoxA ( hWndDlg, "Something went wrong!", "Error 0x002", MB_ICONERROR );
						else if ( certifyLib == 2 )
							MessageBoxA ( hWndDlg, "The module is already certified!", "Error 0x002", MB_ICONERROR );
						else if ( certifyLib == 3 )
							MessageBoxA ( hWndDlg, "The signatures can't be found!", "Error 0x003", MB_ICONERROR ); 
						else if ( certifyLib == 4 )
							MessageBoxA ( hWndDlg, "The signatures can't be found!", "Error 0x004", MB_ICONERROR );
						else if ( certifyLib == 5 )
							MessageBoxA ( hWndDlg, "The module was certified!", "Success", MB_ICONINFORMATION );
						else if ( certifyLib == 6 )
							MessageBoxA ( hWndDlg, "The DLL path is not valid.", "Error", MB_ICONERROR );
					}
				}
				break;

			// Generate a settings file.
			case IDC_BUTTON3:
				{
					// Obtain the dll path.
					char szBuffer [256];
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), szBuffer, 256 );
		
					if ( strcmp ( szBuffer, "" ) != 0 )
					{
						// Obtain the library name.
						char szLibrary [256];
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), szLibrary, 256 );

						if ( strcmp ( szLibrary, "" ) != 0 )
						{
							// Obtain the process name.
							char szProcess [256];
							GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT3 ), szProcess, 256 );

							if ( strcmp ( szProcess, "" ) != 0 )
							{
								// Convert to string
								string pathway;
								pathway += (LPSTR) szBuffer;
								pathway = pathway.substr ( 0, pathway.find_last_of ( "\\" ) );

								string library;
								library += (LPSTR) szLibrary;

								string process;
								process += (LPSTR) szProcess;

								// Generate a settings file
								GenerateSettings ( pathway, process, library );

								// Message
								MessageBoxA ( hWndDlg, "The settings file has been generated!", "Success!", MB_ICONINFORMATION );
							}
						}						
					}
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Setup window text
			SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), "C:\\mydll.dll" );
			SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), "mydll.dll" );
			SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT3 ), "WolfTeam.bin" );

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
Beispiel #21
0
BOOL CALLBACK DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    char szSysPath[MAX_PATH], szLibPath[MAX_PATH];
    WSADATA Wsa;

    switch(dwReason)
    {
        case DLL_PROCESS_ATTACH:
            l_hFakeDll = hInstance;

            if(MessageBoxA(NULL, "Connect to Packet Parser?", "Packet Parser", MB_YESNO|MB_ICONQUESTION)==IDNO)
            {
                use_dll = FALSE;
            }

            {// rewrite system DLL load path
                LPFNSETDLLDIRECTORYA lpfnSetDllDirectoryA = (LPFNSETDLLDIRECTORYA)GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "SetDllDirectoryA");

                if(lpfnSetDllDirectoryA)
                {
                    lpfnSetDllDirectoryA(".");
                }
            }

            GetSystemDirectoryA(szSysPath, _ARRAYSIZE(szSysPath));

            wsprintfA(szLibPath, "%s\\ws2_32.dll", szSysPath);

            l_hRealDll = LoadLibraryA(szLibPath);

            if(l_hRealDll)
            {
                if(l_hRealDll==l_hFakeDll)
                {// oops
                    FreeLibrary(l_hRealDll);
                    l_hRealDll = NULL;
                    MessageBoxA(NULL, "Attempted self-load.", "Library Error", MB_OK|MB_ICONSTOP);
                    return FALSE;
                }

#define LOADFUNC(x,y) l_WsFuncs.y = (x)GetProcAddress(l_hRealDll, #y)
                LOADFUNC(LPFN_CLOSESOCKET,closesocket);
                LOADFUNC(LPFN_CONNECT,connect);
                LOADFUNC(LPFN_HTONL,htonl);
                LOADFUNC(LPFN_HTONS,htons);
                LOADFUNC(LPFN_IOCTLSOCKET,ioctlsocket);
                LOADFUNC(LPFN_INET_ADDR,inet_addr);
                LOADFUNC(LPFN_INET_NTOA,inet_ntoa);
                LOADFUNC(LPFN_NTOHL,ntohl);
                LOADFUNC(LPFN_NTOHS,ntohs);
                LOADFUNC(LPFN_RECV,recv);
                LOADFUNC(LPFN_SELECT,select);
                LOADFUNC(LPFN_SEND,send);
                LOADFUNC(LPFN_SENDTO,sendto);
                LOADFUNC(LPFN_SETSOCKOPT,setsockopt);
                LOADFUNC(LPFN_SHUTDOWN,shutdown);
                LOADFUNC(LPFN_SOCKET,socket);
                LOADFUNC(LPFN_GETHOSTBYNAME,gethostbyname);
                LOADFUNC(LPFN_GETHOSTNAME,gethostname);
                LOADFUNC(LPFN_WSAGETLASTERROR,WSAGetLastError);
                LOADFUNC(LPFN_WSASTARTUP,WSAStartup);
                LOADFUNC(LPFN_WSACLEANUP,WSACleanup);
#undef LOADFUNC
				if(use_dll)
				{
					if(l_WsFuncs.WSAStartup(MAKEWORD(2,2), &Wsa))
					{
						FreeLibrary(l_hRealDll);
						l_hRealDll = NULL;
						MessageBoxA(NULL, "Failed to initialize actual Windows Sockets.", "Library Error", MB_OK|MB_ICONSTOP);
						return FALSE;
					}

					if((l_hSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET)
					{
						l_WsFuncs.WSACleanup();
						FreeLibrary(l_hRealDll);
						l_hRealDll = NULL;
						MessageBoxA(NULL, "Failed to create socket.", "Library Error", MB_OK|MB_ICONSTOP);
						return FALSE;
					}
					else
					{
						struct sockaddr_in sin;

						sin.sin_family = AF_INET;
						sin.sin_addr.s_addr = l_WsFuncs.htonl(SOCK_JOINIP(127,0,0,1));
						sin.sin_port = l_WsFuncs.htons(13554);

						if(connect(l_hSock, (struct sockaddr*)&sin, sizeof(sin))==SOCKET_ERROR)
						{
							l_WsFuncs.shutdown(l_hSock, SD_BOTH);
							l_WsFuncs.closesocket(l_hSock);
							l_hSock = INVALID_SOCKET;
							l_WsFuncs.WSACleanup();
							FreeLibrary(l_hRealDll);
							l_hRealDll = NULL;
							MessageBoxA(NULL, "Failed to connect to 127.0.0.1:13554 (TCP).", "Library Error", MB_OK|MB_ICONSTOP);
							use_dll = FALSE;
							//return FALSE;
						}
					}
				}
            }
            else
            {
                return FALSE;
            }
            break;
        case DLL_PROCESS_DETACH:
            if(l_hRealDll)
            {
                if(l_hSock!=INVALID_SOCKET)
                {
                    l_WsFuncs.shutdown(l_hSock, SD_BOTH);
                    l_WsFuncs.closesocket(l_hSock);
                    l_hSock = INVALID_SOCKET;
                }
                l_WsFuncs.WSACleanup();
                FreeLibrary(l_hRealDll);
                l_hRealDll = NULL;
            }
            l_hFakeDll = NULL;
            break;
    }
    return TRUE;

    // unused
    lpReserved;
}
Beispiel #22
0
//-------------------------------------------------------------------------
void SharedTools::ErrorMessage( const Char* message )
{
    MessageBoxA(NULL, message, APP_NAMEC, MB_OK|MB_ICONERROR);
}
HRESULT DXSourceWindow::CreateShaderResources()
{
	HRESULT hr = S_OK;
		
	// Set up constant buffer
	D3D11_BUFFER_DESC Desc;
	Desc.Usage = D3D11_USAGE_DYNAMIC;
	Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	Desc.MiscFlags = 0;    
	Desc.ByteWidth = sizeof( CUBE_CB );
	hr = m_pd3dDevice->CreateBuffer( &Desc, NULL, &m_Cube_pcb );
	PASS_TEST( hr );

	// create vertex buffer
	const float pVertices[] = { -0.5f, -0.5f,  0.5f,   0.5f, -0.5f,  0.5f,   0.5f,  0.5f,  0.5f,  -0.5f,  0.5f,  0.5f,
                                 0.5f, -0.5f,  0.5f,   0.5f, -0.5f, -0.5f,   0.5f,  0.5f, -0.5f,   0.5f,  0.5f,  0.5f,
                                -0.5f, -0.5f, -0.5f,   0.5f, -0.5f, -0.5f,   0.5f,  0.5f, -0.5f,  -0.5f,  0.5f, -0.5f,
                                -0.5f, -0.5f,  0.5f,  -0.5f, -0.5f, -0.5f,  -0.5f,  0.5f, -0.5f,  -0.5f,  0.5f,  0.5f,
                                -0.5f,  0.5f,  0.5f,   0.5f,  0.5f,  0.5f,   0.5f,  0.5f, -0.5f,  -0.5f,  0.5f, -0.5f,
                                -0.5f, -0.5f,  0.5f,   0.5f, -0.5f,  0.5f,   0.5f, -0.5f, -0.5f,  -0.5f, -0.5f, -0.5f };

	const float pNormal[] = {   0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,
                                1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,
                                0.0f, 0.0f, -1.0f,  0.0f, 0.0f, -1.0f,  0.0f, 0.0f, -1.0f,  0.0f, 0.0f, -1.0f,
                                -1.0f, 0.0f, 0.0f,  -1.0f, 0.0f, 0.0f,  -1.0f, 0.0f, 0.0f,  -1.0f, 0.0f, 0.0f,
                                0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,
                                0.0f, -1.0f, 0.0f,  0.0f, -1.0f, 0.0f,  0.0f, -1.0f, 0.0f,  0.0f, -1.0f, 0.0f };

	const float pTexture[] =  { 1.0f,0.0f,   1.0f,1.0f,    0.0f,1.0f,    0.0f,0.0f,
                                1.0f,0.0f,   1.0f,1.0f,    0.0f,1.0f,    0.0f,0.0f,
                                1.0f,0.0f,   1.0f,1.0f,    0.0f,1.0f,    0.0f,0.0f,
                                1.0f,0.0f,   1.0f,1.0f,    0.0f,1.0f,    0.0f,0.0f,
                                1.0f,0.0f,   1.0f,1.0f,    0.0f,1.0f,    0.0f,0.0f,
                                1.0f,0.0f,   1.0f,1.0f,    0.0f,1.0f,    0.0f,0.0f};

    const float pColors[]   = { 1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,
                                0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,
                                1.0f, 1.0f, 0.0f,  1.0f, 1.0f, 0.0f,  1.0f, 1.0f, 0.0f,  1.0f, 1.0f, 0.0f,
                                0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,
                                0.0f, 1.0f, 1.0f,  0.0f, 1.0f, 1.0f,  0.0f, 1.0f, 1.0f,  0.0f, 1.0f, 1.0f,
                                1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 1.0f };



	CUBE_Vertex1 verts[24];
	for (int i=0; i<24; i++)
	{
		verts[i].pos = D3DXVECTOR3(pVertices[3*i], pVertices[3*i+1], pVertices[3*i+2]);
		verts[i].texture = D3DXVECTOR2(pTexture[2*i], pTexture[2*i+1] );
		verts[i].normal = D3DXVECTOR3(pNormal[3*i], pNormal[3*i+1], pNormal[3*i+2] );
		verts[i].color = D3DXVECTOR3(pColors[3*i], pColors[3*i+1], pColors[3*i+2]);
	}

	D3D11_BUFFER_DESC vbDesc    = {0};
	vbDesc.BindFlags            = D3D11_BIND_VERTEX_BUFFER; // Type of resource
	vbDesc.ByteWidth            = 24*sizeof(CUBE_Vertex1);       // size in bytes
	vbDesc.Usage = D3D11_USAGE_DEFAULT;
	vbDesc.CPUAccessFlags = 0;
	vbDesc.MiscFlags = 0;

	D3D11_SUBRESOURCE_DATA vbData = {0};
	vbData.pSysMem = verts;

	hr = m_pd3dDevice->CreateBuffer( &vbDesc, &vbData, &m_Cube_pVertexBuffer);
    PASS_TEST(hr);

	// create index buffer
	int indices[36] = {-1};
	for (int i=0; i<6; i++)
	{
		indices[6*i]=4*i; indices[6*i+1]=4*i+1; indices[6*i+2]=4*i+3;
		indices[6*i+3]=4*i+1; indices[6*i+4]=4*i+2; indices[6*i+5]=4*i+3;
	}
	vbDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
    vbDesc.ByteWidth            = 36*sizeof(unsigned int);
	vbData.pSysMem = indices;
	hr = m_pd3dDevice->CreateBuffer( &vbDesc, &vbData, &m_Cube_pIndexBuffer );
	PASS_TEST(hr);


	// Compile the shaders using the lowest possible profile for broadest feature level support
	ID3DBlob* pVertexShaderBuffer = NULL;
	hr = CompileShaderFromFile(L"DrawCube.hlsl", "VSMain", "vs_4_0_level_9_1", &pVertexShaderBuffer );
	if ( hr == D3D11_ERROR_FILE_NOT_FOUND ) 
	{ 
		MessageBoxA(NULL,"ERROR, file DrawCube.hlsl not found.","DirectGMA",NULL);
		return D3D11_ERROR_FILE_NOT_FOUND;
	}
	PASS_TEST(hr);
	hr = m_pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(), pVertexShaderBuffer->GetBufferSize(), NULL, &m_Cube_pVertexShader );
	PASS_TEST(hr);

	ID3DBlob* pPixelShaderBuffer = NULL;
	hr = CompileShaderFromFile( L"DrawCube.hlsl", "PSMain", "ps_4_0_level_9_1", &pPixelShaderBuffer );
	PASS_TEST(hr);
	hr = m_pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(), pPixelShaderBuffer->GetBufferSize(), NULL, &m_Cube_pPixelShader );
	PASS_TEST(hr);

	// Create our vertex input layout
    const D3D11_INPUT_ELEMENT_DESC layout[] =
    {
        { "POSITION",  0, DXGI_FORMAT_R32G32B32_FLOAT,   0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "TEXTURE",  0,  DXGI_FORMAT_R32G32_FLOAT,      0, 12,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "NORMAL",  0,   DXGI_FORMAT_R32G32B32_FLOAT,   0, 20,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "COLOR",  0,    DXGI_FORMAT_R32G32B32_FLOAT,   0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    };

    hr = m_pd3dDevice->CreateInputLayout( layout, ARRAYSIZE( layout ), pVertexShaderBuffer->GetBufferPointer(), pVertexShaderBuffer->GetBufferSize(), &m_Cube_pVertexLayout11 );
	PASS_TEST(hr);
    SAFE_RELEASE( pVertexShaderBuffer );
    SAFE_RELEASE( pPixelShaderBuffer );

	
    // Create a sampler state
    D3D11_SAMPLER_DESC sampDesc;
    ZeroMemory( &sampDesc, sizeof(sampDesc) );
    sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
    sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
    sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
    sampDesc.MinLOD = 0;
    sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
    hr = m_pd3dDevice->CreateSamplerState( &sampDesc, &m_Cube_pSamplerLinear );
	PASS_TEST(hr);


	// Set the raster state
	D3D11_RASTERIZER_DESC RasterizerDesc;
	RasterizerDesc.FillMode = D3D11_FILL_SOLID;
	RasterizerDesc.CullMode = D3D11_CULL_NONE;
	RasterizerDesc.FrontCounterClockwise = TRUE;
	RasterizerDesc.DepthBias = 0;
	RasterizerDesc.DepthBiasClamp = 0.0f;
	RasterizerDesc.SlopeScaledDepthBias = 0.0f;
	RasterizerDesc.DepthClipEnable = TRUE;
	RasterizerDesc.ScissorEnable = FALSE;
	RasterizerDesc.MultisampleEnable = FALSE;
	RasterizerDesc.AntialiasedLineEnable = FALSE;

	hr = m_pd3dDevice->CreateRasterizerState( &RasterizerDesc, &m_Cube_pRasterizerStateSolid );
	PASS_TEST(hr);

	// Set state Objects
	m_pImmediateContext->RSSetState( m_Cube_pRasterizerStateSolid );


	hr = D3DX11CreateShaderResourceViewFromFile( m_pd3dDevice, L"amdlogo.dds", NULL, NULL, &m_Cube_pTextureRV, NULL );
	if ( hr == D3D11_ERROR_FILE_NOT_FOUND ) 
	{ 
		MessageBoxA(NULL,"ERROR, file amdlogo.dds not found.","DirectGMA",NULL);
		return D3D11_ERROR_FILE_NOT_FOUND;
	}
	PASS_TEST(hr);


	return S_OK;
}
Beispiel #24
0
void ntGenerateTextures(const ShaderScripts& shaderScript, 
                        nlEngineContext* cxt )
{
#if 0
    /* この関数が呼ばれる前にテクスチャは解放されている事が期待される */
    for( int i=0;i<MAX_TEXTURE_NUM;++i){ NL_ASSERT( !cxt->texs[i].texture );}
    const ShaderScriptGroup& tsScripts = shaderScript.tsScripts;
    const ShaderScript& commonScrips = shaderScript.commonScripts;
    /**/
    NL_ASSERT( 0 < tsScripts.numScript );
    /**/
    ID3D11Device* d3dDevice = cxt->d3dDevice;
    ID3D11DeviceContext* d3dContext = cxt->d3dContext;

    tsScripts.numScript;
    tsScripts.scripts[0].script;
    tsScripts.scripts[0].name;

    //const nlInt8* script = tsScripts.scripts;
    nlTexture* texuters = &(cxt->texs[0]);
    /**/
    const unsigned int scriptLen = nlStrlen(script);
    /* 全シェーダを作成 */
    ID3D11PixelShader* texturShaders[MAX_TEXTURE_NUM];
    nlMemset( texturShaders, 0, sizeof(ID3D11PixelShader*)*MAX_TEXTURE_NUM );
    /**/
    const unsigned int numTexture = textureScripts.numTexture;
    /**/
    for( unsigned int i=0;i<numTexture;++i)
    {
        ID3DBlob* pBlob = NULL;
        ID3DBlob* pErrorBlob = NULL;
        const nlInt8* funcName = textureScripts.funcs[i];
        const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR;
        /* ピクセルシェーダの作成 */
        if( FAILED(
            D3D10CompileShader(
            script, scriptLen, funcName, shaderMacros, NULL, 
           "main", "ps_4_0",flag, &pBlob, &pErrorBlob ) ) )
        {
            NL_ERR(ERR_009);
            MessageBoxA( NULL, "load texshader error", "", MB_OK );
            if(pErrorBlob)
            {
                NL_ERR(ERR_003, pErrorBlob->GetBufferPointer() );
                MessageBoxA( NULL, (nlInt8*)pErrorBlob->GetBufferPointer(), "", MB_OK );
            }
            return;
        }
        if( pBlob )
        {
            d3dDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &texturShaders[i] );
        }
        ++i;
    }

    /* 書きこむのに必要なシェーダを作成 */
    ID3D11VertexShader* vsRenderQuad;
    ID3DBlob* pBlob = NULL;
    ID3DBlob* pErrorBlob = NULL;    

    NL_HR_ASSSERT( D3D10CompileShader(script, scriptLen, "vs", shaderMacros, NULL, 
        "main","vs_4_0",(D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR),
        &pBlob, &pErrorBlob ) ) ;
    d3dDevice->CreateVertexShader( pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &vsRenderQuad );

    /* 全テクスチャを作成 */
    for(unsigned int i=0;i<numTexture;++i)
    {
        /**/
        nlTexture& tex = texuters[i];
        /**/
        tex.width  = 512; /* HACK サイズは適当 */
        tex.height = 512; /* HACK サイズは適当 */
        int mipLevel = 1;
        int CPUAccessFlags = 0;
        D3D11_TEXTURE2D_DESC descTarget = 
        {
            tex.width, tex.height,
            mipLevel, 1,
            DXGI_FORMAT_B8G8R8A8_UNORM,
            {1,0}, D3D11_USAGE_DEFAULT,
            (D3D11_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE),
            CPUAccessFlags, 0
        };
        d3dDevice->CreateTexture2D( &descTarget, NULL, &tex.texture );
        d3dDevice->CreateRenderTargetView( tex.texture, NULL, &tex.rtView );
        d3dDevice->CreateShaderResourceView( tex.texture, NULL ,&tex.shaderView );
    }

    /* 現在のRasterStateを取得 */
    ID3D11RasterizerState* oldRasterState;
    d3dContext->RSGetState(&oldRasterState);
    /**/
    D3D11_RASTERIZER_DESC rasterDesc;
    rasterDesc.AntialiasedLineEnable = false;
    rasterDesc.CullMode = D3D11_CULL_NONE;
    rasterDesc.DepthBias = 0;
    rasterDesc.DepthBiasClamp = 0.0f;
    rasterDesc.DepthClipEnable = true;
    rasterDesc.FillMode = D3D11_FILL_SOLID;
    rasterDesc.FrontCounterClockwise = false;
    rasterDesc.MultisampleEnable = false;
    rasterDesc.ScissorEnable = false;
    rasterDesc.SlopeScaledDepthBias = 0.0f;
    ID3D11RasterizerState* rasterState;
    d3dDevice->CreateRasterizerState(&rasterDesc, &rasterState);
    d3dContext->RSSetState(rasterState);
    rasterState->Release();

    /* 全テクスチャを焼き込む */
    for(unsigned int i=0;i<numTexture;++i)
    {
        /**/
        nlTexture& tex = texuters[i];
        /* ビューポートの設定 */
        D3D11_VIEWPORT viewport;
        viewport.Width = tex.width;
        viewport.Height = tex.height;
        viewport.MinDepth = 0.0f;
        viewport.MaxDepth = 1.0f;
        viewport.TopLeftX = 0.0f;
        viewport.TopLeftY = 0.0f;
        d3dContext->RSSetViewports(1, &viewport);
        /* シェーダを設定する */
        d3dContext->VSSetShader( vsRenderQuad, NULL, 0);
        d3dContext->PSSetShader( texturShaders[i], NULL, 0);
        /* レンダーターゲットを設定する */
        const float clearColor[4] = {0.0f, 0.0f, 1.0f, 0.0f};
        d3dContext->ClearRenderTargetView( tex.rtView, clearColor );
        d3dContext->OMSetRenderTargets( 1, &tex.rtView, NULL );

        /* 全てのテクスチャを設定する */
        /* TODO 毎回全てのテクスチャを設定せずに、このループで設定したテクスチャを省くようにだけする?*/
        for( unsigned int j=0;j<numTexture;++j)
        {
            if( i != j )
            {
                nlTexture& texSamp = texuters[j];
                d3dContext->PSSetShaderResources(j, 1, &texSamp.shaderView );
            }
        }

        /* 描画する */
        d3dContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );
        d3dContext->Draw( 4, 0 );
    }
    /**/
    d3dContext->VSSetShader( NULL, NULL, 0);
    d3dContext->PSSetShader( NULL, NULL, 0);

    /* ビューポート設定を元に戻す */
    /* 現在のビューポート設定を取得しておく */
    D3D11_VIEWPORT oldViewports = {0.0,0.0,cxt->rendertargets[0].width_,cxt->rendertargets[0].height_,0.0f,1.0f};
    d3dContext->RSSetViewports( 1, &oldViewports );

    /* RasterState設定を元に戻す */
    d3dContext->RSSetState(oldRasterState);
    if( oldRasterState ){ oldRasterState->Release(); }

    /* PSを解放 */
    for(unsigned int i=0;i<numTexture;++i)
    {
        if( texturShaders[i] ){ texturShaders[i]->Release(); }
    }
#endif
}
/***************************************************************************************************\
*	Функа xMsgBox; 
*	тестирование данной dll путём её запуска через rundll32.exe;
*	Вход:
*		hWnd		-	заголовок окна, который должен указываться в качестве родительского окна при создании окон в функциях загружаемой библиотеки DLL; 
*		hInst		-	заголовок экземпляра выбранной библиотеки DLL;
*		lpszCmdLine	-	командная строка, передаваемая библиотеке DLL. Данная строка представляет собой последовательность символов ASCII, завершающуюся символом с кодом 0; 
*		nCmdShow	-	режим отображения окон выбранной библиотеки DLL;
*	Выход:
*		(+)
*	Замметки:
*		for test; e.g, rundll32.exe xnewdll.dll,xMsgBox VX! 
*		для вызова данной длл и функи из rundll32.exe используй соглашение о вызовах _stdcall (
*		по умолчанию для атрибута _stdcall используется значение CALLBACK); 
\***************************************************************************************************/
DLLEXPORTC void CALLBACK xMsgBox(HWND hWnd, HINSTANCE hInst, LPSTR lpszCmdLine, int nCmdShow)
{
	MessageBoxA(0, lpszCmdLine, lpszCmdLine, MB_OK);	//! 
}
Beispiel #26
0
/* @NOTE この関数は近い将来撤去されます */
nlVertexShader nlCreateVertexShader(
                                    const nlInt8* script, 
                                    unsigned int scriptSize, 
                                    const nlInt8* funcName,
                                    nlEngineContext& cxt )
{
    struct GOD_VERTEX
    {
        nlVec4    pos_;
        nlVec4    normal_;
        nlVec4    uv_;
        D3DCOLOR  color_;
    };

    ID3DBlob* pBlob = NULL;
    ID3DBlob* pErrorBlob = NULL;
    nlVertexShader vertexShader;
    vertexShader.inputLayout_ = NULL;
    vertexShader.shader_ = NULL;

    
#ifdef INTROMODE
    const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR | D3D10_SHADER_OPTIMIZATION_LEVEL3;
    HRESULT hr = D3D10CompileShader( script, scriptSize, funcName, shaderMacros, NULL, funcName, "vs_4_0", flag, &pBlob, &pErrorBlob );
    if(FAILED( hr ) )
    {
        MessageBoxA(NULL,(nlInt8*)pErrorBlob->GetBufferPointer(),"",MB_OK);
    }
#else 
    const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR;
    HRESULT hr = D3D10CompileShader( script, scriptSize, funcName, shaderMacros, NULL, funcName, "vs_4_0", flag, &pBlob, &pErrorBlob );
#endif

#ifndef INTROMODE
    if( FAILED(hr) )
    {
        std::string error = std::string("[")+std::string(funcName)+std::string("]")+std::string(DXGetErrorDescriptionA(hr));
        if(pErrorBlob)
        {
            error += std::string( (nlInt8*)pErrorBlob->GetBufferPointer() ); 
            error.resize(error.size()-1);/* 改行コードを取り除く */
        }
        NL_ERR( ERR_005, error.c_str() );
        /* ファイルに書き出す */
        QString fileName;
        QTime now = QDateTime::currentDateTime().time();
        fileName.sprintf("err_%s_%d_%d_d.log",funcName,now.hour(),now.minute(),now.second() );
        QString path = sandboxPath(SP_APP)+fileName;
        QFile dataFile(path);
        dataFile.open(QIODevice::WriteOnly|QIODevice::Text);
        dataFile.write( script );
        /**/
        return vertexShader;
    }
#endif
    /* create shader */
    NL_HR_VALID( cxt.d3dDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &vertexShader.shader_ ) );
    /* create inputlayout */
    NL_HR_VALID( cxt.d3dDevice->CreateInputLayout(NLM_INPUT_ELEMENT, _countof(NLM_INPUT_ELEMENT), pBlob->GetBufferPointer(), pBlob->GetBufferSize(), &vertexShader.inputLayout_  ) );
    /**/
    return vertexShader;
}
Beispiel #27
0
int __stdcall debugeventplugin(LPDEBUG_EVENT DebugEvent)
{
	//Note, because this is called from a different thread than the mainthread, the thread un-safe ShowMessage is better not used.
	MessageBoxA(0,"A debug event has happened. You could do some editing of the context here...","Debug Event Plugin Example", MB_OK);
	return 0; //If you return 1 you will have to call ContinueDebugEvent yourself.
}
Beispiel #28
0
/*
 * DlgProcYahooOpts - Connection Options Dialog
 */
static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	DBVARIANT dbv;
	CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
	
	switch ( msg ) {
	case WM_INITDIALOG:
		TranslateDialogDefault( hwndDlg );

		ppro = ( CYahooProto* )lParam;
		SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );

		if ( !ppro->GetString( YAHOO_LOGINSERVER, &dbv )){
			SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, dbv.pszVal );
			DBFreeVariant( &dbv );
		}
		else SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, 
						ppro->GetByte( "YahooJapan", 0 ) 
						?  YAHOO_DEFAULT_JAPAN_LOGIN_SERVER
						: YAHOO_DEFAULT_LOGIN_SERVER );

		SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, ppro->GetWord( NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT ), FALSE );
		
		SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 ) );
		return TRUE;

	case WM_COMMAND:
		switch ( LOWORD( wParam )) {
		case IDC_RESETSERVER:
			SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER );
			SetDlgItemInt(  hwndDlg, IDC_YAHOOPORT,  YAHOO_DEFAULT_PORT, FALSE );
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		
		case IDC_YAHOO_JAPAN:
			SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, 
				(IsDlgButtonChecked(hwndDlg,IDC_YAHOO_JAPAN)==BST_CHECKED) ?
					YAHOO_DEFAULT_JAPAN_LOGIN_SERVER :
					YAHOO_DEFAULT_LOGIN_SERVER );
				// fall through and enable apply button

			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}    

		if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
			switch( LOWORD( wParam )) {
			case IDC_LOGINSERVER:
			case IDC_YAHOOPORT:			
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}

		break;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->code == PSN_APPLY )
		{
			BOOL	    reconnectRequired = FALSE/*, restartRequired = FALSE*/;
			char	    str[128];
			DBVARIANT 	dbv;
			int			port;

			GetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, str, sizeof( str ));
			
			if ( ppro->GetString( YAHOO_LOGINSERVER, &dbv ) || lstrcmpA( str, dbv.pszVal ))
				reconnectRequired = TRUE;
				
			if ( dbv.pszVal != NULL )
				DBFreeVariant( &dbv );

			ppro->SetString( YAHOO_LOGINSERVER, str );

			port = GetDlgItemInt( hwndDlg, IDC_YAHOOPORT, NULL, FALSE );
			if ( ppro->GetWord(NULL, YAHOO_LOGINPORT, -1) != port)
				reconnectRequired = TRUE;
			
			ppro->SetWord( NULL, YAHOO_LOGINPORT, port);

			ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN ));

			/*if ( restartRequired )
				MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda IM before they take effect"), Translate("YAHOO Options"), MB_OK );
			else */
			if ( reconnectRequired && ppro->m_bLoggedIn )
				MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK );

			return TRUE;
		}
		break;
	}
	return FALSE;
}
Beispiel #29
0
/*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
  Function: WinMain

  Summary:  The Windows main entry point function for this application.
            Initializes the application, the OLE Libraries, and starts
            the main application message loop.

  Args:     HINSTANCE hInstance,
              Instance handle; a new one for each invocation of this app.
            HINSTANCE hPrevInstance,
              Instance handle of the previous instance. NULL in Win32.
            LPSTR lpCmdLine,
              Windows passes a pointer to the application's
              invocation command line.
            int nCmdShow)
              Bits telling the show state of the application.

  Returns:  int
              msg.wParam (upon exit of message loop).
              FALSE if this instance couldn't initialize and run.
F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
extern "C" int PASCAL WinMain(
    HINSTANCE hInstance,
    HINSTANCE ,
    LPSTR ,
    int nCmdShow)
{
    CMainWindow* pWin = NULL;
    MSG msg;
    HACCEL hAccel = NULL;
    int iRun = FALSE;

    // If we were compiled for UNICODE and the platform seems OK with this
    // then proceed.  Else we error and exit the app.
    if (UnicodeOk())
    {
        // Call to initialize the OLE COM Library.  Use the OLE SUCCEEDED macro
        // to detect success.  If fail then exit app with error message.
        // Tell COM that this client process and all subordinate threads
        // will live in a multi-threaded world. This means that all subsequent
        // COM objects created and functioned by this client must be coded
        // to be thread-safe. This is where we tell COM that we are using
        // the "Free-threading" model (rather than the default Apartment Model).
        if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
        {
            // If we succeeded in initializing the COM Library we proceed to
            // initialize the application.  If we can't init the application
            // then we signal shut down with an error message exit.
            iRun = InitApplication(hInstance);
            if (iRun)
            {
                // Assume we'll set iRun to TRUE when initialization is done.
                iRun = FALSE;
                // We are still go for running so we try to create a nifty new
                // CMainWindow object for this app instance.
                pWin = new CMainWindow;
                if (NULL != pWin)
                {
                    // Now we initialize an instance of the new CMainWindow.
                    // This includes creating the main window.  Note: if
                    // InitInstance fails then it would have already deleted
                    // pWin so we wouldn't need to delete it here.
                    if (pWin->InitInstance(hInstance, nCmdShow))
                    {
                        // Load the keyboard accelerators from the resources.
                        hAccel = LoadAccelerators(hInstance, TEXT("AppAccel"));
                        if (NULL != hAccel)
                        {
                            // Signal App Initialization is successfully done.
                            iRun = TRUE;
                        }
                    }
                }
            }

            if (iRun)
            {
                // If we initialized the app instance properly then we are still
                // go for running.  We then start up the main message pump for
                // the application.
                while (GetMessage(&msg, NULL, 0, 0))
                {
                    if (!TranslateAccelerator(pWin->GetHwnd(), hAccel, &msg))
                    {
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                    }
                }

                // We also ask COM to unload any unused COM Servers, including our
                // friend, FRESERVE.
                CoFreeUnusedLibraries();

                // We'll pass to Windows the reason why we exited the message loop.
                iRun = (int) msg.wParam;
            }
            else
            {
                // We failed to initialize the application--issue an error
                // messagebox.
                TCHAR szMsg[MAX_STRING_LENGTH];

                // Load the error message string from the resources.
                if (LoadString(
                            hInstance,
                            IDS_APPINITFAILED,
                            szMsg,
                            MAX_STRING_LENGTH))
                {
                    // Put up error message box saying that application couldn't be
                    // initialized.  Parent window is desktop (ie, NULL).
                    MessageBox(
                        NULL,
                        szMsg,
                        TEXT(ERROR_TITLE_STR),
                        MB_OK | MB_ICONEXCLAMATION);
                }
                delete pWin;
            }

            // We're exiting this app (either normally or by init failure) so
            // shut down the OLE COM Library.
            CoUninitialize();
        }
        else
        {
            // We failed to Initialize the OLE COM Library.
            TCHAR szMsg[MAX_STRING_LENGTH];

            // Load the error message string from the resources.
            if (LoadString(
                        hInstance,
                        IDS_OLEINITFAILED,
                        szMsg,
                        MAX_STRING_LENGTH))
            {
                // Put up error message box saying that OLE COM Library
                // couldn't be initialized.  Parent window is desktop (ie, NULL).
                // And exit the failed application.
                MessageBox(
                    NULL,
                    szMsg,
                    TEXT(ERROR_TITLE_STR),
                    MB_OK | MB_ICONEXCLAMATION);
            }
        }
    }
    else
    {
        // If we were compiled for UNICODE but the platform has problems with
        // this then indicate an error and exit the app immediately.
        CHAR szMsg[MAX_STRING_LENGTH];

        if (LoadStringA(
                    hInstance,
                    IDS_NOUNICODE,
                    szMsg,
                    MAX_STRING_LENGTH))
        {
            MessageBoxA(
                NULL,
                szMsg,
                ERROR_TITLE_STR,
                MB_OK | MB_ICONEXCLAMATION);
        }
    }

    return iRun;
}
Beispiel #30
0
void BuildShaderFX()
{
	m_diffuseTextureRV[0] = NULL;
	m_diffuseTextureTV[0] = NULL;
	m_distDirTextureRV = NULL;
	m_distDirTextureTV = NULL;
	m_TextureRV = NULL;
	m_TextureTV = NULL;
	m_pDepthStencilView = NULL;
	m_otherTextureRV = NULL;
	m_otherTextureTV = NULL;
	m_pDrawVectorsTechnique = NULL;
	m_pDiffuseTechnique = NULL;
	m_pLineAntiAliasTechnique = NULL;
	m_pDisplayImage = NULL;
	m_pInTex[0] = NULL;
	m_pInTex[1] = NULL;
	m_pInTex[2] = NULL;
	m_pDiffTex = NULL;
	m_pDiffX = NULL;
	m_pDiffY = NULL;
	m_pScale = NULL;
	m_pPan = NULL;
	m_pPolySize = NULL;
	m_vp.Width = (int)(WIDTH);
	m_vp.Height = (int)(HEIGHT);
	m_vp.MinDepth = 0.0f;
	m_vp.MaxDepth = 1.0f;
	m_vp.TopLeftX = 0;
	m_vp.TopLeftY = 0;
	ID3DBlob* pCode;
	ID3DBlob* pError;
	ID3DX11Effect*  pEffect11;
	//Picture
	HRESULT hr = 0;
	hr = D3DX11CompileFromFile(_T("DiffusionCurves.fx"), NULL, NULL, NULL,
		"fx_5_0", D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG, NULL, NULL,
		&pCode, &pError, NULL);
	if (FAILED(hr))
	{
		if (pError)
		{
			MessageBoxA(0, (char*)pError->GetBufferPointer(), 0, 0);
			SAFE_RELEASE(pError);
		}
		DXTrace(__FILE__, __LINE__, hr, _T("D3DX11CreateEffectFromFile"), TRUE);
	}
	V(D3DX11CreateEffectFromMemory(pCode->GetBufferPointer(),
		pCode->GetBufferSize(), NULL, m_pd3dDevice, &pEffect11));
	m_pDrawVectorsTechnique = pEffect11->GetTechniqueByName("DrawCurves");
	m_pDiffuseTechnique = pEffect11->GetTechniqueByName("Diffuse");
	m_pLineAntiAliasTechnique = pEffect11->GetTechniqueByName("LineAntiAlias");
	m_pDisplayImage = pEffect11->GetTechniqueByName("DisplayDiffusionImage");
	m_pDiffTex = pEffect11->GetVariableByName("g_diffTex")->AsShaderResource();
	for (int i = 0; i < 3; i++)
	{
		m_pInTex[i] = (pEffect11->GetVariableByName("g_inTex"))->GetElement(
			i)->AsShaderResource();
	}
	m_blurOn = pEffect11->GetVariableByName("g_blurOn")->AsScalar();
	m_pDiffX = pEffect11->GetVariableByName("g_diffX")->AsScalar();
	m_pDiffY = pEffect11->GetVariableByName("g_diffY")->AsScalar();
	m_pScale = pEffect11->GetVariableByName("g_scale")->AsScalar();
	m_pPolySize = pEffect11->GetVariableByName("g_polySize")->AsScalar();
	m_pPan = pEffect11->GetVariableByName("g_pan")->AsVector();
	D3DX11_PASS_DESC PassDesc;
	m_pDrawVectorsTechnique->GetPassByIndex(0)->GetDesc(&PassDesc);
	if (FAILED(m_pd3dDevice->CreateInputLayout(VertexDesc_CurveVertex,
		4,
		PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize,
		&m_pCurveVertexLayout)))
	{
		return;
	}
	m_pDiffuseTechnique->GetPassByIndex(0)->GetDesc(&PassDesc);
	if (FAILED(m_pd3dDevice->CreateInputLayout(VertexDesc_VSOVertex,
		2,
		PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize,
		&m_pCurveVertex2Layout)))
	{
		return;
	}
	// create the depth buffer (only needed for curve mask rendering)
	DXGI_SAMPLE_DESC samdesc;
	samdesc.Count = 1;
	samdesc.Quality = 0;
	D3D11_TEXTURE2D_DESC texdesc;
	ZeroMemory(&texdesc, sizeof(D3D10_TEXTURE2D_DESC));
	texdesc.MipLevels = 1;
	texdesc.ArraySize = 1;
	texdesc.SampleDesc = samdesc;
	texdesc.Width = (int)(WIDTH);
	texdesc.Height = (int)(HEIGHT);
	texdesc.Usage = D3D11_USAGE_DEFAULT;
	texdesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
	texdesc.Format = DXGI_FORMAT_D32_FLOAT;
	if (m_pDepthStencil != NULL)
	{
		m_pDepthStencil->Release();
	}
	hr = m_pd3dDevice->CreateTexture2D(&texdesc, NULL, &m_pDepthStencil);
	hr = m_pd3dDevice->CreateDepthStencilView(m_pDepthStencil, NULL,
		&m_pDepthStencilView);
	//create diffusion textures (2 for ping pong rendering)
	if (m_diffuseTexture[0] != NULL)
	{
		m_diffuseTexture[0]->Release();
	}
	if (m_diffuseTexture[1] != NULL)
	{
		m_diffuseTexture[1]->Release();
	}
	if (m_distDirTexture != NULL)
	{
		m_distDirTexture->Release();
	}
	if (m_otherTexture != NULL)
	{
		m_otherTexture->Release();
	}
	texdesc.Width = (int)(WIDTH);
	texdesc.Height = (int)(HEIGHT);
	texdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	//texdesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;  // use this for higher accuracy diffusion
	texdesc.BindFlags =  D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
	hr = m_pd3dDevice->CreateTexture2D(&texdesc, NULL, &m_diffuseTexture[0]);
	hr = m_pd3dDevice->CreateTexture2D(&texdesc, NULL, &m_diffuseTexture[1]);
	hr = m_pd3dDevice->CreateTexture2D(&texdesc, NULL, &m_otherTexture);
	// distance map + nearest point map
	texdesc.Usage = D3D11_USAGE_DEFAULT;
	texdesc.CPUAccessFlags = 0;
	texdesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
	texdesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	hr = m_pd3dDevice->CreateTexture2D(&texdesc, NULL, &m_distDirTexture);
	hr = m_pd3dDevice->CreateTexture2D(&texdesc, NULL, &m_Texture);
	//create render target views
	hr = m_pd3dDevice->CreateShaderResourceView(m_diffuseTexture[0], NULL,
		&m_diffuseTextureRV[0]);
	hr = m_pd3dDevice->CreateRenderTargetView(m_diffuseTexture[0], NULL,
		&m_diffuseTextureTV[0]);
	hr = m_pd3dDevice->CreateShaderResourceView(m_diffuseTexture[1], NULL,
		&m_diffuseTextureRV[1]);
	hr = m_pd3dDevice->CreateRenderTargetView(m_diffuseTexture[1], NULL,
		&m_diffuseTextureTV[1]);
	hr = m_pd3dDevice->CreateShaderResourceView(m_distDirTexture, NULL,
		&m_distDirTextureRV);
	hr = m_pd3dDevice->CreateRenderTargetView(m_distDirTexture, NULL,
		&m_distDirTextureTV);
	hr = m_pd3dDevice->CreateShaderResourceView(m_Texture, NULL, &m_TextureRV);
	hr = m_pd3dDevice->CreateRenderTargetView(m_Texture, NULL, &m_TextureTV);
	hr = m_pd3dDevice->CreateShaderResourceView(m_otherTexture, NULL,
		&m_otherTextureRV);
	hr = m_pd3dDevice->CreateRenderTargetView(m_otherTexture, NULL,
		&m_otherTextureTV);
	char s[255] = "zephyr.xml";
	ReadVectorFile(s);
	ConstructCurves();
}