I'm getting a really wierd error. I started it as an empty .NET project, and everything is posted here but the int main() file:
The program compiles without any errors or warnings reported by the debugger, but when it runs, I get this error:
"An unhandled exception of type 'System.NullReferenceException' occurred in NumberConversion.exe
Additional information: Object reference not set to an instance of an object."
It points to this line inside memcpy.asm:
mov [edi],al ;U - write second byte to destination
using namespace std;
NumMenuOptions = 2; //number of menu options
cout<<"Availible menu options:"<<endl;
for(int i=0; i < NumMenuOptions; i++)
cout<<"Please enter a menu option: [1-"<<NumMenuOptions<<"]: ";
void Menu::PrintMenuOption(int MenuOption)
for(int i=0; i < NumMenuOptions; i++)
MenuOptions[i].OptionNumber = i + 1;
MenuOptions.OptionName = "Decimal -) Binary";
MenuOptions.OptionName = "Binary -) Decimal";
MenuOptions.OptionName = "Exit Program";
MenuOptions.OptionDescription = "Convert a base 10 number to a base 2 number.";
MenuOptions.OptionDescription = "Convert a base 2 number to a base 10 number.";
MenuOptions.OptionDescription = "Exit the program.";
using namespace std;
Menu(); //default constructor
void PrintOptions(); //print all menu options
void PrintMenuOption(int MenuOption); //print a single menu option
void InitializeMenuOptions(); //inits MenuOptions array structure
int NumMenuOptions; //number of menu options
MenuOptionType MenuOptions; //structure of menu options
I have a simple server written in MFC as a dialog box application. I find the page fault to increase and rapidly and this inturn increasing the memory size when there are many TCP connection requests to the server. But as soon as I press the minimize button, the memory abruptly returns to 400K and again starts building up. For testing case, we are using the debug version. Does the debug version have a bug like this (which otherwise means that the release version will not have this bug?)? Is there a much bigger problem in my code?
Please help me.
Thanks in advance
Varchas R S
The memory footprint for Debug versions will be larger than Release versions, but this isn't what you are seeing. This is most likely a bug in your code and you should investigate it (sounds like a memory/resource leak from what you described).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
OK . .But why is it when I minimize, I always go back to the minimum possible memory ..i.e. 384K ..then it starts building up. The server receives something like around 10 connections per second and this can cause memory leaks that also I agree, but how come when minimizing it returns to 384K? When I restore it, because of SHOW_WINDOW, it takes another 300K and the memory becomes 700K. But it again starts increasing. .to a huge number. .even 110MB .. :-S but one minimize click . .returns to 384K. ..
Will look at memory leaks too!
Varchas R S
Using Task Manager!! .. we have hosted the server and the connections per second is more than 10. so quite a lot of socket creation and socket closing that is done.. but minimizing the window is flushing some memory ... its strange ..
Which is not the best tool for what information you are after. Task Manager is simply reportng to you is the address space currently in use.
Varchas R S wrote:
...but minimizing the window is flushing some memory ... its strange ..
This is not strange at all. In fact it is quite expected. When a program's main window is minimized, the memory that the OS had reserved for it can be freed. If the window is restored, the OS must once again allocate memory for it.
i have displayed the valuess from database. when i change the TAB IN DIALOG it should not read from database.it should store the values in local structure.and when ever the TAB changes it display the values from the structure.how it is possible?
No it need not be. Atleast we haven not used a different setup file for CD and a different setup file in the web. The only additional stuff in the CD could be the Autorun file which will be absent in the web.
I have a function within the DLL(Hook.dll) that tries to get the DLLs(Hook.dll) file name and path (fullpath with filename of Hook.dll).
this is the original code, this code gets and reads the crc32 checksum of the Main.exe: pEXEFile = fopen(pszEXEFileName, "rb");
now i have changed it to and can fopen and read the dll, when i use:: pDLLFile = fopen("C:\\Documents and Settings\\Shawn\\Desktop\\Hook.dll", "rb");
this code above works, it will open my dll and read it's crc32 checksum, when i place and load the dll from my desktop.
another code that works: pDLLFile = fopen("\\Hook.dll", "rb");
this last code above works, when i move the Hook.dll into the same folder where the Main.exe is.
I thought that because I used LoadLibrary to load the DLL that it would be
in its own application space. So I figured I could just use the DLLs
Application component to extract the file name using GetModuleFileName
However, I was supprised to find that the returned name was the main
application not the DLL.
Is there another way to get the DLLs files name when dynamically loading it or is their a better way to use GetModuleFileName?
The problem is I do not know what directory the DLL was in when i inject the dll into the main program and I need to figure this out at run time.
what im trying to do is, get the fullpath to the injected dll at runtime, fopen the dll then to read it in binary mode and get a crc32 hash from the dll, check the retrieved crc32 checksum and validate the dll, if the dll was altered, exit the Main.exe.
i got some example code and need now some help, how could i bring the code to give me the fullpath of my loaded module "Hook.dll" from the Main.exe
I'm coding a program which gives a stimuli and wait for the user's answer before giving another one. The user answer by pressing one of 2 keys, and at the moment the program seems to be storing extra key pressed for the next stimulis. For example, if the user is asked to answer a question but presses twice the key, the second hit is used to answer the next question. Could anyone point me to a way of flushing all these keypresses before asking the user for the real one? Thanks in advance,
I'm using a windows form and the KeyPress event handler (which I'm really not yet comfortable with) and visual c++ studio express
//Code in the form1 constructor :
this->KeyPress += gcnew KeyPressEventHandler(this, &Form1::Form1_KeyPress);
Form1::KeyPreview = true;
//Code for the function
void Form1_KeyPress(Object^ sender, KeyPressEventArgs^ e)
// Here I handle the key
i wonder if someone could help me with an issue im having converting a hex value to a binary string..
i am trying to convert the hex string 0x00C000000000 to binary which should work out to be 1100000000000000000000000000000000000000.
i am using std::stringstream to fist convert the hex value to decimal and this is where it seems to be failing.. for the hex string 0x00C000000000 the decimal equivalent should be 824633720832 but i am not getting that..
here is my code
// hex = 0x00C000000000<br />
// dec = 824633720832<br />
// bin = 1100000000000000000000000000000000000000<br />
std::string hexvalue = "00C000000000";<br />
std::string binary = "";<br />
long decimalVal;<br />
std::stringstream sstr(hexvalue);<br />
sstr >> std::hex >> decimalVal;<br />
// now convert decimalVal to binary<br />
std::ostringstream out;<br />
long digit;<br />
bool nonzero = false;<br />
for (long i = 31; i >=0; i--)<br />
digit = (decimalVal >> i) & 1 ;<br />
if (!nonzero && digit)<br />
nonzero = true;<br />
if (nonzero)<br />
out << digit;<br />
binary = out.str();
by the way, if i set hexvalue to a smaller number then it seems to work. for example.
std::string hexvalue = "12";
can anybody help me out here?
thanks in advance
Last Visit: 31-Dec-99 18:00 Last Update: 18-Jun-21 18:06