All Projects → JustasMasiulis → Inline_syscall

JustasMasiulis / Inline_syscall

Licence: apache-2.0
Inline syscalls made easy for windows on clang

Programming Languages

assembly
5116 projects
cpp17
186 projects

Projects that are alternatives of or similar to Inline syscall

execmon
Advanced process execution monitoring utility for linux (procmon like)
Stars: ✭ 77 (-66.81%)
Mutual labels:  hooks, syscalls
Befa Library
High-level library for executable binary file analysis
Stars: ✭ 12 (-94.83%)
Mutual labels:  static-analysis, library
Binee
Binee: binary emulation environment
Stars: ✭ 408 (+75.86%)
Mutual labels:  static-analysis, hooks
Ideas
Ideas for protecting C/C++
Stars: ✭ 37 (-84.05%)
Mutual labels:  syscalls, obfuscation
Lazy importer
library for importing functions from dlls in a hidden, reverse engineer unfriendly way
Stars: ✭ 544 (+134.48%)
Mutual labels:  static-analysis, obfuscation
Onednn
oneAPI Deep Neural Network Library (oneDNN)
Stars: ✭ 2,600 (+1020.69%)
Mutual labels:  x64, library
Stdlib
✨ Standard library for JavaScript and Node.js. ✨
Stars: ✭ 2,749 (+1084.91%)
Mutual labels:  library
Use Position
🌍 React hook usePosition() for fetching and following a browser geolocation
Stars: ✭ 230 (-0.86%)
Mutual labels:  hooks
Slideimageview
Simple and convenient library that allows you to slide images through a view.
Stars: ✭ 227 (-2.16%)
Mutual labels:  library
Permissionsswiftui
A SwiftUI package to beautifully display and handle permissions.
Stars: ✭ 220 (-5.17%)
Mutual labels:  library
Revive
🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
Stars: ✭ 3,139 (+1253.02%)
Mutual labels:  static-analysis
Use Expo
Complementary hooks for Expo
Stars: ✭ 233 (+0.43%)
Mutual labels:  hooks
Saml2
SimpleSAMLphp low-level SAML2 PHP library
Stars: ✭ 229 (-1.29%)
Mutual labels:  library
Php Parser
A PHP parser written in PHP
Stars: ✭ 15,101 (+6409.05%)
Mutual labels:  static-analysis
Reel Search
🔍 RAMReel is a UI controller that allows you to choose options from a list. Swift UI library made by @Ramotion
Stars: ✭ 2,533 (+991.81%)
Mutual labels:  library
Juice
Juice inlines CSS stylesheets into your HTML source.
Stars: ✭ 2,683 (+1056.47%)
Mutual labels:  inline
Ringbuf
Lock-free ring buffer (MPSC)
Stars: ✭ 227 (-2.16%)
Mutual labels:  library
Torchdata
PyTorch dataset extended with map, cache etc. (tensorflow.data like)
Stars: ✭ 226 (-2.59%)
Mutual labels:  library
Srs Librtmp
The client library srs-librtmp of SRS(https://github.com/ossrs/srs)
Stars: ✭ 228 (-1.72%)
Mutual labels:  library
Printooth
A well documented, high-level Android interface that makes printing via bluetooth printers easier
Stars: ✭ 231 (-0.43%)
Mutual labels:  library

inline_syscall

Header only library that allows you to generate direct syscall instructions in an optimized, inlineable and easy to use manner.

How to use

All you have to do is copy over the header files and call the initialization function init_syscalls_list before using the INLINE_SYSCALL(function_pointer) and INLINE_SYSCALL_T(function_type) macros.

// This header contains the initialization function.
// If you already initialized, inline_syscall.hpp contains all you need.
#include "inline_syscall/include/in_memory_init.hpp"

// Needs to be called once at startup before INLINE_SYSCALL is used.
jm::init_syscalls_list();

// Usage of the main macro INLINE_SYSCALL
void* allocation = nullptr;
SIZE_T size      = 0x1000;
NTSTATUS status  = INLINE_SYSCALL(NtAllocateVirtualMemory)((HANDLE)-1, &allocation, 0, &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);

What code does it generate

As one of the main goals of this library is to be as optimized as possible here is the output of an optimized build.

mov qword ptr [rsp+30h], 0                  ; void* allocation = nullptr
mov qword ptr [rsp+28h], 1000h              ; SIZE_T size      = 0x1000;
mov eax, dword ptr [entry (07FF683157004h)] ; syscall id is loaded
lea rdx, [rsp+30h]                          ; BaseAddress     = &allocation
lea r9, [rsp+28h]                           ; RegionSize      = &size
mov r10, 0FFFFFFFFFFFFFFFFh                 ; ProcessHandle   = -1
xor r8d,r8d                                 ; ZeroBits        = 0
sub rsp,40h                                 ; preparing stack
mov qword ptr [type],3000h                  ; AllocationType  = MEM_RESERVE | MEM_COMMIT
mov qword ptr [protect], 4                  ; Protect         = PAGE_READWRITE
syscall                                     ; syscall instruction itself
add rsp,40h                                 ; restoring stack

FAQ

  • Q: What are the main uses of this? A: Obfuscation and hook avoidance.
  • Q: Why would I use this over some other library? A: The code this generates can be inlined and it is optimized for every single parameter count as much as possible.
  • Q: Why can't this work on MSVC? A: MSVC doesn't support GCC style inline assembly which can be properly optimized and worked on by compiler.
  • Q: Why can't this work on GCC? A: Contrary to MSVC, GCC is too good at optimizing inline assembly and as such breaks my code that tries to be somewhat generic.

Creating your own initialization function

This library enables you to create your own custom initialization routines that are more resilent against missing syscalls or acquire syscall ids in some other way.

JM_INLINE_SYSCALL_ENTRY_TYPE can be defined with your own syscall entry type that needs to be constructible from a hash. By default syscall_entry_small is used, but syscall_entry_full is also shipped.

If you want to use the provided INLINE_SYSCALL macro you will need to use the provided jm::hash function.

To acquire the start of syscall entries you need to call jm::syscall_entries() and iterate untill you hit a zero entry.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].