Skip to content

Commit

Permalink
Fixes for multi-byte build configurations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkhoury committed Feb 26, 2018
1 parent c7b95a0 commit 574e262
Show file tree
Hide file tree
Showing 20 changed files with 327 additions and 296 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ DriverPlugin_dbg.rc-plugin64d
/BIN/plugins-lol/TestPlugin.lib
*.rc-plugin
/BIN/plugins/TestPlugin.lib
*.rc-plugin64
2 changes: 2 additions & 0 deletions ReClass/CClassView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,9 @@ void CClassView::ReplaceSelectedWithType( NodeType Type )
{
std::vector<CNodeBase*> newSelected;

#if defined(_DEBUG)
PrintOut( _T( "Replace Node Type %s" ), NodeTypeToString( Type ) );
#endif

for (size_t i = 0; i < m_Selected.size( ); i++)
{
Expand Down
5 changes: 1 addition & 4 deletions ReClass/CMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ class CMemory {

~CMemory( )
{
if (m_pMemory)
{
if (m_pMemory != NULL)
free( m_pMemory );
m_pMemory = NULL;
}
}

inline void SetSize( unsigned long Size )
Expand Down
11 changes: 6 additions & 5 deletions ReClass/CNodeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CNodeClass::CNodeClass( )

m_RequestPosition = -1;
m_Idx = 0;
m_pChildClassFrame = nullptr;
m_pChildClassFrame = NULL;
}

void CNodeClass::Update( const PHOTSPOT Spot )
Expand Down Expand Up @@ -47,6 +47,7 @@ NODESIZE CNodeClass::Draw( const PVIEWINFO View, int x, int y )
{
NODESIZE DrawSize;
NODESIZE ChildDrawSize;
int tx;

DrawSize.x = 0;
DrawSize.y = 0;
Expand All @@ -55,7 +56,7 @@ NODESIZE CNodeClass::Draw( const PVIEWINFO View, int x, int y )
x = AddOpenClose( View, x, y );

// Save tx here
int tx = x;
tx = x;

x = AddIcon( View, x, y, ICON_CLASS, -1, -1 );
x = AddText( View, x, y, g_crOffset, 0, _T( "%s" ), m_strOffset ) + g_FontWidth;
Expand Down Expand Up @@ -87,21 +88,21 @@ NODESIZE CNodeClass::Draw( const PVIEWINFO View, int x, int y )
CNodeBase* pNode = m_ChildNodes[i];
if (!pNode)
{
PrintOut( _T( "Node %d is NULL in class %s!" ), i, m_strName.GetString( ) );
PrintOutDbg( _T( "Node %d is NULL in class %s!" ), i, m_strName.GetString( ) );
continue;
}

if (pNode->GetType( ) == nt_vtable)
{
CNodeVTable* VTableNode = static_cast<CNodeVTable*>(pNode);
if (!VTableNode->IsInitialized( ) && m_pChildClassFrame != nullptr)
if (!VTableNode->IsInitialized( ) && m_pChildClassFrame != NULL)
VTableNode->Initialize( static_cast<CWnd*>(m_pChildClassFrame->GetChildView( )) );
}

if (pNode->GetType( ) == nt_function)
{
CNodeFunction* FunctionNode = static_cast<CNodeFunction*>(pNode);
if (!FunctionNode->IsInitialized( ) && m_pChildClassFrame != nullptr)
if (!FunctionNode->IsInitialized( ) && m_pChildClassFrame != NULL)
FunctionNode->Initialize( m_pChildClassFrame->GetChildView( ), m_Offset + FunctionNode->GetOffset( ) );
}

Expand Down
6 changes: 1 addition & 5 deletions ReClass/CNodeFunctionPtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ NODESIZE CNodeFunctionPtr::Draw( const PVIEWINFO View, int x, int y )
NODESIZE DrawSize;
int tx, ax;

if (m_bHidden)
if (IsHidden( ))
return DrawHidden( View, x, y );

AddSelection( View, 0, y, g_FontHeight );
Expand Down Expand Up @@ -99,7 +99,6 @@ NODESIZE CNodeFunctionPtr::Draw( const PVIEWINFO View, int x, int y )
tx = AddOpenClose( View, tx, y );

tx += g_FontWidth;

tx = AddComment( View, tx, y );

if (m_LevelsOpen[View->Level])
Expand Down Expand Up @@ -151,9 +150,7 @@ void CNodeFunctionPtr::Initialize( CWnd* pParentWindow, ULONG_PTR Address )
{
m_pAssemblyWindow->Clear( );
m_pAssemblyWindow->ShowWindow( SW_HIDE );

delete m_pAssemblyWindow;
m_pAssemblyWindow = NULL;
}

m_pAssemblyWindow = new CScintillaEdit;
Expand Down Expand Up @@ -304,5 +301,4 @@ void CNodeFunctionPtr::DisassembleBytes( ULONG_PTR Address )

// Force a redraw
m_bRedrawNeeded = TRUE;

}
8 changes: 7 additions & 1 deletion ReClass/CNodeFunctionPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ class CNodeFunctionPtr : public CNodeBase {

inline void HideAssemblyWindow( )
{
if (m_bRedrawNeeded == FALSE)
if (!m_bRedrawNeeded)
{
if (m_pAssemblyWindow != NULL)
m_pAssemblyWindow->ShowWindow( SW_HIDE );
m_bRedrawNeeded = TRUE;
}

//if (m_pAssemblyWindow != NULL)
//{
// m_pAssemblyWindow->ShowWindow( SW_HIDE );
// m_bRedrawNeeded = TRUE;
//}
}

private:
Expand Down
21 changes: 11 additions & 10 deletions ReClass/CNodePtr.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "stdafx.h"
#include "CNodePtr.h"

CNodePtr::CNodePtr( ) : m_pNode( NULL )
CNodePtr::CNodePtr( )
: m_pClassNode( NULL )
{
m_nodeType = nt_pointer;
}
Expand All @@ -15,12 +16,13 @@ NODESIZE CNodePtr::Draw( const PVIEWINFO View, int x, int y )
{
NODESIZE DrawSize;
NODESIZE ChildDrawSize;
uintptr_t* Data;
ULONG_PTR* Data;
int tx;

if (m_bHidden)
return DrawHidden( View, x, y );

Data = (uintptr_t*)(View->Data + m_Offset);
Data = (ULONG_PTR*)(View->Data + m_Offset);

//printf( "read ptr: %p\n", View->Data );
AddSelection( View, 0, y, g_FontHeight );
Expand All @@ -30,21 +32,21 @@ NODESIZE CNodePtr::Draw( const PVIEWINFO View, int x, int y )
x = AddOpenClose( View, x, y );
x = AddIcon( View, x, y, ICON_POINTER, -1, -1 );

int tx = x;
tx = AddAddressOffset( View, tx, y );
tx = AddAddressOffset( View, x, y );
tx = AddText( View, tx, y, g_crType, HS_NONE, _T( "Ptr " ) );
tx = AddText( View, tx, y, g_crName, HS_NAME, _T( "%s" ), m_strName );
tx = AddText( View, tx, y, g_crValue, HS_NONE, _T( " <%s>" ), m_pNode->GetName( ) );
tx = AddText( View, tx, y, g_crValue, HS_NONE, _T( " <%s>" ), m_pClassNode->GetName( ) );
tx = AddIcon( View, tx, y, ICON_CHANGE, HS_CLICK, HS_CHANGE_A );

tx += g_FontWidth;
tx = AddComment( View, tx, y );

y += g_FontHeight;
DrawSize.x = tx;

if (m_LevelsOpen[View->Level])
{
DWORD NeededSize = m_pNode->GetMemorySize( );
DWORD NeededSize = m_pClassNode->GetMemorySize( );
m_Memory.SetSize( NeededSize );

VIEWINFO NewView;
Expand All @@ -54,12 +56,11 @@ NODESIZE CNodePtr::Draw( const PVIEWINFO View, int x, int y )

ReClassReadMemory( (LPVOID)NewView.Address, (LPVOID)NewView.Data, NeededSize );

ChildDrawSize = m_pNode->Draw( &NewView, x, y );
ChildDrawSize = m_pClassNode->Draw( &NewView, x, y );

y = ChildDrawSize.y;
if (ChildDrawSize.x > DrawSize.x)
{
DrawSize.x = ChildDrawSize.x;
}
}

DrawSize.y = y;
Expand Down
6 changes: 3 additions & 3 deletions ReClass/CNodePtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class CNodePtr : public CNodeBase {

virtual NODESIZE Draw( const PVIEWINFO View, int x, int y );

inline void SetClass( CNodeClass* pNode ) { m_pNode = pNode; }
inline CNodeClass* GetClass( void ) { return m_pNode; }
inline void SetClass( CNodeClass* pClassNode ) { m_pClassNode = pClassNode; }
inline CNodeClass* GetClass( void ) { return m_pClassNode; }

inline CMemory* Memory( ) { return &m_Memory; }

private:
CNodeClass* m_pNode;
CNodeClass* m_pClassNode;
CMemory m_Memory;
};
6 changes: 4 additions & 2 deletions ReClass/CNodeVTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ NODESIZE CNodeVTable::Draw( const PVIEWINFO View, int x, int y )

ReClassReadMemory( (LPVOID)NewView.Address, NewView.Data, NeededSize );

for (UINT i = 0; i < m_ChildNodes.size( ); i++)
for (size_t i = 0; i < m_ChildNodes.size( ); i++)
{
CNodeFunctionPtr* FunctionPtrNode = static_cast<CNodeFunctionPtr*>(m_ChildNodes[i]);

Expand All @@ -86,8 +86,10 @@ NODESIZE CNodeVTable::Draw( const PVIEWINFO View, int x, int y )
}
else
{
for (UINT i = 0; i < m_ChildNodes.size( ); i++)
for (size_t i = 0; i < m_ChildNodes.size( ); i++)
{
static_cast<CNodeFunctionPtr*>(m_ChildNodes[i])->HideAssemblyWindow( );
}
}

return DrawSize;
Expand Down
10 changes: 4 additions & 6 deletions ReClass/CScintillaEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,9 @@ void CScintillaEdit::AddText( CString text, ULONG length )
else
{
#ifdef UNICODE
ULONG textLength = text.GetLength( );
SendEditor( SCI_ADDTEXT, (WPARAM)textLength, (LPARAM)CW2A( text.GetBuffer( ) ).m_psz );
SendEditor( SCI_ADDTEXT, (WPARAM)text.GetLength( ), (LPARAM)CW2A( text.GetBuffer( ) ).m_psz );
#else
SendEditor( SCI_ADDTEXT, (WPARAM)textLength, (LPARAM)text.GetBuffer( ) );
SendEditor( SCI_ADDTEXT, (WPARAM)text.GetLength( ), (LPARAM)text.GetBuffer( ) );
#endif
}
}
Expand All @@ -782,10 +781,9 @@ void CScintillaEdit::AppendText( CString text, ULONG length )
else
{
#ifdef UNICODE
ULONG textLength = text.GetLength( );
SendEditor( SCI_APPENDTEXT, (WPARAM)textLength, (LPARAM)CW2A( text.GetBuffer( ) ).m_psz );
SendEditor( SCI_APPENDTEXT, (WPARAM)text.GetLength( ), (LPARAM)CW2A( text.GetBuffer( ) ).m_psz );
#else
SendEditor( SCI_APPENDTEXT, (WPARAM)textLength, (LPARAM)text.GetBuffer( ) );
SendEditor( SCI_APPENDTEXT, (WPARAM)text.GetLength( ), (LPARAM)text.GetBuffer( ) );
#endif
}
}
Expand Down
29 changes: 17 additions & 12 deletions ReClass/DialogPlugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,47 +77,52 @@ void CDialogPlugins::OnPopupMenuSettings( )
}

void CDialogPlugins::OnPopupMenuAbout( )
{
CStringW Title;
PRECLASS_PLUGIN Plugin = GetSelectedPlugin( );
{
PRECLASS_PLUGIN Plugin = GetSelectedPlugin( );

//TODO: make cool about dialog maybe??

Title.Format( L"%s - About", Plugin->Info.Name );
MessageBoxW( Plugin->Info.About, Title, MB_OK | MB_ICONINFORMATION );
CStringW Title( Plugin->Info.Name );
Title.Append( L" - About" );
::MessageBoxW( GetSafeHwnd( ), Plugin->Info.About, Title, MB_OK | MB_ICONINFORMATION );
}

void CDialogPlugins::OnPopupMenuChangeState( )
{
PRECLASS_PLUGIN Plugin = GetSelectedPlugin( );

Plugin->StateChangeFunction( Plugin->State = !Plugin->State );
Plugin->State = !Plugin->State;
Plugin->StateChangeFunction( Plugin->State );

#ifdef UNICODE
#ifdef _UNICODE
g_ReClassApp.WriteProfileInt( L"PluginState", Plugin->Info.Name, Plugin->State ? 1 : 0 );
#else
g_ReClassApp.WriteProfileInt( "PluginState", CW2A( Plugin.Info.Name ), Plugin.State ? 1 : 0 );
g_ReClassApp.WriteProfileInt( "PluginState", CW2A( Plugin->Info.Name ), Plugin->State ? 1 : 0 );
#endif

RefreshPlugins( );
}

VOID CDialogPlugins::RefreshPlugins( )
{
LVITEM Item;
LVITEMW Item;

m_PluginsList.DeleteAllItems( );

for (PRECLASS_PLUGIN Plugin : g_LoadedPlugins)
{
ZeroMemory( &Item, sizeof( LVITEM ) );

ZeroMemory( &Item, sizeof( LVITEMW ) );
Item.mask = LVIF_TEXT;
Item.pszText = Plugin->Info.Name;
Item.cchTextMax = (int)wcslen( Plugin->Info.Name ) + 1;
Item.iItem = m_PluginsList.GetItemCount( );

int PosIdx = m_PluginsList.InsertItem( &Item );
int PosIdx = m_PluginsList.InsertItem( (LVITEM*)&Item );
#ifdef _UNICODE
m_PluginsList.SetItemText( PosIdx, 1, Plugin->Info.Version );
#else
m_PluginsList.SetItemText( PosIdx, 1, CW2A( Plugin->Info.Version ) );
#endif
m_PluginsList.SetItemText( PosIdx, 2, Plugin->State ? _T( "Enabled" ) : _T( "Disabled" ) );
}
}
2 changes: 1 addition & 1 deletion ReClass/DialogProcSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void CDialogProcSelect::ListRunningProcs( )
#ifdef UNICODE
Info.strProcessName = ProcessInfo->ImageName.Buffer;
#else
Info.strProcessName = CW2A( proc_info->ImageName.Buffer );
Info.strProcessName = CW2A( ProcessInfo->ImageName.Buffer );
#endif

GetModuleFileNameEx( hProcess, NULL, tcsProcessPath, MAX_PATH );
Expand Down
Loading

0 comments on commit 574e262

Please sign in to comment.