能力值:
(RANK:510 )
|
-
-
2 楼
很好的总结,很实用。
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
能否给出Yonsm和那片国外的文章的链接啊~
学习一下~
|
能力值:
( LV7,RANK:110 )
|
-
-
4 楼
yonsm的代码就在本版块啦……
国外那个网站:
http://wmdevelopers.blogspot.com/2008/05/inject-dlls.html
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
ci.hProcess = hProcessDest;
ci.pFunction = (FARPROC)GetProcAddress(GetModuleHandle( _T("coredll.dll") ),_T("LoadLibraryW") );
ci.pvArg0 = MapPtrToProcess(_T("test.dll"),GetCurrentProcess()); //先注入dll
HINSTANCE hInst = (HINSTANCE) PerformCallBack4(&ci,0,0,0);
hInst 返回的是空啊,一直取不到, 不知道哪里出问题了..
(Windows Mobile 5.0 Pocket PC )
=============================
ci.pvArg0 = MapPtrToProcess((PVOID)pszPath, GetCurrentProcess()); //先注入dll
pszPath这个传入dll的全路径,就能取到INSTANCE 了
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
我有一段代码是能用的,
typedef struct {
int hprocess;
int func;
int arg0;
} CallBackInfo;
typedef int (WINAPI *PerformCallBack4_T)(CallBackInfo* pcbi, int arg1, int arg2, int arg3);
//-----------------------------------------------------------------------------
// fill process view
//-----------------------------------------------------------------------------
BOOL
MemoryDlg::ProcessMemoryView(PROCESSENTRY32* ppe32)
{
PerformCallBack4_T PerformCallBack4;
HANDLE hsnapshot;
PROCESSENTRY32 pe = {0};
CallBackInfo cbi = {0};
MEMORYSTATUS ms = {0};
TCHAR szFmt[256];
DWORD dwUsedHeap;
PerformCallBack4 = (PerformCallBack4_T)GetProcAddress(hcoredll, _T("PerformCallBack4"));
if (0 == PerformCallBack4) {
return FALSE;
}
cbi.func = (int)GetProcAddress(hcoredll, _T("GlobalMemoryStatus"));
if (0 == cbi.func) {
return FALSE;
}
cbi.arg0 = (int)&ms;
hsnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe.dwSize = sizeof(pe);
if (Process32First(hsnapshot, &pe)) {
do {
if ( _tcsicmp(ppe32->szExeFile, pe.szExeFile) == 0 ) {
cbi.hprocess = (int)OpenProcess(0, 0, pe.th32ProcessID);
PerformCallBack4(&cbi, 0, 0, 0);
// _tprintf(_T("----------------------------------------\n"));
// _tprintf(_T("image: %s\npid: %u\n"), pe.szExeFile, ppe32.th32ProcessID);
// _tprintf(_T("dwTotalPhys: %d\ndwAvailPhys: %d (%.1f%%)\n"), ms.dwTotalPhys, ms.dwAvailPhys, ms.dwAvailPhys * 100.0/ms.dwTotalPhys);
// _tprintf(_T("dwTotalVirtual: %d\ndwAvailVirtual: %d (%.1f%%)\n"), ms.dwTotalVirtual, ms.dwAvailVirtual, ms.dwAvailVirtual * 100.0/ms.dwTotalVirtual);
m_list_mem.InsertItem(0, pe.szExeFile);
//// Total Virtual Memory(Not Visible)
//wsprintf( szFmt, _T("%dKB"), ms.dwMemoryLoad / 1024 );
//m_list_mem.SetItemText(1, 1, szFmt);
dwUsedHeap = CalcHeapOfProcess(pe.th32ProcessID);
wsprintf(szFmt, _T("%dKB"), (dwUsedHeap>>10));
m_list_mem.SetItemText(0, 1, szFmt);
// Available Virtual Memory
wsprintf( szFmt, _T("%dKB"), ms.dwAvailVirtual / 1024 );
m_list_mem.SetItemText(0, 2, szFmt);
// Available Virtual Memory(%)
wsprintf( szFmt, _T("%.1f"), ms.dwAvailVirtual * 100.0 / ms.dwTotalVirtual );
m_list_mem.SetItemText(0, 3, szFmt);
//ListView_SetItemText( hwndLView2, dwIndex, 3, szFmt );
CloseHandle((HANDLE)cbi.hprocess);
break;
}
} while (Process32Next(hsnapshot, &pe));
}
CloseToolhelp32Snapshot(hsnapshot);
return TRUE;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
学习中。。。
为什么我跑下来会在GetModuleHandle( _T("coredll.dll") ),这句出错呢
GetLastError()错误代码为6,The handle is invalid.
HINSTANCE hInst = (HINSTANCE) PerformCallBack4(&ci,0,0,0);
这句hInst返回也是空,error126
不解
|
能力值:
( LV2,RANK:10 )
|
-
-
8 楼
codeproject有篇文章 http://www.codeproject.com/KB/mobile/InjectDLLIntoProcess.aspx
我按照它这样来做有点问题
|
能力值:
( LV2,RANK:10 )
|
-
-
9 楼
小金 我按照你的方法做了一遍 为什么执行到HINSTANCE hInst = (HINSTANCE) PerformCallBack4(&ci,0,0,0);
if ( 0 == GetLastError()) 这里的时候hInst返回负值,而且GetLastError不为0,程序直接跑到异常
|
能力值:
( LV2,RANK:10 )
|
-
-
10 楼
好文章,
|
能力值:
( LV2,RANK:10 )
|
-
-
11 楼
跟7楼一样,PerformCallBack4返回的是0,请问该怎么办啊?它之前的所有函数的返回值都正常。
wince6.0的,楼主请帮忙指点下。
|
能力值:
( LV2,RANK:10 )
|
-
-
12 楼
NETTF小金 大牛:我参考你的代码, 但是PerfromCallback4调用失败, Error = 6(无效的句柄)
下面是我写的关键代码:
HANDLE
FindProcess(IN PWCHAR pProcess)
{
HANDLE hProc = NULL;
PROCESSENTRY32 entry;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(INVALID_HANDLE_VALUE != hSnap)
{
ZeroMemory(&entry, sizeof(entry));
entry.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(hSnap, &entry))
{
do
{
//DbgPrint(entry.szExeFile);
if(wcsicmp(entry.szExeFile, pProcess) == 0)
{
hProc = OpenProcess(0, FALSE, entry.th32ProcessID);
break;
}
} while (Process32Next(hSnap, &entry));
}
}
if(hSnap)
CloseToolhelp32Snapshot(hSnap);
return hProc;
}
VOID
InjectDllToProcess()
{
WCHAR DllPath[MAX_PATH] = L"";
CallbackInfo ci;
GetModuleFileName(NULL, DllPath, MAX_PATH);
PWCHAR p = wcsrchr(DllPath, L'\\');
DllPath[p - DllPath] = '\0';
wcscat(DllPath, L"\\Inject.dll");
ZeroMemory(&ci, sizeof(ci));
g_hProcess = FindProcess(L"fexplore.exe");
if(g_hProcess != NULL)
{
DWORD dwMode = SetKMode(TRUE);
DWORD dwPerm = SetProcPermissions(0xFFFFFFFF);
FARPROC pFunc = GetProcAddress(GetModuleHandle(L"Coredll.dll"), L"LoadLibraryW");
ci.ProcId = (HANDLE)g_hProcess ;
ci.pFunc = pFunc;//(FARPROC)MapPtrToProcess(pFunc, g_hProcess);
ci.pvArg0 = MapPtrToProcess(DllPath, GetCurrentProcess());
g_Inject = (HINSTANCE)PerformCallBack4(&ci, 0, 0, 0);
if(GetLastError() != 0)
DbgError(L"PerformCallBack 执行失败", GetLastError());
SetKMode(dwMode);
SetProcPermissions(dwPerm);
}
}
我不知道问题出在哪, 你以前研究过, 不知道有没有遇到过?
|
能力值:
( LV2,RANK:10 )
|
-
-
13 楼
NETTF小金 大牛:我参考你的代码, 但是PerfromCallback4调用失败, Error = 6(无效的句柄)
下面是我写的关键代码:
HANDLE
FindProcess(IN PWCHAR pProcess)
{
HANDLE hProc = NULL;
PROCESSENTRY32 entry;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(INVALID_HANDLE_VALUE != hSnap)
{
ZeroMemory(&entry, sizeof(entry));
entry.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(hSnap, &entry))
{
do
{
//DbgPrint(entry.szExeFile);
if(wcsicmp(entry.szExeFile, pProcess) == 0)
{
hProc = OpenProcess(0, FALSE, entry.th32ProcessID);
break;
}
} while (Process32Next(hSnap, &entry));
}
}
if(hSnap)
CloseToolhelp32Snapshot(hSnap);
return hProc;
}
VOID
InjectDllToProcess()
{
WCHAR DllPath[MAX_PATH] = L"";
CallbackInfo ci;
GetModuleFileName(NULL, DllPath, MAX_PATH);
PWCHAR p = wcsrchr(DllPath, L'\\');
DllPath[p - DllPath] = '\0';
wcscat(DllPath, L"\\Inject.dll");
ZeroMemory(&ci, sizeof(ci));
g_hProcess = FindProcess(L"fexplore.exe");
if(g_hProcess != NULL)
{
DWORD dwMode = SetKMode(TRUE);
DWORD dwPerm = SetProcPermissions(0xFFFFFFFF);
FARPROC pFunc = GetProcAddress(GetModuleHandle(L"Coredll.dll"), L"LoadLibraryW");
ci.ProcId = (HANDLE)g_hProcess ;
ci.pFunc = pFunc;//(FARPROC)MapPtrToProcess(pFunc, g_hProcess);
ci.pvArg0 = MapPtrToProcess(DllPath, GetCurrentProcess());
g_Inject = (HINSTANCE)PerformCallBack4(&ci, 0, 0, 0);
if(GetLastError() != 0)
DbgError(L"PerformCallBack 执行失败", GetLastError());
SetKMode(dwMode);
SetProcPermissions(dwPerm);
}
}
我不知道问题出在哪, 你以前研究过, 不知道有没有遇到过?
|
能力值:
( LV2,RANK:10 )
|
-
-
14 楼
现在有遇到问题, 我用Remote Process Viewer看的时候, 发现我的DLL已经加载了, 但是为什么PerfromCallback4会返回 无效句柄呢 ?
|
能力值:
( LV2,RANK:10 )
|
-
-
15 楼
各位牛人能不能做这个:
获取QQ2008列表焦点处的文字
平台:WM5, WM6 for smartphone
价格没有问题可以商量
|