示例#1
0
/*
int i: either the number of existing watches minus 1, or the index of the watch to edit.
*/
bool InsertWatch(const AddressWatcher& Watch, char *Comment, int i)
{

	if (i == WatchCount) // append new watch
	{
		if(!VerifyWatchNotAlreadyAdded(Watch))
			return false;
		if(WatchCount >= MAX_WATCH_COUNT)
			return false;

		WatchCount++;
	}
	else // replace existing watch
	{
		// TODO: minor bug: we have not checked that they haven't changed the address to an already-existing watch.
		//       We can't just use VerifyWatchNotAlreadyAdded because doing so doesn't let us keep the same address but change the comment.
		free(rswatches[i].comment);
	}
	AddressWatcher& NewWatch = rswatches[i];
	NewWatch = Watch;
	NewWatch.comment = (char *) malloc(strlen(Comment)+2);
	NewWatch.CurValue = GetCurrentValue(NewWatch);
	strcpy(NewWatch.comment, Comment);
	ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
	RWfileChanged=true;

	return true;
}
示例#2
0
bool InsertWatch(const AddressWatcher& Watch, char *Comment, int atIndex)
{
	if(!VerifyWatchNotAlreadyAdded(Watch))
		return false;

	if(WatchCount >= MAX_WATCH_COUNT)
		return false;

	int i = WatchCount;
	if(atIndex == -1) {}
	else
	{
		//move watches down
		i = atIndex;
		for(int x=WatchCount;x>atIndex;x--)
			rswatches[x] = rswatches[x-1];
	}
	WatchCount++;
	AddressWatcher& NewWatch = rswatches[i];
	NewWatch = Watch;
	//if (NewWatch.comment) free(NewWatch.comment);
	NewWatch.comment = (char *) malloc(strlen(Comment)+2);
	NewWatch.CurValue = GetCurrentValue(NewWatch);
	strcpy(NewWatch.comment, Comment);
	ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
	RWfileChanged=true;

	return true;
}
示例#3
0
bool InsertWatch(const AddressWatcher& Watch, HWND parent)
{
	if(!VerifyWatchNotAlreadyAdded(Watch))
		return false;

	if(!parent)
		parent = RamWatchHWnd;
	if(!parent)
		parent = MainWindow->getHWnd();

	int prevWatchCount = WatchCount;

	rswatches[WatchCount] = Watch;
	rswatches[WatchCount].CurValue = GetCurrentValue(rswatches[WatchCount]);
	DialogBox(hAppInst, MAKEINTRESOURCE(IDD_PROMPT), parent, (DLGPROC) PromptWatchNameProc);

	return WatchCount > prevWatchCount;
}
示例#4
0
int InsertWatchHwnd(const struct AddressWatcher *Watch, HWND parent)
{
	int prevWatchCount;

	if(!VerifyWatchNotAlreadyAdded(Watch))
		return 0;

	if(!parent)
		parent = RamWatchHWnd;
	if(!parent)
		parent = YabWin;

	prevWatchCount = WatchCount;

	rswatches[WatchCount] = *Watch;
	rswatches[WatchCount].CurValue = GetCurrentValue(&rswatches[WatchCount]);
	DialogBox(y_hInstance, MAKEINTRESOURCE(IDD_PROMPT), parent, (DLGPROC) PromptWatchNameProc);

	return WatchCount > prevWatchCount;
}
bool InsertWatch(const AddressWatcher& Watch, HWND parent)
{
	if(!VerifyWatchNotAlreadyAdded(Watch))
		return false;

	if(!parent)
		parent = RamWatchHWnd;
	if(!parent)
		parent = hWnd;

	int prevWatchCount = WatchCount;

	rswatches[WatchCount] = Watch;
	EnterCriticalSection(&g_processMemCS);
	rswatches[WatchCount].CurValue = GetCurrentValue(rswatches[WatchCount]);
	LeaveCriticalSection(&g_processMemCS);
	DialogBox(hInst, MAKEINTRESOURCE(IDD_PROMPT), parent, (DLGPROC) PromptWatchNameProc);

	return WatchCount > prevWatchCount;
}
bool InsertWatch(const AddressWatcher& Watch, LPCSTR Comment)
{
	if(!VerifyWatchNotAlreadyAdded(Watch))
		return false;

	if(WatchCount >= MAX_WATCH_COUNT)
		return false;

	int i = WatchCount++;
	AddressWatcher& NewWatch = rswatches[i];
	NewWatch = Watch;
	//if(NewWatch.comment) free(NewWatch.comment);
	NewWatch.comment = (char *) malloc(strlen(Comment)+2);
	EnterCriticalSection(&g_processMemCS);
	NewWatch.CurValue = GetCurrentValue(NewWatch);
	LeaveCriticalSection(&g_processMemCS);
	strcpy(NewWatch.comment, Comment);
	ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
	RWfileChanged=true;

	return true;
}
示例#7
0
int InsertWatch(const struct AddressWatcher *Watch, char *Comment)
{
	int i;
	struct AddressWatcher *NewWatch;

	if(!VerifyWatchNotAlreadyAdded(Watch))
		return 0;

	if(WatchCount >= MAX_WATCH_COUNT)
		return 0;

	i = WatchCount++;

	NewWatch = &rswatches[i];
	//	NewWatch = Watch;
//	if (NewWatch->comment) free(NewWatch->comment);
	NewWatch->comment = (char *) malloc(strlen(Comment)+2);
	NewWatch->CurValue = GetCurrentValue((AddressWatcher*)Watch);;//Watch->CurValue;//GetCurrentValue(NewWatch);
	NewWatch->Address = Watch->Address;
	NewWatch->Size = Watch->Size;
	NewWatch->Type = Watch->Type;

	strcpy(NewWatch->comment, Comment);
	ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
	RWfileChanged=1;

	/*
	NewWatch = rswatches[i];
	NewWatch = Watch;
	//if (NewWatch.comment) free(NewWatch.comment);
	NewWatch->comment = (char *) malloc(strlen(Comment)+2);
	NewWatch->CurValue = GetCurrentValue(NewWatch);
	strcpy(NewWatch->comment, Comment);
	ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
	RWfileChanged=1;
	*/
	return 1;
}
LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List
{
	RECT r;
	RECT r2;
	int dx1, dy1, dx2, dy2;
	static int index;
	static char s,t = s = 0;

	switch(uMsg)
	{
		case WM_INITDIALOG:
			//Clear_Sound_Buffer();
			

			GetWindowRect(hWnd, &r);
			dx1 = (r.right - r.left) / 2;
			dy1 = (r.bottom - r.top) / 2;

			GetWindowRect(hDlg, &r2);
			dx2 = (r2.right - r2.left) / 2;
			dy2 = (r2.bottom - r2.top) / 2;

			//SetWindowPos(hDlg, NULL, max(0, r.left + (dx1 - dx2)), max(0, r.top + (dy1 - dy2)), NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
			index = (int)lParam;
			sprintf(Str_Tmp_RW,"%08X",rswatches[index].Address);
			SetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp_RW);
			if(rswatches[index].comment != NULL)
				SetDlgItemText(hDlg,IDC_PROMPT_EDIT,rswatches[index].comment);
			s = rswatches[index].Size;
			t = rswatches[index].Type;
			switch(s)
			{
				case 'b':
					SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'w':
					SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'd':
					SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'l':
					SendDlgItemMessage(hDlg, IDC_8_BYTES, BM_SETCHECK, BST_CHECKED, 0);
					break;
				default:
					s = 0;
					break;
			}
			switch(t)
			{
				case 's':
					SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0);
					EnableWindow(GetDlgItem(hDlg,IDC_1_BYTE),true);
					EnableWindow(GetDlgItem(hDlg,IDC_2_BYTES),true);
					break;
				case 'u':
					SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0);
					EnableWindow(GetDlgItem(hDlg,IDC_1_BYTE),true);
					EnableWindow(GetDlgItem(hDlg,IDC_2_BYTES),true);
					break;
				case 'h':
					SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0);
					EnableWindow(GetDlgItem(hDlg,IDC_1_BYTE),true);
					EnableWindow(GetDlgItem(hDlg,IDC_2_BYTES),true);
					break;
				case 'f':
					SendDlgItemMessage(hDlg, IDC_FLOAT, BM_SETCHECK, BST_CHECKED, 0);
					if(s == 'b' || s == 'w')
					{
						SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0);
						SendDlgItemMessage(hDlg, IDC_8_BYTES, BM_SETCHECK, BST_UNCHECKED, 0);
						SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_UNCHECKED, 0);
						SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_UNCHECKED, 0);
						s = 'd';
					}
					EnableWindow(GetDlgItem(hDlg,IDC_1_BYTE),false);
					EnableWindow(GetDlgItem(hDlg,IDC_2_BYTES),false);
					break;
				default:
					t = 0;
					break;
			}

			return true;
			break;
		
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDC_SIGNED:
					t='s';
					return true;
				case IDC_UNSIGNED:
					t='u';
					return true;
				case IDC_HEX:
					t='h';
					return true;
				case IDC_FLOAT:
					t='f';
					return true;
				case IDC_1_BYTE:
					s = 'b';
					return true;
				case IDC_2_BYTES:
					s = 'w';
					return true;
				case IDC_4_BYTES:
					s = 'd';
					return true;
				case IDC_8_BYTES:
					s = 'l';
					return true;
				case IDOK:
				{
					if(s && t)
					{
						AddressWatcher Temp = {};
						Temp.Size = s;
						Temp.Type = t;
						Temp.WrongEndian = false; //replace this when I get little endian working properly
						GetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp_RW,1024);
						char *addrstr = Str_Tmp_RW;
						if(strlen(Str_Tmp_RW) > 8) addrstr = &(Str_Tmp_RW[strlen(Str_Tmp_RW) - 9]);
						for(int i = 0; addrstr[i]; i++) {if(toupper(addrstr[i]) == 'O') addrstr[i] = '0';}
						sscanf(addrstr,"%08X",&(Temp.Address));

						//if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF)
						//	Temp.Address &= 0xFFFFFF;

						bool canceled = false;
						if(!VerifyWatchNotAlreadyAdded(Temp, index))
						{
							int result = MessageBox(hDlg,"Watch already exists. Replace it?","REPLACE",MB_YESNO);
							if(result == IDYES)
								RemoveWatch(Temp, index);
							if(result == IDNO)
								canceled = true;
						}
						if(!canceled)
						{
							if(IsHardwareAddressValid(Temp.Address) || !Config::started || (index < WatchCount && Temp.Address == rswatches[index].Address))
							{
								GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp_RW,80);
								ReplaceWatch(Temp,Str_Tmp_RW,index);
								if(RamWatchHWnd)
								{
									ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
								}
								EndDialog(hDlg, true);
							}
							else
							{
								MessageBox(hDlg,"Invalid Address","ERROR",MB_OK);
							}
						}
					}
					else
					{
						strcpy(Str_Tmp_RW,"Error:");
						if(!s)
							strcat(Str_Tmp_RW," Size must be specified.");
						if(!t)
							strcat(Str_Tmp_RW," Type must be specified.");
						MessageBox(hDlg,Str_Tmp_RW,"ERROR",MB_OK);
					}
					RWfileChanged=true;
					return true;
					break;
				}
				case ID_CANCEL:
				case IDCANCEL:
					EndDialog(hDlg, false);
					return false;
					break;
			}
			break;

		case WM_CLOSE:
			EndDialog(hDlg, false);
			return false;
			break;
	}

	return false;
}