Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
😊
Hi

NaniteFactory

😊
Hi
View GitHub Profile
@NaniteFactory
NaniteFactory / get_own_process_address.go
Last active October 5, 2018 07:05
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 / dllmain.go
Last active March 15, 2024 16:35
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 / 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 / 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 / 나나스킨수정하기.md
Last active September 16, 2018 06:03
나나스킨 배너 로고 수정

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

스킨 편집 - HTML

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

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

- 
@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 / messagebox.go
Last active April 24, 2024 17:58
Win32 API MessageBox() in Golang
import (
"syscall"
"unsafe"
)
// MessageBox of Win32 API.
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
@NaniteFactory
NaniteFactory / traverse_unmarshalled_json.go
Created August 5, 2018 09:18
Traverse / iterate over an unmarshalled JSON data in Golang.
package main
import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
)
@NaniteFactory
NaniteFactory / unescape_unicode_sequences_in_json.go
Created July 29, 2018 11:39
Converting escaped forms of unicode characters in JSON into unescaped UTF-8 characters.
package main
import (
"encoding/json"
"fmt"
"strconv"
"strings"
)
func _UnescapeUnicodeCharactersInJSON(_jsonRaw json.RawMessage) (json.RawMessage, error) {
@NaniteFactory
NaniteFactory / hello_world_in_different_languages.go
Created July 29, 2018 11:32
"Hello, world." in 8 different languages for testers.
package main
import (
"fmt"
)
type HelloWorld struct {
Arabic string
English string
Greek string