Skip to content

Instantly share code, notes, and snippets.

@lab313ru
lab313ru / mark_20k.py
Created December 10, 2018 16:37
Thunder Force 3 mark data
table = 0x20000
item_size = 3 * 4
table_end = Dword(table + 2) + table
items = (table_end - table + 2) // item_size
print 'Items count = %d' % items
for i in xrange(items):
item_addr = table + 2 + item_size * i
import sys
import struct
def calc_crc(data):
crc = 0
for i in xrange(0x200, 0x40000, 2):
w = struct.unpack_from('>H', data, i)[0]
crc = (crc + w) & 0xFFFF
@lab313ru
lab313ru / off_fixer.py
Created November 23, 2018 08:36
offset_fixer for struct offsets in code
# sega
OpOffEx(0x6560, 0, REF_OFF32, -1, 0, -4)
@lab313ru
lab313ru / rnc_list_mark.py
Created November 4, 2018 14:55
Mark RNC Propack data by list
with open('rnc_list.txt', 'r') as f:
lines = f.readlines()
for line in lines:
line = line.rstrip()
# RNC archive found: 0x01aea8 (010054/017280 bytes)
offset = int(line[19:19+8].replace('0x', ''), 16)
csize = int(line[29:29+6])
@lab313ru
lab313ru / quackshot_20_offsets.py
Created October 20, 2018 17:10
QuackShot Starring Donald Duck search $20 offsets
PATTERN = '? 7C ? ? ? ? 00 20'
ea = 0
old = list()
while True:
ea = FindBinary(ea, SEARCH_DOWN, PATTERN)
if ea == BADADDR:
break
@lab313ru
lab313ru / find_smd_palette.py
Last active November 18, 2020 01:02
Script that searches for sequences that look like Sega Mega Drive / Genesis palettes
from os import path
PAL_MASK_L = 0xF1
PAL_MASK_R = 0x11
PAL_SIZE = 16 * 2
PAL_THRESHOLD = 10
def find_palette(data, count=4):
l = len(data)
for seg_ea in Segments():
for ea in Heads(seg_ea, get_segm_end(seg_ea)):
if is_code(get_full_flags(ea)):
n = 0
while n < 6:
t = get_operand_type(ea, n)
if (t == -1):
break
#include <Windows.h>
#include <ida.hpp>
#include <kernwin.hpp>
#include <diskio.hpp>
#include <regex>
#include "ida_fd.h"
#include "sysdeps.h"
#include "memory.h"
@lab313ru
lab313ru / get_data_offsets.lua
Last active April 12, 2016 20:02
SMD Jungle Book RNC Addresses logger
require "binio"
local caddr, daddr, log
os.execute("mkdir dumps_dir")
logpath = "dumps_dir\\data.log"
dumppath = "dumps_dir\\dump_%06X.bin"
local START_ADDR_1 = 0x1C6DEE
local END_ADDR_1 = 0x1C6F4A