title: C++ SysCall asm unresolved externals
body: <p>I am trying to call NtReadVirtualMemory via a syscall in asm. I am doing this for a few different reasons but it is not to important. So I define the function like so in my main header file:</p>
  
  <pre><code>extern "C" NTSTATUS SysWPM(HANDLE ProcessHandle, PVOID BaseAddress,
  PVOID Buffer, ULONG NumberOfBytesToWrite, PULONG NumberOfBytesWritten);
  </code></pre>
  
  <p>The parameters I believe are correct</p>
  
  <p>I then created an ASM file in the project. I only know enough about it to try and complete this task because it's a very small part of it. Supposedly you do not need to include this asm file anywhere so I left that. Here it is:</p>
  
  <pre><code>.code
  
  SysWPM proc
  
      mov r10, rcx
      mov eac, 37h
      syscall
      ret
  
  SysWPM endp
  
  end
  </code></pre>
  
  <p>Now however when I compile, I get the unresolved external error. I believe this is because I need to define it within this ASM file but I am not sure how to go about doing it. What am I doing wrong/what should I do.</p>
  
  <p>Thought it may be useful to mention I am on Windows 7 and the actual syscall index is 37 as shown in this table:</p>
  
  <p><a href="http://j00ru.vexillium.org/ntapi_64/" rel="nofollow noreferrer">table</a></p>
  
  <p>Here is the exact error for those asking:</p>
  
  <pre><code>1&gt;Main.obj : error LNK2019: unresolved external symbol _SysWPM referenced in function _main
  1&gt;c:\users\Reece\documents\visual studio 2015\Projects\cs-ext\Debug\cs-ext.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <hr>
  
  <p>Still getting the error with the commented solution:</p>
  
  <pre><code>_SysWPM@20 proc
  
      mov r10, rcx
      mov eax, 37h ;
      syscall
      ret
  
  _SysWPM@20 endp
  
  extern "C" NTSTATUS NTAPI SysWPM(HANDLE ProcessHandle, PVOID BaseAddress,
  PVOID Buffer, ULONG NumberOfBytesToWrite, PULONG NumberOfBytesWritten);
  </code></pre>