diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | README.md | 19 | ||||
-rw-r--r-- | build.gradle | 24 | ||||
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | settings.gradle | 2 | ||||
-rw-r--r-- | src/mingwMain/kotlin/moe.yuuta.desktop/Desktop.kt | 37 |
6 files changed, 87 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6914145 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +build/ +gradle/
\ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a4a56a1 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Desktop + +A simple Windows Secure Desktop demo written in Kotlin. + +It is also a demo for Kotlin Native and Windows APIs. + +Feel free to ask me questions in Issues and I'm sure I cannot answer them because this is my first Kotlin Native project, lol. + +# Acknowledgements + +* [https://www.codeproject.com/Articles/677695/Csharp-Create-Secure-Desktop-Anti-Keylogger](https://www.codeproject.com/Articles/677695/Csharp-Create-Secure-Desktop-Anti-Keylogger) + +* @duangsuse + +* Others + +# Licenses + +WTFPL
\ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..47dcc08 --- /dev/null +++ b/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'org.jetbrains.kotlin.multiplatform' version '1.3.40' +} +repositories { + jcenter() + mavenCentral() +} + +kotlin { + mingwX64() + sourceSets { + mingwX64Main { + mingwX64Main.kotlin.srcDirs += file("src/mingwMain/kotlin") + } + } + mingwX64 { + binaries { + executable { + entryPoint 'moe.yuuta.desktop.main' + linkerOpts "-Wl,--subsystem,windows" + } + } + } +}
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..de16ded --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +kotlin.code.style=official +kotlin.import.noCommonSourceSets=true
\ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..35d5053 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'Desktop' +// enableFeaturePreview('GRADLE_METADATA')
\ No newline at end of file diff --git a/src/mingwMain/kotlin/moe.yuuta.desktop/Desktop.kt b/src/mingwMain/kotlin/moe.yuuta.desktop/Desktop.kt new file mode 100644 index 0000000..ecef5fd --- /dev/null +++ b/src/mingwMain/kotlin/moe.yuuta.desktop/Desktop.kt @@ -0,0 +1,37 @@ +package moe.yuuta.desktop + +import platform.posix.printf +import platform.windows.* +import kotlin.native.concurrent.TransferMode +import kotlin.native.concurrent.Worker + +@Suppress("unused") +fun main() { + printf("Secure Desktop demo by i@yuuta.moe") + val oldDesktop = GetThreadDesktop(GetCurrentThreadId()) + val newDesktop = CreateDesktopA("desktop_dialog", + null, + null, + 0, + (DESKTOP_READOBJECTS or + DESKTOP_CREATEWINDOW or + DESKTOP_CREATEMENU or + DESKTOP_HOOKCONTROL or + DESKTOP_JOURNALRECORD or + DESKTOP_JOURNALPLAYBACK or + DESKTOP_ENUMERATE or + DESKTOP_WRITEOBJECTS or + DESKTOP_SWITCHDESKTOP).toUInt(), + null) + SwitchDesktop(newDesktop) + Worker.start().execute(TransferMode.SAFE, { newDesktop }) { + SetThreadDesktop(it) + MessageBoxA(null, + "Hi! This is message from thread ${GetCurrentThreadId()} in the secure desktop.", + "Secure Desktop", + (MB_OK or MB_ICONINFORMATION).toUInt()) + }.consume { + SwitchDesktop(oldDesktop) + CloseDesktop(newDesktop) + } +}
\ No newline at end of file |