News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Weird error

Started by Nilrem, May 04, 2005, 02:25:08 PM

Previous topic - Next topic

Nilrem

Sorry about the vague title but I didn't know what to put other then 'Weird error'.
Ok in my .inc file under the .data section I have this


fiveofakind_file db "FiveOfAKind.exe",0
solo_file db "Solo.exe",0

robottsoorg_val db 075h, 00Ah, 0BAh, 098h, 093h      ;original values


Now if I use my drop down menu and the file isn't there, and say the file was fiveofakind then it will say fiveofakind.exe could not be found (that is what it is supposed to say):

however if I have this layout:


solo_file db "Solo.exe",0
fiveofakind_file db "FiveOfAKind.exe",0

robottsoorg_val db 075h, 00Ah, 0BAh, 098h, 093h      ;original values


Then the error message says fiveofakind.
instead of fiveofakind.exe

So it would be wise to say on the first code I posted:

fiveofakind_file db "FiveOfAKind.exe",0
solo_file db "Solo.exe",0

robottsoorg_val db 075h, 00Ah, 0BAh, 098h, 093h      ;original values

The solo should be reported as solo. but no it actually comes up as solo.exe
very weird error, maybe hard to understand what I am saying but if you try a basic program maybe it will happen to you.

mnemonic

Errrr... uh... where do you get the error message? Compile time, runtime... ?
Sorry, but I can neither follow your description nor can I understand what you mean.

EDIT: Corrected some spelling mistakes.
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Nilrem

Sorry for some reason I had the presumption that the nature of my program was known.

Ok basically I have a dialog window with a drop-down menu and some buttons.
Each list on the dropdownmenu is a name of a file.
For example:
Solo.exe is a file,
FiveOfAKind.exe is a file.

You select the file from the drop-down menu and click the button (Open).
If it cannot be found or opened you will get a messagebox with the message been along the lines of:
"filename.exe could not be opened.".

Is that a little better now?

Mark Jones

It sounds like you are only reading a set number of bytes from each string. With some API's you can limit the number of characters "read" such as in GetDlgItemText:


UINT GetDlgItemText(

    HWND hDlg, // handle of dialog box
    int nIDDlgItem, // identifier of control
    LPTSTR lpString, // address of buffer for text
    int nMaxCount // maximum size of string
   );
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

mnemonic

Ok, that point is clear right now.
But I can't still figure out why you get the "error". Therefor I'd need the whole code you are using.
Guessing is always hard and (to steal from someones sig) you risk beeing wrong half of the time :wink

EDIT: Maybe Mark solved your prob.
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Nilrem

I'll try and explain a little better. 8-)

Let's say I try and open (through my program) a file called FiveOfAKind.exe if it cannot find it it should give this error:
"FiveOfAKind.exe could not be found."

This happens only if I have this code in my .inc file

.data
fiveofakind_file db "FiveOfAKind.exe",0
solo_file db "Solo.exe",0

robottsoorg_val db 075h, 00Ah, 0BAh, 098h, 093h      ;original values


However if I have it this way round in the .inc file:

.data
solo_file db "Solo.exe",0
fiveofakind_file db "FiveOfAKind.exe",0

robottsoorg_val db 075h, 00Ah, 0BAh, 098h, 093h      ;original values

Then the error handling message is "FiveOfAKind. could not be opened." instead of "FiveOfAKind.exe could not be opened."

Hope this makes more sense, thanks for trying.

mnemonic

As I said: Without the code (not only the data) I can't tell you more.
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Mark Jones

Nilrem, fiveofakind_file and solo_file are simply static pointers to the strings in memory. As long as the strings are indeed intact and have not been modified, then any string functions should return the full string. The only other exception is when the API or function being used purposely limits the number of returned bytes, such as with GetDlgItemText. There should be no reason why the order of the declared strings would matter... unless only a set number of bytes were being read, or, something was overwriting your memory.

Sounds like you need to load this into a debugger and find out what's really going on... theorizing could take forever. Try imbedding an INT 3 or NOP into your code where you think the problem is starting, and open the .exe with a debugger such as OllyDbg. Then you can search for the NOP (ctrl-F) and place a breakpoint on it (F2) or just run the program (F9) to halt on an INT 3, where you can then check the values of the registers and variables in memory. I'm sure we could talk Olly-specifics in The Soap Box if need be. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Nilrem

Thanks. I've been using Olly for about a year and a half so I'm pretty clued up on it. Thanks I will give that a go soon, not right now because it has been solved, but why it happened would be very interesting.

Mark Jones

Indeed, let us know what you find out. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08