<|start_filename|>LPMS Tutorial/main.cpp<|end_filename|>
#include <Windows.h>
#include <Windowsx.h>
#include <sstream>

using namespace std;

#include "resource.h"

// Global Variables
HINSTANCE hInst;

HWND hWndOne, 
	 hWndTwo, 
	 hWndThree;

// Step 1
DWORD Ammo;

// Step 2
float XPos = 2000;
float YPos = 2000;

// Step 3
DWORD *Health;
void  *pHealth = &Health;

// Extra Functions
template <class T> string ToString ( T VALUE )
{
	stringstream ss;
	ss << VALUE;
	return ss.str ();
}
//

// Callback
INT_PTR CALLBACK StepOne   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK StepTwo   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK StepThree ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );

// Threads
VOID ThreadOne ()
{
	while ( true )
	{
		if ( Ammo == 1000 )
		{
			// Enable the button
			Button_Enable ( GetDlgItem ( hWndOne, IDC_BUTTON2 ), TRUE );

			// Close the thread
			DWORD dwExitCode;
			GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
			TerminateThread   ( GetCurrentThread (), dwExitCode );
		}

		Sleep ( 100 );
	}
}

VOID LaunchTwo ()
{
	DialogBoxA ( hInst, MAKEINTRESOURCE ( IDD_DIALOG2 ), NULL, StepTwo );

	// Close the thread
	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode );
}
VOID ThreadTwo ()
{
	while ( true )
	{
		if ( XPos == 5000 )
			SetWindowText ( GetDlgItem ( hWndTwo, X_POS ), "Good job!" );
		if ( YPos == 5000 )
			SetWindowText ( GetDlgItem ( hWndTwo, Y_POS ), "Good job!" );

		if ( XPos == 5000 &&
			 YPos == 5000 )
		{
			// Enable the button
			Button_Enable ( GetDlgItem ( hWndTwo, IDC_BUTTON2 ), TRUE );

			// Close the thread
			DWORD dwExitCode;
			GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
			TerminateThread   ( GetCurrentThread (), dwExitCode );
		}

		Sleep ( 100 );
	}
}

VOID LaunchThree ()
{
	DialogBoxA ( hInst, MAKEINTRESOURCE ( IDD_DIALOG3 ), NULL, StepThree );

	// Close the thread
	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode );
}
//

// Callback Procedures
INT_PTR CALLBACK StepOne   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	hWndOne = hWndDlg;

	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			Ammo = 30;

			// Create the thread
			CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) ThreadOne, NULL, NULL, NULL );

			// Set window titles
			SetWindowText ( GetDlgItem ( hWndDlg, IDC_AMMO ), "30" );

			return TRUE;
		}

	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					DWORD randomNum = rand () % 5 + 1;

					// Decrease the Ammo
					Ammo -= randomNum;

					if ( randomNum > Ammo )
					{
						MessageBoxA ( hWndDlg, "Reloading...", "You ran out!", MB_ICONINFORMATION );
						Ammo = 30;
					}

					// Display the new Ammo
					stringstream ss;
					ss << Ammo;

					string ammoStr;
					ammoStr += ss.str ();

					// Set Title
					SetWindowText ( GetDlgItem ( hWndDlg, IDC_AMMO ), ammoStr.c_str () );
				}
				break;

			case IDC_BUTTON2:
				{
					// Create the thread
					CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) LaunchTwo, NULL, NULL, NULL );

					// Close the window
					ShowWindow ( hWndDlg, SW_HIDE );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK StepTwo   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	hWndTwo = hWndDlg;

	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) ThreadTwo, NULL, NULL, NULL );

			// Set Window Text
			SetWindowText ( GetDlgItem ( hWndDlg, X_POS ), "2000.00" );
			SetWindowText ( GetDlgItem ( hWndDlg, Y_POS ), "2000.00" );

			return TRUE;
		}

	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					int decreasedX = rand () % 10 + 1;
					int decreasedY = rand () % 10 + 1;

					// Create the text
					string Orig = "Decreased by ";

					string XStr = Orig;
					XStr += ToString <int> ( decreasedX );

					string YStr = Orig;
					YStr += ToString <int> ( decreasedY );					
					
					// Set the text
					if ( XPos != 5000 )
						SetWindowText ( GetDlgItem ( hWndDlg, X_POS ), XStr.c_str () );
					if ( YPos != 5000 )
						SetWindowText ( GetDlgItem ( hWndDlg, Y_POS ), YStr.c_str () );

					if ( XPos != 5000 )
						XPos -= decreasedX;
					if ( YPos != 5000 )
						YPos -= decreasedY;

					if ( XPos < decreasedX )
						XPos = 2000;
					if ( YPos < decreasedY )
						YPos = 2000;
				}
				break;

			case IDC_BUTTON2:
				{
					// Create
					CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) LaunchThree, NULL, NULL, NULL );

					// Close
					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			EndDialog ( hWndOne, 0 );

			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK StepThree ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	hWndThree = hWndDlg;

	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			// Set variables
			Health  = new DWORD;
			*Health = 1000;

			return TRUE;
		}

	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					DWORD randNum = rand () % 50 + 1;

					// Subtract
					*(DWORD*) ( *(DWORD*) pHealth ) -= randNum;

					if ( *Health < randNum )
						*Health = 1000;

					SetWindowText ( GetDlgItem ( hWndDlg, IDC_HEALTH ), ToString <DWORD> ( *Health ).c_str () );
				}
				break;

			case IDC_BUTTON2:
				{
					// Change health
					Health  = new DWORD;
					*Health = 1000;

					int second = 3;
					ShowWindow ( GetDlgItem ( hWndDlg, IDC_SEC ), SW_SHOW );

					while ( second != 0 )
					{
						string str = "You have ";
						str += ToString ( second );
						str += " seconds left.";

						SetWindowText ( GetDlgItem ( hWndDlg, IDC_SEC ), str.c_str () );

						-- second;
						Sleep ( 1000 );
					}

					ShowWindow ( GetDlgItem ( hWndDlg, IDC_SEC ), SW_HIDE );

					if ( *Health == 5000 )
						Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON3 ), TRUE );
				}
				break;

			case IDC_BUTTON3:
				{
					MessageBoxA ( hWndDlg, "Congragulations\n  Looks like you're ready.", "LPMS Tutorial", MB_ICONINFORMATION );

					EndDialog ( hWndDlg, 0 );
					EndDialog ( hWndOne, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			EndDialog ( hWndOne, 0 );

			return TRUE;
		}

	default:
		return FALSE;
	}
}

//

// Main Entrypoint
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
	hInst = hInstance;

	DialogBoxA ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG1 ), NULL, StepOne );

	return 0;
}
//

<|start_filename|>Memory Engine/hopper.h<|end_filename|>
#include <Windows.h>
#include <sstream>

using namespace std;

void la ( LPVOID lpAddr )
{
	stringstream ss;
	ss << lpAddr;

	string str;
	str += ss.str ();

	MessageBoxA ( 0, str.c_str (), 0, 0 );
}

//

// SendMessageA
LRESULT WINAPI SMX (
  __in  HWND hWnd,
  __in  UINT Msg,
  __in  WPARAM wParam,
  __in  LPARAM lParam
  )
{
	return SendMessageA ( hWnd, Msg, wParam, lParam );
	/*
	DWORD dwSend = (DWORD) GetProcAddress ( GetModuleHandle ( "user32.dll" ), "SendMessageA" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwSend]
	}*/
}

// VirtualQuery
SIZE_T WINAPI VQ (
  __in_opt  LPCVOID lpAddress,
  __out     PMEMORY_BASIC_INFORMATION lpBuffer,
  __in      SIZE_T dwLength
  )
{
	return VirtualQuery ( lpAddress, lpBuffer, dwLength );
	/*
	DWORD dwQuery = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "VirtualQuery" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwQuery]
	}
	*/
}
// Module32First
BOOL WINAPI M32F (
  __in     HANDLE hSnapshot,
  __inout  LPMODULEENTRY32 lpme
)
{
	return Module32First ( hSnapshot, lpme );

	/*
	DWORD dwM32F = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "Module32First" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwM32F]
	}
	*/
}
// Module32Next
BOOL WINAPI M32N (
  __in   HANDLE hSnapshot,
  __out  LPMODULEENTRY32 lpme
)
{
	return Module32Next ( hSnapshot, lpme );

	/*
	DWORD dwM32N = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "Module32Next" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwM32N]
	}
	*/
}
// DialogBoxA
INT_PTR WINAPI DB (
  __in_opt  HINSTANCE hInstance,
  __in      LPCTSTR lpTemplate,
  __in_opt  HWND hWndParent,
  __in_opt  DLGPROC lpDialogFunc
)
{
	return DialogBox ( hInstance, lpTemplate, hWndParent, lpDialogFunc );
}
// GetAsyncKeyState 
SHORT WINAPI GKEY (
  __in  int vKey
)
{
	return GetKeyState ( vKey );
	/*
	DWORD dwKey = (DWORD) GetProcAddress ( GetModuleHandle ( "user32.dll" ), "GetAsyncKeyState" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwKey]
	}
	*/
}
// GetThreadContext
BOOL WINAPI GetContext(
  __in     HANDLE hThread,
  __inout  LPCONTEXT lpContext
)
{
	return GetThreadContext ( hThread, lpContext );
	/*
	DWORD dwHopTo = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "GetThreadContext" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwHopTo]
	}
	*/
}
// SetThreadContext
BOOL WINAPI SetContext(
  __in  HANDLE hThread,
  __in  const CONTEXT *lpContext
)
{
	return SetThreadContext ( hThread, lpContext );

	/*
	DWORD dwHopTo = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "SetThreadContext" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwHopTo]
	}
	*/
}
// WriteFile
BOOL WINAPI WriteFil (
  __in         HANDLE hFile,
  __in         LPCVOID lpBuffer,
  __in         DWORD nNumberOfBytesToWrite,
  __out_opt    LPDWORD lpNumberOfBytesWritten,
  __inout_opt  LPOVERLAPPED lpOverlapped
)
{
	return WriteFile ( hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped );
	/*
	DWORD dwHopTo = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "WriteFile" ) + 5;

	__asm {
		mov edi, edi
		push ebp
		mov esp, ebp
		jmp [dwHopTo]
	}
	*/
}

<|start_filename|>iScan/MainCode.cpp<|end_filename|>
#include <Windows.h>
#include <TlHelp32.h>
#include <Commctrl.h>
#include <sstream>
#include <Windowsx.h>
#include <fstream>

#include "resource.h"

using namespace std;

#pragma comment ( lib, "Urlmon.lib" )

// Global Variables
HWND      updateDlg = NULL;
HWND      mainDlg	= NULL;
HINSTANCE hInstance = NULL;
HANDLE    hInject   = NULL;
HANDLE    hTitle    = NULL;
HANDLE    hMerge    = NULL;

string Target   = "";
string Username = "";
string Version  = "0.91";
string OnlineVers = "";
string FileName = "";
string DownloadTo = "";

char szDirectory [256] = {0};

bool downloadMerger = false;
bool downloadUpdate = false;
bool downloadTutorial = false;
bool downloadFinished = false;

/*
	0 - regular
	1 - driver
*/

int injectionMethod   = 0;

//
class DownloadSoftware : public IBindStatusCallback { 
public: 
    HRESULT __stdcall QueryInterface(const IID &,void **) {  
        return E_NOINTERFACE; 
    } 
    ULONG STDMETHODCALLTYPE AddRef(void) {  
        return 1; 
    } 
    ULONG STDMETHODCALLTYPE Release(void) { 
        return 1; 
    } 
    HRESULT STDMETHODCALLTYPE OnStartBinding(DWORD dwReserved, IBinding *pib) { 
        return E_NOTIMPL; 
    } 
    virtual HRESULT STDMETHODCALLTYPE GetPriority(LONG *pnPriority) { 
        return E_NOTIMPL; 
    } 
    virtual HRESULT STDMETHODCALLTYPE OnLowResource(DWORD reserved) { 
        return S_OK; 
    } 
    virtual HRESULT STDMETHODCALLTYPE OnStopBinding(HRESULT hresult, LPCWSTR szError) { 
        return E_NOTIMPL; 
    } 
    virtual HRESULT STDMETHODCALLTYPE GetBindInfo(DWORD *grfBINDF, BINDINFO *pbindinfo) { 
        return E_NOTIMPL; 
    } 
    virtual HRESULT STDMETHODCALLTYPE OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed) { 
        return E_NOTIMPL; 
    }         
    virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(REFIID riid, IUnknown *punk) { 
        return E_NOTIMPL; 
    } 
 
    virtual HRESULT __stdcall OnProgress (ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText) 
    { 
		downloadFinished = false;

		string Download = "Progress ";		
		stringstream ss;
		ss << ( ulProgress / 1024 );
		Download += ss.str ();
		Download += "\\";
		stringstream ss2;
		ss2 << ( ulProgressMax / 1024 );
		Download += ss2.str ();
		Download += " kB";

		SetWindowText ( GetDlgItem ( updateDlg, IDC_DOWNLOAD ), Download.c_str () );

		if ( ulProgress == ulProgressMax )
			downloadFinished = true;

        return S_OK; 
    } 
};
//

//
void decipherAlgorithm ( string text, string* hWid, string* Username )
{
	int beginAt = 0;

	for ( SIZE_T i = 0; i < text.length (); i ++ )
	{
		char character  = (char) text.at ( i );
		char deciphered = (char) ( (int) character + 15 );

		if ( deciphered == '}' )
			beginAt = i;
	}

	for ( int i = 0; i <= beginAt; i ++ )
		*hWid += (char) ( text.at ( i ) + 15 );

	for ( SIZE_T i = beginAt + 1; i < text.length (); i ++ )
		*Username += (char) ( text.at ( i ) + 15 );
}
//

//
INT_PTR CALLBACK DialogProc ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK UpdateProc ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK LoadingProc ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
//

// Update function
VOID DownloadIt ()
{
	string Site = "http://easygamez.ca/LPMS/";
	Site += FileName;

	DownloadSoftware progress; 
	IBindStatusCallback* callback = (IBindStatusCallback*)&progress; 
	URLDownloadToFile ( NULL, Site.c_str (), DownloadTo.c_str (), 0, callback); 

	ShellExecute ( NULL, "open", "Other.bat", NULL, szDirectory, SW_HIDE );

	if ( !downloadMerger && !downloadTutorial )
		ShellExecute ( NULL, "open", "Install.bat", NULL, szDirectory, SW_HIDE );

	// Close
	EndDialog ( updateDlg, 0 );
}
//

//
void StartUpdate ()
{
	// Latest Update
	DownloadTo = szDirectory;
	DownloadTo += "\\LPMS2.txt";

	ofstream File ( DownloadTo.c_str () );
	File.clear ();
	File.close ();

	// Download
	FileName = "LPMS.txt";

	CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) DownloadIt, NULL, NULL, NULL );

	string RemoveFinal = "DEL ";
	RemoveFinal += 0x22;
	RemoveFinal += szDirectory;
	RemoveFinal += "\\LPMS.exe";
	RemoveFinal += 0x22;		

	string BatchFile = "DEL ";
	BatchFile += 0x22;
	BatchFile += szDirectory;
	BatchFile += "\\Install.bat";
	BatchFile += 0x22;

	string FinalDir = szDirectory;
	FinalDir += "\\Install.bat";

	string Closer = "taskkill ";
	Closer += 0x2F;
	Closer += "f";
	Closer += " ";
	Closer += 0x2F;
	Closer += "im";
	Closer += " ";
	Closer += "LPMS.exe";

	string Merger = "Start ";
	Merger += 0x22;
	Merger += 0x22;
	Merger += " ";
	Merger += 0x22;
	Merger += szDirectory;
	Merger += "\\LPMS.exe";
	Merger += 0x22;

	// Setup batch file
	ofstream Batch ( FinalDir.c_str () );
	Batch.clear ();			
	Batch << Closer.c_str () << endl;
	Batch << RemoveFinal.c_str () << endl;
	Batch << "CD " << szDirectory << endl;
	Batch << "REN LPMS2.txt LPMS.exe" << endl;
	Batch << Merger.c_str () << endl;
	Batch << BatchFile.c_str () << endl;
	Batch.close ();	
}
int  StartMerge ()
{	
	// Obtain
	DownloadTo = szDirectory;
	DownloadTo += "\\Merge.txt";

	// Create
	ofstream File ( DownloadTo.c_str () );
	File.clear ();
	File.close ();

	// Download
	FileName = "Merge.txt";

	CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) DownloadIt, NULL, NULL, NULL );

	string RemoveFinal = "DEL ";
	RemoveFinal += 0x22;
	RemoveFinal += szDirectory;
	RemoveFinal += "\\Merge.exe";
	RemoveFinal += 0x22;		

	string BatchFile = "DEL ";
	BatchFile += 0x22;
	BatchFile += szDirectory;
	BatchFile += "\\Other.bat";
	BatchFile += 0x22;

	string FinalDir = szDirectory;
	FinalDir += "\\Other.bat";

	ofstream Batch ( FinalDir.c_str () );
	Batch.clear ();			
	Batch << RemoveFinal.c_str () << endl;
	Batch << "CD " << szDirectory << endl;
	Batch << "REN Merge.txt Merge.exe" << endl;
	Batch << BatchFile.c_str () << endl;
	Batch.close ();	

	return 0;
}
int  StartTutorial ()
{
	// Obtain
	DownloadTo = szDirectory;
	DownloadTo += "\\Tutorial.txt";

	// Create
	ofstream File ( DownloadTo.c_str () );
	File.clear ();
	File.close ();

	// Download
	FileName = "Tutorial.txt";

	CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) DownloadIt, NULL, NULL, NULL );

	string RemoveFinal = "DEL ";
	RemoveFinal += 0x22;
	RemoveFinal += szDirectory;
	RemoveFinal += "\\Tutorial.exe";
	RemoveFinal += 0x22;		

	string BatchFile = "DEL ";
	BatchFile += 0x22;
	BatchFile += szDirectory;
	BatchFile += "\\Other.bat";
	BatchFile += 0x22;

	string FinalDir = szDirectory;
	FinalDir += "\\Other.bat";

	string Merger = "Start ";
	Merger += 0x22;
	Merger += 0x22;
	Merger += " ";
	Merger += 0x22;
	Merger += szDirectory;
	Merger += "\\Tutorial.exe";
	Merger += 0x22;

	ofstream Batch ( FinalDir.c_str () );
	Batch.clear ();			
	Batch << RemoveFinal.c_str () << endl;
	Batch << "CD " << szDirectory << endl;
	Batch << "REN Tutorial.txt Tutorial.exe" << endl;
	Batch << Merger << endl;
	Batch << BatchFile.c_str () << endl;
	Batch.close ();	

	return 0;
}
//

//
template <class T> string ToString ( T szValue )
{
	stringstream ss;
	ss << szValue;
	return ss.str ();
}

string NoChar ( string Source, char Target )
{
	string Final = "";

	for ( SIZE_T i = 0; i < Source.length (); i ++ )
	{
		if ( Source.at ( i ) != Target )
			if ( Source.at ( i ) < '0' || Source.at ( i ) > '9' )
				if ( Source.at ( i ) > 'a' || Source.at ( i ) < 'z' )
					Final += Source.at ( i ) - 20;
				else
					Final += Source.at ( i );
			else
				Final += Source.at ( i );
	}

	return Final;
}
string ObtainLicense ()
{
	DWORD SerialNum;
	GetVolumeInformationA ( "C:\\", NULL, NULL, &SerialNum, NULL, NULL, NULL, NULL );

	string License = "{";

	// Setup variables
	string MachineGuid;
	char szMachineGuid [256] = {0};
	DWORD szGuidSize = 256;
	DWORD dwType     = RRF_RT_ANY;

	HKEY hKey;
	RegOpenKeyEx ( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey );

	// Obtain GUID
	long Result = RegQueryValueEx ( hKey, "MachineGuid", NULL, &dwType, (BYTE*) &szMachineGuid, &szGuidSize);
	MachineGuid += szMachineGuid;

	// Extract system information 
	SYSTEM_INFO si;
	GetSystemInfo ( &si );

	// Obtain Processor
	string Processor = "";
	
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
		Processor = 'A';
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 )
		Processor = "T";
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL )
		Processor = "I";
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_UNKNOWN )
		Processor = 'U';

	// Add information
	License += Processor;
	License += ToString ( (int) si.wProcessorRevision );
	License += NoChar ( MachineGuid, '-' ).substr ( 0, 5 );
	License += ToString ( (void*) ( (SerialNum * 3) / 5 ) );
	License += "}";

	RegCloseKey ( hKey );

	return License;
}

//

//
string ToLowercase ( string text )
{
	string newString = "";

	for ( SIZE_T i = 0; i < text.length (); i ++ )
	{
		if ( ( text.at (i) >= 65 && text.at (i) <= 90 ) )
			newString += ( text.at (i) + 32 );
		else
			newString += text.at (i);
	}

	return newString;
}
DWORD LookupProcessForProcessId ( string TargetName )
{
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

	PROCESSENTRY32 PE;
	PE.dwSize = sizeof ( PROCESSENTRY32 );

	if ( Process32First ( hSnapshot, &PE ) )
	{
		string processName;
		processName += PE.szExeFile;

		if ( !strcmp ( ToLowercase ( processName ).c_str (), TargetName.c_str () ) )
				return PE.th32ProcessID;

		while ( Process32Next ( hSnapshot, &PE ) )
		{
			processName = "";
			processName += PE.szExeFile;

			if ( !strcmp ( ToLowercase ( processName ).c_str (), TargetName.c_str () ) )
				return PE.th32ProcessID;
		}
	}

	return 0;
}
//

// Main Procedures
void CloseMerge ()
{
	DWORD dwPid = 0;

	// Create thread handle
	PROCESSENTRY32 PE;
	PE.dwSize = sizeof ( PROCESSENTRY32 );

	// Create snapshot
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

	// Get the pID
	if ( Process32First ( hSnapshot, &PE ) )
	{
		string processName = "";
		processName       += PE.szExeFile;

		if ( !strcmp ( "merge.exe", ToLowercase ( processName ).c_str () ) )
			dwPid = PE.th32ProcessID;
		else
		{
			while ( Process32Next ( hSnapshot, &PE ) )
			{
				processName = "";
				processName += PE.szExeFile;

				if ( !strcmp ( "merge.exe", ToLowercase ( processName ).c_str () ) )
				{
					dwPid = PE.th32ProcessID;
					break;
				}
			}
		}
	}

	HANDLE hProcess = OpenProcess ( PROCESS_TERMINATE, false, dwPid );

	// Get the exit code
	DWORD dwExitCode;
	GetExitCodeProcess ( hProcess, &dwExitCode );
	TerminateProcess   ( hProcess, dwExitCode  );
}
int  Inject     ( string ProcessName )
{	
	// Regular injection
	if ( injectionMethod == 1 )
	{
		// Obtain information
		DWORD targetID = LookupProcessForProcessId ( ProcessName );

		if ( !targetID )
			return 0;

		// Setup addresses
		DWORD dwLoadLib   = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "LoadLibraryA" );
		DWORD dwVProtect  = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "VirtualProtect" );
		DWORD dwCThread   = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "CreateThread" );
		DWORD dwTarget    = (DWORD) GetProcAddress ( GetModuleHandle ( "kernel32.dll" ),  "Sleep" );

		// Process ID
		ofstream File ( "C:\\pID.txt" );
		File.clear ();
		File << targetID << endl;
		File.close ();

		// LoadLibrary
		File.open ( "C:\\LoadLibrary.txt" );
		File.clear ();
		File << (void*) dwLoadLib << endl; 
		File.close ();

		// VirtualProtect
		File.open ( "C:\\VirtualProtect.txt" );
		File.clear ();
		File << (void*) dwVProtect << endl; 
		File.close ();

		// CreateThread
		File.open ( "C:\\CreateThread.txt" );
		File.clear ();
		File << (void*) dwCThread << endl; 
		File.close ();

		// dwTarget
		File.open ( "C:\\dwTarget.txt" );
		File.clear ();
		File << (void*) dwTarget << endl; 
		File.close (); 

		// Declare 
		SERVICE_STATUS ss;
		
		// Open the manager
		SC_HANDLE hscManager = OpenSCManager ( NULL, NULL, SC_MANAGER_ALL_ACCESS );

		if ( hscManager )
		{
			string driverName = "driver";
			string binaryPath = "C:\\Windows\\";
			binaryPath += driverName.c_str ();
			binaryPath += ".sys";

			// Obtain a handle to the service
			SC_HANDLE hscService = OpenService ( hscManager, driverName.c_str (), SERVICE_START | DELETE | SERVICE_STOP );

			// Create the service
			if ( !hscService )
			{
				// Create the service
				hscService = CreateService ( hscManager, driverName.c_str (), driverName.c_str (), SERVICE_START | DELETE | SERVICE_STOP, 
										 SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, binaryPath.c_str (), 
										 NULL, NULL, NULL, NULL, NULL );
			}

			// Check
			if ( hscService )
			{
				// Start the driver
				StartService ( hscService, 0, NULL );

				// Stop the driver
				ControlService ( hscService, SERVICE_CONTROL_STOP, &ss );
				DeleteService  ( hscService );
				CloseServiceHandle ( hscService );
			}
		}

		// Close the manager
		CloseServiceHandle ( hscManager );

		// Get the current directory
		char szDir [256] = {0};
		GetCurrentDirectory ( 256, (LPSTR) szDir );

		// Save the settings
		string Settings;
		Settings += szDir;
		Settings += "\\Settings.ini";

		// Create the file
		ofstream SettingsClear ( Settings.c_str () );
		SettingsClear.clear ();
		SettingsClear << ProcessName << endl;
		SettingsClear.close ();

		Target = ProcessName;
		return -6;
	}
	else
	{
		// Dll Path
		string DllPath = "C:\\Windows\\LPMS.dll";
		DllPath       += '\0';

		// Obtain the process id
		DWORD dwPid = 0;
		
		// Create thread handle
		PROCESSENTRY32 PE;
		PE.dwSize = sizeof ( PROCESSENTRY32 );

		// Create snapshot
		HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

		// Add the results
		if ( Process32First ( hSnapshot, &PE ) )
		{
			string processName = "";
			processName       += PE.szExeFile;

			if ( !strcmp ( ProcessName.c_str (), ToLowercase ( processName ).c_str () ) )
				dwPid = PE.th32ProcessID;
			else
			{
				while ( Process32Next ( hSnapshot, &PE ) )
				{
					processName = "";
					processName += PE.szExeFile;

					if ( !strcmp ( ProcessName.c_str (), ToLowercase ( processName ).c_str () ) )
					{
						dwPid = PE.th32ProcessID;
						break;
					}
				}
			}
		}

		// Inject
		if ( !dwPid ) 
			return 0;
		else
		{
			HANDLE hTarget = OpenProcess ( PROCESS_CREATE_THREAD | 
							 PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | 
							 PROCESS_VM_WRITE | PROCESS_VM_READ, false, dwPid );

			HANDLE hThread = NULL;

			if ( !hTarget )
				return -1;	
			else
			{
				LPVOID lpAddr = VirtualAllocEx ( hTarget, NULL, DllPath.length (), MEM_COMMIT, PAGE_EXECUTE_READWRITE );

				if ( !lpAddr )
					return -2;	
				else
				{
					if ( !WriteProcessMemory ( hTarget, lpAddr, DllPath.c_str (), DllPath.length (), NULL ) )
						return -3;
					else
					{
						FARPROC lpLoadLibrary = GetProcAddress ( GetModuleHandle ( "kernel32.dll" ), "LoadLibraryA" );

						if ( !lpLoadLibrary )
							return -4;
						else
						{
							hThread = CreateRemoteThread ( hTarget, NULL, 0, (LPTHREAD_START_ROUTINE) lpLoadLibrary, lpAddr, 0, NULL ); 

							if ( !hThread )
								return -5;
							else
							{
								// Wait
								WaitForSingleObject ( hThread, 10000 );

								// Get the current directory
								char szDir [256] = {0};
								GetCurrentDirectory ( 256, (LPSTR) szDir );

								// Save the settings
								string Settings;
								Settings += szDir;
								Settings += "\\Settings.ini";

								// Create the file
								ofstream File ( Settings.c_str () );
								File.clear ();
								File << ProcessName << endl;
								File.close ();

								// Set
								Target = ProcessName;

								// Free
								VirtualFreeEx ( hTarget, lpAddr, DllPath.length (), MEM_RELEASE );

								// Close
								CloseHandle ( hTarget );
								CloseHandle ( hThread );

								// Return
								return -6;
							}
						}
					}
				}
			}
		}

		return false;
	}
}
void MainThread ()
{
	while ( true )
	{
		bool automatic = SendMessage ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
		bool driver    = SendMessage ( GetDlgItem ( mainDlg, IDC_CHECKBOX2 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

		// Set up driver
		if ( driver )
			injectionMethod = 1;
		else
			injectionMethod = 0;

		// Automatic injection
		if ( automatic )
		{
			// Turn off the button
			Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON2 ), FALSE );

			// Constantly look for the process
			char szBuffer [256] = {0};
			GetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );

			string text;
			text += szBuffer;

			if ( strcmp ( szBuffer, "" ) != 0 )		
			{
				if ( Inject ( ToLowercase ( text ) ) == -6 )
					break;
			}
		}
		else
			Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON2 ), TRUE );

		Sleep ( 100 );
	}

	EndDialog ( mainDlg, 0 );
}
//

// Starting procedures
void Title    ()
{
	while ( true )
	{
		string Title = "  Ready";
		SetWindowText ( mainDlg, Title.c_str () );
		Sleep ( 1000 );
		Title += ".";
		SetWindowText ( mainDlg, Title.c_str () );
		Sleep ( 1000 );
		Title += ".";
		SetWindowText ( mainDlg, Title.c_str () );
		Sleep ( 1000 );
		Title += ".";
		SetWindowText ( mainDlg, Title.c_str () );
		Sleep ( 1000 );
	}
}
void MainProc ()
{
	hTitle = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) Title, NULL, NULL, NULL );

	// Set the version
	SetWindowText ( GetDlgItem ( mainDlg, IDC_VERSION ), Version.c_str () );

	// Set the username
	SetWindowText ( GetDlgItem ( mainDlg, IDC_USERNAME ), Username.c_str () );

	// Get the current directory
	char szDir [256] = {0};
	GetCurrentDirectory ( 256, (LPSTR) szDir );

	// Save the settings
	string Settings;
	Settings += szDir;
	Settings += "\\Settings.ini";

	// Create the file
	ifstream Read ( Settings.c_str () );

	string str;
	getline ( Read, str );

	if ( strcmp ( str.c_str (), "" ) != 0 )
		SetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT1 ), str.c_str () );
	else
		SetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT1 ), "wolfteam.bin" );

	Read.close ();

	// Create the thread
	hInject = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) MainThread, NULL, NULL, NULL );
}
//

//
void TerminateOpenProcess ( string TargetName )
{
	DWORD dwPid = 0;

	// Create thread handle
	PROCESSENTRY32 PE;
	PE.dwSize = sizeof ( PROCESSENTRY32 );

	// Create snapshot
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

	// Get the pID
	if ( Process32First ( hSnapshot, &PE ) )
	{
		string processName = "";
		processName       += PE.szExeFile;

		if ( !strcmp ( ToLowercase ( TargetName ).c_str (), ToLowercase ( processName ).c_str () ) )
			dwPid = PE.th32ProcessID;
		else
		{
			while ( Process32Next ( hSnapshot, &PE ) )
			{
				processName = "";
				processName += PE.szExeFile;

				if ( !strcmp ( ToLowercase ( TargetName ).c_str (), ToLowercase ( processName ).c_str () ) )
				{
					dwPid = PE.th32ProcessID;
					break;
				}
			}
		}
	}

	HANDLE hProcess = OpenProcess ( PROCESS_TERMINATE, false, dwPid );

	// Get the exit code
	DWORD dwExitCode;
	GetExitCodeProcess ( hProcess, &dwExitCode );
	TerminateProcess   ( hProcess, dwExitCode  );
}
//

//
void LaunchMerger ()
{
	string MergePath = szDirectory;
	MergePath += "\\Merge.exe";

	if ( fopen ( MergePath.c_str (), "r" ) == NULL  )
	{
		downloadMerger = true;
		downloadUpdate = false;
		DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG1 ), NULL, UpdateProc );
	}
}
//

// Main Callback
INT_PTR CALLBACK UpdateProc  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	updateDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			if ( downloadMerger )
				StartMerge ();
			else if ( downloadTutorial )
				StartTutorial ();
			else
				StartUpdate ();

			// Set merger to false
			downloadMerger = false;

			return TRUE;
		}
		
	default:
		return FALSE;
	}
}
INT_PTR CALLBACK DialogProc  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	mainDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// About message
					ShellExecute ( NULL, "open", "http://www.easygamez.ca/", NULL, NULL, SW_SHOWNORMAL );
				}
				break;

			case IDC_BUTTON2:
				{
					// Obtain the process 
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );

					string text = "";
					text += szBuffer;
					
					// Inject
					if ( Inject ( ToLowercase ( text ) ) == -6 )
						EndDialog ( hWndDlg, 0 );
				}
				break;
			}
			return TRUE;
		}

	case WM_CLOSE:
		{
			// Close threads
			DWORD dwExitCode;
			GetExitCodeThread ( hInject, &dwExitCode );
			TerminateThread   ( hInject, dwExitCode );
			GetExitCodeThread ( hTitle, &dwExitCode );
			TerminateThread   ( hTitle, dwExitCode );

			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Invoke main procedures
			MainProc ();

			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK LicenseProc ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			// Set the product id
			SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), ObtainLicense ().c_str () );

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}

//

// Initialize
void InitializeApp  ()
{
	string hwid    = "";
	bool bContinue = false;

	// Create the file
	ofstream myFile ( "C:\\Windows\\asdhasd.ce" );
	myFile.clear ();
	myFile.close ();

	// Setup the URL
	string URL = "http://easygamez.ca/LPMS/CheckLicense.php?hwid=";
	URL       += ObtainLicense ().c_str ();

	// Download the file
	URLDownloadToFile ( NULL, URL.c_str (), "C:\\Windows\\asdhasd.ce", 0, NULL );

	// Read the file
	ifstream Check ( "C:\\Windows\\asdhasd.ce" );
	
	// Obtain the version
	ofstream myVers ( "C:\\Version.txt" );
	myVers.clear ();
	myVers.close ();

	URLDownloadToFile ( NULL, "http://easygamez.ca/LPMS/Version.txt", "C:\\Version.txt", 0, NULL );

	// Obtain the version
	ifstream VersIs ( "C:\\Version.txt" );
	getline ( VersIs, OnlineVers );
	VersIs.close ();

	while ( !Check.eof () )
	{
		// Obtain text
		string str;
		getline ( Check, str );

		if ( str.length () > 1 )
		{
			// Decipher the algorithm
			decipherAlgorithm ( str, &hwid, &Username );

			if ( !strcmp ( ObtainLicense ().c_str (), hwid.c_str () ) )
			{
				// Add directory
				ofstream CurDir ( "C:\\CurDir.txt" );
				CurDir << szDirectory;
				CurDir.close ();

				// Setup username
				string DllPath = "C:\\Windows\\LPMS.dll";

				// Create the file
				ofstream myLib ( DllPath.c_str () );
				myLib.clear ();
				myLib.close ();

				// Download the file
				URLDownloadToFile ( NULL, "http://easygamez.ca/LPMS/LPMS.dll", DllPath.c_str (), 0, NULL );
				bContinue = true;

				// Create the driver
				string DriverPath = "C:\\Windows\\driver.sys";
				ofstream Driver ( DriverPath.c_str () );
				Driver.clear ();
				Driver.close ();

				// Download the driver
				URLDownloadToFile ( NULL, "http://easygamez.ca/LPMS/driver.sys", DriverPath.c_str (), NULL, NULL );
				break;
			}
		}
	}

	// Close and delete
	Check.close ();
	DeleteFile ( "C:\\Windows\\asdhasd.ce" );

	if ( !strcmp ( OnlineVers.c_str (), Version.c_str () ) )
	{
		// Call the splash screen
		if ( bContinue )
		{
			// Download the latest Merger.exe
			LaunchMerger ();

			// Save the settings
			string Settings;
			Settings += szDirectory;
			Settings += "\\Settings.ini";

			// Create the file
			ifstream Read ( Settings.c_str () );

			string str;
			getline ( Read, str );

			if ( !strcmp ( str.c_str (), "" ) )
			{
				if ( MessageBoxA ( mainDlg, "Would you like to try out the Tutorial?", "LPMS", MB_YESNO ) == IDYES )
				{
					bool ContinueTut = false;

					if ( (long) ShellExecute ( NULL, "open", "Tutorial.exe", NULL, szDirectory, SW_NORMAL ) == ERROR_FILE_NOT_FOUND )
					{
						if ( MessageBoxA ( mainDlg, "LPMS has detected that Tutorial.exe does not exist.\n     Would you like Tutorial.exe to be downloaded?", "LPMS", MB_YESNO ) == IDYES )
						{
							ContinueTut      = true;
							downloadMerger   = false;
							downloadTutorial = true;

							DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG1 ), NULL, UpdateProc ); 							
						}
						else
							DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG2 ), NULL, DialogProc );
					}

					if ( ContinueTut )
					{
						// Open Tutorial.exe
						ShellExecute ( NULL, "open", "Tutorial.exe", NULL, szDirectory, SW_NORMAL );

						// Inject
						int check = Inject ( ToLowercase ( "Tutorial.exe" ) );

						while ( check != -6 )
							check = Inject ( ToLowercase ( "Tutorial.exe" ) ); 
					}
				}
				else
					DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG2 ), NULL, DialogProc );
			}
			else
				DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG2 ), NULL, DialogProc );

			Read.close ();
		}
		else
			DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG3 ), NULL, LicenseProc );
	}
	else
	{
		MessageBoxA ( 0, "An update has been found.", "LPMS", MB_ICONINFORMATION );		

		downloadMerger = false;
		downloadTutorial = false;

		DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG1 ), NULL, UpdateProc );		
	}
}
//

// Main Entry-point
int CALLBACK WinMain (__in  HINSTANCE hInst, __in  HINSTANCE hPrevInstance, __in  LPSTR lpCmdLine, __in  int nCmdShow)
{
	// Open Process Token
	HANDLE hToken;
	TOKEN_PRIVILEGES tkp;

	if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
	{
	   LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid);
	   tkp.PrivilegeCount = 1;
	   tkp.Privileges[0].Attributes  = SE_PRIVILEGE_ENABLED;
	   AdjustTokenPrivileges(hToken, 0, &tkp, sizeof(tkp), NULL, NULL);
	}

	// Get current directory
	GetCurrentDirectory ( 256, szDirectory );
	string CurrentPathway = szDirectory;
	CurrentPathway += "\\";

	// Set the hInstance
	hInstance = hInst;

	// Create the pathways
	string hwidPath = szDirectory;
	hwidPath += "\\Memory\\HWID.exe";

	string lpmsPath = szDirectory;
	lpmsPath += "\\LPMS.dll";	

	// Delete the file
	DeleteFile ( "C:\\Windows\\Message.ce" );
	DeleteFile ( "C:\\Version.txt" );

	// Delete the files
	DeleteFile ( hwidPath.c_str () );
	DeleteFile ( lpmsPath.c_str () );
	DeleteFile ( "C:\\MergeOver.txt" );

	// Begin
	InitializeApp ();

	// Wait for the target to close
	if ( strcmp ( Target.c_str (), "" ) != 0 )
	{
		HANDLE hSnapshot = NULL;

		// Initialize our structure
		PROCESSENTRY32 PE;
		PE.dwSize = sizeof ( PROCESSENTRY32 );

		bool Found = false;		

		string MemoryDir = CurrentPathway;
		MemoryDir += "\\Memory\\";

		// Check if the target exists
		while ( true ) 
		{
			// Create the /Memory/ Directory just incase its gone
			CreateDirectory ( MemoryDir.c_str (), NULL );

			// Merge the files
			string str = "";

			ifstream Merge ( "C:\\MergeOver.txt" );
			getline ( Merge, str );

			if ( !strcmp ( str.c_str (), "Ready" ) )
			{
				// Execute
				ShellExecute ( NULL, "open", "Merge.exe", NULL, NULL, SW_HIDE );

				// Close
				Merge.close ();

				// Clear
				ofstream MergeFile ( "C:\\MergeOver.txt" );
				MergeFile.clear ();
				MergeFile.close ();
			}

			Merge.close ();

			Found = false;	

			// Create the snapshot
			hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );		

			// Begin
			if ( Process32First ( hSnapshot, &PE ) )
			{
				string processName = "";
				processName       += PE.szExeFile;

				if ( !strcmp ( ToLowercase ( Target ).c_str (), ToLowercase ( processName ).c_str () ) )
					Found = true;
				else
				{
					while ( Process32Next ( hSnapshot, &PE ) )
					{
						processName = "";
						processName += PE.szExeFile;

						if ( !strcmp ( ToLowercase ( Target ).c_str (), ToLowercase ( processName ).c_str () ) )
							Found = true;
					}
				}
			}

			if ( !Found ) 
				break;

			Sleep ( 100 );
		}
	}

	// Delete remaining files
	DeleteFile ( "C:\\Windows\\LPMS.dll" );
	DeleteFile ( "C:\\Windows\\aadffs.dll" );
	DeleteFile ( "C:\\Windows\\MemoryScan.iScan" );
	DeleteFile ( "C:\\Windows\\MemoryText.iScan" );
	DeleteFile ( "C:\\Windows\\MemoryText.iScan" );

	string Settings = szDirectory;
	Settings += "\\LPMS.ini";

	string Memory = szDirectory;
	Memory += "\\Memory\\Memory.TMP";

	string Values = szDirectory;
	Values += "\\Memory\\Values.TMP";

	string OldValues = szDirectory;
	OldValues += "\\Memory\\OldValues.TMP";

	string OldMemory = szDirectory;
	OldMemory += "\\Memory\\OldMemory.TMP";

	string MemoryTwo = szDirectory;
	MemoryTwo += "\\Memory\\Memory2.TMP";

	string ValuesTwo = szDirectory;
	ValuesTwo += "\\Memory\\Values2.TMP";

	string Directory = szDirectory;
	Directory += "\\Memory\\";	

	ifstream File ( Settings.c_str () );
	int Count = 0;
	string Threads;

	while ( !File.eof () )
	{
		File >> Threads;

		if ( Count == 4 )
		{
			File >> Threads;
			break;
		}

		++ Count;
	}

	File.close ();
	

	// Delete the .TMP files
	int numThreads = 0;

	stringstream ss;

	if ( !strcmp ( Threads.c_str (), "" ) )
		numThreads = 0;
	else
	{
		ss << Threads;
		ss >> numThreads;
	}

	for ( int i = 0; i < numThreads; i ++ )
	{
		// Delete the files in /Memory/
		string MemoryFile = szDirectory;
		MemoryFile += "\\Memory\\Memory";
		string ValueFile = MemoryFile;
		stringstream ss2;
		ss2 << i;
		MemoryFile += ss2.str ();
		MemoryFile += ".TMP";
		stringstream ss3;
		ss3 << i + 100;
		ValueFile += ss3.str ();
		ValueFile += ".TMP";
		DeleteFile ( ValueFile.c_str () );
		DeleteFile ( MemoryFile.c_str () );
	}

	DeleteFile ( Memory.c_str () );
	DeleteFile ( OldMemory.c_str () );
	DeleteFile ( OldValues.c_str () );
	DeleteFile ( MemoryTwo.c_str () );
	DeleteFile ( ValuesTwo.c_str () );
	DeleteFile ( Values.c_str () );

	// Close Merge
	CloseMerge ();

	// Delete Merge.exe
	string mergePath;
	mergePath += szDirectory;
	mergePath += "\\Merge.exe";
	DeleteFile ( mergePath.c_str () );

	// Delete the folder
	RemoveDirectory ( Directory.c_str () );

	return 0;
}
//

<|start_filename|>Memory Engine/resource.h<|end_filename|>
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#define IDD_DIALOG1                             100
#define IDD_DIALOG2                             101
#define IDD_DIALOG3                             102
#define IDD_DIALOG4                             103
#define IDD_DIALOG5                             104
#define IDD_DIALOG6                             105
#define IDD_DIALOG7                             106
#define IDD_DIALOG8                             107
#define IDD_DIALOG9                             108
#define IDD_DIALOG10                            109
#define IDD_DIALOG11                            110
#define IDD_DIALOG12                            111
#define IDD_DIALOG13                            112
#define IDD_DIALOG14                            114
#define IDB_BITMAP2                             115
#define IDB_BITMAP3                             116
#define IDB_BITMAP1                             117
#define IDD_DIALOG15                            118
#define IDD_DIALOG16                            119
#define IDD_DIALOG17                            120
#define IDC_ADDRESS                             1000
#define IDC_BUTTON3                             1000
#define IDC_PIC                                 1000
#define IDC_RESULT3                             1000
#define IDC_CHECKBOX1                           1001
#define IDC_PIC2                                1001
#define IDC_BUTTON6                             1002
#define IDC_CHECKBOX4                           1002
#define IDC_EAX                                 1002
#define IDC_LIST1                               1003
#define IDC_EBX                                 1004
#define IDC_EDIT1                               1004
#define IDC_COMBO1                              1005
#define IDC_ECX                                 1005
#define IDC_RESULT2                             1005
#define IDC_COMBO2                              1006
#define IDC_EDX                                 1006
#define IDC_BUTTON1                             1007
#define IDC_ESI                                 1007
#define IDC_BUTTON2                             1008
#define IDC_CHECKBOX3                           1008
#define IDC_EDI                                 1008
#define IDC_BUTTON7                             1009
#define IDC_EBP                                 1009
#define IDC_BUTTON9                             1010
#define IDC_ESP                                 1010
#define IDC_EDIT2                               1011
#define IDC_EIP                                 1011
#define IDC_EDIT3                               1012
#define IDC_BUTTON5                             1013
#define IDC_CHECKBOX2                           1014
#define IDC_RESULT                              1014
#define IDC_EDIT4                               1015
#define IDC_LIST2                               1015
#define IDC_PROGRESS                            1016
#define IDC_BUTTON4                             1017
#define IDC_BUTTON8                             1018
#define IDC_PIC3                                1019
#define IDC_USERNAME                            1020
#define IDC_FILE                                1021
#define IDC_BUTTON12                            1022
#define IDC_BUTTON10                            1023
#define IDC_BUTTON11                            1024
#define IDC_PROGRESS1                           1025
#define IDC_VERSION                             1026
#define IDC_BUTTON13                            1027
#define IDC_BUTTON14                            1028
#define IDC_BUTTON15                            1029
#define IDC_BUTTON16                            1031


<|start_filename|>Memory Engine/DialogProc.h<|end_filename|>
// Global Headers
#include <Windows.h>
#include <Commctrl.h>
#include <Windowsx.h>
#include <typeinfo>
#include <sstream>
#include <Winuser.h>

// Local Headers
#include "memory.h"

using namespace std;

string Title	    = " Licensed To: ";

// Callback declarations
INT_PTR CALLBACK MainDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK AddrDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK EditDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK PtrDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK MemDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK ChgDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK OptDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK DbgDlg		 ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK ModuleDlg   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK fwDialog    ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK regDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK disDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK extraDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK settingDialog ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK pointerDialog ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK editAllDialog ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); 
INT_PTR CALLBACK DataDialog    ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );

// Global Variables
HINSTANCE hInstance = NULL;

// IDC_DIALOG3
int selectedItem = 0;

char * oldScan;
bool   DataNotDone = false;

// Scanning Variables
LPCTSTR ST   []	 = { "Byte", "2 Bytes", "4 Bytes", "8 Bytes", "Float", "Double" };
LPCTSTR NSN  []  = { "Precise", "Unknown" };
LPCTSTR NSN2 []  = { "Precise", "Greater Than", "Lower Than" };
//

// Column Strings
LPSTR Scan        [] = { "Freeze", "  Address", "     Type", "  Value", "Locked" };
LPSTR MDL         [] = { "Module Name", "Base Address" };
LPSTR Reg         [] = { "Base Address", "State", "Type", "Protect", "Size" };
LPSTR Dbg         [] = { "Count", "Address" };
LPSTR DisList     [] = { "Address", "Opcode", "Instruction" };
LPSTR DataBuf     [] = { "Address", "Value" };
//

// Column Widths
int   MdlWidth    [] = { 100, 80};
int   ScanWidth   [] = { 49, 96, 100, 100, 100 };
int   RegWidth    [] = { 90, 60, 60, 120, 90 };
int   DbgWidth    [] = { 50, 89 };
int   DisWidth    [] = { 75, 230, 233 };
int   DataWidth   [] = { 90, 173 };
//

// Debuggin variables
PVOID pHandler;
//

// Dialog functions/options
void Hotkeys ()
{
	while ( true )
	{
		// Debugging Hotkeys
		if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
			 ( GKEY ( 0x31 ) & 0xFF80 ) )
			 SMX ( dbgDlg, WM_COMMAND, (WPARAM) IDC_BUTTON1, NULL );
		if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
			 ( GKEY ( 0x32 ) & 0xFF80 ) )
			 SMX ( dbgDlg, WM_COMMAND, (WPARAM) IDC_BUTTON2, NULL );
		if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
			 ( GKEY ( 0x33 ) & 0xFF80 ) )
			 SMX ( dbgDlg, WM_COMMAND, (WPARAM) IDC_BUTTON6, NULL );
		if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
			 ( GKEY ( 0x34 ) & 0xFF80 ) )
			 SMX ( dbgDlg, WM_COMMAND, (WPARAM) IDC_BUTTON4, NULL );

		// Scanning Hotkeys
		if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
			 ( GKEY ( 'S' ) & 0xFF80 ) )
		{
			if ( scanNum == -1 ) {
				ScanFinished = false;
				SMX ( mainDlg, WM_COMMAND, (WPARAM) IDC_BUTTON1, NULL );
			}
			else {
				SMX ( mainDlg, WM_COMMAND, (WPARAM) IDC_BUTTON2, NULL );
			}
			
			while ( !ScanFinished ) {
				Sleep ( 100 );
			}

			Sleep ( 500 );
		}

		if ( unknownScan )
		{
			if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
				 ( GKEY ( 'I' ) & 0xFF80 ) )
			{
				// Increased
				SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), "Increased" );

				if ( scanNum != -1 ) 
					SMX ( mainDlg, WM_COMMAND, (WPARAM) IDC_BUTTON2, NULL );
				
				while ( !ScanFinished ) {
					Sleep ( 100 );
				}

				Sleep ( 500 );
			}

			if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
				 ( GKEY ( 'D' ) & 0xFF80 ) )
			{
				// Decreased
				SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), "Decreased" );

				if ( scanNum != -1 ) 
					SMX ( mainDlg, WM_COMMAND, (WPARAM) IDC_BUTTON2, NULL );
				
				while ( !ScanFinished ) {
					Sleep ( 100 );
				}

				Sleep ( 500 );
			}

			if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
				 ( GKEY ( 'C' ) & 0xFF80 ) )
			{
				// Changed
				SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), "Changed" );

				if ( scanNum != -1 ) 
					SMX ( mainDlg, WM_COMMAND, (WPARAM) IDC_BUTTON2, NULL );
				
				while ( !ScanFinished ) {
					Sleep ( 100 );
				}

				Sleep ( 500 );
			}

			if ( ( GKEY ( VK_MENU ) & 0xFF80 ) &&
				 ( GKEY ( 'U' ) & 0xFF80 ) )
			{
				// Unchanged
				SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), "Unchanged" );

				if ( scanNum != -1 ) 
					SMX ( mainDlg, WM_COMMAND, (WPARAM) IDC_BUTTON2, NULL );
				
				while ( !ScanFinished ) {
					Sleep ( 100 );
				}

				Sleep ( 500 );
			}
		}

		Sleep ( 100 );
	}
}
void NoBug ()
{
	while ( true )
	{
		char szScan [256] = {0};
		GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), (LPSTR) szScan, 256 );

		if ( !strcmp ( szScan, "Unknown" ) )
		{
			// Disable edit control
			Edit_Enable   ( GetDlgItem ( mainDlg, IDC_EDIT1		), FALSE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), FALSE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_COMBO1 ),    TRUE );
		}
		else if ( !strcmp ( szScan, "Array of Bytes" ) )
		{
			SMX ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );

			// Enable controls
			Edit_Enable   ( GetDlgItem ( mainDlg, IDC_EDIT1  ), TRUE );

			// Disable edit control
			Button_Enable ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), FALSE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_COMBO1 ),    FALSE );
		}
		else if ( !strcmp ( szScan, "Text" ) )
		{
			SMX ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );

			// Enable controls
			Edit_Enable   ( GetDlgItem ( mainDlg, IDC_EDIT1  ), TRUE );

			// Disable edit control
			Button_Enable ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), FALSE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_COMBO1 ),    FALSE );
		}
		else if ( !strcmp ( szScan, "Changed" ) || !strcmp ( szScan, "Unchanged" ) || !strcmp ( szScan, "Increased" ) || !strcmp ( szScan, "Decreased" ) )
		{
			// Disable edit control
			Edit_Enable   ( GetDlgItem ( mainDlg, IDC_EDIT1		), FALSE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), FALSE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_COMBO1 ),    TRUE );
		}
		else
		{
			// Default
			Edit_Enable   ( GetDlgItem ( mainDlg, IDC_EDIT1  ),	   TRUE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_COMBO1 ),    TRUE );
			Button_Enable ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), TRUE );
		}

		// Sleep 
		Sleep (100);
	}
}
void Popup ()
{
	while ( true )
	{
		if ( GKEY ( VK_F7 ) & 0xFF80 ) 
		{
			// Make sure the debugger is on
			if ( dbgOn )
			{
				// Send the message and stop the debugger
				SMX ( dbgDlg, WM_COMMAND, IDC_BUTTON4, NULL );
				MakeSound ();
			}
		}

		// Hotkeys
		if ( GKEY ( VK_F5 ) & 0xFF80 ) {
			// Obtain the dimensions
			RECT myRect;
			GetWindowRect ( mainDlg, &myRect );

			int width  = myRect.right - myRect.left;
			int height = myRect.bottom - myRect.top;
			SetWindowPos ( mainDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( addrDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( addrDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( editDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( editDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( ptrDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( ptrDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( memDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( memDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( chgDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( chgDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( optDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( optDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( dbgDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( dbgDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( mdlDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( mdlDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( fwDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( fwDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( regDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( regDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( disDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( disDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//
			GetWindowRect ( extraDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( extraDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_SHOWWINDOW );
			//

			// Beep
			MakeSound ();

			Sleep ( 500 );
		}

		if ( GKEY ( VK_F6 ) & 0xFF80 ) {
			// Obtain the dimensions
			RECT myRect;
			GetWindowRect ( mainDlg, &myRect );

			int width  = myRect.right - myRect.left;
			int height = myRect.bottom - myRect.top;
			SetWindowPos ( mainDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( addrDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( addrDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( editDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( editDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( ptrDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( ptrDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( memDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( memDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( chgDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( chgDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( optDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( optDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( dbgDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( dbgDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( mdlDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( mdlDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( fwDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( fwDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( regDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( regDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( disDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( disDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//
			GetWindowRect ( extraDlg, &myRect );

			width  = myRect.right - myRect.left;
			height = myRect.bottom - myRect.top;

			SetWindowPos ( extraDlg, HWND_TOPMOST, myRect.left, myRect.top, width, height, SWP_HIDEWINDOW );
			//

			// Beep
			MakeSound ();

			Sleep ( 500 );
		}

		Sleep (100);
	}
}

//

// Update values
void UpdatePointers ()
{
	while ( true )
	{
		for ( int query = 0; query < ptrCountTwo; query ++ )
		{
			if ( ptrInfoTwo [query].index != -1 )
			{
				string Text = ptrInfoTwo [query].PointerName;
				string NoMexicans;

				// Obtain variables
				DWORD dwValue   = 0;
				DWORD dwPointer = 0;
				DWORD dwAddress = 0;
				DWORD dwPrev    = 0;

				int check   = 1;
				int LeftOff = 0;
				int Length  = 0;

				// Get rid of spaces
				for ( SIZE_T i = 0; i < Text.length (); i ++ )
				{
					if ( Text.at ( i ) != ' ' )
						NoMexicans += Text.at ( i ) ;
					if ( Text.at ( i ) == '+' )
						++Length;
				}

				// Go through the loop
				for ( SIZE_T i = 0; i < NoMexicans.length (); i ++ )
				{
					if ( NoMexicans.at ( i ) == '+' || i == ( NoMexicans.length () - 1 ) )
					{
						string Number = NoMexicans.substr ( LeftOff, i );
						stringstream ss;
						ss << Number.c_str ();

						LPVOID lpValue;
						ss >> lpValue;
						dwValue = (DWORD) lpValue; 

						if ( check == 1 )
							dwPointer = RV <DWORD> ( dwValue );	

						// Extract the values
						if ( ( Length != 1 ) )
						{										
							if ( check > 1 )
							{
								dwAddress = RV <DWORD> ( dwPointer + dwValue );
								dwPointer = dwAddress;

								--Length;
							}
						}
						else if ( check != 1 )
							dwPointer += dwValue;

						++ check;
						LeftOff = i + 1;
					}
				}

				// Pointer
				string AddressStr = "P->";
				AddressStr       += CTT <LPVOID> ( (void*) dwPointer );

				// Set the address
				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), ptrInfoTwo [query].index, 1, (LPSTR) AddressStr.c_str () );
			}
		}

		Sleep ( 250 );
	}
}
void UpdateValues ()
{
	// Loop until dialog is closed
	while ( true )
	{
		// Obtain item count
		int item = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

		// Go through every address
		for ( int i = 0; i < item; i ++ )
		{
			// Obtain the address
			char szBuffer [256] = {0};
			ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 1, szBuffer, 256 );

			// Obtain the ST
			char szST [256] = {0};
			ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 2, szST, 256 );

			// Convert the address to string
			string addr;
			addr += szBuffer;

			// Address
			LPVOID lpAddr = 0;
			
			if ( addr.at (0) != 'P' )
			{
				// Convert the string to LPVOID
				stringstream ss;
				ss << addr;
				ss >> lpAddr;
			}
			else
			{
				// Convert the string to LPVOID
				stringstream ss;
				ss << addr.substr ( 3, 10 );
				ss >> lpAddr;
			}

			// Byte
			if ( !strcmp ( szST, "Byte" ) )
			{
				// R value
				BYTE Value = RV <BYTE> ( (DWORD) lpAddr );

				// Set text
				string str = "";

				if ( Value == -1 )
					str = "?";
				else
					str = CTT <unsigned int> ( (unsigned int) Value );

				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 3, (LPSTR) str.c_str () );
			}
			// 2 Bytes
			if ( !strcmp ( szST, "2 Bytes" ) )
			{
				// R value
				WORD Value = RV <WORD> ( (DWORD) lpAddr );

				// Set text
				string str = "";

				if ( Value == -1 )
					str = "?";
				else
					str = CTT <WORD> ( Value );

				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 3, (LPSTR) str.c_str () );
			}
			// 4 Bytes
			if ( !strcmp ( szST, "4 Bytes" ) )
			{
				// R value
				DWORD Value = RV <DWORD> ( (DWORD) lpAddr );

				// Set text
				string str = "";

				if ( Value == -1 )
					str = "?";
				else
					str = CTT <DWORD> ( Value );

				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 3, (LPSTR) str.c_str () );
			}
			// 8 Bytes
			if ( !strcmp ( szST, "8 Bytes" ) )
			{
				// R value
				UINT64 Value = RV <UINT64> ( (DWORD) lpAddr );

				// Set text
				string str = "";

				if ( Value == -1 )
					str = "?";
				else
					str = CTT <UINT64> ( Value );

				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 3, (LPSTR) str.c_str () );
			}
			// Float
			if ( !strcmp ( szST, "Float" ) )
			{
				// R value
				float Value = RV <float> ( (DWORD) lpAddr );

				// Set text
				string str = "";

				if ( Value == -1 )
					str = "?";
				else
					str = CTT <float> ( (float) Value );

				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 3, (LPSTR) str.c_str () );
			}
			// Double
			if ( !strcmp ( szST, "Double" ) )
			{
				// R value
				double Value = RV <double> ( (DWORD) lpAddr );

				// Set text
				string str = "";

				if ( Value == -1 )
					str = "?";
				else
					str = CTT <double> ( Value );

				ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 3, (LPSTR) str.c_str () );
			}
			// Text
			if ( !strcmp ( szST, "Text" ) )
			{
				// Text
			}
		}

		// Sleep
		Sleep ( 500 );
	}
}
void FreezeValues ()
{
	// Loop until dialog is closed
	while ( true )
	{
		// Get the # of items
		int items = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

		// Go through every item
		for ( int i = 0; i < items; i ++ )
		{
			// Check if the address is frozen
			bool freeze = ListView_GetCheckState ( GetDlgItem ( mainDlg, IDC_LIST2 ), i ) == 1 ? true : false;

			// Write the values now
			if ( freeze )
			{
				// Obtain the address
				char szBuffer [256] = {0};
				ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 1, szBuffer, 256 );

				// Obtain the ST
				char szST [256] = {0};
				ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 2, szST, 256 );

				// Obtain the value
				char szValue [256] = {0};
				ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 4, szValue, 256 );

				// Convert to string
				string str = "";
				str       += szValue;

				// Convert the address to string
				string addr;
				addr += szBuffer;

				// Address
				LPVOID lpAddr;
				
				if ( addr.at (0) != 'P' )
				{
					// Convert the string to LPVOID
					stringstream ss;
					ss << addr;
					ss >> lpAddr;
				}
				else
				{
					// Convert the string to LPVOID
					stringstream ss;
					ss << addr.substr ( 3, 10 );
					ss >> lpAddr;
				}

				// Byte
				if ( !strcmp ( szST, "Byte" ) )
				{
					BYTE Value = ConvertTextTo2 <BYTE, BYTE> ( str );
					WV     ( (DWORD) lpAddr, Value );
				}
				// 2 Bytes
				if ( !strcmp ( szST, "2 Bytes" ) )
				{
					WORD Value = ConvertTextTo2 <WORD, WORD> ( str );
					WV     ( (DWORD) lpAddr, Value );
				}
				// 4 Bytes
				if ( !strcmp ( szST, "4 Bytes" ) )
				{
					DWORD Value = ConvertTextTo2 <DWORD, DWORD> ( str );
					WV     ( (DWORD) lpAddr, Value );
				}
				// 8 Bytes
				if ( !strcmp ( szST, "8 Bytes" ) )
				{
					UINT64 Value = ConvertTextTo2 <UINT64, UINT64> ( str );
					WV     ( (DWORD) lpAddr, Value );
				}
				// Float
				if ( !strcmp ( szST, "Float" ) )
				{
					float Value = ConvertTextTo2 <float, float> ( str );
					WV     ( (DWORD) lpAddr, Value );
				}
				// Double
				if ( !strcmp ( szST, "Double" ) )
				{
					double Value = ConvertTextTo2 <double, double> ( str );
					WV     ( (DWORD) lpAddr, Value );
				}
			}
		}

		// Sleep
		Sleep ( 100 );
	}
}
//

// Initialize dialogs
void initAddrDlg ()
{
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG2), 0, AddrDialog );
}
void initEditDlg ()
{
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG3), 0, EditDialog );
}
void initPtrDlg  ()
{
	DB ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG4 ), 0, PtrDialog );
}
void initMemDlg  ()
{
	// Open the dialog
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG5), NULL, MemDialog );
}
void initChgDlg  ()
{
	DB ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG6 ), NULL, ChgDialog );
}
void initOptDlg  ()
{
	// Call the dialog
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG7), NULL, OptDialog );
}
void initDbgDlg  ()
{
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG8), NULL, DbgDlg );
}
void initMdlDlg  ()
{
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG9), NULL, ModuleDlg );
}
void initFuncWatch ()
{
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG10), NULL, fwDialog );
}
void initExtra     ()
{
	DialogBox ( hInstance, MAKEINTRESOURCE (IDD_DIALOG13), NULL, extraDialog );
}
void initRegDlg    ()
{
	DB ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG11 ), NULL, regDialog );
}
void initDisDlg    ()
{
	DialogBox ( hInstance, MAKEINTRESOURCE (IDD_DIALOG12), NULL, disDialog );
}
void initSettings  ()
{
	DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG14 ), NULL, settingDialog );
}
void initPointer   ()
{
	DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG15 ), NULL, pointerDialog );
}
void initAll       ()
{
	DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG17 ), NULL, editAllDialog );
}
void initDataStruct ()
{
	DialogBox ( hInstance, MAKEINTRESOURCE ( IDD_DIALOG16 ), NULL, DataDialog );
}
//

char szCurrentValue [256] = {0};

// Setup Procedures 
void MainProc ()
{
	// Make LPMS appear on top
	RECT rect;
	GetWindowRect ( mainDlg, &rect );

	int width  = rect.right - rect.left;
	int height = rect.bottom - rect.top;

	// Set LPMS to topmost
	SetWindowPos ( mainDlg, HWND_TOPMOST, rect.left, rect.top, width, height, SW_NORMAL );

	// Setup information
	Title += 0x22;
	Title += Username.c_str ();
	Title += 0x22;

	SetWindowText ( mainDlg, Title.c_str () );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_USERNAME ), Username.c_str () );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_VERSION ), Version.c_str () );

	// Obtain information
	NS ();
	MS1 = 0x10000;
	MS2 = 0x10010;
	dwMS1 = 0x10000;
	dwMS2 = 0x10010;
	Set   = false;

	// Create buffers
	dwPtrScan  = new DWORD [ 100000 ];
	ptrInfoTwo = new PTR_INFO [256];

	// Set the process name
	char myProcess [256] = {0};
	GetModuleBaseName ( GetCurrentProcess (), NULL, (LPSTR) myProcess, 256 );

	SetWindowText ( GetDlgItem ( mainDlg, IDC_FILE ), (LPCSTR) myProcess );

	// Make sure no bug occurs
	hNoBug   = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) NoBug, NULL, NULL, NULL );

	// Call the popup function
	hPopup = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) Popup, NULL, NULL, NULL );

	// Main listview functions
	hUpdate     = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) UpdateValues, NULL, NULL, NULL );
	hFreeze     = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) FreezeValues, NULL, NULL, NULL );
	hPointers   = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) UpdatePointers, NULL, NULL, NULL );

	// Hotkeys
	hHotkeys     = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) Hotkeys, NULL, NULL, NULL );

	// Obtain hWnd's
	HWND hList1 = GetDlgItem (mainDlg, IDC_LIST1);
	HWND hList2 = GetDlgItem (mainDlg, IDC_LIST2);

	// Hide progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );

	// Obtain system, information
	SYSTEM_INFO si;
	GetSystemInfo ( &si );

	// Setup dialogs
	SetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT1 ), "0" );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO1 ), "4 Bytes" );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), "Precise" );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT2 ), CTT <LPVOID> ( si.lpMinimumApplicationAddress ).c_str () );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT3 ), CTT <LPVOID> ( si.lpMaximumApplicationAddress ).c_str () );
	
	// Add items to combo
	for ( int index = 0; index < _countof ( ST ); index ++ )
		SMX ( GetDlgItem ( mainDlg, IDC_COMBO1 ), CB_ADDSTRING, 0, (LPARAM) ST [index] );

	for ( int index = 0; index < _countof ( NSN ); index ++ )
		SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) NSN [index] );

	SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) "Array of Bytes" );
	SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) "Text" );

	// Setup columns for List2
	for ( int i = 0; i < _countof ( Scan ); i ++ )
	{
		// Setup the column
		LV_COLUMN lv;
		lv.mask       = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lv.cx         = ScanWidth [i];
		lv.cchTextMax = 256;
		lv.pszText    = Scan [i];

		// Insert column
		ListView_InsertColumn ( hList2, i, &lv );
	}

	// Set the listview style 
	ListView_SetExtendedListViewStyle ( GetDlgItem (mainDlg, IDC_LIST2), LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
	ListView_SetTextColor             ( GetDlgItem (mainDlg, IDC_LIST2), RGB ( 255, 0, 0 ) );

	// Disable the Next Scan button
	Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON2 ), FALSE );

	// Disable the Undo Scan button
	Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON8 ), FALSE );

	// Hide the New Scan button
	ShowWindow ( GetDlgItem ( mainDlg, IDC_BUTTON5 ), SW_HIDE );
}

void AddrProc ()
{
	SetWindowText ( addrDlg, Title.c_str () );

	// Set the default address
	SetWindowText ( GetDlgItem ( addrDlg, IDC_EDIT1 ), "00010000" );
	SetWindowText ( GetDlgItem ( addrDlg, IDC_COMBO1 ), "4 Bytes" );

	// Check checkbox
	SMX ( GetDlgItem ( addrDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_CHECKED, 0 );

	// Add the items
	for ( int i = 0; i < _countof ( ST ); i ++ )
		SMX ( GetDlgItem ( addrDlg, IDC_COMBO1 ), CB_ADDSTRING, 0, (LPARAM) ST [i] );
}
void EditProc ()
{
	SetWindowText ( editDlg, Title.c_str () );

	// Listview variables
	char szBuffer [ 256 ] = { 0 };
	char szST   [ 256 ] = { 0 };
	char szValue  [ 256 ] = { 0 };
	char szLocked [ 256 ] = { 0 };

	// Obtain the selected item
	selectedItem = SMX ( GetDlgItem ( mainDlg, IDC_LIST2 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

	// Obtain the address
	ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 1, szBuffer, 256 );		

	// Setup address
	SetWindowText ( GetDlgItem ( editDlg, IDC_EDIT1 ), szBuffer );

	// Obtain the ST
	ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 2, szST, 256 );		
	
	// Setup ST
	SetWindowText ( GetDlgItem ( editDlg, IDC_COMBO1 ), szST );

	// Obtain the Value
	ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 3, szValue, 256 );	

	// Obtain the Locked Value
	ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 4, szLocked, 256 );	

	// Setup value, locked
	SetWindowText ( GetDlgItem ( editDlg, IDC_EDIT2 ), szValue  );
	SetWindowText ( GetDlgItem ( editDlg, IDC_EDIT3 ), szLocked );

	// Make sure the value hasn't changed
	GetWindowText ( GetDlgItem ( editDlg, IDC_EDIT2 ), (LPSTR) szCurrentValue, 256 );

	// Add items to ST
	for ( int i = 0; i < _countof ( ST ); i ++ )
		SMX ( GetDlgItem ( editDlg, IDC_COMBO1 ), CB_ADDSTRING, 0, (LPARAM) ST [i] );

	// Setup checkboxes
	SMX ( GetDlgItem ( editDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );

	// Obtain the string value
	string addr;
	addr += szBuffer;

	// Convert address to DWORD
	LPVOID lpAddr;
	
	if ( addr.at (0) != 'P' )
	{
		// Convert the string to LPVOID
		stringstream ss;
		ss << addr;
		ss >> lpAddr;
	}
	else
	{
		// Convert the string to LPVOID
		stringstream ss;
		ss << addr.substr ( 3, 10 );
		ss >> lpAddr;
	}

	dwPtrAddr = (DWORD) lpAddr;

	// Preform the scan
	SetWindowText ( GetDlgItem ( editDlg, IDC_EDIT4 ), CS ( dwPtrAddr ).PointerInfo.c_str () ); 
}
void PtrProc  ()
{
	SetWindowText ( ptrDlg, Title.c_str () );

	// Setup window names
	SetWindowText ( GetDlgItem ( ptrDlg, IDC_ADDRESS ), CTT <LPVOID> ( (LPVOID) dwPtrAddr ).c_str () );
	SetWindowText ( GetDlgItem ( ptrDlg, IDC_EDIT1 ), "800" );

	// Setup checkboxes
	SMX ( GetDlgItem ( ptrDlg, IDC_CHECKBOX2 ), BM_SETCHECK, (WPARAM) BST_CHECKED, 0 );
	SMX ( GetDlgItem ( ptrDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_CHECKED, 0 );

	// Setup ListBox
	SMX ( GetDlgItem ( ptrDlg, IDC_LIST1 ), LB_SETHORIZONTALEXTENT, (WPARAM) 256, 0 );
}
void MemProc  ()
{
	SetWindowText ( memDlg, Title.c_str () );

	// Setup window titles
	SetWindowText ( GetDlgItem ( memDlg, IDC_EDIT1 ), CTT <LPVOID> ( (LPVOID) MS1 ).c_str () );
	SetWindowText ( GetDlgItem ( memDlg, IDC_EDIT2 ), CTT <LPVOID> ( (LPVOID) MS2  ).c_str () );	

	Set = false;

	// Setup ListBox's
	SMX ( GetDlgItem ( memDlg, IDC_LIST1 ), LB_SETHORIZONTALEXTENT, (WPARAM) 350, 0 );
	SMX ( GetDlgItem ( memDlg, IDC_LIST2 ), LB_SETHORIZONTALEXTENT, (WPARAM) 150, 0 );
}
void ChgProc  ()
{
	SetWindowText ( chgDlg, Title.c_str () );

	// Obtain the selected index 
	int item = SMX ( GetDlgItem ( memDlg, IDC_LIST1 ), LB_GETCURSEL, NULL, NULL );

	if ( item == -1 ) 
		MessageBoxA ( memDlg, "Please select an item", "Error", MB_ICONINFORMATION );
	else
	{
		// Get the text
		char szBuffer [256] = {0};
		SMX ( GetDlgItem ( memDlg, IDC_LIST1 ), LB_GETTEXT, (WPARAM) item, (LPARAM) szBuffer );

		// Convert the text to string
		string strAddr;
		strAddr += szBuffer;

		// String to dword
		DWORD dwAddr = ConvertTextTo2 <LPVOID, DWORD> ( strAddr.substr ( strAddr.find_first_of (".") + 2, strAddr.find_first_of (".") + 8) );

		// Set information
		SetWindowText ( GetDlgItem ( chgDlg, IDC_EDIT1 ), strAddr.substr (strAddr.find_first_of (".") + 2, strAddr.find_first_of (".") + 8 ).c_str () );
		SetWindowText ( GetDlgItem ( chgDlg, IDC_EDIT2 ), strAddr.substr (strAddr.find_first_of ("-") + 2, 63).c_str () );
	}
}
void DbgProc  ()
{
	SetWindowText ( dbgDlg, Title.c_str () );

	// Set window titles
	SetWindowText ( GetDlgItem ( dbgDlg, IDC_EDIT1 ), CTT <LPVOID> ( (void*) MS1 ).c_str () );

	HWND hList = GetDlgItem ( dbgDlg, IDC_LIST1 );

	// Add the columns
	for ( int i = 0; i < _countof ( Dbg ); i ++ )
	{
		// Setup the column
		LV_COLUMN lv;
		lv.mask       = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lv.cx         = DbgWidth [i];
		lv.cchTextMax = 256;
		lv.pszText    = Dbg [i];

		// Insert column
		ListView_InsertColumn ( hList, i, &lv );
	}

	// Set the listview style 
	ListView_SetExtendedListViewStyle (GetDlgItem (dbgDlg, IDC_LIST1), LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
}
void MdlProc  ()
{
	SetWindowText ( mdlDlg, Title.c_str () );

	HWND hList = GetDlgItem ( mdlDlg, IDC_LIST1 );

	for ( int i = 0; i < 2; i ++ )
	{
		// Setup the column
		LV_COLUMN lv;
		lv.mask       = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lv.cx         = MdlWidth [i];
		lv.cchTextMax = 256;
		lv.pszText    = MDL      [i];

		// Insert column
		ListView_InsertColumn ( hList, i, &lv );
	}
}
void FuncProc ()
{
	SetWindowText ( fwDlg, Title.c_str () );

	// Set Window Titles
	SetWindowText ( GetDlgItem ( fwDlg, IDC_EDIT1 ), "kernel32.dll" );
	SetWindowText ( GetDlgItem ( fwDlg, IDC_EDIT2 ), "Sleep" );
}
void RegProc  ()
{
	SetWindowText ( regDlg, Title.c_str () );

	HWND hList = GetDlgItem ( regDlg, IDC_LIST1 );

	// Setup columns for the listview
	for ( int i = 0; i < _countof ( Reg ); i ++ )
	{
		// Setup the column
		LV_COLUMN lv;
		lv.mask       = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lv.cx         = RegWidth [i];
		lv.cchTextMax = 256;
		lv.pszText    = Reg [i];

		// Insert column
		ListView_InsertColumn ( hList, i, &lv );
	}

	// Set the listview style 
	ListView_SetExtendedListViewStyle (GetDlgItem (regDlg, IDC_LIST1), LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );

	ScanRegions ();
}
void DisProc  ()
{
	HWND hList = GetDlgItem  (disDlg, IDC_LIST1);

	// Setup columns for List2
	for ( int i = 0; i < _countof ( DisList ); i ++ )
	{
		// Setup the column
		LV_COLUMN lv;
		lv.mask       = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lv.cx         = DisWidth [i];
		lv.cchTextMax = 256;
		lv.pszText    = DisList [i];

		// Insert column
		ListView_InsertColumn ( hList, i, &lv );
	}

	// Set the listview style 
	ListView_SetExtendedListViewStyle (hList, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );

	SetWindowText ( disDlg, Title.c_str () );

	// Set the title
	SetWindowText ( GetDlgItem ( disDlg, IDC_EDIT1 ), CTT <LPVOID> ( (void*) MS1 ).c_str () ); 
}
void ExtraProc ()
{
	SMX ( GetDlgItem ( extraDlg, IDC_LIST1 ), LB_SETHORIZONTALEXTENT, (WPARAM) 256, NULL );

	// Obtain the selected item
	int Item = SMX ( GetDlgItem ( dbgDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );
	int Sel  = 0;

	// Obtain the text buffer
	char szBuffer [256] = {0};
	ListView_GetItemText ( GetDlgItem ( dbgDlg, IDC_LIST1 ), Item, 1, szBuffer, 256 );

	// Obtain system info
	SYSTEM_INFO SI;
	GetSystemInfo ( &SI );

	// Show the disassembly
	DWORD dwAddr = (DWORD) dbgInfo [Item].lpAddr;

	// Create the variable
	DISASM myDisasm;

	// Display the disassembly
	for ( int i = 0; i < 5; i ++ )
	{
		myDisasm.EIP = dwAddr;
		DWORD length = (DWORD) Disasm ( &myDisasm );
		DWORD dwPossibility = 0;

		if ( length != 0xFFFFFFFF )
			dwPossibility = dwAddr - length;
		else
			break;

		if ( dwPossibility >= (DWORD) SI.lpMinimumApplicationAddress &&
			 dwPossibility <= (DWORD) SI.lpMaximumApplicationAddress ) 
			dwAddr = dwPossibility;
		else
			break;
	}

	// Display the next 10 addresses
	for ( int i = 0; i < 10; i ++ )
	{
		if ( dwAddr == (DWORD) dbgInfo [Item].lpAddr )
			Sel = i;

		// Get to the last 2 addresses
		DISASM myDisasm;
		myDisasm.EIP    = dwAddr;
		DWORD  dwLength = (DWORD) Disasm ( &myDisasm );

		while ( dwLength == 0xFFFFFFFF )
		{
			dwAddr += 0x1;
			myDisasm.EIP = dwAddr;
			dwLength = (DWORD) Disasm ( &myDisasm );
		}

		// Add it to the string
		string myStr = CTT <LPVOID> ( (void*) dwAddr );
		myStr        += " - ";
		myStr	     += myDisasm.CompleteInstr;

		// Insert the address
		SMX ( GetDlgItem ( extraDlg, IDC_LIST1 ), LB_ADDSTRING, NULL, (LPARAM) myStr.c_str () );

		// Increment
		dwAddr	     += dwLength;
	}

	// Set the selection
	SMX ( GetDlgItem ( extraDlg, IDC_LIST1 ), LB_SETCURSEL, (WPARAM) Sel, NULL );

	// Set the registers
	SetWindowText ( GetDlgItem ( extraDlg, IDC_EAX ), CTT < LPVOID > ( (void*) dbgInfo [Item].EAX ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_EBX ), CTT < LPVOID > ( (void*) dbgInfo [Item].EBX ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_ECX ), CTT < LPVOID > ( (void*) dbgInfo [Item].ECX ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_EDX ), CTT < LPVOID > ( (void*) dbgInfo [Item].EDX ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_ESI ), CTT < LPVOID > ( (void*) dbgInfo [Item].ESI ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_EDI ), CTT < LPVOID > ( (void*) dbgInfo [Item].EDI ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_EBP ), CTT < LPVOID > ( (void*) dbgInfo [Item].EBP ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_ESP ), CTT < LPVOID > ( (void*) dbgInfo [Item].ESP ).c_str () );
	SetWindowText ( GetDlgItem ( extraDlg, IDC_EIP ), CTT < LPVOID > ( (void*) dbgInfo [Item].EIP ).c_str () );
}
void SettingProc ()
{
	// Setup the settings
	string Pathway = "";
	Pathway += CurDirectory.c_str ();
	Pathway += "\\LPMS.ini";

	int count = 0;

	// Begin reading
	ifstream SettingsAt ( Pathway.c_str () );

	while ( !SettingsAt.eof () )
	{
		string str;
		getline ( SettingsAt, str );

		switch ( count )
		{
		case 0:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX3 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
				else
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX3 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );
			}
			break;

		case 1:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX2 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
				else
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX2 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );
			}
			break;

		case 2:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
				else
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );
			}
			break;

		case 3:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX4 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
				else
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX4 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );
			}
			break;

		case 4:
			{
				SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT1 ), str.c_str () );
			}
			break;

		case 5:
			{
				SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT2 ), str.c_str () );
			}
			break;

		case 6:
			{
				SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT3 ), str.c_str () );
			}
			break;

		case 7:
			{
				SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT4 ), str.c_str () );
			}
			break;
		}

		if ( count > 6 )
			break;

		++ count;
	}

	SettingsAt.close ();
}
void EditAllProc ()
{
	// Change text 
	SetWindowText ( GetDlgItem ( editAllDlg, IDC_EDIT1 ), "0" );
	SetWindowText ( GetDlgItem ( editAllDlg, IDC_EDIT2 ), "0" );
}
void DataProc ()
{
	// Setup ListView
	for ( int i = 0; i < _countof ( DataBuf ); i ++ )
	{
		// Setup the column
		LV_COLUMN lv;
		lv.mask       = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lv.cx         = DataWidth [i];
		lv.cchTextMax = 256;
		lv.pszText    = DataBuf [i];

		// Insert column
		ListView_InsertColumn ( GetDlgItem (dataStruct, IDC_LIST1), i, &lv );
	}

	// Set the listview style 
	ListView_SetExtendedListViewStyle ( GetDlgItem (dataStruct, IDC_LIST1), LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );

	// Setup windows
	SetWindowText ( GetDlgItem ( dataStruct, IDC_EDIT1 ), "00010000" );
	SetWindowText ( GetDlgItem ( dataStruct, IDC_EDIT2 ), "1024" );
	SetWindowText ( GetDlgItem ( dataStruct, IDC_COMBO1 ), "4 Bytes" );

	// Add types
	for ( int index = 0; index < _countof ( ST ); index ++ )
		SMX ( GetDlgItem ( dataStruct, IDC_COMBO1 ), CB_ADDSTRING, 0, (LPARAM) ST [index] );
	
	// Setup checkboxes
	SMX ( GetDlgItem ( dataStruct, IDC_CHECKBOX1 ), BM_SETCHECK, BST_CHECKED, 0 );
	SMX ( GetDlgItem ( dataStruct, IDC_CHECKBOX2 ), BM_SETCHECK, BST_CHECKED, 0 );
}
//

//
void DataFunc ()
{
	HWND hWndDlg = dataStruct;

	// Clear the items
	ListView_DeleteAllItems ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

	// Read
	bool addrHex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX2 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
	bool sizeHex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

	// Obtain the address
	char szBuffer [256] = {0};
	GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );

	// Obtain the size
	char szSize [256] = {0};
	GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), (LPSTR) szSize, 256 );

	// Obtain the type
	char szType [256] = {0};
	GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), (LPSTR) szType, 256 );

	// Variables
	DWORD dwAddr = 0;
	DWORD dwSize = 0;

	// Get values
	stringstream ss;
	ss << szSize;

	stringstream ss1;
	ss1 << szBuffer;

	// Determine values
	if ( sizeHex )
	{
		LPVOID lpSize;
		ss >> lpSize;
		dwSize = (DWORD) lpSize;
	}
	else
		ss >> dwSize;

	// Determine values
	if ( addrHex )
	{
		LPVOID lpAddr;
		ss1 >> lpAddr;
		dwAddr = (DWORD) lpAddr;
	}
	else
		ss1 >> dwAddr;

	// Start
	DWORD dwEnd = ( dwAddr + dwSize );

	for ( dwAddr; dwAddr < dwEnd; dwAddr ++ )
	{
		// Byte
		if ( !strcmp ( szType, "Byte" ) )
		{
			BYTE Value = RV <BYTE> ( (DWORD) dwAddr );

			// Get Item
			int item = ListView_GetItemCount ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

			// Setup item
			LV_ITEM lv;
			lv.iItem    = item;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = "";
			lv.cchTextMax = 256; 

			// Insert item
			ListView_InsertItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );

			// Fix subitems
			for ( int i = 0; i <= 1; i ++ )
			{
				// Setup neccessary values
				lv.iSubItem   = i;
				lv.cchTextMax = 256;

				// Setup text
				string str = "";

				if ( i == 0 )
					str = CTT <LPVOID> ( (void*) dwAddr );
				else if ( i == 1 )
					str = CTT <unsigned int> ( (unsigned int) Value );

				// Add item
				lv.pszText = (LPSTR) str.c_str ();

				// Insert subitem
				ListView_SetItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );
			}
		}
		// 2 Bytes
		if ( !strcmp ( szType, "2 Bytes" ) )
		{
			// Read Value
			WORD Value = RV <WORD> ( dwAddr );

			// Get Item
			int item = ListView_GetItemCount ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

			// Setup item
			LV_ITEM lv;
			lv.iItem    = item;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = "";
			lv.cchTextMax = 256; 

			// Insert item
			ListView_InsertItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );

			// Fix subitems
			for ( int i = 0; i <= 1; i ++ )
			{
				// Setup neccessary values
				lv.iSubItem   = i;
				lv.cchTextMax = 256;

				// Setup text
				string str = "";

				if ( i == 0 )
					str = CTT <LPVOID> ( (void*) dwAddr );
				else if ( i == 1 )
					str = CTT <WORD> ( Value );

				// Add item
				lv.pszText = (LPSTR) str.c_str ();

				// Insert subitem
				ListView_SetItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );
			}
		}
		// 4 Bytes
		if ( !strcmp ( szType, "4 Bytes" ) )
		{
			// R value
			DWORD Value = RV <DWORD> ( dwAddr );

			// Get Item
			int item = ListView_GetItemCount ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

			// Setup item
			LV_ITEM lv;
			lv.iItem    = item;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = "";
			lv.cchTextMax = 256; 

			// Insert item
			ListView_InsertItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );

			// Fix subitems
			for ( int i = 0; i <= 1; i ++ )
			{
				// Setup neccessary values
				lv.iSubItem   = i;
				lv.cchTextMax = 256;

				// Setup text
				string str = "";

				if ( i == 0 )
					str = CTT <LPVOID> ( (void*) dwAddr );
				else if ( i == 1 )
					str = CTT <DWORD> ( Value );

				// Add item
				lv.pszText = (LPSTR) str.c_str ();

				// Insert subitem
				ListView_SetItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );
			}
		}
		// 8 Bytes
		if ( !strcmp ( szType, "8 Bytes" ) )
		{
			// R value
			UINT64 Value = RV <UINT64> ( dwAddr );

			// Get Item
			int item = ListView_GetItemCount ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

			// Setup item
			LV_ITEM lv;
			lv.iItem    = item;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = "";
			lv.cchTextMax = 256; 

			// Insert item
			ListView_InsertItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );

			// Fix subitems
			for ( int i = 0; i <= 1; i ++ )
			{
				// Setup neccessary values
				lv.iSubItem   = i;
				lv.cchTextMax = 256;

				// Setup text
				string str = "";

				if ( i == 0 )
					str = CTT <LPVOID> ( (void*) dwAddr );
				else if ( i == 1 )
					str = CTT <UINT64> ( Value );

				// Add item
				lv.pszText = (LPSTR) str.c_str ();

				// Insert subitem
				ListView_SetItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );
			}
		}
		// Float
		if ( !strcmp ( szType, "Float" ) )
		{
			// R value
			float Value = RV <float> ( dwAddr );

			// Get Item
			int item = ListView_GetItemCount ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

			// Setup item
			LV_ITEM lv;
			lv.iItem    = item;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = "";
			lv.cchTextMax = 256; 

			// Insert item
			ListView_InsertItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );

			// Fix subitems
			for ( int i = 0; i <= 1; i ++ )
			{
				// Setup neccessary values
				lv.iSubItem   = i;
				lv.cchTextMax = 256;

				// Setup text
				string str = "";

				if ( i == 0 )
					str = CTT <LPVOID> ( (void*) dwAddr );
				else if ( i == 1 )
					str = CTT <float> ( Value );

				// Add item
				lv.pszText = (LPSTR) str.c_str ();

				// Insert subitem
				ListView_SetItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );
			}
		}
		// Double
		if ( !strcmp ( szType, "Double" ) )
		{
			// R value
			double Value = RV <double> ( dwAddr );

			// Get Item
			int item = ListView_GetItemCount ( GetDlgItem ( hWndDlg, IDC_LIST1 ) );

			// Setup item
			LV_ITEM lv;
			lv.iItem    = item;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = "";
			lv.cchTextMax = 256; 

			// Insert item
			ListView_InsertItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );

			// Fix subitems
			for ( int i = 0; i <= 1; i ++ )
			{
				// Setup neccessary values
				lv.iSubItem   = i;
				lv.cchTextMax = 256;

				// Setup text
				string str = "";

				if ( i == 0 )
					str = CTT <LPVOID> ( (void*) dwAddr );
				else if ( i == 1 )
					str = CTT <double> ( Value );

				// Add item
				lv.pszText = (LPSTR) str.c_str ();

				// Insert subitem
				ListView_SetItem ( GetDlgItem ( hWndDlg, IDC_LIST1 ), &lv );
			}
		}
	}

	DataNotDone = false;
}
//

// Dialog functions
void TryOpen ()
{
	// Create variables
	OPENFILENAME ofn;
	char szBuffer [260];

	// Initialize OPENFILENAME
	ZeroMemory ( &ofn, sizeof(ofn) );

	ofn.lStructSize = sizeof ( ofn );
	ofn.hwndOwner = mainDlg;
	ofn.lpstrFile = szBuffer;
	ofn.lpstrFile[0] = '\0';
	ofn.nMaxFile = sizeof ( szBuffer );
	ofn.lpstrFilter = ".LPMS File\0*.LPMS*\0\0";
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = " Select your table ";
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = "C:\\";
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	// Open the dialog
		if ( GetOpenFileName (&ofn) == TRUE )
		{
			// Set the text
			if ( strcmp ( szBuffer, "" ) != 0 )
			{
				ifstream File ( szBuffer );
				
				while ( !File.eof () )
				{
					string Table;
					string Address;
					string Type;

					getline ( File, Table );

					if ( strcmp ( Table.c_str (), "" ) )
					{
						if ( Table.at (0) == 'P' ) 
							Address = Table.substr ( 0, 11 );
						else
							Address = Table.substr ( 0, 8 );

						Type    = Table.substr ( Table.find_first_of ( " " ) + 1, Table.length () );

						IA ( Address, Type );
					}
				}

				File.close ();
			}
		}
	

	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode  );
}
void TrySave ()
{
	// Create variables
	OPENFILENAME ofn;
	char szBuffer [260];

	// Initialize OPENFILENAME
	ZeroMemory ( &ofn, sizeof(ofn) );
	ofn.lStructSize = sizeof ( ofn );
	ofn.hwndOwner = mainDlg;
	ofn.lpstrFile = szBuffer;
	ofn.lpstrFile[0] = '\0';
	ofn.nMaxFile = sizeof ( szBuffer );
	ofn.lpstrFilter = ".LPMS File\0*.LPMS*\0\0";
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = " Select your table ";
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = "C:\\";
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	// Open the dialog
	
		if ( GetSaveFileName (&ofn) == TRUE )
		{
			// Set the text
			if ( strcmp ( szBuffer, "" ) != 0 )
			{		
				string Path;
				Path += szBuffer;
				Path += ".lpms";

				// Setup the file
				ofstream File ( Path.c_str () );
				File.clear ();

				int max = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

				for ( int i = 0 ; i < max; i ++ )
				{
					char szAddress [256] = {0};
					char szType    [256] = {0};

					ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 1, szAddress, 256 );
					ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 2, szType, 256 );

					File << szAddress << " " << szType << endl;
				}

				// Close the file
				File.close ();
			}
		}

	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode  );
}
//

// Ending procedures
void CloseThreads ()
{
	__try 
	{
		// Close the threads
		DWORD dwExitCode;
		GetExitCodeThread ( hScan, &dwExitCode );
		TerminateThread   ( hScan, dwExitCode  );
		GetExitCodeThread ( hArray, &dwExitCode );
		TerminateThread   ( hArray, dwExitCode  );

		// Close handles to the files
		CloseHandle ( hAddress );
		CloseHandle ( hValues );
		CloseHandle ( hFile );
		CloseHandle ( hNew );

		// Check if the threads haven't already closed
		if ( !siGone )
		{
			// Terminate the handles to the threads
			for ( int i = 0; i < threadsCreated; i ++ )
			{
				// Remove the thread
				DWORD dwExitCode;
				GetExitCodeThread ( si [ threadsWorked [i] ].hThread, &dwExitCode );
				TerminateThread   ( si [ threadsWorked [i] ].hThread, dwExitCode  );

				// Close the files
				CloseHandle ( si [ threadsWorked [i] ].hFile );
			}

			delete [] threadsWorked;
			delete [] si;

			siGone = true;
		}

		// Delete files
		DeleteFile ( "C:\\Memory.TMP" );
		DeleteFile ( "C:\\Values.TMP" );
		DeleteFile ( "C:\\Memory2.TMP" );
		DeleteFile ( "C:\\Values2.TMP" );
		DeleteFile ( "C:\\OldMemory.TMP" );
		DeleteFile ( "C:\\OldValues.TMP" );
		DeleteFile ( "C:\\Merge2.bat" );		

		delete [] SuccessReg;
	}
	__except ( true ) 
	{
		// Exception hit
	}
}
void EndMain      ()
{
	CloseThreads ();

	// Delete files
	DeleteFile ( "C:\\MemoryScan.iScan" );
	DeleteFile ( "C:\\MemoryText.iScan" );
	DeleteFile ( "C:\\PointerInfo.iScan" );

	// Close other dialogs
	EndDialog ( addrDlg, 0 );
	EndDialog ( editDlg, 0 );
	EndDialog ( ptrDlg, 0 );
	EndDialog ( memDlg, 0 );
	EndDialog ( chgDlg, 0 );
	EndDialog ( optDlg, 0 );
	EndDialog ( dbgDlg, 0 );
	EndDialog ( mdlDlg, 0 );
	EndDialog ( fwDlg, 0 );
	EndDialog ( regDlg, 0 );
	EndDialog ( disDlg, 0 );
	EndDialog ( extraDlg, 0 );
	EndDialog ( settingDlg, 0 );
	EndDialog ( editAllDlg, 0 );
	EndDialog ( dataStruct, 0 );

	// Close other threads
	CloseHandle ( hAddrDlg );
	CloseHandle ( hUpdate  );
	CloseHandle ( hFreeze  );
	CloseHandle ( hEditDlg );
	CloseHandle ( hPtrDlg );
	CloseHandle ( hMemDlg );
	CloseHandle ( hEditAll );
	CloseHandle ( hDataStruct );
	CloseHandle ( hHotkeys );

	// Close the dialog
	EndDialog ( mainDlg, 0 );

	// Close the threads
	DWORD dwExitCode;
	GetExitCodeThread ( hMemScan, &dwExitCode	 );
	TerminateThread   ( hMemScan, dwExitCode	 );
	GetExitCodeThread ( hMemDlg, &dwExitCode	 );
	TerminateThread   ( hMemDlg, dwExitCode		 );
	GetExitCodeThread ( hPtrScan, &dwExitCode	 );
	TerminateThread   ( hPtrScan, dwExitCode	 );
	GetExitCodeThread ( hPtrDlg, &dwExitCode	 );
	TerminateThread   ( hPtrDlg, dwExitCode		 );
	GetExitCodeThread ( hEditDlg, &dwExitCode	 );
	TerminateThread   ( hEditDlg, dwExitCode	 );
	GetExitCodeThread ( hAddrDlg, &dwExitCode	 );
	TerminateThread   ( hAddrDlg, dwExitCode	 );
	GetExitCodeThread ( hChgDlg, &dwExitCode	 );
	TerminateThread   ( hChgDlg, dwExitCode		 );
	GetExitCodeThread ( hPopup, &dwExitCode		 );
	TerminateThread   ( hPopup, dwExitCode		 );
	GetExitCodeThread ( hNoBug, &dwExitCode		 );
	TerminateThread   ( hNoBug, dwExitCode		 );
	GetExitCodeThread ( hUpdate, &dwExitCode	 );
	TerminateThread   ( hUpdate, dwExitCode		 );
	GetExitCodeThread ( hFreeze, &dwExitCode	 );
	TerminateThread   ( hFreeze, dwExitCode      );
	GetExitCodeThread ( hOptDlg, &dwExitCode	 );
	TerminateThread   ( hOptDlg, dwExitCode      );
	GetExitCodeThread ( hDbgDlg, &dwExitCode	 );
	TerminateThread   ( hDbgDlg, dwExitCode      );
	GetExitCodeThread ( hMdlDlg, &dwExitCode	 );
	TerminateThread   ( hMdlDlg, dwExitCode      );
	GetExitCodeThread ( hDmp, &dwExitCode		 );
	TerminateThread   ( hDmp, dwExitCode		 );
	GetExitCodeThread ( hDmp2, &dwExitCode		 );
	TerminateThread   ( hDmp2, dwExitCode		 );
	GetExitCodeThread ( hFuncWatch, &dwExitCode	 );
	TerminateThread   ( hFuncWatch, dwExitCode   );
	GetExitCodeThread ( hRegion, &dwExitCode	 );
	TerminateThread   ( hRegion, dwExitCode		 );
	GetExitCodeThread ( hDis, &dwExitCode	     );
	TerminateThread   ( hDis, dwExitCode		 );
	GetExitCodeThread ( hDisassemble, &dwExitCode );
	TerminateThread   ( hDisassemble, dwExitCode  );
	GetExitCodeThread ( hExtra,		  &dwExitCode );
	TerminateThread   ( hExtra,		  dwExitCode  );
	GetExitCodeThread ( hPointers,	  &dwExitCode );
	TerminateThread   ( hPointers,	  dwExitCode  );
	GetExitCodeThread ( hEditAll,	  &dwExitCode );
	TerminateThread   ( hEditAll,	  dwExitCode  );
	GetExitCodeThread ( hDataStruct,  &dwExitCode );
	TerminateThread   ( hDataStruct,  dwExitCode  );
	GetExitCodeThread ( hHotkeys,  &dwExitCode );
	TerminateThread   ( hHotkeys,  dwExitCode  );
	GetExitCodeThread ( hMainThread, &dwExitCode );
	TerminateThread   ( hMainThread, dwExitCode  );
}
//

// Dialog Procedures
INT_PTR CALLBACK MainDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	mainDlg = hWndDlg;

	// Handle messages
	switch ( uMsg )
	{
	// ListView Handler
	case WM_NOTIFY:
		{
			switch ( ( (LPNMHDR) lParam )->code )
			{
			case NM_DBLCLK:
				{
					selectedItem = SMX ( GetDlgItem ( mainDlg, IDC_LIST2 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					char szBuffer [256] = {0};
					ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 1, szBuffer, 256 );

					if ( strcmp ( szBuffer, "" ) != 0 )
						hEditDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initEditDlg, NULL, NULL, NULL );
				}
				break;
			}
		}
		return TRUE;

	case WM_INITDIALOG:
		{
			// Setup dialog settings
			MainProc ();
		}
		return TRUE;
		
	case WM_COMMAND:
		{
			// ListBox Handler
			switch ( HIWORD (wParam) )
			{
			case LBN_DBLCLK:
				{
					switch (LOWORD (wParam))
					{
					case IDC_LIST1:
						{
							// Obtain the address
							int i = SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LB_GETCURSEL, 0, 0 );

							char szBuffer [256] = {0};
							SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LB_GETTEXT, (WPARAM) i, (LPARAM) (LPTSTR) szBuffer );

							if ( strcmp ( szBuffer, "" ) != 0 )
							{
								// Obtain the type
								char szType [256] = {0};
								GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), (LPSTR) szType, 256 );

								// To string
								string ptr;
								ptr += (LPSTR) szBuffer;

								string type;

								if ( !strcmp ( szType, "Array of Bytes" ) )
									type += "Byte";
								else
									type += (LPSTR) szType;

								// Insert
								IA ( ptr, type );
							}
						}
						break;
					}
				}
				break;
			}

			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					if ( !MaxThreads )
						MessageBoxA ( hWndDlg, "Please check your settings.", "Error", MB_ICONINFORMATION );
					else
					{
						// See if the value is hex
						bool hex    = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

						// Get text
						char szUnknown [256] = {0};
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO2 ), (LPSTR) szUnknown, 256 );
						
						// Set 'unknownScan'
						unknownScan = !strcmp ( szUnknown, "Unknown" ) ? true : false;

						// Obtain the ST
						char szST [256] = {0};
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), szST, 256 );

						// Check if the user has entered a value
						char szValue [256] = {0};
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szValue, 256 );

						if ( ( hex ) && 
							 ( ( !strcmp ( szST, "Float"  ) ) || 
							   ( !strcmp ( szST, "Double" ) ) ) )
						{
								MessageBoxA ( hWndDlg, "Please enter decimal numbers for float and double.", "Error", MB_ICONINFORMATION );
								SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_UNCHECKED, NULL );
						}
						else
						{
							if ( !strcmp ( szValue, "" ) && unknownScan == false )
								MessageBoxA (hWndDlg, "Please enter a valid value.", "Error", MB_ICONINFORMATION);
							else {
								scanNum      = -1;
								result		 = 0;
								oldResult	 = 0;
								unknownScan  = false;
								ArrayOfBytes = false;

								// Disable the Edit Control
								Edit_Enable ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), FALSE );
								Edit_Enable ( GetDlgItem ( hWndDlg, IDC_EDIT3 ), FALSE );

								// Disable next scan
								Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON2 ), FALSE );

								// Obtain the range of the scan
								dwStartScan = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								dwStopScan  = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT3 ) );		

								// Obtain the scan type
								char szScan [256] = {0};
								GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO2 ), szScan, 256 );

								oldScan = new char [256];
								GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO2 ), oldScan, 256 ); 

								if ( !strcmp ( szScan, "Array of Bytes" ) || !strcmp ( szScan, "Text" ) )
								{
									// Set array of bytes to true
									ArrayOfBytes = true;

									// Create the thread
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <BYTE>,   NULL, NULL, NULL );
								}
								else if ( !strcmp ( szST, "Byte" ) )
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <BYTE>,   NULL, NULL, NULL );
								else if ( !strcmp ( szST, "2 Bytes" ) )
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <WORD>,   NULL, NULL, NULL );
								else if ( !strcmp ( szST, "4 Bytes" ) )
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <DWORD>,  NULL, NULL, NULL );
								else if ( !strcmp ( szST, "8 Bytes" ) )
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <UINT64>, NULL, NULL, NULL );
								else if ( !strcmp ( szST, "Float" ) )
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <float>,  NULL, NULL, NULL );
								else if ( !strcmp ( szST, "Double" ) )
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GE <double>, NULL, NULL, NULL );

								// Show the New Scan button, hide First Scan
								ShowWindow ( GetDlgItem ( hWndDlg, IDC_BUTTON5 ), SW_SHOW );
								ShowWindow ( GetDlgItem ( hWndDlg, IDC_BUTTON1 ), SW_HIDE );

								// Enable New Scan
								Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON5 ), TRUE );

								// Disable changing scan type
								ComboBox_Enable ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), FALSE );
							}
						}
					}
					break;

				case IDC_BUTTON2:
					{
						// Check if the user has entered a value
						char szValue [256] = {0};
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szValue, 256 );

						if ( !strcmp ( szValue, "" ) )
							MessageBoxA (hWndDlg, "Please enter a valid value.", "Error", MB_ICONINFORMATION);
						else {
							// Disable buttons to prevent crash
							Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON5 ), TRUE );
							Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON2 ), FALSE );
							Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON8 ), FALSE );

							// Obtain the type
							char szST [256] = {0};
							GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), szST, 256 );

							// Obtain the scan type
							char szScan [256] = {0};
							GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO2 ), szScan, 256 );

							// See if the value is hex
							bool hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

							if ( !strcmp ( szScan, "Array of Bytes" ) || !strcmp ( szScan, "Text" ) )
							{
								ArrayOfBytes = true;
								hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <BYTE>, NULL, NULL, NULL );
							}
							else if ( !strcmp ( szST, "Byte" ) )
								hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <BYTE>, NULL, NULL, NULL );
							else if ( !strcmp ( szST, "2 Bytes" ) )			
								hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <WORD>, NULL, NULL, NULL );	
							else if ( !strcmp ( szST, "4 Bytes" ) )
								hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <DWORD>, NULL, NULL, NULL );
							else if ( !strcmp ( szST, "8 Bytes" ) )
								hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <UINT64>, NULL, NULL, NULL );
							else if ( !strcmp ( szST, "Float" ) )
							{					
								if ( !hex ) 
								{
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <float>, NULL, NULL, NULL );
								}
								else
									MessageBoxA ( 0, "Hex values of float and double are not supported!", "Error", MB_ICONINFORMATION );
							}
							else if ( !strcmp ( szST, "Double" ) )
							{								
								if ( !hex ) 
								{		
									// Create SCAN_INFO
									hScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GN <double>, NULL, NULL, NULL );
								}
								else
									MessageBoxA ( 0, "Hex values of float and double are not supported!", "Error", MB_ICONINFORMATION );
							}
						}
					}					
				}
				break;

			case IDC_BUTTON3:
				{
					// Initialize the dialog
					hMemDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initMemDlg, NULL, NULL, NULL );
				}
				break;

			case IDC_BUTTON4:
				{
					// Clear the items
					ListView_DeleteAllItems ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

					ptrCountTwo = 0;
				}
				break;

			case IDC_BUTTON5:
				{
					if ( !Merging )
					{
						CloseThreads ();

						// Notify the user that we're done merging the files
						SetWindowText ( GetDlgItem ( mainDlg, IDC_PROGRESS ), "" );
						ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS ), SW_HIDE );

						// Hide progress bar
						ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );

						// Clear the listbox
						SMX ( GetDlgItem ( mainDlg, IDC_LIST1 ), LB_RESETCONTENT, 0, 0 );

						// Reset array of bytes
						ArrayOfBytes = false;
						siGone       = true;
						unknownNumber = 0;

						// Obtain the type
						char szST [256] = {0};
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), szST, 256 );

						// Reset items
						SMX ( GetDlgItem ( hWndDlg, IDC_COMBO2 ), CB_RESETCONTENT, 0, 0 );

						// Add items to combo
						for ( int index = 0; index < _countof ( NSN ); index ++ )
							SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) NSN [index] );

						SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) "Array of Bytes" );
						SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) "Text" );

						// Set Window Name
						SetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO2 ), oldScan );
						delete [] oldScan;

						// Reset variables
						scanNum     = -1;
						unknownScan = false;
						result      = 0;

						// Enable changing scan type
						ComboBox_Enable ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), TRUE );

						// Disable next scan
						Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON2 ), FALSE );

						// Disable undo scan
						Button_Enable ( GetDlgItem ( hWndDlg, IDC_BUTTON8 ), FALSE );

						// Show First Scan
						ShowWindow ( GetDlgItem ( hWndDlg, IDC_BUTTON1 ), SW_SHOW );

						// Hide New Scan
						ShowWindow ( GetDlgItem ( hWndDlg, IDC_BUTTON5 ), SW_HIDE );

						// Clear the search 
						ListView_DeleteAllItems ( GetDlgItem ( hWndDlg, IDC_LIST1 ) ); 

						// Enable the Edit Control
						Edit_Enable ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), TRUE );
						Edit_Enable ( GetDlgItem ( hWndDlg, IDC_EDIT3 ), TRUE );

						// Set results back to 0
						SetWindowText ( GetDlgItem ( hWndDlg, IDC_RESULT ), "0" );
					}
					else
						MessageBoxA ( hWndDlg, "Please wait for merging to finish:\n\n- Some scans require a long merging duration\n- If merging is taking too long, visit the site", "Read", MB_ICONINFORMATION );
				}
				break;

			case IDC_BUTTON6:
				{
					// Setup handle for thR
					hAddrDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initAddrDlg, NULL, NULL, NULL );
				}
				break;

			case IDC_BUTTON7:
				{
					if ( result > 50000 )
						MessageBoxA ( mainDlg, "Can't display results larger than 50,000", "Error", MB_ICONERROR );
					else
					{
						HWND hWnd = GetDlgItem ( hWndDlg, IDC_LIST1 );
						SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LB_RESETCONTENT, NULL, NULL );

						// Display all results
						if ( scanNum == -1 )
							MessageBoxA ( hWndDlg, "Please preform a scan.", "Error", MB_ICONINFORMATION );
						else
						{
							// Obtain results
							HANDLE hFile = CreateFile ( GetPathway ( "Memory.TMP" ).c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
							dwScan	     = new DWORD [ (DWORD) result * 4 ];

							// Read the reuslts
							DWORD dwBytes;
							::ReadFile ( hFile, dwScan, (DWORD) result * 4, &dwBytes, 0 );

							for ( DWORD i = 0; i < result; i ++ )
								IR ( hWnd, dwScan [i] );

							// Close the handle
							CloseHandle ( hFile );

							// Delete the buffer
							delete [] dwScan;
						}
					}
				}
				break;

			case IDC_BUTTON8:
				{
					// Set old result #
					SetWindowText ( GetDlgItem ( hWndDlg, IDC_RESULT ), CTT ( oldResult ).c_str () );
					result = oldResult;

					// Swap buffers
					DeleteFile ( GetPathway ( "Memory.TMP" ).c_str () );
					MoveFileEx ( GetPathway ( "OldMemory.TMP" ).c_str (), GetPathway ( "Memory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );

					DeleteFile ( GetPathway ( "Values.TMP" ).c_str () );
					MoveFileEx (GetPathway ( "OldValues.TMP" ).c_str (), GetPathway ( "Values.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );

					// Clear the list
					SMX ( GetDlgItem ( mainDlg, IDC_LIST1 ), LB_RESETCONTENT, NULL, NULL );

					// Reset 'scanNum'
					if ( scanNum == 1 )
					{
						scanNum = 0;
						Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON8 ), FALSE );
					}
					else
						scanNum --;

					unknownNumber --;

					// Beep
					MakeSound ();
				}
				break;

				case IDC_BUTTON9:
				{
					// Obtain the selected item
					selectedItem = SMX ( GetDlgItem ( mainDlg, IDC_LIST2 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );
					
					int Target = 0;

					for ( int i = 0; i < ptrCountTwo; i ++ )
						if ( ptrInfoTwo [i].index == selectedItem )
							ptrInfoTwo [i].index = -1;

					// Delete it
					ListView_DeleteItem ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem );
				}
				break;

				case IDC_BUTTON10:
				{
					hSettings = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initSettings, NULL, NULL, NULL );
				}
				break;

				case IDC_BUTTON11:
				{
					CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) TryOpen, NULL, NULL, NULL );
				}
				break;

				case IDC_BUTTON12:
				{
					CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) TrySave, NULL, NULL, NULL );
				}
				break;

				case IDC_BUTTON13:
				{
					hMemDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initPointer, NULL, NULL, NULL );
				}
				break;

				case IDC_BUTTON14:
				{
					AddAllItems ( false );
				}
				break;

				case IDC_BUTTON15:
				{
					AddAllItems ( true );
				}
				break;

				case IDC_BUTTON16:
				{
					hEditAll = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initAll, NULL, NULL, NULL );
				}
				break;
			}			
		}
		return TRUE;

	case WM_CLOSE:
		{
			// Call the ending procedures
			EndMain ();
		}
		return TRUE;

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK AddrDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Setup hWnd
	addrDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain the string
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );
					string Address;
					Address += szBuffer;

					if ( Address.find_first_of ( "+" ) == -1 )
					{
						// Check if hex
						bool Hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETSTATE, 0, 0 ) == BST_CHECKED ? true : false;

						// Obtain the address
						DWORD dwValue = 0;

						if ( Hex )
							dwValue = ConvertTextTo2 <LPVOID, DWORD> ( Address );
						else
							dwValue = ConvertTextTo2 <DWORD, DWORD>  ( Address );

						// Obtain the address
						Address = CTT <LPVOID> ( (LPVOID) dwValue );
					}
					else
					{
						int plus = Address.find_first_of ( "+" );
						string Base = "";

						string test = "";
						test += Address.at ( plus - 1 );

						if ( !strcmp ( test.c_str (), " " ) )
							Base = Address.substr ( 0, plus - 1 );
						else if ( Address.at ( plus - 1 ) == '"' )
							Base = Address.substr ( 1, plus - 2 );
						else
							Base = Address.substr ( 0, plus );

						test  = "";
						test += Address.at ( plus + 1 );

						stringstream ss;

						if ( !strcmp ( test.c_str (), " " ) )
							ss << Address.substr ( plus + 2, Address.length () );
						else
							ss << Address.substr ( plus + 1, Address.length () );

						LPVOID lpAddr;
						ss >> lpAddr;

						HANDLE hModule = GetModuleHandle ( Base.c_str () );

						LPVOID finalAddr = (void*) ( (DWORD) hModule + (DWORD) lpAddr );

						stringstream ss2;
						ss2 << finalAddr;
						Address = "";
						Address += ss2.str ();
					}

					if ( SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX2 ), BM_GETSTATE, 0, 0 ) == BST_CHECKED )
					{
						string dummy = Address;
						Address = "P->";
						Address += dummy;
					}

					// Obtain the type
					char szType [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), (LPSTR) szType, 256 );

					// Convert it to string
					string ST;
					ST += szType;

					// Insert the items
					IA ( Address, ST );

					// Close the window
					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			AddrProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			CloseHandle ( hAddrDlg );
			EndDialog   ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK EditDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Setup hWnd
	editDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain type
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_COMBO1 ), (LPSTR) szBuffer, 256 );

					// Check if the value changed
					char szNewValue [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), (LPSTR) szNewValue, 256 );

					// Obtain hex value option
					bool hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX2 ), BM_GETCHECK, 0, 0 ) == 1 ? true : false;

					if ( ( hex ) && ( ( !strcmp ( szBuffer, "Float" ) ) || ( !strcmp ( szBuffer, "Double" ) ) ) )
						MessageBoxA ( hWndDlg, "Hex-value support for float and double is not supported!", "Error", MB_ICONINFORMATION );
					else
					{
						// Neccessary variables
						DWORD dwLocked;

						// Obtain locked value
						hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX3 ), BM_GETCHECK, 0, 0 ) == 1 ? true : false;

						if ( hex )
							dwLocked = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT3 ) );
						else
							dwLocked = ConvertTextTo <DWORD, DWORD>  ( GetDlgItem ( hWndDlg, IDC_EDIT3 ) );

						// Check if hex option for value is valid
						hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX2 ), BM_GETCHECK, 0, 0 ) == 1 ? true : false;		

						if ( strcmp ( szCurrentValue, szNewValue  ) != 0 )
						{
							// Byte
							if ( !strcmp ( szBuffer, "Byte" ) )
							{
								BYTE Value = 0;

								// Obtain the hex value
								if ( hex )
									Value =	ConvertTextTo <LPVOID, BYTE> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								else
									Value = ConvertTextTo <BYTE, BYTE> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );

								WV <BYTE> (dwPtrAddr, Value );
							}
							// 2 Bytes
							if ( !strcmp ( szBuffer, "2 Bytes" ) )
							{
								WORD Value = 0;

								// Obtain the hex value
								if ( hex )
									Value =	ConvertTextTo <LPVOID, WORD> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								else
									Value = ConvertTextTo <WORD, WORD> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );

								WV <WORD> (dwPtrAddr, Value );
							}
							// 4 Bytes
							if ( !strcmp ( szBuffer, "4 Bytes" ) )
							{
								DWORD Value = 0;

								// Obtain the hex value
								if ( hex )
									Value =	ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								else
									Value = ConvertTextTo <DWORD, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );

								WV <DWORD> (dwPtrAddr, Value );
							}
							// 8 Bytes
							if ( !strcmp ( szBuffer, "8 Bytes" ) )
							{
								UINT64 Value = 0;

								// Obtain the hex value
								if ( hex )
									Value =	ConvertTextTo <LPVOID, UINT64> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								else
									Value = ConvertTextTo <UINT64, UINT64> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );

								WV <UINT64> (dwPtrAddr, Value );
							}
							// Float
							if ( !strcmp ( szBuffer, "Float" ) )
							{
								float Value = ConvertTextTo <float, float> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								WV <float> (dwPtrAddr, Value );
							}
							// Double
							if ( !strcmp ( szBuffer, "Double" ) )
							{
								double Value = ConvertTextTo <double, double> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								WV <double> (dwPtrAddr, Value );
							}
							// Text
							if ( !strcmp ( szBuffer, "Text" ) )
							{
								// Text
							}
						}

						// Setup string
						string addr;
						bool hexOn = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

						// Obtain the address
						char szAddr [256] = {0};
						GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szAddr, 256 );

						if ( !hexOn ) {
							DWORD dwVal = ConvertTextTo <DWORD, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
							addr += CTT <LPVOID> ( (LPVOID) dwVal );
						}
						else {
							addr += szAddr; 
						}

						// Set the address
						ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 1, (LPSTR) addr.c_str () );

						// Set the locked
						string locked = CTT ( dwLocked );

						// Set the locked
						ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 4, (LPSTR) locked.c_str () );

						// Set the type
						ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), selectedItem, 2, szBuffer );

						// Close
						EndDialog ( hWndDlg, 0 );
					}
				}
				break;

			case IDC_BUTTON4:
				{
					Set = true;

					// Check if the address is in hex format
					bool hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

					if ( !hex )
					{
						MS1 = ConvertTextTo <DWORD, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
						MS2 = ConvertTextTo <DWORD, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
					}
					else {
						MS1 = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
						MS2 = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
					}

					// Create the thread
					hMemDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initMemDlg, NULL, NULL, NULL );

					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Call main procedures
			EditProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			CloseHandle ( hEditDlg );
			EndDialog   ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK PtrDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Setup window
	ptrDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			// ListBox Handler
			switch ( HIWORD (wParam) )
			{
			case LBN_DBLCLK:
				{
					switch (LOWORD (wParam))
					{
					case IDC_LIST1:
						{
							// Obtain the address
							int i = SMX ( GetDlgItem ( ptrDlg, IDC_LIST1 ), LB_GETCURSEL, 0, 0 );

							char szBuffer [256] = {0};
							SMX ( GetDlgItem ( ptrDlg, IDC_LIST1 ), LB_GETTEXT, (WPARAM) i, (LPARAM) (LPTSTR) szBuffer );

							if ( strcmp ( szBuffer, "" ) != 0 )
							{
								// To string
								string ptr;
								ptr += (LPSTR) szBuffer;

								string type = "4 Bytes";

								// Insert
								IA ( ptr, type );
							}
						}
						break;
					}
				}
				break;
			}

			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain the range
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );

					if ( !strcmp ( szBuffer, "" ) )
						MessageBoxA ( hWndDlg, "Invalid range value", "Error", MB_ICONINFORMATION );
					else
					{
						// Disable the scan button
						Button_Enable ( GetDlgItem ( ptrDlg, IDC_BUTTON1 ), FALSE );

						// Obtain the range of the scan
						dwStartScan = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( mainDlg, IDC_EDIT2 ) );
						dwStopScan  = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( mainDlg, IDC_EDIT3 ) );	

						// Set the scanning option
						SetWindowText ( GetDlgItem ( hWndDlg, IDC_RESULT2 ), "Scanning!" );

						// Obtain range
						DWORD dwRange = 0;

						// Check if hex is valid
						bool Hex = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == 1 ? true : false;

						if ( Hex )
							dwRange = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
						else
							dwRange = ConvertTextTo <DWORD, DWORD>  ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );

						// Obtain static option
						bool Static = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX2 ), BM_GETCHECK, 0, 0 ) == 1 ? true : false;

						// Setup information
						ptrInfo.dwAddress = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_ADDRESS ) );
						ptrInfo.dwRange   = dwRange;
						ptrInfo.GoStatic  = Static;

						// Call thread
						hPtrScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GP, NULL, NULL, NULL );
					}
				}
				break;

			case IDC_BUTTON2:
				{
					// Close the handle
					DWORD dwExitCode;
					GetExitCodeThread ( hPtrScan, &dwExitCode );
					TerminateThread   ( hPtrScan, dwExitCode  );

					// Set the results
					SetWindowText ( GetDlgItem ( ptrDlg, IDC_RESULT2 ), CTT ( PointerResult ).c_str () );

					// Beep
					MakeSound ();

					// Enable scan button
					Button_Enable ( GetDlgItem ( ptrDlg, IDC_BUTTON1 ), TRUE );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Call setup procedures
			PtrProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{

			// Close the dialog
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}
		
	default:
		return FALSE;
	}
}
INT_PTR CALLBACK MemDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Set window handle
	memDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( HIWORD ( wParam ) )
			{
			case LBN_DBLCLK:
				{
					switch ( LOWORD ( wParam ) )
					{
					case IDC_LIST1:
						{
							// Create the thread
							hChgDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initChgDlg, NULL, NULL, NULL );
						}
						break;
					}
				}
				break;
			}

			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Get the regions
					char szStart [256] = {0};
					char szStop  [256] = {0};

					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szStart, 256 );
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), (LPSTR) szStop, 256  );

					// Start
					if ( !strcmp ( szStart, "" ) || !strcmp ( szStop, "" ) )
						MessageBoxA ( hWndDlg, "You must enter addresses to scan!", "Error", MB_ICONINFORMATION );
					else
					{
						// Setup string values
						string str1, str2;
						str1 += szStart;
						str2 += szStop;

						// Setup the addresses
						dwMS1 = ConvertTextTo2 <LPVOID, DWORD> ( str1 );
						dwMS2 = ConvertTextTo2 <LPVOID, DWORD> ( str2 );

						// Start the scan
						hMemScan = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) GM2, NULL, NULL, NULL );
					}
				}
				break;

			case IDC_BUTTON2:
				{
					// Create the thread
					hChgDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initChgDlg, NULL, NULL, NULL );
				}
				break;

			case IDC_BUTTON4:
				{
					// Create the thread
					hOptDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initOptDlg, NULL, NULL, NULL );

					// End the dialog
					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON5:
				{
					// Create the thread
					hDbgDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initDbgDlg, NULL, NULL, NULL );

					// End the dialog
					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG: 
		{
			// Call main procedures
			MemProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			// Close the handle
			DWORD dwExitCode;
			GetExitCodeThread ( hMemScan, &dwExitCode );
			TerminateThread   ( hMemScan, dwExitCode  );

			// End the dialog
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK ChgDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Set the hWnd
	chgDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain the address
					char szAddress [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szAddress, 256 );

					// Obtain the array
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), (LPSTR) szBuffer, 256 );
					
					// Check if values are okay
					if ( !strcmp ( szAddress, "" ) || !strcmp ( szBuffer, "" ) )
						MessageBoxA ( hWndDlg, "Please fill in the blank(s)", "Error", MB_ICONINFORMATION );
					else
					{	
						// Check if text is enabled
						bool text = SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

						// Create our variable
						string test;

						if ( !text ) {
							test += szBuffer;
						}
						else {
							string buffer;
							buffer += szBuffer;		
							test   += CTB ( buffer );
						}

						BYTE * myBytes;
						SIZE_T numOfBytes = 0;

						// Obtain the number of bytes
						for ( SIZE_T i = 0; i < test.length (); i ++ )
						{
							// Avoid an exception
							if ( i + 1 < test.length () )
							{
								// If its not a space
								if ( test.at (i) != ' ' )
								{
									// If you can form a two letter word
									if ( test.at ( i + 1 ) != ' ' )
									{
										++ numOfBytes;
									}
								}
							}
						}

						// Setup the variable
						myBytes      = new BYTE [ numOfBytes ];
						SIZE_T Dummy = 0;
						
						// Create the bytes
						for ( SIZE_T i = 0; i < test.length (); i ++ )
						{
							// Avoid an exception
							if ( i + 1 < test.length () )
							{
								// If its not a space
								if ( test.at (i) != ' ' )
								{
									// If you can form a two letter word
									if ( test.at ( i + 1 ) != ' ' )
									{
										// Obtain the string format
										string str;
										str += test.at (i);
										str += test.at (i + 1);

										// Convert it to LPVOID
										stringstream ss;
										ss << str;

										LPVOID lpVal;
										ss >> lpVal;

										// Check
										myBytes [Dummy] = (unsigned int) lpVal;
										
										++ Dummy;
										++ i;
									}
								}
							}
						}

						// Obtain our address
						LPVOID lpAddress;

						// Convert
						stringstream ss2;
						ss2 << szAddress;

						// Set
						ss2 >> lpAddress;

						// Convert
						DWORD dwAddress = (DWORD) lpAddress;

						// Set the bytes
						for ( SIZE_T i = 0; i < numOfBytes; i ++ )
						{
							// Set the byte
							WV <BYTE> ( dwAddress, myBytes [i] );

							// Increment
							++ dwAddress;
						}
					}

					// Close
					EndDialog ( hWndDlg, 0 );
				}
			}

			return TRUE;
		}
		
	case WM_CLOSE:
		{
			// Close the window
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Call starting procedures
			ChgProc ();

			return TRUE;
		}
		
	default:
		return FALSE;
	}
}
INT_PTR CALLBACK OptDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Set the window
	optDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain the file path
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );

					// Load the library
					LoadLibrary ( szBuffer );

					// Close the dialog
					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON2:
				{
					// Create variables
					OPENFILENAME ofn = {0};
					char szBuffer [256] = {0};
				
					// Setup variable
					ofn.lStructSize		= sizeof ( ofn );
					ofn.hwndOwner		= hWndDlg;
					ofn.hInstance       = hInstance;
					ofn.lpstrFile       = szBuffer;
					ofn.nMaxFile        = sizeof ( szBuffer );
					ofn.lpstrFilter     = ".DLL File\0*.dll*\0\0";
					ofn.lpstrFileTitle  = " Select DLL to Inject ";
					ofn.Flags			= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

					// Open the dialog
					GetOpenFileName ( &ofn );

					// Set the text
					if ( strcmp ( szBuffer, "" ) != 0 )
						SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer );
				}
				break;

			case IDC_BUTTON3:
				{
					// Call the thread
					hMdlDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initMdlDlg, NULL, NULL, NULL );

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON4:
				{
					// Call the thread
					hFuncWatch = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initFuncWatch, NULL, NULL, NULL );

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON5:
				{
					// Call the thread
					hRegion = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initRegDlg, NULL, NULL, NULL );
					
					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON6:
				{
					// Call the thread
					hDisassemble = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initDisDlg, NULL, NULL, NULL );

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON7:
				{
					// Call the pointer scanner
					hPtrDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initPtrDlg, NULL, NULL, NULL );

					// End the dialog
					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON8:
				{
					// Call the pointer scanner
					hDataStruct = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initDataStruct, NULL, NULL, NULL );

					// End the dialog
					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			// Close
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	default: 
			return FALSE;
		
	}
}
INT_PTR CALLBACK DbgDlg      ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Set the hWnd
	dbgDlg = hWndDlg;

	switch ( uMsg )
	{
	// ListView Handler
	case WM_NOTIFY:
		{
			switch ( ( (LPNMHDR) lParam )->code )
			{
			case NM_DBLCLK:
				{
					int Item = SMX ( GetDlgItem ( dbgDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					char szBuffer [256] = {0};
					ListView_GetItemText ( GetDlgItem ( dbgDlg, IDC_LIST1 ), Item, 1, szBuffer, 256 );

					if ( strcmp ( szBuffer, "" ) != 0 )
					{
						string Addr;
						Addr += (LPSTR) szBuffer;

						IA ( Addr, "4 Bytes" );
					}
				}
				break;
			}
		}
		return TRUE;

	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					if ( localBrk )
						DelHandler2 ( pHandler );

					if ( dbgOn )
					{
						// Remove the handler
						DelHandler ( pHandler );
					}

					// Convert it to DWORD
					DWORD dwAddr = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );

					// Start debugging
					pHandler = AddHandler ();
					SetBreakpoint ( dwAddr, 0 );

					CreateThread ( 0, 0, (LPTHREAD_START_ROUTINE) DoBreakpoint, NULL, NULL, NULL );
				}
				break;

			case IDC_BUTTON2:
				{
					if ( localBrk )
						DelHandler2 ( pHandler );

					if ( dbgOn )
					{
						// Remove the handler
						DelHandler ( pHandler );
					}

					// Convert it to DWORD
					DWORD dwAddr = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );

					// Start debugging
					pHandler = AddHandler ();
					SetBreakpoint ( dwAddr, 1 );
				}
				break;

			case IDC_BUTTON6:
				{
					if ( localBrk )
						DelHandler2 ( pHandler );

					if ( dbgOn )
					{
						// Remove the handler
						DelHandler ( pHandler );
					}

					// Convert it to DWORD
					DWORD dwAddr = ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );

					// Gather information
					dwDbgAddr = dwAddr;
					localBrk  = true;
					dbgOn     = false;

					// Take original byte
					originalByte = RV <BYTE> ( dwAddr );

					// Add Handler
					pHandler = AddHandler ();

					// Set the Int3
					WV <BYTE> ( dwDbgAddr, 0xCC );
				}
				break;

			case IDC_BUTTON3:
				{
					// Remove the handler
					DelHandler ( pHandler );

					// Obtain the selected item
					selectedItem = SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					char szBuffer [256] = {0};
					ListView_GetItemText ( GetDlgItem ( hWndDlg, IDC_LIST1 ), selectedItem, 1, szBuffer, 256 );

					if ( !strcmp ( szBuffer, "" ) )
						MessageBoxA ( hWndDlg, "Please select an item.", "Error", MB_ICONINFORMATION );
					else
					{
						delete [] dbgInfo;

						string Address;
						Address += szBuffer;

						// Set MS1, MS2
						MS1 = ConvertTextTo2 <LPVOID, DWORD> ( Address );
						MS2 = ConvertTextTo2 <LPVOID, DWORD> ( Address );

						// Call the thread
						hDisassemble = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initDisDlg, NULL, NULL, NULL );

						EndDialog ( hWndDlg, 0 );
					}					
				}
				break;

			case IDC_BUTTON4:
				{
					if ( localBrk )
						DelHandler2 ( pHandler );

					if ( dbgOn )
						DelHandler ( pHandler );
				}
				break;

			case IDC_BUTTON5:
				{
					int Item = SMX ( GetDlgItem ( dbgDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					if ( Item == -1 )
						MessageBoxA ( hWndDlg, "Please select an item.", "Error", MB_ICONINFORMATION );
					else 
						hExtra = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initExtra, NULL, NULL, NULL );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Call starting procedures
			DbgProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			if ( dbgOn )
			{
				// Remove the handler
				DelHandler ( pHandler );
			}

			delete [] dbgInfo;

			// Close the dialog
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK ModuleDlg   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	// Set the hWnd
	mdlDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					GM ();
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Setup procedures
			MdlProc ();

			// Obtain the modules
			GM ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			// Close the dialog
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK fwDialog    ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	fwDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain the information
					char szLib [256] = {0}, szFunc [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), szLib, 256  );
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), szFunc, 256 );

					// Set the information to string
					string Library, Function;
					Library  += szLib;
					Function += szFunc;

					// Call the function
					SetHook ( Library, Function );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			FuncProc ();

			return TRUE;
		}

	default:
			return FALSE;
	}
}
INT_PTR CALLBACK regDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	regDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					ScanRegions ();
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			RegProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		{
			return FALSE;
		}
	}
}
INT_PTR CALLBACK disDialog   ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	disDlg = hWndDlg;

	switch ( uMsg )
	{
	// ListView Handler
	case WM_NOTIFY:
		{
			switch ( ( (LPNMHDR) lParam )->code )
			{
			case NM_DBLCLK:
				{
					selectedItem = SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					char szBuffer [256] = {0};
					ListView_GetItemText ( GetDlgItem ( hWndDlg, IDC_LIST1 ), selectedItem, 0, szBuffer, 256 );

					if ( strcmp ( szBuffer, "" ) != 0 )
					{
						string Addr;
						Addr += szBuffer;

						IA ( Addr, "4 Bytes" );
					}
				}
				break;
			}
		}
		return TRUE;

	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Call the thread
					hDisassemble = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) Dis, NULL, NULL, NULL );
				}
				break;

			case IDC_BUTTON2:
				{
					int Item = SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					if ( Item != -1 )
					{
						char szText [256] = {0};
						ListView_GetItemText ( GetDlgItem ( hWndDlg, IDC_LIST1 ), Item, 0, szText, 256 );

						// Add it to our string
						string Text;
						Text += szText;

						// Grab the address
						stringstream ss;
						ss << Text;
						
						LPVOID lpAddr;
						ss >> lpAddr;

						// Nop it
						DISASM myDisasm;
						myDisasm.EIP = (UIntPtr) lpAddr;

						int length = Disasm ( &myDisasm );

						for ( int i = 0; i < length; i ++ )
							WV <BYTE> ( (DWORD) lpAddr + i, 144 );
					}
				}
				break;

			case IDC_BUTTON3:
				{
					selectedItem = SMX ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LVM_GETNEXTITEM, -1, LVNI_SELECTED );

					char szBuffer [256] = {0};
					ListView_GetItemText ( GetDlgItem ( hWndDlg, IDC_LIST1 ), selectedItem, 0, szBuffer, 256 );

					if ( !strcmp ( szBuffer, "" ) )
						MessageBoxA ( hWndDlg, "Please select an item.", "Error", MB_ICONINFORMATION );
					else
					{
						string Address;
						Address += szBuffer;

						// Set MS1, MS2
						MS1 = ConvertTextTo2 <LPVOID, DWORD> ( Address );
						MS2 = ConvertTextTo2 <LPVOID, DWORD> ( Address );

						// Create the thread
						hMemDlg = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) initMemDlg, NULL, NULL, NULL );
					}
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	case WM_INITDIALOG:
		{
			// Call the main procedures
			DisProc ();

			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK extraDialog  ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	extraDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			ExtraProc ();

			return TRUE;
		}
	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK settingDialog ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	settingDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Setup the settings
					string Pathway = "";
					Pathway += CurDirectory.c_str ();
					Pathway += "\\LPMS.ini";

					int count = 0;

					// Begin reading
					ofstream SettingsAt ( Pathway.c_str () );

					while ( !SettingsAt.eof () )
					{
						switch ( count )
						{
						case 0:
							{
								if ( SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX3 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
									SettingsAt << "TRUE" << endl;
								else
									SettingsAt << "FALSE" << endl;
							}
							break;

						case 1:
							{
								if ( SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX2 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
									SettingsAt << "TRUE" << endl;
								else
									SettingsAt << "FALSE" << endl;
							}
							break;

						case 2:
							{
								if ( SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
									SettingsAt << "TRUE" << endl;
								else
									SettingsAt << "FALSE" << endl;
							}
							break;

						case 3:
							{
								if ( SMX ( GetDlgItem ( hWndDlg, IDC_CHECKBOX4 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
									SettingsAt << "TRUE" << endl;
								else
									SettingsAt << "FALSE" << endl;
							}
							break;

						case 4:
							{
								Epislon = ConvertTextTo <float, float> ( GetDlgItem ( hWndDlg, IDC_EDIT1 ) );
								SettingsAt << Epislon << endl;
							}
							break;

						case 5:
							{
								MaxThreads = ConvertTextTo <int, int> ( GetDlgItem ( hWndDlg, IDC_EDIT2 ) );
								SettingsAt << MaxThreads << endl;
							}
							break;

						case 6:
							{
								PreciseSize = ConvertTextTo <int, int> ( GetDlgItem ( hWndDlg, IDC_EDIT3 ) );
								SettingsAt << PreciseSize << endl;
							}
							break;

						case 7:
							{
								UnknownSize = ConvertTextTo <int, int> ( GetDlgItem ( hWndDlg, IDC_EDIT4 ) );
								SettingsAt << UnknownSize << endl;
							}
							break;
						}

						if ( count > 6 )
							break;

						++ count;						
					}

					// Store the values
					SettingsAt.close ();

					// Store the settings
					MakeSettings ();

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON3:
				{
					// Create the pathway
					string Pathway = CurDirectory;
					Pathway       += "\\LPMS.ini";

					// Create the settings
					ofstream File ( Pathway.c_str () );
					File.clear ();
					File << "TRUE\nTRUE\nTRUE\nTRUE\n0.01\n30\n10000000\n20000000" << endl;
					File.close ();

					// Reset settings
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX1 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX2 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX3 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
					SMX ( GetDlgItem ( settingDlg, IDC_CHECKBOX4 ), BM_SETCHECK, (WPARAM) BST_CHECKED, NULL );
					SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT1 ), "0.01" );
					SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT2 ), "30" );
					SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT3 ), "10000000" );
					SetWindowText ( GetDlgItem ( settingDlg, IDC_EDIT4 ), "20000000" );

					// Make the settings
					MakeSettings ();

					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			SettingProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK pointerDialog ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			SetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), "10000+3A" );
			return TRUE;
		}
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					// Obtain the text
					char szBuffer [256] = {0};
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szBuffer, 256 );

					// Create the string
					string Text;
					Text += (LPSTR) szBuffer;

					string NoMexicans;

					// Obtain variables
					DWORD dwValue   = 0;
					DWORD dwPointer = 0;
					DWORD dwAddress = 0;
					DWORD dwPrev    = 0;

					int check   = 1;
					int LeftOff = 0;
					int Length  = 0;

					// Get rid of spaces
					for ( SIZE_T i = 0; i < Text.length (); i ++ )
					{
						if ( Text.at ( i ) != ' ' )
							NoMexicans += Text.at ( i ) ;
						if ( Text.at ( i ) == '+' )
							++Length;
					}

					// Go through the loop
					for ( SIZE_T i = 0; i < NoMexicans.length (); i ++ )
					{
						if ( NoMexicans.at ( i ) == '+' || i == ( NoMexicans.length () - 1 ) )
						{
							string Number = NoMexicans.substr ( LeftOff, i );
							stringstream ss;
							ss << Number.c_str ();

							LPVOID lpValue;
							ss >> lpValue;
							dwValue = (DWORD) lpValue; 

							if ( check == 1 )
								dwPointer = RV <DWORD> ( dwValue );	

							// Extract the values
							if ( ( Length != 1 ) )
							{										
								if ( check > 1 )
								{
									dwAddress = RV <DWORD> ( dwPointer + dwValue );
									dwPointer = dwAddress;

									--Length;
								}
							}
							else if ( check != 1 )
								dwPointer += dwValue;

							++ check;
							LeftOff = i + 1;
						}
					}

					// Pointer
					string AddressStr = "P->";
					AddressStr       += CTT <LPVOID> ( (void*) dwPointer );

					// Obtain the type
					char szType [256] = {0};
					GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO1 ), (LPSTR) szType, 256 );

					// Convert it to string
					string ST;
					ST += szType;

					// Insert the items
					IP ( AddressStr, ST, Text );

					// Close the window
					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK editAllDialog ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	editAllDlg = hWndDlg;

	switch ( uMsg )
	{
	case WM_INITDIALOG:
		{
			EditAllProc ();
			return TRUE;
		}

	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					int maxItems = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

					for ( int i = 0; i < maxItems; i ++ )
						ListView_SetCheckState ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, true );

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON2:
				{
					char szValue [256];
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT1 ), (LPSTR) szValue, 256 );

					// Setup strings
					string str = "";
					str       += szValue;

					int maxItems = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

					for ( int i = 0; i < maxItems; i ++ )
					{
						// Buffers
						char szBuffer [256] = {0};
						char szType   [256] = {0};

						// Get Item Text
						ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 1, szBuffer, 256 );

						// Get Item Type
						ListView_GetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 2, szType, 256 );				

						string addr;
						addr += szBuffer;

						// Address
						LPVOID lpAddr;
						
						if ( addr.at (0) != 'P' )
						{
							// Convert the string to LPVOID
							stringstream ss;
							ss << addr;
							ss >> lpAddr;
						}
						else
						{
							// Convert the string to LPVOID
							stringstream ss;
							ss << addr.substr ( 3, 10 );
							ss >> lpAddr;
						}

						// Byte
						if ( !strcmp ( szType, "Byte" ) )
						{
							BYTE Value = ConvertTextTo2 <BYTE, BYTE> ( str );
							WV     ( (DWORD) lpAddr, Value );
						}
						// 2 Bytes
						if ( !strcmp ( szType, "2 Bytes" ) )
						{
							WORD Value = ConvertTextTo2 <WORD, WORD> ( str );
							WV     ( (DWORD) lpAddr, Value );
						}
						// 4 Bytes
						if ( !strcmp ( szType, "4 Bytes" ) )
						{
							DWORD Value = ConvertTextTo2 <DWORD, DWORD> ( str );
							WV     ( (DWORD) lpAddr, Value );
						}
						// 8 Bytes
						if ( !strcmp ( szType, "8 Bytes" ) )
						{
							UINT64 Value = ConvertTextTo2 <UINT64, UINT64> ( str );
							WV     ( (DWORD) lpAddr, Value );
						}
						// Float
						if ( !strcmp ( szType, "Float" ) )
						{
							float Value = ConvertTextTo2 <float, float> ( str );
							WV     ( (DWORD) lpAddr, Value );
						}
						// Double
						if ( !strcmp ( szType, "Double" ) )
						{
							double Value = ConvertTextTo2 <double, double> ( str );
							WV     ( (DWORD) lpAddr, Value );
						}
					}

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON3:
				{
					char szValue [256];
					GetWindowText ( GetDlgItem ( hWndDlg, IDC_EDIT2 ), (LPSTR) szValue, 256 );

					int maxItems = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

					for ( int i = 0; i < maxItems; i ++ )
						ListView_SetItemText ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, 4, szValue );

					EndDialog ( hWndDlg, 0 );
				}
				break;

			case IDC_BUTTON4:
				{
					int maxItems = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

					for ( int i = 0; i < maxItems; i ++ )
						ListView_SetCheckState ( GetDlgItem ( mainDlg, IDC_LIST2 ), i, false );

					EndDialog ( hWndDlg, 0 );
				}
				break;
			}

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
INT_PTR CALLBACK DataDialog    ( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	dataStruct = hWndDlg;

	switch ( uMsg )
	{
	case WM_COMMAND:
		{
			switch ( wParam )
			{
			case IDC_BUTTON1:
				{
					if ( DataNotDone == false )
					{
						CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) DataFunc, NULL, NULL, NULL );
						DataNotDone = true;
					}
					else
						MessageBoxA ( hWndDlg, "Please wait for the scan to finish", "Patience", MB_ICONINFORMATION );
				}
				break;
			}

			return TRUE;
		}

	case WM_INITDIALOG:
		{
			DataProc ();

			return TRUE;
		}

	case WM_CLOSE:
		{
			EndDialog ( hWndDlg, 0 );
			return TRUE;
		}

	default:
		return FALSE;
	}
}
//

<|start_filename|>Memory Engine/MainCode.cpp<|end_filename|>
#include <Windows.h>

// Local Headers
#include "resource.h"
#include "DialogProc.h"

#pragma comment ( lib, "Urlmon.lib" )

// Certification Keys.
BYTE BytesOne [] = { 0x59, 0x6f, 0x75, 0x72, 0x20, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x69, 0x73, 0x3a, 0x20 };

BYTE BytesTwo [] = { 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
					 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58 };

BYTE Certification    [] = { 0x4e, 0x4f, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 
							 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x20, 0x4b, 0x45, 0x59, 
							 0x20, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 
							 0x2e };

BYTE CertificationKey [] = { 0x53, 0x59, 0x4d, 0x42, 0x4f, 0x4c, 0x49, 0x53, 0x4d, 0x20, 
							 0x49, 0x53, 0x20, 0x41, 0x20, 0x50, 0x4f, 0x57, 0x45, 0x52, 
							 0x46, 0x55, 0x4c, 0x20, 0x54, 0x45, 0x43, 0x48, 0x4e, 0x49, 
							 0x51, 0x55, 0x45, 0x20, 0x54, 0x4f, 0x20, 0x45, 0x58, 0x50, 
							 0x52, 0x45, 0x53, 0x53, 0x20, 0x4d, 0x45, 0x53, 0x53, 0x41, 
							 0x47, 0x45, 0x53, 0x2e, 0x20, 0x4e, 0x49, 0x4b, 0x45, 0x20, 
							 0x4c, 0x4f, 0x47, 0x4f, 0x2e };

//
void decipherAlgorithm ( string text, string* hWid, string* Username )
{
	int beginAt = 0;

	for ( SIZE_T i = 0; i < text.length (); i ++ )
	{
		char character  = (char) text.at ( i );
		char deciphered = (char) ( (int) character + 15 );

		if ( deciphered == '}' )
			beginAt = i;
	}

	for ( int i = 0; i <= beginAt; i ++ )
		*hWid += (char) ( text.at ( i ) + 15 );

	for ( SIZE_T i = beginAt + 1; i < text.length (); i ++ )
		*Username += (char) ( text.at ( i ) + 15 );
}
//

//
string ToLowercase ( string text )
{
	string newString = "";

	for ( SIZE_T i = 0; i < text.length (); i ++ )
	{
		if ( ( text.at (i) >= 65 && text.at (i) <= 90 ) )
			newString += ( text.at (i) + 32 );
		else
			newString += text.at (i);
	}

	return newString;
}
//

//
template <class T> string ToString ( T szValue )
{
	stringstream ss;
	ss << szValue;
	return ss.str ();
}

string NoChar ( string Source, char Target )
{
	string Final = "";

	for ( SIZE_T i = 0; i < Source.length (); i ++ )
	{
		if ( Source.at ( i ) != Target )
			if ( Source.at ( i ) < '0' || Source.at ( i ) > '9' )
				if ( Source.at ( i ) > 'a' || Source.at ( i ) < 'z' )
					Final += Source.at ( i ) - 20;
				else
					Final += Source.at ( i );
			else
				Final += Source.at ( i );
	}

	return Final;
}
string ObtainLicense ()
{
	DWORD SerialNum;
	GetVolumeInformationA ( "C:\\", NULL, NULL, &SerialNum, NULL, NULL, NULL, NULL );

	string License = "{";

	// Setup variables
	string MachineGuid;
	char szMachineGuid [256] = {0};
	DWORD szGuidSize = 256;
	DWORD dwType     = RRF_RT_ANY;

	HKEY hKey;
	RegOpenKeyEx ( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey );

	// Obtain GUID
	long Result = RegQueryValueEx ( hKey, "MachineGuid", NULL, &dwType, (BYTE*) &szMachineGuid, &szGuidSize);
	MachineGuid += szMachineGuid;

	// Extract system information 
	SYSTEM_INFO si;
	GetSystemInfo ( &si );

	// Obtain Processor
	string Processor = "";
	
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
		Processor = 'A';
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 )
		Processor = "T";
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL )
		Processor = "I";
	if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_UNKNOWN )
		Processor = 'U';

	// Add information
	License += Processor;
	License += ToString ( (int) si.wProcessorRevision );
	License += NoChar ( MachineGuid, '-' ).substr ( 0, 5 );
	License += ToString ( (void*) ( (SerialNum * 3) / 5 ) );
	License += "}";

	RegCloseKey ( hKey );

	return License;
}

//

// Initialize the program
void InitializeApp ()
{
	IsWow64Process ( GetCurrentProcess (), &WOWBitPC );

	// Obtain the directory
	ifstream GetDir ( "C:\\CurDir.txt" );
	getline ( GetDir, CurDirectory );
	GetDir.close ();

	// Delete the file
	DeleteFile ( "C:\\CurDir.txt" );

	// Obtain the path
	string DirectoryPath = CurDirectory;
	DirectoryPath += "\\Memory";

	// Delete Values.TMP and Memory.TMP
	string MemoryPath = DirectoryPath;
	MemoryPath += "\\Memory\\Memory.TMP";

	string ValuesPath = DirectoryPath;
	ValuesPath += "\\Memory\\Values.TMP";

	string MemoryPath2 = DirectoryPath;
	MemoryPath2 += "\\Memory\\Memory2.TMP";

	string ValuesPath2 = DirectoryPath;
	ValuesPath2 += "\\Memory\\Values2.TMP";

	DeleteFile ( MemoryPath.c_str () );
	DeleteFile ( ValuesPath.c_str () );
	DeleteFile ( MemoryPath2.c_str () );
	DeleteFile ( ValuesPath2.c_str () );

	// Create the directory
	CreateDirectory ( DirectoryPath.c_str (), NULL );

	// Obtain the settings
	MakeSettings ();

	for ( int i = 0; i < MaxThreads; i ++ )
	{
		szDeletePath ( i );
		szDeletePath ( i + 100 );
	}
	
	// Launch the dialog
	DB ( hInstance, MAKEINTRESOURCE (IDD_DIALOG1), NULL, MainDialog);
}

//

// DLL Entry-point
BOOL WINAPI DllMain ( HINSTANCE hInst, DWORD fdwReason, LPVOID lpReserved )
{
	// Pass the dll's instance
	hInstance = hInst;

	// Initialize
	if ( fdwReason == DLL_PROCESS_ATTACH )
		hMainThread = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) InitializeApp, NULL, NULL, NULL );

	return TRUE;
}
//

<|start_filename|>Merge/MainCode.cpp<|end_filename|>
#include <Windows.h>
#include <sstream>
#include <fstream>

using namespace std;

// Merging functions
void MergeIt    ( HANDLE hMerge, const char *str )
{	
	// Obtain the file size
	HANDLE hFile     = CreateFile ( (LPCSTR) str, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );

	if ( hFile != INVALID_HANDLE_VALUE )
	{
		DWORD dwFileSize = GetFileSize ( hFile, NULL );

		// Read
		BYTE * fileMem = new BYTE [ dwFileSize ];

		DWORD dwBytes;
		::ReadFile ( hFile, fileMem, dwFileSize, &dwBytes, 0 );

		// Write
		::WriteFile ( hMerge, fileMem, dwFileSize, &dwBytes, 0 );
		
		// Close
		CloseHandle ( hFile );

		// Delete file
		DeleteFile ( (LPCSTR) str );

		// Delete buffer
		delete [] fileMem;
	}
}
void MergeFiles ()
{
	char szDirectory [256] = {0};
	GetCurrentDirectory ( 256, szDirectory );

	string CurrentDir = szDirectory;
	
	string Settings = CurrentDir;
	Settings += "\\LPMS.ini";

	// Obtain max threads
	ifstream File ( Settings.c_str () );
	int count = 0;
	int maxThreads = 0;

	while ( !File.eof () )
	{
		string str;
		getline ( File, str );

		if ( count == 5 )
		{
			stringstream ss;
			ss << str;
			ss >> maxThreads;
		}

		++count;
	}

	File.close ();

	// Create our file
	string Memory = CurrentDir;
	Memory += "\\Memory\\Memory.TMP";

	DeleteFile ( Memory.c_str () );
	HANDLE hMerge = CreateFile ( Memory.c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );

	// Begin merging
	string Directory = CurrentDir;
	Directory += "\\Memory\\Memory";

	for ( int i = 0; i < maxThreads; i ++ )
	{
		string newPath = Directory;

		// Create the path
		stringstream ss;
		ss << i; 
		newPath += ss.str ();
		newPath += ".TMP";

		MergeIt ( hMerge, newPath.c_str () );
	}

	// Write
	ofstream Finished ( "C:\\MergeOver.txt" );
	Finished.clear ();
	Finished << "Done" << endl;
	Finished.close ();

	// Close
	CloseHandle ( hMerge );
}
//

// Entry-point
int CALLBACK WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	MergeFiles ();

	return 0;
}
//

<|start_filename|>LPMS Tutorial/resource.h<|end_filename|>
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#define IDD_DIALOG1                             101
#define IDD_DIALOG2                             102
#define IDD_DIALOG3                             103
#define IDB_BITMAP1                             104
#define IDC_HEALTH                              1000
#define IDC_SEC                                 1001
#define IDC_AMMO                                1002
#define IDC_BUTTON1                             1003
#define IDC_BUTTON2                             1004
#define X_POS                                   1005
#define IDC_BUTTON3                             1007
#define Y_POS                                   1007


<|start_filename|>Memory Engine/memory.h<|end_filename|>
// Global Headers
#include <Windows.h>
#include <fstream>
#include <sstream>
#include <Winbase.h>
#include <Psapi.h>
#include <Tlhelp32.h>
#include <bitset>
#include <math.h>

#define BEA_ENGINE_STATIC
#define BEA_USE_STDCALL

#include "hopper.h"
#include "BeaEngine.h"

bool     localBrk = false;
BYTE originalByte;

BOOL WOWBitPC = FALSE;

#define READABLE PAGE_EXECUTE_READ || PAGE_EXECUTE_READWRITE || PAGE_READONLY || PAGE_READWRITE

// LPMS Information
string Username;
string Version;
//

#pragma comment ( lib, "Psapi.lib" )

using namespace std;

string CurDirectory = "";

bool Merging = false;

// Structures
template <class T> struct ADDR_INFO
{
	DWORD dwAddr; // Address
	T     Value;  // Value
};
template <class T> struct SCAN_INFO
{
	T     Value;   // Value
};
template <class T> struct BLA_INFO
{
public:
	T      Value;
	DWORD  dwStartScan;
	DWORD  dwStopScan;
	HANDLE hThread;
	bool   finished;
};
struct SCANINFO
{
	int	   regionStart;
	int	   regionStop;
	int    scanNum;
	int   *Regions;
	int    goodReg;
	int    results;
	bool   finished;
	HANDLE hFile;
	HANDLE hNew;
	HANDLE hThread;
};
struct STATIC_INFO
{
	string PointerInfo; 
	BOOL   isStatic;    
};
struct POINTER_INFO
{
	DWORD dwAddress; 
	DWORD dwRange;   
	bool  GoStatic;  
};
struct IMAGE_INFO
{
	DWORD dwBase;
	SIZE_T szBase;
};
struct REGION_INFO
{
	DWORD dwBaseAddr;
	SIZE_T szRegion;
};
struct DBG_INFO
{
	PVOID lpAddr;
	DWORD EAX;
	DWORD EBX;
	DWORD EIP;
	DWORD ESP;
	DWORD EDI;
	DWORD ECX;
	DWORD EBP;
	DWORD EDX;
	DWORD ESI;
};

struct MEM_INFO
{
public:
	DWORD  dwRegBase; // Base Address
	SIZE_T szRegSize; // Region Size
};

struct PTR_INFO
{
	string PointerName;
	int    index;
};
//

// Settings
bool  EpislonOn = false;
float Epislon   = (float) 0.01;
int   MaxThreads = 30;

SIZE_T PreciseSize = PreciseSize;
SIZE_T UnknownSize = 20000000;

bool MemPrivate = false;
bool MemMapped  = false;
bool MemImage   = false;

SCANINFO * si;
int * threadsWorked;

bool siGone		   = false;
int threadsCreated = 0;

PTR_INFO *ptrInfoTwo;
int      ptrCountTwo = 0;

//
DWORD dwMS1;
DWORD dwMS2;
int	  myResult;
//

//
DWORD  dwPtrAddr;
DWORD  dwStartScan;
DWORD  dwStopScan;
POINTER_INFO ptrInfo; 
//

//
DWORD dwFunction;
BYTE  originalBytes [5] = {0};
DWORD dwOldProtect, dwDummy;
//

//
HWND mainDlg	   = NULL;
HWND addrDlg	   = NULL;
HWND editDlg       = NULL;
HWND ptrDlg        = NULL;
HWND memDlg        = NULL;
HWND chgDlg        = NULL;
HWND optDlg        = NULL;
HWND dbgDlg        = NULL;
HWND mdlDlg        = NULL;
HWND fwDlg         = NULL;
HWND regDlg        = NULL;
HWND disDlg        = NULL;
HWND extraDlg      = NULL;
HWND settingDlg    = NULL;
HWND editAllDlg    = NULL;
HWND dataStruct    = NULL;
//

//
HANDLE hScan       = NULL;
HANDLE hAddrDlg    = NULL;
HANDLE hEditDlg    = NULL;
HANDLE hMainThread = NULL;
HANDLE hUpdate     = NULL;
HANDLE hFreeze     = NULL;
HANDLE hPtrDlg     = NULL;
HANDLE hPtrScan    = NULL;
HANDLE hMemDlg     = NULL;
HANDLE hMemScan    = NULL;
HANDLE hChgDlg     = NULL;
HANDLE hPopup      = NULL;
HANDLE hOptDlg     = NULL;
HANDLE hDbgDlg     = NULL;
HANDLE hMdlDlg     = NULL;
HANDLE hArray      = NULL;
HANDLE hNoBug      = NULL;
HANDLE hDmp        = NULL;
HANDLE hDmp2       = NULL;
HANDLE hFuncWatch  = NULL;
HANDLE hRegion     = NULL;
HANDLE hDis        = NULL;
HANDLE hDisassemble = NULL;
HANDLE hExtra       = NULL;
HANDLE hSettings    = NULL;
HANDLE hOpen        = NULL;
HANDLE hSave        = NULL;
HANDLE hPointers    = NULL;
HANDLE hEditAll     = NULL;
HANDLE hDataStruct  = NULL;
HANDLE hHotkeys     = NULL;
//

//
HANDLE hAddress;
HANDLE hValues;
HANDLE hFile;
HANDLE hNew;
//

//
int  typeunknown  = -1;
bool ScanFinished = false;
bool unknownScan  = false;
bool ArrayOfBytes = false;
//

//
int wildcard [] = {0};
int wildcardnum = 0;
//

//
DWORD MS1;
DWORD MS2;
bool Set;
//

//
DWORD *    dwScan;	
DWORD * dwOldScan;
DWORD * dwPtrScan;  
//

//
DBG_INFO *dbgInfo;
void     *Dbged [] = {0};
int       numOfDbg = 0;
//

//
int      scanNum                 = -1;
int      oldResult               = 0;
UINT64   result                  = 0;
int      PointerResult           = 0;
int      finalResult             = 0;
int      newResult               = 0;
int      temp_result             = 0;
bool     dbgOn                   = false;

REGION_INFO * AllRegions;
int         NumRegions    = 0;
//

// Dll name
string DllName = "LPMS.dll";

//
DWORD dwNoStartScan = 0;
DWORD dwNoStopScan  = 0;
//

//
IMAGE_INFO imageInfo []  = {0};
int		   element		 = 0;
//

//
BYTE * pBytes;
SIZE_T szBytes;
int successRegion = 0;
int unknownNumber = 0;
int *SuccessReg;
//

//
string FuncCalled = "";
//

//
void MakeSound  ()
{
	Beep ( 1000, 100 );
}
//

//
BYTE * pRegion;
DWORD dwDbgAddr;
//

// Trimming, Static
string TrimZero ( string str )
{
	// Trim the zero's
	string Output = str.substr ( 6, 2 );

	// Return the final string
	return Output;
}
string RTrimZero ( string str )
{
	string output = str;
	int    index  = 0;

	for ( int i = 0; i < (int) str.length (); i ++ )
	{
		if ( str.at ( i ) != '0' )
			break;
		else
			++index;
	}

	return index < (int) ( str.length () - 1 ) ? output.substr ( index, str.length () ) : "0";
}
STATIC_INFO CS ( DWORD dwAddr )
{
	string PointerInfo;

	// Create our variable
	STATIC_INFO PtrInfo;
	PtrInfo.isStatic = FALSE;

	// Module information
	char  szModule [256] = {0};
	DWORD dwBaseAddr	 = 0;

	// Module entry 32
	MODULEENTRY32 ME;
	ME.dwSize = sizeof ( MODULEENTRY32 );

	// Begin checking the modules
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

	// Start checking
	if ( M32F ( hSnapshot, &ME ) )
	{
		// Check if the address is in the range
		dwBaseAddr       = (DWORD) ME.modBaseAddr;
		DWORD dwLastAddr = (DWORD) ME.modBaseAddr + (DWORD) ME.modBaseSize;

		if ( dwAddr >= dwBaseAddr && 
			 dwAddr <= dwLastAddr )
		{
			// Set the 'isStatic' variable
			PtrInfo.isStatic = TRUE;
		}
		else
		{
			// Check every other module
			while ( M32N ( hSnapshot, &ME ) )
			{
				// Check if the address is in the range
				dwBaseAddr       = (DWORD) ME.modBaseAddr;
				DWORD dwLastAddr = (DWORD) ME.modBaseAddr + (DWORD) ME.modBaseSize;

				if ( dwAddr >= dwBaseAddr && 
					 dwAddr <= dwLastAddr )
				{
					// Set the 'isStatic' variable
					PtrInfo.isStatic = TRUE;

					break;
				}
			}
		}
	}

	// Check
	if ( PtrInfo.isStatic )
	{
		// Obtain the base address
		DWORD dwOffset = 0;

		// Obtain offset
		if ( dwAddr > dwBaseAddr )
			dwOffset = dwAddr - dwBaseAddr;
		else
			dwOffset = dwBaseAddr - dwAddr;

		// Convert offset to string
		stringstream ss;
		ss << (LPVOID) dwOffset;

		// Final string
		PointerInfo += (LPSTR) ME.szModule;
		PointerInfo += " + ";

		string Offset;
		Offset      += ss.str ();
		PointerInfo += RTrimZero ( Offset );

		// Set the string
		PtrInfo.PointerInfo = PointerInfo;
	}
	else {
		// Set the pointer information
		PointerInfo         += "Dynamic Address";
		PtrInfo.PointerInfo = PointerInfo;
	}

	return PtrInfo;
}
//

// Reading/Writing
template <class T> string CTT ( T Value )
{
	// Obtain the value in stringstream format
	if ( !strcmp ( typeid (T).name (), "unsigned char" ) )
	{
		stringstream ss;
		ss << (unsigned int) Value;
		return ss.str ();
	}
	else
	{
		stringstream ss;
		ss << Value;

		// Return the string
		return ss.str ();
	}
}

template <class T> bool   CMP ( DWORD dwAddr, T Value )
{
	__try {
		if ( *(T*) dwAddr == Value )
			return true;
		else 
			return false;
	}
	__except ( true ) {
		return false;
	}
}

template <class T> T      RV ( DWORD dwAddr )
{
	__try {
		return *(T*) dwAddr;
	}
	__except ( true ) {
		return -1;
	}
}

template <class T> void   WV ( DWORD dwAddr, T Value )
{
	__try 
	{
		// Protect the address
		DWORD dwDummy, dwflOldProtect;
		VirtualProtect ( (LPVOID) dwAddr, sizeof (T), PAGE_EXECUTE_READWRITE, &dwflOldProtect );

		// Write
		*(T*) dwAddr = Value;

		// Reprotect
		VirtualProtect ( (LPVOID) dwAddr, sizeof (T), dwflOldProtect, &dwDummy );
	}
	__except ( true ) 
	{
		// Failed to write
	}
}
template <class T> bool   R ( DWORD dwPtr, ADDR_INFO <T> * i )
{
	__try {
		i->dwAddr = dwPtr;
		i->Value  = *(T*) dwPtr;
		return true;
	}
	__except ( true ) {
		return false;
	}
}
bool					  RB ( DWORD dwAddress, BYTE * myBytes )
{
	__try {
		// Read 10 bytes
		memcpy ( myBytes, (void*) dwAddress, 16 );

		return true;
	}
	__except ( true ) {
		// Failed
		return false;
	}
}
bool                      CA ( DWORD dwAddr )
{
	__try 
	{
		if ( !memcmp ( (void*) dwAddr, pBytes, szBytes ) )
			return true;
		else
			return false;
	}
	__except ( true ) {
		return false;
	}
}
//

// Conversion
template <class T> string ConvertToText ( T Value )
{
	stringstream ss;
	ss << Value;
	return ss.str ();
}
template <class T, class R> R ConvertTextTo  ( HWND hWndDlg )
{
	// Obtain the text
	char szBuffer [256] = {0};
	GetWindowText ( hWndDlg, szBuffer, 256 );

	// Convert to stringstream
	stringstream ss;
	ss << szBuffer;

	if ( !strcmp ( typeid ( T ).name (), "unsigned char" ) )
	{
		// R 
		unsigned int pValue = 0;
		ss >> pValue;

		// Return
		return (BYTE) pValue;
	}
	else if ( !strcmp ( typeid ( T ).name (), "void *" ) )
	{		
		if ( !strcmp ( typeid ( R ).name (), "unsigned char" ) )
		{
			LPVOID lpAddr;
			ss >> lpAddr;

			unsigned int uiVal = (unsigned int) lpAddr;
			return (BYTE) lpAddr;
		}
		else if ( !strcmp ( typeid ( R ).name (), "unsigned short" ) )
		{
			LPVOID lpAddr;
			ss >> lpAddr;
			
			return (WORD) lpAddr;
		}
		else if ( !strcmp ( typeid ( R ).name (), "unsigned long" ) )
		{
			LPVOID lpAddr;
			ss >> lpAddr;
			
			return (DWORD) lpAddr;
		}
		else if ( !strcmp ( typeid ( R ).name (), "unsigned __uint64" ) )
		{
			LPVOID lpAddr;
			ss >> lpAddr;
			
			return (UINT64) lpAddr;
		}
	}

	// Pass it to our new value
	R Value = 0;

	// Pass
	ss >> Value;

	// Return 
	return Value;	
}
template <class T, class R> R ConvertTextTo2 ( string ValueStr )
{
	// Convert to stringstream
	stringstream ss;
	ss << ValueStr.c_str ();

	// Pass it to our new value
	R Value = 0;

	if ( !strcmp ( typeid ( T ).name (), "unsigned char" ) )
	{
		// R 
		unsigned int pValue = 0;
		ss >> pValue;

		// Return
		return (BYTE) pValue;
	}
	else if ( !strcmp ( typeid ( T ).name (), "void *" ) )
	{
		LPVOID lpAddr;
		ss >> lpAddr;
		
		return (DWORD) lpAddr;
	}
	else
		ss >> Value;

	// Return value
	return Value;
}
//

// Set settings
void MakeSettings ()
{
	// Setup the settings
	string Pathway = "";
	Pathway += CurDirectory.c_str ();
	Pathway += "\\LPMS.ini";

	int count = 0;

	// Begin reading
	ifstream SettingsAt ( Pathway.c_str () );

	while ( !SettingsAt.eof () )
	{
		string str;
		getline ( SettingsAt, str );

		switch ( count )
		{
		case 0:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					MemMapped = true;
				else
					MemMapped = false;
			}
			break;

		case 1:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					MemImage = true;
				else
					MemImage = false;
			}
			break;

		case 2:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					MemPrivate = true;
				else
					MemPrivate = false;
			}
			break;

		case 3:
			{
				if ( !strcmp ( str.c_str (), "TRUE" ) )
					Epislon = true;
				else
					Epislon = false;
			}
			break;

		case 4:
			{
				Epislon = ConvertTextTo2 <float, float>  ( str );
			}
			break;

		case 5:
			{
				MaxThreads = ConvertTextTo2 <int, int> ( str );
			}
			break;

		case 6:
			{
				PreciseSize = ConvertTextTo2 <int, int> ( str );
			}
			break;

		case 7:
			{
				UnknownSize = ConvertTextTo2 <int, int> ( str );
			}
			break;
		}

		if ( count > 6 )
			break;

		++ count;

		Sleep (1);
	}
}
//

// Conversion
string CTS ( int value )
{
	stringstream ss;
	ss << value;
	return ss.str ();
}
string CTH ( int decimal )
{
	int number = decimal;
	int result = 1;
	int remainder = 1;
	string hex = "";

	while ( result >= 1 )
	{
		result = ( number / 16 );
		remainder = number % 16;
		
		if ( remainder == 1 )
			hex += CTS ( remainder );
		else if ( remainder < 10 )
			hex += CTS ( remainder );
		else
		{
			if ( remainder == 10 )
				hex += "A";
			else if ( remainder == 11 )
				hex += "B";
			else if ( remainder == 12 )
				hex += "C";
			else if ( remainder == 13 )
				hex += "D";
			else if ( remainder == 14 )
				hex += "E";
			else
				hex += "F";
		}

		number = result;
	}

	string reversedHex = "";

	for ( int i = hex.length () - 1; i > -1; i -- )
		reversedHex += hex [i];

	return reversedHex;
}
string CTB ( string text )
{
	string bytes = "";

	for ( SIZE_T i = 0; i < text.length (); i ++ )
	{
		char character = (char) text [i];
		int  toHex     = (int) character;
		bytes += CTH ( toHex );
		bytes += " ";
	}

	return bytes;
}
//

// Insertion
void IR  ( HWND hWndDlg, DWORD dwAddr )
{
	SMX ( hWndDlg, LB_ADDSTRING, NULL, (LPARAM) CTT <LPVOID> ( (LPVOID) dwAddr ).c_str () );
}
void IR2 ( string PTRINFO )
{
	// Add the message
	SMX ( GetDlgItem ( ptrDlg, IDC_LIST1 ), LB_ADDSTRING, 0, (LPARAM) PTRINFO.c_str () );
}
void IA  ( string Addr, string Type )
{
	// Get Item
	int item = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

	// Setup item
	LV_ITEM lv;
	lv.iItem    = item;           
	lv.iSubItem = 0;
	lv.mask     = LVIF_TEXT;       
	lv.pszText  = "";
	lv.cchTextMax = 256; 

	// Insert item
	ListView_InsertItem ( GetDlgItem ( mainDlg, IDC_LIST2 ), &lv );

	// Fix subitems
	for ( int i = 1; i <= 4; i ++ )
	{
		// Setup neccessary values
		lv.iSubItem   = i;
		lv.cchTextMax = 256;

		// Setup text
		string str = "";

		if ( i == 1 )
			str = Addr;
		else if ( i == 2 )
			str = Type;
		else
			str = "0";

		// Add item
		lv.pszText = (LPSTR) str.c_str ();

		// Insert subitem
		ListView_SetItem ( GetDlgItem ( mainDlg, IDC_LIST2 ), &lv );
	}
}
void IP  ( string Addr, string Type, string Pointer )
{
	// Get Item
	int item = ListView_GetItemCount ( GetDlgItem ( mainDlg, IDC_LIST2 ) );

	// Setup item
	LV_ITEM lv;
	lv.iItem    = item;           
	lv.iSubItem = 0;
	lv.mask     = LVIF_TEXT;       
	lv.pszText  = "";
	lv.cchTextMax = 256; 

	// Set pointer up
	PTR_INFO ptrStruct;
	ptrStruct.index       = item;
	ptrStruct.PointerName = Pointer;
	ptrInfoTwo [ ptrCountTwo ]  = ptrStruct;
	++ ptrCountTwo;

	// Insert item
	ListView_InsertItem ( GetDlgItem ( mainDlg, IDC_LIST2 ), &lv );

	// Fix subitems
	for ( int i = 1; i <= 4; i ++ )
	{
		// Setup neccessary values
		lv.iSubItem   = i;
		lv.cchTextMax = 256;

		// Setup text
		string str = "";

		if ( i == 1 )
			str = Addr;
		else if ( i == 2 )
			str = Type;
		else
			str = "0";

		// Add item
		lv.pszText = (LPSTR) str.c_str ();

		// Insert subitem
		ListView_SetItem ( GetDlgItem ( mainDlg, IDC_LIST2 ), &lv );
	}
}
void IM  ( char * MdlName, DWORD dwBase )
{
	// Get Item
	int item = ListView_GetItemCount ( GetDlgItem ( mdlDlg, IDC_LIST1 ) );

	// Setup the item
	LV_ITEM lv;
	lv.iItem    = item;           
	lv.iSubItem = 0;
	lv.mask     = LVIF_TEXT;       
	lv.pszText  = MdlName;
	lv.cchTextMax = 256; 

	// Insert the item
	ListView_InsertItem ( GetDlgItem ( mdlDlg, IDC_LIST1 ), &lv );

	// Convert the string to char
	string strAddr = CTT <LPVOID> ( (LPVOID) dwBase );

	// Setup the item
	lv.cchTextMax = 256;
	lv.pszText = (LPSTR) strAddr.c_str ();
	lv.iSubItem = 1;

	// Insert the item
	ListView_SetItem ( GetDlgItem ( mdlDlg, IDC_LIST1 ), &lv );
}
void ID  ( string Address, char * Instruction, string Opcode )
{
	// Get Item
	int item = ListView_GetItemCount ( GetDlgItem ( disDlg, IDC_LIST1 ) );

	// Setup item
	LV_ITEM lv;
	lv.iItem    = item;           
	lv.iSubItem = 0;
	lv.mask     = LVIF_TEXT;       
	lv.pszText  = "";
	lv.cchTextMax = 256; 

	// Insert item
	ListView_InsertItem ( GetDlgItem ( disDlg, IDC_LIST1 ), &lv );

	// Fix subitems
	for ( int i = 0; i < 3; i ++ )
	{
		// Setup neccessary values
		lv.iSubItem   = i;
		lv.cchTextMax = 256;

		// Setup text
		string str = "";

		if ( i == 0 )
			str = Address;
		else if ( i == 2 )
			str += Instruction;
		else
			str += Opcode;

		// Add item
		lv.pszText = (LPSTR) str.c_str ();

		// Insert subitem
		ListView_SetItem ( GetDlgItem ( disDlg, IDC_LIST1 ), &lv );
	}
}
void test ( string Address, char * Instruction, string Opcode )
{
	ID ( Address, Instruction, Opcode );
}
//

// No scan
void NS ()
{
	MODULEENTRY32 me;
	me.dwSize = sizeof ( MODULEENTRY32 );

	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

	if ( Module32First ( hSnapshot, &me ) )
	{
		if ( !strcmp ( DllName.c_str (), me.szModule  ) )
		{
			dwNoStartScan = (DWORD) me.modBaseAddr;
			dwNoStopScan  = (DWORD) me.modBaseAddr + (DWORD) me.modBaseSize;
		}
		else
		{
			while ( Module32Next ( hSnapshot, &me ) )
			{
				if ( !strcmp ( DllName.c_str (), me.szModule  ) )
				{
					dwNoStartScan = (DWORD) me.modBaseAddr;
					dwNoStopScan  = (DWORD) me.modBaseAddr + (DWORD) me.modBaseSize;
				}
			}
		}
	}
}
//

// Region Viewer
void InsertRegion ( void* BaseAddress, DWORD dwState, DWORD dwType, DWORD dwProtect, SIZE_T szReg )
{
	// Get Item
	int item = ListView_GetItemCount ( GetDlgItem ( regDlg, IDC_LIST1 ) );

	// Setup item
	LV_ITEM lv;
	lv.iItem    = item;           
	lv.iSubItem = 0;
	lv.mask     = LVIF_TEXT;       
	lv.pszText  = "";
	lv.cchTextMax = 256; 

	// Insert item
	ListView_InsertItem ( GetDlgItem ( regDlg, IDC_LIST1 ), &lv );

	// Fix subitems
	for ( int i = 0; i < 5; i ++ )
	{
		// Setup neccessary values
		lv.iSubItem   = i;
		lv.cchTextMax = 256;

		// Setup text
		string str = "";

		if ( i == 0 )
			str = CTT <LPVOID> ( BaseAddress );
		else if ( i == 1 )
		{
			switch ( dwState )
			{
			case MEM_COMMIT:
				{
					str = "Commit";
				}
				break;

			case MEM_RESERVE:
				{
					str = "Reserved";
				}
				break;

			case MEM_FREE:
				{
					str = "Free";
				}
				break;
			}
		}
		else if ( i == 2 )
		{
			switch ( dwType )
			{
			case MEM_PRIVATE:
				{
					str = "Private";
				}
				break;

			case MEM_IMAGE:
				{
					str = "Image";
				}
				break;

			case MEM_MAPPED:
				{
					str = "Mapped";
				}
				break;
			}
		}
		else if ( i == 3 )
		{
			switch ( dwProtect )
			{
			case PAGE_EXECUTE:
				{
					str = "PAGE_EXECUTE";
				}
				break;

			case PAGE_EXECUTE_READ:
				{
					str = "PAGE_EXECUTE_READ";
				}
				break;

			case PAGE_EXECUTE_READWRITE:
			{
				str = "PAGE_EXECUTE_READWRITE";
			}
			break;

			case PAGE_EXECUTE_WRITECOPY:
			{
				str = "PAGE_EXECUTE_WRITECOPY";
			}
			break;

			case PAGE_NOACCESS:
			{
				str = "PAGE_NOACCESS";
			}
			break;

			case PAGE_READONLY:
			{
				str = "PAGE_READONLY";
			}
			break;

			case PAGE_READWRITE:
			{
				str = "PAGE_READWRITE";
			}
			break;

			case PAGE_WRITECOPY:
			{
				str = "PAGE_WRITECOPY";
			}
			break;

			}
		}
		else
			str = CTT <LPVOID> ( (void*) szReg );

		// Add item
		lv.pszText = (LPSTR) str.c_str ();

		// Insert subitem
		ListView_SetItem ( GetDlgItem ( regDlg, IDC_LIST1 ), &lv );
	}
}
void ScanRegions ()
{
	// Clear the search 
	ListView_DeleteAllItems ( GetDlgItem ( regDlg, IDC_LIST1 ) ); 

	// Get the system information
	SYSTEM_INFO SI;
	GetSystemInfo ( &SI );

	for ( DWORD dwStart = (DWORD) SI.lpMinimumApplicationAddress; dwStart < (DWORD) SI.lpMaximumApplicationAddress; dwStart ++ )
	{
		// Obtain region information
		MEMORY_BASIC_INFORMATION MBI;
		VQ ( (LPCVOID) dwStart, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

		// Add the information
		InsertRegion ( MBI.BaseAddress, MBI.State, MBI.Type, MBI.Protect, MBI.RegionSize );

		// Go to the next region
		dwStart = (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize;
	}
}
//

// Module-Viewer
void GM ()
{
	// Clear the listbox
	SMX ( GetDlgItem ( mdlDlg, IDC_LIST1 ), LVM_DELETEALLITEMS, NULL, NULL );

	// Create the snapshot
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );

	// Obtain the module information
	MODULEENTRY32 me;
	me.dwSize = sizeof ( MODULEENTRY32 );

	// Insert the information
	if ( M32F ( hSnapshot, &me ) )
	{
		IM ( me.szModule, (DWORD) me.modBaseAddr );

		while ( M32N ( hSnapshot, &me ) )
			IM ( me.szModule, (DWORD) me.modBaseAddr );
	}
}
//

// Locate all regions
void LocateAllRegions ( DWORD dwStartAddr, DWORD dwStopAddr )
{
	// Remove 
	if ( NumRegions != 0 )
		delete [] AllRegions;

	// Initialize
	AllRegions = new REGION_INFO [ 10000 ];
	NumRegions = 0;

	// Scan
	for ( DWORD begin = dwStartAddr;
			    begin < dwStopAddr;
				begin ++ )
	{
		// Obtain 
		MEMORY_BASIC_INFORMATION MBI;
		VQ ( (LPCVOID) begin, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

		// Check 
		if (                           (DWORD) MBI.BaseAddress  < dwNoStartScan || 
		   ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) > dwNoStopScan )
		{
			if ( MBI.Type == ( MemPrivate == true ? MEM_PRIVATE : -1 ) ||
				 MBI.Type == ( MemImage   == true ? MEM_IMAGE   : -1 ) ||
				 MBI.Type == ( MemMapped  == true ? MEM_MAPPED  : -1 ) )
			{
				if ( MBI.RegionSize > UnknownSize )
				{
					SIZE_T allocationSize = 0;
					SIZE_T szDummy = MBI.RegionSize;
					DWORD  dwBase  = (DWORD) MBI.BaseAddress;
					int    Offset  = ( szDummy / UnknownSize ) + 1;

					for ( int x = 0 ; x < Offset; x ++ )
					{
						// Obtain allocation size
						if ( x == Offset - 1 )
							allocationSize = szDummy;
						else
							allocationSize = UnknownSize;

						// Set
						REGION_INFO regionInfo;
						regionInfo.dwBaseAddr = dwBase;
						regionInfo.szRegion   = allocationSize;
						dwBase               += allocationSize;

						// Add 
						AllRegions [ NumRegions ] = regionInfo;				
						NumRegions++;

						// Decrease
						szDummy -= allocationSize;
					}
				}
				else
				{
					// Set 
					REGION_INFO RegionInfo;
					RegionInfo.dwBaseAddr = (DWORD) MBI.BaseAddress;
					RegionInfo.szRegion   = MBI.RegionSize;		

					// Add 
					AllRegions [ NumRegions ] = RegionInfo;				
					NumRegions++;
				}
			}
		}

		// Next
		begin = (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize;
	}
}

//

// File operations
void   WriteToFile   ( HANDLE hFile, LPCVOID Buffer, SIZE_T szSize )
{
	DWORD dwBytes;

	__try 
	{
		if ( !WriteFil ( hFile, Buffer, szSize, &dwBytes, 0 ) )
			la ( 0 );
	}
	__except ( true ) 
	{
		// Exception
	}
}
HANDLE szCreateFile  ( int scanNum )
{
	// Create the path
	string Path = CurDirectory;
	Path       += "\\Memory\\";
	Path       += "Memory";
	Path       += CTT ( scanNum );
	Path       += ".TMP";

	// Delete the file
	DeleteFile ( Path.c_str () );

	// Delete then create
	return CreateFile ( Path.c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
}

HANDLE szCreateFile2 ( string Path )
{
	// Create the path
	string NewPath = CurDirectory;
	NewPath       += "\\Memory\\";
	NewPath       += Path.c_str ();

	// Delete the file
	DeleteFile ( NewPath.c_str () );

	// Obtain the handle
	return CreateFile ( NewPath.c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
}
HANDLE szCreateFile3 ( string Path )
{
	// Delete the file
	DeleteFile ( Path.c_str () );

	// Obtain the handle
	return CreateFile ( Path.c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
}
HANDLE szObtainFile  ( int scanNum )
{
	// Create the path
	string Path = CurDirectory;
	Path       += "\\Memory\\";
	Path       += "Memory";
	Path       += CTT ( scanNum );
	Path       += ".TMP";

	return CreateFile ( Path.c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
}
string GetPathway    ( string Path )
{
	// Create the path
	string NewPath = CurDirectory;
	NewPath       += "\\Memory\\";
	NewPath       += Path.c_str ();

	return NewPath;
}
void   szDeletePath  ( int scanNum )
{
	// Create the path
	string Path = CurDirectory;
	Path       += "\\Memory\\";
	Path       += "Memory";
	Path       += CTT ( scanNum );
	Path       += ".TMP";

	DeleteFile ( Path.c_str () );
}
//

// 
void Setup ()
{
	finalResult = 0;
	temp_result = (int) result;

	// Create the handles
	hFile = CreateFile ( GetPathway ( "Memory.TMP" ).c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
	hNew  = CreateFile ( GetPathway ( "Values.TMP" ).c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

	// New files
	hAddress = szCreateFile2 ( "Memory2.TMP" );
	hValues  = szCreateFile2 ( "Values2.TMP" );

	// Initialize
	int endScan;

	if ( !unknownNumber )
		endScan = successRegion;
	else
		endScan = ( (int) result / UnknownSize ) + 1;

	// Setup progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
	SMX        ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETPOS, (WPARAM) 0, 0 );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETRANGE, 0, MAKELPARAM ( 0, endScan ) );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETSTEP, (WPARAM) 1, 0 );
}
void Progress ()
{
	SMX ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_STEPIT, 0, 0 );
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
}
void FinishNS ()
{
	++unknownNumber;

	// Setup final result
	result = finalResult;

	// Close the handles
	CloseHandle ( hFile );
	CloseHandle ( hNew );
	
	CloseHandle ( hAddress );
	CloseHandle ( hValues );

	// Delete the old buffer and rename
	DeleteFile ( GetPathway ( "OldMemory.TMP" ).c_str () );
	DeleteFile ( GetPathway ( "OldValues.TMP" ).c_str () );

	MoveFileEx ( GetPathway ( "Memory.TMP" ).c_str (), GetPathway ( "OldMemory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );
	MoveFileEx ( GetPathway ( "Values.TMP" ).c_str (), GetPathway ( "OldValues.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );

	MoveFileEx ( GetPathway ( "Memory2.TMP" ).c_str (), GetPathway ( "Memory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );
	MoveFileEx ( GetPathway ( "Values2.TMP" ).c_str (), GetPathway ( "Values.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );

	// Hide progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );
}
//

// Unknown Scan
bool SetupRegions ()
{
	__try {
		SuccessReg = new int [10000];
		int element = 0;

		for ( int i = 0; i < MaxThreads; i ++ )
		{
			for ( int x = 0; x < si [i].goodReg; x ++ )
			{
				if ( AllRegions [ si [i].Regions [x] ].dwBaseAddr != 0 && 
					 AllRegions [ si [i].Regions [x] ].szRegion   != 0 )
				{
					if (            element <= NumRegions &&
						 si [i].Regions [x] <= NumRegions )
					{
						SuccessReg [element] = si [i].Regions [x];
						++element;
					}
				}
			}

			successRegion += si [ i ].goodReg;
		}

		return true;
	}
	__except ( true )
	{
		MessageBoxA ( mainDlg, "An error has occured.", "Error", MB_ICONINFORMATION );
		SMX         ( mainDlg, WM_COMMAND, IDC_BUTTON8, NULL );

		return false;
	}
}
//

// Memory Scanning Routines
int					   US  ( LPVOID lpParam )
{
	// Scan the memory
	for ( int i = si [ (int) lpParam ].regionStart; i <= si [ (int) lpParam ].regionStop; i ++ )
	{
		MEMORY_BASIC_INFORMATION MBI;
		VirtualQuery ( (LPCVOID) AllRegions [i].dwBaseAddr, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

		if ( MBI.Protect == READABLE )
		{
			// Write information
			DWORD dwBytes;

			if ( WriteFil ( si [ (int) lpParam ].hFile, (void*) AllRegions [i].dwBaseAddr, AllRegions [i].szRegion, &dwBytes, 0 ) )
			{
				// Increment
				si [ (int) lpParam ].results += AllRegions [i].szRegion;
				si [ (int) lpParam ].Regions [ si [ (int) lpParam ].goodReg ] = i;
				si [ (int) lpParam ].goodReg ++;	
			}
		}
	}

	// Notify the scan has finished
	si [ (int) lpParam ].finished = true;

	return 0;
}
template <class T> int FS  ( LPVOID lpParam )
{
	// See if the value is hex
	bool hex = SMX ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

	// Obtain the value
	T Value;
	
	if ( hex )
		Value = ConvertTextTo <LPVOID, T> ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );
	else
		Value = ConvertTextTo <T, T>	  ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );

	__try 
	{
		for ( int i = si [ (int) lpParam ].regionStart; i <= si [ (int) lpParam ].regionStop; i ++ )
		{
			MEMORY_BASIC_INFORMATION MBI;
			VirtualQuery ( (LPCVOID) AllRegions [i].dwBaseAddr, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

			if ( MBI.Protect == READABLE )
			{
				// Variables
				DWORD  *dwBuffer;
				DWORD   dwBytes;

				int temp_result = 0;

				// Scan the region
				__try 
				{
					temp_result = 0;

					// Obtain buffer info
					dwBuffer = new DWORD [ AllRegions [i].szRegion ];

					// Begin reading the region
					for ( DWORD begin = (DWORD) AllRegions [i].dwBaseAddr;
								begin < (DWORD) AllRegions [i].dwBaseAddr + (DWORD) AllRegions [i].szRegion - 1 - sizeof (T);
								begin ++ )
					{
						__try
						{
							if ( fabs ( (float) ( *(float*) begin - Value ) ) <= (float) Epislon ) 
							{
								dwBuffer [temp_result] = begin;
								++ temp_result;
							}
						}
						__except ( true ) 
						{
							break;
						}
					}

					// Write results into buffer
					::WriteFil ( si [ (int) lpParam ].hFile, dwBuffer, ( temp_result * 4 ), &dwBytes, 0 );

					// Increment results
					si [ (int) lpParam ].results += temp_result;

					// Delete the buffer
					delete [] dwBuffer;
				}
				__except ( true ) 
				{
					// Delete the buffer
					delete [] dwBuffer;
				}
			}
		}
	}
	__except ( true ) 
	{
		// Exception
	}

	// Notify the scan has finished
	si [ (int) lpParam ].finished = true;

	return 0;
}
template <class T> int DS  ( LPVOID lpParam )
{
	// See if the value is hex
	bool hex = SMX ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

	// Obtain the value
	T Value;
	
	if ( hex )
		Value = ConvertTextTo <LPVOID, T> ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );
	else
		Value = ConvertTextTo <T, T>	  ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );

	__try 
	{
		for ( int i = si [ (int) lpParam ].regionStart; i <= si [ (int) lpParam ].regionStop; i ++ )
		{
			MEMORY_BASIC_INFORMATION MBI;
			VirtualQuery ( (void*) AllRegions [i].dwBaseAddr, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

			if ( MBI.Protect == READABLE )
			{
				// Variables	
				DWORD  *dwBuffer;
				DWORD   dwBytes;

				int temp_result = 0;

				// Scan the region
				__try 
				{
					temp_result = 0;

					// Obtain buffer info
					dwBuffer = new DWORD [ AllRegions [i].szRegion ];

					// Begin reading the region
					for ( DWORD begin = (DWORD) AllRegions [i].dwBaseAddr;
								begin < (DWORD) AllRegions [i].dwBaseAddr + (DWORD) AllRegions [i].szRegion - 1 - sizeof (T);
								begin ++ )
					{
						__try
						{
							if ( fabs ( (double) ( *(double*) begin - Value ) ) <= (double) Epislon ) 
							{
								dwBuffer [temp_result] = begin;
								++ temp_result;
							}
						}
						__except ( true ) 
						{
							break;
						}
					}

					// Write results into buffer
					::WriteFil ( si [ (int) lpParam ].hFile, dwBuffer, ( temp_result * 4 ), &dwBytes, 0 );

					// Increment results
					si [ (int) lpParam ].results += temp_result;

					// Delete the buffer
					delete [] dwBuffer;
				}
				__except ( true )
				{
					// Delete the buffer
					delete [] dwBuffer;
				}
			}
		}
	}
	__except ( true ) 
	{
		// Exception
	}

	// Notify the scan has finished
	si [ (int) lpParam ].finished = true;

	return 0;
}
template <class T> int ES  ( LPVOID lpParam )
{
	// See if the value is hex
	bool hex = SMX ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

	// Obtain the value
	T Value;
	
	if ( hex )
		Value = ConvertTextTo <LPVOID, T> ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );
	else
		Value = ConvertTextTo <T, T>	  ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );

	__try 
	{
		for ( int i = si [ (int) lpParam ].regionStart; i <= si [ (int) lpParam ].regionStop; i ++ )
		{
			MEMORY_BASIC_INFORMATION MBI;
			VirtualQuery ( (LPCVOID) AllRegions [i].dwBaseAddr, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

			if ( MBI.Protect == READABLE )
			{
				// Variables	
				DWORD  *dwBuffer;
				DWORD   dwBytes;
				int temp_result = 0;

				// Scan the region
				__try 
				{				
					temp_result = 0;

					// Obtain buffer info
					dwBuffer = new DWORD [ AllRegions [i].szRegion ];
					
					// Begin reading the region
					for ( DWORD begin = (DWORD) AllRegions [i].dwBaseAddr;
								begin < (DWORD) AllRegions [i].dwBaseAddr + (DWORD) AllRegions [i].szRegion - 1 - sizeof (T);
								begin ++ )
					{
						__try
						{
							if ( *(T*) begin == Value )
							{
								dwBuffer [ temp_result ] = begin;
								++temp_result;
							}
						}
						__except ( true )
						{
							break;
						}
					}
					
					// Write results into buffer
					::WriteFile ( si [ (int) lpParam ].hFile, dwBuffer, ( temp_result * 4 ), &dwBytes, 0 );

					// Increment results
					si [ (int) lpParam ].results += temp_result;

					// Delete the buffer
					delete [] dwBuffer;
				}
				__except ( true ) 
				{
					// Delete the buffer
					delete [] dwBuffer;
				}
			}
		}
	}
	__except ( true ) 
	{
		// Exception
	}

	// Notify the scan has finished
	si [ (int) lpParam ].finished = true;

	return 0;
}

template <class T> int SFB ( LPVOID lpParam )
{
	__try 
	{
		for ( int i = si [ (int) lpParam ].regionStart; i <= si [ (int) lpParam ].regionStop; i ++ )
		{
			MEMORY_BASIC_INFORMATION MBI;
			VirtualQuery ( (LPCVOID) AllRegions [i].dwBaseAddr, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

			if ( MBI.Protect == READABLE )
			{
				// Variables	
				DWORD  *dwBuffer;
				DWORD   dwBytes;

				int temp_result = 0;

				// Scan the region
				__try 
				{
					temp_result = 0;

					// Obtain buffer info
					dwBuffer = new DWORD [ AllRegions [i].szRegion ];

					// Begin reading the region
					for ( DWORD begin = (DWORD) AllRegions [i].dwBaseAddr;
								begin < (DWORD) AllRegions [i].dwBaseAddr + (DWORD) AllRegions [i].szRegion - 1 - sizeof (T);
								begin ++ )
					{
						if ( !memcmp ( (void*) begin, pBytes, szBytes ) ) 
						{
							dwBuffer [temp_result] = begin;
							++temp_result;
						}			
					}

					// Write results into buffer
					::WriteFil ( si [ (int) lpParam ].hFile, dwBuffer, ( temp_result * 4 ), &dwBytes, 0 );

					// Increment results
					si [ (int) lpParam ].results += temp_result;

					// Delete the buffer
					delete [] dwBuffer;
				}
				__except ( true ) {
					// Delete the buffer
					delete [] dwBuffer;
				}
			}
		}
	}
	__except ( true ) 
	{
		// Notify the scan has finished
		si [ (int) lpParam ].finished = true;

		return 0;
	}

	// Notify the scan has finished
	si [ (int) lpParam ].finished = true;

	return 0;
}

//

// Sophisticated Thread System (STS)
template <class T> void STS ( int NumberOfThreads, DWORD dwStart, DWORD dwStop )
{
	// Reset windows
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS ), SW_HIDE );

	// Reset variables
	siGone = false;

	// Delete files
	DeleteFile ( GetPathway ( "Memory.TMP" ).c_str () );
	DeleteFile ( GetPathway ( "OldMemory.TMP" ).c_str () );
	DeleteFile ( GetPathway ( "Values.TMP" ).c_str () );
	DeleteFile ( GetPathway ( "OldValues.TMP" ).c_str () );
	DeleteFile ( GetPathway ( "Merge.bat" ).c_str () );
	DeleteFile ( GetPathway ( "Memory2.TMP" ).c_str () );
	DeleteFile ( GetPathway ( "Values2.TMP" ).c_str () );

	// Create threads
	result         = 0;
	threadsCreated = 0;

	// Setup variables
	int offset = NumRegions / NumberOfThreads;

	// Setup variables
	si			  = new SCANINFO [ NumberOfThreads ];
	threadsWorked = new int      [ NumberOfThreads ];

	// Create threads
	for ( int i = 0; i < NumberOfThreads; i ++ )
	{
		// Setup our si variable
		si [i].finished = false;
		si [i].results  = 0;

		// Setup the beginning scan of the regions
		if ( !i )
			si [i].regionStart = 0;
		else
			si [i].regionStart = si [ i - 1 ].regionStop + 1;

		// Setup the ending scan of the regions
		if ( NumberOfThreads == 1 )
			si [i].regionStop = NumRegions;
		else if ( i == ( NumberOfThreads - 1 ) )
			si [i].regionStop = NumRegions;
		else
			si [i].regionStop = si [i].regionStart + offset;

		if ( si [i].regionStop > NumRegions )
			si [i].regionStop = NumRegions;

		// Setup 'si'
		si [i].goodReg = 0;
		si [i].scanNum = i;

		// Setup file
		si [i].hFile = szCreateFile ( i );

		// Array of bytes
		if ( ArrayOfBytes )
			si [i].hThread = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) SFB <T>, (void*) i, NULL, NULL );
		else if ( !unknownScan  )
		{
			if      ( !strcmp ( typeid (T).name (), "float" ) )
				si [i].hThread = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) FS <T>, (void*) i, NULL, NULL );
			else if ( !strcmp ( typeid (T).name (), "double" ) )
				si [i].hThread = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) DS <T>, (void*) i, NULL, NULL );
			else
				si [i].hThread = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) ES <T>, (void*) i, NULL, NULL );
		}
		else if ( unknownScan )
		{
			si [i].Regions = new int [1000];

			// Setup 'si'
			si [i].hThread = CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) US, (void*) i, NULL, NULL );
		}

		// Check if the thread passed
		if ( si [i].hThread != NULL )
		{
			threadsWorked [ threadsCreated ] = i;
			++threadsCreated;
		}
	}

	// Setup progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOW );
	SMX        ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETPOS, (WPARAM) 0, 0 );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETRANGE, 0, MAKELPARAM ( 0, threadsCreated ) );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETSTEP, (WPARAM) 1, 0 );

	// Create our finished variable
	int finished;
		
	if ( threadsCreated == 1 )
		finished = -1;
	else
		finished = 0;

	// Check if the threads finished
	while ( true )
	{
		for ( int i = 0; i < threadsCreated; i ++ )
		{
			if ( si [ threadsWorked [i] ].finished == true )
			{
				// Increment finished
				result += si [ threadsWorked [i] ].results; 
				++finished;

				// Increment progress bar
				SMX ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_STEPIT, 0, 0 );
				ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );

				// Remove the thread
				DWORD dwExitCode;
				GetExitCodeThread ( si [ threadsWorked [i] ].hThread, &dwExitCode );
				TerminateThread   ( si [ threadsWorked [i] ].hThread, dwExitCode  );

				// Close the files
				CloseHandle ( si [ threadsWorked [i] ].hFile );

				si [ threadsWorked [i] ].finished = false;
			}
		}

		if ( NumberOfThreads == 1 )
		{
			if ( finished == threadsCreated - 1 )
				break;
		}
		else if ( finished == threadsCreated )
			break;		

		// Sleep 
		Sleep ( 100 );
	}

	// Setup successful regions
	if ( unknownScan )
		SetupRegions ();

	// Delete variables
	delete [] threadsWorked;
	delete [] si;
	siGone = true;

	// Notify 
	Merging = true;
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS ), SW_NORMAL );
	SetWindowText ( GetDlgItem ( mainDlg, IDC_PROGRESS ), "Merging.." );

	// Notify
	char Finished [] = "Ready";

	HANDLE hFile = szCreateFile3 ( "C:\\MergeOver.txt" );

	DWORD bytesWritten;
	WriteFile ( hFile, &Finished, strlen ( "Ready" ), &bytesWritten, NULL );

	CloseHandle ( hFile );

	// Wait
	while ( Merging )
	{
		string Data;
		ifstream ReadMerge ( "C:\\MergeOver.txt" );

		while ( !ReadMerge.eof () )
		{
			getline ( ReadMerge, Data );

			if ( !strcmp ( Data.c_str (), "Done" ) )
			{
				ReadMerge.close ();

				Merging = false;
				break;
			}
		}
		
		ReadMerge.close ();
		Sleep ( 100 );
	}

	// Delete merge
	DeleteFile ( "C:\\MergeOver.txt" );
}
//

// First Scan
template <class T> void GE ()
{
	// Reset variables
	Merging = false;
	result  = 0;

	// Obtain scanning type
	char szScan [256] = {0};
	GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), szScan, 256 );	

	// Call the first scan
	if ( ArrayOfBytes )
	{
		// Setup variables
		string test;
		char szBuffer [256] = {0};
		GetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT1 ), szBuffer, 256 );

		// Obtain the value
		if ( !strcmp ( szScan, "Array of Bytes" ) ) {
			test += szBuffer;
		}
		else {
			string buffer;
			buffer += szBuffer;		
			test += CTB ( buffer );
		}

		szBytes = 0;

		// Obtain the number of bytes
		for ( SIZE_T i = 0; i < test.length (); i ++ )
		{
			// Avoid an exception
			if ( i + 1 < test.length () )
			{
				// Find the number of bytes 
				if ( test.at (i) != ' ' )
				{
					// If you can form a two letter word
					if ( test.at ( i + 1 ) != ' ' )
					{
						++ szBytes;
					}
				}
			}
		}

		// Setup the variable
		pBytes = new BYTE [ szBytes ];
		SIZE_T Dummy = 0;
		
		// Create the bytes
		for ( SIZE_T i = 0; i < test.length (); i ++ )
		{
			// Avoid an exception
			if ( i + 1 < test.length () )
			{
				// Write the bytes
				if ( test.at (i) != ' ' )
				{
					// If you can form a two letter word
					if ( test.at ( i + 1 ) != ' ' )
					{
						// Obtain the string format
						string str;
						str += test.at (i);
						str += test.at (i + 1);

						// Convert it to LPVOID
						stringstream ss;
						ss << str;

						LPVOID lpVal;
						ss >> lpVal;

						// Check
						pBytes [Dummy] = (unsigned int) lpVal;
						
						++ Dummy;
						++ i;
					}
				}
			}
		}

		scanNum = 0;
		unknownScan = false;
	}
	else
	{
		if ( !strcmp ( szScan, "Unknown" ) )
		{	
			successRegion = 0;
			unknownNumber = 0;

			// Set settings
			scanNum     = -2;
			unknownScan = true;
		}
		else if ( !strcmp ( szScan, "Precise" ) )
		{
			// Set settings
			scanNum     = 0;
			unknownScan = false;		
		}
	}

	// Locate all regions
	LocateAllRegions ( dwStartScan, dwStopScan );

	// Begin scanning
	STS <T> ( MaxThreads, dwStartScan, dwStopScan );	
	
	// Reset scanning options
	ComboBox_ResetContent ( GetDlgItem ( mainDlg, IDC_COMBO2 ) );

	// Add new options
	if ( !ArrayOfBytes )
	{
		for ( int i = 0; i < _countof ( NSN2 ); i ++ )
			ComboBox_AddString ( GetDlgItem ( mainDlg, IDC_COMBO2 ), NSN2 [i] );

		// Unknown Initial Scan options
		if ( unknownScan )
		{
			SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, NULL, (LPARAM) "Increased by" );
			SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, NULL, (LPARAM) "Decreased by" );
			SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, NULL, (LPARAM) "Increased" );
			SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, NULL, (LPARAM) "Decreased" );
			SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, NULL, (LPARAM) "Changed" );
			SMX ( GetDlgItem ( mainDlg, IDC_COMBO2 ), CB_ADDSTRING, NULL, (LPARAM) "Unchanged" );
		}
	}

	// Set the new text
	if ( ArrayOfBytes )
		SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), oldScan );
	else
		SetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), "Precise" );

	// Display results
	SetWindowText ( GetDlgItem ( mainDlg, IDC_RESULT ), CTT ( result ).c_str () );

	// Notify 
	SetWindowText ( GetDlgItem ( mainDlg, IDC_PROGRESS ), "" );
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS ), SW_HIDE );

	// Enable next scan
	Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON2 ), TRUE );

	// Enable scan finished
	ScanFinished = true;

	// Beep
	MakeSound ();

	// Close the handle
	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode  );
}
//

// Next Scan
void                    NS3 ()
{
	int newResult   = 0;
	int finalResult = 0;
	int temp_result = (int) result;

	// Create the handle to the file
	hFile = CreateFile ( GetPathway ( "Memory.TMP" ).c_str (),  GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
	hNew  = CreateFile ( GetPathway ( "Memory2.TMP" ).c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );

	// Obtain the scan type
	char szScan [256] = {0};
	GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), szScan, 256 );

	// Create the offset
	int offset = ( (int) result / PreciseSize) + 1;

	// Set up progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
	SMX        ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETPOS, (WPARAM) 0, 0 );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETRANGE, 0, MAKELPARAM ( 0, offset ) );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETSTEP, (WPARAM) 1, 0 );

	// Begin
	for ( int readLoop = 0; readLoop < offset; readLoop ++ )
	{
		// Reset new result
		newResult = 0;

		// Obtain allocation size
		SIZE_T allocationSize;

		if ( readLoop == ( offset - 1 ) )
			allocationSize = (SIZE_T) result;
		else
			allocationSize = PreciseSize;

		// Initialize the variable
		dwScan = new DWORD [ allocationSize ];

		// Read the file
		DWORD dwBytes;
		::ReadFile ( hFile, dwScan, (allocationSize * 4), &dwBytes, 0 );

		// Begin the scan
		for ( SIZE_T i = 0; i < allocationSize; i ++ )
		{
			if ( CA ( dwScan [i] ) ) 
			{
				dwScan [newResult] = dwScan [i];
				++newResult;
			}
		}

		// Write the results
		DWORD dwWrite;
		::WriteFil ( hNew, dwScan, ( newResult * 4 ), &dwWrite, 0 );

		// Subtract from result
		result      -= allocationSize;
		finalResult += newResult;		

		// Delete the buffer		
		delete [] dwScan;

		// Increment progress bar
		SMX ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_STEPIT, 0, 0 );
		ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
	}

	// Setup final result
	result = finalResult;
	++scanNum;

	// Close the handles
	CloseHandle ( hFile );
	CloseHandle ( hNew  );

	// Delete the old buffer and rename
	DeleteFile ( GetPathway ( "OldMemory.TMP" ).c_str () );
	MoveFileEx ( GetPathway ( "Memory.TMP" ).c_str (),  GetPathway ( "OldMemory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );
	MoveFileEx ( GetPathway ( "Memory2.TMP" ).c_str (), GetPathway ( "Memory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );

	// Hide progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );
}
template <class T> void NS2 ( T Value )
{
	// Declare
	DWORD dwEndAddr = NULL;

	// Initialize scan
	Setup ();

	// Obtain the scan type
	char szScan [256] = {0};
	GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), szScan, 256 );

	// Begin
	if ( !unknownNumber )
	{
		// Begin
		for ( int x = 0; x < successRegion; x ++ )
		{
			// Reset
			newResult = 0;

			// Declare
			DWORD * Pointers;
			BYTE  * Values;

			// Attempt
			__try 
			{
				// Create
				dwEndAddr = AllRegions [ SuccessReg [x] ].dwBaseAddr + (DWORD) ( AllRegions [ SuccessReg [x] ].szRegion - 1 - sizeof (T) );

				// Initialize the variable
				Pointers = new DWORD [ AllRegions [ SuccessReg [x] ].szRegion ];
				Values   = new BYTE  [ AllRegions [ SuccessReg [x] ].szRegion * sizeof (T) ];

				// Obtain memory info
				DWORD dwBytes;
				::ReadFile ( hFile, Values, AllRegions [ SuccessReg [x] ].szRegion, &dwBytes, 0 );

				// Scanning Options
				if ( !strcmp ( szScan, "Precise" ) )
				{
					// Go through the results				
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{					
						// Read the value
						T check = RV <T> ( Addr );

						if ( check == Value )
						{
							// Set information
							*(T*) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Greater Than" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check > Value )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Lower Than" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check < Value )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Increased by" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check - *(T*) &Values [ (Addr - AllRegions [ SuccessReg [x] ].dwBaseAddr) * sizeof (T)] == Value )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Decreased by" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( *(T*) (DWORD) &Values [ (Addr - AllRegions [ SuccessReg [x] ].dwBaseAddr) ] - check == Value )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Increased" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check > *(T*) &Values [ (Addr - AllRegions [ SuccessReg [x] ].dwBaseAddr) ] )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Decreased" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check < *(T*) &Values [ (Addr - AllRegions [ SuccessReg [x] ].dwBaseAddr) ] )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Changed" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check != *(T*) &Values [ (Addr - AllRegions [ SuccessReg [x] ].dwBaseAddr) ] )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}
				else if ( !strcmp ( szScan, "Unchanged" ) )
				{
					for ( DWORD Addr = AllRegions [ SuccessReg [x] ].dwBaseAddr; Addr < dwEndAddr; Addr ++ )
					{
						T check = *(T*) Addr;

						if ( check == *(T*) &Values [ (Addr - AllRegions [ SuccessReg [x] ].dwBaseAddr) ] )
						{
							// Set information
							*(T*) (DWORD) &Values  [newResult * sizeof (T)] = check;
							Pointers [newResult] = Addr;

							// Increment results
							++ newResult;
						}
					}
				}

				// Write 
				WriteToFile ( hAddress, Pointers, newResult * 4 );
				WriteToFile ( hValues,    Values, newResult * sizeof (T) );

				// Subtract from result
				finalResult += newResult;

				// Delete the buffer		
				delete [] Pointers;
				delete [] Values;

				Progress ();
			}
			__except ( true )
			{
				// Delete the buffer		
				delete [] Pointers;
				delete [] Values;

				Progress ();
			}
		}
	}
	else 
	{
		SIZE_T offset = ( (SIZE_T) result / UnknownSize ) + 1;

		for ( SIZE_T readLoop = 0; readLoop < offset; readLoop ++ )
		{
			// Reset new result
			newResult = 0;

			// Obtain allocation size
			SIZE_T allocationSize;

			if ( readLoop == ( offset - 1 ) )
				allocationSize = (SIZE_T) result;
			else
				allocationSize = UnknownSize;

			// Initialize the variable
			DWORD * dwAddress = new DWORD [ allocationSize ];
			BYTE  * Values    = new BYTE  [ allocationSize * sizeof (T) ];

			// Obtain the information
			DWORD dwBytes;
			::ReadFile ( hFile, dwAddress, allocationSize * sizeof (DWORD), &dwBytes, 0 );
			::ReadFile ( hNew,     Values, allocationSize * sizeof (T), &dwBytes, 0 );

			// Scan
			if ( !strcmp ( szScan, "Precise" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check == Value )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Greater Than" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check > Value )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Lower Than" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check < Value )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Increased by" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check - *(T*) &Values [i * sizeof (T)] == Value )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Decreased by" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( *(T*) &Values [i * sizeof (T)] - check == Value )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Increased" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check > *(T*) &Values [i * sizeof (T)] )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Decreased" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check < *(T*) &Values [i * sizeof (T)] )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Changed" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check != *(T*) &Values [i * sizeof (T)] )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}
			else if ( !strcmp ( szScan, "Unchanged" ) )
			{
				for ( SIZE_T i = 0; i < allocationSize; i ++ )
				{
					T check = RV <T> ( dwAddress [i] );

					if ( check == *(T*) &Values [i * sizeof (T)] )
					{
						*(T*) &Values  [newResult * sizeof (T)] = check;
						dwAddress      [newResult] = dwAddress [i];
						++ newResult;
					}
				}
			}

			// Write the new results
			DWORD dwWrite;
			::WriteFil ( hAddress, dwAddress, newResult * 4, &dwWrite, 0 );
			::WriteFil ( hValues,     Values, newResult * sizeof (T), &dwWrite, 0 );

			// Subtract from result
			result      -= allocationSize;
			finalResult += newResult;

			// Delete the buffer		
			delete [] dwAddress;
			delete [] Values;

			// Increment progress bar
			SMX ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_STEPIT, 0, 0 );
			ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
		}
	}

	// Finish the scan
	FinishNS ();
}
template <class T> void NS1 ( T Value )
{
	int newResult   = 0;
	int finalResult = 0;
	int temp_result = (int) result;

	// Create the handle to the file
	HANDLE hFile = CreateFile ( GetPathway ( "Memory.TMP" ).c_str (),  GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
	HANDLE hNew  = CreateFile ( GetPathway ( "Memory2.TMP" ).c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );

	// Obtain the scan type
	char szScan [256] = {0};
	GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), szScan, 256 );

	// Create the offset
	int offset = ( (int) result / PreciseSize) + 1;

	// Set up progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
	SMX        ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETPOS, (WPARAM) 0, 0 );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETRANGE, 0, MAKELPARAM ( 0, offset ) );
	SMX		   ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_SETSTEP, (WPARAM) 1, 0 );

	// Begin
	for ( int readLoop = 0; readLoop < offset; readLoop ++ )
	{
		// Reset new result
		newResult = 0;

		// Obtain allocation size
		SIZE_T allocationSize;

		if ( readLoop == ( offset - 1 ) )
			allocationSize = (SIZE_T) result;
		else
			allocationSize = PreciseSize;

		// Initialize the variable
		dwScan = new DWORD [ allocationSize ];

		// Read the file
		DWORD dwBytes;
		::ReadFile ( hFile, dwScan, (allocationSize * 4), &dwBytes, 0 );

		// Begin the scan
		if ( !strcmp ( szScan, "Precise" ) )
		{
			for ( SIZE_T i = 0; i < allocationSize; i ++ )
			{
				if ( !strcmp ( typeid (T).name (), "float" ) )
				{
					// Check values
					if ( fabs ( (float) ( RV <float> ( dwScan [i] ) - Value ) ) <= (float) Epislon ) 
					{	
						dwScan [newResult] = dwScan [i];
						++newResult;
					}
				}
				else if ( !strcmp ( typeid (T).name (), "double" ) )
				{
					// Check values
					if ( fabs ( (double) ( RV <double> ( dwScan [i] ) - Value ) ) <= (double) Epislon ) 
					{	
						dwScan [newResult] = dwScan [i];
						++newResult;
					}
				}
				else
				{
					if ( CMP <T> ( dwScan [i], Value ) ) 
					{		
						dwScan [newResult] = dwScan [i];
						++newResult;
					}
				}
			}
		}
		// Greater than
		if ( !strcmp ( szScan, "Greater Than" ) )
		{
			for ( SIZE_T i = 0; i < allocationSize; i ++ )
			{
				if ( RV <T> ( dwScan [i] ) > Value )
				{
					dwScan [newResult] = dwScan [i];
					++newResult;
				}
			}
		}
		// Lower than
		if ( !strcmp ( szScan, "Lower Than" ) )
		{
			for ( SIZE_T i = 0; i < allocationSize; i ++ )
			{
				if ( RV <T> ( dwScan [i] ) < Value )
				{
					dwScan [newResult] = dwScan [i];
					++newResult;
				}
			}
		}	

		// Write the results
		DWORD dwWrite;
		::WriteFil ( hNew, dwScan, ( newResult * 4 ), &dwWrite, 0 );

		// Subtract from result
		result      -= allocationSize;
		finalResult += newResult;

		// Delete the buffer		
		delete [] dwScan;

		// Increment progress bar
		SMX ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), PBM_STEPIT, 0, 0 );
		ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_SHOWNORMAL );
	}

	// Setup final result
	result = finalResult;
	++scanNum;

	// Close the handles
	CloseHandle ( hFile );
	CloseHandle ( hNew  );

	// Delete the old buffer and rename
	DeleteFile ( GetPathway ( "OldMemory.TMP" ).c_str () );
	MoveFileEx ( GetPathway ( "Memory.TMP" ).c_str (),  GetPathway ( "OldMemory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );
	MoveFileEx ( GetPathway ( "Memory2.TMP" ).c_str (), GetPathway ( "Memory.TMP" ).c_str (), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED );

	// Hide progress bar
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );
}
template <class T> void GN  ()
{
	oldResult = (int) result;

	// See if the value is hex
	bool hex = SMX ( GetDlgItem ( mainDlg, IDC_CHECKBOX1 ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;

	// Obtain the value
	T Value;
	
	if ( hex )
		Value = ConvertTextTo <LPVOID, T> ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );
	else
		Value = ConvertTextTo <T, T>	  ( GetDlgItem ( mainDlg, IDC_EDIT1 ) );

	// Clear the listbox
	SMX ( GetDlgItem ( mainDlg, IDC_LIST1 ), LB_RESETCONTENT, 0, 0 );
	
	// Obtain the scan type
	char szScan [256] = {0};
	GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO2 ), szScan, 256 );

	// Begin the scan
	if      ( ArrayOfBytes )
	{
		// Setup variables
		string test;
		char szBuffer [256] = {0};
		GetWindowText ( GetDlgItem ( mainDlg, IDC_EDIT1 ), szBuffer, 256 );

		// Obtain the value
		if ( !strcmp ( szScan, "Array of Bytes" ) ) {
			test += szBuffer;
		}
		else {
			string buffer;
			buffer += szBuffer;		
			test += CTB ( buffer );
		}

		szBytes = 0;

		// Obtain the number of bytes
		for ( SIZE_T i = 0; i < test.length (); i ++ )
		{
			// Avoid an exception
			if ( i + 1 < test.length () )
			{
				// Find the number of bytes 
				if ( test.at (i) != ' ' )
				{
					// If you can form a two letter word
					if ( test.at ( i + 1 ) != ' ' )
					{
						++ szBytes;
					}
				}
			}
		}

		// Setup the variable
		delete [] pBytes;
		pBytes = new BYTE [ szBytes ];
		SIZE_T Dummy = 0;
		
		// Create the bytes
		for ( SIZE_T i = 0; i < test.length (); i ++ )
		{
			// Avoid an exception
			if ( i + 1 < test.length () )
			{
				// Write the bytes
				if ( test.at (i) != ' ' )
				{
					// If you can form a two letter word
					if ( test.at ( i + 1 ) != ' ' )
					{
						// Obtain the string format
						string str;
						str += test.at (i);
						str += test.at (i + 1);

						// Convert it to LPVOID
						stringstream ss;
						ss << str;

						LPVOID lpVal;
						ss >> lpVal;

						// Check
						pBytes [Dummy] = (unsigned int) lpVal;
						
						++ Dummy;
						++ i;
					}
				}
			}
		}

		NS3 ();
	}
	else if ( !unknownScan ) 
		NS1  <T> ( Value );
	else 
	{
		NS2  <T> ( Value );
	}
	
	// Notify 
	SetWindowText ( GetDlgItem ( mainDlg, IDC_PROGRESS ), "" );
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS ), SW_HIDE );

	// Display results
	SetWindowText ( GetDlgItem ( mainDlg, IDC_RESULT ), CTT ( result ).c_str () );

	// Notify the user the scan has finished
	ShowWindow ( GetDlgItem ( mainDlg, IDC_PROGRESS1 ), SW_HIDE );

	// Enable 'New Scan'
	Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON2 ), TRUE );

	// Enable 'Undo Scan'
	Button_Enable ( GetDlgItem ( mainDlg, IDC_BUTTON8 ), TRUE );

	ScanFinished = true;

	// Beep
	MakeSound ();

	// Close the handle
	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	ExitThread		  ( dwExitCode );
}
//

// Pointer Scanner
void PS ( DWORD dwAddress, DWORD Range, bool GoStatic )
{
	// Setup minimum value
	DWORD dwMinimum = dwAddress - Range;

	// Keep track of results
	PointerResult = 0;

	// Scan the memory
	for ( DWORD i = dwStartScan; i < dwStopScan; i ++ )
	{
		MEMORY_BASIC_INFORMATION MBI;
		VQ ( (LPCVOID) i, &MBI, sizeof ( MEMORY_BASIC_INFORMATION ) );

		// Check the range
		if ( MBI.State == MEM_COMMIT )
		{
			// Check the static information
			HMODULE hModule;

			if ( GoStatic == true )
				GetModuleHandleEx ( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR) (DWORD) MBI.BaseAddress, &hModule );

			// Check if its a static region
			if ( ( GoStatic == true && hModule != NULL ) ||
				 ( GoStatic == false ) )
			{
				// Last address
				DWORD dwLastAddr = (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize;
				dwLastAddr = dwLastAddr - 1 - sizeof ( DWORD );

				// Read the region
				for ( DWORD ptr = (DWORD) MBI.BaseAddress; ptr < dwLastAddr && PointerResult < 100000; ptr ++ )
				{
					// Obtain the value
					DWORD dwVal = RV <DWORD> ( ptr );	

					// Check if the value is in the range
					if ( dwVal >= dwMinimum && dwVal <= dwAddress ) 
					{			
						// Add the result
						dwPtrScan [PointerResult] = ptr;
						++ PointerResult;
					}
				}
			}
		}	

		i = (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize;
	}
}
void GP ()
{
	// Clear the list
	SMX ( GetDlgItem ( ptrDlg, IDC_LIST1 ), LB_RESETCONTENT, 0, 0 );

	// Call the function
	PS ( ptrInfo.dwAddress, ptrInfo.dwRange, ptrInfo.GoStatic );

	// Adding Results
	SetWindowText ( GetDlgItem ( ptrDlg, IDC_RESULT2 ), "Adding Results" );

	// Add the results
	for ( int i = 0; i < PointerResult; i ++ )
	{
		string Pointer = "[ ";

		// Check pointer information
		STATIC_INFO staticInfo = CS ( dwPtrScan [ i ] );

		Pointer += staticInfo.PointerInfo;
		Pointer += " ] + ";

		// Obtain value
		DWORD dwValue = RV <DWORD> ( dwPtrScan [ i ] );

		Pointer += RTrimZero ( ConvertToText <void*> ( (void*) ( dwValue > ptrInfo.dwAddress ? dwValue - ptrInfo.dwAddress : ptrInfo.dwAddress - dwValue ) ) );

		// Add result
		IR2 ( Pointer );
	}

	// Set the results
	SetWindowText ( GetDlgItem ( ptrDlg, IDC_RESULT2 ), CTT ( PointerResult ).c_str () );

	// Beep
	MakeSound ();

	// Enable scan button
	Button_Enable ( GetDlgItem ( ptrDlg, IDC_BUTTON1 ), TRUE );

	// Close the handle
	DWORD dwExitCode;
	GetExitCodeThread ( hPtrScan, &dwExitCode );
	TerminateThread   ( hPtrScan, dwExitCode  );
}
//

// Memory Viewer
void MV ( DWORD dwStart, DWORD dwStop )
{
	// Keep track of results
	myResult = 0;

	// Setup file
	ofstream File ( "C:\\MemoryScan.iScan" );
	File.clear ();

	ofstream Hex  ( "C:\\MemoryText.iScan" );
	Hex.clear ();

	// Begin reading
	for ( DWORD i = dwStart; i <= dwStop; i += 0x10 )
	{
		// Setup bytes
		BYTE * myBytes;
		myBytes = new BYTE [16];

		// Read the bytes
		if ( RB ( i, myBytes ) )
		{
			++myResult;

			// Initialize the string
			string Text   = CTT ( myResult );
			string Output = CTT ( myResult );	

			Text         += ". ";
			Output       += ". ";

			// Fix output
			Output       += CTT <LPVOID> ( (LPVOID) i );
			Output       += " - ";

			// Add all the bytes
			for ( int index = 0; index < 16; index ++ ) {
				Output += TrimZero ( CTT <LPVOID> ( (LPVOID) (unsigned int) myBytes [index] ) );
				Output += " ";

				char myChar = (char) myBytes [index];

				// Skip NULL and new line
				if ( !myChar || myChar == 0x0A )
					Text += ".";
				else
					Text += myChar;
			}

			// Add the file
			File << Output << endl;
			Hex  << Text   << endl;
		}
	}

	// Close the file
	File.close ();
	Hex.close ();
}
void GM2 ()
{
	// Clear the listbox
	SMX ( GetDlgItem ( memDlg, IDC_LIST1 ), LB_RESETCONTENT, 0, 0 );
	SMX ( GetDlgItem ( memDlg, IDC_LIST2 ), LB_RESETCONTENT, 0, 0 );

	// Set the status
	SetWindowText ( GetDlgItem ( memDlg, IDC_RESULT3 ), "Scanning!" );

	// Call MV () func
	MV ( dwMS1, dwMS2 );

	// Set the status
	SetWindowText ( GetDlgItem ( memDlg, IDC_RESULT3 ), "Adding Results" );

	// Setup the file
	ifstream File ( "C:\\MemoryScan.iScan" );
	ifstream Hex  ( "C:\\MemoryText.iScan" );

	// Read and add results
	while ( !File.eof () )
	{
		// Obtain the string
		string myLine, myHex;
		getline ( File, myLine );
		getline ( Hex, myHex );

		// Insert the result
		if ( strcmp ( myLine.c_str (), "" ) != 0 && strcmp ( myHex.c_str (), "" ) != 0 ) {
			SMX ( GetDlgItem ( memDlg, IDC_LIST1 ), LB_ADDSTRING, 0, (LPARAM) myLine.c_str () );
			SMX ( GetDlgItem ( memDlg, IDC_LIST2 ), LB_ADDSTRING, 0, (LPARAM) myHex.c_str ()  );
		}
	}

	// Close the files
	File.close ();
	Hex.close  ();

	// Set the status
	SetWindowText ( GetDlgItem ( memDlg, IDC_RESULT3 ), "" );

	// Beep
	MakeSound ();

	// Close the handle
	DWORD dwExitCode;
	GetExitCodeThread ( hMemScan, &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode  );
}
//

// Function Watcher
__declspec ( naked ) void HookTo ()
{
	__asm 
	{
		push ebp
		push ebx
		push edx
		push esp
		push ecx
		push eax
		push esp
		push esi
		push edi
	}

	SMX ( GetDlgItem ( fwDlg, IDC_LIST1 ), LB_ADDSTRING, 0, (LPARAM) FuncCalled.c_str () );

	// Protect the memory
	VirtualProtect ( (void*) dwFunction, 5, PAGE_EXECUTE_READWRITE, &dwOldProtect );

	// Rewrite the bytes
	memcpy ( (void*) dwFunction, &originalBytes, 5 );	

	// Remove hook
	VirtualProtect ( (void*) dwFunction, 5, PAGE_EXECUTE_READWRITE, &dwDummy );

	// JMP to original func
	__asm 
	{
		pop edi
		pop esi
		pop esp
		pop eax
		pop ecx
		pop esp
		pop edx
		pop ebx
		pop ebp

		jmp [ dwFunction ];
	}
}

void SetHook (string Library, string Function)
{
	SMX ( GetDlgItem ( fwDlg, IDC_LIST1 ), LB_RESETCONTENT, 0, 0 );

	// Set string
	FuncCalled = "-> ";
	FuncCalled += Function;
	FuncCalled += " () in library ";
	FuncCalled += Library.c_str ();
	FuncCalled += " has been called.";

	// Declare variables
	DWORD dwNewProtect;

	// Obtain Function addr
	dwFunction = (DWORD) GetProcAddress ( GetModuleHandle (Library.c_str ()), Function.c_str () );

	if ( dwFunction != 0 )
	{
		// Protect the memory
		VirtualProtect ( (void*) dwFunction, 5, PAGE_EXECUTE_READWRITE, &dwOldProtect );

		// Copy the first five bytes
		memcpy ( &originalBytes, (void*) dwFunction, 5 );

		// Set the hook
		*(BYTE*)    dwFunction       = 0xE9;
		*(DWORD*) ( dwFunction + 1 ) = ( (DWORD) &HookTo - ( dwFunction + 0x5) );

		VirtualProtect ( (void*) dwFunction, 5, dwOldProtect, &dwNewProtect );

		// Beep
		MakeSound ();
	}
	else
	{
		FuncCalled = "The function ";
		FuncCalled += Function.c_str ();
		FuncCalled += " can't be located.";

		SMX ( GetDlgItem ( fwDlg, IDC_LIST1 ), LB_ADDSTRING, 0, (LPARAM) FuncCalled.c_str () );
	}
}
//

// Handling the results
void InsertResult ( void* lpAddr )
{
	// Get Item
	int item = ListView_GetItemCount ( GetDlgItem ( dbgDlg, IDC_LIST1 ) );

	// Setup item
	LV_ITEM lv;
	lv.iItem    = item;           
	lv.iSubItem = 0;
	lv.mask     = LVIF_TEXT;       
	lv.pszText  = "";
	lv.cchTextMax = 256; 

	// Insert item
	ListView_InsertItem ( GetDlgItem ( dbgDlg, IDC_LIST1 ), &lv );

	// Fix subitems
	for ( int i = 0; i < 2; i ++ )
	{
		// Setup neccessary values
		lv.iSubItem   = i;
		lv.cchTextMax = 256;

		// Setup text
		string str = "";

		if ( !i )
			str = "1";
		else
			str = CTT <LPVOID> ( lpAddr );

		// Add item
		if ( !strcmp ( str.c_str (), "" ) )
			str = "Error";

		lv.pszText = (LPSTR) str.c_str ();

		// Insert subitem
		ListView_SetItem ( GetDlgItem ( dbgDlg, IDC_LIST1 ), &lv );
	}
}
void CheckResult  ( void* Exception )
{	
	// Obtain system information
	SYSTEM_INFO SI;
	GetSystemInfo ( &SI );

	// 
	DWORD  dwAddr = (DWORD) Exception;
	DISASM myDisasm;

	// Find the last address
	for ( int i = 0; i < 10; i++ )
	{
		myDisasm.EIP = dwAddr;
		DWORD length = (DWORD) Disasm ( &myDisasm );
		DWORD dwPossibility = 0;

		if ( length != 0xFFFFFFFF )
			dwPossibility = dwAddr - length;
		else
			break;

		if ( dwPossibility >= (DWORD) SI.lpMinimumApplicationAddress &&
			 dwPossibility <= (DWORD) SI.lpMaximumApplicationAddress ) 
			dwAddr = dwPossibility;
		else
			break;
	}

	dwAddr -= 0x1;

	DWORD dwPrevAddr = dwAddr;

	// Get disassembler information
	void* ExceptionAddr = 0;

	for ( int i = 0; i < 20; i ++ )
	{
		if ( dwAddr == (DWORD) Exception )
			break;
		
		myDisasm.EIP = dwAddr;
		DWORD Length = (DWORD) Disasm ( &myDisasm );

		while ( Length == 0xFFFFFFFF )
		{
			dwAddr += 0x1;
			myDisasm.EIP = dwAddr;
			Length = (DWORD) Disasm ( &myDisasm );
		}

		dwPrevAddr = dwAddr;
		dwAddr    += Length;
	}

	ExceptionAddr = (void*) dwPrevAddr;

	bool NoAdd = false;

	// Check if the item exists
	int max = ListView_GetItemCount ( GetDlgItem ( dbgDlg, IDC_LIST1 ) );

	if ( !max )
	{
		InsertResult ( ExceptionAddr );
		Dbged [numOfDbg] = ExceptionAddr;
		++numOfDbg;
	}
	else
	{
		int i = 0;

		for ( i = 0; i < numOfDbg; i ++ )
		{
			if ( Dbged [i] == ExceptionAddr )
			{
				NoAdd = true;
				break;
			}
		}

		if ( !NoAdd && ExceptionAddr != 0 )
		{
			InsertResult ( ExceptionAddr );
			Dbged [numOfDbg] = ExceptionAddr;
			++numOfDbg;
		}
		else
		{
			// Increment the count
			char szCount [256] = {0};
			ListView_GetItemText ( GetDlgItem ( dbgDlg, IDC_LIST1 ), i, 0, szCount, 256 );

			stringstream ss2;
			ss2 << szCount;

			int Count = 0;
			ss2 >> Count;
			++Count;

			// Convert count to string
			string str = CTT <int> ( Count );

			// Add the information
			LV_ITEM lv;
			lv.iItem    = i;           
			lv.iSubItem = 0;
			lv.mask     = LVIF_TEXT;       
			lv.pszText  = (LPSTR) str.c_str ();
			lv.cchTextMax = 256; 

			// Insert subitem
			ListView_SetItem ( GetDlgItem ( dbgDlg, IDC_LIST1 ), &lv );
		}
	}

	// Close the handle
	DWORD dwExitCode;
	GetExitCodeThread ( GetCurrentThread (), &dwExitCode );
	TerminateThread   ( GetCurrentThread (), dwExitCode  );
}
//

// Set bits
DWORD GetDr7 ( int BreakType, int Length, bool GE, bool LE, bool Local, bool Global, bool GD )
{
	bitset <32> myBitset;	
	
	// Set the break on condition
	if ( BreakType == 00 )
	{
		myBitset.set ( 16, 0 );
		myBitset.set ( 17, 0 );
		myBitset.set ( 20, 0 );
		myBitset.set ( 21, 0 );
		myBitset.set ( 24, 0 );
		myBitset.set ( 25, 0 );
		myBitset.set ( 28, 0 );
		myBitset.set ( 29, 0 );	
	}
	if ( BreakType == 01 )
	{
		myBitset.set ( 16, 0 );
		myBitset.set ( 17, 1 );
		myBitset.set ( 20, 0 );
		myBitset.set ( 21, 1 );
		myBitset.set ( 24, 0 );
		myBitset.set ( 25, 1 );
		myBitset.set ( 28, 0 );
		myBitset.set ( 29, 1 );	
	}
	if ( BreakType == 10 )
	{
		myBitset.set ( 16, 1 );
		myBitset.set ( 17, 0 );
		myBitset.set ( 20, 1 );
		myBitset.set ( 21, 0 );
		myBitset.set ( 24, 1 );
		myBitset.set ( 25, 0 );
		myBitset.set ( 28, 1 );
		myBitset.set ( 29, 0 );	
	}
	else
	{
		myBitset.set ( 16, 1 );
		myBitset.set ( 17, 1 );
		myBitset.set ( 20, 1 );
		myBitset.set ( 21, 1 );
		myBitset.set ( 24, 1 );
		myBitset.set ( 25, 1 );
		myBitset.set ( 28, 1 );
		myBitset.set ( 29, 1 );	
	}

	// Set the length
	if ( Length == 00 )
	{
		myBitset.set ( 18, 0 );
		myBitset.set ( 19, 0 );
		myBitset.set ( 22, 0 );
		myBitset.set ( 23, 0 );
		myBitset.set ( 26, 0 );
		myBitset.set ( 27, 0 );
		myBitset.set ( 30, 0 );
		myBitset.set ( 31, 0 );	
	}
	if ( Length == 01 )
	{
		myBitset.set ( 18, 0 );
		myBitset.set ( 19, 1 );
		myBitset.set ( 22, 0 );
		myBitset.set ( 23, 1 );
		myBitset.set ( 26, 0 );
		myBitset.set ( 27, 1 );
		myBitset.set ( 30, 0 );
		myBitset.set ( 31, 1 );		
	}
	if ( Length == 10 )
	{
		myBitset.set ( 18, 1 );
		myBitset.set ( 19, 0 );
		myBitset.set ( 22, 1 );
		myBitset.set ( 23, 0 );
		myBitset.set ( 26, 1 );
		myBitset.set ( 27, 0 );
		myBitset.set ( 30, 1 );
		myBitset.set ( 31, 0 );	
	}
	else
	{
		myBitset.set ( 18, 1 );
		myBitset.set ( 19, 1 );
		myBitset.set ( 22, 1 );
		myBitset.set ( 23, 1 );
		myBitset.set ( 26, 1 );
		myBitset.set ( 27, 1 );
		myBitset.set ( 30, 1 );
		myBitset.set ( 31, 1 );	
	}	

	if ( GE )
		myBitset.set ( 9, 1 );
	else
		myBitset.set ( 9, 1 );

	if ( LE )
		myBitset.set ( 8, 1 );
	else
		myBitset.set ( 8, 1 );

	if ( Local )
	{
		for ( int i = 0; i <= 6; i += 2 )
			myBitset.set ( i, 1 );
	}
	else
	{
		for ( int i = 0; i <= 6; i += 2 )
			myBitset.set ( i, 0 );
	}

	if ( Global )
	{
		for ( int i = 1; i <= 7; i += 2 )
			myBitset.set ( i, 1 );
	}
	else
	{
		for ( int i = 1; i <= 7; i += 2 )
			myBitset.set ( i, 0 );
	}

	if ( GD )
		myBitset.set ( 13, 1 );
	else
		myBitset.set ( 13, 0 );

	return (DWORD) myBitset.to_ulong ();
}

//

//
ofstream File ( "C:\\breakpoint.txt" );

void CheckBreakpoint ()
{
	// Initialize our variable
	THREADENTRY32 te;
	te.dwSize = sizeof ( THREADENTRY32 );

	// Create the snapshot
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPTHREAD, 0 );

	if ( Thread32First ( hSnapshot, &te ) )
	{
		// Check the thread
		if ( te.th32OwnerProcessID == GetCurrentProcessId () && te.th32ThreadID != GetCurrentThreadId () )
		{
			// Open the thread
			HANDLE hThread = OpenThread ( THREAD_SUSPEND_RESUME | THREAD_SET_CONTEXT | THREAD_GET_CONTEXT, false, te.th32ThreadID );

			// Suspend the thread
			SuspendThread ( hThread );

			// Obtain the thread information
			CONTEXT Context;
			Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

			// Obtain the thread information
			GetThreadContext ( hThread, &Context );

			// Display 
			File << "Dr0: " << (void*) Context.Dr0 << endl;
			File << "Dr1: " << (void*) Context.Dr1 << endl;
			File << "Dr2: " << (void*) Context.Dr2 << endl;
			File << "Dr3: " << (void*) Context.Dr3 << endl;
			File << endl;
			
			// Resume the thread
			ResumeThread ( hThread );
			CloseHandle  ( hThread );
		}

		while ( Thread32Next ( hSnapshot, &te ) )
		{
			// Check the thread
			if ( te.th32OwnerProcessID == GetCurrentProcessId () && te.th32ThreadID != GetCurrentThreadId () )
			{
				// Open the thread
				HANDLE hThread = OpenThread ( THREAD_SUSPEND_RESUME | THREAD_SET_CONTEXT | THREAD_GET_CONTEXT, false, te.th32ThreadID );

				// Suspend the thread
				SuspendThread ( hThread );

				// Obtain the thread information
				CONTEXT Context;
				Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

				// Obtain the thread information
				GetThreadContext ( hThread, &Context );

				// Display 
				File << "Dr0: " << (void*) Context.Dr0 << endl;
				File << "Dr1: " << (void*) Context.Dr1 << endl;
				File << "Dr2: " << (void*) Context.Dr2 << endl;
				File << "Dr3: " << (void*) Context.Dr3 << endl;
				File << endl;

				// Resume the thread
				ResumeThread ( hThread );
				CloseHandle  ( hThread );
			}
		}
	}
}
void DoBreakpoint ()
{
	while ( true )
	{
		CheckBreakpoint ();
		Sleep ( 5000 );
	}
}
//

// Handling/Setting the breakpoint
LONG CALLBACK VectoredHandler ( PEXCEPTION_POINTERS ExceptionInfo )
{
	if ( dbgOn )
	{
		if ( ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_SINGLE_STEP )
		{
			Sleep ( 100 );

			if ( (DWORD) ExceptionInfo->ExceptionRecord->ExceptionAddress < dwNoStartScan ||
				 (DWORD) ExceptionInfo->ExceptionRecord->ExceptionAddress > dwNoStopScan )
			{
				bool add = true;

				for ( int i = 0; i < numOfDbg; i ++ ) {
					if ( dbgInfo [i].lpAddr == ExceptionInfo->ExceptionRecord->ExceptionAddress ) {
						add = false;
						break;
					}
				}

				if ( add ) 
				{
					dbgInfo [numOfDbg].lpAddr = ExceptionInfo->ExceptionRecord->ExceptionAddress;
					dbgInfo [numOfDbg].EAX    = ExceptionInfo->ContextRecord->Eax;
					dbgInfo [numOfDbg].EBP    = ExceptionInfo->ContextRecord->Ebp;
					dbgInfo [numOfDbg].EBX    = ExceptionInfo->ContextRecord->Ebx;
					dbgInfo [numOfDbg].ECX    = ExceptionInfo->ContextRecord->Ecx;
					dbgInfo [numOfDbg].EDI    = ExceptionInfo->ContextRecord->Edi;
					dbgInfo [numOfDbg].EDX    = ExceptionInfo->ContextRecord->Edx;
					dbgInfo [numOfDbg].EIP    = ExceptionInfo->ContextRecord->Eip;
					dbgInfo [numOfDbg].ESI    = ExceptionInfo->ContextRecord->Esi;
					dbgInfo [numOfDbg].ESP    = ExceptionInfo->ContextRecord->Esp;
				}

				CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) CheckResult, ExceptionInfo->ExceptionRecord->ExceptionAddress, NULL, NULL );
			}

			return EXCEPTION_CONTINUE_EXECUTION;
		}
	}

	if ( localBrk )
	{
		if ( ( ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION ) ||
		     ( ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT    ) )
		{
			Sleep ( 100 );

			// Add result
			bool add = true;

			for ( int i = 0; i < numOfDbg; i ++ ) {
				if ( dbgInfo [i].lpAddr == (void*) RV <DWORD> ( ExceptionInfo->ContextRecord->Esp ) ) {
					add = false;
					break;
				}
			}

			if ( add ) 
			{
				dbgInfo [numOfDbg].lpAddr = (void*) RV <DWORD> ( ExceptionInfo->ContextRecord->Esp );
				dbgInfo [numOfDbg].EAX    = ExceptionInfo->ContextRecord->Eax;
				dbgInfo [numOfDbg].EBP    = ExceptionInfo->ContextRecord->Ebp;
				dbgInfo [numOfDbg].EBX    = ExceptionInfo->ContextRecord->Ebx;
				dbgInfo [numOfDbg].ECX    = ExceptionInfo->ContextRecord->Ecx;
				dbgInfo [numOfDbg].EDI    = ExceptionInfo->ContextRecord->Edi;
				dbgInfo [numOfDbg].EDX    = ExceptionInfo->ContextRecord->Edx;
				dbgInfo [numOfDbg].EIP    = ExceptionInfo->ContextRecord->Eip;
				dbgInfo [numOfDbg].ESI    = ExceptionInfo->ContextRecord->Esi;
				dbgInfo [numOfDbg].ESP    = ExceptionInfo->ContextRecord->Esp;
			}

			CreateThread ( NULL, NULL, (LPTHREAD_START_ROUTINE) CheckResult, (void*) RV <DWORD> ( ExceptionInfo->ContextRecord->Esp ), NULL, NULL );

			// Continue
			return EXCEPTION_CONTINUE_EXECUTION;
		}
	}

	return EXCEPTION_CONTINUE_SEARCH;
}
bool            SetBreakpoint ( DWORD dwAddr, int Type )
{
	if ( dbgOn )
	{
		dwDbgAddr = dwAddr;

		// Initialize our variable
		THREADENTRY32 te;
		te.dwSize = sizeof ( THREADENTRY32 );

		// Create the snapshot
		HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPTHREAD, 0 );

		if ( Thread32First ( hSnapshot, &te ) )
		{
			// Check the thread
			if ( te.th32OwnerProcessID == GetCurrentProcessId () && te.th32ThreadID != GetCurrentThreadId () )
			{
				// Open the thread
				HANDLE hThread = OpenThread ( THREAD_SUSPEND_RESUME | THREAD_SET_CONTEXT | THREAD_GET_CONTEXT, false, te.th32ThreadID );

				// Suspend the thread
				SuspendThread ( hThread );

				// Obtain the thread information
				CONTEXT Context;
				Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

				// Obtain the thread information
				GetThreadContext ( hThread, &Context );

				// Find an available regiser and set it
				//Context.Dr0 = dwAddr;
				Context.Dr1 = dwAddr;
				Context.Dr2 = dwAddr;
				Context.Dr3 = dwAddr;

				// Set the Dr7 register
				if ( !Type )
					Context.Dr7 = GetDr7 ( 11, 11, true, true, true, true, true);
				else if ( Type == 1 )
					Context.Dr7 = GetDr7 ( 10, 11, true, true, true, true, true);
				else if ( Type == 2 )
					Context.Dr7 = GetDr7 ( 00, 11, true, true, true, true, true );

				// Set the thread information
				SetThreadContext ( hThread, &Context );

				// Resume the thread
				ResumeThread ( hThread );
				CloseHandle  ( hThread );
			}

			while ( Thread32Next ( hSnapshot, &te ) )
			{
				// Check the thread
				if ( te.th32OwnerProcessID == GetCurrentProcessId () && te.th32ThreadID != GetCurrentThreadId () )
				{
					// Open the thread
					HANDLE hThread = OpenThread ( THREAD_SUSPEND_RESUME | THREAD_SET_CONTEXT | THREAD_GET_CONTEXT, false, te.th32ThreadID );

					// Suspend the thread
					SuspendThread ( hThread );

					// Obtain the thread information
					CONTEXT Context;
					Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

					// Obtain the thread information
					GetThreadContext ( hThread, &Context );

					// Find an available regiser and set it
					//Context.Dr0 = dwAddr;
					Context.Dr1 = dwAddr;
					Context.Dr2 = dwAddr;
					Context.Dr3 = dwAddr;

					// Set the Dr7 register
					if ( !Type )
						Context.Dr7 = GetDr7 ( 11, 11, true, true, true, true, true);
					else if ( Type == 1 )
						Context.Dr7 = GetDr7 ( 10, 11, true, true, true, true, true);
					else if ( Type == 2 )
						Context.Dr7 = GetDr7 ( 00, 11, true, true, true, true, true );

					// Set the thread information
					SetThreadContext ( hThread, &Context );

					// Resume the thread
					ResumeThread ( hThread );
					CloseHandle  ( hThread );
				}
			}
		}
	}

	return true;
}

//

// Adding/Removing the handler
PVOID AddHandler ()
{
	dbgInfo = new DBG_INFO [100];
	numOfDbg = 0;
	PVOID pHandler = AddVectoredExceptionHandler ( 0, VectoredHandler );

	if ( !pHandler )
	{
		dbgOn = false;
		MessageBoxA ( 0, "Failed to add the handler!", "Error", MB_ICONINFORMATION );
	}
	else
	{
		if ( !localBrk )
			dbgOn = true;

		ListView_DeleteAllItems ( GetDlgItem ( dbgDlg, IDC_LIST1 ) );
	}

	return pHandler;
}

void  DelHandler  ( PVOID pHandler )
{
	dbgOn = false;

	// Remove the breakpoint
	THREADENTRY32 te;
	te.dwSize = sizeof ( THREADENTRY32 );

	// Create the snapshot
	HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPTHREAD, 0 );

	if ( Thread32First ( hSnapshot, &te ) )
	{
		// Check the thread
		if ( te.th32OwnerProcessID == GetCurrentProcessId () && te.th32ThreadID != GetCurrentThreadId () )
		{
			// Open the thread
			HANDLE hThread = OpenThread ( THREAD_SUSPEND_RESUME | THREAD_SET_CONTEXT | THREAD_GET_CONTEXT, false, te.th32ThreadID );

			// Suspend the thread
			SuspendThread ( hThread );

			// Obtain the thread information
			CONTEXT Context;
			Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

			// Obtain the thread information
			GetContext ( hThread, &Context );

			// Find an available regiser and set it
			int i = 0;

			for ( i = 0; i < 4; i ++ )
			{
				if ( *(DWORD*) ( ((DWORD) &Context.Dr0) + (4 * i) ) == dwDbgAddr )
				{
					*(DWORD*) ( ((DWORD) &Context.Dr0) + (4 * i) ) = 0;
					break;
				}
			}

			// Set the Dr7 register
			Context.Dr7 = 0;

			// Set the thread information
			SetContext ( hThread, &Context );

			// Resume the thread
			ResumeThread ( hThread );

			// Close Handle
			CloseHandle ( hThread );
		}

		while ( Thread32Next ( hSnapshot, &te ) )
		{
			// Check the thread
			if ( te.th32OwnerProcessID == GetCurrentProcessId () && te.th32ThreadID != GetCurrentThreadId () )
			{
				// Open the thread
				HANDLE hThread = OpenThread ( THREAD_SUSPEND_RESUME | THREAD_SET_CONTEXT | THREAD_GET_CONTEXT, false, te.th32ThreadID );

				// Suspend the thread
				SuspendThread ( hThread );

				// Obtain the thread information
				CONTEXT Context;
				Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

				// Obtain the thread information
				GetContext ( hThread, &Context );

				// Find an available regiser and set it
				Context.Dr0 = 0;
				Context.Dr1 = 0;
				Context.Dr2 = 0;
				Context.Dr3 = 0;

				// Set the Dr7 register
				Context.Dr7 = 0;

				// Set the thread information
				SetContext ( hThread, &Context );

				// Resume the thread
				ResumeThread ( hThread );

				// Close Handle
				CloseHandle ( hThread );
			}
		}
	}

	// Remove our exception handler
	RemoveVectoredExceptionHandler ( pHandler );
}
void  DelHandler2 ( PVOID pHandler )
{
	localBrk = false;

	// Remove our exception handler
	RemoveVectoredExceptionHandler ( pHandler );

	// Restore original byte
	WV <BYTE> ( dwDbgAddr, originalByte );
}
//

// Disassembler
string GetBytesInStr ( DWORD dwAddr, DWORD dwLength )
{
	// Create the variable
	BYTE * opcodes;

	// Set the length
	opcodes = new BYTE [ dwLength ];
	memcpy ( opcodes, (void*) dwAddr, (SIZE_T) dwLength );

	// Our byte variable
	string OpcodesStr;

	// Convert our bytes to lpvoid
	for ( SIZE_T i = 0; i < (SIZE_T) dwLength; i ++ )
	{
		stringstream bla;
		bla << (LPVOID) (unsigned int) opcodes [i];

		// Substr and then add it
		string hexa;
		hexa += bla.str ();

		OpcodesStr += hexa.substr ( 6, 8 );			
		OpcodesStr += " ";
	}

	delete [] opcodes;
	return OpcodesStr;
}

void Dis ()
{
	// Clear the listbox
	ListView_DeleteAllItems ( GetDlgItem ( disDlg, IDC_LIST1 ) );

	// Get system information
	SYSTEM_INFO SI;
	GetSystemInfo ( &SI );

	// Begin debugging
	DISASM myDisasm;
	DWORD dwTrgt = (DWORD) ConvertTextTo <LPVOID, DWORD> ( GetDlgItem ( disDlg, IDC_EDIT1 ) );
	DWORD dwAddr = dwTrgt;

	int myItem = 0;

	// Find the last address
	for ( int i = 0; i < 10; i++ )
	{
		if ( dwAddr > (DWORD) SI.lpMinimumApplicationAddress &&
			 dwAddr < (DWORD) SI.lpMaximumApplicationAddress ) 
		{
			myDisasm.EIP = dwAddr;
			DWORD length = (DWORD) Disasm ( &myDisasm );

			if ( length != 0xFFFFFFFF )
				dwAddr -= length;
			else
				break;
		}
		else
			break;
	}

	if ( dwAddr > (DWORD) SI.lpMinimumApplicationAddress )
		dwAddr -= 0x1;	

	// Display the next 20 instructions
	for ( int i = 0; i < 20; i ++ )
	{
		if ( dwAddr == dwTrgt )
			myItem = i;

		if ( dwAddr >= (DWORD) SI.lpMinimumApplicationAddress &&
			 dwAddr <= (DWORD) SI.lpMaximumApplicationAddress ) 
		{
			myDisasm.EIP = dwAddr;
			DWORD length = (DWORD) Disasm ( &myDisasm );

			while ( length == 0xFFFFFFFF )
			{
				dwAddr ++;
				myDisasm.EIP = dwAddr;
				length = (DWORD) Disasm ( &myDisasm );
			}

			// Add then increment				
			ID ( CTT <LPVOID> ( (void*) dwAddr ), myDisasm.CompleteInstr, GetBytesInStr ( dwAddr, length ) );
			dwAddr += length;
		}
		else
			break;
	}

	SendMessage           (GetDlgItem ( disDlg, IDC_LIST1 ), LVM_ENSUREVISIBLE, (WPARAM) myItem, FALSE); 
	ListView_SetItemState (GetDlgItem ( disDlg, IDC_LIST1 ), myItem, LVIS_SELECTED, LVIS_SELECTED); 
	ListView_SetItemState (GetDlgItem ( disDlg, IDC_LIST1 ), myItem, LVIS_FOCUSED, LVIS_FOCUSED);
}
//

// Add all items
void AddAllItems ( bool GoStatic )
{
	int maxItems = SendMessage ( GetDlgItem ( mainDlg, IDC_LIST1 ), LB_GETCOUNT, 0, 0 );

	if ( result > 0 && maxItems != 0 )
	{
		for ( int i = 0; i < maxItems; i ++ )
		{
			char szBuffer [256] = {0};
			SMX ( GetDlgItem ( mainDlg, IDC_LIST1 ), LB_GETTEXT, (WPARAM) i, (LPARAM) (LPTSTR) szBuffer );

			HMODULE hModule;

			if ( GoStatic )
				GetModuleHandleEx ( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR) szBuffer, &hModule );

			if ( ( strcmp ( szBuffer, "" ) != 0 ) &&
				 ( ( ( GoStatic == true ) && hModule != NULL ) ) ||
				   ( ( GoStatic == false ) ) )
			{
				// Obtain the type
				char szType [256] = {0};
				GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO1 ), (LPSTR) szType, 256 );

				// To string
				string ptr;
				ptr += (LPSTR) szBuffer;

				string type;

				if ( !strcmp ( szType, "Array of Bytes" ) )
					type += "Byte";
				else
					type += (LPSTR) szType;

				// Insert
				IA ( ptr, type );
			}
		}
	}
	else
	{
		if ( result > 50000 )
			MessageBoxA ( mainDlg, "Can't display results larger than 50,000", "Error", MB_ICONERROR );
		else
		{
			// Obtain results
			HANDLE hFile = CreateFile ( GetPathway ( "Memory.TMP" ).c_str (), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
			dwScan	     = new DWORD [ (DWORD) result * 4 ];

			// Read the reuslts
			DWORD dwBytes;
			::ReadFile ( hFile, dwScan, (DWORD) result * 4, &dwBytes, 0 );

			for ( int i = 0; i < result; i ++ )
			{
				HMODULE hModule;

				if ( GoStatic )
					GetModuleHandleEx ( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR) dwScan [i], &hModule );

				if ( ( ( ( GoStatic == true ) && hModule != NULL ) ) ||
					   ( ( GoStatic == false ) ) )
				{
					stringstream ss;
					ss << (void*) dwScan [i];

					// Obtain the type
					char szType [256] = {0};
					GetWindowText ( GetDlgItem ( mainDlg, IDC_COMBO1 ), (LPSTR) szType, 256 );

					// Convert address to str
					string ptr;
					ptr += ss.str ();

					// Obtain type
					string type;

					if ( !strcmp ( szType, "Array of Bytes" ) )
						type += "Byte";
					else
						type += (LPSTR) szType;

					// Insert
					IA ( ptr, type );
				}
			}

			// Close the handle
			CloseHandle ( hFile );

			// Delete the buffer
			delete [] dwScan;
		}
	}
}
//

<|start_filename|>iScan/resource.h<|end_filename|>
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#define IDD_DIALOG1                             100
#define IDD_DIALOG2                             102
#define IDB_BITMAP2                             103
#define IDD_DIALOG3                             104
#define IDC_VERSION                             1000
#define IDC_BUTTON1                             1001
#define IDC_CHECKBOX2                           1002
#define IDC_EDIT1                               1003
#define IDC_CHECKBOX1                           1004
#define IDC_BUTTON2                             1005
#define IDC_DOWNLOAD                            1005
#define IDC_USERNAME                            1006
