i have this simple code that will get the HDD Serial Id into a string then XOR it using a key and then HTTP Encode so i can safely send it using InternetOpenUrl() api
the problem is that on my HTTPEncode() function , the passing string gets magically Nulled or altered after the 1 line of code
any help would be appreciated
code:
Code:#include <iostream> #include <windows.h> #include <Wininet.h> #pragma comment( lib, "Advapi32.lib") #pragma comment( lib, "WinInet.lib") using namespace std; char* GetVolumeID(); char* XOREncryption(char* szData , char* szKey); char* HTTPEncode(const char* AStr); char* HTTPEncode(const char* AStr) { //based on zedwood.com code string URL = ""; int string_gets_altered_when_it_reaches_this_point = 1; for(int i=0; i<strlen(AStr); i++) { if ( (48 <= AStr[i] && AStr[i] <= 57) ||//0-9 (65 <= AStr[i] && AStr[i] <= 90) ||//abc...xyz (97 <= AStr[i] && AStr[i] <= 122) || //ABC...XYZ (AStr[i]=='~' || AStr[i]=='!' || AStr[i]=='*' || AStr[i]=='(' || AStr[i]==')' || AStr[i]=='\'') ) { URL.append( &AStr[i], 1); } else { char* tmp = new char[3]; sprintf(tmp, "%x", AStr[i]); URL.append("%"); URL.append(tmp); delete[] tmp; } } char * Ret= new char[URL.length() + 1]; strcpy(Ret, URL.c_str()); return Ret; } char* XOREncryption(char* szData , char* szKey) { DWORD i, x = 0; char* szTemp = new char [strlen(szData)]; szTemp[strlen(szData)] = 0; for (int i = 0; i <= (strlen(szData)-1); i++) { szTemp[i] = szData[i]^szKey[x]; x >= (strlen(szKey)-1) ? x=0 : x++; } return szTemp; } char* GetVolumeID() { DWORD dwNull1, dwNull2, dwID; char szSys[MAX_PATH]; GetSystemDirectoryA(szSys,MAX_PATH); char Drive[4] = {szSys[0],szSys[1],szSys[2]}; char cSerial[100]; if (GetVolumeInformationA(Drive,0,0,&dwID, &dwNull1, &dwNull2, 0, 0)) return ultoa(dwID,cSerial,10); } int main() { char* ID = GetVolumeID(); char* szID = HTTPEncode(XOREncryption(ID, "Random")); return 0; }




Reply With Quote