ntapi | Rust FFI bindings for Native API | Wrapper library

 by   MSxDOS Rust Version: Current License: Apache-2.0

kandi X-RAY | ntapi Summary

kandi X-RAY | ntapi Summary

ntapi is a Rust library typically used in Utilities, Wrapper applications. ntapi has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Rust FFI bindings for Native API. Mostly based on Process Hacker phnt headers as the most complete source of bindings to be found. The comments there also contain useful information on how to use specific things.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ntapi has a low active ecosystem.
              It has 77 star(s) with 21 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 4 open issues and 5 have been closed. On average issues are closed in 146 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of ntapi is current.

            kandi-Quality Quality

              ntapi has no bugs reported.

            kandi-Security Security

              ntapi has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              ntapi is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              ntapi releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ntapi
            Get all kandi verified functions for this library.

            ntapi Key Features

            No Key Features are available at this moment for ntapi.

            ntapi Examples and Code Snippets

            No Code Snippets are available at this moment for ntapi.

            Community Discussions

            QUESTION

            C++ help to understand syntax of low level code
            Asked 2021-Jan-07 at 17:12

            I was reading some code and found really hard to understand this:

            extern "C" NTSYSAPI NTSTATUS NTAPI ObReferenceObjectByName

            Here some real code:

            ...

            ANSWER

            Answered 2021-Jan-07 at 17:12

            There's only one return type, NTSTATUS, which is an enumeration. The others are modifiers on the function call, for example NTAPI resolves to __stdcall, which modifies how the function is called by the compiler, and NTSYSAPI resolves to declspec(dllimport), which marks the function as a library import.

            Also this has nothing to do with SAL.

            Source https://stackoverflow.com/questions/65616875

            QUESTION

            Using DeviceIoControl from C# code always returns empty output buffer
            Asked 2020-Dec-05 at 15:58

            I have a driver, which I want to use from my C# client app. The issue here is that my output buffer is always empty (0). When I use this driver from C code - everything works like a charm, so I think the issue is in my client C# code.

            Extern is defined as below:

            ...

            ANSWER

            Answered 2020-Dec-05 at 15:58

            First - I had to compile in x64. Second - had to allocate memory for pBuffer

            Below is a working example

            Source https://stackoverflow.com/questions/65088820

            QUESTION

            Cast shellcode inside function pointer
            Asked 2020-Nov-15 at 18:36

            I am trying to perform a system call on 32-bit, but there is an issue.

            I originally had a naked function as my stub and used inline assembly, but when I tried to turn it into shellcode, despite it being a 1-to-1 copy of the naked function (When looking at it in Visual Studio's disassembly), it does not function (Access Violation Executing NULL).

            It worked perfectly with the naked function, by the way.

            Here is the shellcode I wrote:

            ...

            ANSWER

            Answered 2020-Nov-15 at 18:36

            As noted by Micheal Petch, the shellcode was wrong. I only missed one byte (0x0C) that should be 0xC0.

            If anyone will ever attempt something so stupid and useless like I did, double-check your shellcode first!

            Source https://stackoverflow.com/questions/64846269

            QUESTION

            _WIN32_WINNT Not defined
            Asked 2020-Aug-27 at 20:19

            I had a problem with using winternl.h, I was using some of the datatypes out of there and have sucessfully compiled it for x64 without any problems. However I made some changes and now for some reason its failing to compile, through debugging I've found that the reason seems to be down to _WIN32_WINNT not being defined at all which causes winternl.h to not define any types. It was specifically this that was causing the problem with the PEB struct

            ...

            ANSWER

            Answered 2020-Aug-27 at 20:19

            _WIN32_WINNT comes from the include file , so in order to fix the error you are seeing:

            In the file throwing the error, change this:

            Source https://stackoverflow.com/questions/63622291

            QUESTION

            Memory allocation issues using NTAllocateVirtualMemory and GetProcAddress not working
            Asked 2020-Jun-18 at 16:03

            I am trying to write a little program which uses NTAllocateVirtualMemory and GetProcAddress instead of VirtualAlloc.

            This is what I have currently:

            ...

            ANSWER

            Answered 2020-Jun-18 at 09:53

            Since your actual problem is to hide from anti-virus, I would suggest to use a static buffer.

            Make data sections executable(in Visual Studio)

            Specify Project->Properties->Linker->Specify Section Attributes.

            For uninitialized data

            uninitialized is still zero initialized

            /* global or static*/ char buf[20000];

            specify .bss,RWE

            (which is probably what you need)

            For initialized data

            /* global or static*/ char buf[20000]{1};

            specify .data,RWE

            Both

            specify Linker->Command Line->Additional Options as /SECTION:.bss,RWE /SECTION:.data,RWE

            Source https://stackoverflow.com/questions/62444773

            QUESTION

            Allocating memory in specific Windows DLL module
            Asked 2020-May-15 at 22:38

            I want to allocate some memory inside a specific module of a process instead of the process in general. The following Windows C++ code can allocate memory inside a process given its process id:

            ...

            ANSWER

            Answered 2020-May-15 at 22:38

            I want to allocate some memory inside a specific module

            You cannot do this, when a module is mapped it's memory is allocated. You can't allocate memory inside the module, the module exists inside it's allocated pages and no where else. Any allocated pages will be outside of the module.

            Alternatively if you want to use memory which is already allocated but is not used, this called a code cave. It's typically an area of memory inside a module which is filled with zeros. So you can scan for a code cave by finding a certain length of redundant zeros inside the module and then you can write to that memory.

            This is done frequently and is especially useful if the page has the execute bit set as you won't have to change any permissions which could be deemed risky.

            This is also done frequently in injectors which use "scatter mapping" where it only uses these code caves to inject code.

            Source https://stackoverflow.com/questions/55772133

            QUESTION

            Unhandled exception thrown: read access violation error when accessing dos header of DLL
            Asked 2020-May-07 at 03:39

            I am trying to access the dos header of a DLL PE file. I am getting the address of the IMAGE_DOS_HEADER from the PEB of my process. I am getting the address by accessing the PEB, then accessing the LDR and then scanning the InMemoryOrderModuleList until I find the DLL I want to access (on this case the kernel32.DLL), and use the dllbase to convert it to IMAGE_DOS_HEADER. After getting the DLL base I am getting the following error :

            ...

            ANSWER

            Answered 2020-May-07 at 03:39

            And your currentitem_InMemoryOrderModuleList is just a pointer to LIST_ENTRY. And this LIST_ENTRY is a InMemoryOrderLinks field in LDR_DATA_TABLE_ENTRY. You can adjust pointer to point to enclosing structure before using.

            Refer to "PEB (Process Environment Block) invalid DllBase address", "CONTAINING_RECORD" (Which returns the base address of an instance of a structure given the type of the structure and the address of a field within the containing structure.).

            The following code works for me. You can have a try:

            Source https://stackoverflow.com/questions/61639086

            QUESTION

            Calling NtCreateProcessEx fails without exception
            Asked 2020-Apr-04 at 06:11

            I want to call NtCreateProcessEx, But i get no exception and error and nothing happens. Also i don't want to use CreateProcess. My intention is to create and run a process from a file with this specific function.

            This what i have tried so far:

            ...

            ANSWER

            Answered 2020-Mar-31 at 07:53

            First of all, the 3rd parameter is a pointer to the OBJECT_ATTRIBUTES:

            Source https://stackoverflow.com/questions/60899305

            QUESTION

            NativeAPI Suspend process
            Asked 2020-Feb-13 at 18:54

            I try to stop some process, I use NativeAPI from ntdll. I wrote some C code, It works:

            ...

            ANSWER

            Answered 2020-Feb-13 at 18:54
            ;Process pause
            pauseProc proc pid:dword
            
            push pid
            push 0
            push PROCESS_ALL_ACCESS
            call OpenProcess@12
            
            .IF eax == 0
                PUSH MB_ICONERROR
                PUSH 0
                PUSH offset errorOpenProccess
                PUSH 0
                CALL MessageBoxA@16 
            .ENDIF
            
            mov processHandle, eax
            
            push offset NtModuleNameWStr
            call GetModuleHandleW@4
            
            ; call GetLastError
            
            .IF eax == 0
                PUSH MB_ICONERROR
                PUSH 0
                PUSH offset errorGetModuleHandle
                PUSH 0
                CALL MessageBoxA@16 
            .ENDIF
            
            push offset NtSuspendProcessAStr
            push eax
            call GetProcAddress@8
            
            .IF eax == 0
                PUSH MB_ICONERROR
                PUSH 0
                PUSH offset errorGetProcAddress
                PUSH 0
                CALL MessageBoxA@16 
            .ENDIF
            
            ;Call NtSuspendProcess from dll
            push processHandle
            call eax
            
            push processHandle
            call CloseHandle@4
            
            ; pfnNtSuspendProcess
            ret
            pauseProc endp
            

            Source https://stackoverflow.com/questions/60208565

            QUESTION

            Why do the hooking libraries work only occasionally for API Calls in Windows 10?
            Asked 2019-Jul-23 at 23:40

            I used multiple Hooking libraries e.g. Microsoft Detours Express, Mhook, etc. to hook NtWriteVirtualMemory API calls. I wrote following code to hook the API:

            ...

            ANSWER

            Answered 2017-May-02 at 13:39

            Simple: Your DLL is loaded only into process that load user32.dll. Some process do. Other don't. The one you speak of doesn't:

            It's not that the hooking doesn't work. Your DLL isn't even loaded.

            Also, hooking in thread attach is probably not what you want, and unhooking in thread detach is almost certainly not what you want.

            Source https://stackoverflow.com/questions/43707340

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ntapi

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            Always the latest stable. Some features require a nightly compiler.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/MSxDOS/ntapi.git

          • CLI

            gh repo clone MSxDOS/ntapi

          • sshUrl

            git@github.com:MSxDOS/ntapi.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Wrapper Libraries

            jna

            by java-native-access

            node-serialport

            by serialport

            lunchy

            by eddiezane

            ReLinker

            by KeepSafe

            pyserial

            by pyserial