2828import com .sun .jna .Native ;
2929import com .sun .jna .NativeLibrary ;
3030import com .sun .jna .Pointer ;
31- import com .sun .jna .Structure ;
3231import com .sun .jna .platform .win32 .Tlhelp32 ;
33- import com .sun .jna .platform .win32 .WinDef ;
3432import com .sun .jna .win32 .W32APIOptions ;
3533
36- import java .util .Arrays ;
37- import java .util .List ;
38-
3934public final class Kernel32 {
4035
4136 static {
@@ -50,115 +45,10 @@ public final class Kernel32 {
5045
5146 public static native boolean Process32Next (Pointer pointer , Tlhelp32 .PROCESSENTRY32 entry );
5247
53- public static native boolean Module32NextW (Pointer pointer , Kernel32 .MODULEENTRY32W entry );
48+ public static native boolean Module32NextW (Pointer pointer , Tlhelp32 .MODULEENTRY32W entry );
5449
5550 public static native long ReadProcessMemory (Pointer process , Pointer address , MemoryBuffer memory , int size , int written );
5651
5752 public static native long WriteProcessMemory (Pointer process , Pointer address , MemoryBuffer memory , int size , int written );
5853
59- /**
60- * Describes an entry from a list of the modules belonging to the specified
61- * process.
62- *
63- * @see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms684225(v=vs.85).aspx">MSDN</a>
64- */
65- public static class MODULEENTRY32W extends Structure {
66-
67- public static final int MAX_MODULE_NAME32 = 255 ;
68-
69- /**
70- * A representation of a MODULEENTRY32 structure as a reference
71- */
72- public static class ByReference extends MODULEENTRY32W implements Structure .ByReference {
73- public ByReference () {
74- }
75-
76- public ByReference (Pointer memory ) {
77- super (memory );
78- }
79- }
80-
81- /**
82- * The size of the structure, in bytes. Before calling the Module32First
83- * function, set this member to sizeof(MODULEENTRY32). If you do not
84- * initialize dwSize, Module32First fails.
85- */
86- public WinDef .DWORD dwSize ;
87-
88- /**
89- * This member is no longer used, and is always set to one.
90- */
91- public WinDef .DWORD th32ModuleID ;
92-
93- /**
94- * The identifier of the process whose modules are to be examined.
95- */
96- public WinDef .DWORD th32ProcessID ;
97-
98- /**
99- * The load count of the module, which is not generally meaningful, and
100- * usually equal to 0xFFFF.
101- */
102- public WinDef .DWORD GlblcntUsage ;
103-
104- /**
105- * The load count of the module (same as GlblcntUsage), which is not
106- * generally meaningful, and usually equal to 0xFFFF.
107- */
108- public WinDef .DWORD ProccntUsage ;
109-
110- /**
111- * The base address of the module in the context of the owning process.
112- */
113- public Pointer modBaseAddr ;
114-
115- /**
116- * The size of the module, in bytes.
117- */
118- public WinDef .DWORD modBaseSize ;
119-
120- /**
121- * A handle to the module in the context of the owning process.
122- */
123- public WinDef .HMODULE hModule ;
124-
125- /**
126- * The module name.
127- */
128- public char [] szModule = new char [MAX_MODULE_NAME32 + 1 ];
129-
130- /**
131- * The module path.
132- */
133- public char [] szExePath = new char [com .sun .jna .platform .win32 .Kernel32 .MAX_PATH ];
134-
135- public MODULEENTRY32W () {
136- dwSize = new WinDef .DWORD (size ());
137- }
138-
139- public MODULEENTRY32W (Pointer memory ) {
140- super (memory );
141- read ();
142- }
143-
144- /**
145- * @return The module name.
146- */
147- public String szModule () {
148- return Native .toString (this .szModule );
149- }
150-
151- /**
152- * @return The module path.
153- */
154- public String szExePath () {
155- return Native .toString (this .szExePath );
156- }
157-
158- @ Override
159- protected List <String > getFieldOrder () {
160- return Arrays .asList ("dwSize" , "th32ModuleID" , "th32ProcessID" , "GlblcntUsage" , "ProccntUsage" , "modBaseAddr" , "modBaseSize" , "hModule" , "szModule" , "szExePath" );
161- }
162- }
163-
16454}
0 commit comments