EDN Admin
Well-known member
bool inject(DWORD pid);
.....
on BUTTON 1 :
DWORD proc;<br/>
PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};<br/>
HANDLE hPsnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br/>
<span style="white-spacere if(Process32First(hPsnap, &pe32)){<br/>
while(Process32Next(hPsnap, &pe32)){<br/>
if(!strcmp(pe32.szExeFile, "target.exe")){<br/>
proc
= pe32.th32ProcessID;<br/>
<br/>
<span style="white-spacere
if(inject(proc)){break;}<br/>
<span style="white-spacere <br/>
<span style="white-spacere }<br/>
<span style="white-spacere <br/>
<span style="white-spacere }<br/>
<br/>
<span style="white-spacere }<br/>
CloseHandle(hPsnap);
i made an injector in winform..this one works well in my PC but it doesnt inject the DLL when running in other pc....basically the code doesnt work in other PC !!!!
and one dll i made with code that will read registry when it attached to a process..
int main()<br/>
{<br/>
<span style="white-spacere HKEY hKey;<br/>
<span style="white-spacere char buf[255] = {0};<br/>
<span style="white-spacere DWORD dwType = 0;<br/>
DWORD dwBufSize = sizeof(buf);<br/>
if( RegOpenKey(HKEY_CURRENT_USER,"Software\foo",&hKey ) == ERROR_SUCCESS )<br/>
<span style="white-spacere {<br/>
<span style="white-spacere <span style="white-spacere dwType = REG_SZ;<br/>
<span style="white-spacere if( RegQueryValueEx(hKey,"DWORD",0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS)<br/>
{<span style="white-spacere <br/>
<span style="white-spacere //do stuff<br/>
}<br/>
<br/>
<span style="white-spacere }<br/>
<span style="white-spacere <br/>
RegCloseKey(hKey);<br/>
<span style="white-spacere return 0;<br/>
}<br/>
works well again in my PC but when i injected this dll in other PC, it crashes the process
what a waste of f#$%^ time and effort and energy for working on projects that not gonna run in other machine..only in c++ i guess !!
Can u give me tips on how to debug/ build/ release projects correctly ?!!!im using VS2008 prof
and if u can pls correct my code above
Many thanks in advance
<br/>
<br/>
<br/>
View the full article
.....
on BUTTON 1 :
DWORD proc;<br/>
PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};<br/>
HANDLE hPsnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br/>
<span style="white-spacere if(Process32First(hPsnap, &pe32)){<br/>
while(Process32Next(hPsnap, &pe32)){<br/>
if(!strcmp(pe32.szExeFile, "target.exe")){<br/>
proc
= pe32.th32ProcessID;<br/>
<br/>
<span style="white-spacere
if(inject(proc)){break;}<br/>
<span style="white-spacere <br/>
<span style="white-spacere }<br/>
<span style="white-spacere <br/>
<span style="white-spacere }<br/>
<br/>
<span style="white-spacere }<br/>
CloseHandle(hPsnap);
i made an injector in winform..this one works well in my PC but it doesnt inject the DLL when running in other pc....basically the code doesnt work in other PC !!!!
and one dll i made with code that will read registry when it attached to a process..
int main()<br/>
{<br/>
<span style="white-spacere HKEY hKey;<br/>
<span style="white-spacere char buf[255] = {0};<br/>
<span style="white-spacere DWORD dwType = 0;<br/>
DWORD dwBufSize = sizeof(buf);<br/>
if( RegOpenKey(HKEY_CURRENT_USER,"Software\foo",&hKey ) == ERROR_SUCCESS )<br/>
<span style="white-spacere {<br/>
<span style="white-spacere <span style="white-spacere dwType = REG_SZ;<br/>
<span style="white-spacere if( RegQueryValueEx(hKey,"DWORD",0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS)<br/>
{<span style="white-spacere <br/>
<span style="white-spacere //do stuff<br/>
}<br/>
<br/>
<span style="white-spacere }<br/>
<span style="white-spacere <br/>
RegCloseKey(hKey);<br/>
<span style="white-spacere return 0;<br/>
}<br/>
works well again in my PC but when i injected this dll in other PC, it crashes the process
what a waste of f#$%^ time and effort and energy for working on projects that not gonna run in other machine..only in c++ i guess !!
Can u give me tips on how to debug/ build/ release projects correctly ?!!!im using VS2008 prof
and if u can pls correct my code above
Many thanks in advance
<br/>
<br/>
<br/>
View the full article