Last active
November 16, 2016 07:15
-
-
Save txdv/ff2b572478913e66fcf99a46895200c1 to your computer and use it in GitHub Desktop.
Example
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
using System; | |
using System.Runtime.InteropServices; | |
public class MainClass | |
{ | |
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | |
private struct ModuleInputData | |
{ | |
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] | |
public unsafe fixed char name[260]; | |
public uint pid; | |
} | |
public unsafe static void Main(string[] args) | |
{ | |
ModuleInputData data; | |
var arg = args[0]; | |
fixed (char* ptr = arg) | |
{ | |
for (int i = 0; i < 260; i++) { | |
char chr = *(ptr + i); | |
if (chr == '\0') { | |
break; | |
} | |
data.name[i] = chr; | |
} | |
data.name[0] = ptr[0]; | |
} | |
} | |
} |
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
main.exe: main.cs | |
mcs /unsafe main.cs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment