Hello, Win32 API(Jasmin) World!

Posted on 1月 16th, 2013 by cx20

Win32 API(Jasmin)

Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
以下は Jasmin にて SWT の非公開 API を使用した Win32 API 呼出しの例となっている。

ソースコード

; Produced by NeoJasminVisitor (tinapoc)
; http://tinapoc.sourceforge.net
; The original JasminVisitor is part of the BCEL
; http://jakarta.apache.org/bcel/
; Sat Dec 08 23:04:58 JST 2012
 
.bytecode 51.0
.source Hello.java
.class public Hello
.super java/lang/Object
 
 
.method public ()V
    .limit stack 1
    .limit locals 1
    .var 0 is this LHello; from Label0 to Label1
 
    Label0:
.line 4
       0: aload_0
       1: invokespecial java/lang/Object/()V
 
    Label1:
       4: return
 
.end method
 
 
.method public static main([Ljava/lang/String;)V
    .limit stack 5
    .limit locals 3
    .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1
 
 
    Label0:
.line 6
       0: new org/eclipse/swt/internal/win32/TCHAR
       3: dup
       4: iconst_0
       5: ldc "Hello, Win32 API World!"
       7: iconst_1
       8: invokespecial org/eclipse/swt/internal/win32/TCHAR/(ILjava/lang/String;Z)V
      11: astore_1
 
    .line 7
      12: new org/eclipse/swt/internal/win32/TCHAR
      15: dup
      16: iconst_0
      17: ldc "Hello, World"
      19: iconst_1
      20: invokespecial org/eclipse/swt/internal/win32/TCHAR/(ILjava/lang/String;Z)V
      23: astore_2
 
    .line 8
      24: iconst_0
      25: aload_1
      26: aload_2
      27: iconst_0
      28: invokestatic org/eclipse/swt/internal/win32/OS/MessageBox(ILorg/eclipse/swt/internal/win32/TCHAR;Lorg/eclipse/swt/internal/win32/TCHAR;I)I
      31: pop
 
    Label1:
.line 9
      32: return
 
.end method

コンパイル&実行方法

C:¥> jasmin Hello.j
C:¥> java -cp org.eclipse.swt.win32.win32.x86_3.6.1.v3655c.jar;. Hello

実行結果

---------------------------
Hello, World!
---------------------------
Hello, Win32 API World!
---------------------------
OK   
---------------------------

Tags:

Categories: Jasmin, Java, Win32 API

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

WP-SpamFree by Pole Position Marketing