commit
7ad939bbe0
@ -0,0 +1,8 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry kind="src" path="src"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> |
||||
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/jna-4.5.0.jar"/> |
||||
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/jna-platform-4.5.0.jar"/> |
||||
<classpathentry kind="output" path="bin"/> |
||||
</classpath> |
@ -0,0 +1,13 @@ |
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> |
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> |
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> |
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> |
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> |
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> |
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="RabiTracker"/> |
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/RabiTracker/projectBuilder.xml}"/> |
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> |
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> |
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/RabiTracker}"/> |
||||
</launchConfiguration> |
@ -0,0 +1 @@ |
||||
/bin/ |
@ -0,0 +1,27 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>RabiTracker</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
<buildCommand> |
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> |
||||
<triggers>full,incremental,</triggers> |
||||
<arguments> |
||||
<dictionary> |
||||
<key>LaunchConfigHandle</key> |
||||
<value><project>/.externalToolBuilders/New_Builder (7).launch</value> |
||||
</dictionary> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
</natures> |
||||
</projectDescription> |
@ -0,0 +1,11 @@ |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve |
||||
org.eclipse.jdt.core.compiler.compliance=1.8 |
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate |
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate |
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate |
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
||||
org.eclipse.jdt.core.compiler.source=1.8 |
Binary file not shown.
@ -0,0 +1,18 @@ |
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project default="create_run_jar" name="Create Runnable Jar for Rabi Tracker"> |
||||
<!--this file was created by Eclipse Runnable JAR Export Wizard--> |
||||
<!--ANT 1.7 is required --> |
||||
<!--define folder properties--> |
||||
<property name="dir.buildfile" value="."/> |
||||
<property name="dir.workspace" value="${dir.buildfile}/.."/> |
||||
<property name="dir.jarfile" value="${dir.buildfile}"/> |
||||
<target name="create_run_jar"> |
||||
<jar destfile="${dir.jarfile}/RabiTracker.jar" filesetmanifest="mergewithoutmain"> |
||||
<manifest> |
||||
<attribute name="Main-Class" value="RabiTracker.Window"/> |
||||
<attribute name="Class-Path" value="."/> |
||||
</manifest> |
||||
<fileset dir="${dir.jarfile}/bin"/> |
||||
</jar> |
||||
</target> |
||||
</project> |
@ -0,0 +1,151 @@ |
||||
package RabiTracker; |
||||
|
||||
import sig.modules.RabiRibi.OffsetHelper; |
||||
|
||||
public enum MemoryData { |
||||
MONEY(0xD654CC), |
||||
PLAYTIME(0xD642D8), |
||||
HEALTHUP_START(0xD6342C), |
||||
HEALTHUP_END(0xD6342C), |
||||
ATTACKUP_START(0xD6352C), |
||||
ATTACKUP_END(0xD63628), |
||||
MANAUP_START(0xD6362C), |
||||
MANAUP_END(0xD63728), |
||||
REGENUP_START(0xD6372C), |
||||
REGENUP_END(0xD63828), |
||||
PACKUP_START(0xD6382C), |
||||
PACKUP_END(0xD63928), |
||||
/*ENTITY_ARRAY(0x0096DA3C), //Erina Data Pointer.
|
||||
ERINA_HP(0x4D8), |
||||
ERINA_MAXHP(0x4E8), |
||||
ERINA_XPOS(0xC), |
||||
ERINA_YPOS(0x10), |
||||
ERINA_XSPEED(0x470), //Relative to Entity Array.
|
||||
ERINA_YSPEED(0x474), //Relative to Entity Array.
|
||||
MAPID(0xA600AC), |
||||
CAMERA_XPOS(0x991AF4), |
||||
CAMERA_YPOS(0xABD0A4), |
||||
//ENTITY_SIZE(0x704),
|
||||
ENTITY_ID(0x4F4), |
||||
ENTITY_HP(0x4D8), |
||||
ENTITY_MAXHP(0x4E8), |
||||
ENTITY_ISACTIVE(0x674), |
||||
ENTITY_ANIMATION(0x678), |
||||
ENTITY_XPOS(0xC), |
||||
ENTITY_YPOS(0x10), |
||||
ENTITY_COLOR(0x1C), |
||||
TRANSITION_COUNTER(0xA7661C),*/ |
||||
//WARP_TRANSITION_COUNTER(0,0x582CE0+OffsetHelper.KEY_ITEM_OFFSET_V185_TO_V1851), //Detects pausing
|
||||
|
||||
|
||||
|
||||
GAME_DIFFICULTY(0xD64338), |
||||
GAME_LOOP(0xD6D05C), |
||||
|
||||
HAMMER(0xD632B0), |
||||
AIR_JUMP(0xD632B4), |
||||
SLIDING_POWDER(0xD632B8), |
||||
CARROT_BOMB(0xD632BC), |
||||
HOURGLASS(0xD632C0), |
||||
SPEED_BOOST(0xD632C4), |
||||
AUTO_EARRINGS(0xD632C8), |
||||
RIBBON(0xD632CC), |
||||
SOUL_HEART(0xD632D0), |
||||
RABI_SLIPPERS(0xD632D4), |
||||
BUNNY_WHIRL(0xD632D8), |
||||
QUICK_BARETTE(0xD632DC), |
||||
BOOK_OF_CARROT(0xD632E0), |
||||
CHAOS_ROD(0xD632E4), |
||||
HAMMER_WAVE(0xD632E8), |
||||
HAMMER_ROLL(0xD632EC), |
||||
LIGHT_ORB(0xD632F0), |
||||
WATER_ORB(0xD632F4), |
||||
FIRE_ORB(0xD632F8), |
||||
NATURE_ORB(0xD632FC), |
||||
P_HAIRPIN(0xD63300), |
||||
SUNNY_BEAM(0xD63304), |
||||
PLUS_NECKLACE(0xD63308), |
||||
CYBER_FLOWER(0xD6330C), |
||||
HEALING_STAFF(0xD63310), |
||||
MAX_BRACELET(0xD63314), |
||||
EXPLODE_SHOT(0xD63318), |
||||
AIR_DASH(0xD6331C), |
||||
BUNNY_STRIKE(0xD63320), |
||||
STRANGE_BOX(0xD63324), |
||||
WALL_JUMP(0xD63328), |
||||
SPIKE_BARRIER(0xD6332C), |
||||
BUNNY_AMULET(0xD63330), |
||||
CHARGE_RING(0xD63334), |
||||
CARROT_SHOOTER(0xD63338), |
||||
SUPER_CARROT(0xD6333C), |
||||
RUMI_DONUT(0xD63340), |
||||
RUMI_CAKE(0xD63344), |
||||
GOLD_CARROT(0xD63348), |
||||
COCOA_BOMB(0xD6334C), |
||||
UNKNOWN_ITEM1(0xD63350), |
||||
TROPHY(0xD63354), |
||||
EXCLAMATION_POINT(0xD63358), |
||||
UNKNOWN_ITEM2(0xD6335C), |
||||
UNKNOWN_ITEM3(0xD63360), |
||||
UNKNOWN_ITEM4(0xD63364), |
||||
RAINBOW_MAGIC(0xD63368), |
||||
UNKNOWN_ITEM5(0xD6336C), |
||||
UNKNOWN_ITEM6(0xD63370), |
||||
UNKNOWN_ITEM7(0xD63374), |
||||
UNKNOWN_ITEM8(0xD63378), |
||||
UNKNOWN_ITEM9(0xD6337C), |
||||
UNKNOWN_ITEM10(0xD63380), |
||||
UNKNOWN_ITEM11(0xD63384), |
||||
UNKNOWN_ITEM12(0xD63388), |
||||
UNKNOWN_ITEM13(0xD6338C), |
||||
UNKNOWN_ITEM14(0xD63390), |
||||
/*DLC_ITEM1(0xD63394,0xD63394+OffsetHelper.KEY_ITEM_OFFSET_V175_TO_V1851), |
||||
DLC_ITEM2(0xD63398,0xD63398+OffsetHelper.KEY_ITEM_OFFSET_V175_TO_V1851),*/ |
||||
BUNNY_CLOVER(0xD6339C), |
||||
FAIRYS_FLUTE(0), |
||||
BUNNY_MEMORIES(0), |
||||
WIND_BLESSING(0), |
||||
DLC_ITEM4(0xD633A0), |
||||
BADGE_HEALTH_PLUS(0xD633AC), |
||||
BADGE_HEALTH_SURGE(0xD633B0), |
||||
BADGE_MANA_PLUS(0xD633B4), |
||||
BADGE_MANA_SURGE(0xD633B8), |
||||
BADGE_CRISIS_BOOST(0xD633BC), |
||||
BADGE_ATK_GROW(0xD633C0), |
||||
BADGE_DEF_GROW(0xD633C4), |
||||
BADGE_ATK_TRADE(0xD633C8), |
||||
BADGE_DEF_TRADE(0xD633CC), |
||||
BADGE_ARM_STRENGTH(0xD633D0), |
||||
BADGE_CARROT_BOOST(0xD633D4), |
||||
BADGE_WEAKEN(0xD633D8), |
||||
BADGE_SELF_DEFENSE(0xD633DC), |
||||
BADGE_ARMORED(0xD633E0), |
||||
BADGE_LUCKY_SEVEN(0xD633E4), |
||||
BADGE_HEX_CANCEL(0xD633E8), |
||||
BADGE_PURE_LOVE(0xD633EC), |
||||
BADGE_TOXIC_STRIKE(0xD633F0), |
||||
BADGE_FRAME_CANCEL(0xD633F4), |
||||
BADGE_HEALTH_WAGER(0xD633F8), |
||||
BADGE_MANA_WAGER(0xD633FC), |
||||
BADGE_STAMINA_PLUS(0xD63400), |
||||
BADGE_BLESSED(0xD63404), |
||||
BADGE_HITBOX_DOWN(0xD63408), |
||||
BADGE_CASHBACK(0xD6340C), |
||||
BADGE_SURVIVAL(0xD63410), |
||||
BADGE_TOP_FORM(0xD63414), |
||||
BADGE_TOUGH_SKIN(0xD63418), |
||||
BADGE_ERINA_BADGE(0xD6341C), |
||||
BADGE_RIBBON_BADGE(0xD63420), |
||||
BADGE_AUTO_TRIGGER(0xD63424), |
||||
BADGE_LILITHS_GIFT(0xD63428), |
||||
//13413E8
|
||||
ITEM_PERCENT(0), |
||||
MAP_PERCENT(0), |
||||
RAINBOW_EGG_COUNT(0xD65FD4), |
||||
PAUSED(0), |
||||
; |
||||
|
||||
public MemoryData(long baseAddress) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,98 @@ |
||||
package RabiTracker; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.net.MalformedURLException; |
||||
import java.net.URL; |
||||
import java.util.List; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.concurrent.ScheduledExecutorService; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.platform.win32.Kernel32; |
||||
import com.sun.jna.platform.win32.WinNT; |
||||
import com.sun.jna.platform.win32.WinNT.HANDLE; |
||||
|
||||
import sig.modules.utils.PsapiTools; |
||||
|
||||
public class MemoryManager { |
||||
final int PROCESS_PERMISSIONS = WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_READ; |
||||
boolean foundRabiRibi = false; |
||||
int rabiRibiPID = -1; |
||||
long rabiRibiMemOffset = 0; |
||||
public HANDLE rabiribiProcess = null; |
||||
|
||||
MemoryManager() { |
||||
CheckRabiRibiClient(); |
||||
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
||||
scheduler.scheduleWithFixedDelay(()->{ |
||||
CheckRabiRibiClient(); |
||||
if (foundRabiRibi) { |
||||
/*myProfile.uploadProfile(); |
||||
getSessionList(); |
||||
getMessageUpdates(); |
||||
//trimeadProfile.downloadProfile();
|
||||
firstCheck=true; |
||||
if (mySession!=null) { |
||||
File file = new File(sigIRC.BASEDIR+"sigIRC/tmp.data"); |
||||
try { |
||||
org.apache.commons.io.FileUtils.copyURLToFile(new URL("http://45.33.13.215/rabirace/send.php?key=keepalivesession&session="+mySession.getID()),file); |
||||
} catch (MalformedURLException e) { |
||||
e.printStackTrace(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
}*/ |
||||
} |
||||
}, 5000, 5000, TimeUnit.MILLISECONDS); |
||||
} |
||||
|
||||
private void CheckRabiRibiClient() { |
||||
List<Integer> pids; |
||||
try { |
||||
pids = PsapiTools.getInstance().enumProcesses(); |
||||
boolean found=false; |
||||
for (Integer pid : pids) { |
||||
HANDLE process = Kernel32.INSTANCE.OpenProcess(PROCESS_PERMISSIONS, true, pid); |
||||
List<sig.modules.utils.Module> hModules; |
||||
try { |
||||
hModules = PsapiTools.getInstance().EnumProcessModules(process); |
||||
for(sig.modules.utils.Module m: hModules){ |
||||
//System.out.println(m.getFileName()+":"+m.getEntryPoint());
|
||||
if (m.getFileName().contains("rabiribi")) { |
||||
found=true; |
||||
if (!foundRabiRibi) { |
||||
rabiRibiMemOffset = Pointer.nativeValue(m.getLpBaseOfDll().getPointer()); |
||||
System.out.println("Found an instance of Rabi-Ribi at 0x"+Long.toHexString(rabiRibiMemOffset)+" | File:"+m.getFileName()+","+m.getBaseName()); |
||||
rabiRibiPID=pid; |
||||
foundRabiRibi=true; |
||||
rabiribiProcess=process; |
||||
break; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
if (found) { |
||||
break; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
if (process!=null) { |
||||
Kernel32.INSTANCE.CloseHandle(process); |
||||
} |
||||
} |
||||
if (!found && foundRabiRibi) { |
||||
foundRabiRibi=false; |
||||
System.out.println("Rabi-Ribi process lost."); |
||||
} else |
||||
if (!foundRabiRibi) { |
||||
System.out.println("Failed to find Rabi-Ribi."); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,92 @@ |
||||
package RabiTracker; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
import java.util.Calendar; |
||||
import java.util.Timer; |
||||
|
||||
import javax.swing.JFrame; |
||||
import javax.swing.JPanel; |
||||
|
||||
class DrawingPanel extends JPanel { |
||||
Window parent; |
||||
|
||||
public DrawingPanel(Window parent) { |
||||
this.parent = parent; |
||||
} |
||||
|
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
|
||||
parent.drawGUI(g); |
||||
|
||||
parent.frames++; |
||||
} |
||||
} |
||||
|
||||
public class Window extends JFrame{ |
||||
final static String WINDOW_TITLE = "Rabi Tracker v1.0"; |
||||
public static int MAX_FPS = 60; |
||||
|
||||
public static int TICK = 0; |
||||
|
||||
JFrame window = new JFrame("Rabi Tracker v1.0"); |
||||
DrawingPanel panel = new DrawingPanel(this); |
||||
|
||||
MemoryManager mem = new MemoryManager(); |
||||
|
||||
int timer = Calendar.getInstance().get(Calendar.SECOND); |
||||
public int frames = 0; |
||||
|
||||
public void setTitle(String str) { |
||||
window.setTitle(WINDOW_TITLE+" "+str); |
||||
} |
||||
|
||||
public void drawGUI(Graphics g) { |
||||
|
||||
} |
||||
|
||||
|
||||
public void display() { |
||||
window.setSize(640, 480); |
||||
window.setResizable(true); |
||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
|
||||
panel.setSize(640, 480); |
||||
panel.setBackground(Color.MAGENTA); |
||||
|
||||
window.getContentPane().add(panel); |
||||
window.setVisible(true); |
||||
} |
||||
|
||||
private void runTick() { |
||||
Window.TICK++; |
||||
panel.repaint(); |
||||
} |
||||
|
||||
public void update() { |
||||
int new_val = Calendar.getInstance().get(Calendar.SECOND); |
||||
int current_tick = Calendar.getInstance().get(Calendar.MILLISECOND); |
||||
if (new_val!=timer) { |
||||
setTitle("- "+frames+" FPS"); |
||||
frames=0; |
||||
timer = new_val; |
||||
} |
||||
try { |
||||
runTick(); |
||||
Thread.sleep((long)(1000d/MAX_FPS)); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
System.setProperty("sun.java2d.opengl", "True"); |
||||
|
||||
Window program = new Window(); |
||||
program.display(); |
||||
while (true) { |
||||
program.update(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
package sig.modules.utils; |
||||
|
||||
import sig.modules.utils.Psapi.LPMODULEINFO; |
||||
import com.sun.jna.platform.win32.WinDef.HMODULE; |
||||
import com.sun.jna.platform.win32.WinNT.HANDLE; |
||||
|
||||
public class Module { |
||||
private HANDLE hProcess; |
||||
private HMODULE hModule; |
||||
private HANDLE lpBaseOfDll = null; |
||||
private int SizeOfImage = 0; |
||||
private HANDLE EntryPoint = null; |
||||
|
||||
private PsapiTools psapi = PsapiTools.getInstance(); |
||||
|
||||
protected Module() { |
||||
} |
||||
|
||||
public Module(HANDLE hProcess, HMODULE hModule) { |
||||
this.hProcess = hProcess; |
||||
this.hModule = hModule; |
||||
} |
||||
|
||||
public HMODULE getPointer() { |
||||
return hModule; |
||||
} |
||||
|
||||
public String getFileName() { |
||||
return psapi.GetModuleFileNameExA(hProcess, hModule); |
||||
} |
||||
|
||||
public String getBaseName() { |
||||
return psapi.GetModuleBaseNameA(hProcess, hModule); |
||||
} |
||||
|
||||
private void GetModuleInformation() { |
||||
if (lpBaseOfDll == null) { |
||||
try { |
||||
LPMODULEINFO x = psapi.GetModuleInformation(hProcess, hModule); |
||||
lpBaseOfDll = x.lpBaseOfDll; |
||||
SizeOfImage = x.SizeOfImage; |
||||
EntryPoint = x.EntryPoint; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public HANDLE getLpBaseOfDll() { |
||||
GetModuleInformation(); |
||||
return lpBaseOfDll; |
||||
} |
||||
|
||||
public int getSizeOfImage() { |
||||
GetModuleInformation(); |
||||
return SizeOfImage; |
||||
} |
||||
|
||||
public HANDLE getEntryPoint() { |
||||
GetModuleInformation(); |
||||
return EntryPoint; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@ |
||||
package sig.modules.utils; |
||||
|
||||
import com.sun.jna.Memory; |
||||
import com.sun.jna.Native; |
||||
import com.sun.jna.platform.win32.Kernel32; |
||||
import com.sun.jna.ptr.IntByReference; |
||||
|
||||
public interface MyKernel32 extends Kernel32 { |
||||
final Kernel32 INSTANCE = (Kernel32) Native.loadLibrary ("kernel32", Kernel32.class); |
||||
|
||||
// BOOL WINAPI WriteProcessMemory(
|
||||
// __in HANDLE hProcess,
|
||||
// __in LPVOID lpBaseAddress,
|
||||
// __in LPCVOID lpBuffer,
|
||||
// __in SIZE_T nSize,
|
||||
// __out SIZE_T *lpNumberOfBytesWritten
|
||||
// );
|
||||
boolean WriteProcessMemory(HANDLE p, int address, HANDLE buffer, int size, IntByReference written); |
||||
|
||||
|
||||
// BOOL WINAPI ReadProcessMemory(
|
||||
// __in HANDLE hProcess,
|
||||
// __in LPCVOID lpBaseAddress,
|
||||
// __out LPVOID lpBuffer,
|
||||
// __in SIZE_T nSize,
|
||||
// __out SIZE_T *lpNumberOfBytesRead
|
||||
// );
|
||||
boolean ReadProcessMemory(HANDLE hProcess, int inBaseAddress, Memory outputBuffer, int nSize, IntByReference outNumberOfBytesRead); |
||||
|
||||
|
||||
// HANDLE WINAPI OpenProcess(
|
||||
// __in DWORD dwDesiredAccess,
|
||||
// __in BOOL bInheritHandle,
|
||||
// __in DWORD dwProcessId
|
||||
// );
|
||||
HANDLE OpenProcess(int desired, boolean inherit, int pid); |
||||
|
||||
|
||||
// BOOL WINAPI EnumProcessModules(
|
||||
// _In_ HANDLE hProcess,
|
||||
// _Out_ HMODULE *lphModule,
|
||||
// _In_ DWORD cb,
|
||||
// _Out_ LPDWORD lpcbNeeded
|
||||
// );
|
||||
boolean EnumProcessModules(HANDLE hProcess, HMODULE lphModule, int cb, int lpcbNeeded); |
||||
|
||||
|
||||
// DWORD WINAPI GetModuleFileName(
|
||||
// _In_opt_ HMODULE hModule,
|
||||
// _Out_ LPTSTR lpFilename,
|
||||
// _In_ DWORD nSize
|
||||
// );
|
||||
|
||||
int GetModuleFileName(HMODULE hModule, String lpFilename, int size); |
||||
|
||||
// DWORD WINAPI GetModuleFileNameEx(
|
||||
// _In_ HANDLE hProcess,
|
||||
// _In_opt_ HMODULE hModule,
|
||||
// _Out_ LPTSTR lpFilename,
|
||||
// _In_ DWORD nSize
|
||||
// );
|
||||
|
||||
|
||||
// BOOL WINAPI GetModuleHandleEx(
|
||||
// _In_ DWORD dwFlags,
|
||||
// _In_opt_ LPCTSTR lpModuleName,
|
||||
// _Out_ HMODULE *phModule
|
||||
// );
|
||||
|
||||
int GetModuleHandleExA(int permissions, String lpFilename, HMODULE module); |
||||
|
||||
// BOOL WINAPI EnumProcesses(
|
||||
// _Out_ DWORD *pProcessIds,
|
||||
// _In_ DWORD cb,
|
||||
// _Out_ DWORD *pBytesReturned
|
||||
// );
|
||||
|
||||
boolean EnumProcesses(int[] processIds, int cb, int bytesReturned); |
||||
|
||||
int GetLastError(); |
||||
} |
@ -0,0 +1,12 @@ |
||||
package sig.modules.utils; |
||||
|
||||
import com.sun.jna.Native; |
||||
import com.sun.jna.platform.win32.User32; |
||||
|
||||
public interface MyUser32 extends User32 { |
||||
final User32 INSTANCE = (User32) Native.loadLibrary ("user32", User32.class); |
||||
boolean ShowWindow(HWND hWnd, int nCmdShow); |
||||
boolean SetForegroundWindow(HWND hWnd); |
||||
HWND FindWindowA(String lpClassName, String lpWindowName); |
||||
|
||||
} |
@ -0,0 +1,57 @@ |
||||
package sig.modules.utils; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import com.sun.jna.Native; |
||||
import com.sun.jna.Structure; |
||||
import com.sun.jna.platform.win32.WinDef.HMODULE; |
||||
import com.sun.jna.platform.win32.WinNT.HANDLE; |
||||
import com.sun.jna.ptr.IntByReference; |
||||
import com.sun.jna.win32.StdCallLibrary; |
||||
|
||||
public interface Psapi extends StdCallLibrary{ |
||||
Psapi INSTANCE = (Psapi) Native.loadLibrary("Psapi", Psapi.class); |
||||
|
||||
/* |
||||
* http://msdn.microsoft.com/en-us/library/ms682629(VS.85).aspx
|
||||
*/ |
||||
boolean EnumProcesses(int[] pProcessIds, int cb, IntByReference pBytesReturned); |
||||
|
||||
|
||||
/* |
||||
* http://msdn.microsoft.com/en-us/library/ms682631(VS.85).aspx
|
||||
*/ |
||||
boolean EnumProcessModules(HANDLE hProcess, HMODULE[] lphModule, int cb, IntByReference lpcbNeededs); |
||||
|
||||
boolean EnumProcessModulesEx(HANDLE hProcess, HMODULE[] lphModule, int cb, IntByReference lpcbNeededs, int flags); |
||||
|
||||
|
||||
/* |
||||
* http://msdn.microsoft.com/en-us/library/ms683198(VS.85).aspx
|
||||
*/ |
||||
int GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule, byte[] lpImageFileName, int nSize); |
||||
|
||||
int GetModuleBaseNameA(HANDLE hProcess, HMODULE hModule, byte[] lpImageFileName, int nSize); |
||||
|
||||
|
||||
/* |
||||
* http://msdn.microsoft.com/en-us/library/ms684229(VS.85).aspx
|
||||
*/ |
||||
public static class LPMODULEINFO extends Structure { |
||||
public HANDLE lpBaseOfDll; |
||||
public int SizeOfImage; |
||||
public HANDLE EntryPoint; |
||||
@Override |
||||
protected List getFieldOrder() { |
||||
return Arrays.asList(new String[] { "lpBaseOfDll", "SizeOfImage", "EntryPoint"}); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* http://msdn.microsoft.com/en-us/library/ms683201(VS.85).aspx
|
||||
*/ |
||||
boolean GetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, int cb); |
||||
|
||||
|
||||
} |
@ -0,0 +1,104 @@ |
||||
package sig.modules.utils; |
||||
|
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
|
||||
import sig.modules.utils.Psapi.LPMODULEINFO; |
||||
import com.sun.jna.Native; |
||||
import com.sun.jna.platform.win32.Kernel32; |
||||
import com.sun.jna.platform.win32.WinDef.HMODULE; |
||||
import com.sun.jna.platform.win32.WinNT.HANDLE; |
||||
import com.sun.jna.ptr.IntByReference; |
||||
|
||||
public class PsapiTools { |
||||
private static PsapiTools INSTANCE=null; |
||||
private static Psapi psapi = Psapi.INSTANCE; |
||||
private static Kernel32 k32 = MyKernel32.INSTANCE; |
||||
|
||||
private PsapiTools(){} |
||||
|
||||
public static PsapiTools getInstance(){ |
||||
if (INSTANCE==null) |
||||
INSTANCE=new PsapiTools(); |
||||
return INSTANCE; |
||||
} |
||||
|
||||
|
||||
public List<Integer> enumProcesses() throws Exception{ |
||||
List<Integer> list = new LinkedList<Integer>(); |
||||
|
||||
int[] pProcessIds = new int[1024]; |
||||
IntByReference pBytesReturned = new IntByReference(); |
||||
boolean success = psapi.EnumProcesses(pProcessIds, pProcessIds.length*Integer.SIZE/8, pBytesReturned); |
||||
if (!success){ |
||||
int err=k32.GetLastError(); |
||||
throw new Exception("EnumProcesses failed. Error: "+err); |
||||
} |
||||
|
||||
int size = (pBytesReturned.getValue()/(Integer.SIZE/8)); |
||||
for (int i=0;i<size;i++) |
||||
list.add(pProcessIds[i]); |
||||
|
||||
return list; |
||||
} |
||||
|
||||
public List<Module> EnumProcessModules(HANDLE hProcess) throws Exception{ |
||||
List<Module> list = new LinkedList<Module>(); |
||||
|
||||
HMODULE[] lphModule = new HMODULE[1024]; |
||||
IntByReference lpcbNeededs= new IntByReference(); |
||||
boolean success = psapi.EnumProcessModules(hProcess, lphModule, lphModule.length, lpcbNeededs); |
||||
if (!success){ |
||||
int err=k32.GetLastError(); |
||||
if (err!=6 && err!=299 /*Generic Errors*/) { |
||||
throw new Exception("EnumProcessModules failed. Error: "+err); |
||||
} |
||||
} |
||||
for (int i = 0; i < lpcbNeededs.getValue()/4; i++) { |
||||
list.add(new Module(hProcess, lphModule[i])); |
||||
} |
||||
|
||||
return list; |
||||
} |
||||
|
||||
public List<Module> EnumProcessModulesEx(HANDLE hProcess, int flags) throws Exception{ |
||||
List<Module> list = new LinkedList<Module>(); |
||||
|
||||
HMODULE[] lphModule = new HMODULE[1024]; |
||||
IntByReference lpcbNeededs= new IntByReference(); |
||||
boolean success = psapi.EnumProcessModulesEx(hProcess, lphModule, lphModule.length, lpcbNeededs, flags); |
||||
if (!success){ |
||||
int err=k32.GetLastError(); |
||||
throw new Exception("EnumProcessModules failed. Error: "+err); |
||||
} |
||||
for (int i = 0; i < lpcbNeededs.getValue()/4; i++) { |
||||
list.add(new Module(hProcess, lphModule[i])); |
||||
} |
||||
|
||||
return list; |
||||
} |
||||
|
||||
public String GetModuleFileNameExA(HANDLE hProcess, HMODULE hModule){ |
||||
byte[] lpImageFileName= new byte[256]; |
||||
psapi.GetModuleFileNameExA(hProcess, hModule, lpImageFileName, 256); |
||||
return Native.toString(lpImageFileName); |
||||
} |
||||
|
||||
public String GetModuleBaseNameA(HANDLE hProcess, HMODULE hModule){ |
||||
byte[] lpImageFileName= new byte[256]; |
||||
psapi.GetModuleBaseNameA(hProcess, hModule, lpImageFileName, 256); |
||||
return Native.toString(lpImageFileName); |
||||
} |
||||
|
||||
public LPMODULEINFO GetModuleInformation(HANDLE hProcess, HMODULE hModule) throws Exception{ |
||||
LPMODULEINFO lpmodinfo = new LPMODULEINFO(); |
||||
|
||||
boolean success = psapi.GetModuleInformation(hProcess, hModule, lpmodinfo, lpmodinfo.size()); |
||||
if (!success){ |
||||
int err=k32.GetLastError(); |
||||
throw new Exception("GetModuleInformation failed. Error: "+err); |
||||
} |
||||
return lpmodinfo; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue