32-bit Windows Assembly coding
From: Nathan C. Baker (nbaker2328_at_charter.net)
Date: 12/18/03
- Next message: Nathan C. Baker: "Re: 32-bit Windows Assembly coding"
- Previous message: Jumbo: "Re: allocating memory."
- Next in thread: Nathan C. Baker: "Re: 32-bit Windows Assembly coding"
- Reply: Nathan C. Baker: "Re: 32-bit Windows Assembly coding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 18 Dec 2003 07:43:05 -0500
Okay, I am trying some Win32 programming using MASM32 and attempting to use
the MASM32.LIB functions that come with it. I am starting with one of the
example sources that came with the package so I can concentrate on the
critical code and not have to debug the rest of the framework. So, I pick
out a function...
Hmmm.. XorData proc lpSource:DWORD,ln:DWORD,lpKey:DWORD,lnKey:DWORD
looks like a good one to start with, and I will load up the FSTACKER.ASM
found in the EXAMPLE6 directory and just make some modifications to make
practical use of this function. First, I insert the neccessart INCLUDES and
PROTO statements:
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
XorData PROTO :DWORD,:DWORD,:DWORD,:DWORD
Then, I edit the ".ELSEIF ax==IDM_STACK" section to look like this:
invoke GetDlgItemText,hWnd,IDC_IN1,ADDR File1, 512
invoke GetDlgItemText,hWnd,IDC_IN2,ADDR File2, 512
invoke GetDlgItemText,hWnd,IDC_OUT,ADDR File3, 512
invoke CreateFile, ADDR File1, GENERIC_READ, NULL, NULL, OPEN_EXISTING,
NULL, NULL
.if eax==INVALID_HANDLE_VALUE
invoke MessageBox, NULL, ADDR File1, ADDR Nonce, MB_ICONERROR
jmp Errore
.endif
mov hFile1,eax
invoke GetFileSize, eax, NULL
mov File1Size,eax
invoke CreateFileMapping, hFile1, NULL, PAGE_READONLY,NULL,NULL,NULL
mov hMFile1,eax
invoke MapViewOfFile, eax, FILE_MAP_READ, NULL, NULL, NULL
mov hMVFile1,eax
invoke CreateFile, ADDR File2, GENERIC_READ, NULL, NULL, OPEN_EXISTING,
NULL, NULL
.if eax==INVALID_HANDLE_VALUE
invoke MessageBox, NULL, ADDR File2, ADDR Nonce, MB_ICONERROR
jmp Errore
.endif
mov hFile2,eax
invoke GetFileSize, eax, NULL
mov File2Size,eax
mov edx, File1Size
mov eax,edx ;<<< was add eax,edx
mov File3Size,eax
invoke CreateFileMapping, hFile2, NULL, PAGE_READONLY,NULL,NULL,NULL
mov hMFile2,eax
invoke MapViewOfFile, eax, FILE_MAP_READ, NULL, NULL, NULL
mov hMVFile2,eax
invoke XorData, hMVFile1, ADDR File1Size, hMVFile2, ADDR File2Size ;<<< OUR
NEW FUNCTION
invoke CreateFile, ADDR File3, GENERIC_READ or GENERIC_WRITE, NULL, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
mov hFile3,eax
invoke SetFilePointer, eax, File3Size, NULL, FILE_BEGIN
invoke SetEndOfFile, hFile3
invoke SetFilePointer, hFile3, 0, NULL, FILE_BEGIN
invoke WriteFile, hFile3, hMVFile1, File1Size, ADDR BytesWritten, NULL
;invoke WriteFile, hFile3, hMVFile2, File2Size, ADDR BytesWritten, NULL
invoke UnmapViewOfFile, hMVFile1
invoke UnmapViewOfFile, hMVFile2
invoke CloseHandle, hMFile1
invoke CloseHandle, hMFile2
mov hMFile1,0
mov hMFile2,0
invoke CloseHandle, hFile1
invoke CloseHandle, hFile2
invoke CloseHandle, hFile3
I have gotten rid of all the Assemble-time errors and have produced an EXE.
However, the program doesn't DO ANYTHING when run. Why?
- Next message: Nathan C. Baker: "Re: 32-bit Windows Assembly coding"
- Previous message: Jumbo: "Re: allocating memory."
- Next in thread: Nathan C. Baker: "Re: 32-bit Windows Assembly coding"
- Reply: Nathan C. Baker: "Re: 32-bit Windows Assembly coding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|