flat assembler
Message board for the users of flat assembler.
Index
> Windows > Returning values in DLL Functions? |
Author |
|
revolution 22 Feb 2011, 00:15
The type of LPCTSTR is dependant upon the unicode setting. Your code always returns LPCSTR.
|
|||
22 Feb 2011, 00:15 |
|
hansdieter 22 Feb 2011, 00:19
the program needs:
Code: LPCTSTR GetString(UINT id, UINT flags) But with the Proc i posted above, it will not show my _test string, instead it shows some kind of japanese characters. |
|||
22 Feb 2011, 00:19 |
|
revolution 22 Feb 2011, 00:21
Is your project unicode?
|
|||
22 Feb 2011, 00:21 |
|
hansdieter 22 Feb 2011, 00:25
Well i don't quite know if the target project is unicode, but here is an example plugin: http://code.google.com/p/rainmeter/source/browse/trunk/Plugins/PluginExample/ExamplePlugin.c
I just want to write a plugin for it, that uses GetString to give a string to the calling progam. full source: Code: ;format PE GUI 4.0 DLL ;FOR 32 BIT DLL format PE64 GUI 4.0 DLL ;FOR 64 BIT DLL entry DllEntryPoint include '../INCLUDE/win64a.inc' ;include '../INCLUDE/win32a.inc' section '.code' code readable writeable executable _test db 'Test',0 _strTest db 'This is a test string',0 _author db 'test',0 _ver dq 1001d proc DllEntryPoint hinstDLL,fdwReason,lpvReserved sub rsp,8*5 mov rax,TRUE ret endp ; VOID Initialize(HWND instance,DWORD iniFile,DWORD section,DWORD ID); proc Initialize hWnd,iniFile,section,id invoke MessageBox,0,_test,NULL,MB_OK mov rax,0 ret endp ; DWORD Update(DWORD id); proc Update id ;local buffer:DWORD ;lea eax,[buffer] ;invoke MessageBox,0,_test,NULL,MB_OK mov eax,0 ret endp ; DWORD GetString(UINT id, UINT flags); proc GetString id,flags mov rax,_test ret endp ; DWORD GetPluginVersion(); proc GetPluginVersion mov rax,_ver ret endp ; DWORD GetPluginAuthor(); proc GetPluginAuthor lea eax, [_author] lea rax, [_author] ;mov eax,_author ret endp ; VOID Finalize(); proc Finalize instance,id mov rax,TRUE ret endp section '.idata' import data readable writeable library user,'USER32.DLL' import user,\ MessageBox,'MessageBoxA' section '.edata' export data readable export 'TEST.DLL',\ Initialize,'Initialize',\ Finalize,'Finalize',\ Update,'Update',\ GetString,'GetString',\ GetPluginAuthor,'GetPluginAuthor',\ GetPluginVersion,'GetPluginVersion' section '.reloc' fixups data discardable |
|||
22 Feb 2011, 00:25 |
|
revolution 22 Feb 2011, 00:28
hansdieter wrote: Well i don't quite know if the target project is unicode ... |
|||
22 Feb 2011, 00:28 |
|
hansdieter 22 Feb 2011, 00:30
Ok, yes it seems to be unicode.
|
|||
22 Feb 2011, 00:30 |
|
revolution 22 Feb 2011, 00:31
http://msdn.microsoft.com/en-us/library/aa383751%28v=vs.85%29.aspx:
Code: #ifdef UNICODE typedef LPCWSTR LPCTSTR; #else typedef LPCSTR LPCTSTR; #endif |
|||
22 Feb 2011, 00:31 |
|
revolution 22 Feb 2011, 00:32
hansdieter wrote: Ok, yes it seems to be unicode. Code: _test du 'This is a test string',0 |
|||
22 Feb 2011, 00:32 |
|
hansdieter 22 Feb 2011, 00:34
It works! Thank you very much. Your help is much appreciated!
|
|||
22 Feb 2011, 00:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.