Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package kine;
- import static java.util.Arrays.asList;
- import java.util.List;
- import com.sun.jna.Library;
- import com.sun.jna.Structure;
- import com.sun.jna.ptr.IntByReference;
- public interface Kernel32 extends Library {
- IntByReference VirtualAllocEx(IntByReference hProcess,
- IntByReference lpAddress, int dwSize, int flAllocationType,
- int flProtect);
- boolean CreateProcess(String lpApplicationName, String commandLine,
- int processAttributes, int threadAttributes,
- boolean inheritHandles, int creationFlags,
- IntByReference environment, String currentDirectory,
- STARTUPINFO startupInfo, PROCESS_INFORMATION processInformation);
- boolean ReadProcessMemory(IntByReference hProcess,
- IntByReference lpBaseAddress, IntByReference lpBuffer, int dwSize,
- int lpNumberOfBytesRead);
- boolean WriteProcessMemory(IntByReference hProcess,
- IntByReference lpBaseAddress, IntByReference lpBuffer, int nSize,
- int lpNumberOfBytesWritten);
- boolean GetThreadContext(IntByReference hThread, CONTEXT lpContext);
- boolean SetThreadContext(IntByReference hThread, CONTEXT lpContext);
- int SuspendThread(IntByReference hThread);
- int ResumeThread(IntByReference hThread);
- boolean VirtualProtectEx(IntByReference hProcess, IntByReference lpAddress,
- IntByReference dwSize, int flNewProtect, int lpflOldProtect);
- int VirtualQueryEx(IntByReference hProcess, IntByReference lpAddress,
- MEMORY_BASIC_INFORMATION lpBuffer, int dwLength);
- IntByReference VirtualAlloc(IntByReference address, int numBytes,
- int commitOrReserve, int pageProtectionMode);
- public static class PROCINFO extends Structure {
- public int baseAddr;
- public int imageSize;
- @Override
- protected List<String> getFieldOrder() {
- return asList("baseAddr", "imageSize");
- }
- }
- public static class PROCESS_INFORMATION extends Structure {
- public IntByReference hProcess;
- public IntByReference hThread;
- public int dwProcessId;
- public int dwThreadId;
- @Override
- protected List<String> getFieldOrder() {
- return asList("hProcess", "hThread", "dwProcessId", "dwThreadId");
- }
- }
- public static class STARTUPINFO extends Structure {
- public int cb;
- public String lpReserved;
- public String lpDesktop;
- public String lpTitle;
- public byte unused[] = new byte[52];
- @Override
- protected List<String> getFieldOrder() {
- return asList("cb", "lpReserved", "lpDesktop", "lpTitle", "unused");
- }
- }
- public static class CONTEXT extends Structure {
- public int ContextFlags;
- public byte[] unused = new byte[160];
- public int Ebx;
- public int Edx;
- public int Ecx;
- public int Eax;
- @Override
- protected List<String> getFieldOrder() {
- return asList("ContextFlags", "unused", "Ebx", "Edx", "Ecx", "Eax");
- }
- }
- public static class MEMORY_BASIC_INFORMATION extends Structure {
- public int BaseAddress;
- public int AllocationBase;
- public int AllocationProtect;
- public int RegionSize;
- public int State;
- public int Protect;
- public int lType;
- @Override
- protected List<String> getFieldOrder() {
- return asList("BaseAddress", "AllocationBase", "AllocationProtect",
- "RegionSize", "State", "Protect", "lType");
- }
- }
- public static class MZHeader extends Structure {
- public short signature;
- public byte[] unused = new byte[58];
- public int offsetToPE;
- @Override
- protected List<String> getFieldOrder() {
- return asList("signature", "unused", "offsetToPE");
- }
- }
- public static class PE_Header extends Structure {
- public int signature;
- public short machine;
- public short numSections;
- public int timeDateStamp;
- public int pointerToSymbolTable;
- public int numOfSymbols;
- public short sizeOfOptionHeader;
- public short characteristics;
- @Override
- protected List<String> getFieldOrder() {
- return asList("signature", "machine", "numSections",
- "timeDateStamp", "pointerToSymbolTable", "numOfSymbols",
- "sizeOfOptionHeader", "characteristics");
- }
- }
- public static class PE_ExtHeader extends Structure {
- public short magic;
- public byte majorLinkerVersion;
- public byte minorLinkerVersion;
- public int sizeOfCode;
- public int sizeOfInitializedData;
- public int sizeOfUninitializedData;
- public int addressOfEntryPoint;
- public int baseOfCode;
- public int baseOfData;
- public int imageBase;
- public int sectionAlignment;
- public int fileAlignment;
- public byte[] unused = new byte[16];
- public int sizeOfImage;
- public int sizeOfHeaders;
- public byte[] unused2 = new byte[160];
- @Override
- protected List<String> getFieldOrder() {
- return asList("magic", "majorLinkerVersion", "minorLinkerVersion",
- "sizeOfCode", "sizeOfInitializedData",
- "sizeOfUninitializedData", "addressOfEntryPoint",
- "baseOfCode", "baseOfData", "imageBase",
- "sectionAlignment", "fileAlignment", "unused",
- "sizeOfImage", "sizeOfHeaders", "unused2");
- }
- }
- public static class SectionHeader extends Structure {
- public long sectionName;
- public int virtualSize;
- public int virtualAddress;
- public int sizeOfRawData;
- public int pointerToRawData;
- public byte[] unused = new byte[16];
- @Override
- protected List<String> getFieldOrder() {
- return asList("sectionName", "virtualSize", "virtualAddress",
- "sizeOfRawData", "pointerToRawData", "unused");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement