|
tdnxxx444 wrote: Okay. Where would the above file you mentioned be locationed? On my website with the email client?
Ignore my earlier suggestion.
tdnxxx444 wrote: I looked at how they do it for the hotmail client that is built into internet explorer and it seems to use a DLL file.
I'm sure that IE uses dozens of DLL files. That sort of goes without saying.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
hey, I am almost certain that the problem with my dll at this point is an access violation caused by writting to a file. I have stripped out all other code but that, and it fails, I strip out just that and the rest succeeds. So, I know it is with the writting to the file, which is causing an access violation.
I placed returns strategically through out the source and I know that it is behaving accordingly as planned and should not cause a violation, however, it is.
I have a setup similar as follows:
while (blah is blah) { // run till judgment day
out = fopen("test.txt", "a");
for (blah = 0 to length of header) { // loop till blah equals header length
fprintf(out, some data)
}
fclose(out);
} // end while
and that is pretty much it, in a nutshell. The problem is unknown to me, because this works fine in an exe I built --I am trying to port my code to dll.
I am starting to think that I can NOT work with a dll like I could a VB module. It seems the minute I start to write to the file, it will loop through the for 5 times and then crash, if I don't loop, it will write one time just fine.
I hope that I haven't explained all help away and that my question is clear. I need to find out why I can not continously write to a file from a DLL. Why it is causing an access violation, per debug. And what I can do to fix it or if I should stop trying to do the impossible --I assume at this point that this is impossible to accomplish from a DLL.
If you need more info, please let me know. I thank you in advance.
-- modified at 13:41 Wednesday 5th April, 2006
bold = modified
|
|
|
|
|
borono wrote: out = fopen("test.txt", "a");
Why are you opening the file in the while loop?
borono wrote: I hope that...my question is clear.
Given that you did not show the exact code that is causing the problem, it's going to be hard to offer any real help.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Without seeing your real code, ie. without all the blah's, it's gonna be a little hard to find your problem. But one thing does stand out. Each time you loop, you are opening the file, then you close it after the loop. This is an uneven ratio of open/close. You should really open the file before the loop, do the wrinting inside the loop, close it after the loop.
|
|
|
|
|
I tried your suggestions, but they didn't seem to help --same results. No one has said this is impossible, so I am glad about that. And, my code is so long at this point, I thought to post it would be unbearable. However, if either one of you would like me to mail it to you, I would be more than willing to zip it right up and send it on over. Let me know on that.
I just don't understand why it would work in my exe but not in my dll? The format I showed you is the same for the exe and it works flawlessly, so I am baffeled.
Anyway, an access violation probably isn't writing to the file, it is trying to reference bad memory, right? But, when I remove the writing portion, it works fine. I bet it is this here:
fprintf(out, "%.2x", pkt_data[i-1]);
I defined pkt_data[i-1] as:
const u_char *pkt_data;
but in my exe I defined it as simply:
u_char *pkt_data;
...could that be the reason. Because, that is the only thing that changed during the transition. It kept complaining about not being able to make the conversion.
I hope that provides what you need. If you need more, let me know and also I can send my code via email to whoever wants to give it a shot. thanks in advance.
|
|
|
|
|
It sounds to me like you are trying to write an unitialised variable. When you define a variable as const, it must be initialised with something, and cannot be changed for the duration of the exe.
I have a feeling you are trying to write data to u_char somewhere and it isn't happening. Remove the const, and instead set the memory and zero it. When you come to use it later simply test it.
|
|
|
|
|
Hey, thanks for the reply. Here is the result of removing const, minus setting the memory and zeroing it, because I am not sure what that means or how to do that. I am still quite new. Hopefully, this provides a better description of the 0xc0000005 access violation error I am having and why.
ERROR: C:\test.cpp error C2664: 'pcap_next_ex' : cannot convert parameter 3 from 'unsigned char ** ' to 'const unsigned char ** '
Caused by: u_char *pkt_data
Prevents error: const u_char *pkt_data
Here is where it is intialised: while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0)
Here is where it fails: (5 times through)
if (i < 7) { //dst address (ETH)
fprintf(out, "%.2x", pkt_data[i-1]);
if (i > 0 && i < 6) { fprintf(out, ":"); } else { fprintf(out, "\neSrc="); }
I am sorry, but I do not know what you meant by: "...set the memory and zero it. When you come to use it later simply test it." Can I see an example?
If you need more info, let me know. Thanks in advance.
|
|
|
|
|
borono wrote: am sorry, but I do not know what you meant by: "...set the memory and zero it. When you come to use it later simply test it." Can I see an example?
sure:
unsgined char *foo;
foo = new unsigned char [100];
ZeroMemory(foo,sizeof foo);
int size = strlen((char *)foo);
strcpy((char *)foo,"Some random string");
if (!foo)
MessageBox(0,"foo is still empty",0,0);
delete foo;
As for your code, have you checked the size of pkt_data? You are using it as an array, but are you sure it is correctly being initialised? It's hard to see from your code since you do it in a while loop and there is no specified number of loops.
You later use if(i<7) which may be reading past the end of your array. Watch the values of i at this point. I would also put a check for the size there: if ((i<7)&&(i<strlen(pkt_data)).
If you have further problems, and if you are using VC6, I can take a look at your project.
|
|
|
|
|
waldermort wrote: Watch the values of i at this point.
Especially when i is equal to 0. Then, referencing an array with -1 would be very suspicious.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
borono wrote: could that be the reason.
If you suspect it is, then try:
fprintf(out, "%.2x", 123);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
@DavidCrow
Good idea and I tried that just now and it still failed after five times through. I have yet to try waldermort's suggestion, so let me try that here in a few hours, after I get off work and I will let you know if that fixed it. I am sure it is something very simple. I write in assembler too and when I first started I kept forgetting to initialise the DS in my code, went through everything over and over, got real frustrating but showed my code to a friend, he saw it and that was that. --something so simple it hurts. I bet that is what this is too.
Im off in three hours, talk to you again then. thanks guys.
|
|
|
|
|
borono wrote: Good idea and I tried that just now and it still failed...
Which indicates the problem (probably) has nothing to do with pkt_data .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I think your right, I am about to send my project or source to waldermort -- as soon as he tells me what he preffers. Hopefully, he will be able to look through it and correct the problem, or at least identify it better than I have.
I want to say, yeah it is the pkt_data variable, because when it is non-existant, my dll works, when it is existant, it fails. So it can't be the device I am reading from, which is what I first assumed. Then I thought maybe it was the file output portions, but if I remove that it still fails. I have no idea whatsoever.
It's a riddle. I am stumped.
best regards
-- modified at 21:50 Thursday 6th April, 2006
Eureka. I have it working. After picking at it, it turns out I was leading us completly the wrong way --miles away. It happened to be from a variable further down in the code that deals with the hex dumpage, it becomes corrupt after a few times through the loop. Why, I have no idea as of now. However, it is now printing to the file as intended.
best regards
|
|
|
|
|
Hi ya'all,
I'm sure this might be a very easy and simple thing but I would like to find out how to package my project application so it can run without the developing environment; yes, just want to make it executable. Any pointers will be appreciated.
Regards...
|
|
|
|
|
first of all, build it in release mode.
then, use the "Dependency Walker" tool to find which DLL are required
provide them with your exe, and use installshield (or any install packager) to provide an installer if you like...
|
|
|
|
|
Hi,
I want to query, modify and write a REG_MULTI_SZ values from Registry.Can anyone pleeeease show me some code samples.
Thanks in advance.
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
Hello!
I'm just a basic MFC user. Mostly I do my UIs in resource editor in VS.NET 2003. I know how to handle BN_CLICKED message from button and do something with it (trough message map). But now I have a problem. I should do something on button "press" and something different on button "release". It's the situation when event is dispatched on press and release not just release like it is the case with BN_CLICKED. Is it even possible?
Thank you for all the help.
Best regards,
Rostfrei
|
|
|
|
|
WM_LBUTTONDOWN and WM_LBUTTONUP should do
|
|
|
|
|
Can you please give me more instructions? Like I said I am using resource editor for it. What to type into message map?
Rostfrei
|
|
|
|
|
do you mean LButtonDown??
Regards,
FarPointer
|
|
|
|
|
What do you mean by LButtonDown? I just want do something on button down and something else on button up.
Rostfrei
|
|
|
|
|
|
Which means you need to supply handlers for the WM_LBUTTONDOWN and WM_LBUTTONUP messages.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|