main ad7d3c05d3c1 cached
4 files
3.4 KB
1.0k tokens
2 symbols
1 requests
Download .txt
Repository: ben0x539/totally-safe-transmute
Branch: main
Commit: ad7d3c05d3c1
Files: 4
Total size: 3.4 KB

Directory structure:
gitextract_qtmj_ci_/

├── .github/
│   └── workflows/
│       └── ci.yml
├── .gitignore
├── Cargo.toml
└── src/
    └── lib.rs

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/ci.yml
================================================
name: test it
on: [push]
jobs:
  ubuntu:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - uses: actions-rs/cargo@v1
        with:
          command: test
  windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - uses: actions-rs/cargo@v1
        with:
          command: test

================================================
FILE: .gitignore
================================================
/target


================================================
FILE: Cargo.toml
================================================
[package]
name = "totally-safe-transmute"
version = "0.0.3"
authors = ["Benjamin Herr <ben@0x539.de>"]
edition = "2018"
description = "I'm sure it's fine."
license = "AGPL-3.0-or-later"
repository = "https://github.com/ben0x539/totally-safe-transmute"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]


================================================
FILE: src/lib.rs
================================================
#![forbid(unsafe_code)]

pub fn totally_safe_transmute<T, U>(v: T) -> U {
    #[repr(C)]
    enum E<T, U> {
        T(T),
        #[allow(dead_code)] U(U),
    }
    let v = E::T(v);

    #[cfg(target_os = "linux")]
    {
        use std::{io::{self, Write, Seek}, fs};

        let mut f = fs::OpenOptions::new()
            .write(true)
            .open("/proc/self/mem").expect("welp");

        f.seek(io::SeekFrom::Start(&v as *const _ as u64)).expect("oof");
        f.write(&[1]).expect("darn");
    }

    #[cfg(target_os = "windows")]
    {
        use std::{env, process, fs};
        let p = env::temp_dir().join("random-collision-free-name-I1G3qPvXTU4RvRML.ps1");
        fs::write(&p, r#"
            Param (
                [int]$parentPid,
                [UInt64]$tagAddress
            )

            Add-Type -TypeDefinition @"
                using System;
                using System.Runtime.InteropServices;

                public static class Helper {
                    const int PROCESS_VM_WRITE = 0x0020;
                    const int PROCESS_VM_OPERATION = 0x0008;

                    [DllImport("kernel32.dll")]
                    public static extern IntPtr OpenProcess(int dwDesiredAccess,
                        bool bInheritHandle, int dwProcessId);

                    [DllImport("kernel32.dll", SetLastError = true)]
                    public static extern bool WriteProcessMemory(IntPtr hProcess, ulong lpBaseAddress,
                        byte[] lpBuffer, int dwSize, IntPtr lpNumberOfBytesWritten);
                    
                    public static void Run(int parentPid, ulong tagAddress) {
                        IntPtr handle = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION, false, parentPid);
                        WriteProcessMemory(handle, tagAddress, new byte[]{1}, 1, (IntPtr) 0);
                    }
                }
            "@

            [Helper]::Run($parentPid, $tagAddress) 
        "#.replace("\n            ", "\n")).unwrap();
        let i = process::id();
        if !process::Command::new("powershell")
            .args(&[&p.to_str().unwrap(), &i.to_string()[..], &(&v as *const _ as u64).to_string()])
            .spawn()
            .unwrap()
            .wait()
            .unwrap()
            .success() { panic!("install linux lol"); }
        fs::remove_file(&p).unwrap();
    }

    if let E::U(v) = v {
        return v;
    }

    panic!("rip");
}

#[test]
fn main() {
    let v: Vec<u8> = b"foo".to_vec();
    let v: String = totally_safe_transmute(v);
    assert_eq!(&v, "foo");
}
Download .txt
gitextract_qtmj_ci_/

├── .github/
│   └── workflows/
│       └── ci.yml
├── .gitignore
├── Cargo.toml
└── src/
    └── lib.rs
Download .txt
SYMBOL INDEX (2 symbols across 1 files)

FILE: src/lib.rs
  function totally_safe_transmute (line 3) | pub fn totally_safe_transmute<T, U>(v: T) -> U {
  function main (line 77) | fn main() {
Condensed preview — 4 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
  {
    "path": ".github/workflows/ci.yml",
    "chars": 522,
    "preview": "name: test it\r\non: [push]\r\njobs:\r\n  ubuntu:\r\n    runs-on: ubuntu-latest\r\n    steps:\r\n      - uses: actions/checkout@v3\r\n"
  },
  {
    "path": ".gitignore",
    "chars": 8,
    "preview": "/target\n"
  },
  {
    "path": "Cargo.toml",
    "chars": 366,
    "preview": "[package]\nname = \"totally-safe-transmute\"\nversion = \"0.0.3\"\nauthors = [\"Benjamin Herr <ben@0x539.de>\"]\nedition = \"2018\"\n"
  },
  {
    "path": "src/lib.rs",
    "chars": 2585,
    "preview": "#![forbid(unsafe_code)]\n\npub fn totally_safe_transmute<T, U>(v: T) -> U {\n    #[repr(C)]\n    enum E<T, U> {\n        T(T)"
  }
]

About this extraction

This page contains the full source code of the ben0x539/totally-safe-transmute GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 4 files (3.4 KB), approximately 1.0k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!