Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
😊
Hi

NaniteFactory

😊
Hi
View GitHub Profile
@NaniteFactory
NaniteFactory / hacking_unexported_member.go
Created August 19, 2018 18:59
A hacky way to access an unexported field (a private member) of a struct from an external package.
// Hack an unexported (private) member of a struct.
// ptrToTargetStruct - a ptr to that struct.
// member - name of an unexported field.
func Hack(ptrToTargetStruct interface{}, member string) *TYPE_MEMBER {
return *(**TYPE_MEMBER)(unsafe.Pointer(reflect.Indirect(reflect.ValueOf(ptrToTargetStruct)).FieldByName(member).UnsafeAddr()))
}
//
// type TARGET struct {
// privateMemer *TYPE_MEMBER
// }
@NaniteFactory
NaniteFactory / 나나스킨수정하기.md
Last active September 16, 2018 06:03
나나스킨 배너 로고 수정

나나스킨v4에서 카테고리별 배너 로고 만들기

스킨 편집 - HTML

배너 로고 아이디를 확인해 주세요. (크롬에서 대문 우클릭하고 검사 누르시면 나옵니다.)

아이디는 임의로 수정해도 좋지만 다른 태그에서 이 이름(아이디)이 식별자로 쓰인다는 점에 주의하세요.

- 
@NaniteFactory
NaniteFactory / http-proxy.go
Created September 15, 2018 11:42 — forked from fabrizioc1/http-proxy.go
Http proxy server in Go
package main
import (
"fmt"
"io"
"log"
"net/http"
)
type _ReqRes struct {
@NaniteFactory
NaniteFactory / messagebox.c
Created September 25, 2018 15:20
MessageBox Win32 API
MessageBoxW(
NULL,
(LPCWSTR)L"Resource not available\nDo you want to try again?",
(LPCWSTR)L"Account Details 1",
MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
);
@NaniteFactory
NaniteFactory / dllmain.go
Last active February 21, 2025 23:33
An implementation example of DllMain() entrypoint with Golang. $ go build --buildmode=c-shared -o my.dll && rundll32.exe my.dll Test
package main
//#include "dllmain.h"
import "C"
@NaniteFactory
NaniteFactory / get_own_process_address.go
Last active May 21, 2025 02:27
A way to get 'Windows process module (.exe) handle' of process itself in Golang.
package main
import "syscall"
func main() {
// equivalent to (HANDLE)GetModuleHandle(NULL); in C
handle, _, _ := syscall.Syscall(
syscall.NewLazyDLL("kernel32.dll").NewProc("GetModuleHandleW").Addr(),
1, 0, 0, 0,
@NaniteFactory
NaniteFactory / lpcwstr.go
Last active September 21, 2023 00:12 — forked from icholy/lpcwstr.go
Convert the UTF16 Wide String (WSTR) from/to plain Go string.
package lpcwstr
// #include <windows.h>
// #include <wchar.h>
// #include <WinNT.h>
import "C"
import (
"unicode/utf16"
"unsafe"
@NaniteFactory
NaniteFactory / invalid_address.go
Created October 20, 2018 15:27
Suggesting ways to handle invalid addresses in Golang.
package main
import (
"errors"
"log"
"unsafe"
)
func foo1() (err error) {
defer func() {
@NaniteFactory
NaniteFactory / c_function_hook_x64.go
Last active February 11, 2025 16:23
API hook in Golang.
package main
import (
"log"
"syscall"
"unsafe"
"github.com/nanitefactory/gominhook" // In order to use this package you need to have MinHook.x64.dll in your system.
)
@NaniteFactory
NaniteFactory / imageToColors.go
Created December 13, 2018 06:37
Get a single dimensional color.Color list (array) from an image.Image and vice versa.
func imageToColors(img image.Image) []color.Color {
rect := img.Bounds()
width := rect.Dx()
height := rect.Dy()
xFrom := rect.Min.X
xTo := rect.Max.X
yFrom := rect.Max.Y - 1
yTo := rect.Min.Y - 1
ret := make([]color.Color, width*height)