Пример #1
0
HEFFECT D3DCore_Impl::Effect_Load(const WCHAR *filename, DWORD size)
{
	if(m_bSilent) return 0;

	DWORD _size;
	FilePtr pf;
	SampleSource* SSource = NULL;
	void *data;

	if(m_pADevice)
	{
		if(size) { data=(void *)filename; _size=size; }
		else
		{
			data=File_Load(filename, &_size);
			if(!data) return NULL;
		}
	
		pf = CreateMemoryFile(data, _size);
		if(pf.get() != NULL) {
			SSource = OpenSampleSource( pf.get() );			
			if(!SSource) {
				System_Log(L"[AUDIERE - ERROR] %s - Can't create sound effect", filename);				
			}
			SSource->ref();
		}

		if(!size) File_Free(data);
		return (HEFFECT)SSource;
	}
	else return 0;
}
Пример #2
0
void Font_CacheGlyphsFromFile(FontObj* font, const std::string& path)
{
	char* buffer = NULL;
	int bufferSize = 0;
	if (File_Load(path, (void*&) buffer, bufferSize))
	{
		Font_CacheGlyphs(font, buffer);
		free(buffer);
	}
}
Пример #3
0
HSTREAM D3DCore_Impl::Stream_Load(const WCHAR *filename, DWORD size)
{
	if(m_bSilent) return 0;

	void *data;
	DWORD _size;
	CStreamList *stmItem;

	if(m_pADevice)
	{
		if(size) { data=(void *)filename; _size=size; }
		else
		{
			data=File_Load(filename, &_size);
			if(!data) return 0;
		}
		
		FilePtr pf = CreateMemoryFile(data, _size);
		SampleSourcePtr source = OpenSampleSource(pf);
		if (!source) {
			System_Log(L"[AUDIERE - ERROR] %s: Can't load sample source", filename);
			return 0;
		}

		LoopPointSourcePtr loop_source = CreateLoopPointSource(source);
		if (loop_source) {
			source = loop_source.get();
		}

		OutputStream* stream = OpenSound( m_pADevice, source, true);
		if (!stream) 
		{
			System_Log(L"[AUDIERE - ERROR] %s: Can't load stream", filename);
			if(!size) File_Free(data);
			return 0;
		}
		stream->ref();
		if(!size)
		{
			stmItem=new CStreamList;
			stmItem->hstream=(HSTREAM)stream;
			stmItem->data=data;
			stmItem->next=streams;
			streams=stmItem;
		}
		return (HSTREAM)stream;
	}
	else return 0;
}
Пример #4
0
sProfilerHeader	*	Profiler_LoadProfile( char * apFileName )
{
	sProfilerHeader *	lpHeader;
	S32					lSize;

	lSize = File_GetSize( apFileName );
	if( lSize < sizeof(sProfilerHeader ) )
	{
		return( 0 );
	}

	lpHeader = File_Load( apFileName );
	if( lpHeader )
	{
		lSize -= sizeof(sProfilerHeader);
		lpHeader->EntryCount = lSize >> 2L;
	}

	return( lpHeader );
}
Пример #5
0
void	Test_Loop( void )
{
	Screen_Init();

	gpPicture = File_Load( "RGLOGO.PI1" );

	if( gpPicture )
	{
		Memory_Copy( 32000L, &gpPicture->Pixels[ 0 ], gpPhysic );
		Video_SetNextPalST( &gpPicture->Header.Palette[ 0 ] );

		while( !IKBD_GetKeyStatus(eIKBDSCAN_SPACE) )
		{
		}
	}

	File_UnLoad( gpPicture );

	Screen_DeInit();
}
Пример #6
0
void	Test_Loop( void )
{
	sGraphicPos	lPos;
	S16			lAddX,lAddY;
	sSprite *	lpSprite;

	Screen_Init();

	gpPicture = File_Load( "SPRITE.PI1" );

	if( gpPicture )
	{
		Video_SetPalST( &gpPicture->Header.Palette[ 0 ] );

		lPos.X = 0;
		lPos.Y = 0;

		lAddX  = 1;
		lAddY  = 1;

		lpSprite = Sprite_Create(
			&gpPicture->Pixels[ 0 ],
			&gpPicture->Pixels[ 0 ],
			16,
			16,
			4,
			0 );

		while( !IKBD_GetKeyStatus(eIKBDSCAN_SPACE) )
		{
			Screen_Swap();

			gGraphic.pVRAM = gpLogic;
			gGraphic.pFuncs->ClearScreen( &gGraphic );

			gGraphic.pClipFuncs->DrawSprite(
				&gGraphic,
				&lPos,
				lpSprite );

			if( lAddX > 0 )
			{
				lPos.X++;
				if( lPos.X > (320-16) )
				{
					lPos.X = 320-16;
					lAddX  = -1;
				}
			}
			else
			{
				lPos.X--;
				if( lPos.X < 0 )
				{
					lPos.X = 0;
					lAddX  = 1;
				}
			}

			if( lAddY > 0 )
			{
				lPos.Y++;
				if( lPos.Y > (200-16) )
				{
					lPos.Y = 200-16;
					lAddY  = -1;
				}
			}
			else
			{
				lPos.Y--;
				if( lPos.Y < 0 )
				{
					lPos.Y = 0;
					lAddY  = 1;
				}
			}


		}
	}

	File_UnLoad( gpPicture );

	Screen_DeInit();
}
Пример #7
0
INT32 __stdcall start( )
{
    HANDLE sectionHandle, *hMutex;
    HANDLE eventHandle;
    HANDLE threadHandle;
    DWORD sectionSize;
    MSG messages;
    OBJECT_ATTRIBUTES objAttrib = {0};
    PTEB threadEnvironmentBlock;
    UNICODE_STRING eventSource;
    LDR_DATA_TABLE_ENTRY *module;
    SECTION_BASIC_INFORMATION sectionInfo;
    LARGE_INTEGER newSectionSize;

    InitializeCRT();

    threadEnvironmentBlock = NtCurrentTeb();

    PushProcessId = threadEnvironmentBlock->ClientId.UniqueProcess;
    PushHeapHandle = threadEnvironmentBlock->ProcessEnvironmentBlock->ProcessHeap;
    PushSessionId = threadEnvironmentBlock->ProcessEnvironmentBlock->SessionId;

    // Check if already running
    hMutex = CreateMutexW(0, FALSE, L"PushOneInstance");

    if (threadEnvironmentBlock->LastErrorValue == ERROR_ALREADY_EXISTS
        || threadEnvironmentBlock->LastErrorValue == ERROR_ACCESS_DENIED)
    {
        MessageBoxW(0, L"Only one instance!", 0,0);
        ExitProcess(0);
    }


    //create image event
    eventHandle = NULL;

    UnicodeString_Init(&eventSource, L"Global\\" PUSH_IMAGE_EVENT_NAME);

    objAttrib.Length = sizeof(OBJECT_ATTRIBUTES);
    objAttrib.RootDirectory = BaseGetNamedObjectDirectory();
    objAttrib.ObjectName = &eventSource;
    objAttrib.Attributes = OBJ_OPENIF;
    objAttrib.SecurityDescriptor = NULL;
    objAttrib.SecurityQualityOfService = NULL;

    NtCreateEvent(&eventHandle, EVENT_ALL_ACCESS, &objAttrib, NotificationEvent, FALSE);

    // populate file name and path
    module = (LDR_DATA_TABLE_ENTRY*)threadEnvironmentBlock->ProcessEnvironmentBlock->Ldr->InLoadOrderModuleList.Flink;

    Memory_Copy(PushFilePath, module->FullDllName.Buffer, module->FullDllName.Length);

    PushFilePath[module->FullDllName.Length] = L'\0';

    // Start Driver.
    Driver_Extract();
    PushDriverLoaded = Driver_Load();

    //initialize instance
    PushInstance = Module_GetHandle(L"Push.exe");

    // Create interface
    MwCreateMainWindow();

    // Create section.
    sectionSize = sizeof(PUSH_SHARED_MEMORY) + OSD_GetSize();

    PushSharedMemory = (PUSH_SHARED_MEMORY*)Memory_MapViewOfSection(PUSH_SECTION_NAME, sectionSize, &sectionHandle);

    if (!PushSharedMemory)
    {
        Log(L"Could not create shared memory");
        return 0;
    }

    Log(L"Created section of size %i bytes", sectionSize);

    //zero struct
    Memory_Clear(PushSharedMemory, sizeof(PUSH_SHARED_MEMORY));

    //initialize window handle used by overlay
    //PushSharedMemory->WindowHandle = PushMainWindow->Handle;

    //initialize default font properties for overlay
    String_Copy(PushSharedMemory->FontName, L"Verdana");
    PushSharedMemory->FontBold = TRUE;

    if (File_Exists(PUSH_SETTINGS_FILE))
    {
        wchar_t *buffer;
        wchar_t marker;

        // Check if file is UTF-16LE.
        buffer = (WCHAR*) File_Load(PUSH_SETTINGS_FILE, NULL);
        marker = buffer[0];

        Memory_Free(buffer);

        if (marker == 0xFEFF)
            //is UTF-LE.
        {
            // Init settings from ini file.

            buffer = Memory_Allocate(100 * sizeof(WCHAR));

            Ini_GetString(L"Settings", L"FrameLimit", NULL, buffer, 5, L".\\" PUSH_SETTINGS_FILE);
            PushSharedMemory->FrameLimit = _wtoi(buffer);

            if (Ini_ReadBoolean(L"Settings", L"ThreadOptimization", FALSE, L".\\" PUSH_SETTINGS_FILE))
                PushSharedMemory->ThreadOptimization = TRUE;

            if (Ini_ReadBoolean(L"Settings", L"KeepFps", FALSE, L".\\" PUSH_SETTINGS_FILE))
                PushSharedMemory->KeepFps = TRUE;

            Ini_GetString(L"Settings", L"OverlayInterface", NULL, buffer, 5, L".\\" PUSH_SETTINGS_FILE);

            if (String_Compare(buffer, L"PURE") == 0)
                PushOverlayInterface = OVERLAY_INTERFACE_PURE;
            else if (String_Compare(buffer, L"RTSS") == 0)
                PushOverlayInterface = OVERLAY_INTERFACE_RTSS;

            Ini_GetString(L"Settings", L"KeyboardHookType", L"AUTO", buffer, 10, L".\\" PUSH_SETTINGS_FILE);

            if (String_Compare(buffer, L"AUTO") == 0)
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_AUTO;
            }
            else if (String_Compare(buffer, L"SUBCLASS") == 0)
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_SUBCLASS;
            }
            else if (String_Compare(buffer, L"MESSAGE") == 0)
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_MESSAGE;
            }
            else if (String_Compare(buffer, L"KEYBOARD") == 0)
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_KEYBOARD;
            }
            else if (String_Compare(buffer, L"DETOURS") == 0)
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_DETOURS;
            }
            else if (String_Compare(buffer, L"RAW") == 0)
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_RAW;
            }
            else
            {
                PushSharedMemory->KeyboardHookType = KEYBOARD_HOOK_AUTO;
            }

            Ini_GetString(L"Settings", L"EngineClockMax", NULL, buffer, 5, L".\\" PUSH_SETTINGS_FILE);
            PushSharedMemory->HarwareInformation.DisplayDevice.EngineOverclock = _wtoi(buffer);

            Ini_GetString(L"Settings", L"MemoryClockMax", NULL, buffer, 5, L".\\" PUSH_SETTINGS_FILE);
            PushSharedMemory->HarwareInformation.DisplayDevice.MemoryOverclock = _wtoi(buffer);

            Ini_GetString(L"Settings", L"ControllerTimeout", NULL, buffer, 5, L".\\" PUSH_SETTINGS_FILE);
            PushSharedMemory->ControllerTimeout = _wtoi(buffer);

            Ini_GetString(L"Settings", L"FontName", L"Verdana", buffer, 100, L".\\" PUSH_SETTINGS_FILE);
            String_Copy(PushSharedMemory->FontName, buffer);

            Memory_Free(buffer);

            if (Ini_ReadBoolean(L"Settings", L"FontBold", FALSE, L".\\" PUSH_SETTINGS_FILE))
                PushSharedMemory->FontBold = TRUE;
        }
        else
        {
            MessageBoxW(
                NULL,
                L"Settings file not UTF-16LE! "
                L"Resave the file as \"Unicode\" or Push won't read it!",
                L"Bad Settings file",
                NULL
                );
        }
    }

    if (!PushDriverLoaded)
    {
        wchar_t driverPath[260];

        Resource_Extract(L"DRIVERALT", L"WinRing0x64.sys");
        GetDriverPath(L"WinRing0x64.sys", driverPath);
        Wr0DriverLoaded = Wr0Initialize(driverPath);
    }

    //initialize HWInfo
    GetHardwareInfo();

    //initialize OSD items

    NtQuerySection(
        sectionHandle,
        SectionBasicInformation,
        &sectionInfo,
        sizeof(SECTION_BASIC_INFORMATION),
        NULL
        );

    newSectionSize.QuadPart = OSD_Initialize() + sizeof(PUSH_SHARED_MEMORY);

    if (newSectionSize.QuadPart > sectionInfo.MaximumSize.QuadPart)
    {
        Log(L"Shared memory too small!");
    }

    //Check for controllers/gamepads/bluetooth adapters
    //EnumerateDevices();

    // Check for running games
    Process_EnumProcesses(ProcessEnum);

    // Activate process monitoring
    if (PushDriverLoaded)
    {
        PushToggleProcessMonitoring(TRUE);
    }
    else
    {
        HANDLE overlayLib = NULL;
        void* prcAddress = 0;

        Resource_Extract(L"OVERLAY32", PUSH_LIB_NAME_32);

        overlayLib = Module_Load(L"overlay32.dll");
        prcAddress = Module_GetProcedureAddress(overlayLib, "InstallOverlayHook");

        if (prcAddress)
        {
            InstallOverlayHook = (TYPE_InstallOverlayHook)prcAddress;
            InstallOverlayHook();
        }
    }

    g_szPrevGame[5] = '\0';

    NtCreateThreadEx(
        &PushMonitorThreadHandle,
        THREAD_ALL_ACCESS,
        NULL,
        NtCurrentProcess(),
        &MonitorThread,
        NULL,
        NoThreadFlags,
        0, 0, 0,
        NULL
        );

    NtCreateThreadEx(
        &threadHandle,
        THREAD_ALL_ACCESS,
        NULL,
        NtCurrentProcess(),
        &PipeThread,
        NULL,
        NoThreadFlags,
        0, 0, 0,
        NULL
        );

    // Handle messages

    while(GetMessageW(&messages, 0,0,0))
    {
        TranslateMessage(&messages);

        DispatchMessageW(&messages);
    }

    ExitProcess(0);

    return 0;
}
Пример #8
0
int window_update(window_t* window) { LOG

    static unsigned int previous_key = -1;
    static mouse_state_t prev_mouse_state;
    int error;

    /* Mouse */
    if (mouse_state.updated) {
        mouse_state.updated = 0;

        window->mouse_x += mouse_state.diffx;
        window->mouse_y -= mouse_state.diffy; /* inverted y axis */

        window->mouse_x = clamp(window->mouse_x, 0, window->width);
        window->mouse_y = clamp(window->mouse_y, 0, window->height);

        /*error = window_set_title(window, "x: %d, y: %d, w: %d, h: %d",
            window->mouse_x,
            window->mouse_y,
            window->width,
            window->height);
        if (error) {
            printf("window_update: window_set_title failed with error code %d.\n", error);
            return error;
        }*/

        if (mouse_state.ldown || mouse_state.mdown || mouse_state.rdown)
            window_mouse_press(window);

        if ((prev_mouse_state.ldown && !mouse_state.ldown) ||
            (prev_mouse_state.mdown && !mouse_state.mdown) ||
            (prev_mouse_state.rdown && !mouse_state.rdown))
            window_mouse_release(window);

        window->redraw = 1;
        prev_mouse_state = mouse_state;
    }

    /* Keyboard */
    if (last_key_pressed != -1) {
        error = window_key_press(window, last_key_pressed);
        if (!error) {
            switch (window->state) {
                case WIN_STATE_OPEN_ASK_NAME: {
                    if (window->current_tab != TAB_CONSOLE) {
                        window_set_log_message(window, "Open: Cancelled");
                        window_set_previous_tab(window);
                        window->state = WIN_STATE_NORMAL;
                    }
                    else if (last_key_pressed == KEY_ENTER || last_key_pressed == KEY_NUM_ENTER) {
                        int i;
                        size_t size;
                        char* fileName = tab_to_file(window->tabs[TAB_CONSOLE]);
                        char* fileBuffer = NULL;
                        tab_t* tab = NULL;
                        
                        for (i = 0; i < (TAB_COUNT - 1); i++) {
                            if (!window->tabs[i]) {
                                tab = window->tabs[i];
                                break;
                            }
                        }

                        if (i >= (TAB_COUNT - 1)) {
                            window_set_log_message(window, "Open: No tabs available to open file!");
                            window_set_previous_tab(window);
                            window->state = WIN_STATE_NORMAL;
                            break;
                        }

                        if (!File_Load(fileName, &fileBuffer, &size)) {
                            window_set_log_message(window, "Open: Error loading file %s", fileName);
                            window_set_previous_tab(window);
                            window->state = WIN_STATE_NORMAL;
                            break;
                        }

			fileBuffer[size-1] = 0;

                        window->tabs[i] = tab_create_from_file(fileName, fileBuffer);
                        if (window->tabs[i]) {
                            window_set_log_message(window, "Open: File loaded with success");
                        }
                        window_set_tab(window, i);
                        window->state = WIN_STATE_NORMAL;
                    }
                    break;
                }
                case WIN_STATE_SAVE_ASK_NAME: {
                    if (window->current_tab != TAB_CONSOLE) {
                        window_set_log_message(window, "Save: Cancelled");
                        window_set_previous_tab(window);
                        window->state = WIN_STATE_NORMAL;
                    } else if (last_key_pressed == KEY_ENTER || last_key_pressed == KEY_NUM_ENTER) {
                        char* fileName = tab_to_file(window->tabs[TAB_CONSOLE]);
                        char* fileBuffer = tab_to_file(window->tabs[window->prev_current_tab]);

                        if (strlen(fileName) != 0) {
                            if (File_Save(fileName, fileBuffer, strlen(fileBuffer))) {
                                window_set_log_message(window, "Save: File saved with success");
                                tab_remove_all(window->tabs[TAB_CONSOLE]);
                                window_set_previous_tab(window);
                                if ((strcmp(window->tabs[window->current_tab]->file_name, fileName) != 0) && (strlen(window->tabs[window->current_tab]->file_name) != strlen(fileName))) {
                                    tab_destroy(window->tabs[window->current_tab]);
                                    window->tabs[window->current_tab] = tab_create_from_file(fileName, fileBuffer);
                                }
                            } else {
                                window_set_log_message(window, "Save: Error saving file");
                            }
                        } else {
                            window_set_log_message(window, "Save: Invalid File name. Save cancelled");
                            window_set_previous_tab(window);
                        }
                        window->state = WIN_STATE_NORMAL;
                    }
                    break;
                }
                default: {
                    if (window->current_tab == TAB_CONSOLE && (last_key_pressed == KEY_ENTER || last_key_pressed == KEY_NUM_ENTER)) {
                        char* command = tab_to_file(window->tabs[TAB_CONSOLE]);
                        if (!command) break;
                        int size = strlen(command);
                        if (size == 0) break;
                        
                        if ((size == 3) && (strcmp("new", command) == 0)) {
                            new_btn_click(new_btn);
                            tab_remove_all(window->tabs[TAB_CONSOLE]);
                        }
                        else if ((size == 4) && (strcmp("save", command) == 0)) {
                            window_set_previous_tab(window);
                            save_btn_click(save_btn);
                        }
                        else if ((size == 4) && (strcmp("open", command) == 0)) {
                            open_btn_click(open_btn);
                        } else if ((size == 4) && (strcmp("exit", command) == 0)) {
                            close_btn_click(close_btn);
                        } else if ((size == 9) && (strcmp("close-tab", command) == 0)) {
                            window_remove_tab(window, window->prev_current_tab);
                            tab_remove_all(window->tabs[TAB_CONSOLE]);
                        } else {
                            window_set_log_message(window, "Invalid Command.");
                        }
                    }
                    break;
                }
            }

            previous_key = last_key_pressed;
            last_key_pressed = -1;
            window->redraw = 1;
        } else {
            printf("window_update: window_key_press failed with error code %d.\n", error);
            last_key_pressed = -1;
            window->redraw = 1;
        }
    }

    /* RTC */
    char* date = rtc_get_date();
    if (date) {
        printf("DEBUG: %s, %d\n", __FUNCTION__, __LINE__);
        if (window->date)
            free(window->date);
        window->date = date;
        window->redraw = 1;
    }

    return 0;
}