Skip to content

Instantly share code, notes, and snippets.

View hackpascal's full-sized avatar

Weijie Gao hackpascal

View GitHub Profile
@hackpascal
hackpascal / embde-binary-file-using-gnu-as.S
Last active October 14, 2018 11:46
Embed a binary file into an object file which can be linked into a program and referenced by other source codes
.align 2
.section ".rodata.data_start", "a"
.globl data_start
.type data_start, @object
data_start:
.incbin "data.bin"
.equ _data_size, . - data_start
.size data_start, _data_size
@hackpascal
hackpascal / txt
Created April 9, 2018 15:22
coap draft
https://tools.ietf.org/id/draft-ietf-core-coap-03.html
@hackpascal
hackpascal / 0001-uclibc-0.9.33.2-add-lexra-support-for-mips-string-funcs.patch
Created December 17, 2017 14:38
Patch to uCLibc-0.9.33.2 for Lexra processors
--- uClibc-0.9.33.2.orig/libc/string/mips/memcpy.S
+++ uClibc-0.9.33.2/libc/string/mips/memcpy.S
@@ -167,10 +167,19 @@ ENTRY (memcpy)
andi t1, 0x3 # a0/a1 are aligned, but are we
beq t1, zero, L(chk8w) # starting in the middle of a word?
subu a2, t1
+#ifndef __mlexra
LWHI t0, 0(a1) # Yes we are... take care of that
addu a1, t1
SWHI t0, 0(a0)
@hackpascal
hackpascal / 0001-gcc-4.8.4-add-lexra-support.patch
Created December 17, 2017 14:37
Patch to gcc-4.8.4 for Lexra processors
--- gcc-4.8.4.orig/gcc/config/mips/mips.c
+++ gcc-4.8.4/gcc/config/mips/mips.c
@@ -7062,6 +7062,8 @@ mips_block_move_straight (rtx dest, rtx
if (MEM_ALIGN (src) == BITS_PER_WORD / 2
&& MEM_ALIGN (dest) == BITS_PER_WORD / 2)
bits = BITS_PER_WORD / 2;
+ else if (TARGET_LEXRA || TARGET_RLX)
+ bits = MIN (MEM_ALIGN (src), MEM_ALIGN (dest));
else
bits = BITS_PER_WORD;
@hackpascal
hackpascal / 0001-binutils-2.24-add-lexra-support.patch
Created December 17, 2017 14:35
Patch to binutils-2.24 for Lexra processors (LX4180/RLX4181/...)
--- binutils-2.24.orig/bfd/bfd-in2.h
+++ binutils-2.24/bfd/bfd-in2.h
@@ -1938,6 +1938,12 @@ enum bfd_architecture
#define bfd_mach_mipsisa64 64
#define bfd_mach_mipsisa64r2 65
#define bfd_mach_mips_micromips 96
+#define bfd_mach_mips4180 4180
+#define bfd_mach_mips4181 4181
+#define bfd_mach_mips4281 4281
+#define bfd_mach_mips5181 5181
@hackpascal
hackpascal / seh.cc
Created July 10, 2017 12:40 — forked from kikairoya/seh.cc
SEH for gcc (working)
#include <stdio.h>
#include <windows.h>
#include <excpt.h>
#include <functional>
#pragma GCC optimize ("no-omit-frame-pointer")
//#define SEH_NO_CALL_DESTRUCTORS
#define SEH_ENABLE_TRACE
@hackpascal
hackpascal / debuggerdetect.c
Created April 15, 2017 09:50
简单的检测调试器的方法
#include <Windows.h>
#include <winternl.h>
extern "C"
__declspec(dllimport) NTSTATUS WINAPI NtSetInformationThread(
_In_ HANDLE ThreadHandle,
_In_ THREADINFOCLASS ThreadInformationClass,
_In_ PVOID ThreadInformation,
_In_ ULONG ThreadInformationLength
@hackpascal
hackpascal / ueoffactivate.c
Created April 15, 2017 08:46
UltraEdit 强制离线激活
#include <Windows.h>
#include <locale.h>
typedef void (WINAPI *PFNSWITCHTOTHISWINDOW) (HWND, BOOL);
int _tmain(int argc, _TCHAR* argv[])
{
HWND hWindow, hButton;
DWORD dwButtonId, dwStyle;
HMODULE hModule;
@hackpascal
hackpascal / win32mmap.c
Created March 26, 2017 13:00
获取进程的内存映射表
int main()
{
SYSTEM_INFO si;
GetSystemInfo(&si);
char *pMin = (char*)si.lpMinimumApplicationAddress;
char *pMax = (char*)si.lpMaximumApplicationAddress;
for (char* pAddress = pMin; pAddress<pMax; /*Empty*/)
{
MEMORY_BASIC_INFORMATION mbi;