Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-02-2009, 06:59 PM   #1 (permalink)
shadachi
Recruit
 
Join Date: Jul 2009
Posts: 2
shadachi is on a distinguished road
Is it possible to write DLL using C++

Is it possible to write DLL using C++ and use that dll to kill a specific process when detected.

It like i have a game , and i open a hack , the hack will be listed in the process list as hack.exe

So i would like that dll to detect the hack.exe and terminate it upon opening .

At least a guidance would be quite helpful. I'm still a newbie and want to learn more =)
shadachi is offline   Reply With Quote
Old 07-04-2009, 12:08 AM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 832
DJMaze is on a distinguished road
And what if i rename hack.exe to startup.exe?
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 07-04-2009, 12:12 AM   #3 (permalink)
shadachi
Recruit
 
Join Date: Jul 2009
Posts: 2
shadachi is on a distinguished road
Well , then the dll will terminate startup.exe . I AM NOT MAKING A VIRUS .. swtness . i've seen alot of threads ppl wanting to make this a deadly dll. I'm just trying to make a simple anti-hack dll that kills the hack process

The sole reason to write this dll is to kill a process upon opening . It's an anti-hack dll for a game.exe



How bout using psapi.dll to list down the process .

Well , i found a code in the net but have no idea how to build it . Tried compiling but Gave me errors .

using psapi, this function list all process, check name and if the boolean is true check the filename too

(use the longname (if>8 char) without the .exe), then for your sample just call GetProcessIDByName(L"notepad", true);to find it.

Code:
#include <Psapi.h>

DWORD GetProcessIDByName(LPWSTR szName, bool bCheckFileName) {
DWORD aProcesses[i], cbNeeded, cProcesses;
unsigned int i;

if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return 0;

long l = wcslen(szName);
WCHAR szProcessToFind[MAX_PATH];
wcscpy(szProcessToFind, szName);
if(wcsicmp(&szName[l-4], L".exe")) {
wcscat(szProcessToFind, L".exe");
}

// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);

// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ ) {
WCHAR szProcessName[MAX_PATH] = L"unknown";

// Get a handle to the process.
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);

// Get the process name.
if(hProcess) {
HMODULE hMod;
DWORD cbNeeded;

if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
GetModuleBaseNameW(hProcess, hMod, szProcessName, sizeof(szProcessName));
if(wcsicmp(szProcessToFind, szProcessName) == 0) {
CloseHandle( hProcess );
return aProcesses[i];
} else if(bCheckFileName) {
WCHAR *p, szFileName[MAX_PATH] = L"unknown", szLongFileName[MAX_PATH] = L"unknown";

GetModuleFileNameExW(hProcess, hMod, szFileName, sizeof(szFileName));
p = wcsrchr(szFileName, '\\');
if(wcsicmp(szProcessToFind, p+1) == 0) {
CloseHandle( hProcess );
return aProcesses[i];
}
if(wcschr(szFileName, '~')) {
if(GetLongPathNameW(szFileName, szLongFileName, sizeof(szLongFileName))) {
p = wcsrchr(szLongFileName, '\\');
if(wcsicmp(szProcessToFind, p+1) == 0) {
CloseHandle( hProcess );
return aProcesses[i];
}
}
}
} 
}
}
CloseHandle(hProcess);
}
return 0;
}
shadachi is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Write Permissions Redline PHP 3 04-20-2006 01:48 PM
How to write a whole string backwards. slashdot All Other Coding Languages 1 03-04-2005 06:56 AM
Someone want to write a script? falsepride HTML, XML, Javascript, AJAX 9 11-26-2004 08:07 PM


All times are GMT -8. The time now is 10:18 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting