Last active
March 23, 2018 06:11
-
-
Save sailfish009/b309d36d7cfefd1069b98596a073cabd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# | |
public class WIN32 | |
{ | |
[DllImport("kernel32.dll")] | |
public static extern Boolean AllocConsole(); | |
[DllImport("kernel32.dll")] | |
public static extern Boolean FreeConsole(); | |
[DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl)] | |
public static extern IntPtr memcpy(IntPtr dest, IntPtr src, int count); | |
[DllImport("msvcrt.dll", EntryPoint = "fopen", CallingConvention = CallingConvention.Cdecl)] | |
public static extern IntPtr fopen(String filename, String mode); | |
[DllImport("msvcrt.dll", EntryPoint = "fwrite", CallingConvention = CallingConvention.Cdecl)] | |
public static extern int fwrite(IntPtr buffer, int size, int count, IntPtr fp); | |
[DllImport("msvcrt.dll", EntryPoint = "fclose", CallingConvention = CallingConvention.Cdecl)] | |
public static extern int fclose(IntPtr fp); | |
} | |
' VB.net | |
Public Class Win32 | |
<DllImport("kernel32.dll")> | |
Public Shared Function AllocConsole() As Boolean | |
End Function | |
<DllImport("kernel32.dll")> | |
Public Shared Function FreeConsole() As Boolean | |
End Function | |
<DllImport("msvcrt.dll", EntryPoint:="memcpy", CallingConvention:=CallingConvention.Cdecl)> | |
Public Shared Sub memcpy(ByVal dest As IntPtr, ByVal src As IntPtr, ByVal count As Integer) | |
End Sub | |
<DllImport("msvcrt.dll", EntryPoint:="memset", CallingConvention:=CallingConvention.Cdecl, SetLastError:=False)> | |
Public Shared Function memset(ByVal dest As IntPtr, ByVal val As Integer, ByVal count As Integer) As IntPtr | |
End Function | |
<DllImport("msvcrt.dll", EntryPoint:="fopen", CallingConvention:=CallingConvention.Cdecl)> | |
Public Shared Function fopen(ByVal filename As String, ByVal mode As String) As IntPtr | |
End Function | |
<DllImport("msvcrt.dll", EntryPoint:="fwrite", CallingConvention:=CallingConvention.Cdecl)> | |
Public Shared Function fwrite(ByVal buffer As IntPtr, ByVal size As Integer, ByVal count As Integer, ByVal fp As IntPtr) As Integer | |
End Function | |
<DllImport("msvcrt.dll", EntryPoint:="fclose", CallingConvention:=CallingConvention.Cdecl)> | |
Public Shared Function fclose(ByVal fp As IntPtr) As Integer | |
End Function | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment