473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C#: DLL Injection

Hello,

I'm curious if anyone could describe the settings needed for a C#
project to inject a C dll (setup a windows hook) into a running process.

Thanks,
Ryan
Nov 17 '05 #1
2 14425
It is impossible to do this in pure C#. You can write a C dll which injects
code and use it in C# via P/Invoke using DllImport attribute to import and
use native functions from your C dll.

"Ryan Ross" <ry***@nni.com> wrote in message
news:2c********************@nni.com...
Hello,

I'm curious if anyone could describe the settings needed for a C#
project to inject a C dll (setup a windows hook) into a running process.

Thanks,
Ryan

Nov 17 '05 #2
Yes. The problem I'm faced with is that the C dll does not appear to be
working. More precisely, the dll injects just fine in the alpha code,
but appears not to work in the beta code. Here's some snippets:

The DLL injection code (same in both the alpha and the beta):
public class PaintHook
{
[DllImport ("PaintHook.dll", EntryPoint="#1")]
public static extern IntPtr InstallHook();

}

This code works fine in the alpha, but does not work in the beta.
Invocation of the dll is PaintHook.InstallHook(). The dll is activated
by sending a custom message via SendMessage().

For the life of me, I cannot figure out why it's not working. The dll
copies a window into a bitmap (which exists in shared memory, which the
C# component accesses), something akin to the PrintWindow() function.

As a test, I changed the dll to close a window when activated. Alpha
code closes the window, beta does not. Very simple code (InstallHook,
SendMessage methods), should work in both. No dice.

Any theories as to why the dll works only in the one? Am I missing some
security or project settings that are the cause?

Thanks,
Ryan

Lebesgue wrote:
It is impossible to do this in pure C#. You can write a C dll which injects
code and use it in C# via P/Invoke using DllImport attribute to import and
use native functions from your C dll.

"Ryan Ross" <ry***@nni.com> wrote in message
news:2c********************@nni.com...
Hello,

I'm curious if anyone could describe the settings needed for a C#
project to inject a C dll (setup a windows hook) into a running process.

Thanks,
Ryan


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: NotGiven | last post by:
Steve wrote, > "And read up on "sql injection" attacks (use your favorite search > engine). As indicated, validate input. e.g. if you expert $_GET > to be integer, then do > > $a =...
1
by: Cogswell | last post by:
I am working on an ecommerce app and want to be able to take my entire POST results as one item (or iterate through them) and check for any malicious SQL INJECTION items. After checking/escaping...
11
by: Bã§TãRÐ | last post by:
I have been working on this particular project for a little over 2 weeks now. This product contains between 700-900 stored procedures to handle just about all you can imagine within the product. I...
10
by: bregent | last post by:
I've seen plenty of articles and utilities for preventing form injections for ASP.NET, but not too much for classic ASP. Are there any good input validation scripts that you use to avoid form...
8
by: stirrell | last post by:
Hello, One problem that I had been having is stopping email injections on contact forms. I did some research, read up on it and felt like I had created a working solution. I hadn't gotten any...
7
by: | last post by:
There are assorted "SQL Injection vulnerability assessment tools" out there. They scan your site and send your report. They also take your money. We don't have the money so I was wondering if I...
3
by: =?Utf-8?B?Um9kbmV5IFZpYW5h?= | last post by:
IIS 6 SQL Injection Sanitation ISAPI Wildcard at http://www.codeplex.com/IIS6SQLInjection I created an ISAPI dll application to prevent SQL Injection attempts by intercepting the HTTP requests...
2
by: Sudhakar | last post by:
A) validating username in php as part of a registration form a user fills there desired username and this is stored in a mysql. there are certain conditions for the username. a) the username...
12
by: shank | last post by:
I've been hit again using DW, parameterized queries and stored procedures. I'm guessing I was not strict enough with character counts and allowing to long of a string to pass. Aside from that,...
2
by: Brian Bozarth | last post by:
This is weird, I'm pretty familiar with SQL Injection - but we're getting these weird injection that is writing in the default document or home page. What it's doing is putting in script code at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.