title: Calling Nt function from ntdll.dll in Win32 environment, C++
body: <p>I want to call some Nt function from ntdll.dll, I'm doing that like this above.</p>
  
  <p>For calling: NtTestAlert() , you need typical ntcall kernel routine, accessable via int 2Eh.
  ( from here I got Nt functions <a href="http://undocumented.ntinternals.net/" rel="noreferrer">http://undocumented.ntinternals.net/</a> )</p>
  
  <p>Code is also unfinished, I'm getting:</p>
  
  <p>*error C2664: '_<em>ntcall' : cannot convert parameter 1 from 'int' to 'MESS (</em>_stdcall <em>)'</em></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;Ntsecapi.h&gt;
  
  using namespace std;
  
  typedef int(__stdcall MESS)(unsigned int);
  
  void __ntcall(MESS *msg)
  {
      __asm
      {
          int 2Eh;
      }
  }
  
  int main(void)
  {
      MESS *me = 0;
      int result = 0;
  
      HINSTANCE__ *hModule= LoadLibrary(L"C:\\Windows\\System32\\ntdll.dll");
  
      if(hModule != 0)
      {
          me = (MESS*)GetProcAddress(hModule, "NtTestAlert");
  
          if(me != 0)
          {
              unsigned int type = 1;
  
              result = (__ntcall((*me)(type)));
          }
          else
          {
              cout &lt;&lt; "Error Load function!" &lt;&lt; endl;
          }
  
          FreeLibrary(hModule);
      }
      else
      {
          cout &lt;&lt; "Error load Dll!" &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>