Closed ytrsoft closed 7 months ago
Working on it
I've roughly tried some code, and there's a significant issue with the passing of string values my code: https://github.com/ytrsoft/jmem/tree/main/src/main/java/com/ytrsoft
I've roughly tried some code, and there's a significant issue with the passing of string values my code: https://github.com/ytrsoft/jmem/tree/main/src/main/java/com/ytrsoft
Strings are a bit problematic on Windows. You have two types of strings, char *
s (Multibyte) and wchar_t *
s (Unicode). The default string is picked based on how you compiled libmem (with or without _UNICODE
).
Another possible issue (which I think is the most likely one), is that Java strings are not null terminated. I didn't look your code very deeply, but since you're receiving a byte[]
, you can just push the value 0
before passing it to libmem to append the null terminator, making it become a C string.
for example
the returned path field is not a complete path
i dont understand
import com.sun.jna.Native;
public class MainClass { public static void main(String[] args) { Libmem.INSTANCE.LM_EnumProcesses(process -> { System.out.println(Native.toString(process.path)); return true; }); } }
output: ws\System32\conhost.exe ws\System32\sihost.exe ws\System32\svchost.exe am Files (x86)\Alibaba\wuying\1.3.1-R-20230619.223451\dasd\AspDriveService.exe ws\System32\svchost.exe ws\System32\conhost.exe ws\System32\taskhostw.exe ws\System32\ctfmon.exe am Files\Common Files\microsoft shared\ink\TabTip.exe am Files (x86)\Common Files\microsoft shared\Ink\TabTip32.exe ws\explorer.exe ws\System32\InputMethod\CHS\ChsIME.exe ws\System32\smartscreen.exe ws\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy\SearchUI.exe ws\System32\RuntimeBroker.exe ws\System32\RuntimeBroker.exe ws\System32\RuntimeBroker.exe ws\System32\ApplicationFrameHost.exe ws\System32\dllhost.exe am Files (x86)\letsvpn\app-3.3.2\LetsPRO.exe ws\System32\svchost.exe ws\SystemApps\ShellExperienceHost_cw5n1h2txyewy\ShellExperienceHost.exe am Files\JetBrains\IntelliJ IDEA 2023.2\bin\idea64.exe am Files\JetBrains\IntelliJ IDEA 2023.2\bin\fsnotifier.exe ws\System32\conhost.exe am Files\JetBrains\IntelliJ IDEA 2023.2\jbr\bin\java.exe ws\System32\conhost.exe am Files\Java\jdk-1.8\bin\java.exe ws\System32\conhost.exe am Files\JetBrains\IntelliJ IDEA 2023.2\bin\idea64.exe am Files\JetBrains\IntelliJ IDEA 2023.2\bin\idea64.exe am Files\JetBrains\IntelliJ IDEA 2023.2\bin\idea64.exe am Files\JetBrains\IntelliJ IDEA 2023.2\bin\idea64.exe am Files\JetBrains\IntelliJ IDEA 2023.2\jbr\bin\java.exe ws\System32\conhost.exe am Files\Java\jdk-1.8\bin\java.exe ws\System32\conhost.exe
@ytrsoft I think your structure might be missaligned. Check if the other fields before the path are returning the correct values.
New binary releases at: https://github.com/rdbo/libmem/releases Closing for inactivity
import com.sun.jna.Native; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions;
public interface Libmem extends StdCallLibrary {
}