Browse Source

store updateKey in resource table

COM-121
Volker Birk 6 years ago
parent
commit
99b5eb47c3
8 changed files with 87 additions and 28 deletions
  1. +28
    -0
      GateKeeper.cpp
  2. +2
    -1
      GateKeeper.h
  3. +5
    -27
      pEpCOMServerAdapter.cpp
  4. +44
    -0
      pEpCOMServerAdapter.h
  5. BIN
      pEpCOMServerAdapter.rc
  6. +2
    -0
      pEpCOMServerAdapter.vcxproj
  7. +6
    -0
      pEpCOMServerAdapter.vcxproj.filters
  8. BIN
      resource.h

+ 28
- 0
GateKeeper.cpp View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "GateKeeper.h"
#include "pEpCOMServerAdapter.h"
using namespace std;
@ -78,6 +79,11 @@ namespace pEp {
void GateKeeper::keep_plugin()
{
while (!_self->m_bComInitialized)
Sleep(1);
MessageBox(NULL, _T("test"), _T("keep_plugin"), MB_ICONINFORMATION | MB_TOPMOST);
DWORD value;
DWORD size;
@ -91,6 +97,28 @@ namespace pEp {
}
}
string GateKeeper::updateKey()
{
static string key;
if (key.length() == 0) {
HRSRC res = FindResource(_self->hModule(), MAKEINTRESOURCE(IRD_UPDATEKEY), RT_RCDATA);
assert(res);
if (!res)
throw runtime_error("FindResource: IRD_UPDATEKEY");
HGLOBAL hRes = LoadResource(_self->hModule(), res);
assert(hRes);
if (!hRes)
throw runtime_error("LoadResource: IRD_UPDATEKEY");
key = string((char *)LockResource(hRes), SizeofResource(_self->hModule(), res));
UnlockResource(hRes);
}
return key;
}
GateKeeper::product_list& GateKeeper::registered_products()
{
static product_list products;


+ 2
- 1
GateKeeper.h View File

@ -37,6 +37,7 @@ namespace pEp {
void keep_plugin();
string updateKey();
string handshake(HINTERNET hUrl);
void update_product(product p, DWORD context);
product_list& registered_products();
@ -50,6 +51,6 @@ namespace pEp {
HKEY hkUpdater;
HINTERNET internet;
CpEpCOMServerAdapterModule * const _self;
CpEpCOMServerAdapterModule * _self;
};
}

+ 5
- 27
pEpCOMServerAdapter.cpp View File

@ -3,38 +3,14 @@
#include "stdafx.h"
#include "resource.h"
#include "pEpCOMServerAdapter_i.h"
#include "xdlldata.h"
#include "GateKeeper.h"
#include "pEpCOMServerAdapter.h"
using namespace ATL;
using namespace std;
class CpEpCOMServerAdapterModule : public ATL::CAtlExeModuleT< CpEpCOMServerAdapterModule >
{
public:
CpEpCOMServerAdapterModule() : ATL::CAtlExeModuleT< CpEpCOMServerAdapterModule >(), gatekeeper_thread(NULL)
{
try {
gatekeeper_thread = new thread(gatekeeper, this);
gatekeeper_thread->detach();
}
catch (system_error&) {
}
}
DECLARE_LIBID(LIBID_pEpCOMServerAdapterLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_PEPCOMSERVERADAPTER, "{B3480081-82C0-4EE4-9AA1-3F513C9D78DD}")
protected:
static void gatekeeper(CpEpCOMServerAdapterModule * const self);
private:
thread *gatekeeper_thread;
};
void CpEpCOMServerAdapterModule::gatekeeper(CpEpCOMServerAdapterModule * const self)
{
pEp::GateKeeper keeper(self);
@ -44,9 +20,11 @@ void CpEpCOMServerAdapterModule::gatekeeper(CpEpCOMServerAdapterModule * const s
CpEpCOMServerAdapterModule _AtlModule;
//
extern "C" int WINAPI _tWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/,
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
LPTSTR /*lpCmdLine*/, int nShowCmd)
{
_AtlModule.hModule(hInstance);
_AtlModule.start_gatekeeper();
return _AtlModule.WinMain(nShowCmd);
}

+ 44
- 0
pEpCOMServerAdapter.h View File

@ -0,0 +1,44 @@
#include "stdafx.h"
#include "pEpCOMServerAdapter_i.h"
using namespace ATL;
using namespace std;
class CpEpCOMServerAdapterModule : public ATL::CAtlExeModuleT< CpEpCOMServerAdapterModule > {
public:
CpEpCOMServerAdapterModule() : ATL::CAtlExeModuleT< CpEpCOMServerAdapterModule >(), gatekeeper_thread(NULL), _hModule(NULL)
{
}
DECLARE_LIBID(LIBID_pEpCOMServerAdapterLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_PEPCOMSERVERADAPTER, "{B3480081-82C0-4EE4-9AA1-3F513C9D78DD}")
HMODULE hModule()
{
return _hModule;
}
void hModule(HMODULE m)
{
_hModule = m;
}
void start_gatekeeper()
{
try {
gatekeeper_thread = new thread(gatekeeper, this);
gatekeeper_thread->detach();
}
catch (system_error&) {
}
}
protected:
static void gatekeeper(CpEpCOMServerAdapterModule * self);
private:
thread *gatekeeper_thread;
HMODULE _hModule;
};

BIN
pEpCOMServerAdapter.rc View File


+ 2
- 0
pEpCOMServerAdapter.vcxproj View File

@ -154,6 +154,7 @@ echo "generating interop assembly $(TargetDir)pEpCOMServerAdapter.Interop.dll"
<ClInclude Include="CpEpEngine.h" />
<ClInclude Include="GateKeeper.h" />
<ClInclude Include="locked_queue.hh" />
<ClInclude Include="pEpCOMServerAdapter.h" />
<ClInclude Include="pEpCOMServerAdapter_i.h" />
<ClInclude Include="pEp_utility.h" />
<ClInclude Include="Resource.h" />
@ -173,6 +174,7 @@ echo "generating interop assembly $(TargetDir)pEpCOMServerAdapter.Interop.dll"
<None Include="..\..\pep_for_outlook\pep\pep_test.snk" />
<None Include="pEpCOMServerAdapter.rgs" />
<None Include="pEpEngine.rgs" />
<None Include="updatekey.bin" />
</ItemGroup>
<ItemGroup>
<Midl Include="pEpCOMServerAdapter.idl" />


+ 6
- 0
pEpCOMServerAdapter.vcxproj.filters View File

@ -78,6 +78,9 @@
<ClInclude Include="GateKeeper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pEpCOMServerAdapter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="pEpCOMServerAdapter.rc">
@ -95,6 +98,9 @@
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\pep_for_outlook\pep\pep_test.snk" />
<None Include="updatekey.bin">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Midl Include="pEpCOMServerAdapter.idl">


BIN
resource.h View File


Loading…
Cancel
Save