Example #1
0
HWND MakeWindow(
    const wchar_t* title, ULONG style, HMENU menu, const SIZE& size, MessageHandler* handlers) {
  WNDCLASSEXW wcex = {sizeof(wcex)};
  wcex.hCursor = ::LoadCursorW(NULL, IDC_ARROW);
  wcex.hInstance = ThisModule();
  wcex.hIcon = ::LoadIcon(ThisModule(), MAKEINTRESOURCE(IDI_FILECLEANER));
  wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_FILECLEANER);
  wcex.lpszClassName = __FILEW__;
  wcex.lpfnWndProc = [] (HWND window, UINT message, WPARAM wparam, LPARAM lparam) -> LRESULT {
    static MessageHandler* s_handlers = reinterpret_cast<MessageHandler*>(lparam);
    size_t ix = 0;
    while (s_handlers[ix].message != -1) {
      if (s_handlers[ix].message == message)
        return s_handlers[ix].callback(window, wparam, lparam);
      ++ix;
    }

    return ::DefWindowProcW(window, message, wparam, lparam);
  };

  wcex.lpfnWndProc(NULL, 0, 0, reinterpret_cast<UINT_PTR>(handlers));
  ATOM atom = VerifyNot(::RegisterClassExW(&wcex), 0);
  int pos_def = CW_USEDEFAULT;
  return ::CreateWindowExW(0, MAKEINTATOM(atom), title, style,
                           pos_def, pos_def, size.cx, size.cy,
                           NULL, menu, ThisModule(), NULL); 
}
Example #2
0
plx::File OpenConfigFile() {
  std::unique_ptr<wchar_t[]> sp(new wchar_t[300]);
  ::GetModuleFileNameW(ThisModule(), sp.get(), 256);
  auto path = plx::FilePath(sp.get()).parent().append(L"config.json");
  plx::FileParams fparams = plx::FileParams::Read_SharedRead();
  return plx::File::Create(path, fparams, plx::FileSecurity());
}
DHWImportHooker::DHWImportHooker(const char* aModuleName,
                                 const char* aFunctionName,
                                 PROC aHook,
                                 PRBool aExcludeOurModule /* = PR_FALSE */)
    :   mNext(nsnull),
        mModuleName(aModuleName),
        mFunctionName(aFunctionName),
        mOriginal(nsnull),
        mHook(aHook),
        mIgnoreModule(aExcludeOurModule ? ThisModule() : nsnull),
        mHooking(PR_TRUE)
{
    //printf("DHWImportHooker hooking %s, function %s\n",aModuleName, aFunctionName);

    if(!gLock)
        gLock = PR_NewLock();
    PR_Lock(gLock);

    dhwEnsureImageHlpInitialized(); // for the extra ones we care about.

    if(!gRealGetProcAddress)
        gRealGetProcAddress = ::GetProcAddress;

    mOriginal = gRealGetProcAddress(::GetModuleHandleA(aModuleName), 
                                    aFunctionName),
 
    mNext = gHooks;
    gHooks = this;

    PatchAllModules();

    PR_Unlock(gLock);
}   
Example #4
0
__QCMP_STARTLINKAGE_C

//------------------------------------------------------------------------------
__QCMP_EXPORT nsArch::CMachine* TheMachine(void)
{
	return ((nsArch::CArchQORModule&)ThisModule()).Machine();
}
Example #5
0
	//------------------------------------------------------------------------------
	CThreading::CThreading()
	{
		nsCodeQOR::CClassInstanceFactory* pFactory = ThisModule().ExternalClassReg().GetFactory( IThreading::ClassID() );
		if( pFactory )
		{
			m_Impl.Attach( reinterpret_cast<IThreading*>( pFactory->Instance() ), true );
		}
	}
Example #6
0
	//------------------------------------------------------------------------------
	CRole::CRole( nsCodeQOR::mxGUID* classID )
	{
		__QCS_FCONTEXT( "CRole::CRole" );
		nsCodeQOR::CClassInstanceFactory* pFactory = ThisModule().ExternalClassReg().GetFactory( classID );
		if( pFactory )
		{
			void* pInstance = pFactory->Instance();
			//m_Impl.Attach( reinterpret_cast<IRole*>( pFactory->Instance() ), true );
		}
	}
Example #7
0
	//--------------------------------------------------------------------------------
	CLibraryBase::~CLibraryBase()
	{
		if( m_bRegistered )
		{
			CLoadableModuleBase* pThisModule = &(ThisModule());
			if( pThisModule != 0 )
			{
				pThisModule->UnregisterLibrary( this );
			}
		}
	}
Example #8
0
	//--------------------------------------------------------------------------------
    CLibraryBase::CLibraryBase( const char* szLibName, bool bShared ) : m_szLibName( szLibName ), m_bRegistered( false ), m_pNext( 0 )
	{
		if( !bShared )
		{
			CLoadableModuleBase* pThisModule = &(ThisModule());			//Find the Loadable module this static library is part of
			if( pThisModule != 0 && pThisModule->m_bRegistered )
			{
				m_bRegistered = pThisModule->RegisterLibrary( this );	//Register as a static library component
			}
		}
	}