[MASM] => [FASM] DLL для JAVA (using JNI)

Тема в разделе "WASM.ASSEMBLER", создана пользователем miae, 11 авг 2009.

  1. miae

    miae Member

    Публикаций:
    0
    Регистрация:
    22 дек 2007
    Сообщения:
    44
    ПОМОГИТЕ партировать из masm в fasm ... PLZ

    Код (Text):
    1. .386
    2. .model flat,stdcall
    3. option casemap:none
    4. include C:\masm32\include\windows.inc
    5. include C:\masm32\include\user32.inc
    6. include C:\masm32\include\kernel32.inc
    7. includelib C:\masm32\lib\user32.lib
    8. includelib C:\masm32\lib\kernel32.lib
    9.  
    10. Java_ShowMessage_HelloDll PROTO :DWORD, :DWORD, :DWORD
    11.  
    12. ;This macro returns pointer to the function table in fnTblPtr
    13.  
    14. GetFnTblPtr MACRO envPtr, fnTblPtr
    15.     mov ebx, envPtr
    16.     mov eax, [ebx]
    17.     mov fnTblPtr, eax
    18. ENDM
    19.  
    20. ;This macro returns pointer to desired function in fnPtr.
    21.  
    22. GetFnPtr MACRO fnTblPtr, index, fnPtr
    23.     mov eax, index
    24.     mov ebx, 4
    25.     mul ebx
    26.     mov ebx, fnTblPtr
    27.     add ebx, eax
    28.     mov eax, [ebx]
    29.     mov fnPtr, eax
    30. ENDM
    31.  
    32.  
    33. .data
    34.   Caption       db "JAV_ASM",0
    35.   ErrorMsg      db "String conversion error",0
    36.   SccsMsg       db "MessageBox displayed",0
    37.  
    38. .code
    39. hwEntry proc hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
    40.  
    41.     mov eax, TRUE
    42.     ret
    43.  
    44. hwEntry endp
    45.  
    46. Java_ShowMessage_HelloDll proc JNIEnv:DWORD, jobject:DWORD, Msgptr:DWORD
    47.  
    48.   LOCAL fntblptr        :DWORD
    49.   LOCAL Message     :DWORD
    50.   LOCAL fnptr       :DWORD
    51.  
    52.  
    53.     GetFnTblPtr JNIEnv, fntblptr    ; get pointer to function table
    54.       GetFnPtr fntblptr, 169, fnptr ; get pointer to GETstringUTFChars
    55.  
    56.     push NULL       ; push
    57.     push Msgptr       ; parameters for
    58.     push JNIEnv       ; GetStringUTFChars
    59.  
    60.     call [fnptr]    ; call GetStringUTFChars
    61.  
    62.     mov Message, eax
    63.  
    64.     .if eax == NULL
    65.             invoke MessageBox, NULL, addr ErrorMsg, addr Caption, 16
    66.  
    67.         GetFnPtr fntblptr, 167, fnptr   ; get pointer to NewStringUTF
    68.  
    69.         push offset ErrorMsg        ; push parameters for
    70.         push JNIEnv               ; NewStringUTF
    71.  
    72.         call [fnptr]            ; call NewStringUTF
    73.  
    74.     .else
    75.         invoke MessageBox, NULL, Message, addr Caption, 64
    76.  
    77.         push Message
    78.         push Msgptr
    79.         push JNIEnv
    80.  
    81.         call [fnptr]                  ; release string
    82.  
    83.  
    84.         GetFnPtr fntblptr, 167, fnptr   ; get pointer to NewStringUTF
    85.  
    86.         push offset SccsMsg     ; push parameters for
    87.         push JNIEnv               ; NewStringUTF
    88.  
    89.         call [fnptr]            ; call NewStringUTF
    90.  
    91.     .endif
    92.  
    93.     ret
    94.  
    95. Java_ShowMessage_HelloDll endp
    96.  
    97. End hwEntry
     
  2. GoldFinch

    GoldFinch New Member

    Публикаций:
    0
    Регистрация:
    29 мар 2008
    Сообщения:
    1.775
    а в чем проблема-то? за тебя сделать?