本文整理匯總了C++中FindModule函數的典型用法代碼示例。如果您正苦於以下問題:C++ FindModule函數的具體用法?C++ FindModule怎麽用?C++ FindModule使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FindModule函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: params
void SystemWrapper::CMD_UnloadModule(char *cmdLine)
{
TokenLine params(cmdLine);
if (params.CountToken() < 2) {
Printf("Syntax: unloadmodule <module> [<name>]\n");
return;
}
ISystemModule *module = nullptr;
switch (params.CountToken()) {
case 2:
module = FindModule(params.GetToken(1));
break;
case 3:
module = FindModule(params.GetToken(1), params.GetToken(2));
break;
}
if (!module) {
Printf("Module not found.\n");
return;
}
RemoveModule(module);
}
示例2: LoadModule
Module* VirtualMachine::LoadModule(const ModuleName &name, bool noreflection, bool debug, Module *hint)
{
// Check for an already loaded module.
// TODO: Add security.
LoadedModulesByName::iterator it = loadedModulesByName.find(name.name);
if(it != loadedModulesByName.end())
return it->second;
// Use the filename if present
if(!name.filename.empty())
return LoadModule(name.filename, debug);
// Try to load the module.
std::string baseName = name.name + ".cbm";
std::string fileName;
if(FindModule(baseName, &fileName, hint))
return LoadModule(fileName, noreflection, debug);
// Try to load embedded module.
// ELF module.
baseName = "lib" + name.name + ".so";
if(FindModule(baseName, &fileName, hint))
return LoadModule(fileName, noreflection, debug);
// PE module.
baseName = name.name + ".dll";
if(FindModule(baseName, &fileName, hint))
return LoadModule(fileName, noreflection, debug);
return NULL;
}
示例3: GetModuleInformation
BOOL
WINAPI
GetModuleInformation(
HANDLE hProcess,
HMODULE hModule,
LPMODULEINFO lpmodinfo,
DWORD cb
)
{
LDR_DATA_TABLE_ENTRY LdrEntryData;
MODULEINFO modinfo;
if (cb < sizeof(MODULEINFO)) {
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return(FALSE);
}
if (!FindModule(hProcess, hModule, &LdrEntryData)) {
return(0);
}
modinfo.lpBaseOfDll = (PVOID) hModule;
modinfo.SizeOfImage = LdrEntryData.SizeOfImage;
modinfo.EntryPoint = LdrEntryData.EntryPoint;
try {
*lpmodinfo = modinfo;
}
except (EXCEPTION_EXECUTE_HANDLER) {
SetLastError( RtlNtStatusToDosError( GetExceptionCode() ) );
return(FALSE);
}
return(TRUE);
}
示例4: ASSERT_CHECK_RET
LWRESULT Cx_PluginLoader::RegisterPlugin(const Ix_Module* pModule)
{
ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PARAMETER_ERROR, (pModule), "RegisterPlugin Para Error");
if (FindModule(pModule->GetModuleMODID()) >= 0)
{
return false;
}
MODULE moduleInfo;
moduleInfo.modid = pModule->GetModuleMODID();
moduleInfo.module = (Ix_Module *)pModule;
moduleInfo.owned = (pModule->GetModuleInstance())? true: false;
moduleInfo.inited = false;
int32_ moduleIndex = GetPluginIndex(pModule->GetModuleMODID());
if (moduleIndex >= 0)
{
ASSERT_CHECK_RET(LWDP_MODULE_LOG, false, (m_modules[moduleIndex] != NULL), "Get Plugin Index Error");
*m_modules[moduleIndex] = moduleInfo;
}
else
{
moduleIndex = m_modules.size();
MODULE* module = new MODULE;
*module = moduleInfo;
m_modules.push_back(module);
}
RegisterClassEntryTable(moduleIndex);
return LWDP_OK;
}
示例5: GetFixedFuncAddr
//////////////////////////////////////////////////////////////////////////
//
// ƯÁ¤ ¹ÙÀ̳ʸ® ÆÐÄ¡
//
//////////////////////////////////////////////////////////////////////////
BOOL CRawHookMgr::preHook(LPVOID pfnOld, unsigned char* cBuff, size_t copysize)
{
pfnOld = GetFixedFuncAddr(pfnOld);
if(NULL == pfnOld) return FALSE;
// ÇÔ¼ö°¡ µé¾îÀÖ´Â ¸ðµâÀ» ¾Ë¾Æ³½´Ù
HMODULE hModule = HandleFromAddress(pfnOld);
if(NULL == hModule) return FALSE;
// ÇöÀç °ü¸®µÇ°í ÀÖ´Â ¸ðµâµé Áß ÀÌ ¸ðµâÀÌ Àִ ã¾Æº¸°í
CRawHookedModule* pModule = FindModule(hModule);
// ¾øÀ¸¸é »õ ¸ðµâ µî·Ï
if( NULL == pModule )
{
pModule = new CRawHookedModule();
if( pModule->Init( hModule ) == FALSE )
{
delete pModule;
return FALSE;
}
m_listModules.push_back(pModule);
}
return pModule->preHook(pfnOld, cBuff, copysize);
}
示例6: VoiceUnregister
static INT_PTR VoiceUnregister(WPARAM wParam, LPARAM lParam)
{
char *moduleName = (char *) wParam;
if (moduleName == NULL || moduleName[0] == 0)
return -1;
VoiceProvider *module = FindModule(moduleName);
if (module == NULL)
return -2;
for(int i = calls.getCount() - 1; i >= 0; --i)
{
VoiceCall *call = &calls[i];
if (call->module == module)
{
call->Drop();
call->SetState(VOICE_STATE_ENDED);
calls.remove(i);
}
}
modules.remove(module);
if (hwnd_frame != NULL)
PostMessage(hwnd_frame, WMU_REFRESH, 0, 0);
return 0;
}
示例7: XN_VALIDATE_INPUT_PTR
XnStatus XnDeviceBase::UnregisterFromPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
XN_VALIDATE_INPUT_PTR(Module);
XN_VALIDATE_INPUT_PTR(PropertyName);
XN_VALIDATE_INPUT_PTR(hCallback);
XnPropertyCallback* pRealCookie = (XnPropertyCallback*)hCallback;
XnDeviceModule* pModule;
nRetVal = FindModule(Module, &pModule);
XN_IS_STATUS_OK(nRetVal);
// first unregister it from property
nRetVal = pModule->UnregisterFromOnPropertyValueChanged(PropertyName, pRealCookie->hCallback);
XN_IS_STATUS_OK(nRetVal);
XnValue val = pRealCookie;
XnList::Iterator it = m_PropertyCallbacks.Find(val);
if (it != m_PropertyCallbacks.end())
{
m_PropertyCallbacks.Remove(it);
}
// now free the memory
XN_DELETE(pRealCookie);
return (XN_STATUS_OK);
}
示例8: FindModule
XnStatus XnDeviceBase::RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
XnDeviceModule* pModule;
nRetVal = FindModule(Module, &pModule);
XN_IS_STATUS_OK(nRetVal);
XnPropertyCallback* pRealCookie;
XN_VALIDATE_NEW(pRealCookie, XnPropertyCallback, GetDeviceHandle(), Module, PropertyName, Handler, pCookie);
// register
nRetVal = pModule->RegisterForOnPropertyValueChanged(PropertyName, PropertyValueChangedCallback, pRealCookie, &pRealCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
XN_DELETE(pRealCookie);
return (nRetVal);
}
m_PropertyCallbacks.AddLast(pRealCookie);
*phCallback = pRealCookie;
return (XN_STATUS_OK);
}
示例9: GD_ASSERT
Bool ModuleManager::LoadModule( const Char* pModuleName, const Char* pModuleDir )
{
GD_ASSERT(pModuleName);
GD_ASSERT(pModuleDir);
Char fullPath[260];
if( IsModuleLoaded(pModuleName) )
return true;
strcpy(fullPath, pModuleDir);
strcat(fullPath, pModuleName);
Handle libHandle = Core::OpenLibrary( fullPath );
if( !libHandle )
throw ModuleNotFoundException( pModuleName, Here );
Module* module = const_cast<Module*>(FindModule(pModuleName));
if( !module )
throw ModuleNotRegisteredException( pModuleName, Here );
module->mHandle = libHandle;
module->mDynamicLoad = true;
return true;
}
示例10: FindModule
void Cx_ObjectFactory::ReleaseModule(HMODULE hModule)
{
int index = FindModule(hModule);
ASSERT(index >= 0);
MODULE* item = m_modules[index];
CLSIDS::const_iterator it = item->clsids.begin();
for (; it != item->clsids.end(); ++it)
{
CLSMAP::iterator mit = m_clsmap.find(it->str());
if (mit != m_clsmap.end())
{
m_clsmap.erase(mit);
}
}
if (item->owned)
{
FreeLibrary(hModule);
}
// don't remove: m_modules.erase(m_modules.begin() + index);
item->hdll = NULL;
item->module = NULL;
item->clsids.clear();
}
示例11: NOTIFY_DEBUG_MESSAGE
//////////////////////////////////////////////////////////////////////////
//
// ƯÁ¤ ÇÔ¼ö ÈÄÅ·
//
//////////////////////////////////////////////////////////////////////////
BOOL CRawHookMgr::Hook(LPVOID pfnOld, LPVOID pfnNew, BOOL bWriteCallCode, INT nHookType)
{
NOTIFY_DEBUG_MESSAGE(_T("CRawHookMgr:Hook: called, pfnOld=%p, pfnNew=%p, bWrite=%s\n"), pfnOld, pfnNew, (bWriteCallCode?_T("TRUE"):_T("FALSE")));
pfnOld = GetFixedFuncAddr(pfnOld);
if(NULL == pfnOld) return FALSE;
// ÇÔ¼ö°¡ µé¾îÀÖ´Â ¸ðµâÀ» ¾Ë¾Æ³½´Ù
HMODULE hModule = HandleFromAddress(pfnOld);
if(NULL == hModule) return FALSE;
// ÇöÀç °ü¸®µÇ°í ÀÖ´Â ¸ðµâµé Áß ÀÌ ¸ðµâÀÌ Àִ ã¾Æº¸°í
CRawHookedModule* pModule = FindModule(hModule);
// ¾øÀ¸¸é »õ ¸ðµâ µî·Ï
if( NULL == pModule )
{
pModule = new CRawHookedModule();
if( pModule->Init( hModule ) == FALSE )
{
delete pModule;
return FALSE;
}
m_listModules.push_back(pModule);
}
// ¸ðµâ°´Ã¼¿¡ ÀÌ ÇÔ¼ö¸¦ ÈÄÅ·Ç϶ó Áö½Ã
if(nHookType == ATHOOKTYPE_SOURCE) return pModule->Hook2(pfnOld, pfnNew, bWriteCallCode);
else return pModule->Hook(pfnOld, pfnNew, bWriteCallCode);
}
示例12: InjectDLL
static bool InjectDLL(HANDLE process, const char* dllname)
{
SIZE_T bytesRet = 0;
DWORD oldProtect = 0;
LPVOID remote_addr = NULL;
HANDLE hThread = NULL;
size_t len = strlen(dllname) + 1;
remote_addr = ::VirtualAllocEx(process, 0, 1024, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if(remote_addr==NULL) { return false; }
::VirtualProtectEx(process, remote_addr, len, PAGE_EXECUTE_READWRITE, &oldProtect);
::WriteProcessMemory(process, remote_addr, dllname, len, &bytesRet);
::VirtualProtectEx(process, remote_addr, len, oldProtect, &oldProtect);
HMODULE kernel32 = ::GetModuleHandleA(KernelDLLFileName);
HMODULE tkernel32 = FindModule(process, KernelDLLFileName);
void *loadlib = ::GetProcAddress(kernel32, "LoadLibraryA");
void *entrypoint = (void*) ((size_t)tkernel32+((size_t)loadlib-(size_t)kernel32));
hThread = ::CreateRemoteThread(process, NULL, 0, (LPTHREAD_START_ROUTINE)entrypoint, remote_addr, 0, NULL);
// デバッガがスレッド止めてるので以下の Wait は永久停止を招く
//::WaitForSingleObject(hThread, INFINITE);
//::VirtualFreeEx(process, remote_addr, 0, MEM_RELEASE);
return hThread!=nullptr;
}
示例13: FindModule
InterModuleData Global::ModuleInternalApiCall(const String& module, int method, void* arg) {
Module* mod = FindModule(module);
if (mod == NULL)
return InterModuleData();
void* data = mod->InternalApiCall(method, arg);
return InterModuleData(data, mod, method);
};
示例14: EnumerateThreads
bool Injector::Inject(DWORD processID)
{
HANDLE process = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
if(!process) {
return false;
}
std::vector<HANDLE> threads;
EnumerateThreads(process, [&](DWORD tid){
if(HANDLE thread=::OpenThread(THREAD_ALL_ACCESS, FALSE, tid)) {
::SuspendThread(thread);
threads.push_back(thread);
}
});
{
HMODULE kernel32 = ::GetModuleHandleA(KernelDLLFileName);
HMODULE tkernel32 = FindModule(process, KernelDLLFileName);
void *base = ::GetProcAddress(kernel32, "SetUnhandledExceptionFilter");
void *tbase = (void*) ((size_t)tkernel32+((size_t)base-(size_t)kernel32));
SetThreadTrap(process, tbase);
}
std::for_each(threads.begin(), threads.end(), [](HANDLE thread){
::ResumeThread(thread);
});
std::string dll_path = std::getenv("USERPROFILE");
dll_path += AddInDir;
dll_path += MLBDllFileName;
bool result = InjectDLL(process, dll_path.c_str());
::CloseHandle(process);
return result;
}
示例15: FindModule
bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
CString sMod = sModule; // Make a copy incase the reference passed in is from CModule::GetModName()
CModule* pModule = FindModule(sMod);
sRetMsg = "";
if (!pModule) {
sRetMsg = "Module [" + sMod + "] not loaded.";
return false;
}
bool bSuccess;
GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg), pModule->GetUser(), NULL, return bSuccess);
ModHandle p = pModule->GetDLL();
if (p) {
delete pModule;
for (iterator it = begin(); it != end(); ++it) {
if (*it == pModule) {
erase(it);
break;
}
}
dlclose(p);
sRetMsg = "Module [" + sMod + "] unloaded";
return true;
}
sRetMsg = "Unable to unload module [" + sMod + "]";
return false;
}