Skip to content

Instantly share code, notes, and snippets.

View retep998's full-sized avatar
🐇
Very fluffy

Peter Atashian retep998

🐇
Very fluffy
  • Massachusetts, USA
View GitHub Profile
@retep998
retep998 / a.rs
Last active April 15, 2019 22:45
#![crate_type = "dylib"]
pub const FOO: &str = "FOO";
pub static BAR: &str = "BAR";
[package]
name = "masstest"
version = "0.1.0"
authors = ["Peter"]
[profile.release]
lto = true
[dependencies]
advapi32-sys = "0.2.0"
@retep998
retep998 / Cargo.toml
Last active May 31, 2017 09:58
winapi-rs invalid handle in union
[package]
name = "handletest"
version = "0.1.0"
authors = ["Peter Atashian <[email protected]>"]
[dependencies.winapi]
git = "https://github.com/retep998/winapi-rs"
branch = "dev"
features = ["minwinbase", "minwindef", "processthreadsapi", "winbase", "winnt"]
> cargo rustc --features everything -- -Ztime-passes
Compiling winapi v0.3.0-alpha.0 (file:///C:/Users/Peter/Code/winapi-rs)
time: 0.469; rss: 66MB parsing
time: 0.000; rss: 66MB recursion limit
time: 0.000; rss: 66MB crate injection
time: 0.000; rss: 66MB plugin loading
time: 0.000; rss: 66MB plugin registration
time: 1.858; rss: 140MB expansion
time: 0.000; rss: 140MB maybe building test harness
time: 0.023; rss: 140MB maybe creating a macro crate
@retep998
retep998 / sizes.md
Created March 9, 2017 15:29
Sizes of functions in naive hello world with rustc main.rs -O -g -Cpanic=abort -Clto
Name Size
std__panicking__default_hook____closure__ 000025E4
std__panicking__rust_panic_with_hook 00000E60
main 000008FB
std__io__Write__write_fmt____impl____write_str_std__io__stdio__StdoutLock_ 000008C5
core__fmt__Formatter__pad_integral 000005B4
std__io__error____impl____fmt 0000056C
core__fmt____impl____fmt_0 00000438
core__fmt__Formatter__pad 00000437
@retep998
retep998 / blah.md
Created November 25, 2016 04:52
winapi DST requirements

Need to be able to add dynamically sized arrays as the last field of a type.

#[repr(C)] struct Foo {
    blah: Blah,
    cbSize: DWORD,
    array: [SomeType; N], // This field should be dynamically sized.
}

The user must be able to specify a value for N when creating such a type, but there must only be one such type, so that FFI functions can easily take a *const Foo or *mut Foo.

Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file cdylib gnu.dll
File Type: DLL
Section contains the following exports for cdylib.dll
@retep998
retep998 / families.md
Created October 18, 2016 13:34
What winapi needs to have better version/feature selection

There are 5 winapi families:

  1. WINAPI_FAMILY_PC_APP
  2. WINAPI_FAMILY_PHONE_APP
  3. WINAPI_FAMILY_SYSTEM
  4. WINAPI_FAMILY_SERVER
  5. WINAPI_FAMILY_DESKTOP_APP
  • A crate that depends on winapi should specify the set of winapi families that it supports.
#include <iostream>
using namespace std;
struct Bar {
~Bar() {
cout << "C++ destructor is firing" << endl;
}
};
extern "C" {
#include <iostream>
using namespace std;
extern "C" {
void bar() {
cout << "C++ throwing an exception" << endl;
throw 273;
}
void foo();
}