This commit is contained in:
Nukem 2015-04-06 21:15:54 -04:00
commit 7e7f475995
9 changed files with 170 additions and 117 deletions

View File

@ -65,6 +65,7 @@ void ExceptionCodeInit()
ExceptionNames.insert(std::make_pair(0xC00002C9, "STATUS_REG_NAT_CONSUMPTION"));
ExceptionNames.insert(std::make_pair(0xC0000409, "STATUS_STACK_BUFFER_OVERRUN"));
ExceptionNames.insert(std::make_pair(0xC0000417, "STATUS_INVALID_CRUNTIME_PARAMETER"));
ExceptionNames.insert(std::make_pair(0xC000041D, "STATUS_USER_CALLBACK"));
ExceptionNames.insert(std::make_pair(0xC0000420, "STATUS_ASSERTION_FAILURE"));
ExceptionNames.insert(std::make_pair(0xE0434352, "CLR_EXCEPTION"));
ExceptionNames.insert(std::make_pair(0xE06D7363, "CPP_EH_EXCEPTION"));

View File

@ -17,15 +17,20 @@ bool ModLoad(uint Base, uint Size, const char* FullPath)
MODINFO info;
// Copy the module path in the struct
strcpy_s(info.path, FullPath);
// Break the module path into a directory and file name
char dir[deflen];
char* file;
if(GetFullPathNameA(FullPath, ARRAYSIZE(dir), dir, &file) == 0)
return false;
// Make everything lowercase
char dir[MAX_PATH] = "";
char file[MAX_MODULE_SIZE] = "";
strcpy_s(dir, FullPath);
_strlwr(dir);
char* fileStart = strrchr(dir, '\\');
if(fileStart)
{
strcpy_s(file, fileStart + 1);
*fileStart = '\0';
}
// Copy the extension into the module struct
{

View File

@ -1,55 +1,89 @@
/**
@file msgqueue.cpp
@brief Implements the msgqueue class.
*/
#include "msgqueue.h"
#include <stdio.h>
// Allocate a message stack
//allocate a message (internal)
static MESSAGE* msgalloc()
{
return (MESSAGE*)emalloc(sizeof(MESSAGE), "msgalloc:msg");
}
//free a message (internal)
static void msgfree(MESSAGE* msg)
{
efree(msg, "msgfree:msg");
}
//allocate a message stack
MESSAGE_STACK* MsgAllocStack()
{
// Allocate memory for the structure
PVOID memoryBuffer = emalloc(sizeof(MESSAGE_STACK), "MsgAllocStack:memoryBuffer");
if(!memoryBuffer)
return nullptr;
// Use placement new to ensure all constructors are called correctly
return new(memoryBuffer) MESSAGE_STACK;
MESSAGE_STACK* msgstack = (MESSAGE_STACK*)emalloc(sizeof(MESSAGE_STACK), "msgallocstack:msgstack");
if(!msgstack)
return 0;
memset(msgstack, 0, sizeof(MESSAGE_STACK));
InitializeCriticalSection(&msgstack->cr);
return msgstack;
}
// Free a message stack and all messages in the queue
void MsgFreeStack(MESSAGE_STACK* Stack)
//free a message stack
void MsgFreeStack(MESSAGE_STACK* msgstack)
{
// Destructor must be called manually due to placement new
Stack->FIFOStack.~unbounded_buffer();
// Free memory
efree(Stack, "MsgFreeStack:Stack");
DeleteCriticalSection(&msgstack->cr);
int stackpos = msgstack->stackpos;
for(int i = 0; i < stackpos; i++) //free all messages left in stack
msgfree(msgstack->msg[i]);
efree(msgstack, "msgfreestack:msgstack");
}
// Add a message to the stack
bool MsgSend(MESSAGE_STACK* Stack, int Msg, uint Param1, uint Param2)
//add a message to the stack
bool MsgSend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2)
{
MESSAGE messageInfo;
messageInfo.msg = Msg;
messageInfo.param1 = Param1;
messageInfo.param2 = Param2;
// Asynchronous send. Return value doesn't matter.
concurrency::asend(Stack->FIFOStack, messageInfo);
CRITICAL_SECTION* cr = &msgstack->cr;
EnterCriticalSection(cr);
int stackpos = msgstack->stackpos;
if(stackpos >= MAX_MESSAGES)
{
LeaveCriticalSection(cr);
return false;
}
MESSAGE* newmsg = msgalloc();
if(!newmsg)
{
LeaveCriticalSection(cr);
return false;
}
newmsg->msg = msg;
newmsg->param1 = param1;
newmsg->param2 = param2;
msgstack->msg[stackpos] = newmsg;
msgstack->stackpos++; //increase stack pointer
LeaveCriticalSection(cr);
return true;
}
// Get a message from the stack (will return false when there are no messages)
bool MsgGet(MESSAGE_STACK* Stack, MESSAGE* Message)
//get a message from the stack (will return false when there are no messages)
bool MsgGet(MESSAGE_STACK* msgstack, MESSAGE* msg)
{
return concurrency::try_receive(Stack->FIFOStack, *Message);
CRITICAL_SECTION* cr = &msgstack->cr;
EnterCriticalSection(cr);
int stackpos = msgstack->stackpos;
if(!msgstack->stackpos) //no messages to process
{
LeaveCriticalSection(cr);
return false;
}
msgstack->stackpos--; //current message is at stackpos-1
stackpos--;
MESSAGE* stackmsg = msgstack->msg[stackpos];
memcpy(msg, stackmsg, sizeof(MESSAGE));
msgfree(stackmsg);
msgstack->msg[stackpos] = 0;
LeaveCriticalSection(cr);
return true;
}
// Wait for a message on the specified stack
void MsgWait(MESSAGE_STACK* Stack, MESSAGE* Message)
//wait for a message on the specified stack
void MsgWait(MESSAGE_STACK* msgstack, MESSAGE* msg)
{
*Message = concurrency::receive(Stack->FIFOStack);
while(!MsgGet(msgstack, msg))
Sleep(1);
}

View File

@ -3,9 +3,10 @@
#include "_global.h"
#include <windows.h>
#include <agents.h>
// Message structure
#define MAX_MESSAGES 256
//message structure
struct MESSAGE
{
int msg;
@ -13,17 +14,19 @@ struct MESSAGE
uint param2;
};
// Message stack structure.
// Supports an unlimited number of messages.
//message stack structure
struct MESSAGE_STACK
{
concurrency::unbounded_buffer<MESSAGE> FIFOStack;
CRITICAL_SECTION cr;
int stackpos;
MESSAGE* msg[MAX_MESSAGES];
};
//function definitions
MESSAGE_STACK* MsgAllocStack();
void MsgFreeStack(MESSAGE_STACK* Stack);
bool MsgSend(MESSAGE_STACK* Stack, int Msg, uint Param1, uint Param2);
bool MsgGet(MESSAGE_STACK* Stack, MESSAGE* Message);
void MsgWait(MESSAGE_STACK* Stack, MESSAGE* Message);
void MsgFreeStack(MESSAGE_STACK* msgstack);
bool MsgSend(MESSAGE_STACK* msgstack, int msg, uint param1, uint param2);
bool MsgGet(MESSAGE_STACK* msgstack, MESSAGE* msg);
void MsgWait(MESSAGE_STACK* msgstack, MESSAGE* msg);
#endif // _MSGQUEUE_H

View File

@ -27,6 +27,7 @@ AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(pare
mGuiState = AbstractTableView::NoState;
mShouldReload = true;
mAllowPainting = true;
// ScrollBar Init
setVerticalScrollBar(new AbstractTableScrollBar(verticalScrollBar()));
@ -79,6 +80,8 @@ void AbstractTableView::fontsUpdated()
*/
void AbstractTableView::paintEvent(QPaintEvent* event)
{
if(!mAllowPainting)
return;
if(getColumnCount()) //make sure the last column is never smaller than the window
{
int totalWidth = 0;

View File

@ -187,6 +187,7 @@ protected:
QColor separatorColor;
QColor headerTextColor;
QColor selectionColor;
bool mAllowPainting;
};
#endif // ABSTRACTTABLEVIEW_H

View File

@ -975,6 +975,7 @@ void HexDump::appendDescriptor(int width, QString title, bool clickable, ColumnD
//Clears the descriptors, append a new descriptor and fix the tableOffset (use this instead of clearDescriptors()
void HexDump::appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor)
{
mAllowPainting = false;
if(mDescriptor.size())
{
int_t wRVA = getTableOffset() * getBytePerRowCount() - mByteOffset;
@ -984,6 +985,7 @@ void HexDump::appendResetDescriptor(int width, QString title, bool clickable, Co
}
else
appendDescriptor(width, title, clickable, descriptor);
mAllowPainting = true;
}
void HexDump::clearDescriptors()

View File

@ -2229,7 +2229,7 @@ SIZE_T RegistersView::GetSizeRegister(const REGISTER_NAME reg_name)
else if(mFPUYMM.contains(reg_name))
size = 32;
else if(reg_name == LastError)
return sizeof(LASTERROR);
return sizeof(DWORD);
else
size = 0;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>250</height>
<width>383</width>
<height>307</height>
</rect>
</property>
<property name="sizePolicy">
@ -33,7 +33,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabEvents">
<attribute name="title">
@ -154,83 +154,87 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="lblCalculationType">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Calculation Type:</string>
<property name="title">
<string>Calculation Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="layoutCalulationType">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QRadioButton" name="radioSigned">
<property name="text">
<string>&amp;Signed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioUnsigned">
<property name="text">
<string>&amp;Unsigned</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layoutCalulationType">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QRadioButton" name="radioSigned">
<property name="text">
<string>&amp;Signed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioUnsigned">
<property name="text">
<string>&amp;Unsigned</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lblBreakpointType">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Default Breakpoint Type:</string>
<property name="title">
<string>Default Breakpoint Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="layoutBreakpointType">
<item>
<widget class="QRadioButton" name="radioInt3Short">
<property name="text">
<string>INT3</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioInt3Long">
<property name="text">
<string>Long INT3</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioUd2">
<property name="text">
<string>UD2</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layoutBreakpointType">
<item>
<widget class="QRadioButton" name="radioInt3Short">
<property name="text">
<string>INT3</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioInt3Long">
<property name="text">
<string>Long INT3</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioUd2">
<property name="text">
<string>UD2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="chkUndecorateSymbolNames">
<property name="text">