Created
June 3, 2013 23:57
-
-
Save CCInc/5702511 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//header | |
class SamplePlugin : public DexpotEventHandler | |
{ | |
public: | |
SamplePlugin(void); | |
~SamplePlugin(void); | |
BOOL Initialize(); | |
int Run(); | |
Dexpot *dex; | |
virtual VOID OnSwitched(INT32 FromDesktop, INT32 ToDesktop, WORD Flags, WORD Trigger); | |
virtual VOID OnShutdown(VOID); | |
virtual VOID OnLogon(std::string); | |
virtual VOID OnLoad(VOID); | |
virtual VOID OnHotkey(INT32 Id, WORD Hotkey, WORD Modifier); | |
virtual VOID OnSetIntegerOption(INT32 Id, INT32 Value); | |
virtual VOID OnSetStringOption(INT32 Id, LPTSTR Value); | |
virtual VOID OnConfigure(VOID); | |
virtual VOID OnMenuCommand(INT32 Id); | |
private: | |
static const INT32 OPTION_INITIALIZED = 1; | |
static const INT32 OPTION_FAKEPASS = 2; | |
static const INT32 OPTION_REALPASS = 3; | |
static const INT32 HOTKEY_SAYHELLO = 1; | |
static const INT32 MENUCOMMAND_QUIT = 1; | |
int OptionsInitialized; | |
}; | |
//C++ file | |
Dexpot *dexx; | |
SamplePlugin *plugin; | |
#include "Example1.h" | |
// Server function. | |
void Output(const char* s) | |
{ | |
MessageBox(NULL, _T("Hi!"), _T("Dexpot Sample Plugin"), MB_OK | MB_ICONINFORMATION); | |
dexx->SwitchDesktop(2,0); | |
} | |
BOOL SamplePlugin::Initialize() | |
{ | |
RPC_STATUS status; | |
// Uses the protocol combined with the endpoint for receiving | |
// remote procedure calls. | |
status = RpcServerUseProtseqEp(reinterpret_cast<RPC_WSTR>(L"ncacn_ip_tcp"), // Use TCP/IP protocol. | |
RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP. | |
reinterpret_cast<RPC_WSTR>(L"4747"), // TCP/IP port to use. | |
NULL); // No security. | |
// Registers the Example1 interface. | |
status = RpcServerRegisterIf2( | |
Example1_v1_0_s_ifspec, // Interface to register. | |
NULL, // Use the MIDL generated entry-point vector. | |
NULL, // Use the MIDL generated entry-point vector. | |
RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, // Forces use of security callback. | |
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Use default number of concurrent calls. | |
(unsigned)-1, // Infinite max size of incoming data blocks. | |
SecurityCallback); // Naive security callback. | |
// Start to listen for remote procedure | |
// calls for all registered interfaces. | |
// This call will not return until | |
// RpcMgmtStopServerListening is called. | |
status = RpcServerListen( | |
1, // Recommended minimum number of threads. | |
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads. | |
FALSE); // Start listening now. | |
if(!dex) | |
{ | |
dex = new Dexpot(_T("SamplePlugin")); | |
dex->RegisterEventHandler(this); | |
} | |
if(dex->Connect()) | |
{ | |
return TRUE; | |
} | |
return FALSE; | |
} | |
int SamplePlugin::Run() | |
{ | |
MSG msg; | |
while(GetMessage(&msg, NULL, 0, 0)) | |
{ | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
} | |
return (int) msg.wParam; | |
} | |
void SamplePlugin::OnLoad() | |
{ | |
plugin=this; | |
TCHAR DexpotPath[MAX_PATH]; | |
TCHAR Message[2 * MAX_PATH]; | |
dex->GetDexpotHome(DexpotPath, MAX_PATH * sizeof(TCHAR)); | |
_stprintf_s(Message, 2 * MAX_PATH, _T("Dexpot sample plugin has loaded.\nHere are some facts:\n\nDesktop count: %i\nCurrent desktop: %i\nDexpot path: %s"), | |
dex->GetPluginID(), dex->GetCurrentDesktop(), DexpotPath); | |
MessageBox(NULL, Message, _T("Dexpot Sample Plugin"), MB_OK | MB_ICONINFORMATION); | |
/// | |
dex->RegisterOption(DEX_OPTION_TYPE_INTEGER, OPTION_INITIALIZED, _T("Initialized")); | |
dex->RegisterOption(DEX_OPTION_TYPE_STRING, OPTION_FAKEPASS, _T("Fake Pass")); | |
dex->RegisterOption(DEX_OPTION_TYPE_STRING, OPTION_REALPASS, _T("Real Pass")); | |
//dex->RegisterHotkey(HOTKEY_SAYHELLO, _T("Say Hello")); | |
dex->LoadSettings(); | |
if(!OptionsInitialized) | |
{ | |
OptionsInitialized = 1; | |
dex->SetOptionValue(OPTION_INITIALIZED, OptionsInitialized); | |
dex->SetOptionValue(OPTION_FAKEPASS, _T("")); | |
dex->SetOptionValue(OPTION_REALPASS, _T("")); | |
// dex->SetHotkeyValue(HOTKEY_SAYHELLO, MOD_WIN, VK_F8); | |
dex->SaveSettings(); | |
} | |
dexx = dex; | |
Dexpot *fkdex = dex; | |
dex->InsertMainMenuItem(MENUCOMMAND_QUIT, _T(" Quit Sample Plugin"), NULL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment