|
I want to sign my application and the assemblies that it use, so I know it has not been tampered with when it runs
Right now there are a binary crack for my application, and I thought I might make it a bit harder for the crackers by signing my assemblies...
So I read in MSDN about signing my assemblies with a strong name, but then I read that all the assemblies that the application calls need to be signed with the same private key...
This is a problem as I'm exposing a plug-in interface where people can make plug-in that the application loads at runtime.
If my program is signed with a strong name, does that mean that the plug-in's need to be signed with the same private key?
If it does it makes the whole strong-name thingy useless for me, as no one can develop plug-in's then...
Anyone out there that know more about this than me who can fill me in on it?
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]My Photos[^]
|
|
|
|
|
But when a user make a plug-in he makes it in a separate dll, and MSDN states that an assembly with a strong name can only load other assemblies that are signed with the same private key...
Or have I got something wrong...
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]My Photos[^]
|
|
|
|
|
If I sign an assembly using signcode.exe (and yes, I have a personal certificate ) is there any way to check if the program is signed when it loads?
That way the program could check that it is signed itself (and not has been changed) and that all the dll's also are signed with my certificate and not tampered with, but ignore the plug-in's...
Is that possible, ot just a bad idea?
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]My Photos[^]
|
|
|
|
|
Anders,
After doing just a little reading on MSDN, you could invoke the Certificate Verification Tool (Chktrust.exe) with a Process object which should which will extract the X.509 certificate and with the /q flag you could read the result; Succeeded or Failed. There is probably a much better way with Reflection, this would require more research. HTH
- Nick Parker My Blog | My Articles
|
|
|
|
|
Actually, you can use code access security to state that your assembly must be signed with an X.509 certificate or that your application will only load assemblies signed with your certificate. The CLR will make sure that it hasn't been tampered with.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Let say that you only wanted your assembly loaded if it was signed with your X.509 certificate, you'd add the assembly-level attribute:
[assembly: PublisherIdentityPermission(SecurityAction.RequestMinimum,
X509Certificate="hex-encoded value of your certificate")] If you wanted only plugins to be able to call a method if it was signed with the certificate, attribute your method like so:
[PublisherIdentityPermission(SecurityAction.Demand,
X509Certificate="same thing")]
public void MyMethod()
{
} There's a lot of information about code access security in the .NET Framework SDK that will explain more, as well as a pretty decent (but long) article here on CP, Understanding .NET Code Access Security[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Of course, just use sn.exe -k KeyFile.snk to create one, and you could even put it into a user or machine store using sn.exe -i KeyFile.snk MyContainerName, using the path (project-relative or absolute) in the AssemblyKeyFileAttribute in the former case, and AssemblyKeyNameAttribute in the latter case.
As far as plugins, they do not need to use the same key unless you use code access security to state that plugins must use the same key (not a good idea). Think about this: in your .config file there's several sections where you can specify a type (like in .NET Remoting config sections or system.net config sections) and they load into your application (though typically in these cases you don't load them directly).
Signing an assembly not only identifies the assembly but provides a level of security as you've discovered, such as determining when the file has been tampered with (the CLR takes care of this) or by using CAS to determine what assemblies to trust.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I read some tutorials about scrren capture with C#.
I need a way to draw rectangle selection over whole screen ?
I am able to draw rectangle selection inside my form (application), but I want to draw rectangle selection acros whole screen area (over all active windows, outside my form) to select screen area for capturing ?
How to do rectangle drawing outside app.form ?
Thanks,
|
|
|
|
|
Look up information on the SystemInformation class.
This class has properties to get the bounds of the entire virtual screen:
public static Rectangle VirtualScreen
and the working area:
public static Rectangle WorkingArea
plus many others
The previous post doesn't account for OS controls that always remain on top like the taskbar.
VirtualScreen should get you what you need;
i.e. the rectangle bounds to draw.
John C
|
|
|
|
|
How can you get your application to execute other applications, such as CALC.EXE?
Thanks in advance,
Jon
|
|
|
|
|
The easiest way is probably System.Diagnostic.Process.Start("calc.exe");
However, the Process class has much more functionality that you can use to refine exactly how things should be run and receiving basic information back from the external application.
For more information see MSDN: Process Class[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
Hello,
How do you set the margin (text) of a column of a ListView. For example:
|Column0 | Column1|
| | |
I am referring simply to the text margin of a column.
Given that you have to derive a class from ListView, what function do you override to set the margin or to draw the text based on a different margin?
Thanks,
Kuphryn
|
|
|
|
|
You must override WndProc and handle Windows messages for the header control (which are passed to their parent control's window, which is the List-View common control, which ListView encapsulates). You could handle the NM_CUSTOMDRAW message (sent using a WM_NOTIFY message, actually) and draw your text that way, perhaps extending the ListView control to provide a margin property of some sort (or just hard-code it, depending on what you need the control for).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
i made a class that inherits from System.Windows.Forms.Control, IButtonControl
i want to make the button in an irregular shape, so i assigned the Region with a GraphicsPath object
mycontrol.Region = new Region(mygraphicpath)
the problem is that the quality of the button is horrible!not the same as when i draw it without using the Region object
|
|
|
|
|
Enable anti-aliasing for line drawing.
|
|
|
|
|
i had already tried changing SmoothingModes and CompositingQuality but nothing changes, the problem is there r missing things in the region of my control!
|
|
|
|
|
What do you mean "missing things"? Be a little more technical please. If you're missing certain UI elements like a handle or something, then you need to create a more advanced region.
Another option is to use an image format that supports an alpha channel (like PNG) for your button and then P/Invoke SetLayeredWindowAttributes and use the LWA_ALPHA (0x02) to mask the alpha channel. This will still result in a rectanglular control, but the transparent portions of the image will be transparent. Another problem is, though, that this is only supported on Win2K and higher.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Looking at your original code, you set the region as the size of the graphicspath, but your code does not show whether you in fact draw the graphics path onto the graphics object. Are you doing it?
|
|
|
|
|
How do you create a callback for an OnViseme event in c#?
I've got a simple TTS that I want to animate facial features with
But can't get any viseme events.
public void SpeakText(string text)
{
// Create a Text To Speech voice and speak the specified text.
try
{
//SpFlags = SpeechVoiceSpeakFlags.SVSFDefault ;
SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
Voice = new SpVoice();
if(selectedVoice != null)
{
Voice.Voice = selectedVoice;
}
Voice.Rate = rate;
//Voice.add_Viseme(new _ISpeechVoiceEvents_VisemeEventHandler(vismeHandler ));
Voice.Viseme +=new _ISpeechVoiceEvents_VisemeEventHandler( vismeHandler );
Voice.Speak(text, SpFlags);
}
catch
{
MessageBox.Show("Speak error", "SpeechUI", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|
|
|
|
|
Hi,
I need to add soem custome HTML text in the New Message window of OutlookExpress.
I used the ObjectFromLresult and the IHTMLDocument for getting the HTML of that part whose class is Internet_Explorer Server.I wrote a function which will take the handle of the windows & returns IHTMLDocument.It is as follows
Public Function IEDOMFromhWnd(ByVal hWnd As Integer) As IHTMLDocument
Dim IID_IHTMLDocument As System.Guid = New System.Guid("626FC520-A41E-11CF-731-00A0C9082637")
Dim lRes As Int32
Dim lMsg As Int32
Dim hr As Int32
Const SMTO_ABORTIFHUNG As Int32 = &H2
If Not hWnd.Equals(0) Then
If Not hWnd.Equals(0) Then
' Register the message
lMsg = RegisterWindowMessage("WM_HTML_GETOBJECT")
' Get the object
Call SendMessageTimeout(hWnd, lMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes)
If lRes Then
' Get the object from lRes
hr = ObjectFromLresult(lRes, IID_IHTMLDocument, 0, IEDOMFromhWnd)
If hr Then Throw New COMException(hr)
End If
End If
End If
End Function
But the problem is that I'm not getting the HTML Body even I used the Script property of IHTMLDocument. In the interface variable its showing <undefined value="">. Then in the Script property call Error triggers as Object not reference to an instance of an object.
Please Help me
Its Urgent
Manjith
|
|
|
|
|
I am just wondering if I'm headed in the right direction for this.
Could I use the Bitmap.Clone() to specify the area to grab out of an existing image?
i.e.
Point point = new Point(0 , 0);
Size size = new Size( 100, 50 );
Rectangle rect = new Rectangle( point, size );
Bitmap bitmap = new Bitmap.Clone( rect, System.Drawing.Imaging.PixelFormat.DontCare );
Will this get me the portion of the image that starts at 0,0 and has a width of 100 and a height of 50?
Any feedback will be greatly appreciated.
No comment, Mr. Senator<pre>
|
|
|
|
|
Well, that's what the documentation says. In most cases, I'd trust the documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'd go with Heath on this. As a little tip, if there is anything in the documentation that I don't quite understand I build myself a little demonstrator application (5 minutes work) to test my interpretation of the documentation. That way I can see if it works the way I think it does or not, and if not I now have a test platform to work from to see exactly how it is working.
I hope this helps.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|