コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: AceXIE/xenomai-lab
MainWindow::MainWindow(const QString &execName, const QString &name, QWidget *parent) :
    BlockBase(parent,execName,name)
{

    /*
     * Sets the text for the top half of the dialog.
     */
    fillDialog("Plant","Transfer function of a given plant in the form B(Z)/A(Z)");
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: AceXIE/xenomai-lab
MainWindow::MainWindow(const QString &execName, const QString &name, QWidget *parent) :
    BlockBase(parent,execName,name)
{

    /*
     * Sets the text for the top half of the dialog.
     */
    fillDialog("Template","This is the paragraph describing what the block does");
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: AceXIE/xenomai-lab
MainWindow::MainWindow(const QString &execName, const QString &name, QWidget *parent) :
    BlockBase(parent,execName,name)
{

    /*
     * Sets the text for the top half of the dialog.
     */
    fillDialog("Dac12bpp","Interfaces the 12 bit dac in the blackbox.<BR>No options.");
}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: AceXIE/xenomai-lab
MainWindow::MainWindow(const QString &execName, const QString &name, QWidget *parent) :
    BlockBase(parent,execName,name)
{

    /*
     * Sets the text for the top half of the dialog.
     */
    fillDialog("Pid","A standard PID controller.");
}
コード例 #5
0
ファイル: sourceeditdialog.cpp プロジェクト: annejan/swarmtv
sourceEditDialog::sourceEditDialog(int id, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::sourceEditDialog)
{
    setAttribute(Qt::WA_DeleteOnClose);
    this->id = id;
    ui->setupUi(this);

    // Set values on the dialog
    fillDialog();

    // Connect signal
    QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(sourceAccepted()));
}
コード例 #6
0
ファイル: mainwindow.cpp プロジェクト: AceXIE/xenomai-lab
MainWindow::MainWindow(const QString &execName, const QString &name, QWidget *parent) :
    BlockBase(parent,execName,name)
{
    fillDialog("DA","This is a parallel port interface that outputs a PWM wave.<BR>The duty cycle is modulated by the input");
}
コード例 #7
0
DWORD WINAPI MyThread(LPVOID)
{
	char buf [100];
	DWORD oldProtection;
	BYTE Before_JMP[6]; // save retn here
	// find base address of GameDemo.exe in memory
	if(GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, ProcessName, &game_handle) == NULL) {
		wsprintf(buf, "Failed to get module handle");
		OutputDebugString(buf);
	} else {
		// find address of character constructor
		ParseCharacter = (CharacterConstReturnPtr)((uint32_t)game_handle+CHARACTER_CONST_OFFSET);
		wsprintf (buf, "Address of CharacterConstructor 0x%x", ParseCharacter);
		OutputDebugString(buf);
		// find address of character constructor return
		ParseCharacter = (CharacterConstReturnPtr)((uint32_t)game_handle+CHARACTER_CONST_OFFSET+CHARACTER_CONST_RETN_OFFSET);
		wsprintf (buf, "Address of retn in CharacterConstructor 0x%x", ParseCharacter);
		OutputDebugString(buf);
		// find addres of character destructor return
		RemoveCharacter = (CharacterDestReturnPtr)((uint32_t)game_handle+CHARACTER_DESTRUCTOR_RETN_OFFSET);
		wsprintf (buf, "Address of retn in CharacterDestReturnPtr 0x%x", RemoveCharacter);
		OutputDebugString(buf);
		// find address of character destructor
		CharacterDestructor = (CharacterDestructorPtr)((uint32_t)game_handle+CHARACTER_DESTRUCTOR_OFFSET);
		wsprintf (buf, "Address of CharacterDestructor 0x%x", CharacterDestructor);
		OutputDebugString(buf);
		

		// If jabia_characters is not empty, clear it. Every time the game loads a level, character pointers change.
		//TODO this function crashes on exit game
		
		/*
		// start detour characer destructor function		
		DetourRestoreAfterWith();
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)CharacterDestructor, myCharacterDestructor);
		DetourTransactionCommit();		
		// end detour characer destructor function
		*/

		jabia_characters.clear();
		
		// read + write
		VirtualProtect(ParseCharacter, 6, PAGE_EXECUTE_READWRITE, &oldProtection);
		DWORD JMPSize = ((DWORD)myCharacterConstReturn - (DWORD)ParseCharacter - 5);		
		BYTE JMP[6] = {0xE9, 0x90, 0x90, 0x90, 0x90, 0x90}; // JMP NOP NOP ...
		memcpy((void *)Before_JMP, (void *)ParseCharacter, 6); // save retn
		memcpy(&JMP[1], &JMPSize, 4);
		//wsprintf(buf, "JMP: %x%x%x%x%x", JMP[0], JMP[1], JMP[2], JMP[3], JMP[4], JMP[5]);
		//OutputDebugString(buf);
		// overwrite retn with JMP
		memcpy((void *)ParseCharacter, (void *)JMP, 6);
		// restore protection
		VirtualProtect((LPVOID)ParseCharacter, 6, oldProtection, NULL);

		// hook destructor return
		VirtualProtect(RemoveCharacter, 6, PAGE_EXECUTE_READWRITE, &oldProtection);
		JMPSize = ((DWORD)myCharacterDestReturn - (DWORD)RemoveCharacter - 5);		
		memcpy(&JMP[1], &JMPSize, 4);
		// overwrite retn with JMP
		memcpy((void *)RemoveCharacter, (void *)JMP, 6);
		// restore protection
		VirtualProtect((LPVOID)RemoveCharacter, 6, oldProtection, NULL);

		// give user instructions
		wsprintf(buf, "DLL successfully loaded. Load a save game and press F7 to bring up editor. Due to some bugs, you need to quit to main menu before you load another savegame.");
		MessageBox (0, buf, "JABIA character editor", MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
		wsprintf(buf, "Size of struct %i", sizeof(JABIA_Character));
		OutputDebugString(buf);
	
		while(true)
		{
			if(GetAsyncKeyState(VK_F7) & 1)
			{
				if(jabia_characters.at(last_character_selected_index) == NULL) {
					MessageBox (0, buf, "Memory error", MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
				} else {
					HWND hDialog = 0;
				
					hDialog = CreateDialog (g_hModule,
								MAKEINTRESOURCE (IDD_DIALOG1),
								0,
								DialogProc);

					fillDialog(hDialog, jabia_characters.at(last_character_selected_index));
				
					if (!hDialog)
					{
						char buf [100];
						wsprintf (buf, "Error x%x", GetLastError ());
						MessageBox (0, buf, "CreateDialog", MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
						return 1;
					 }
				
					MSG  msg;
					int status;
					while ((status = GetMessage (& msg, 0, 0, 0)) != 0)
					{
						if (status == -1)
							return -1;
						if (!IsDialogMessage (hDialog, & msg))
						{
							TranslateMessage ( & msg );
							DispatchMessage ( & msg );
						}
					}
				}
			} else if(GetAsyncKeyState(VK_F8) &1) {
				OutputDebugString("Unloading JABIA_debug DLL");
				break;
			}
		Sleep(100);
		}
		// restore retn hook
		// read + write
		VirtualProtect(ParseCharacter, 6, PAGE_EXECUTE_READWRITE, &oldProtection);
		memcpy((void *)ParseCharacter, (void *)Before_JMP, 6);
		// restore protection
		VirtualProtect((LPVOID)ParseCharacter, 6, oldProtection, NULL);

		FreeLibraryAndExitThread(g_hModule, 0);
	}
    return 0;
}
コード例 #8
0
BOOL CALLBACK DialogProc (HWND hwnd, 
                          UINT message, 
                          WPARAM wParam, 
                          LPARAM lParam)
{
	HMENU hMenu;
	HWND comboControl1;
	HWND comboControl2;
	HWND comboControl3;
	comboControl1=GetDlgItem(hwnd,IDC_COMBO1);	
	comboControl2=GetDlgItem(hwnd,IDC_COMBO2);	
	comboControl3=GetDlgItem(hwnd,IDC_COMBO3);	
	BOOL status = FALSE;
	JABIA_Character * ptr = 0; // character address

    switch (message)
    {
		case WM_INITDIALOG:
			BringWindowToTop(hwnd);

			// add menu
			hMenu = LoadMenu(g_hModule, MAKEINTRESOURCE(IDR_MENU1));
			SetMenu(hwnd,hMenu);
			
			// add icon
			HICON hIcon;

			hIcon = (HICON)LoadImage(   g_hModule,
                           MAKEINTRESOURCE(IDI_ICON1),
                           IMAGE_ICON,
                           GetSystemMetrics(SM_CXSMICON),
                           GetSystemMetrics(SM_CYSMICON),
                           0);
			if(hIcon) {
				SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			}

			// add characters to drop down list
			for(unsigned long i = 0; i < jabia_characters.size(); i++) {							
				SendMessage(comboControl1,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)jabia_characters.at(i)->merc_name));
				char buf[255];
				wsprintf(buf, "In init, Character at 0x%X", jabia_characters.at(i));	
				OutputDebugString(buf);
			}
				// select fist item in list
			SendMessage(comboControl1, CB_SETCURSEL, last_character_selected_index, 0);
			

			// add weapons slots to their combo box
			SendMessage(comboControl2,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"1"));
			SendMessage(comboControl2,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"2"));
			SendMessage(comboControl2,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"3"));

			// select fist item in list
			SendMessage(comboControl2, CB_SETCURSEL, last_weaponslot_selected_index, 0);


			// add inventory slots to their combo box
			for(int i = 0; i < JABIA_CHARACTER_INV_SLOTS; i++) {
				char buf[5];
				//wsprintf(buf, "%i", i);
				SendMessage(comboControl3,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)buf));
			}

			// select fist item in list
			SendMessage(comboControl3, CB_SETCURSEL, 0, 0);

			break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
				case IDC_COMBO1:
					switch(HIWORD(wParam))
					{
						case CBN_CLOSEUP:
							// use combo box selected index to get a character out of the vector
							last_character_selected_index = SendMessage(comboControl1, CB_GETCURSEL, 0, 0);
							ptr = jabia_characters.at(last_character_selected_index);
							fillDialog(hwnd, ptr);
							break;
					}
					break;
				case IDC_COMBO2:
					switch(HIWORD(wParam))
					{
						case CBN_CLOSEUP:
							// use combo box selected index to get weapon from inventory
							last_weaponslot_selected_index = SendMessage(comboControl2, CB_GETCURSEL, 0, 0);
							ptr = jabia_characters.at(last_character_selected_index);
							fillDialog(hwnd, ptr);
							break;
					}
					break;
				case IDC_COMBO3:
					switch(HIWORD(wParam))
					{
						case CBN_CLOSEUP:
							// use combo box selected index to get weapon from inventory
							last_inventory_selected_index = SendMessage(comboControl3, CB_GETCURSEL, 0, 0);
							ptr = jabia_characters.at(last_character_selected_index);
							fillDialog(hwnd, ptr);
							break;
					}
					break;
                case IDSET:
					//char buf[50];
					//wsprintf(buf, "Setting");
					ptr = jabia_characters.at(last_character_selected_index);
					setCharacter(hwnd, ptr);
					break;
				case IDM_HEAL_CHARACTER:					
					ptr = jabia_characters.at(last_character_selected_index);
					heal_character(ptr);
					fillDialog(hwnd, ptr);
					break;
				case IDM_KILL_CHARACTER:					
					ptr = jabia_characters.at(last_character_selected_index);
					kill_character(ptr);
					fillDialog(hwnd, ptr);
					break;
				case IDM_STUN_CHARACTER:
					ptr = jabia_characters.at(last_character_selected_index);
					stun_character(ptr);
					fillDialog(hwnd, ptr);
					break;
				case IDM_EQUIPMENT1:
					ptr = jabia_characters.at(last_character_selected_index);
					give_equipment1(ptr);
					fillDialog(hwnd, ptr);
					break;
				case IDM_DUMP_CHARACTER:					
					ptr = jabia_characters.at(last_character_selected_index);
					dump_current_character(hwnd, ptr);
					break;
				case IDM_DUMP_ALL:				
					dump_all_characters(hwnd);
					break;
                case IDCANCEL:
                    DestroyWindow(hwnd);
					PostQuitMessage(0);
					break;
            }
        break;
        default:
            return FALSE;
    }
    return FALSE;
}