Skip to content

Instantly share code, notes, and snippets.

@jzebedee
jzebedee / gist:cff3a1e00669364821fd
Last active August 29, 2015 14:03
Talkin' bout ESP structure
class Record : IEnumerable<Record> {
public byte[] ID;
public uint Size;
private List<Record> _children = new List();
public Record(some data source) {
ID = read ID;
Size = read Size;
_children = read children;
var strTest = "The quick brown fox jumps over the lazy dog";
var bufTest = Encoding.Default.GetBytes(strTest);
using (var msBufTest = new MemoryStream(bufTest))
{
var compressedBytes = Zlib.Compress(msBufTest);
using (var msCompressedBytes = new MemoryStream(compressedBytes))
{
var decompressedBytes = Zlib.Decompress(msCompressedBytes, (uint)compressedBytes.Length);
var strDecompressed = Encoding.Default.GetString(decompressedBytes);
@jzebedee
jzebedee / gist:51625c37d8e1e6da3c84
Created July 22, 2014 15:04
old/new Write64 IL diff
Text Compare
Produced: 7/22/2014 10:02:39 AM
Mode: All
Left file: C:\Users\\Desktop\old_Write64.txt Right file: C:\Users\\Desktop\new_Write64.txt
1 .method private hidebysig static = 1 .method private hidebysig static
2 void WriteInt64 ( 2 void WriteInt64 (
3 int64 'value', 3 int64 'value',
4 uint8[] buf, 4 uint8[] buf,
5 int32 offset 5 int32 offset
@jzebedee
jzebedee / gist:d96d1f585508b8ec3660
Created July 22, 2014 15:18
old/new Write64 JIT
Text Compare
Produced: 7/22/2014 10:17:01 AM
Mode: All
Left file: C:\Users\\Desktop\old_Write64_JIT.txt
Right file: C:\Users\\Desktop\new_Write64_JIT.txt
<> 1 if (value < 0)
1 00007FFC28EE46B0 mov dword ptr [rsp+18h],r8d 2 00007FFC28EE48C0 mov dword ptr [rsp+18h],r8d
2 00007FFC28EE46B5 mov qword ptr [rsp+10h],rdx 3 00007FFC28EE48C5 mov qword ptr [rsp+10h],rdx
3 00007FFC28EE46BA mov qword ptr [rsp+8],rcx 4 00007FFC28EE48CA mov qword ptr [rsp+8],rcx
@jzebedee
jzebedee / gist:926cd0ad1805939180be
Created July 22, 2014 15:19
old/new Write64 JIT loop
Text Compare
Produced: 7/22/2014 10:14:10 AM
Mode: All
Left file: C:\Users\\Desktop\old_Write64_JIT_loop.txt
Right file: C:\Users\\Desktop\new_Write64_JIT_loop.txt
1 for (int byteIndex = 0; byteIndex < 8; byteIndex++) <> 1 for (int i = -1; ++i < 8; value >>= 8)
2 00007FFC28EE471D mov dword ptr [rsp+28h],0 2 00007FFC28EE4911 mov dword ptr [rsp+20h],0FFFFFFFFh
3 00007FFC28EE4725 jmp 00007FFC28EE4825 3 00007FFC28EE4919 jmp 00007FFC28EE4972
4 {
@jzebedee
jzebedee / gist:f5f13c68c022643cc11a
Last active August 29, 2015 14:04
WriteInt64 benchmark winners
//winner x64
private static void WriteInt64E(long y, byte[] buf, int offset)
{
if (y < 0)
{
y = -y;
buf[offset] = (byte)y;
buf[offset + 1] = (byte)(y >>= 8);
buf[offset + 2] = (byte)(y >>= 8);
private T ReadEnum<T>(int size)
{
switch (size)
{
case 1:
return (T)Enum.ToObject(typeof(T), reader.ReadByte());
case 2:
return (T)Enum.ToObject(typeof(T), reader.ReadInt16());
case 4:
return (T)Enum.ToObject(typeof(T), reader.ReadInt32());
Value = field.GetValue(this);
IOType = valueType = field.FieldType;
if (Value is Enum)
IOType = enumType = Enum.GetUnderlyingType(valueType);
else
enumType = null;
if (IOType == typeof(float))
writer.Write((float)(object)Value);
@jzebedee
jzebedee / gist:dfc0907fb65c534143f1
Created August 29, 2014 21:05
plagiarized from a great book
a
----
static void Main(string[] args)
{
int a = 13;
int b = 14;
int c = a + b;
Console.WriteLine(c);
@jzebedee
jzebedee / gist:abdb1b530a0c2ff71be3
Created December 1, 2014 08:26
Subnormality issue

This has the issue:

<a href="http://www.viruscomix.com/findingjebus.html"><br>
	<img style="border: 0px solid ; width: 632px; height: 150px; position: absolute; z-index: 1; top: 171px; left: 7px;" alt="" src="jad2.jpg">
</a>

This doesn't have the issue: