Page MenuHomedesp's stash

No OneTemporary

diff --git a/Scylla/PickApiGui.cpp b/Scylla/PickApiGui.cpp
index c066ed3..61cf662 100644
--- a/Scylla/PickApiGui.cpp
+++ b/Scylla/PickApiGui.cpp
@@ -1,178 +1,186 @@
#include "PickApiGui.h"
#include <atlconv.h> // string conversion
#include "WindowDeferrer.h"
PickApiGui::PickApiGui(const std::vector<ModuleInfo> &moduleList) : moduleList(moduleList)
{
selectedApi = 0;
hIcon.LoadIcon(IDI_ICON_SCYLLA);
}
BOOL PickApiGui::OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
{
DoDataExchange(); // attach controls
fillDllComboBox(ComboDllSelect);
CenterWindow();
SetIcon(hIcon, TRUE);
SetIcon(hIcon, FALSE);
GetWindowRect(&minDlgSize);
return TRUE;
}
void PickApiGui::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
lpMMI->ptMinTrackSize = CPoint(minDlgSize.Size());
}
void PickApiGui::OnSizing(UINT fwSide, RECT* pRect)
{
// Get size difference
CRect rectOld;
GetWindowRect(&rectOld);
CRect rectNew = *pRect;
sizeOffset = rectNew.Size() - rectOld.Size();
}
void PickApiGui::OnSize(UINT nType, CSize size)
{
const WindowDeferrer::Deferrable controls[] =
{
{IDC_GROUP_DLL, false, false, true, false},
{IDC_CBO_DLLSELECT, false, false, true, false},
{IDC_GROUP_APIS, false, false, true, true},
{IDC_LIST_APISELECT, false, false, true, true},
{IDC_STATIC_APIFILTER, false, true, false, false},
{IDC_EDIT_APIFILTER, false, true, true, false},
{IDC_BTN_PICKAPI_OK, true, true, false, false},
{IDC_BTN_PICKAPI_CANCEL, true, true, false, false}
};
if(nType == SIZE_RESTORED)
{
WindowDeferrer deferrer(m_hWnd, controls, _countof(controls));
deferrer.defer(sizeOffset.cx, sizeOffset.cy);
sizeOffset.SetSize(0, 0);
}
}
void PickApiGui::OnOK(UINT uNotifyCode, int nID, CWindow wndCtl)
{
actionApiSelected();
}
void PickApiGui::OnCancel(UINT uNotifyCode, int nID, CWindow wndCtl)
{
EndDialog(0);
}
void PickApiGui::OnDllListSelected(UINT uNotifyCode, int nID, CWindow wndCtl)
{
int indexDll = ComboDllSelect.GetCurSel();
if (indexDll != CB_ERR)
{
- apiListTemp = moduleList[indexDll].apiList;
- fillApiListBox(ListApiSelect, apiListTemp);
+ fillApiListBox(ListApiSelect, moduleList[indexDll].apiList);
EditApiFilter.SetWindowText(L"");
}
}
void PickApiGui::OnApiListDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl)
{
actionApiSelected();
}
void PickApiGui::OnApiFilterUpdated(UINT uNotifyCode, int nID, CWindow wndCtl)
{
- // remove from apiListTemp that don't fit
int indexDll = ComboDllSelect.GetCurSel();
- if (indexDll != CB_ERR)
- {
- WCHAR filter[MAX_PATH];
- int lenFilter = EditApiFilter.GetWindowText(filter, _countof(filter));
- if(lenFilter > 0)
- {
- apiListTemp.clear();
+ if (indexDll == CB_ERR)
+ return;
- const std::vector<ApiInfo *> &apis = moduleList[indexDll].apiList;
+ std::vector<ApiInfo *> newApis;
+ WCHAR filter[MAX_PATH];
+
+ int lenFilter = EditApiFilter.GetWindowText(filter, _countof(filter));
+ if(lenFilter > 0)
+ {
+ const std::vector<ApiInfo *> &apis = moduleList[indexDll].apiList;
- for (size_t i = 0; i < apis.size(); i++)
+ for (size_t i = 0; i < apis.size(); i++)
+ {
+ ApiInfo* api = apis[i];
+ if(api->name[0] != '\0')
{
- ApiInfo* api = apis[i];
- if(api->name[0] != '\0')
+ CA2WEX<MAX_PATH> wStr(api->name);
+ if(!_wcsnicmp(wStr, filter, lenFilter))
{
- CA2WEX<MAX_PATH> wStr(api->name);
- if(!_wcsnicmp(wStr, filter, lenFilter))
- {
- apiListTemp.push_back(api);
- }
+ newApis.push_back(api);
}
- else
+ }
+ else
+ {
+ WCHAR buf[6];
+ swprintf_s(buf, _countof(buf), L"#%04X", api->ordinal);
+ if(!_wcsnicmp(buf, filter, lenFilter))
{
- WCHAR buf[6];
- swprintf_s(buf, _countof(buf), L"#%04X", api->ordinal);
- if(!_wcsnicmp(buf, filter, lenFilter))
- {
- apiListTemp.push_back(api);
- }
+ newApis.push_back(api);
}
}
}
- else
- {
- apiListTemp = moduleList[indexDll].apiList;
- }
-
- fillApiListBox(ListApiSelect, apiListTemp);
}
+ else
+ {
+ newApis = moduleList[indexDll].apiList;
+ }
+
+ fillApiListBox(ListApiSelect, newApis);
}
void PickApiGui::actionApiSelected()
{
int indexDll = ComboDllSelect.GetCurSel();
- int indexApi = ListApiSelect.GetCurSel();
- if (indexDll != CB_ERR && indexApi != CB_ERR)
+ int indexApi;
+ if(ListApiSelect.GetCount() == 1)
+ {
+ indexApi = 0;
+ }
+ else
+ {
+ indexApi = ListApiSelect.GetCurSel();
+ }
+ if (indexDll != CB_ERR && indexApi != LB_ERR)
{
- selectedApi = apiListTemp[indexApi];
+ selectedApi = (ApiInfo *)ListApiSelect.GetItemData(indexApi);
EndDialog(1);
}
}
void PickApiGui::fillDllComboBox(CComboBox& combo)
{
combo.ResetContent();
for (size_t i = 0; i < moduleList.size(); i++)
{
combo.AddString(moduleList[i].fullPath);
}
}
void PickApiGui::fillApiListBox(CListBox& list, const std::vector<ApiInfo *> &apis)
{
list.ResetContent();
for (size_t i = 0; i < apis.size(); i++)
{
const ApiInfo* api = apis[i];
+ int item;
if(api->name[0] != '\0')
{
CA2WEX<MAX_PATH> wStr(api->name);
- list.AddString(wStr);
+ item = list.AddString(wStr);
}
else
{
WCHAR buf[6];
swprintf_s(buf, _countof(buf), L"#%04X", api->ordinal);
- list.AddString(buf);
+ item = list.AddString(buf);
}
+ list.SetItemData(item, (DWORD_PTR)api);
}
}
diff --git a/Scylla/PickApiGui.h b/Scylla/PickApiGui.h
index ed295e3..7a4356d 100644
--- a/Scylla/PickApiGui.h
+++ b/Scylla/PickApiGui.h
@@ -1,91 +1,90 @@
#pragma once
#include <windows.h>
#include "resource.h"
// WTL
#include <atlbase.h> // base ATL classes
#include <atlapp.h> // base WTL classes
#include <atlwin.h> // ATL GUI classes
#include <atlmisc.h> // WTL utility classes like CString
#include <atlcrack.h> // WTL enhanced msg map macros
#include <atlctrls.h> // WTL controls
#include <atlddx.h> // WTL dialog data exchange
#include <vector>
#include "ProcessAccessHelp.h"
class PickApiGui : public CDialogImpl<PickApiGui>, public CWinDataExchange<PickApiGui>
{
public:
enum { IDD = IDD_DLG_PICKAPI };
BEGIN_DDX_MAP(PickApiGui)
DDX_CONTROL_HANDLE(IDC_CBO_DLLSELECT, ComboDllSelect)
DDX_CONTROL_HANDLE(IDC_LIST_APISELECT, ListApiSelect)
DDX_CONTROL_HANDLE(IDC_EDIT_APIFILTER, EditApiFilter)
END_DDX_MAP()
BEGIN_MSG_MAP(PickDllGui)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
MSG_WM_SIZING(OnSizing)
MSG_WM_SIZE(OnSize)
COMMAND_HANDLER_EX(IDC_CBO_DLLSELECT, CBN_SELENDOK, OnDllListSelected)
COMMAND_HANDLER_EX(IDC_LIST_APISELECT, LBN_DBLCLK, OnApiListDoubleClick)
COMMAND_HANDLER_EX(IDC_EDIT_APIFILTER, EN_UPDATE, OnApiFilterUpdated)
COMMAND_ID_HANDLER_EX(IDC_BTN_PICKAPI_OK, OnOK)
COMMAND_ID_HANDLER_EX(IDC_BTN_PICKAPI_CANCEL, OnCancel)
COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel)
END_MSG_MAP()
PickApiGui(const std::vector<ModuleInfo> &moduleList);
ApiInfo* getSelectedApi() const { return selectedApi; }
protected:
// Variables
const std::vector<ModuleInfo> &moduleList;
- std::vector<ApiInfo *> apiListTemp;
ApiInfo* selectedApi;
// Controls
CComboBox ComboDllSelect;
CListBox ListApiSelect;
CEdit EditApiFilter;
CRect minDlgSize;
CSize sizeOffset;
// Handles
CIcon hIcon;
protected:
// Message handlers
BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam);
void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
void OnSizing(UINT fwSide, RECT* pRect);
void OnSize(UINT nType, CSize size);
void OnOK(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnCancel(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnDllListSelected(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnApiListDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnApiFilterUpdated(UINT uNotifyCode, int nID, CWindow wndCtl);
// Actions
void actionApiSelected();
// GUI functions
void fillDllComboBox(CComboBox& combo);
void fillApiListBox(CListBox& list, const std::vector<ApiInfo *> &apis);
};

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 14, 6:53 PM (1 h, 49 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
27/22/d7030864d7787b53830cf27145bd

Event Timeline