Can someone tell me please, that is the best way to find the drive (letter) of my runnig programm! Is there an API or must I analyse the command line? thanks
I recommend you to use the GetModuleFileName api. The first letter of your buffer is the drive where your program is stored. DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // file name of module DWORD nSize // size of buffer ); I can write a little example if you want. Hope this helps. Happy coding.
Thanks for the fast replay! It works fine! push 256 push offset lpFilename push NULL call GetModuleFileName mov eax, offset lpFilename mov eax, mov , al mov , ah Or did you have an better idea how to move ax ('C:') in lpDir?
I was happy to help you. Try to push 2 instead of 256... I think you will have the two first characters of the program path in your destination buffer... so, it will save some instructions... space, and run time :). Happy coding.
Thanks! It works with three cause one letter that the api sends back is 00h for end of line. But this one works really good. push 3 push offset lpFilename push NULL call GetModuleFileName mov eax, offset lpFilename mov eax, push ax pop word ptr