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

  • SEARCH
  • Home
  • 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 8573337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:13:33+00:00 2026-06-11T19:13:33+00:00

I am trying to do a simple task in FASM that I have literally

  • 0

I am trying to do a simple task in FASM that I have literally been struggling with for about two hours now.

I have commented the code with the goal and the issue, but I will explain.

I am trying to store the path to a specific file into a variable. The file is located in the Temp Directory. So I must first get the temp path, then append the file name to the end of the temp path.

I am trying to do this two times sequentially. But for some reason, my resulting strings end up “screwy”.

My current code is as follows:

include "win32ax.inc"

entry start

section ".data" data readable writeable

TmpDir          rb 256d
aSTR            dd ?
bSTR            dd ?
cSTR            db "aFILE.txt",0
dSTR            db "bFILE.txt",0

section ".code" code readable executable

start:

        ;The goal is to get two seperate strings like so:
        ;1 - C:\PATH-TO-TEMP-DIR\aFILE.txt in "aSTR"
        ;2 - C:\PATH-TO-TEMP-DIR\bFILE.txt in "bSTR"

        ;Get temp directory
        invoke  GetTempPath,TmpDir,TmpDir

        ;Copy tempdir into aSTR
        invoke  lstrcpy,aSTR,TmpDir
        ;Add "aFILE.txt" to the end of aSTR
        invoke  lstrcat,aSTR,cSTR

        ;Copy tempdir into bSTR
        invoke  lstrcpy,bSTR,TmpDir
        ;Add "bFILE.txt" to the end of bSTR
        invoke  lstrcat,bSTR,dSTR

        ;Results in "C:\UC:\Users\user\AppData\Local\Temp\AppData\Local\Temp\A\\
        ;Instead of "C:\Users\user\AppData\Local\Temp\aFILE.txt"
        invoke  MessageBox,0,aSTR,"Test",0
        ;Results in "C:\Users\user\AppData\Local\Temp\AppData\Local\Temp\A\\"
        ;Instead of "C:\Users\user\AppData\Local\Temp\bFILE.txt"
        invoke  MessageBox,0,bSTR,"Test",0

        invoke  ExitProcess,0

section ".idata" import readable writeable

        library kernel32,               "KERNEL32.DLL",\
                user32,                 "USER32.DLL"

        import  kernel32,\
                lstrcpy,                "lstrcpy",\
                lstrcat,                "lstrcat",\
                GetTempPath,            "GetTempPathA",\
                ExitProcess,            "ExitProcess"

        import  user32,\
                MessageBox,             "MessageBoxA"

Any help resolving this would be greatly appreciated. Thanks!

  • 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-11T19:13:35+00:00Added an answer on June 11, 2026 at 7:13 pm

    Hmm. one of your strings is:

    C:\UC:\Users\u...
    ^^^^
    

    almost as if there’s only four bytes for storing it before the next item in memory.

    I wonder if that could be anything to do with the fact that you’re using dd to define the space for it. Nudge, nudge, wink, wink.


    Enough humour, time for a more serious response. Why do you think that:

    aSTR            dd ?
    

    will give you enough space to store a path name? Surely it should be something more like:

    aSTR            rb 512d
    

    which should give you heaps of space (and similarly for bSTR).


    In fact, you’re first cpy/cat operation also overwrites cSTR and dSTR, making it even harder to figure out what happens with the second operation.

    Try reserving enough space (as per above) then giving it another shot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to perform a very simple task here. I have an <ol> that contains
I'm trying to do a simple task with jQuery: I have a list of
I have a very simple task I am trying to do in Groovy but
I am trying to do a simple task: I have an editable text field,
I am trying to accomplish a very simple task of loading a WebView that
I've been trying to write a program for the last several hours that does
I have a simple task that should have a simple solution, but I have
I am trying to complete a seemingly simple task that has turned into a
I have been trying to figure out what I figure is a pretty simple
I'm trying to accomplish one simple task (but is not simple for me). I

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.