All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.bloodshura.ignitium.ntv.lib.Win32 Maven / Gradle / Ivy

The newest version!
package com.github.bloodshura.ignitium.ntv.lib;

import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.LPVOID;
import com.sun.jna.platform.win32.WinNT.HANDLE;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;

public final class Win32 {
	private Win32() {
	}

	public static final class Kernel {
		public static final int MEM_DECOMMIT = 0x4000;
		public static final int MEM_RELEASE = 0x8000;

		static {
			Native.register(NativeLibrary.getInstance("kernel32"));
		}

		private Kernel() {
		}

		public static native boolean Beep(int frequency, int duration);

		public static native boolean MessageBeep(int type);

		@Nullable
		public static native Pointer VirtualAllocEx(@Nonnull HANDLE hProcess, @Nullable LPVOID lpAddress, /* SIZE_T */ int dwSize, @Nonnull DWORD flAllocationType, @Nonnull DWORD flProtect);

		public static native boolean VirtualFreeEx(@Nonnull HANDLE hProcess, @Nonnull LPVOID lpAddress, /* SIZE_T */ int dwSize, @Nonnull DWORD dwFreeType);
	}

	public static class TOKEN_ELEVATED extends Structure {
		public static final List FIELDS = createFieldsOrder("TokenIsElevated");

		public DWORD TokenIsElevated;

		public TOKEN_ELEVATED() {
		}

		public TOKEN_ELEVATED(int size) {
			super(new Memory(size));
		}

		public TOKEN_ELEVATED(@Nullable Pointer memory) {
			super(memory);
			read();
		}

		@Nonnull
		@Override
		protected List getFieldOrder() {
			return FIELDS;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy