Good evening all. I'm stuck. :(
I've written a program that is SUPPOSED to compare 2 strings. It assembles and links without error. However when i execute windows throws an error "Windows cannot access the specified device, path, or file. you may not have the appropriate permissions to access the item." This happens when i use CompareString, lstrcmp, or even lstrcat.
Here is the relevant code:
----CODE BEGINS-------
.386p
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
...
.data
ClassName db "SimpleWinClass",0
AppName db "System Time v 1.1",0
FontName db "script",0
timeFormat db "HH':'mm':'ss tt"
dbZulu db "Zulu Time",0
dbLocal db "Local Time",0
dbText db "BEDTIME!!!!!",0
dbCaption db "ALERT",0
dbAlarmTime db "02:05:00 AM",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
ThreadID DWORD ?
Rect RECT <?>
TestString db ?
TestString2 db ?
strucTime SYSTEMTIME <?>
.code
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUCT
LOCAL hfont:HFONT
.IF uMsg==WM_DESTROY
invoke KillTimer,hWnd,ID_TIMER
invoke KillTimer,hWnd, ID_TIMER1
invoke PostQuitMessage,NULL
xor eax,eax
.ELSEIF uMsg==WM_CREATE
invoke SetTimer, hWnd,1, 1000, 0
invoke SetTimer, hWnd,2, 990, 0
xor eax,eax
.ELSEIF uMsg==WM_TIMER
.if wParam==1
invoke GetTimeFormat, 0, TIME_FORCE24HOURFORMAT, 0, ADDR timeFormat, ADDR TestString, 11
jmp alarmtest
...
WndProc endp
alarmtest:
invoke CompareString,LOCALE_USER_DEFAULT,NORM_IGNORECASE,TestString,9,dbAlarmTime,9
.if EAX==2
jmp alert
.endif
ret
alert:
invoke MessageBox, NULL,dbText,dbCaption,MB_OK
ret
end start
-----END CODE-----
I've tried ADDR teststring, offset teststring, moving the strings into registers,and -1ing and different values for the string sizes in CompareString all to no avail.
I've cut the "standard" code (building the window etc) from this listing. I can add it if necessary.
Does anyone have any ideas? (Why it is that way would help too)
Thanks
Kill -9
well - that isn't an assembly error
sounds more like an os privilege level hiccup
are you running win 7 ?
admin privileges ?
Not sure, the only thing that i can think of is if your running on restricted access and that accessing time/date or locale settings is currently prohibited. Depends on the operating system and the account your using - admin vs ordinary user account under vista/win7? UAC? plus the exe file you created probably doesnt have an associated manifest file which vista/win 7 prob wont be happy about. Also depends on where your running exe from - If its in C:\Program Files\X then vista/win7 might complain about that and give you the message you got.
Try moving exe to a normal folder c:\test for example, check your running with administrator rights on the account your using, check UAC settings, try to change date/time from tray bar - if it wont let you, you know its related to that, if none of that applies then it might be the manifest file thing, which informs vista/win7 a little bit more about your exe and what it might need in terms of access or other things.
here is what i get
Microsoft (R) Macro Assembler Version 6.15.8804
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.
Assembling: try.asm
try.asm(17) : error A2008: syntax error : .
try.asm(46) : error A2006: undefined symbol : ID_TIMER
try.asm(46) : error A2114: INVOKE argument type mismatch : argument : 2
try.asm(47) : error A2006: undefined symbol : ID_TIMER1
try.asm(47) : error A2114: INVOKE argument type mismatch : argument : 2
try.asm(62) : error A2008: syntax error : .
try.asm(74) : fatal error A1010: unmatched block nesting : .if-.repeat-.while
this assembles without error...
include\masm32\include\masm32rt.inc
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
ID_TIMER equ 1000
ID_TIMER1 equ 1001
.data
ClassName db "SimpleWinClass",0
AppName db "System Time v 1.1",0
FontName db "script",0
timeFormat db "HH':'mm':'ss tt"
dbZulu db "Zulu Time",0
dbLocal db "Local Time",0
dbText db "BEDTIME!!!!!",0
dbCaption db "ALERT",0
dbAlarmTime db "02:05:00 AM",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
ThreadID DWORD ?
Rect RECT <?>
TestString db ?
TestString2 db ?
strucTime SYSTEMTIME <?>
.code
start:
invoke ExitProcess,0
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUCT
LOCAL hfont:HFONT
.IF uMsg==WM_DESTROY
invoke KillTimer,hWnd,ID_TIMER
invoke KillTimer,hWnd, ID_TIMER1
invoke PostQuitMessage,NULL
xor eax,eax
.ELSEIF uMsg==WM_CREATE
invoke SetTimer, hWnd,1, 1000, 0
invoke SetTimer, hWnd,2, 990, 0
xor eax,eax
.ELSEIF uMsg==WM_TIMER
.if wParam==1
invoke GetTimeFormat, 0, TIME_FORCE24HOURFORMAT, 0, ADDR timeFormat, ADDR TestString, 11
jmp alarmtest
.endif
.endif
WndProc endp
alarmtest:
invoke CompareString,LOCALE_USER_DEFAULT,NORM_IGNORECASE,TestString,9,dbAlarmTime,9
.if EAX==2
jmp alert
.endif
ret
alert:
invoke MessageBox, NULL,dbText,dbCaption,MB_OK
ret
end start
wow folks, thanks for the quick response.
UAC shouldn't be an issue, I'm on XP home and running as the admin.
On a lark, I virus scanned it. It came back infected with PSW.ldpinch. Would that cause this issue?
Any suggestions? Assuming i'm not actually infected (which is highly likely because when I remove the Comparestring commands it runs fine)
possibly your AV program has a lock on a file or something
of course, you might actually be infected - who knows
that makes it hard for us to give any good advice :P
Ok. I sorted it out. I think.
AVG apparently thinks something i did is trojan materiel.
I excepted the file from the scan and ran it. after a few tweeks it works as planned.
Has anyone run across this while programming? Dedn?
one last update. i submitted the file to http://virusscan.jotti.org/ and it scanned it. only AVG reported the infection.... rrrgggg
oh yah - several :bg
http://www.masm32.com/board/index.php?board=52.0
this one is just for AVG
http://www.masm32.com/board/index.php?topic=9699.0
Guys, seriously? I leave you alone for a short while, and this is what happens?! ::)
killdash9:
When you reference a string, you give a pointer to it, not the contents of the string itself.
So the correct form is actually:
invoke CompareString,LOCALE_USER_DEFAULT,NORM_IGNORECASE,ADDR TestString,9,ADDR dbAlarmTime,9
The same for the messagebox..