Giter Club home page Giter Club logo

ntapi's People

Contributors

3fault avatar alovchin91 avatar bdbai avatar mati865 avatar mrelectrify avatar msxdos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ntapi's Issues

Incorrect PEB type for x64

According to https://docs.microsoft.com/en-us/windows/win32/api/Winternl/ns-winternl-peb the peb for 64bit applications differ, from that of 32-bit applications.
There are 2 peb descriptions on that page. One on the top, and one on the bottom.

This can actually be observed in cmd.exe.
With the current PEB structure I am reading 0 as the LDR address. After (copying and) inserting a dummy u32, to have padding, I read a potentially more correct LDR address.

EDIT: Sorry for the many title changes. I can't think straight rn. apparently.

Add (more) x64 types

By types, I mean mostly these:

  • LDR_DATA_TABLE_ENTRY
  • PEB_LDR_DATA
  • PEB
  • PROCESS_BASIC_INFORMATION

Right now, there are Platform independent x86 types and Platform dependent types, but no Platform independent x64 types.

For the time being, I just copied the existing definitions, and modified them slightly.
I copied the Macros, that cannot be imported, for the time being.

I need those types, because I am building a dll injector, that will support injecting into a x64 process, from a x86 injector.
I am reading the PEB, to get the base address, of kernel32.dll.

Replace winapi with windows-sys?

I was updating mio to use windows-sys instead of winapi as windows-sys covers most of Windows API surface and most importantly is maintained and updated frequently as opposed to winapi, but this crate still provides types and functions not available in the windows-sys crate which is to be expected, however since it relies on winapi internally we'll be pulling in 2 versions of windows bindings, and in some cases need to transmute between the "same" type, so just wanted to open this issue to begin a discussion about whether this is something that would be acceptable to this project.

failed to compile `spl-token-cli v2.4.0`

I came across this issue while attempting to install spl-token-cli, and I've invested a considerable amount of time into debugging. Regrettably, I've been unable to resolve the errors on my own. I kindly request assistance from anyone who might be able to offer guidance on this matter at your earliest convenience.

"""error[E0793]: reference to packed field is unaligned
--> C:\Users\hp.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52
|
2783 | *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

error[E0793]: reference to packed field is unaligned
--> C:\Users\hp.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2807:25
|
2807 | ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

Compiling winreg v0.10.1
Compiling flate2 v1.0.27
For more information about this error, try rustc --explain E0793.
error: could not compile ntapi (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile spl-token-cli v2.4.0, intermediate artifacts can be found at C:\Users\hp\AppData\Local\Temp\cargo-installKECsYf.
To reuse those artifacts with a future compilation, set the environment variable CARGO_TARGET_DIR to that path."""

reference to packed field is unaligned

Ive tried
ntapi = "0.4.1"
ntapi = "0.4.0"
ntapi = "0.3.7"

and 32bit and 64bit for each version

I get these errors when compiling the crate

error[E0793]: reference to packed field is unaligned
--> C:\Users\USER.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52
|
2783 | *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

error[E0793]: reference to packed field is unaligned
--> C:\Users\USER.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2807:25
|
2807 | ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad).wrapping_mul((*USER_SHARED_DATA).TickCountMultiplier as u64)) >> 24) as u32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

For more information about this error, try rustc --explain E0793.
error: could not compile ntapi (lib) due to 2 previous errors

`llvm_asm` removed in 1/18/22 nightly

llvm_asm was removed in 1/18/22 nightly, requiring migration to asm macros instead.

This allows ntapi to support the beta toolchain instead of nightly, as asm is being stabilized. It is an easy fix, I have made the necessary changes here. I do not keep up enough to know what you want to do with some of the other mentions of nightly (such as YAML files), but I renamed the feature flag to beta and aliased the old nightly flag.

Nightly incompatibility

This project does not build against nightly-x86_64-pc-windows-msvc and nightly-i686-pc-windows-msv.
Building against the stable-x86_64-pc-windows-msv raises a future incompatibility warning.

Here is the full report produced by cargo report future-incompatibilities --id 23 --package [email protected]:

The following warnings were discovered during the build. These warnings are an
indication that the packages contain code that will become an error in a
future release of Rust. These warnings typically cover changes to close
soundness problems, unintended or undocumented behavior, or critical problems
that cannot be fixed in a backwards-compatible fashion, and are not expected
to be in wide use.

Each warning should contain a link for more information on what the warning
means and how to resolve it.


To solve this problem, you can try the following approaches:


- Some affected dependencies have newer versions available.
You may want to consider updating them to a newer version to see if the issue has been fixed.

ntapi v0.3.7 has the following newer versions available: 0.4.0


- If the issue is not solved by updating the dependencies, a fix has to be
implemented by those dependencies. You can help with that by notifying the
maintainers of this problem (e.g. by creating a bug report) or by proposing a
fix to the maintainers (e.g. by creating a pull request):

  - [email protected]
  - Repository: https://github.com/MSxDOS/ntapi
  - Detailed warning command: `cargo report future-incompatibilities --id 23 --package [email protected]`

- If waiting for an upstream fix is not an option, you can use the `[patch]`
section in `Cargo.toml` to use your own version of the dependency. For more
information, see:
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section

The package `ntapi v0.3.7` currently triggers the following future incompatibility lints:
> warning: reference to packed field is unaligned
>     --> ~\.cargo\registry\src\github.com-1ecc6299db9ec823\ntapi-0.3.7\src\ntexapi.rs:2783:52
>      |
> 2783 |         *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
>      |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      |
>      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>      = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>      = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>      = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
>      = note: `#[allow(unaligned_references)]` on by default
>
> warning: reference to packed field is unaligned
>     --> ~\.cargo\registry\src\github.com-1ecc6299db9ec823\ntapi-0.3.7\src\ntexapi.rs:2807:25
>      |
> 2807 |         ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
>      |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      |
>      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>      = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>      = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>      = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
>      = note: `#[allow(unaligned_references)]` on by default
>

ntapi 0.3.7 contains code that will be incompatible with future versions of Rust

Hi there!

Compiling ntapi (downstream dependency of one of my dependencies) with today (2022-08-06)'s nightly compiler results in the following warning:
warning: the following packages contain code that will be rejected by a future version of Rust: ntapi v0.3.7

The resulting cargo report looks like this:

The package `ntapi v0.3.7` currently triggers the following future incompatibility lints:
> warning: reference to packed field is unaligned
>     --> .cargo\registry\src\github.com-1ecc6299db9ec823\ntapi-0.3.7\src\ntexapi.rs:2783:52
>      |
> 2783 |         *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
>      |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      |
>      = note: `#[allow(unaligned_references)]` on by default
>      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>      = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>      = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>      = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
>
> warning: reference to packed field is unaligned
>     --> .cargo\registry\src\github.com-1ecc6299db9ec823\ntapi-0.3.7\src\ntexapi.rs:2807:25
>      |
> 2807 |         ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
>      |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      |
>      = note: `#[allow(unaligned_references)]` on by default
>      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>      = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>      = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>      = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)

Hoping this isn't too troublesome to fix ๐Ÿ™

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.