Here are the examples of the csharp api ulong.ToString(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
206 Examples
19
Source : Disassembler.cs
with MIT License
from 0xd4d
with MIT License
from 0xd4d
static string FormatAddress(int bitness, ulong address, bool upperCaseHex) {
switch (bitness) {
case 16:
return address.ToString(upperCaseHex ? "X4" : "x4");
case 32:
return address.ToString(upperCaseHex ? "X8" : "x8");
case 64:
return address.ToString(upperCaseHex ? "X16" : "x16");
default:
throw new ArgumentOutOfRangeException(nameof(bitness));
}
}
19
Source : DarksVMDispatcher.cs
with GNU General Public License v3.0
from Aekras1a
with GNU General Public License v3.0
from Aekras1a
private static unsafe string GetIP(DarksVMContext ctx)
{
var ip = (uint) (ctx.Registers[DarksVMConstants.REG_IP].U8 - (ulong) ctx.Instance.Data.KoiSection);
ulong key = (uint) (new object().GetHashCode() + Environment.TickCount) | 1;
return (((ip * key) << 32) | (key & ~1UL)).ToString("x16");
}
19
Source : UntypedBuffer.cs
with MIT License
from Alan-FGR
with MIT License
from Alan-FGR
public unsafe void PrintDebugData(int count, Type type)
{
List<String> strs = new List<String>();
for (int i = 0; i < count; i++)
{
String str;
try
{
var cast = Activator.CreateInstance(type);
var handle = GCHandle.Alloc(cast, GCHandleType.Pinned);
var addr = (void*)handle.AddrOfPinnedObject();
Buffer.MemoryCopy(At(i), addr, ElementSizeInBytes, ElementSizeInBytes);
handle.Free();
str = cast.ToString();
str = str.Substring(Math.Max(0, str.Length - 16), Math.Min(str.Length, 16)).PadLeft(16, '_');
}
catch (Exception e)
{
ulong ul = 0ul;
Buffer.MemoryCopy(At(i), &ul, ElementSizeInBytes, ElementSizeInBytes);
str = ul.ToString("X").PadLeft(16, '0');
}
strs.Add(str);
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($" {GetType()}<{type}>, elSize={ElementSizeInBytes}, bfSize={bufferSizeInBytes_}, ptr={buffer_}, unaligned={unalignedPtr_}");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($" objs: {String.Join(", ", strs)}");
}
19
Source : L64Record.cs
with Apache License 2.0
from alexreinert
with Apache License 2.0
from alexreinert
internal override string RecordDataToString()
{
string locator = Locator64.ToString("x16");
return Preference + " " + locator.Substring(0, 4) + ":" + locator.Substring(4, 4) + ":" + locator.Substring(8, 4) + ":" + locator.Substring(12);
}
19
Source : NIdRecord.cs
with Apache License 2.0
from alexreinert
with Apache License 2.0
from alexreinert
internal override string RecordDataToString()
{
string nodeID = NodeID.ToString("x16");
return Preference + " " + nodeID.Substring(0, 4) + ":" + nodeID.Substring(4, 4) + ":" + nodeID.Substring(8, 4) + ":" + nodeID.Substring(12);
}
19
Source : LiveHexUI.cs
with MIT License
from architdate
with MIT License
from architdate
private void B_CopyAddress_Click(object sender, EventArgs e)
{
if (Remote.Bot.com is not ICommunicatorNX sb)
return;
ulong address = GetPointerAddress(sb);
if (address == 0)
WinFormsUtil.Alert("No pointer address.");
ulong heap = sb.GetHeapBase();
address -= heap;
Clipboard.SetText(address.ToString("X"));
}
19
Source : BV64Algebra.cs
with MIT License
from AutomataDotNet
with MIT License
from AutomataDotNet
public string SerializePredicate(ulong s)
{
return s.ToString("x");
}
19
Source : BV.cs
with MIT License
from AutomataDotNet
with MIT License
from AutomataDotNet
public string Serialize()
{
string str = this.first.ToString("x") + "." + string.Join(".", Array.ConvertAll(this.more, x => x.ToString("x")));
return str;
}
19
Source : PileForm.cs
with MIT License
from azist
with MIT License
from azist
public static Person MakeFake()
{
return new Person
{
ID = new GDID(0, 0, _id++),
FirstName = "Gavial-"+_id.ToString("0000"),
LastName = "Buxarinovich-"+_id.ToString("00000"),
DOB = _id%7==0 ? (DateTime?)null : DateTime.UtcNow,
Balance = 2131m,
// Data = new float[]{12.388f, -32.9090f, 2343434.893f}
};
}
19
Source : DecompiledMethod.cs
with MIT License
from badamczewski
with MIT License
from badamczewski
public override string ToString()
{
StringBuilder builder = new StringBuilder();
builder.AppendLine($"{Name}:");
foreach (var replacedemblyCode in Instructions)
{
StringBuilder argBuilder = new StringBuilder();
foreach (var arg in replacedemblyCode.Arguments)
{
argBuilder.Append(arg.Value + ", ");
}
if (argBuilder.Length > 2)
argBuilder.Remove(argBuilder.Length - 2, 2);
builder.AppendLine($" {replacedemblyCode.Address.ToString("X")} `{replacedemblyCode.Instruction}` {argBuilder.ToString()}");
}
return builder.ToString();
}
19
Source : GOWatcher.cs
with MIT License
from badamczewski
with MIT License
from badamczewski
private string CreateArgument(ulong methodAddress, ulong codeSize, replacedemblyInstruction instruction, InstructionArg arg, bool isLast, Core.Compilation.CompilationOptions options)
{
StringBuilder builder = new StringBuilder();
if (instruction.jumpDirection != JumpDirection.None)
{
var addressInArg = arg.Value.LastIndexOf(' ');
var value = arg.Value;
if (addressInArg != -1)
{
value = arg.Value.Substring(0, addressInArg);
}
var valueFormatted = ulong.Parse(value.Trim()).ToString("X");
builder.Append($"{valueFormatted}");
if (instruction.jumpDirection == JumpDirection.Out)
builder.Append($" ↷");
else if (instruction.jumpDirection == JumpDirection.Up)
builder.Append($" ⇡");
else if (instruction.jumpDirection == JumpDirection.Down)
builder.Append($" ⇣");
}
else
{
//Parse Value
var value = arg.Value.Trim();
var code = string.Empty;
for (int i = 0; i < value.Length; i++)
{
var c = value[i];
if (c == ']' || c == '[' || c == '+' || c == '-' || c == '*')
{
if (string.IsNullOrEmpty(code) == false)
{
builder.Append($"{code}");
code = string.Empty;
}
builder.Append($"{c}");
}
else
{
code += c;
}
}
if (string.IsNullOrEmpty(code) == false)
{
builder.Append($"{code}");
}
}
if (isLast == false)
{
builder.Append($", ");
}
return builder.ToString();
}
19
Source : Node.cs
with GNU General Public License v3.0
from BardMusicPlayer
with GNU General Public License v3.0
from BardMusicPlayer
void OnZeroTierEvent(IntPtr msgPtr)
{
zts_event_msg_t msg = (zts_event_msg_t)Marshal.PtrToStructure(msgPtr, typeof(zts_event_msg_t));
Event newEvent = null;
// Node
if (msg.node != IntPtr.Zero) {
zts_node_info_t details = (zts_node_info_t)Marshal.PtrToStructure(msg.node, typeof(zts_node_info_t));
newEvent = new Event();
newEvent.Code = msg.event_code;
_id = details.node_id;
_primaryPort = details.primary_port;
_secondaryPort = details.secondary_port;
_tertiaryPort = details.tertiary_port;
_versionMajor = details.ver_major;
_versionMinor = details.ver_minor;
_versionRev = details.ver_rev;
_isOnline = Convert.ToBoolean(zts_node_is_online());
if (msg.event_code == Constants.EVENT_NODE_UP) {
newEvent.Name = "EVENT_NODE_UP";
}
if (msg.event_code == Constants.EVENT_NODE_ONLINE) {
newEvent.Name = "EVENT_NODE_ONLINE";
}
if (msg.event_code == Constants.EVENT_NODE_OFFLINE) {
newEvent.Name = "EVENT_NODE_OFFLINE";
}
if (msg.event_code == Constants.EVENT_NODE_DOWN) {
newEvent.Name = "EVENT_NODE_DOWN";
}
if (msg.event_code == Constants.ZTS_EVENT_NODE_FATAL_ERROR) {
newEvent.Name = "EVENT_NODE_FATAL_ERROR";
}
}
// Network
if (msg.network != IntPtr.Zero) {
zts_net_info_t net_info = (zts_net_info_t)Marshal.PtrToStructure(msg.network, typeof(zts_net_info_t));
newEvent = new Event();
newEvent.Code = msg.event_code;
// Update network info as long as we aren't tearing down the network
if (msg.event_code != Constants.EVENT_NETWORK_DOWN) {
ulong networkId = net_info.net_id;
NetworkInfo ni = _networks.GetOrAdd(networkId, new NetworkInfo());
newEvent.NetworkInfo = ni;
newEvent.NetworkInfo.Id = net_info.net_id;
newEvent.NetworkInfo.MACAddress = net_info.mac;
newEvent.NetworkInfo.Name = System.Text.Encoding.UTF8.GetString(net_info.name);
newEvent.NetworkInfo.Status = net_info.status;
newEvent.NetworkInfo.Type = net_info.type;
newEvent.NetworkInfo.MTU = net_info.mtu;
newEvent.NetworkInfo.DHCP = net_info.dhcp;
newEvent.NetworkInfo.Bridge = Convert.ToBoolean(net_info.bridge);
newEvent.NetworkInfo.BroadcastEnabled = Convert.ToBoolean(net_info.broadcast_enabled);
zts_core_lock_obtain();
// Get replacedigned addresses
ConcurrentDictionary<string, IPAddress> newAddrsDict =
new ConcurrentDictionary<string, IPAddress>();
IntPtr addrBuffer = Marshal.AllocHGlobal(ZeroTier.Constants.INET6_ADDRSTRLEN);
int addr_count = zts_core_query_addr_count(networkId);
for (int idx = 0; idx < addr_count; idx++) {
zts_core_query_addr(networkId, idx, addrBuffer, ZeroTier.Constants.INET6_ADDRSTRLEN);
// Convert buffer to managed string
string str = Marshal.PtrToStringAnsi(addrBuffer);
IPAddress addr = IPAddress.Parse(str);
newAddrsDict[addr.ToString()] = addr;
}
// Update addresses in NetworkInfo object
// TODO: This update block works but could use a re-think, I think.
// Step 1. Remove addresses not present in new concurrent dict.
if (! ni._addrs.IsEmpty) {
foreach (string key in ni._addrs.Keys) {
if (! newAddrsDict.Keys.Contains(key)) {
ni._addrs.TryRemove(key, out _);
}
}
}
else {
ni._addrs = newAddrsDict;
}
// Step 2. Add addresses not present in existing concurrent dict.
foreach (string key in newAddrsDict.Keys) {
if (! ni._addrs.Keys.Contains(key)) {
ni._addrs[key] = newAddrsDict[key];
}
}
Marshal.FreeHGlobal(addrBuffer);
addrBuffer = IntPtr.Zero;
// Get managed routes
ConcurrentDictionary<string, RouteInfo> newRoutesDict =
new ConcurrentDictionary<string, RouteInfo>();
IntPtr targetBuffer = Marshal.AllocHGlobal(ZeroTier.Constants.INET6_ADDRSTRLEN);
IntPtr viaBuffer = Marshal.AllocHGlobal(ZeroTier.Constants.INET6_ADDRSTRLEN);
int route_count = zts_core_query_route_count(networkId);
ushort flags = 0, metric = 0;
for (int idx = 0; idx < route_count; idx++) {
zts_core_query_route(
networkId,
idx,
targetBuffer,
viaBuffer,
ZeroTier.Constants.INET6_ADDRSTRLEN,
ref flags,
ref metric);
// Convert buffer to managed string
try {
string targetStr = Marshal.PtrToStringAnsi(targetBuffer);
IPAddress targetAddr = IPAddress.Parse(targetStr);
string viaStr = Marshal.PtrToStringAnsi(viaBuffer);
IPAddress viaAddr = IPAddress.Parse(viaStr);
RouteInfo route = new RouteInfo(targetAddr, viaAddr, flags, metric);
// Add to NetworkInfo object
newRoutesDict[targetStr] = route;
}
catch {
Console.WriteLine("error while parsing route");
}
}
// TODO: This update block works but could use a re-think, I think.
// Step 1. Remove routes not present in new concurrent dict.
if (! ni._routes.IsEmpty) {
foreach (string key in ni._routes.Keys) {
if (! newRoutesDict.Keys.Contains(key)) {
ni._routes.TryRemove(key, out _);
}
}
}
else {
ni._routes = newRoutesDict;
}
// Step 2. Add routes not present in existing concurrent dict.
foreach (string key in newRoutesDict.Keys) {
if (! ni._routes.Keys.Contains(key)) {
ni._routes[key] = newRoutesDict[key];
}
}
Marshal.FreeHGlobal(targetBuffer);
Marshal.FreeHGlobal(viaBuffer);
targetBuffer = IntPtr.Zero;
viaBuffer = IntPtr.Zero;
// Get multicast subscriptions
zts_core_lock_release();
// Update synthetic "readiness" value
ni.transportReady = (route_count > 0) && (addr_count > 0) ? true : false;
} // EVENT_NETWORK_DOWN
if (msg.event_code == Constants.EVENT_NETWORK_NOT_FOUND) {
newEvent.Name = "EVENT_NETWORK_NOT_FOUND " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_REQ_CONFIG) {
newEvent.Name = "EVENT_NETWORK_REQ_CONFIG " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_ACCESS_DENIED) {
newEvent.Name = "EVENT_NETWORK_ACCESS_DENIED " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_READY_IP4) {
newEvent.Name = "EVENT_NETWORK_READY_IP4 " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_READY_IP6) {
newEvent.Name = "EVENT_NETWORK_READY_IP6 " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_DOWN) {
newEvent.Name = "EVENT_NETWORK_DOWN " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_CLIENT_TOO_OLD) {
newEvent.Name = "EVENT_NETWORK_CLIENT_TOO_OLD " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_REQ_CONFIG) {
newEvent.Name = "EVENT_NETWORK_REQ_CONFIG " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_OK) {
newEvent.Name = "EVENT_NETWORK_OK " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_ACCESS_DENIED) {
newEvent.Name = "EVENT_NETWORK_ACCESS_DENIED " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_READY_IP4_IP6) {
newEvent.Name = "EVENT_NETWORK_READY_IP4_IP6 " + net_info.net_id.ToString("x16");
}
if (msg.event_code == Constants.EVENT_NETWORK_UPDATE) {
newEvent.Name = "EVENT_NETWORK_UPDATE " + net_info.net_id.ToString("x16");
}
}
// Route
if (msg.route != IntPtr.Zero) {
zts_route_info_t route_info =
(zts_route_info_t)Marshal.PtrToStructure(msg.route, typeof(zts_route_info_t));
newEvent = new Event();
newEvent.Code = msg.event_code;
// newEvent.RouteInfo = default; // new RouteInfo();
if (msg.event_code == Constants.EVENT_ROUTE_ADDED) {
newEvent.Name = "EVENT_ROUTE_ADDED";
}
if (msg.event_code == Constants.EVENT_ROUTE_REMOVED) {
newEvent.Name = "EVENT_ROUTE_REMOVED";
}
}
// Peer
if (msg.peer != IntPtr.Zero) {
zts_peer_info_t peer_info = (zts_peer_info_t)Marshal.PtrToStructure(msg.peer, typeof(zts_peer_info_t));
newEvent = new Event();
newEvent.Code = msg.event_code;
// newEvent.PeerInfo = default; // new PeerInfo();
if (peer_info.role == Constants.PEER_ROLE_PLANET) {
newEvent.Name = "PEER_ROLE_PLANET";
}
if (msg.event_code == Constants.EVENT_PEER_DIRECT) {
newEvent.Name = "EVENT_PEER_DIRECT";
}
if (msg.event_code == Constants.EVENT_PEER_RELAY) {
newEvent.Name = "EVENT_PEER_RELAY";
}
// newEvent = new ZeroTier.Core.Event(msg.event_code,"EVENT_PEER_UNREACHABLE");
if (msg.event_code == Constants.EVENT_PEER_PATH_DISCOVERED) {
newEvent.Name = "EVENT_PEER_PATH_DISCOVERED";
}
if (msg.event_code == Constants.EVENT_PEER_PATH_DEAD) {
newEvent.Name = "EVENT_PEER_PATH_DEAD";
}
}
// Address
if (msg.addr != IntPtr.Zero) {
zts_addr_info_t unmanagedDetails =
(zts_addr_info_t)Marshal.PtrToStructure(msg.addr, typeof(zts_addr_info_t));
newEvent = new Event();
newEvent.Code = msg.event_code;
// newEvent.AddressInfo = default; // new AddressInfo();
if (msg.event_code == Constants.EVENT_ADDR_ADDED_IP4) {
newEvent.Name = "EVENT_ADDR_ADDED_IP4";
}
if (msg.event_code == Constants.EVENT_ADDR_ADDED_IP6) {
newEvent.Name = "EVENT_ADDR_ADDED_IP6";
}
if (msg.event_code == Constants.EVENT_ADDR_REMOVED_IP4) {
newEvent.Name = "EVENT_ADDR_REMOVED_IP4";
}
if (msg.event_code == Constants.EVENT_ADDR_REMOVED_IP6) {
newEvent.Name = "EVENT_ADDR_REMOVED_IP6";
}
}
// Storage
if (msg.cache != IntPtr.Zero) {
newEvent = new Event();
newEvent.Code = msg.event_code;
// newEvent.AddressInfo = default; // new AddressInfo();
if (msg.event_code == Constants.EVENT_STORE_IDENreplacedY_SECRET) {
newEvent.Name = "EVENT_STORE_IDENreplacedY_SECRET";
}
if (msg.event_code == Constants.EVENT_STORE_IDENreplacedY_PUBLIC) {
newEvent.Name = "EVENT_STORE_IDENreplacedY_PUBLIC";
}
if (msg.event_code == Constants.EVENT_STORE_PLANET) {
newEvent.Name = "EVENT_STORE_PLANET";
}
if (msg.event_code == Constants.EVENT_STORE_PEER) {
newEvent.Name = "EVENT_STORE_PEER";
}
if (msg.event_code == Constants.EVENT_STORE_NETWORK) {
newEvent.Name = "EVENT_STORE_NETWORK";
}
}
// Preplaced the converted Event to the managed callback (visible to user)
if (newEvent != null) {
_managedCallback(newEvent);
}
}
19
Source : MultiItemTests.cs
with GNU Affero General Public License v3.0
from berichan
with GNU Affero General Public License v3.0
from berichan
[Theory]
[InlineData("lucky cat", 131)]
[InlineData("(DIY recipe)", 0x00000295000016A2)]
[InlineData("Aran-knit sweater (White)", 7672)]
[InlineData("impish wings (Black)", 0x3464)]
public static void TestDuplicateVariation(string name, ulong itemValueParse)
{
var items = ItemParser.GereplacedemsFromUserInput(itemValueParse.ToString("X"), new DropBotConfig(), ItemDestination.PlayerDropped);
items.Count.Should().Be(1);
var currenreplacedem = items.ElementAt(0);
var multiItem = new MultiItem(new Item[1] { currenreplacedem });
var itemName = GameInfo.Strings.GereplacedemName(currenreplacedem);
itemName.Should().StartWith(name);
// variations
var remake = ItemRemakeUtil.GetRemakeIndex(currenreplacedem.ItemId);
if (remake > 0)
{
var info = ItemRemakeInfoData.List[remake];
var body = info.GetBodySummary(GameInfo.Strings);
var bodyVariations = body.Split(new string[2] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
int varCount = bodyVariations.Length;
if (!bodyVariations[0].StartsWith("0"))
varCount++;
multiItem.ItemArray.Items[0].ItemId.Should().Be(currenreplacedem.ItemId);
multiItem.ItemArray.Items[1].Count.Should().Be(1);
multiItem.ItemArray.Items[varCount].ItemId.Should().Be(currenreplacedem.ItemId);
multiItem.ItemArray.Items[varCount].Count.Should().Be(0);
foreach (var itm in multiItem.ItemArray.Items)
{
// No leaking replacedociated items
if (itm.IsNone)
continue;
var itmName = GameInfo.Strings.GereplacedemName(itm);
itemName.Should().Be(itmName);
}
}
// replacedociation
var replacedociated = GameInfo.Strings.GetreplacedociatedItems(currenreplacedem.ItemId, out var itemPrefix);
if (replacedociated.Count > 1 && currenreplacedem.ItemId != Item.DIYRecipe)
{
foreach (var asoc in multiItem.ItemArray.Items)
{
var asocName = GameInfo.Strings.GereplacedemName(asoc);
asocName.Should().EndWith(")");
}
}
// everything else
if (currenreplacedem.ItemId == Item.DIYRecipe)
foreach (var itm in multiItem.ItemArray.Items)
itm.ItemId.Should().Be(Item.DIYRecipe);
}
19
Source : Form1.cs
with MIT License
from berryelectronics
with MIT License
from berryelectronics
private void buttonGenerateIconCode_Click(object sender, EventArgs e)
{
UInt64 codeGenHeight = Convert.ToUInt64(tbCodeGenHeight.Value);
String codeGenName = tBCodeGenName.Text;
UInt64 codeGenStart = Convert.ToUInt64(tbStartPos.Value);
UInt64 codeGenWidth = Convert.ToUInt64(tbWidth.Text);
UInt64 codeGenEnd = codeGenStart + (codeGenHeight * codeGenWidth - 1);
codeGenHeight = codeGenHeight * 8;
String codeGenOutput = "";
// Example: { "Walk Animation Frame 1 (???)", "14", "28653", "28661", "24"},
codeGenOutput = "{ \"" + codeGenName + "\", \"" + codeGenWidth.ToString();
codeGenOutput += "\", \"" + codeGenStart.ToString("X") + "\", \"" + codeGenEnd.ToString("X");
codeGenOutput += "\", \"" + codeGenHeight.ToString() + "\"},";
tBCodeGenOutput.Text = codeGenOutput;
// Also copy to clipboard
Clipboard.SetText(codeGenOutput);
}
19
Source : MemoryAccessMeta.cs
with MIT License
from bryanperris
with MIT License
from bryanperris
public string ReadMeta()
{
m_StringBuilder.Clear();
if (m_IsWriteAccess)
m_StringBuilder.Append("Memory write access to ");
else
m_StringBuilder.Append("Memory read access to ");
m_StringBuilder.Append(m_RegionName);
m_StringBuilder.Append(": ");
m_StringBuilder.Append(m_Address.ToString("X8"));
if (m_Value != null)
{
m_StringBuilder.Append(" = ");
m_StringBuilder.Append(m_Value);
}
return m_StringBuilder.ToString();
}
19
Source : BasicBlock.cs
with MIT License
from bryanperris
with MIT License
from bryanperris
public override string ToString()
{
return Address.ToString("X8");
}
19
Source : RspVector.cs
with MIT License
from bryanperris
with MIT License
from bryanperris
public override string ToString() {
return m_ElementsPtr->PACKED_U64[1].ToString("X16") + m_ElementsPtr->PACKED_U64[0].ToString("X16");
}
19
Source : StackMonitor.cs
with MIT License
from bryanperris
with MIT License
from bryanperris
public String DumpStack()
{
StringBuilder sb = new StringBuilder();
// Make a copy
var copy = new Stack<ulong>(m_StackPointers);
for (int i = 0; i < copy.Count; i++)
{
sb.AppendLine(m_StackPointers.Pop().ToString("X8"));
}
return sb.ToString();
}
19
Source : BassTable.cs
with MIT License
from bryanperris
with MIT License
from bryanperris
protected void WriteBits(ulong data, int length)
{
var hexOffset = 16 - (length / 8 * 2);
DebugPrint("Writing out replacedembler bits: " + data.ToString("X16").Substring(hexOffset));
Func<int, ulong> setBits = n => {
/* Create a bit mask with the n least significant bits set */
return (1UL << n) - 1;
};
m_BitVal <<= length;
m_BitVal |= data & setBits(length);
m_BitPos += length;
while (m_BitPos >= 8) {
Write(m_BitVal);
m_BitVal >>= 8;
m_BitPos -= 8;
}
}
19
Source : TestablePJ64.cs
with MIT License
from bryanperris
with MIT License
from bryanperris
private static String L(ulong value)
{
return value.ToString("X16");
}
19
Source : ObscuredULong.cs
with GNU General Public License v3.0
from cc004
with GNU General Public License v3.0
from cc004
public string ToString(string JKDBJBLHONP) => this.InternalDecrypt().ToString(JKDBJBLHONP);
19
Source : WmiHelper.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
private void GetWin32PhysicalMemoryData()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(QueryPhysicalMemory);
ManagementObjectCollection objCol = searcher.Get();
try
{
UInt64 capacity = 0;
foreach (var o in objCol)
{
var mgtObject = (ManagementObject)o;
capacity += (UInt64)mgtObject["Capacity"];
}
_physicalMemory = (capacity / (1024 * 1024 * 1024)).ToString("#,##0") + "GB";
}
catch
{
_physicalMemory = "?";
}
}
19
Source : ThreadPoolAnalyzer.cs
with MIT License
from chrisnas
with MIT License
from chrisnas
public void RunDone()
{
_workItems = new Dictionary<string, WorkInfo>();
_workItemCount = 0;
_tasks = new Dictionary<string, WorkInfo>();
_taskCount = 0;
ClrMDHelper helper = new ClrMDHelper(_host.Session.Clr);
// The ThreadPool is keeping track of the pending work items into two different areas:
// - a global queue: stored by ThreadPoolWorkQueue instances of the ThreadPoolGlobals.workQueue static field
// - several per thread (TLS) local queues: stored in SparseArray<ThreadPoolWorkQueue+WorkStealingQueue> linked from ThreadPoolWorkQueue.allThreadQueues static fields
// both are using arrays of Task or QueueUserWorkItemCallback
//
// NOTE: don't show other thread pool related topics such as timer callbacks or wait objects
//
try
{
var heap = _host.Session.Clr.Heap;
var clr = _host.Session.Clr;
_host.WriteLine("global work item queue________________________________");
// look for the ThreadPoolGlobals.workQueue static field
ClrModule mscorlib = helper.GetMscorlib();
if (mscorlib == null)
return;
ClrType queueType = mscorlib.GetTypeByName("System.Threading.ThreadPoolGlobals");
if (queueType == null)
return;
ClrStaticField workQueueField = queueType.GetStaticFieldByName("workQueue");
if (workQueueField == null)
return;
// the CLR keeps one static instance per application domain
foreach (var appDomain in clr.AppDomains)
{
object workQueueValue = workQueueField.GetValue(appDomain);
ulong workQueueRef = (workQueueValue == null) ? 0L : (ulong)workQueueValue;
if (workQueueRef == 0)
continue;
// should be System.Threading.ThreadPoolWorkQueue
ClrType workQueueType = heap.GetObjectType(workQueueRef);
if (workQueueType == null)
continue;
if (workQueueType.Name != "System.Threading.ThreadPoolWorkQueue")
continue;
if (!DumpThreadPoolWorkQueue(workQueueType, workQueueRef))
{
_host.WriteLine("Impossible to dump thread pool work queue @ 0x" + workQueueRef.ToString("X"));
}
}
// look into the local stealing queues in each thread TLS
// hopefully, they are all stored in static (one per app domain) instance
// of ThreadPoolWorkQueue.SparseArray<ThreadPoolWorkQueue.WorkStealingQueue>
//
_host.WriteLine("\r\nlocal per thread work items_____________________________________");
try
{
queueType = mscorlib.GetTypeByName("System.Threading.ThreadPoolWorkQueue");
if (queueType == null)
return;
ClrStaticField threadQueuesField = queueType.GetStaticFieldByName("allThreadQueues");
if (threadQueuesField == null)
return;
foreach (ClrAppDomain domain in clr.AppDomains)
{
ulong? threadQueue = (ulong?)threadQueuesField.GetValue(domain);
if (!threadQueue.HasValue || threadQueue.Value == 0)
continue;
ClrType threadQueueType = heap.GetObjectType(threadQueue.Value);
if (threadQueueType == null)
continue;
var sparseArrayRef = _host.Session.GetFieldValue(threadQueue.Value, "m_array");
_host.Session.ForEach((ulong)sparseArrayRef, stealingQueue =>
{
if (stealingQueue != 0)
{
var arrayRef = _host.Session.GetFieldValue(stealingQueue, "m_array");
DumpThreadPoolWorkItems((ulong)arrayRef);
}
});
}
}
finally
{
// provide a summary sorted by count
// tasks first if any
if (_tasks.Values.Count > 0)
{
foreach (var item in _tasks.Values.OrderBy(wi => wi.Count))
{
_host.WriteLine(string.Format(" {0,4} Task {1}", item.Count.ToString(), item.Name));
}
_host.WriteLine(" ----");
_host.WriteLine(string.Format(" {0,4}\r\n", _taskCount.ToString()));
}
// then QueueUserWorkItem next if any
if (_workItems.Values.Count > 0)
{
foreach (var item in _workItems.Values.OrderBy(wi => wi.Count))
{
_host.WriteLine(string.Format(" {0,4} Work {1}", item.Count.ToString(), item.Name));
}
_host.WriteLine(" ----");
_host.WriteLine(string.Format(" {0,4}\r\n", _workItemCount.ToString()));
}
var threadPool = _host.Session.Clr.ThreadPool;
_host.WriteLine(string.Format(
"\r\nCPU = {0}% for {1} threads (#idle = {2} + #running = {3} | #dead = {4} | #max = {5})",
threadPool.CpuUtilization.ToString(),
threadPool.TotalThreads.ToString(),
threadPool.IdleThreads.ToString(),
threadPool.RunningThreads.ToString(),
_host.Session.Clr.Threads.Count(t => t.IsThreadpoolWorker && !t.IsThreadpoolCompletionPort && !t.IsAlive && !t.IsThreadpoolGate && !t.IsThreadpoolTimer && !t.IsThreadpoolWait).ToString(),
threadPool.MaxThreads.ToString()
));
// show the running worker threads
DumpRunningThreadpoolThreads(helper);
}
}
catch (Exception x)
{
_host.WriteLine(x.Message);
}
}
19
Source : ThreadPoolAnalyzer.cs
with MIT License
from chrisnas
with MIT License
from chrisnas
public void RunOriginal()
{
_workItems = new Dictionary<string, WorkInfo>();
_workItemCount = 0;
_tasks = new Dictionary<string, WorkInfo>();
_taskCount = 0;
try
{
// look into global thread pool queues
List<ulong> tpRefs = _host.Session.GetInstancesOf("System.Threading.ThreadPoolWorkQueue");
if (tpRefs == null)
{
_host.WriteLine("no ThreadPoolWorkQueue");
return;
}
int count = tpRefs.Count;
_host.WriteLine(count.ToString() + " global" + ((count > 1) ? " threadpools" : " threadpool"));
ClrType threadpoolWorkQueueType = _host.Session.ManagedHeap.GetTypeByName("System.Threading.ThreadPoolWorkQueue");
int currentTp = 1;
foreach (var tpRef in tpRefs)
{
_host.WriteLine("ThreadPool #" + currentTp.ToString() + " ______________________________________________");
if (!DumpThreadPoolWorkQueue(threadpoolWorkQueueType, tpRef))
{
_host.WriteLine("Impossible to dump thread pool work queue @ 0x" + tpRef.ToString("X"));
}
currentTp++;
}
// look into the local stealing queues in each thread TLS
// hopefully, they are all stored in static (one per app domain) instance
// of ThreadPoolWorkQueue.SparseArray<ThreadPoolWorkQueue.WorkStealingQueue>
//
_host.WriteLine("\r\nlocal per thread work items________________________________");
var instanceCount = _host.Session.ForEachInstancesOf("System.Threading.ThreadPoolWorkQueue+SparseArray<System.Threading.ThreadPoolWorkQueue+WorkStealingQueue>", sa =>
{
var sparseArrayRef = _host.Session.GetFieldValue(sa, "m_array");
_host.Session.ForEach((ulong)sparseArrayRef, stealingQueue =>
{
if (stealingQueue != 0)
{
var arrayRef = _host.Session.GetFieldValue(stealingQueue, "m_array");
DumpThreadPoolWorkItems((ulong)arrayRef);
}
});
});
if (instanceCount == 0)
{
_host.WriteLine("Impossible to find per thread work stealing queues :^(");
}
// provide a summary sorted by count
var threadPool = _host.Session.Clr.ThreadPool;
_host.WriteLine(string.Format(
"CPU = {0}% for {1} threads (#idle = {2} + #running = {3} | #dead = {4} | #max = {5})",
threadPool.CpuUtilization.ToString(),
threadPool.TotalThreads.ToString(),
threadPool.IdleThreads.ToString(),
threadPool.RunningThreads.ToString(),
_host.Session.Clr.Threads.Count(t => t.IsThreadpoolWorker && !t.IsThreadpoolCompletionPort && !t.IsAlive && !t.IsThreadpoolGate && !t.IsThreadpoolTimer && !t.IsThreadpoolWait).ToString(),
threadPool.MaxThreads.ToString()
));
_host.WriteLine("\r\n");
foreach (var item in _tasks.Values.OrderBy(wi => wi.Count))
{
_host.WriteLine(string.Format(" {0,4} Task {1}", item.Count.ToString(), item.Name));
}
_host.WriteLine(" ----");
_host.WriteLine(string.Format(" {0,4}\r\n", _taskCount.ToString()));
foreach (var item in _workItems.Values.OrderBy(wi => wi.Count))
{
_host.WriteLine(string.Format(" {0,4} Work {1}", item.Count.ToString(), item.Name));
}
_host.WriteLine(" ----");
_host.WriteLine(string.Format(" {0,4}\r\n", _workItemCount.ToString()));
}
catch (Exception x)
{
_host.WriteLine(x.Message);
}
}
19
Source : Program.cs
with MIT License
from chrisnas
with MIT License
from chrisnas
private static string GetTimerString(TimerInfo timer)
{
return string.Format(
"0x{0} @{1,8} ms every {2,8} ms | {3} ({4}) -> {5}",
timer.TimerQueueTimerAddress.ToString("X16"),
timer.DueTime.ToString(),
(timer.Period == 4294967295) ? " ------" : timer.Period.ToString(),
timer.StateAddress.ToString("X16"),
timer.StateTypeName,
timer.MethodName
);
}
19
Source : Program.cs
with MIT License
from chrisnas
with MIT License
from chrisnas
private static void ProcessDumpFile(string dumpFilename)
{
using (var target = Utils.GetTarget(dumpFilename))
{
ClrRuntime clr = target.ClrVersions[0].CreateRuntime();
Dictionary<string, TimerStat> stats = new Dictionary<string, TimerStat>(64);
int totalCount = 0;
foreach (var timer in EnumerateTimers(clr).OrderBy(t => t.Period))
{
totalCount++;
string line = string.Intern(GetTimerString(timer));
string key = string.Intern(string.Format(
"@{0,8} ms every {1,8} ms | {2} ({3}) -> {4}",
timer.DueTime.ToString(),
(timer.Period == 4294967295) ? " ------" : timer.Period.ToString(),
timer.StateAddress.ToString("X16"),
timer.StateTypeName,
timer.MethodName
));
TimerStat stat;
if (!stats.ContainsKey(key))
{
stat = new TimerStat()
{
Count = 0,
Line = line,
Period = timer.Period
};
stats[key] = stat;
}
else
{
stat = stats[key];
}
stat.Count = stat.Count + 1;
Console.WriteLine(line);
}
// create a summary
Console.WriteLine("\r\n " + totalCount.ToString() + " timers\r\n-----------------------------------------------");
foreach (var stat in stats.OrderBy(kvp => kvp.Value.Count))
{
Console.WriteLine(string.Format(
"{0,4} | {1}",
stat.Value.Count.ToString(),
stat.Value.Line
));
}
}
}
19
Source : GCMemoryWindow.xaml.cs
with MIT License
from chrisnas
with MIT License
from chrisnas
private void ShowSegments(IReadOnlyList<SegmentInfo> segments)
{
// gen0, 1, 2 and LOH
const int MaxGeneration = 4;
_segments = segments;
var sizeByGeneration = new ulong[MaxGeneration];
var segmentsGroupedByGeneration = new List<GenerationInSegment>[MaxGeneration];
for (int currentGeneration = 0; currentGeneration < segmentsGroupedByGeneration.Length; currentGeneration++)
{
segmentsGroupedByGeneration[currentGeneration] = new List<GenerationInSegment>();
}
ulong maxLength = 0;
for (int currentSegment = 0; currentSegment < segments.Count; currentSegment++)
{
var segment = segments[currentSegment];
foreach (var generation in segment.Generations.OrderBy(g => g.Start))
{
if (maxLength < generation.Length)
maxLength = generation.Length;
segmentsGroupedByGeneration[generation.Generation].Add(generation);
sizeByGeneration[generation.Generation] += generation.Length;
}
}
var itemsControls = new ItemsControl[MaxGeneration];
itemsControls[3] = icLoh;
itemsControls[2] = icGen2;
itemsControls[1] = icGen1;
itemsControls[0] = icGen0;
for (int currentGeneration = 0; currentGeneration < segmentsGroupedByGeneration.Length; currentGeneration++)
{
var segmentsModel = new List<SegmentModel>();
foreach (var segment in segmentsGroupedByGeneration[currentGeneration])
{
var model = new SegmentModel()
{
Generation = segment.Generation,
PinnedObjects = segment.PinnedObjects,
FreeBlocks = segment.FreeBlocks,
Start = segment.Start,
End = segment.End,
ControlWidth = new GridLength(100D * segment.Length / maxLength, GridUnitType.Star),
EmptyColumnWidth = new GridLength(100D - (100D * segment.Length / maxLength), GridUnitType.Star)
};
segmentsModel.Add(model);
}
itemsControls[currentGeneration].ItemsSource = segmentsModel;
}
xpGen0.Header = $"Gen 0 ({sizeByGeneration[0].ToString("N0")})";
xpGen1.Header = $"Gen 1 ({sizeByGeneration[1].ToString("N0")})";
xpGen2.Header = $"Gen 2 ({sizeByGeneration[2].ToString("N0")})";
xpLoh.Header = $"LOH ({sizeByGeneration[3].ToString("N0")})";
}
19
Source : DotNetReplacements.cs
with GNU General Public License v3.0
from coconauts
with GNU General Public License v3.0
from coconauts
public override string ToString () {
if (text == null) {
text = new System.Text.StringBuilder();
}
lock (text) {
text.Length = 0;
text.Append (_a.ToString("x16")).Append('-').Append(_b.ToString("x16"));
return text.ToString();
}
}
19
Source : Hex.cs
with MIT License
from colinvella
with MIT License
from colinvella
public static string Format(ulong value)
{
return "$" + value.ToString("X16");
}
19
Source : System_UInt64_Binding.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
static StackObject* ToString_7(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
{
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
StackObject* ptr_of_this_method;
StackObject* __ret = ILIntepreter.Minus(__esp, 2);
ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
System.String @format = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
__intp.Free(ptr_of_this_method);
ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
System.UInt64 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack);
var result_of_this_method = instance_of_this_method.ToString(@format);
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
}
19
Source : Hashtable.cs
with GNU General Public License v3.0
from Crauzer
with GNU General Public License v3.0
from Crauzer
public static string Get(ulong key)
{
if (_hashtable.ContainsKey(key))
{
return _hashtable[key];
}
else
{
return key.ToString("x16");
}
}
19
Source : Hashtable.cs
with GNU General Public License v3.0
from Crauzer
with GNU General Public License v3.0
from Crauzer
public static void Write(string location, Dictionary<ulong, string> hashtable)
{
using (StreamWriter sw = new StreamWriter(File.Create(location)))
{
foreach (KeyValuePair<ulong, string> hashPair in hashtable)
{
sw.WriteLine(string.Format("{0} {1}", hashPair.Key.ToString("X16"), hashPair.Value));
}
}
}
19
Source : SecureValueForm.cs
with MIT License
from Cuyler36
with MIT License
from Cuyler36
public void Set_Secure_NAND_Value(ulong value)
{
textBox1.Text = value.ToString("X16");
}
19
Source : CommonExtensions.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public static string ToHumanReadableFileSize(this ulong bytes)
{
// Determine the suffix and readable value
string suffix;
double readable;
if (bytes >= 0x1000000000000000) // Exabyte
{
suffix = "EB";
readable = bytes >> 50;
}
else if (bytes >= 0x4000000000000) // Petabyte
{
suffix = "PB";
readable = bytes >> 40;
}
else if (bytes >= 0x10000000000) // Terabyte
{
suffix = "TB";
readable = bytes >> 30;
}
else if (bytes >= 0x40000000) // Gigabyte
{
suffix = "GB";
readable = bytes >> 20;
}
else if (bytes >= 0x100000) // Megabyte
{
suffix = "MB";
readable = bytes >> 10;
}
else if (bytes >= 0x400) // Kilobyte
{
suffix = "KB";
readable = bytes;
}
else
{
return bytes.ToString("0 B"); // Byte
}
// Divide by 1024 to get fractional value
readable = readable / 1024;
// Return formatted number with suffix
return readable.ToString("0.## ") + suffix;
}
19
Source : CheatForm.cs
with MIT License
from DaanBanaan121
with MIT License
from DaanBanaan121
private void CheatForm_Load(object sender, EventArgs e)
{
// SET UP SIGSCANNER
Helpers.SigScanSharp SigScan = new Helpers.SigScanSharp(G.hProcess);
// GET BASE ADDRESS OF GAME PROCESS
IntPtr[] hMods = new IntPtr[1024];
var pModules = GCHandle.Alloc(hMods, GCHandleType.Pinned);
uint size = (uint)IntPtr.Size * 1024;
uint cbNeeded;
if (Win32.EnumProcessModules(G.hProcess, pModules.AddrOfPinnedObject(), size, out cbNeeded))
{
G.Memory = new Memory(G.hProcess, hMods[0]); // INITIALISE MEMORY CLreplaced
int cb = Marshal.SizeOf(typeof(Win32._MODULEINFO));
Win32._MODULEINFO modinfo;
Win32.GetModuleInformation(G.hProcess, hMods[0], out modinfo, cb);
// GET OFFSETS
if (SigScan.SelectModule(hMods[0]/*MAIN MODULE*/, modinfo.SizeOfImage))
{
long lTime = 0;
var GWorldAddress = (IntPtr)SigScan.FindPattern("48 8B 1D ? ? ? ? 74 40", out lTime);
var GWorldOffset = M.Read<uint>(GWorldAddress + 3) + 7;
var ppUWorld = (IntPtr)((ulong)GWorldAddress + GWorldOffset);
G.pUWorld = M.Read<IntPtr>(ppUWorld);
Console.WriteLine($"Found UWorld at 0x{((ulong)ppUWorld - (ulong)hMods[0]).ToString("x2")} - {lTime}ms");
var GNamesAddress = SigScan.FindPattern("48 89 1D ? ? ? ? 48 8B 5C 24 ? 48 83 C4 28 C3 48 8B 5C 24 ? 48 89 05 ? ? ? ? 48 83 C4 28 C3", out lTime);
var GNamesOffset = M.Read<uint>((IntPtr)GNamesAddress + 3);
GNamesAddress += GNamesOffset + 7;
Console.WriteLine($"Found GNames at 0x{(GNamesAddress - (ulong)hMods[0]).ToString("x2")} - {lTime}ms");
GNames namearray = M.Read<GNames>((IntPtr)GNamesAddress);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
G.Names = namearray.GetStaticArray().DumpNames();
stopwatch.Stop();
Console.WriteLine($"Dump GNames - {stopwatch.ElapsedMilliseconds}ms");
}
}
// NO NASTY MEMORY LEAKS HERE
pModules.Free();
new Thread(Cheat.EnreplacedyLoop).Start();
new Thread(Cheat.MainLoop).Start();
// SHOW OVERLAY
new OverlayForm().Show();
}
19
Source : ValueULongExtensions.cs
with MIT License
from DavidArayan
with MIT License
from DavidArayan
public static string HexString(this ulong value) {
return value.ToString("X");
}
19
Source : AssetRemappingJSON.cs
with MIT License
from derplayer
with MIT License
from derplayer
public Dictionary<string, string> GenerateRMPFilenames()
{
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (KeyValuePair<Location, Unique> pair in LocationMap)
{
string hash1 = pair.Value.ContHashContainer.ContHashMD5_2.ToString("x");
string hash2 = pair.Value.ContHashContainer.ContHashMD5_1.ToString("x");
string hash3 = pair.Value.ContHashContainer.ContHashMD5_4.ToString("x");
string hash4 = pair.Value.ContHashContainer.ContHashMD5_3.ToString("x");
string hash5 = pair.Value.ContHashTex.ToString("x");
string fileSize = pair.Value.FileSize.ToString();
string filename = String.Format(RMPFormat, hash1, hash2, hash3, hash4, hash5, fileSize);
string tmp = HashCollisionString.Substring((int)pair.Key.LocStrIdx);
if (tmp.IndexOf('!') > 0)
{
tmp = tmp.Substring(0, tmp.IndexOf('!'));
}
tmp = MurmurHash2Shenmue.GetFullFilename(tmp, false).Substring(1);
result.Add(tmp.Substring(0, tmp.Length - 9), filename);
/*
uint hash2_ = MurmurHash2Shenmue.GetFilenameHashPlain(filename);
string fFilename = MurmurHash2Shenmue.GetFullFilename(filename, hash2_);
uint hash1_ = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
Console.WriteLine("{0} => {1} LocHash: {2:X8} ({2}), FileSize: {3}, HashedFilename: {4} ({5:X8})",
tmp, filename, pair.Key.LocHash, pair.Value.FileSize, fFilename, hash1_);
*/
}
return result;
}
19
Source : PrimitiveExtensions.cs
with GNU General Public License v3.0
from ds5678
with GNU General Public License v3.0
from ds5678
public static string ToHexString(this ulong _this)
{
ulong reverse = (_this & 0x00000000000000FFUL) << 56 | (_this & 0x000000000000FF00UL) << 40 |
(_this & 0x0000000000FF0000UL) << 24 | (_this & 0x00000000FF000000UL) << 8 |
(_this & 0x000000FF00000000UL) >> 8 | (_this & 0x0000FF0000000000UL) >> 24 |
(_this & 0x00FF000000000000UL) >> 40 | (_this & 0xFF00000000000000UL) >> 56;
return reverse.ToString("x16");
}
19
Source : FingerPrintDictionary.cs
with Apache License 2.0
from eaglet2006
with Apache License 2.0
from eaglet2006
public override string ToString()
{
return _High.ToString("X16") + _Low.ToString("X16") + _StringLength.ToString("X8") + _Sum.ToString("X8");
}
19
Source : Device.cs
with GNU General Public License v3.0
from EEVblog
with GNU General Public License v3.0
from EEVblog
string ToMacAddress(ulong address)
{
var tempMac = address.ToString("X");
//tempMac is now 'E7A1F7842F17'
//string.Join(":", BitConverter.GetBytes(BluetoothAddress).Reverse().Select(b => b.ToString("X2"))).Substring(6);
var macAddress = macRegex.Replace(tempMac, REGEX_REPLACE);
return macAddress;
}
19
Source : Warnings.cs
with MIT License
from Erisa
with MIT License
from Erisa
public static string Pad(ulong id)
{
return id.ToString("D5");
}
19
Source : VirtualTexture.cs
with MIT License
from EverestAPI
with MIT License
from EverestAPI
private bool PreloadSizeFromPNG(Stream stream) {
using (BinaryReader reader = new BinaryReader(stream)) {
ulong magic = reader.ReadUInt64();
if (magic != 0x0A1A0A0D474E5089U) {
Logger.Log(LogLevel.Error, "vtex", $"Failed preloading PNG: Expected magic to be 0x0A1A0A0D474E5089, got 0x{magic.ToString("X16")} - {Path}");
return false;
}
uint length = reader.ReadUInt32();
if (length != 0x0D000000U) {
Logger.Log(LogLevel.Error, "vtex", $"Failed preloading PNG: Expected first chunk length to be 0x0D000000, got 0x{length.ToString("X8")} - {Path}");
return false;
}
uint chunk = reader.ReadUInt32();
if (chunk != 0x52444849U) {
Logger.Log(LogLevel.Error, "vtex", $"Failed preloading PNG: Expected IHDR marker 0x52444849, got 0x{chunk.ToString("X8")} - {Path}");
return false;
}
Width = SwapEndian(reader.ReadInt32());
Height = SwapEndian(reader.ReadInt32());
return true;
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from exelix11
with GNU General Public License v3.0
from exelix11
static void Main(string[] args)
{
//this disables selecting in the cmd window, an user can accidentally click on the window causing it to go to selection mode and freeze the process.
IntPtr consoleHandle = GetStdHandle(STD_INPUT_HANDLE);
uint consoleMode;
GetConsoleMode(consoleHandle, out consoleMode);
consoleMode &= ~ENABLE_QUICK_EDIT;
SetConsoleMode(consoleHandle, consoleMode);
Console.WriteLine("MakeEmu 1.1 --- https://github.com/exelix11/MakeEmu");
Console.WriteLine("A simple tool to flash sd cards for Atmosphère's emummc on Windows");
Console.WriteLine("");
Console.WriteLine("This tool, if misused, can easily corrupt disks and cause data loss.\nBy continuing you agree to use this program at your own risk.\n");
if (args.Length != 4)
{
Console.WriteLine("Usage:\nMakeEmu Boot0 Boot1 Rawnand.bin TargetDisk\nAvailable disks:");
System.IO.DriveInfo.GetDrives().ToList().ForEach(x =>
{
if (x.IsReady) Console.WriteLine($"{x.Name} : {x.VolumeLabel} {x.TotalSize} Bytes");
else Console.WriteLine($"{x.Name} : unknown filesystem");
});
Console.ReadKey();
return;
}
string Boot0 = args[0];
string Boot1 = args[1];
string RawNand = args[2];
string TargetDevice = args[3];
if (TargetDevice.Length == 1 && char.IsLetter(TargetDevice[0]))
{
Console.WriteLine($"Drive name \"{TargetDevice}\" is invalid, did you mean \"{TargetDevice}:\" ? ");
return;
}
{
//Check device info
GetDiskFreeSpace(TargetDevice, out int lpSectorsPerCluster, out int lpBytesPerSector, out _, out int lpTotalNumberOfClusters);
var TotalDiskSize = (UInt64)lpTotalNumberOfClusters * (UInt64)lpSectorsPerCluster * (UInt64)lpBytesPerSector;
if (TotalDiskSize == 0)
Console.WriteLine($"Warning: Windows reports the disk size to be 0, this is normal if {TargetDevice} does not have a valid filesystem.\n");
else if (TotalDiskSize < ExpectedFullBackupSize)
{
Console.WriteLine($"Warning: There seems to not be enough space for emunand, did you select the correct disk ?");
Console.WriteLine("Press enter to continue anyway but the process could fail.\n");
Console.ReadLine();
}
}
if (TargetDevice.EndsWith("\\") || TargetDevice.EndsWith("/"))
TargetDevice = TargetDevice.Substring(0, TargetDevice.Length - 1);
var disk = new Win32DiskAccess();
disk.Open(@"\\.\" + TargetDevice);
int SectorSize = 0;
{
var geometrySize = Marshal.SizeOf(typeof(DiskGeometryEx));
var geometryBlob = Marshal.AllocHGlobal(geometrySize);
uint numBytesRead = 0;
var success = NativeMethods.DeviceIoControl(disk._diskHandle, NativeMethods.IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, IntPtr.Zero,
0, geometryBlob, (uint)geometrySize, ref numBytesRead, IntPtr.Zero);
var geometry = (DiskGeometryEx)Marshal.PtrToStructure(geometryBlob, typeof(DiskGeometryEx));
if (success)
{
if (geometry.Geometry.BytesPerSector != 512)
Console.WriteLine($"Warning: the disk BytesPerSector value is not 512");
SectorSize = geometry.Geometry.BytesPerSector;
}
else
{
Console.WriteLine("ERROR: coulnd't get the sector size of the target device. Press enter to continue anyway...");
Console.ReadLine();
}
Marshal.FreeHGlobal(geometryBlob);
}
var searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_LogicalDiskToParreplacedion");
UInt64 ParreplacedionStartingAddress = 0;
foreach (var queryObj in searcher.Get())
{
if (queryObj["Dependent"].ToString().Contains($"DeviceID=\"{TargetDevice}\""))
ParreplacedionStartingAddress = (UInt64)queryObj["StartingAddress"];
}
if (ParreplacedionStartingAddress == 0)
{
Console.WriteLine("ERROR: Failed to get the parreplacedion start offset. Press enter to continue anyway...");
Console.ReadLine();
}
else
{
if (SectorSize == 0)
Console.WriteLine("Warning: couldn't calculate the emmc_sector value as the sector size returned 0, replaceduming it is 512: 0x" + (ParreplacedionStartingAddress / 512UL).ToString("X") + "\n");
else
Console.WriteLine("emummc_sector is 0x" + (ParreplacedionStartingAddress / (UInt64)SectorSize).ToString("X") );
Console.WriteLine($"(Parreplacedion starting offset is 0x{ParreplacedionStartingAddress.ToString("X")} bytes and the sector size is {SectorSize})\n");
}
if (!File.Exists(Boot0))
{
Console.WriteLine($"Error: couldn't find file {Boot0}");
return;
}
if (!File.Exists(Boot1))
{
Console.WriteLine($"Error: couldn't find file {Boot1}");
return;
}
if (!File.Exists(RawNand))
{
Console.WriteLine($"Error: couldn't find file {RawNand}");
return;
}
Int64 TotalSize = new FileInfo(Boot0).Length + new FileInfo(Boot1).Length + new FileInfo(RawNand).Length;
if ((UInt64)TotalSize != ExpectedFullBackupSize)
Console.WriteLine($"Warning: the total backup size is {TotalSize} bytes but {ExpectedFullBackupSize} is expected");
Console.WriteLine($"The total nand size is {TotalSize} and the target device is {TargetDevice}");
Console.WriteLine("Everything is ready, press enter to start....");
Console.ReadLine();
const int ReadBlockSize = 1024 * 1204 * 16; //16MB
void WriteFileToDisk(string fileName)
{
Console.WriteLine("Writing file: " + fileName);
Console.Write("0%");
int ReadCount = 0;
byte[] Block = new byte[ReadBlockSize];
FileStream ifStream = new FileStream(fileName, FileMode.Open);
while ((ReadCount = ifStream.Read(Block, 0, ReadBlockSize)) > 0)
{
disk.Write(Block, ReadCount, out int WriteCount);
if (WriteCount != ReadCount)
{
Console.WriteLine("\nError while writing\n");
disk.Close();
return;
}
var Percent = (int)((float)ifStream.Position / ifStream.Length * 100);
Console.SetCursorPosition(0, Console.CursorTop);
Console.Write(Percent + "%");
}
Console.WriteLine(" ---- Done !");
}
Console.WriteLine("\n");
WriteFileToDisk(Boot0);
WriteFileToDisk(Boot1);
WriteFileToDisk(RawNand);
disk.Close();
Console.WriteLine("Completed !");
Console.ReadLine();
}
19
Source : Client.cs
with MIT License
from EZForever
with MIT License
from EZForever
public string OepToString(UInt64 oep)
{
return "0x" + oep.ToString(this.bits == 64 ? "x16" : "x8");
}
19
Source : NumberExtensions.cs
with MIT License
from Facepunch
with MIT License
from Facepunch
public static string FormatBytes<T>( this T input, bool shortFormat = false ) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
{
ulong i = (ulong) Convert.ChangeType( input, typeof( ulong ) );
double readable = (double)i;
string suffix;
if ( i >= 0x1000000000000000 ) // Exabyte
{
suffix = "eb";
readable = (double)( i >> 50 );
}
else if ( i >= 0x4000000000000 ) // Petabyte
{
suffix = "pb";
readable = (double)( i >> 40 );
}
else if ( i >= 0x10000000000 ) // Terabyte
{
suffix = "tb";
readable = (double)( i >> 30 );
}
else if ( i >= 0x40000000 ) // Gigabyte
{
suffix = "gb";
readable = (double)( i >> 20 );
}
else if ( i >= 0x100000 ) // Megabyte
{
suffix = "mb";
readable = (double)( i >> 10 );
}
else if ( i >= 0x400 ) // Kilobyte
{
suffix = "kb";
readable = (double)i;
}
else
{
return i.ToString( "0b" ); // Byte
}
readable /= 1024;
return readable.ToString( shortFormat ? "0" : "0.00" ) + suffix;
}
19
Source : ConstEnumGenerator.cs
with GNU Lesser General Public License v3.0
from falahati
with GNU Lesser General Public License v3.0
from falahati
private string GetEnumValuereplacedtring(object value)
{
var t = value.GetType();
if (t == typeof(uint))
{
return ((uint) value).ToString("X");
}
if (t == typeof(int))
{
return ((int) value).ToString("X");
}
if (t == typeof(ushort))
{
return ((ushort) value).ToString("X");
}
if (t == typeof(short))
{
return ((short) value).ToString("X");
}
if (t == typeof(ulong))
{
return ((ulong) value).ToString("X");
}
if (t == typeof(long))
{
return ((long) value).ToString("X");
}
if (t == typeof(byte))
{
return ((uint) value).ToString("X");
}
if (t == typeof(string))
{
return value as string;
}
return null;
}
19
Source : Program.cs
with MIT License
from FICTURE7
with MIT License
from FICTURE7
public static void HookBlock(Emulator emu, ulong address, int size, object userToken)
{
Console.WriteLine($">>> Tracing basic block at 0x{address.ToString("x2")}, block size = 0x{size.ToString("x2")}");
}
19
Source : Program.cs
with MIT License
from FICTURE7
with MIT License
from FICTURE7
public static void HookCode(Emulator emu, ulong address, int size, object userToken)
{
Console.WriteLine($">>> Tracing instruction at 0x{address.ToString("x2")}, instruction size = 0x{size.ToString("x2")}");
}
19
Source : Program.cs
with MIT License
from FICTURE7
with MIT License
from FICTURE7
private static void BlockHook(Emulator emulator, ulong address, int size, object userToken)
{
Console.WriteLine($">>> Tracing basic block at 0x{address.ToString("x2")}, block size = 0x{size.ToString("x2")}");
}
19
Source : Program.cs
with MIT License
from FICTURE7
with MIT License
from FICTURE7
private static void CodeHook(Emulator emulator, ulong address, int size, object userToken)
{
Console.WriteLine($">>> Tracing instruction at 0x{address.ToString("x2")}, instruction size = 0x{size.ToString("x2")}");
}
See More Examples