DBG: fixed ambiguous stuff in dynamicmem.h (automatic type conversion using templates is not a good idea...)
This commit is contained in:
parent
c44c89f59e
commit
ba0e5e1a0a
|
|
@ -181,11 +181,10 @@ void formathex(char* string)
|
|||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
Memory<char*> new_string(len + 1, "formathex:new_string");
|
||||
memset(new_string, 0, len + 1);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
if(isxdigit(string[i]))
|
||||
j += sprintf(new_string + j, "%c", string[i]);
|
||||
strcpy_s(string, len + 1, new_string);
|
||||
j += sprintf(new_string() + j, "%c", string[i]);
|
||||
strcpy_s(string, len + 1, new_string());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -197,11 +196,10 @@ void formatdec(char* string)
|
|||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
Memory<char*> new_string(len + 1, "formatdec:new_string");
|
||||
memset(new_string, 0, len + 1);
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
if(isdigit(string[i]))
|
||||
j += sprintf(new_string + j, "%c", string[i]);
|
||||
strcpy_s(string, len + 1, new_string);
|
||||
j += sprintf(new_string() + j, "%c", string[i]);
|
||||
strcpy_s(string, len + 1, new_string());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ void dbload()
|
|||
|
||||
Memory<char*> jsonText(jsonFileSize + 1);
|
||||
DWORD read = 0;
|
||||
if(!ReadFile(hFile, jsonText, jsonFileSize, &read, 0))
|
||||
if(!ReadFile(hFile, jsonText(), jsonFileSize, &read, 0))
|
||||
{
|
||||
dputs("\nFailed to read database file!");
|
||||
return;
|
||||
|
|
@ -110,7 +110,7 @@ void dbload()
|
|||
hFile.Close();
|
||||
|
||||
// Deserialize JSON
|
||||
JSON root = json_loads(jsonText, 0, 0);
|
||||
JSON root = json_loads(jsonText(), 0, 0);
|
||||
|
||||
if(lzmaStatus != LZ4_INVALID_ARCHIVE && useCompression)
|
||||
LZ4_compress_fileW(databasePathW.c_str(), databasePathW.c_str());
|
||||
|
|
@ -154,9 +154,9 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum)
|
|||
VirtualQueryEx(fdProcessInfo->hProcess, (const void*)base, &mbi, sizeof(mbi));
|
||||
uint size = mbi.RegionSize;
|
||||
Memory<void*> buffer(size, "apienumexports:buffer");
|
||||
if(!MemRead(base, buffer, size, 0))
|
||||
if(!MemRead(base, buffer(), size, 0))
|
||||
return false;
|
||||
IMAGE_NT_HEADERS* pnth = (IMAGE_NT_HEADERS*)((uint)buffer + GetPE32DataFromMappedFile((ULONG_PTR)buffer, 0, UE_PE_OFFSET));
|
||||
IMAGE_NT_HEADERS* pnth = (IMAGE_NT_HEADERS*)((uint)buffer() + GetPE32DataFromMappedFile((ULONG_PTR)buffer(), 0, UE_PE_OFFSET));
|
||||
uint export_dir_rva = pnth->OptionalHeader.DataDirectory[0].VirtualAddress;
|
||||
uint export_dir_size = pnth->OptionalHeader.DataDirectory[0].Size;
|
||||
IMAGE_EXPORT_DIRECTORY export_dir;
|
||||
|
|
|
|||
|
|
@ -426,9 +426,9 @@ static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode
|
|||
if(strstr(text, " bytes - "))
|
||||
{
|
||||
Memory<char*> newtext(len + 1, "SymRegisterCallbackProc64:newtext");
|
||||
strcpy_s(newtext, len + 1, text);
|
||||
strstr(newtext, " bytes - ")[8] = 0;
|
||||
GuiSymbolLogAdd(newtext);
|
||||
strcpy_s(newtext(), len + 1, text);
|
||||
strstr(newtext(), " bytes - ")[8] = 0;
|
||||
GuiSymbolLogAdd(newtext());
|
||||
suspress = true;
|
||||
}
|
||||
else if(strstr(text, " copied "))
|
||||
|
|
@ -661,14 +661,14 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
|
|||
{
|
||||
dprintf("TLS Callbacks: %d\n", NumberOfCallBacks);
|
||||
Memory<uint*> TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbCreateProcess:TLSCallBacks");
|
||||
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks))
|
||||
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), TLSCallBacks(), &NumberOfCallBacks))
|
||||
dputs("Failed to get TLS callback addresses!");
|
||||
else
|
||||
{
|
||||
uint ImageBase = GetPE32DataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), 0, UE_IMAGEBASE);
|
||||
for(unsigned int i = 0; i < NumberOfCallBacks; i++)
|
||||
{
|
||||
sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + pDebuggedBase, i + 1);
|
||||
sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks()[i] - ImageBase + pDebuggedBase, i + 1);
|
||||
cmddirectexec(dbggetcommandlist(), command);
|
||||
}
|
||||
}
|
||||
|
|
@ -863,7 +863,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
|
|||
{
|
||||
dprintf("TLS Callbacks: %d\n", NumberOfCallBacks);
|
||||
Memory<uint*> TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbLoadDll:TLSCallBacks");
|
||||
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks))
|
||||
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), TLSCallBacks(), &NumberOfCallBacks))
|
||||
dputs("Failed to get TLS callback addresses!");
|
||||
else
|
||||
{
|
||||
|
|
@ -871,9 +871,9 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
|
|||
for(unsigned int i = 0; i < NumberOfCallBacks; i++)
|
||||
{
|
||||
if(bIsDebuggingThis)
|
||||
sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks[i] - ImageBase + (uint)base, i + 1);
|
||||
sprintf(command, "bp "fhex",\"TLS Callback %d\",ss", TLSCallBacks()[i] - ImageBase + (uint)base, i + 1);
|
||||
else
|
||||
sprintf(command, "bp "fhex",\"TLS Callback %d (%s)\",ss", TLSCallBacks[i] - ImageBase + (uint)base, i + 1, modname);
|
||||
sprintf(command, "bp "fhex",\"TLS Callback %d (%s)\",ss", TLSCallBacks()[i] - ImageBase + (uint)base, i + 1, modname);
|
||||
cmddirectexec(dbggetcommandlist(), command);
|
||||
}
|
||||
}
|
||||
|
|
@ -1047,9 +1047,9 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
|
|||
if(nameInfo.dwType == 0x1000 && nameInfo.dwFlags == 0 && ThreadIsValid(nameInfo.dwThreadID)) //passed basic checks
|
||||
{
|
||||
Memory<char*> ThreadName(MAX_THREAD_NAME_SIZE, "cbException:ThreadName");
|
||||
if(MemRead((uint)nameInfo.szName, ThreadName, MAX_THREAD_NAME_SIZE - 1, 0))
|
||||
if(MemRead((uint)nameInfo.szName, ThreadName(), MAX_THREAD_NAME_SIZE - 1, 0))
|
||||
{
|
||||
String ThreadNameEscaped = StringUtils::Escape(ThreadName);
|
||||
String ThreadNameEscaped = StringUtils::Escape(ThreadName());
|
||||
dprintf("SetThreadName(%X, \"%s\")\n", nameInfo.dwThreadID, ThreadNameEscaped.c_str());
|
||||
ThreadSetName(nameInfo.dwThreadID, ThreadNameEscaped.c_str());
|
||||
}
|
||||
|
|
@ -1931,13 +1931,13 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error)
|
|||
Memory<wchar_t*> command_linewstr(new_command_line.Length);
|
||||
|
||||
// Covert to Unicode.
|
||||
if(!MultiByteToWideChar(CP_UTF8, 0, cmd_line, (int)cmd_line_size + 1, command_linewstr, (int)cmd_line_size + 1))
|
||||
if(!MultiByteToWideChar(CP_UTF8, 0, cmd_line, (int)cmd_line_size + 1, command_linewstr(), (int)cmd_line_size + 1))
|
||||
{
|
||||
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;
|
||||
return false;
|
||||
}
|
||||
|
||||
new_command_line.Buffer = command_linewstr;
|
||||
new_command_line.Buffer = command_linewstr();
|
||||
|
||||
uint mem = (uint)MemAllocRemote(0, new_command_line.Length * 2, PAGE_READWRITE);
|
||||
if(!mem)
|
||||
|
|
@ -1995,19 +1995,19 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error)
|
|||
Memory<wchar_t*> wstr_cmd(CommandLine.Length + sizeof(wchar_t));
|
||||
|
||||
cmd_line_error->addr = (uint) CommandLine.Buffer;
|
||||
if(!MemRead(cmd_line_error->addr, wstr_cmd, CommandLine.Length, &size))
|
||||
if(!MemRead(cmd_line_error->addr, wstr_cmd(), CommandLine.Length, &size))
|
||||
{
|
||||
cmd_line_error->type = CMDL_ERR_READ_PROCPARM_CMDLINE;
|
||||
return false;
|
||||
}
|
||||
|
||||
SIZE_T wstr_cmd_size = wcslen(wstr_cmd) + 1;
|
||||
SIZE_T wstr_cmd_size = wcslen(wstr_cmd()) + 1;
|
||||
SIZE_T cmd_line_size = wstr_cmd_size * 2;
|
||||
|
||||
*cmd_line = (char*)emalloc(cmd_line_size, "dbggetcmdline:cmd_line");
|
||||
|
||||
//Convert TO UTF-8
|
||||
if(!WideCharToMultiByte(CP_UTF8, 0, wstr_cmd, (int)wstr_cmd_size, * cmd_line, (int)cmd_line_size, NULL, NULL))
|
||||
if(!WideCharToMultiByte(CP_UTF8, 0, wstr_cmd(), (int)wstr_cmd_size, * cmd_line, (int)cmd_line_size, NULL, NULL))
|
||||
{
|
||||
efree(*cmd_line);
|
||||
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;
|
||||
|
|
|
|||
|
|
@ -294,21 +294,20 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
if(!disasmispossiblestring(addr))
|
||||
return false;
|
||||
Memory<unsigned char*> data((maxlen + 1) * 2, "disasmgetstringat:data");
|
||||
memset(data, 0, (maxlen + 1) * 2);
|
||||
if(!MemRead(addr, data, (maxlen + 1) * 2, 0))
|
||||
if(!MemRead(addr, data(), (maxlen + 1) * 2, 0))
|
||||
return false;
|
||||
uint test = 0;
|
||||
memcpy(&test, data, sizeof(uint));
|
||||
memcpy(&test, data(), sizeof(uint));
|
||||
if(MemIsValidReadPtr(test))
|
||||
return false;
|
||||
if(isasciistring(data, maxlen))
|
||||
if(isasciistring(data(), maxlen))
|
||||
{
|
||||
if(type)
|
||||
*type = str_ascii;
|
||||
int len = (int)strlen((const char*)data);
|
||||
int len = (int)strlen((const char*)data());
|
||||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
switch(data[i])
|
||||
switch(data()[i])
|
||||
{
|
||||
case '\t':
|
||||
j += sprintf(ascii + j, "\\t");
|
||||
|
|
@ -332,20 +331,20 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
j += sprintf(ascii + j, "\\\"");
|
||||
break;
|
||||
default:
|
||||
j += sprintf(ascii + j, "%c", data[i]);
|
||||
j += sprintf(ascii + j, "%c", data()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(isunicodestring(data, maxlen))
|
||||
else if(isunicodestring(data(), maxlen))
|
||||
{
|
||||
if(type)
|
||||
*type = str_unicode;
|
||||
int len = (int)wcslen((const wchar_t*)data);
|
||||
int len = (int)wcslen((const wchar_t*)data());
|
||||
for(int i = 0, j = 0; i < len * 2; i += 2)
|
||||
{
|
||||
switch(data[i])
|
||||
switch(data()[i])
|
||||
{
|
||||
case '\t':
|
||||
j += sprintf(unicode + j, "\\t");
|
||||
|
|
@ -369,7 +368,7 @@ bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode,
|
|||
j += sprintf(unicode + j, "\\\"");
|
||||
break;
|
||||
default:
|
||||
j += sprintf(unicode + j, "%c", data[i]);
|
||||
j += sprintf(unicode + j, "%c", data()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ public:
|
|||
// This class guarantees that the returned allocated memory
|
||||
// will always be zeroed
|
||||
//
|
||||
Memory(const char* Reason = "Memory:???")
|
||||
explicit Memory(const char* Reason = "Memory:???")
|
||||
{
|
||||
m_Ptr = nullptr;
|
||||
m_Size = 0;
|
||||
m_Reason = Reason;
|
||||
}
|
||||
|
||||
Memory(size_t Size, const char* Reason = "Memory:???")
|
||||
explicit Memory(size_t Size, const char* Reason = "Memory:???")
|
||||
{
|
||||
m_Ptr = reinterpret_cast<T>(emalloc(Size));
|
||||
m_Size = Size;
|
||||
|
|
@ -44,28 +44,11 @@ public:
|
|||
return m_Size;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
operator U()
|
||||
{
|
||||
return (U)m_Ptr;
|
||||
}
|
||||
|
||||
operator T()
|
||||
{
|
||||
return m_Ptr;
|
||||
}
|
||||
|
||||
T operator()()
|
||||
{
|
||||
return m_Ptr;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
T operator+(const U & Other)
|
||||
{
|
||||
return m_Ptr + Other;
|
||||
}
|
||||
|
||||
private:
|
||||
T m_Ptr;
|
||||
size_t m_Size;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ bool FileReader::ReadAllText(const String & fileName, String & content)
|
|||
}
|
||||
Memory<char*> filedata(filesize + 1, "FileReader::ReadAllText:filedata");
|
||||
DWORD read = 0;
|
||||
if(!ReadFile(hFile, filedata, filesize, &read, 0))
|
||||
if(!ReadFile(hFile, filedata(), filesize, &read, 0))
|
||||
return false;
|
||||
content = String(filedata());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -184,10 +184,10 @@ CMDRESULT cbInstrMov(int argc, char* argv[])
|
|||
b[1] = dataText[i + 1];
|
||||
int res = 0;
|
||||
sscanf_s(b, "%X", &res);
|
||||
data[j] = res;
|
||||
data()[j] = res;
|
||||
}
|
||||
//Move data to destination
|
||||
if(!MemWrite(dest, data, data.size(), 0))
|
||||
if(!MemWrite(dest, data(), data.size(), 0))
|
||||
{
|
||||
dprintf("failed to write to "fhex"\n", dest);
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -242,7 +242,7 @@ CMDRESULT cbInstrVarList(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
Memory<VAR*> variables(cbsize, "cbInstrVarList:variables");
|
||||
if(!varenum(variables, 0))
|
||||
if(!varenum(variables(), 0))
|
||||
{
|
||||
dputs("error listing variables!");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -251,16 +251,16 @@ CMDRESULT cbInstrVarList(int argc, char* argv[])
|
|||
int varcount = (int)cbsize / sizeof(VAR);
|
||||
for(int i = 0; i < varcount; i++)
|
||||
{
|
||||
if(variables[i].alias.length())
|
||||
if(variables()[i].alias.length())
|
||||
continue;
|
||||
char name[deflen] = "";
|
||||
strcpy_s(name, variables[i].name.c_str());
|
||||
uint value = (uint)variables[i].value.u.value;
|
||||
if(variables[i].type != VAR_HIDDEN)
|
||||
strcpy_s(name, variables()[i].name.c_str());
|
||||
uint value = (uint)variables()[i].value.u.value;
|
||||
if(variables()[i].type != VAR_HIDDEN)
|
||||
{
|
||||
if(filter)
|
||||
{
|
||||
if(variables[i].type == filter)
|
||||
if(variables()[i].type == filter)
|
||||
{
|
||||
if(value > 15)
|
||||
dprintf("%s=%"fext"X (%"fext"ud)\n", name, value, value);
|
||||
|
|
@ -1022,8 +1022,7 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
}
|
||||
Memory<char*> string(size + 1, "cbInstrGetstr:string");
|
||||
memset(string, 0, size + 1);
|
||||
if(!varget(argv[1], (char*)string, &size, 0))
|
||||
if(!varget(argv[1], string(), &size, 0))
|
||||
{
|
||||
dprintf("failed to get variable data \"%s\"!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1057,8 +1056,7 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
}
|
||||
Memory<char*> string(size + 1, "cbInstrGetstr:string");
|
||||
memset(string, 0, size + 1);
|
||||
if(!varget(argv[2], (char*)string, &size, 0))
|
||||
if(!varget(argv[2], string(), &size, 0))
|
||||
{
|
||||
dprintf("failed to get variable data \"%s\"!\n", argv[2]);
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1069,7 +1067,7 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[])
|
|||
dprintf("invalid address \"%s\"!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(!MemPatch(addr, string, strlen(string), 0))
|
||||
if(!MemPatch(addr, string(), strlen(string()), 0))
|
||||
{
|
||||
dputs("memwrite failed!");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1107,7 +1105,7 @@ CMDRESULT cbInstrFind(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
}
|
||||
Memory<unsigned char*> data(size, "cbInstrFind:data");
|
||||
if(!MemRead(base, data, size, 0))
|
||||
if(!MemRead(base, data(), size, 0))
|
||||
{
|
||||
dputs("failed to read memory!");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1123,7 +1121,7 @@ CMDRESULT cbInstrFind(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
find_size = size - start;
|
||||
uint foundoffset = patternfind(data + start, find_size, pattern);
|
||||
uint foundoffset = patternfind(data() + start, find_size, pattern);
|
||||
uint result = 0;
|
||||
if(foundoffset != -1)
|
||||
result = addr + foundoffset;
|
||||
|
|
@ -1159,7 +1157,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
|
|||
return STATUS_ERROR;
|
||||
}
|
||||
Memory<unsigned char*> data(size, "cbInstrFindAll:data");
|
||||
if(!MemRead(base, data, size, 0))
|
||||
if(!MemRead(base, data(), size, 0))
|
||||
{
|
||||
dputs("failed to read memory!");
|
||||
return STATUS_ERROR;
|
||||
|
|
@ -1207,7 +1205,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
|
|||
}
|
||||
while(refCount < 5000)
|
||||
{
|
||||
uint foundoffset = patternfind(data + start + i, find_size - i, searchpattern);
|
||||
uint foundoffset = patternfind(data() + start + i, find_size - i, searchpattern);
|
||||
if(foundoffset == -1)
|
||||
break;
|
||||
i += foundoffset + 1;
|
||||
|
|
@ -1224,7 +1222,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
|
|||
{
|
||||
if(j)
|
||||
k += sprintf(msg + k, " ");
|
||||
k += sprintf(msg + k, "%.2X", printData[j]);
|
||||
k += sprintf(msg + k, "%.2X", printData()[j]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1306,18 +1304,18 @@ CMDRESULT cbInstrCommentList(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
Memory<COMMENTSINFO*> comments(cbsize, "cbInstrCommentList:comments");
|
||||
CommentEnum(comments, 0);
|
||||
CommentEnum(comments(), 0);
|
||||
int count = (int)(cbsize / sizeof(COMMENTSINFO));
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GuiReferenceSetRowCount(i + 1);
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", comments[i].addr);
|
||||
sprintf(addrText, "%p", comments()[i].addr);
|
||||
GuiReferenceSetCellContent(i, 0, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly(comments[i].addr, disassembly))
|
||||
if(GuiGetDisassembly(comments()[i].addr, disassembly))
|
||||
GuiReferenceSetCellContent(i, 1, disassembly);
|
||||
GuiReferenceSetCellContent(i, 2, comments[i].text);
|
||||
GuiReferenceSetCellContent(i, 2, comments()[i].text);
|
||||
}
|
||||
varset("$result", count, false);
|
||||
dprintf("%d comment(s) listed in Reference View\n", count);
|
||||
|
|
@ -1341,18 +1339,18 @@ CMDRESULT cbInstrLabelList(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
Memory<LABELSINFO*> labels(cbsize, "cbInstrLabelList:labels");
|
||||
LabelEnum(labels, 0);
|
||||
LabelEnum(labels(), 0);
|
||||
int count = (int)(cbsize / sizeof(LABELSINFO));
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GuiReferenceSetRowCount(i + 1);
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", labels[i].addr);
|
||||
sprintf(addrText, "%p", labels()[i].addr);
|
||||
GuiReferenceSetCellContent(i, 0, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly(labels[i].addr, disassembly))
|
||||
if(GuiGetDisassembly(labels()[i].addr, disassembly))
|
||||
GuiReferenceSetCellContent(i, 1, disassembly);
|
||||
GuiReferenceSetCellContent(i, 2, labels[i].text);
|
||||
GuiReferenceSetCellContent(i, 2, labels()[i].text);
|
||||
}
|
||||
varset("$result", count, false);
|
||||
dprintf("%d label(s) listed in Reference View\n", count);
|
||||
|
|
@ -1375,16 +1373,16 @@ CMDRESULT cbInstrBookmarkList(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
Memory<BOOKMARKSINFO*> bookmarks(cbsize, "cbInstrBookmarkList:bookmarks");
|
||||
BookmarkEnum(bookmarks, 0);
|
||||
BookmarkEnum(bookmarks(), 0);
|
||||
int count = (int)(cbsize / sizeof(BOOKMARKSINFO));
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GuiReferenceSetRowCount(i + 1);
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", bookmarks[i].addr);
|
||||
sprintf(addrText, "%p", bookmarks()[i].addr);
|
||||
GuiReferenceSetCellContent(i, 0, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly(bookmarks[i].addr, disassembly))
|
||||
if(GuiGetDisassembly(bookmarks()[i].addr, disassembly))
|
||||
GuiReferenceSetCellContent(i, 1, disassembly);
|
||||
}
|
||||
varset("$result", count, false);
|
||||
|
|
@ -1410,26 +1408,26 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
Memory<FUNCTIONSINFO*> functions(cbsize, "cbInstrFunctionList:functions");
|
||||
FunctionEnum(functions, 0);
|
||||
FunctionEnum(functions(), 0);
|
||||
int count = (int)(cbsize / sizeof(FUNCTIONSINFO));
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GuiReferenceSetRowCount(i + 1);
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", functions[i].start);
|
||||
sprintf(addrText, "%p", functions()[i].start);
|
||||
GuiReferenceSetCellContent(i, 0, addrText);
|
||||
sprintf(addrText, "%p", functions[i].end);
|
||||
sprintf(addrText, "%p", functions()[i].end);
|
||||
GuiReferenceSetCellContent(i, 1, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly(functions[i].start, disassembly))
|
||||
if(GuiGetDisassembly(functions()[i].start, disassembly))
|
||||
GuiReferenceSetCellContent(i, 2, disassembly);
|
||||
char label[MAX_LABEL_SIZE] = "";
|
||||
if(LabelGet(functions[i].start, label))
|
||||
if(LabelGet(functions()[i].start, label))
|
||||
GuiReferenceSetCellContent(i, 3, label);
|
||||
else
|
||||
{
|
||||
char comment[MAX_COMMENT_SIZE] = "";
|
||||
if(CommentGet(functions[i].start, comment))
|
||||
if(CommentGet(functions()[i].start, comment))
|
||||
GuiReferenceSetCellContent(i, 3, comment);
|
||||
}
|
||||
}
|
||||
|
|
@ -1456,26 +1454,26 @@ CMDRESULT cbInstrLoopList(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
Memory<LOOPSINFO*> loops(cbsize, "cbInstrLoopList:loops");
|
||||
LoopEnum(loops, 0);
|
||||
LoopEnum(loops(), 0);
|
||||
int count = (int)(cbsize / sizeof(LOOPSINFO));
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GuiReferenceSetRowCount(i + 1);
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", loops[i].start);
|
||||
sprintf(addrText, "%p", loops()[i].start);
|
||||
GuiReferenceSetCellContent(i, 0, addrText);
|
||||
sprintf(addrText, "%p", loops[i].end);
|
||||
sprintf(addrText, "%p", loops()[i].end);
|
||||
GuiReferenceSetCellContent(i, 1, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly(loops[i].start, disassembly))
|
||||
if(GuiGetDisassembly(loops()[i].start, disassembly))
|
||||
GuiReferenceSetCellContent(i, 2, disassembly);
|
||||
char label[MAX_LABEL_SIZE] = "";
|
||||
if(LabelGet(loops[i].start, label))
|
||||
if(LabelGet(loops()[i].start, label))
|
||||
GuiReferenceSetCellContent(i, 3, label);
|
||||
else
|
||||
{
|
||||
char comment[MAX_COMMENT_SIZE] = "";
|
||||
if(CommentGet(loops[i].start, comment))
|
||||
if(CommentGet(loops()[i].start, comment))
|
||||
GuiReferenceSetCellContent(i, 3, comment);
|
||||
}
|
||||
}
|
||||
|
|
@ -1988,7 +1986,7 @@ CMDRESULT cbInstrVisualize(int argc, char* argv[])
|
|||
Sleep(300);
|
||||
|
||||
//continue algorithm
|
||||
const unsigned char* curData = (addr >= _base && addr < _base + _size) ? _data + (addr - _base) : nullptr;
|
||||
const unsigned char* curData = (addr >= _base && addr < _base + _size) ? _data() + (addr - _base) : nullptr;
|
||||
if(_cp.Disassemble(addr, curData, MAX_DISASM_BUFFER))
|
||||
{
|
||||
if(addr + _cp.Size() > maxaddr) //we went past the maximum allowed address
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ int RefFind(uint Address, uint Size, CBREF Callback, void* UserData, bool Silent
|
|||
// Allocate and read a buffer from the remote process
|
||||
Memory<unsigned char*> data(scanSize, "reffind:data");
|
||||
|
||||
if(!MemRead(scanStart, data, scanSize, nullptr))
|
||||
if(!MemRead(scanStart, data(), scanSize, nullptr))
|
||||
{
|
||||
if(!Silent)
|
||||
dprintf("Error reading memory in reference search\n");
|
||||
|
|
|
|||
|
|
@ -87,22 +87,21 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
return false;
|
||||
}
|
||||
Memory<char*> filedata(filesize + 1, "createlinemap:filedata");
|
||||
memset(filedata, 0, filesize + 1);
|
||||
DWORD read = 0;
|
||||
if(!ReadFile(hFile, filedata, filesize, &read, 0))
|
||||
if(!ReadFile(hFile, filedata(), filesize, &read, 0))
|
||||
{
|
||||
GuiScriptError(0, "ReadFile failed...");
|
||||
return false;
|
||||
}
|
||||
hFile.Close();
|
||||
int len = (int)strlen(filedata);
|
||||
int len = (int)strlen(filedata());
|
||||
char temp[256] = "";
|
||||
LINEMAPENTRY entry;
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
std::vector<LINEMAPENTRY>().swap(linemap);
|
||||
for(int i = 0, j = 0; i < len; i++) //make raw line map
|
||||
{
|
||||
if(filedata[i] == '\r' && filedata[i + 1] == '\n') //windows file
|
||||
if(filedata()[i] == '\r' && filedata()[i + 1] == '\n') //windows file
|
||||
{
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
int add = 0;
|
||||
|
|
@ -114,7 +113,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
i++;
|
||||
linemap.push_back(entry);
|
||||
}
|
||||
else if(filedata[i] == '\n') //other file
|
||||
else if(filedata()[i] == '\n') //other file
|
||||
{
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
int add = 0;
|
||||
|
|
@ -137,7 +136,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
linemap.push_back(entry);
|
||||
}
|
||||
else
|
||||
j += sprintf(temp + j, "%c", filedata[i]);
|
||||
j += sprintf(temp + j, "%c", filedata()[i]);
|
||||
}
|
||||
if(*temp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1387,12 +1387,12 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
|
|||
{
|
||||
addrfound.realloc(cbNeeded * sizeof(uint), "valapifromstring:addrfound");
|
||||
Memory<HMODULE*> hMods(cbNeeded * sizeof(HMODULE), "valapifromstring:hMods");
|
||||
if(EnumProcessModules(fdProcessInfo->hProcess, hMods, cbNeeded, &cbNeeded))
|
||||
if(EnumProcessModules(fdProcessInfo->hProcess, hMods(), cbNeeded, &cbNeeded))
|
||||
{
|
||||
for(unsigned int i = 0; i < cbNeeded / sizeof(HMODULE); i++)
|
||||
{
|
||||
wchar_t szModuleName[MAX_PATH] = L"";
|
||||
if(GetModuleFileNameExW(fdProcessInfo->hProcess, hMods[i], szModuleName, MAX_PATH))
|
||||
if(GetModuleFileNameExW(fdProcessInfo->hProcess, hMods()[i], szModuleName, MAX_PATH))
|
||||
{
|
||||
wchar_t* szBaseName = wcsrchr(szModuleName, L'\\');
|
||||
if(szBaseName)
|
||||
|
|
@ -1407,7 +1407,7 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
|
|||
if(!_wcsicmp(szBaseName, L"kernel32.dll"))
|
||||
kernel32 = found;
|
||||
uint rva = funcAddress - (uint)hModule;
|
||||
addrfound[found] = (uint)hMods[i] + rva;
|
||||
addrfound()[found] = (uint)hMods()[i] + rva;
|
||||
found++;
|
||||
}
|
||||
FreeLibrary(hModule);
|
||||
|
|
@ -1425,20 +1425,20 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
|
|||
*hexonly = true;
|
||||
if(kernel32 != -1) //prioritize kernel32 exports
|
||||
{
|
||||
*value = addrfound[kernel32];
|
||||
*value = addrfound()[kernel32];
|
||||
if(!printall || silent)
|
||||
return true;
|
||||
for(int i = 0; i < found; i++)
|
||||
if(i != kernel32)
|
||||
dprintf(fhex"\n", addrfound[i]);
|
||||
dprintf(fhex"\n", addrfound()[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = *addrfound;
|
||||
*value = *addrfound();
|
||||
if(!printall || silent)
|
||||
return true;
|
||||
for(int i = 1; i < found; i++)
|
||||
dprintf(fhex"\n", addrfound[i]);
|
||||
dprintf(fhex"\n", addrfound()[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2122,31 +2122,31 @@ bool valtostring(const char* string, uint value, bool silent)
|
|||
for(int i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if(string[i] == ']')
|
||||
j += sprintf(newstring + j, ")");
|
||||
j += sprintf(newstring() + j, ")");
|
||||
else if(isdigit(string[i]) && string[i + 1] == ':' && string[i + 2] == '[') //n:[
|
||||
{
|
||||
j += sprintf(newstring + j, "@%c:(", string[i]);
|
||||
j += sprintf(newstring() + j, "@%c:(", string[i]);
|
||||
i += 2;
|
||||
}
|
||||
else if(string[i] == '[')
|
||||
j += sprintf(newstring + j, "@(");
|
||||
j += sprintf(newstring() + j, "@(");
|
||||
else
|
||||
j += sprintf(newstring + j, "%c", string[i]);
|
||||
j += sprintf(newstring() + j, "%c", string[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
strcpy_s(newstring, len * 2, string);
|
||||
strcpy_s(newstring(), len * 2, string);
|
||||
int read_size = sizeof(uint);
|
||||
int add = 1;
|
||||
if(newstring[2] == ':' && isdigit((newstring[1])))
|
||||
if(newstring()[2] == ':' && isdigit((newstring()[1])))
|
||||
{
|
||||
add += 2;
|
||||
int new_size = newstring[1] - 0x30;
|
||||
int new_size = newstring()[1] - 0x30;
|
||||
if(new_size < read_size)
|
||||
read_size = new_size;
|
||||
}
|
||||
uint temp;
|
||||
if(!valfromstring(newstring + add, &temp, silent, false))
|
||||
if(!valfromstring(newstring() + add, &temp, silent, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2172,11 +2172,11 @@ bool valtostring(const char* string, uint value, bool silent)
|
|||
bool ok = setregister(string, value);
|
||||
int len = (int)strlen(string);
|
||||
Memory<char*> regName(len + 1, "valtostring:regname");
|
||||
strcpy_s(regName, len + 1, string);
|
||||
_strlwr(regName);
|
||||
if(strstr(regName, "ip"))
|
||||
strcpy_s(regName(), len + 1, string);
|
||||
_strlwr(regName());
|
||||
if(strstr(regName(), "ip"))
|
||||
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), false); //update disassembly + register view
|
||||
else if(strstr(regName, "sp")) //update stack
|
||||
else if(strstr(regName(), "sp")) //update stack
|
||||
{
|
||||
uint csp = GetContextDataEx(hActiveThread, UE_CSP);
|
||||
GuiStackDumpAt(csp, csp);
|
||||
|
|
|
|||
Loading…
Reference in New Issue