Advertisement
donnaken15

GetUName in C#

Feb 20th, 2019
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Runtime.InteropServices;
  3.  
  4. namespace Default
  5. {
  6.     static class Program
  7.     {
  8.         // found using IDA 6.8 Pro
  9.  
  10.         // charmap loads a DLL named GetUName.dll
  11.         // which has a selfnamed function and pulls
  12.         // the name of a unicode character using an
  13.         // int and loads the name into a string
  14.  
  15.         // in c++, it is used like
  16.         // GetUName(int, LPWSTR *)
  17.  
  18.         [DllImport("GetUName.dll", CallingConvention = CallingConvention.StdCall)]
  19.         public static extern int GetUName(int x, [MarshalAs(UnmanagedType.LPWStr)]string lpBuffer);
  20.  
  21.         // create string buffer to load name in (255 in case of large names, can be changed)
  22.         public static string charactername = new string('*', 255);
  23.  
  24.         static void Main()
  25.         {
  26.             GetUName('A', charactername);
  27.             // asteriks are still left in (* because names don't include
  28.             // any), simply cut the length so they aren't included
  29.             charactername = charactername.Substring(0, charactername.IndexOf('*') - 1);
  30.             Console.Write(charactername);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement