Author Topic: How to use ExpandEnvironmentStringsA in NASM ?  (Read 4233 times)

hpuser

  • Guest
How to use ExpandEnvironmentStringsA in NASM ?
« on: December 25, 2012, 10:14:58 PM »
Hello all,

i need to use the function ExpandEnvironmentStringsA in nasm to use shourtcuts such as %appdata% and %tmp% .. etc.

i tried an example on the internet but it wont running and give errors, i think the problem with parameters.

can i find complete illustrated example about using this function...

thanks alot !

jj2007

  • Member
  • *****
  • Posts: 13946
  • Assembly is fun ;-)
    • MasmBasic
Re: How to use ExpandEnvironmentStringsA in NASM ?
« Reply #1 on: December 26, 2012, 01:01:53 AM »
Post the code that throws errors, and the errors themselves, and we'll see if we can help you.

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: How to use ExpandEnvironmentStringsA in NASM ?
« Reply #2 on: December 26, 2012, 01:07:33 AM »
pretty simple function
more than likely, the destination buffer is too small
the return value tells you the size of the required buffer

hpuser

  • Guest
Re: How to use ExpandEnvironmentStringsA in NASM ?
« Reply #3 on: December 26, 2012, 05:26:04 PM »
   jmp GetFilePAth         
FilePAthReturn:           
    pop ecx 
             
   xor Eax,Eax             
   Push Eax
   Push ebx
   Push ecx
   ;Call ExpandEnvironmentStringsA
   call [ebp+0x10]

GetFilePAth:
    call FilePAthReturn
    db "%appdata%\xxx.xx"     
    db 0x00   

this is code don't work correctly

thanks alot !

jj2007

  • Member
  • *****
  • Posts: 13946
  • Assembly is fun ;-)
    • MasmBasic
Re: How to use ExpandEnvironmentStringsA in NASM ?
« Reply #4 on: December 26, 2012, 07:46:53 PM »
That it doesn't work is a big surprise indeed :eusa_boohoo:

;Call ExpandEnvironmentStringsA
   call [ebp+0x10]

What is that, an attempt to cheat the AV brigade?

GetFilePAth:
What's your error message on that, "symbol not found"?

    call FilePAthReturn
    db "%appdata%\xxx.xx"

So Nasm knows by some magic that these two lines are in different segments?
Where did you copy that code from? Or do you pretend it's your own, and you understand what you are doing??