|
The problem occurs because some code has corrupted the heap at some time, but it is impossible to know where. The only way to solve issues like this is by a lot of debugging and code profiling. There are some free tools for code profiling (Google will find them) which may help you.
Veni, vidi, abiit domum
|
|
|
|
|
start by debugging in the DLL's DllMain functions, especially in when the 'reason for the call' parameter (param #2) is DLL_THREAD_DETACH or DLL_PROCESS_DETACH.
odds are good that one DLL is trying to use something that the other DLL owns, and that that something is being destroyed before the first DLL is done using it.
|
|
|
|
|
As I recall there is a facility to check memory in real time in VC6.
It's called something like AfxCheckMemory (), and there's an option called something like checkalways, that checks your heap after every allocation/free, to pinpoint the memory corruption. (Your problem appears to be more than just a memory leak.)
Your program will run VERY slowly, but it will tell you where the error is. Search your documentation for this version to find the names of the function and option.
|
|
|
|
|
|
AfxCheckMemory () is there, but I don't see the "CheckAlways" option. As I recall, that disappeared with the first .NET version of Visual Studio, although I could be wrong.
|
|
|
|
|
Can we pass member function address in CreateThread() function instead of global function address?
|
|
|
|
|
You can pass a static member function but not an instance-specific one.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
The usual solution to the problem you're having is to pass a pointer to your class instance as the context parameter to the thread start procedure.
This way, the thread start procedure can call whatever instance method you want.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
No, we can't.
Member functions, having this as hidden parameter, cannot match the requested function signature.
Veni, vidi, vici.
|
|
|
|
|
It needs to let the current process create a copy of process and then exit current process.
I try to use the SetWindowPos(m_hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE) to set windows topmost, when first showup. So I kill the process in the taskmgr.exe and it will notify process to show a modal dialog to let user click, when click and then current process will create new process of itself and then exit current process. So a new process will showup, but I am amazing that why the topmost window is the taskmgr.
But if I click the shortcut of this application, and it will show on the topmost. I donot know where is the difference between these ways.
|
|
|
|
|
Your question doesn't really make sense (maybe because English is not your first language)... what are you trying to accomplish? Try to elaborate on what it is you're trying to have the user experience.
SetWindowPos() simply shifts the window at that time, not forever.
|
|
|
|
|
Hello.
I made a simple C++ program in Visual Studio 6 (MFC SDI). It sends a mail message using MAPI (mapi32.dll) and it works great and is easy to use.
But I don't undestannd how to attach a digital signature (stored in local certificates) to my message.
Outlook is set to add digital signature to all new messages but it ignores messages created by my C++ program.
Please help.
Best regards, Alex.
modified 7-Oct-13 10:31am.
|
|
|
|
|
Digital signature prevents email content is faked or changed in transport level. Encrypting email protects email content from exposure to inappropriate recipients. Both digital signature and email encrypting depend on digital certificate.
If you have an email digital signature certificate installed on your machine, you can find it in Control Panel-interner option-content-Certificates-Personal
Then you can use your email certificate to sign the email by the following code. If you don't have a certificate for your email address, you MUST get a digital certificate for personal email protection from third-party certificate authorities such as www.verisign.com.
#include "stdafx.h"
#include "easendmailobj.tlh"
using namespace EASendMailObjLib;
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize( NULL );
IMailPtr oSmtp = NULL;
oSmtp.CreateInstance( "EASendMailObj.Mail");
oSmtp->LicenseCode = _T("TryIt");
// Set your sender email address
oSmtp->FromAddr = _T("test@emailarchitect.net");
// Add recipient email address
oSmtp->AddRecipientEx( _T("support@emailarchitect.net"), 0 );
// Set email subject
oSmtp->Subject = _T("email from Visual C++ with digital signature(S/MIME)");
// Set email body
oSmtp->BodyText = _T("this is a test email sent from Visual C++ with digital signature");
// Your SMTP server address
oSmtp->ServerAddr = _T("smtp.emailarchitect.net");
// User and password for ESMTP authentication, if your server doesn't
// require User authentication, please remove the following codes.
oSmtp->UserName = _T("test@emailarchitect.net");
oSmtp->Password = _T("testpassword");
// If your SMTP server requires SSL connection, please add this line
//oSmtp->SSL_init();
// Add signer digital signature
if( oSmtp->SignerCert->FindSubject(_T("test@emailarchitect.net"),
CERT_SYSTEM_STORE_CURRENT_USER , _T("my")) == VARIANT_FALSE )
{
_tprintf(_T("Error with signer certificate; %s\r\n"),
(const TCHAR*)oSmtp->SignerCert->GetLastError());
return 0;
}
if( oSmtp->SignerCert->HasPrivateKey == VARIANT_FALSE )
{
_tprintf(_T("certificate does not have a private key, it can not sign email.\r\n" ));
return 0;
}
_tprintf(_T("Start to send email ...\r\n" ));
if( oSmtp->SendMail() == 0 )
{
_tprintf( _T("email was sent successfully!\r\n"));
}
else
{
_tprintf( _T("failed to send email with the following error: %s\r\n"),
(const TCHAR*)oSmtp->GetLastErrDescription());
}
if( oSmtp != NULL )
oSmtp.Release();
return 0;
}
|
|
|
|
|
Hi there.
I am looking for a simple, basic, preferable a C way of parsing multipart/form-data POST request from a client browser. So far I have a really simple web server, which reads web browser requests in a loop and prints them to to command prompt window:
do
{
len = recv(..., input_buf, ...);
}
while (!strstr(input_buf, "\r\n\r\n") && len > 0);
char * pch = nullptr, *context = nullptr;
pch = strtok_s(input_buf, "\r\n", &context);
while (pch != nullptr)
{
::puts(pch);
pch = strtok_s (nullptr, "\r\n", &context);
}
When this web server starts, it just shows the following web form to the web browser:
<form type=multipart/form-data method=post action=submit><input type=file multiple required /><input type=submit /></form>
So far so good, ok, I connect to my server with firefox, select some test text file, which is a really small one - just a couple of bytes and hit an html form submit button. Server reads request and I have the following output in command prompt window:
POST /submit HTTP/1.1
Host: localhost:6666
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:24.0) Gecko/20100101 Firefox/
24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:6666/
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
But the question is, how do I get file data? I was reading tons of online docs, when it says something about boundary strings - I have no idea what are boundary strings. I am just trying to figure out how to grab raw bytes file data. I cannot use any 3rd party libraries. And what concerns me, is that Content-Length is zero - seems like file was not transferred at all
Can anyone help me with this?
Thanks in advance
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Figured it out - there is an error in my html form, it should be enctype , not type . Now I have a file content.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
I would like to use a "Big Number" package for my application which I am writing on Windows using Visual Studio and C++. Therefore, I thought I would use GMP. However, I get the impression that compiling it under Windows is going to be a big job. Therefore, I am wondering if it is worth doing.
Could somebody suggest a different package that is more geared towards the windows environment?
Thanks
Bob
|
|
|
|
|
Depending on what you need libtommath[^] may do the job for you. It's a C library I've used in several projects along with libtomcrypt. These are in ansi C. Their source is clean. Public domain. Check out the libs of this guy, they are excellent.
The LICENSE file:
LibTomMath is hereby released into the Public Domain.
-- Tom St Denis
|
|
|
|
|
-1
down vote
favorite I have this program that needs to handle large numbers to factorize a number into primes.. Just like the RSA factorization challenge.
I got this list in a txt file with prime numbers. this is the piece of code I use to make that list:
int export_list (int lim = 50)
{
int last_in_txt = 0;
{
ifstream infile ("Primes.txt");
int k;
while(infile >> k)
{ last_in_txt = k; }
}
// Now last_in_txt is assigned properly, and Primes.txt is closed
cout << "\nLast number in \"Primes.txt\": " << last_in_txt << endl << endl;
cout << "Press <enter> to start appending primes... ";
cin.get();
cout << "\nAppend started:\n";
last_in_txt++;
ofstream file ("Primes.txt" , ios::app);
int x, counter;
if (file.is_open()) // if it opens correctly
{
for (x = last_in_txt , counter = 0 ; counter < lim ; x++ , counter++)
{
if (check_prime (x)) // returns 1 when x is prime, returns 0 when not
{
cout << "Appending " << x << "\t\t" << "Estimated time remaining: " << (lim - counter) / 1000 <
|
|
|
|
|
A software is executing some websites links (URLs) internally, Can I get to know which links are thses?
|
|
|
|
|
No. Unless the application offers some way of making them public.
Veni, vidi, abiit domum
|
|
|
|
|
john5632 wrote: Can I get to know which links are thses?
Look at the code.
Put a interceptor in place which catches http requests.
Both of those of course require that you have internal access. However the above applies if you are executing something on your machine rather than a remote server.
|
|
|
|
|
Why not use a packet sniffer?
Wireshark[^] would do the trick... it's a very mature product that's been around for ages (used to be called Ethereal) and is very reliable and used by many.
|
|
|
|
|
Hey there,
I have a C++ WIN32 DLL that acts as a server for a UI. Now i want to capture all keyboard inputs in the PC on the WIN32 dll, whenever the UI has active focus. If the user is typing something into another app, i don't care.
The trick is that, the keyboard can be both a software keyboard or a hardware keyboard. I want to be able to capture every keyboard input from the user on the PC in which the UI and DLL is running.
I would ideally like to get a little deeper on the Windows operating system level to do this. Rather than using WM_CHAR or something like that.
Is this possible to do? How can i implement this?
Any sample code will help.
Thanks in advance.
|
|
|
|
|
This[^] or this[^] could be a start, I'm sure there are plenty of others out there.
|
|
|
|
|
First I tried using kbhit() and getch() to recognize and capture the users input. I call the code below every frame (I tested in BL:R) but nothing happens.
PHP Code
if(kbhit())content += getch();
|
|
|
|