flat assembler
Message board for the users of flat assembler.

Index > Windows > C/C++ code to FASM, help..!!!

Author
Thread Post new topic Reply to topic
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 19 Apr 2005, 15:55
Code:

#include <windows.h> 
#include "gen_empty.h" 

int init(void); 
void config(void); 
void quit(void);

winampGeneralPurposePlugin plugin = {
  GPPHDR_VER,
  "MyEmpyProject vx.x (gen_empty.dll)", // Plug-in description 
  init,
  config, 
  quit,
}; 

int init() {
  MessageBox(plugin.hwndParent,"Init","",MB_OK); 
  return 0; 
} 

void config() { 
  MessageBox(plugin.hwndParent,"Config","",MB_OK); 
} 

void quit() { 
  MessageBox(0,"Quit","",MB_OK); 
} 

__declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
  return &plugin; 
}

    


this is an c/c++ code, how to do this in FASM
and i try to convert to FASM and my code is like this
Code:
format PE GUI 4.0 DLL
entry DllEntryPoint

include 'win32a.inc'
section '.data' data readable writeable

struct winampGeneralPurposePlugin
        .version      dd ?
        .description  dd ?
        .lpInit       dd ?;offset init
        .lpConfig     dd ?; offset Config
        .lpQuit       dd ?;offset Quit
        .WinAmpHwnd   dd ?;   dd ?
        .hDllInstance dd ?;HINSTANCE ;
ends

Deskripsi db 'MyEmpyProject vx.x (gen_empty.dll)', 0
caption db 'win32asm fasm',0
plugin winampGeneralPurposePlugin
configdesk db 'config',0
initdesk db 'init',0
quitdesk db 'quit',0

section '.code' code readable executable


proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved
        mov     eax,TRUE
        return
endp

mov [plugin.version],10h
mov [plugin.description], Deskripsi
mov [plugin.lpInit], init
mov [plugin.lpConfig], config
mov [plugin.lpQuit], quit
mov [plugin.WinAmpHwnd], 0
mov [plugin.hDllInstance], 0

proc winampGetGeneralPurposePlugin
mov eax, plugin
ret
endp

proc init
invoke  MessageBox,HWND_DESKTOP,initdesk,caption,MB_OK
endp

proc config
invoke  MessageBox,HWND_DESKTOP,configdesk,caption,MB_OK
endp

proc quit
invoke  MessageBox,HWND_DESKTOP,quitdesk,caption,MB_OK
endp

section '.idata' import data readable writeable
        library user,'USER32.DLL'

        import user,\
                MessageBox,'MessageBoxA'

section '.edata' export data readable

export 'winamp2.DLL',\
       winampGetGeneralPurposePlugin, 'winampGetGeneralPurposePlugin'

    


it can compiled, but it's doesn't work in winamp

can any body help...

thanks for the answers

my regard
Senolc_eht

_________________
sorry if i always asking.....
Post 19 Apr 2005, 15:55
View user's profile Send private message Yahoo Messenger Reply with quote
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon 19 Apr 2005, 22:05
this code doesn't execute. try putting it into the exported function:

Code:
proc winampGetGeneralPurposePlugin 
mov [plugin.version],10h 
mov [plugin.description], Deskripsi 
mov [plugin.lpInit], init 
mov [plugin.lpConfig], config 
mov [plugin.lpQuit], quit 
mov [plugin.WinAmpHwnd], 0 
mov [plugin.hDllInstance], 0 
mov eax, plugin 
ret 
endp 
    


second, does the c++ code work when compiled??

_________________
It is better to be on the right side of the devil than in his path.
Post 19 Apr 2005, 22:05
View user's profile Send private message Visit poster's website Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 20 Apr 2005, 17:10
Thanks for the help, but its still doesn't work (the dll is compiled, but still doesn't attact to winamp).

are there any deferent between dll that compiled with FASM and VC++..?

and the c++ code is work (I compile it and it attact to winamp), this code i get from winamp forum (empty plugin SDK).

and was a forget to attact the "gen_empty.h"
this "gen_empty.h" code:
Code:
#ifndef gen_empty_h 
#define gen_empty_h
#include <windows.h> 

typedef struct { 
  int version; 
  char *description; 
  int (*init)(); 
  void (*config)(); 
  void (*quit)(); 
  HWND hwndParent; 
  HINSTANCE hDllInstance; 
} winampGeneralPurposePlugin; 

#define GPPHDR_VER 0x10 

extern winampGeneralPurposePlugin *gen_plugins[256]; 
typedef winampGeneralPurposePlugin * (*winampGeneralPurposePluginGetter)(); 

#endif
    


can any body help....

My regard
Senolc_eht

_________________
sorry if i always asking.....
Post 20 Apr 2005, 17:10
View user's profile Send private message Yahoo Messenger Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 20 Apr 2005, 21:31
some things to try:
First, put the code below into your DllEntryPoint function, before the mov eax, TRUE:return

Code:
mov [plugin.version],10h 
mov [plugin.description], Deskripsi 
mov [plugin.lpInit], init 
mov [plugin.lpConfig], config 
mov [plugin.lpQuit], quit 
mov [plugin.WinAmpHwnd], 0 
mov [plugin.hDllInstance], 0     


Second,
try using the cproc macro instead of the proc macro, and you may have to export the three other functions as well: init, config, quit

Third,
put this line at the end of your dll code, after the export
Code:
section '.reloc' fixups data discardable    


MadMatt
Post 20 Apr 2005, 21:31
View user's profile Send private message Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 21 Apr 2005, 04:27
With this code below I got some action out of winamp:

Code:
format PE GUI 4.0 DLL
entry DllEntryPoint

include 'win32a.inc'
section '.data' data readable writeable

struct winampGeneralPurposePlugin
        .version      dd ?
        .description  dd ?
        .lpInit       dd ?;offset init
        .lpConfig     dd ?; offset Config
        .lpQuit       dd ?;offset Quit
        .WinAmpHwnd   dd ?;   dd ?
        .hDllInstance dd ?;HINSTANCE ;
ends

Deskripsi db 'MyEmpyProject vx.x (gen_empty.dll)', 0
caption db 'win32asm fasm',0
plugin winampGeneralPurposePlugin
configdesk db 'config',0
initdesk db 'init',0
quitdesk db 'quit',0

section '.code' code readable executable


proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved
        mov     eax,TRUE
        return
endp

proc winampGetGeneralPurposePlugin
     enter
     mov [plugin.version],10h
     mov [plugin.description], Deskripsi
     mov [plugin.lpInit], init
     mov [plugin.lpConfig], config
     mov [plugin.lpQuit], quit
     mov [plugin.WinAmpHwnd], 0
     mov [plugin.hDllInstance], 0
     mov eax, plugin
     return
endp

proc init
     enter
     invoke  MessageBox,HWND_DESKTOP,initdesk,caption,MB_OK
     return
endp

proc config
     enter
     invoke  MessageBox,HWND_DESKTOP,configdesk,caption,MB_OK
     return
endp

proc quit
     enter
     invoke  MessageBox,HWND_DESKTOP,quitdesk,caption,MB_OK
     return
endp

section '.idata' import data readable writeable
        library user,'USER32.DLL'

        import user,\
                MessageBox,'MessageBoxA'

section '.edata' export data readable

export 'winamp2.DLL',\
       winampGetGeneralPurposePlugin, 'winampGetGeneralPurposePlugin'

section '.reloc' fixups data discardable    
Post 21 Apr 2005, 04:27
View user's profile Send private message Visit poster's website Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 21 Apr 2005, 15:13
Thank for the help, but in my opinion the wrong is in the converting this code
Code:
winampGeneralPurposePlugin plugin = { 
  GPPHDR_VER, 
  "MyEmpyProject vx.x (gen_empty.dll)", // Plug-in description  
  init, 
  config,  
  quit, 
};  
    


is this really give same effect with this code in fasm

Code:
     mov [plugin.version],10h 
     mov [plugin.description], Deskripsi 
     mov [plugin.lpInit], init 
     mov [plugin.lpConfig], config 
     mov [plugin.lpQuit], quit 
     mov [plugin.WinAmpHwnd], 0 
     mov [plugin.hDllInstance], 0
    


i search in the net and found in Iczelion website (win32assembly.online.fr) an example (in masm, i guess) that attact, but it still have code like this (in data.inc)
Code:
plugin winampGeneralPurposePlugin <IN_VER,\
                                   offset szPluginDescription,\
                                   offset init,\
                                   offset config,\
                                   offset quit,\
                                   0,\ ; main window - winamp window
                                   0>  ;dll hInstance 
    


before and after thanks for the help, you all have a good work

my regard
Senolc_eht

ps. i never try the masm code (don't have masm compiler), and Torrey (Sir, Mr, or...? what should i call u? Very Happy ) can you give my the compiled dll, (couse it's doesn't work yet in my Winamp, thanks)

btw, i use winamp v5.03a (x86) -mar 26 2004 and use FASM v1.60


Description:
Download
Filename: mdplug.zip
Filesize: 8.56 KB
Downloaded: 358 Time(s)


_________________
sorry if i always asking.....
Post 21 Apr 2005, 15:13
View user's profile Send private message Yahoo Messenger Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 22 Apr 2005, 04:19
So far it's a boring night at work, so I think I will reverse and recode gen_tray.dll in the plugins directory of winamp so you have a fasm source so you have an example to look at. Shouldn't take me too long. Smile


Description: [edit] Here was a quick screen shot that I had last. Didn't get as far as I thought I would have, but then again I'm doing real work inbetween coding spurts. I understand enough of the plugin features to pretty much make it do anything now, which I might
Filesize: 45.64 KB
Viewed: 5925 Time(s)

screen.jpg


Post 22 Apr 2005, 04:19
View user's profile Send private message Visit poster's website Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 22 Apr 2005, 12:12
Good work, can i have the code Smile , so i can configure what wrong with me (not my code Smile) , Thanks

my regard
Senolc_Eht

_________________
sorry if i always asking.....
Post 22 Apr 2005, 12:12
View user's profile Send private message Yahoo Messenger Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 25 Apr 2005, 07:44
I attached below the simple source code for the winamp plugin that displays the message boxes at initialize, config, and quit that you were trying to get working at the beginning.

[edit]

Also remember that after your init proc has executed EAX needs to equal zero, an easy xor eax,eax takes care of that before you return.


Description: Source code, and DLL for the simple plugin.
Download
Filename: gen_plug.zip
Filesize: 1.44 KB
Downloaded: 402 Time(s)

Post 25 Apr 2005, 07:44
View user's profile Send private message Visit poster's website Reply with quote
senolc_eht



Joined: 22 Mar 2004
Posts: 57
Location: Indonesia
senolc_eht 28 Apr 2005, 07:33
Thanks you Torrey, now i Know if fasm can do that kind things

a new lesson for me, it's make some thing easier..


my regard
Senolc_eht

_________________
sorry if i always asking.....
Post 28 Apr 2005, 07:33
View user's profile Send private message Yahoo Messenger Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 28 Apr 2005, 08:10
FASM's only limitation is your imagination. The more creative the person, the more creative the code, but that's just my own opinion.
Post 28 Apr 2005, 08:10
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.