Skip to content

Instantly share code, notes, and snippets.

View byteandahalf's full-sized avatar

Byteandahalf byteandahalf

View GitHub Profile
@byteandahalf
byteandahalf / demangle.txt
Last active March 23, 2020 17:11
How to demangle C++
Let's say we have this mangled symbol: _ZN5Class8functionEiifb10OtherClass
To demangle this, we start by removing the _Z (I'm not sure what this means)
N means that the following is the class name (There is no N is classless functions)
Next is the length of the class name (in this case 5), followed by the class name (Class)
Class::
Now we have the length of the function name (8 here) and then the function name (function)
Class::function
@byteandahalf
byteandahalf / Redstone Renderer.cpp
Created December 20, 2014 19:45
Code for rendering Redstone dust in Minecraft Pocket Edition
bool TileTessellator::tessellateRedstoneTileInWorld(RedstoneTile* tile, int x, int y, int z, TilePos const& pos, TileSource* tilesource) {
Tessellator* tessellator = tessellator_inst;
int data = (int) tilesource->getData(x, y, z);
// implement my own Texture system because of issues with MCPE's normal TextureUVCoordinateSet
RendererTexture* cross = new RendererTexture(0.0625F, 0.0937F, 0.5F, 0.5625F, 16, 16); // Cross texture
RendererTexture* line = new RendererTexture(0.125F, 0.1562F, 0.5F, 0.5625F, 16, 16); // line texture
RendererTexture* cross_overlay = new RendererTexture(0.0938F, 0.125F, 0.5F, 0.5625F, 16, 16); // cross overlay
RendererTexture* line_overlay = new RendererTexture(0.1563F, 0.1875F, 0.5F, 0.5625F, 16, 16); // line overlay
@byteandahalf
byteandahalf / symbols.txt
Last active August 15, 2016 12:44
symbols for 0.14.3
This file has been truncated, but you can view the full file.
AABB::AABB(Vec3 const&,Vec3 const&) .text 0000000000617BD4 00000096 00000010 FFFFFFFFFFFFFFF0 R
AABB::AABB(Vec3 const&,float) .text 0000000000617D94 0000003A 00000018 FFFFFFFFFFFFFFF8 R
AABB::AABB(float,float,float,float,float,float) .text 0000000000617B48 00000088 00000000 0000000C RT .
AABB::AABB(void) .text 0000000000617B28 0000001E 00000004 00000000 RT .
AABB::centerAt(Vec3 const&) .text 0000000000619658 0000007A 00000020 FFFFFFFFFFFFFFF0 RT .
AABB::clip(Vec3 const&,Vec3 const&) .text 0000000000619748 00000736 00000080 FFFFFFFFFFFFFFD8 RT .
AABB::clipXCollide(AABB const&,float) .text 0000000000618720 000000B0 RT .
AABB::clipYCollide(AABB const&,float) .text 00000000006187D0 000000B0 RT .
AABB::clipZCollide(AABB const&,float) .text 0000000000618880 000000B0 RT .
AABB::cloneMove(Vec3 const&) .text 00000000006186B8 00000068 00000020 FFFFFFFFFFFFFFF8 RT .
@byteandahalf
byteandahalf / mcpe_symbolicate_arm64.idc
Created July 29, 2016 01:16
Adds some symbols to IDA for MCPE iOS 0.15.2
#include <idc.idc>
static symbol(addr, sym) {
MakeFunction(addr, BADADDR);
if(MakeNameEx(addr, sym, SN_NOWARN)) return;
auto i;
for(i = 0; i < 999; i++) if(MakeNameEx(addr, form("%s_%d", sym, i), SN_NOWARN)) return;
}
static main() {
@byteandahalf
byteandahalf / Entity.h
Last active June 22, 2016 14:46
Entity header for MCPE 0.14.3
#pragma once
#include <string>
#include <memory>
#include <vector>
#include "../phys/Vec3.h"
class BlockSource;
class Level;
@byteandahalf
byteandahalf / LevelRenderer.h
Last active June 17, 2016 17:21
Some LevelRenderer functions that I decompiled by hand.
void LevelRenderer::_buildSkyMesh()
{
Tessellator& tessellator = Tessellator::instance;
tessellator.begin(mce::PrimitiveMode::MODE_2, 12);
tessellator.color(Color::BLACK);
tessellator.vertex(0.0F, 128.0F, 0.0F);
double x = 1.0;
double z = 0.0;
double f = Math::TAU * 0.1;
@byteandahalf
byteandahalf / Item.h
Last active February 20, 2016 17:36
Item header for 0.14.0
#pragma once
#include <string>
#include <memory>
class TextureUVCoordinateSet;
struct SeedItemComponent;
class FoodItemComponent;
class Block;
class CreativeItemCategory;
@byteandahalf
byteandahalf / Block.h
Last active February 20, 2016 06:04
Block header for MCPE 0.14.0
#pragma once
#include <string>
#include <vector>
#include "minecraftpe/client/renderer/texture/TextureUVCoordinateSet.h"
#include "minecraftpe/client/renderer/renderer/Color.h"
#include "minecraftpe/world/phys/AABB.h"
struct Material;
@byteandahalf
byteandahalf / tiny_hook.cpp
Last active February 19, 2016 07:17
My totally working attempt at hooking 8 byte functions
#include "sys/mman.h"
void tiny_hook(uint32_t* addr, uint32_t hook) {
bool thumb = (uint32_t)addr & 1;
if(thumb)
addr = (uint32_t*) ((uint32_t) addr - 1);
mprotect(addr, 9, PROT_READ | PROT_WRITE);
*addr = (uint32_t) (thumb)? 0xF000F8DF : 0xE51FF008; // LDR PC, [PC] on Thumb and LDR PC, [PC, #-8] on ARM.
*(addr + 1) = hook;
mprotect(addr, 9, PROT_READ | PROT_EXEC);
@byteandahalf
byteandahalf / customblocksnippet.cpp
Last active February 7, 2016 13:41
Add a custom block to Minecraft Windows 10 Edition (not complete code)
static uintptr_t** mBlocks = (uintptr_t**) (((uint8_t*)baseAddr) + 0xA75750);
static TextureUVCoordinateSet myCustomTexture{0.0F,0.0F,0.0625F,0.0625F,16,16,1,1};
TextureUVCoordinateSet& customGetTexture()
{
return myCustomTexture;
}
uint32_t customGetColor()
{