Merge pull request #1824 from shygoo/fix-string-search

[Debugger] Fix string search
This commit is contained in:
zilmar 2020-06-19 11:56:25 +09:30 committed by GitHub
commit 80b6de0afb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 22 deletions

View File

@ -1652,7 +1652,7 @@ void CDebugMemorySearch::Search(void)
}
}
m_MemoryScanner.SetValue<const char*>(value._string);
m_MemoryScanner.SetValue<const wchar_t*>(value._string);
m_MemoryScanner.SetStringValueLength(stringValueLength);
break;
case ValueType_unkstring:
@ -1662,7 +1662,7 @@ void CDebugMemorySearch::Search(void)
goto value_parse_error;
}
m_MemoryScanner.SetValue<const char*>(value._string);
m_MemoryScanner.SetValue<const wchar_t*>(value._string);
m_MemoryScanner.SetStringValueLength(stringValueLength);
break;
default:
@ -2313,7 +2313,7 @@ CEditMixed::~CEditMixed(void)
{
if (m_String != NULL)
{
free(m_String);
delete[] m_String;
}
}
@ -2331,11 +2331,11 @@ void CEditMixed::ReloadString(void)
{
if (m_String != NULL)
{
free(m_String);
delete[] m_String;
}
m_StringLength = GetWindowTextLength();
m_String = (wchar_t*) malloc(m_StringLength + 1);
m_String = new wchar_t[m_StringLength + 1];
GetWindowText(m_String, m_StringLength + 1);
}
@ -2526,7 +2526,7 @@ bool CEditMixed::GetValue(double& value)
return true;
}
bool CEditMixed::GetValueString(const char*& value, int& length)
bool CEditMixed::GetValueString(const wchar_t*& value, int& length)
{
ReloadString();
@ -2535,12 +2535,12 @@ bool CEditMixed::GetValueString(const char*& value, int& length)
return false;
}
value = (const char*)m_String;
value = m_String;
length = m_StringLength;
return true;
}
bool CEditMixed::GetValueHexString(const char*& value, int& length)
bool CEditMixed::GetValueHexString(const wchar_t*& value, int& length)
{
ReloadString();
@ -2558,18 +2558,19 @@ bool CEditMixed::GetValueHexString(const char*& value, int& length)
}
char *hexString = (char*)malloc(numBytes);
char *hexString = new char[numBytes];
wchar_t *wchexString = new wchar_t[numBytes];
CMemoryScanner::ParseHexString(hexString, string.c_str());
wchar_t *wchexString = (wchar_t*)malloc(numBytes * sizeof(wchar_t));
wcscpy(wchexString, stdstr(hexString).ToUTF16().c_str());
free(hexString);
free(m_String);
delete[] hexString;
delete[] m_String;
m_String = wchexString;
m_StringLength = numBytes;
value = (const char*)m_String;
value = m_String;
length = m_StringLength;
return true;
}

View File

@ -45,8 +45,8 @@ public:
bool GetValue(int64_t& value);
bool GetValue(float& value);
bool GetValue(double& value);
bool GetValueString(const char*& value, int& length);
bool GetValueHexString(const char*& value, int& length);
bool GetValueString(const wchar_t*& value, int& length);
bool GetValueHexString(const wchar_t*& value, int& length);
BEGIN_MSG_MAP_EX(CEditMixed)
//MSG_WM_CHAR(OnChar)

View File

@ -744,7 +744,7 @@ void CMemoryScanner::FirstScanLoopString(DisplayFormat resultDisplayFormat)
}
result.m_Address = addr | m_VAddrBits;
result.Set((const char*)NULL);
result.Set((const wchar_t*)NULL);
m_Results.push_back(result);
next_addr:;
}
@ -773,7 +773,7 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat)
}
result.m_Address = addr | m_VAddrBits;
result.Set((const char*)NULL);
result.Set((const wchar_t*)NULL);
m_Results.push_back(result);
next_addr:;
}
@ -782,7 +782,7 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat)
// scan for text of unknown single-byte encoding
void CMemoryScanner::FirstScanLoopUnkString(void)
{
const uint8_t* str = (const uint8_t*)m_Value._string;
const char* str = stdstr().FromUTF16(m_Value._string).c_str();
int length = m_StringValueLength;
uint32_t startAddr = m_RangeStartAddress;
@ -846,7 +846,7 @@ void CMemoryScanner::FirstScanLoopUnkString(void)
}
result.m_Address = addr | m_VAddrBits;
result.Set((const char*)NULL);
result.Set((const wchar_t*)NULL);
m_Results.push_back(result);
next_addr:;

View File

@ -71,7 +71,7 @@ typedef union {
int64_t _sint64;
float _float;
double _double;
const char* _string;
const wchar_t* _string;
} MixedValue;
class CMixed
@ -106,7 +106,7 @@ public:
inline void Set(int64_t v) { SetType(ValueType_int64); m_Value._sint64 = v; }
inline void Set(float v) { SetType(ValueType_float); m_Value._float = v; }
inline void Set(double v) { SetType(ValueType_double); m_Value._double = v; }
inline void Set(const char* v) { SetType(ValueType_string); m_Value._string = v; }
inline void Set(const wchar_t* v) { SetType(ValueType_string); m_Value._string = v; }
inline void Get(uint8_t* v) { *v = m_Value._uint8; }
inline void Get(int8_t* v) { *v = m_Value._sint8; }
@ -118,7 +118,7 @@ public:
inline void Get(int64_t* v) { *v = m_Value._sint64; }
inline void Get(float* v) { *v = m_Value._float; }
inline void Get(double* v) { *v = m_Value._double; }
inline void Get(const char** v) { *v = m_Value._string; }
inline void Get(const wchar_t** v) { *v = m_Value._string; }
const char* GetTypeName(void);
int GetTypeSize(void);