I am trying to create a file under C:\ in Masm code.
but can never success. I don't know where is wrong with the code.
INCLUDE Irvine32.inc
.data
fileName BYTE "C:\\haha.txt",0
fileHandle HANDLE ?
.code
main PROC
INVOKE CreateFile,
ADDR filename, GENERIC_WRITE, DO_NOT_SHARE, null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,0
exit
main ENDP
END main
if I change the
fileName BYTE "haha.txt",0
it will success write the file haha.txt on the program's folder.
i dont understand why it does not write out to C:\
also, i am using visual studio 2013 and i run the program by run it under debug,start without debugging.
It is a permission problem. If you run the program as administrator, you will see that the file is created.
Just tested it with your code and it works.
Related
I am trying to compile on mingw a program that prints to console using Windows.h functions. Why do I get no output?
C file:
#include <Windows.h>
int main() {
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
WriteConsoleA(out, "hello", 5, NULL, NULL);
return 0;
}
To print to a console your application must be a console application in the first place. A Windows GUI application can
Make sure you linked the application using the -mconsole flag.
Also make sure that you are not running the application from somewhere where the output may disappear right away (like an IDE). Instead open a command prompt and run your .exe file from there to see the output. Or you could add some code to wait for a key in your code so you can see the output before the window closes automatically.
I'm trying to run a MessageBoxA from User32.dll with Rundll32.exe.
As I see in Microsoft references Rundll.exe is for 16-bit applications while Rundll32.exe is for 32-bit ones.
So I write this command :
Rundll32.exe User32.dll,MessageBoxA 0,"Text","Title",0
But nothing shows!
I think there is something wrong with my syntax. Is there anyway to show a MessageBoxA from Rundll32.exe?
I figured out that I could open a file with a specific program with the following batch skeleton code:
START "" <PROGRAM EXE> <FILE>
My question is, if the program denoted by "PROGRAM EXE" is already open (prior to running the batch script), is there a way for the batch script to make the program open the file into the window that is already open and not into a new window/instance of the program? For reference, the program I am using is JMP and I am opening a CSV file.
Just makes things less cluttered.
The solution to this was directed to me from a JMP discussion forum, utilizing the "/shellopen" parameter.
START "" /shellopen <PROGRAM EXE> <FILE>
I'm having some trouble getting NASM to work at the moment. I have to get it installed for a subject that I'm doing at college. I have Windows 8.1 Pro 64-bit installed. I managed to get NASM installed by downloading the latest version.
Our first task is just to copy the code to a Hello World program and get it running. Here's the code below:
bits 16
org 0x100 ; Start the program at offset 100h
jmp main ; Jump to main program
message: db 'Hello World', 0ah, 0dh, '$'
main: mov dx, message ; Start address of message
mov ah, 09 ; Prepare for screen display
int 21h ; DOS interrupt 21h
int 20h ; Terminate program
So I saved that as prog1.asm and used a batch script that our lecturers gave us to compile it. The batch script is this:
nasm -f bin %1.asm -o %1.com -l %1.lst
When I type in as prog1.asm into cmd it compiles without error, although as soon as I type in prog1 to run the program I get the following error in the cmd window:
This version of C:\Users\########\AppData\Local\nasm\prog1.com is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
I don't know what to do really and no matter what I try or Google, nothing seems to give me a straight answer or a proper solution.
The program you've built is a DOS program - it won't run directly in Windows (you might be able to run it in compability mode in Windows XP/9x, but certainly not on your 64-bit edition of Windows 8.1).
You'll need to run your program in some sort of emulator that can handle DOS programs. Probably the most popular one is DOSBox.
If you choose DOSBox you can use a 3rd party front-end to configure things. Or you can just start up DOSBox, then at DOSBox's prompt type:
mount c: <the directory where prog1.com is located>
c:
prog1
I had the same issue with the same exercise.
I have Windows 7 64bit.
My solution was this:
Downloaded and Installed DosBox
Downloaded 16bit version of NASM from:
http://prdownloads.sourceforge.net/nasm/nsm09838.zip?download
(other versions of NASM gave me weird errors)
Unzipped NASM to c:\nasm16
Using notepad, created prog1.asm file (with containing code) in c:\nasm16\
Copied the "as.bat" file into c:\nasm16\
Ran DosBox, and in Dosbox ran command:
mount c c:\nasm16
Open mounted drive with command:
c:\
ran command:
as prog1
And it worked hooraa! :)
I am writing code to download an app from server in visual studio 2005(VC++). After downloading it when I start running it line 3 does not run the exe file while if I write it as
system("c:/pg/ap/app.exe")
it starts running.
Can anybody tell me why this is happening?
1.const char * str;
2. HRESULT hr = URLDownloadToFile ( NULL, _T("file_path/app.exe"),(LPCWSTR)str,0,NULL);
3. system(str);
Rather then using System() function, try ShellExecute(), it ll solve your problem.
For more help refer this