Click here to Skip to main content
15,880,503 members
Home / Discussions / C#
   

C#

 
GeneralRe: Declaring variables inside loops - inefficient? Pin
harold aptroot19-Jul-10 6:52
harold aptroot19-Jul-10 6:52 
GeneralRe: Declaring variables inside loops - inefficient? Pin
Luc Pattyn19-Jul-10 6:52
sitebuilderLuc Pattyn19-Jul-10 6:52 
GeneralRe: Declaring variables inside loops - inefficient? Pin
Pete O'Hanlon19-Jul-10 6:54
mvePete O'Hanlon19-Jul-10 6:54 
AnswerRe: Declaring variables inside loops - inefficient? Pin
Luc Pattyn19-Jul-10 7:04
sitebuilderLuc Pattyn19-Jul-10 7:04 
Questionreading weather.com data feed Pin
Jassim Rahma19-Jul-10 5:07
Jassim Rahma19-Jul-10 5:07 
AnswerRe: reading weather.com data feed Pin
Eddy Vluggen19-Jul-10 5:20
professionalEddy Vluggen19-Jul-10 5:20 
AnswerRe: reading weather.com data feed Pin
brunoseixas19-Jul-10 6:58
brunoseixas19-Jul-10 6:58 
QuestionRtlSetProcessIsCritical, Marshall and pointers. Pin
Night Lol19-Jul-10 4:45
Night Lol19-Jul-10 4:45 
Hi !

I have a big problem, I try to create a parental control (which use the hosts file in windows).
So, I have look the "RtlSetProcessIsCritical" sample code in C/C++. But, I'm a CSharp developer.
My source code is :

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace RtlSetProcessIsCriticalCSharp
{
    unsafe public partial class Form1 : Form
    {
        [DllImport("kernel32.dll")]
        static extern IntPtr LoadLibrary(string dllName);

        [DllImport("kernel32.dll")]
        static extern IntPtr GetProcAddress(IntPtr hModule, string procName);

        delegate long *ProcessIsCriticalDelegate(
        [MarshalAs(UnmanagedType.Bool)]bool bNew, bool *pbOld,
        [MarshalAs(UnmanagedType.Bool)]bool bNeedScb);

        public Form1()
        {
            InitializeComponent();
        }

        unsafe private void Form1_Load(object sender, EventArgs e)
        {
            IntPtr ntdll = LoadLibrary("ntdll.dll");
            IntPtr ProcAdd = GetProcAddress(ntdll, "RtlSetProcessIsCritical");
            ProcessIsCriticalDelegate pcd = (ProcessIsCriticalDelegate)Marshal.GetDelegateForFunctionPointer(ProcAdd, typeof(ProcessIsCriticalDelegate));
            pcd(true, null, false);
        }
    }
}


No error, nothing.

The article about RtlSetProcessIsCritical :

"Protecting" Your Process with RtlSetProcessIsCritical

Can you help me ? Sorry for my bad english, I'm french.
AnswerRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
Luc Pattyn19-Jul-10 5:00
sitebuilderLuc Pattyn19-Jul-10 5:00 
GeneralRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
Night Lol19-Jul-10 5:14
Night Lol19-Jul-10 5:14 
GeneralRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
DaveyM6919-Jul-10 5:31
professionalDaveyM6919-Jul-10 5:31 
GeneralRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
Night Lol19-Jul-10 5:51
Night Lol19-Jul-10 5:51 
GeneralRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
DaveyM6919-Jul-10 7:46
professionalDaveyM6919-Jul-10 7:46 
AnswerRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
Luc Pattyn19-Jul-10 5:33
sitebuilderLuc Pattyn19-Jul-10 5:33 
GeneralRe: RtlSetProcessIsCritical, Marshall and pointers. Pin
Night Lol19-Jul-10 5:52
Night Lol19-Jul-10 5:52 
QuestionUnable to reference shared assembly in GAC [modified] Solved Pin
Jonathan Davies19-Jul-10 2:30
Jonathan Davies19-Jul-10 2:30 
AnswerRe: Unable to reference shared assembly in GAC Pin
PIEBALDconsult19-Jul-10 3:13
mvePIEBALDconsult19-Jul-10 3:13 
GeneralRe: Unable to reference shared assembly in GAC Pin
Jonathan Davies19-Jul-10 4:02
Jonathan Davies19-Jul-10 4:02 
QuestionHTML Table tag text Scraping Pin
NaveenHS19-Jul-10 0:48
NaveenHS19-Jul-10 0:48 
AnswerRe: HTML Table tag text Scraping Pin
Luc Pattyn19-Jul-10 0:57
sitebuilderLuc Pattyn19-Jul-10 0:57 
GeneralRe: HTML Table tag text Scraping Pin
NaveenHS19-Jul-10 1:45
NaveenHS19-Jul-10 1:45 
GeneralRe: HTML Table tag text Scraping Pin
Not Active19-Jul-10 5:41
mentorNot Active19-Jul-10 5:41 
AnswerRe: HTML Table tag text Scraping Pin
ragnaroknrol19-Jul-10 4:04
ragnaroknrol19-Jul-10 4:04 
GeneralRe: HTML Table tag text Scraping Pin
Luc Pattyn19-Jul-10 4:29
sitebuilderLuc Pattyn19-Jul-10 4:29 
AnswerRe: HTML Table tag text Scraping Pin
PIEBALDconsult19-Jul-10 4:21
mvePIEBALDconsult19-Jul-10 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.