|
Looks like that's your only option... if you want something that C++ exclusively, find another suitable library or write your own.
|
|
|
|
|
Hi coders,
IIT Roorkee is presenting an Algorithm Intensive Online Programming
Contest – INSOMNIA, during their annual Tech Fest COGNIZANCE '12.
INSOMNIA is known around the globe and some of the best coders
participate in this reputed competition. The event has a total prize
money of INR 50,000/-
INSOMNIA will be held for 12 hours from 9:00 PM IST (+5:30 GMT), 11th
February to 9:00 AM IST, 12th February 2012. There could be maximum 2
members in a team. Team member may be of different colleges /
professions.
To participate in the contest, first visit
(http://www.cognizance.org.in/) and register each team member
indivisually on it. Then register your team at INSOMNIA website
(http://www.insomnia.cognizance.org.in/). The contest will also be
held on the same site.
Looking forward to your participation.
Coordinators:
Aditya Gupta (adityagupta104@gmail.com) – (+91-7417015693)
Deshank Baranwal (deshank@gmail.com ) - ( +91-9557020929)
Dipit Grover – (+91-9557647167)
Kapil Agrawal – (+91-9568380650)
Important Note: For further queries refer to ‘Rules’ on the site or
email to any of the coordinator or write to Email ID-
insomnia.cogni@gmail.com.
|
|
|
|
|
Hello, I'm wondering how would you programmatically install your program in the Windows Action Center on the antivirus section, to where it says "COMODO antivirus is currently running and up to date." How would you do it to make your own program (e.g., "Windows Application-1 is currently running and up to date.")
Regards,
Brandon T. H.
|
|
|
|
|
|
Thanks for the response, seems that Microsoft keeps the information discreet from anyone out there that's gonna use it in a bad way, but I'll try exploring my registry keys, and see if I find anything that grabs my attention, and keep researching about it see if there is such a way. I mean other anti viruses can do that, I wonder how they can though...
|
|
|
|
|
Brandon T. H. wrote: I mean other anti viruses can do that, I wonder how they can though...
My first guess would be they have a (contractual) relationship with MS that gives them access to such information. Sort of like how hardware mfg's get access to the early versions of a new OS so they have ample time to get drivers and such ready.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I just want to get a check to see if my translation of the Mod Operator in VB to c++ is even close to right, or if there is a c++ equivalent to Mod, where I can just use Mod or something close to it.
edit:
I'm not sure if the null terminate char will produce a different result in the c++.
So I have these lines of code to translate.
strTextChar = Mid(strDomainName, (i Mod Len(strDomainName)) + 1, 1)
strKeyChar = Mid(ApplicationName, (i Mod Len(ApplicationName)) + 1, 1)
szTextChar = &szDomainName[ ( i - ( wcslen(szDomainName)) * (i / wcslen(szDomainName)) ) + 1 ];
szKeyChar = &pzApplicationName[ ( i - ( wcslen(szApplicationName)) * (i / wcslen(szApplicationName)) ) + 1 ];
I have this other line of code to translate, this one is more complex, just thought I would throw it out there. I took a peek at Xor, it's not quite sinking in yet.
strTextChar = Chr(Asc(strTextChar) Xor intTemp)
|
|
|
|
|
% is the modulo operator in C++ and C# and most similar languages.
Philippe Mori
|
|
|
|
|
Thanks Philippe!
I took off the +1 for the null terminator
szTextChar = szDomainName[ (i % wcslen(szDomainName)) ];
szKeyChar = pzApplicationName[ (i % wcslen(szDomainName)) ];
|
|
|
|
|
I'm trying to translate a program I use in vb to c++, to get the exact same results. The program is basically 8 lines of code. I have the first 2 lines working, but on line 3, I get back a int value of 10, and vb returns &h10, which is 16.
So this is the vb loop of the function. I decided to use char since the valid characters are
Private Const VALID_CHARACTERS = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Private Const DEFAULT_FORMAT = "&&&&-&&&&-&&&&-&&&&"
This is the source code from vb I use.
For i = 1 To CountAmpersands(sFormat)
L1 strTextChar = Mid(strDomainName, (i Mod Len(strDomainName)) + 1, 1)
L2 strKeyChar = Mid(ApplicationName, (i Mod Len(ApplicationName)) + 1, 1)
L3 intTemp = (((Asc(strKeyChar) * i) * Len(ApplicationName) + 1) Mod Len(ValidCharacters) + 1)
L4 strTextChar = Chr(Asc(strTextChar) Xor intTemp)
L5 intTemp = (((Asc(strKeyChar) * i) * Len(DomainName) + 1) Mod Len(ValidCharacters) + 1)
L6 strTextChar = Chr(Asc(strTextChar) Xor intTemp)
L7 intEncryptedChar = ((Asc(strTextChar) Xor Asc(strKeyChar)) Mod Len(ValidCharacters)) + 1
L8 strKey = strKey & Mid(ValidCharacters, intEncryptedChar, 1)
Select Case i
Case 4, 8, 12
strKey = strKey & "-"
End Select
Next i
And this is my feeble translation to c++, I didn't do very good on it, this is the 3rd run.
for (int i = 1; i <= iCount; ++i) {
L1 szTextCharA = szDomainNameA[ ( i % strlen( szDomainNameA )) ];
L2 szKeyCharA = szAppKeyA[ ( i % strlen( szAppKeyA )) ];
L3 iTemp = ((szKeyCharA * i) * strlen(szAppKeyA)) % strlen( LICENSEKEY_CHARACTERS );
L4 szTextCharA = (char) ((int)szTextCharA ^ iTemp );
L5 iTemp = (int)(szKeyCharA * i) * strlen(szDomainNameA) % strlen( LICENSEKEY_CHARACTERS );
L6 szTextCharA = (char)((int)szTextCharA ^ iTemp);
L7 iEncryptedChar = (int)szTextCharA ^ (int)szKeyCharA % strlen(LICENSEKEY_CHARACTERS);
if ( i == 1) {
strncpy_s( szKeyA, iKeyA, &LICENSEKEY_CHARACTERS[ iEncryptedChar ], 1 );
}
else {
strncat_s( szKeyA, iKeyA, &LICENSEKEY_CHARACTERS[ iEncryptedChar ], 1 );
}
}
Question1:
On Line 3 in VB, I get back &H10, and Line 3 in c++, I get back 10. I'm not sure if I wrote the c++ L3 wrong, or if I'm not clear on the value of iTemp.
Question2:
Am I even close on my translation? From Line 3 to Line 7, and I think I need a better method of building the final key szKeyA.
Question3:
Should I have just lefted it as WCHAR, On version 2, I changed it to char.
This is the entire program so you can get a better idea of what I did
const char LICENSEKEY_CHARACTERS [] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char LICENSEKEY_FORMAT [] = "&&&&-&&&&-&&&&-&&&&";
WCHAR* CA_LicenseKey::_makeKey( WCHAR *pzAppKeyW, WCHAR *pzDomainNameW )
{
INT iTemp;
int iEncryptedChar;
char szTextCharA;
char szKeyCharA;
char *szKeyA = NULL;
if ( wcslen(pzDomainNameW ) == 0) {
DWORD dwKey = wcslen( L"Invalid Domain Name" );
WCHAR *szReturnW = new WCHAR[dwKey+1];
wcsncpy_s(szReturnW, dwKey+1, L"Invalid Domain Name", dwKey );
return szReturnW;
}
int iDomainNameA = (WideCharToMultiByte(CP_UTF8, 0, (pzDomainNameW), -1, NULL, 0, NULL, NULL) - 1) + 1;
char *szDomainNameA = new char[iDomainNameA];
WideCharToMultiByte(CP_UTF8, 0, pzDomainNameW, -1, szDomainNameA, iDomainNameA, NULL, NULL);
_strlwr_s( szDomainNameA, iDomainNameA );
int iAppKeyA = (WideCharToMultiByte(CP_UTF8, 0, pzAppKeyW, -1, NULL, 0, NULL, NULL) - 1) + 1;
char *szAppKeyA = new char[iDomainNameA];
WideCharToMultiByte(CP_UTF8, 0, pzAppKeyW, -1, szAppKeyA, iAppKeyA, NULL, NULL);
int iCount = _countAmpersands();
int iKeyA = strlen(LICENSEKEY_FORMAT)+1;
szKeyA = new char[ iKeyA+1 ];
for (int i = 1; i <= iCount; ++i) {
szTextCharA = szDomainNameA[ ( i % strlen( szDomainNameA )) ];
szKeyCharA = szAppKeyA[ ( i % strlen( szAppKeyA )) ];
iTemp = ((szKeyCharA * i) * strlen(szAppKeyA)) % strlen( LICENSEKEY_CHARACTERS );
szTextCharA = (char) ((int)szTextCharA ^ iTemp );
iTemp = (int)(szKeyCharA * i) * strlen(szDomainNameA) % strlen( LICENSEKEY_CHARACTERS );
szTextCharA = (char)((int)szTextCharA ^ iTemp);
iEncryptedChar = (int)szTextCharA ^ (int)szKeyCharA % strlen(LICENSEKEY_CHARACTERS);
if ( i == 1) {
strncpy_s( szKeyA, iKeyA, &LICENSEKEY_CHARACTERS[ iEncryptedChar ], 1 );
}
else {
strncat_s( szKeyA, iKeyA, &LICENSEKEY_CHARACTERS[ iEncryptedChar ], 1 );
}
}
delete [] szDomainNameA;
delete [] szAppKeyA;
WCHAR *szKeyW = NULL;
return szKeyW;
}
int CA_LicenseKey::_countAmpersands( void )
{
INT iCount = 0;
int iLength = 0;
char *szFormatA = NULL;
iLength = strlen(LICENSEKEY_FORMAT);
szFormatA = new char[iLength+1];
strncpy_s( szFormatA, iLength+1, LICENSEKEY_FORMAT, iLength );
for (int i = 0; i <= iLength; ++i) {
if ( strncmp( &szFormatA[i], "&", 1) == 0 ) {
++iCount;
}
}
delete szFormatA;
return iCount;
}
|
|
|
|
|
The second one will be something like:
strTextChar = static_cast<wchar_t>(static_cast<int>(strTextChar[0]) ^ intTemp);
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Thanks Dave,
Your hint gave me insight into the proper and more consistent way to write the 8 lines of code.
Now I'm getting accurate results so far going through the loop. Looks like I will be able to complete this today and move on.
|
|
|
|
|
I'm missing the boat here on something. I have this constant, and I just want to count how many ampersands are in it. But I keep getting a character or type mismatch, I can't go though each character to check the value.
Overall, it's my idea of how to replace the mid function used in vb. mid(szFormat, 1,1)
const WCHAR LICENSEKEY_FORMAT [] = L"&&&&-&&&&-&&&&-&&&&";
for (int i = 0; i <= dwLength; ++i) {
if (wcsncmp(szFormat [i], L"&", 1) ==0) {
++dwCount;
}
}
The error I keep getting is
error C2664: 'wcsncmp' : cannot convert parameter 1 from 'WCHAR' to 'const wchar_t *'
If I szFormat[i] == L"&", I sort of get the same error.
Question:
Is it the const that I made is not stated correctly?, If not, what correction do I need?
|
|
|
|
|
try:
wcsncmp( &szFormat[i], L"&", 1 ) == 0
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
That did the trick,
Thanks Richard
|
|
|
|
|
Use this (note the single quotation marks):
if (szFormat [i] == L'&')
You may also have a look on the CString class which provides the Left() , Mid() , and Right() functions.
|
|
|
|
|
I changed it to char, so the single quotes don't work right now. I might change it back to WCHAR today, because I'm not getting the desired results. I do get an accurate count, but I'm trying to translate a vb function, so it needs to be the same.
I'm going to post an extension to the post above in about 10 minutes.
|
|
|
|
|
int wcsncmp( const wchar_t *string1, const wchar_t *string2, size_t count );
szFormat[i] is not a addr
for (int i = 0; i <= dwLength; ++i) {
if (wcsncmp(&szFormat [i], L"&", 1) ==0) {
++dwCount;
}
}
|
|
|
|
|
Hi everyone, I want to develop an application or whatever (driver), this will run before windows starts, and will ask for a password and if the password is correct system will continue to the windows. What can I do? Thanks.
|
|
|
|
|
The simplest thing would be to add a BIOS password[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I know that... But I want to write it myself.
|
|
|
|
|
Take a look at GINA[^], I think that is what you need to work with.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I want to launch a web address with ShellExecute in hidden way :
CString sLink = _T("http://www.codeproject.com/somepage/");
ShellExecute(NULL, NULL, sLink, NULL, NULL, SW_HIDE);
and goes well, but also, I want to close the launched application after execution ... how could I ?
|
|
|
|
|
If you want control over the spawned process, use CreateProcess()[^] instead.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Try using ShellExecuteEx() instead. It gives you back information that you can subsequently send to TerminateProcess() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|