Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:14:18+00:00 2026-06-13T21:14:18+00:00

I have a dll coded in Delphi XE2 with the following code: procedure xMain(MSG:String);export;

  • 0

I have a dll coded in Delphi XE2 with the following code:

procedure xMain(MSG:String);export;
begin
  MessageBox(0,PWideChar(MSG),'Title',0);
end;

exports xMain;

Now, I am importing this function in a FASM application like so:

library  dllfile, "testdll.dll"

import   dllfile,\
         xMain,   "xMain"

And utilizing is as so:

section ".data" data readable writeable

szMSG     db "Message from FASM application!",0

section ".code" code readable executable

invoke    xMain,szMSG

But the resulting messagebox appears with distorted characters as so:

enter image description here

That is the exact result of the function call.

How do I go about solving this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:14:19+00:00Added an answer on June 13, 2026 at 9:14 pm

    Here are two working samples (using FASM 1.70.03 for Windows):

    Ansi version,

    dll:

    library testdll;
    
    uses
      windows;
    
    procedure xMain(MSG: PAnsiChar); export; stdcall;
    begin
      MessageBoxA(0, PAnsiChar(MSG), 'Title', 0);
    end;
    
    exports xMain;
    
    begin
    end.
    

    exe:

    format PE CONSOLE 4.0
    entry start
    
    include 'win32a.inc'
    
    section '.code' code readable executable
      start:
        invoke xMain, szMSG
        invoke ExitProcess, 0
    
    section '.data' data readable writeable
        szMSG db 'Message from FASM application!', 0
    
    section '.idata' import data readable writeable
      library kernel32, 'kernel32.dll',\
              dllfile, 'testdll.dll'
    
      include 'api\kernel32.inc'
    
      import dllfile,\
             xMain, 'xMain'
    

    Unicode version,

    dll:

    library testdll;
    
    uses
      windows;
    
    procedure xMain(MSG: PChar); export; stdcall;
    begin
      MessageBox(0, PChar(MSG), 'Title', 0);
    end;
    
    exports xMain;
    
    begin
    end.
    

    exe:

    format PE CONSOLE 4.0
    entry start
    
    include 'win32w.inc'
    
    section '.code' code readable executable
      start:
        invoke xMain, szMSG
        invoke ExitProcess, 0
    
    section '.data' data readable writeable
        szMSG du 'Message from FASM application!', 0
    
    section '.idata' import data readable writeable
      library kernel32, 'kernel32.dll',\
              dllfile, 'testdll.dll'
    
      include 'api\kernel32.inc'
    
      import dllfile,\
             xMain, 'xMain'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the following code in a number of applications to load .DLL
I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,
I have a Delphi DLL that contains the following types: type TStepModeType = (smSingle,
I have Delphi 2010 built DLL with two methods: function Foo1(a, b: Integer):PChar; export;
I have a dll in C# which returns a class object. DLL code: Person.cs:
I have a C++ DLL with code like this: LogMessage( Hello world ); try
I have a fortran (unmanaged code) dll as the calculation engine, and a C#
I have a DLL that's compiled, and I don't have the source code for
I have a .NET assembly DLL that is created on-the-fly from pre-compiled code in
I've compiled C# code into a DLL, but have little experience with them. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.