Fixed some errors, removed obsolete code, removed some anonymous delegates and added some additional disposing code in the CaptureHelper.cs

This commit is contained in:
RKrom 2014-06-16 11:25:04 +02:00
commit be36a3f42b
11 changed files with 211 additions and 1791 deletions

View file

@ -76,6 +76,10 @@ namespace GreenshotPlugin.UnmanagedHelpers {
/// A hbitmap SafeHandle implementation
/// </summary>
public class SafeHBitmapHandle : SafeObjectHandle {
[SecurityCritical]
private SafeHBitmapHandle() : base(true) {
}
[SecurityCritical]
public SafeHBitmapHandle(IntPtr preexistingHandle) : base(true) {
SetHandle(preexistingHandle);
@ -86,6 +90,10 @@ namespace GreenshotPlugin.UnmanagedHelpers {
/// A hRegion SafeHandle implementation
/// </summary>
public class SafeRegionHandle : SafeObjectHandle {
[SecurityCritical]
private SafeRegionHandle() : base(true) {
}
[SecurityCritical]
public SafeRegionHandle(IntPtr preexistingHandle) : base(true) {
SetHandle(preexistingHandle);
@ -96,6 +104,10 @@ namespace GreenshotPlugin.UnmanagedHelpers {
/// A dibsection SafeHandle implementation
/// </summary>
public class SafeDibSectionHandle : SafeObjectHandle {
[SecurityCritical]
private SafeDibSectionHandle() : base(true) {
}
[SecurityCritical]
public SafeDibSectionHandle(IntPtr preexistingHandle) : base(true) {
SetHandle(preexistingHandle);
@ -112,6 +124,10 @@ namespace GreenshotPlugin.UnmanagedHelpers {
private SafeHandle hdc;
[SecurityCritical]
private SafeSelectObjectHandle() : base(true) {
}
[SecurityCritical]
public SafeSelectObjectHandle(SafeDCHandle hdc, SafeHandle newHandle) : base(true) {
this.hdc = hdc;
@ -135,6 +151,10 @@ namespace GreenshotPlugin.UnmanagedHelpers {
[DllImport("gdi32", SetLastError = true)]
private static extern bool DeleteDC(IntPtr hDC);
[SecurityCritical]
private SafeCompatibleDCHandle() : base(true) {
}
[SecurityCritical]
public SafeCompatibleDCHandle(IntPtr preexistingHandle) : base(true) {
SetHandle(preexistingHandle);
@ -154,6 +174,10 @@ namespace GreenshotPlugin.UnmanagedHelpers {
/// </summary>
public class SafeDeviceContextHandle : SafeDCHandle {
private Graphics graphics = null;
[SecurityCritical]
private SafeDeviceContextHandle() : base(true) {
}
[SecurityCritical]
public SafeDeviceContextHandle(Graphics graphics, IntPtr preexistingHandle) : base(true) {