// WINMPG.cpp : Defines the entry point for the application. float PourcentConvertion = 0.0; #define _WIN32_IE 0x0501 #define _WIN32_WINNT 0x0501 #include "SCENE.H" //For session Notification //#define _WIN32_IE 0x0501 //#define _WIN32_WINNT 0x0501 //#include "SCENE.H" //#include "WtsApi32.h" //WTSRegisterSessionNotification(hWnd, NOTIFY_FOR_ALL_SESSIONS); //case WM_WTSSESSION_CHANGE: //#define SOUND_ON //#include "stdafx.h" #include "resource.h" #include #include #include #include #ifndef SKIMMED_NET #include "NET.H" #endif #include "CODEC.H" #include "rrasters.h" #ifdef SOUND_ON #include "CSound.h" #endif #ifdef ONLINE_MODE #include "account.h" #endif #if _DEBUG #define _CRTDBG_MAP_ALLOC #include "crtdbg.h" #endif #include //_ASSERTE( _CrtIsValidHeapPointer( ) ); HMODULE KeyboardDLL = 0; HANDLE AppAccesMutex; int aviEncoder = 0; char *currentCursor = NULL; int currentCursorType = NULL; void UpdateAllBack(WORLD *pScene); u32 IsMinimized = 0; u32 IsMaximized = 0; u32 VersionNumber = 0; char CurrentDir[1024]; DWORD CurrentSessionID; DWORD LaunchSessionID; #define MYMSG_NOTIFYICON (WM_APP + 100) WORLD *MyCreateWORLD(HWND hWnd, u32 SizeX,u32 SizeY, char *iniFile); u32 DestroyWORLD(WORLD *TheScene); WORLD *TheScene = NULL; u32 modeHigh = 0; int mainThread; int sessionLocked = 0; // If you want to run in D3D, you need to pass in 'd3d' as a commandline argument. // Alternatively, just change the below to 1 to set D3D as default. int D3DDisplay = -1; u32 IsRestart = 0; //*************** Reg INFO **************// #define AUTORUN_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run" #define AUTORUN_KEY_CAMCAM "CamCam Driver" #define CAMCAM_KEY_INSTALL "installdir" #define CAMCAM_EXE "Camcam.exe" #define CAMCAM_LUA "driver.LUA" char xorCrypt[] = {-123,-112,-118,-33,-99,-123,-87,-47,-68,-67,-77,-68,-86,-99,-54,-55,-53,-119,-118,-106,-67,-81,-86,-50,-57,22,-101,-46,-57,-53,-105,-105,-116,22,-120,-58,-102,-103,-41,-46,-40,-54,-53,-123,-58,-57,-53,-103,-98,-103,-119,-101,-98,-58,-57,-46,23,-109,-109,-78,22,-57,-40,-41,-46}; char *xorBase = NULL; void ProcessBase() { if (xorBase) return; xorBase = (char *)CC_malloc(66); for (int i=0; i<65; i++) xorBase[i] = ~xorCrypt[i]; xorBase[65] = 0; } #ifdef USER_MODE void displayIntegrityError(int num) { static bool displayed = false; if (!displayed) // only display once (in case it's called by dofile() in lua, it might occur several times) { char title[30]; sprintf(title, "%s %d", "Integrity Error", num); MessageBox(TheScene ? TheScene->OwnerHwnd : NULL, "Error while opening file, please reinstall", title, MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); displayed = true; } } #include "FileAllowed.h" #ifdef VERSION_STR const char *VersionStr = VERSION_STR; #else #error "Missing VERSION_STR" #endif //static char *FileAllowed[] = { // "camcam.luax", // "sceneclass.luax", // "driver.luax", // "slot.luax", // "studio.luax", // "leftpanel.luax"}; //static char *FileAllowedMD5[] = { // "8cec900ebda28e80fd242f75978854f6", // "ad252982d55ddc4b792b7bc5c8450cb2", // "e959b25f4ff66d3ef70fd9913d4c1357", // "b3fc36864b4f0eb4dd56b0a97157a133", // "2cdb7d127d37cffa49e620a24b7cdc85", // "8975533c1140fa23e521184499ada140"}; BOOL IsFileAllowed(char *filename, bool fromLua) { #ifdef _DEBUG // return true; // for testing purpose #endif char filenameX[1024]; if (!fromLua) { sprintf(filenameX, "%sx", filename); filename = filenameX; } else { if (*filename == '@') filename++; } char md5Base[64]; char fileBaseBuf[1024]; char *fileBase = fileBaseBuf; strncpy(fileBase, filename, 1024); if (fileBase && (fileBase[0] == '.') && (fileBase[1] = '/')) fileBase += 2; int pos = strlen(fileBase) - 1; for (;pos >= 0 && fileBase[pos] != '.'; pos--); fileBase[pos] = '\0'; // get rid of extension //for (;pos >= 0 && filename[pos] != '\\' && filename[pos] != '/' && filename[pos] != ':'; pos--); //strcpy(fileBase, filename + pos + 1); strlwr(fileBase); MDFile(filename, md5Base); for (int i=0; i>1); u32 TEST_SY = 384+(384>>1); //u32 TEST_SY = 352+(352>>1); u32 IconTime = 0; HINSTANCE hBigInstance = 0; TCHAR AVICompressor[256] = ""; bool AVIMicroSound = false; char CompressorsNames[64][256]; int NbCompressorsNames = 0; TCHAR CurrWebCam[256] = ""; char WebCamNames[64][256]; int NbWebCams = 0; char LuaDebugGotoLine[16]; char AppDataPath[MAX_PATH]; char MyDocsPath[MAX_PATH]; char MyMusicsPath[MAX_PATH]; char MyPicturesPath[MAX_PATH]; char CamcamCCM[MAX_PATH]; void TransparentWindowSet(bool enable, bool force = false); int GetVideoEncodersNames(char compressors[][256], int *nbCompressors, int maxCompressors); BOOL GetFilterPropertyByName(char *name, bool openPage); int GetWebCamNames(char compressors[][256], int *nbCompressors, int maxCompressors); BOOL GetWebCamFilterPropertyByName(char *name, bool openPage); u32 FILEIO_DetectPackedExeMode(char *EXEname); u32 FILEIO_IsModePackedEXE(); bool AddUserNameInRegistry();//PL HKEY _RegGetHandleKey(int key); char* _RegReadKeyValue(int HandleKey, const char* SubKey, const char* NameKey); bool _RegSetKeyValue(int HandleKey, const char* SubKey, const char* NameKey, const char* Value); #ifdef SOUND_ON CSnd Audio; #endif #ifdef ONLINE_MODE CCamCamAccount Account; //extern HWND BrowserWnd; #endif void AnimateIcon(HINSTANCE hInstance, HWND hWnd, DWORD dwMsgType,UINT nIndexOfIcon,char *pInfoTexte) { static HICON hIconAtIndex = (HICON)0; if (hInstance == NULL) hInstance = hBigInstance; else hBigInstance = hInstance; if (hIconAtIndex == (HICON)0) hIconAtIndex = LoadIcon(hInstance, (LPCTSTR)IDI_ICON1); IconTime = -1; if (pInfoTexte[0]) IconTime = timeGetTime(); NOTIFYICONDATA IconData; memset(&IconData, 0, sizeof(NOTIFYICONDATA)); IconData.cbSize = sizeof(NOTIFYICONDATA); IconData.hIcon = hIconAtIndex; IconData.hWnd = hWnd; IconData.uID = 0xc0de2003; strcpy(IconData.szTip, "YouUp"); IconData.uCallbackMessage = MYMSG_NOTIFYICON; IconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP | NIF_INFO; if (pInfoTexte[0]) IconData.uFlags |= NIF_INFO; IconData.uVersion = 5; IconData.uTimeout = 0; sprintf(IconData.szInfo,pInfoTexte); if (pInfoTexte[0]) sprintf(IconData.szInfoTitle,"YouUPApp"); else//*/ sprintf(IconData.szInfoTitle,""); IconData.dwInfoFlags = NIIF_INFO; Shell_NotifyIcon(dwMsgType, &IconData); SendMessage(hWnd, WM_SETICON, NULL, (long) hIconAtIndex); DestroyIcon(hIconAtIndex); } u32 bSurchargeMouseCursor = 0; //u32 ResultBNitm[1024*1024]; void Blitte() { if (bnoBlitte) return; bnoBlitte ++; if (TheScene) { static void *H264 = NULL; MAP SDF; TheScene->FrameCall(); if ((TEST_SX != TheScene->XSize) || (TEST_SY != TheScene->YSize) || MustUpdate) { TEST_SX = TheScene->XSize; TEST_SY = TheScene->YSize; RECT Rect1,Rect2; GetClientRect(hWnd , &Rect1); GetWindowRect(hWnd , &Rect2); Rect1 . bottom -= Rect1 . top; Rect2 . bottom -= Rect2 . top; Rect1 . right -= Rect1 . left; Rect2 . right -= Rect2 . left; SetWindowPos(hWnd , NULL , 0 , 0 , TEST_SX + Rect2 . right - Rect1 . right , TEST_SY + Rect2 . bottom - Rect1 . bottom , SWP_NOMOVE); UpdateAllBack(TheScene); MustUpdate = 0; } } bnoBlitte --; } void API_EXIT() { // exec last events before exit ... if (TheScene) TheScene->LuaEventsExec(); #ifdef ONLINE_MODE // Now the background thread will check a mutex in TheScene, so they must be gently exited before destroying TheScene Account.release(); extern void releaseLuaHTTPClients(); releaseLuaHTTPClients(); #endif DestroyWORLD(TheScene); TheScene = NULL; AnimateIcon(NULL, hWnd, NIM_DELETE,0,""); extern HWND hSplashWnd; if (hSplashWnd) DestroyWindow(hSplashWnd); #ifdef SOUND_ON Audio.Stop(); Audio.Liberations(); #endif ReleaseMutex(AppAccesMutex); exit(0); } void API_RESTART(char* luaFileToBoot) { int nArgs; LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); size_t size = wcslen(szArglist[0])+1; char* exepathname = (char*)ZeroAlloc(size); wcstombs(exepathname, szArglist[0], size); exepathname[strlen(exepathname)-4] = 0; char* exename = NULL; if (strrchr(exepathname, '\\')) exename = strrchr(exepathname, '\\')+1; else exename = exepathname; char BATPath[2048]; FILE *BAT; #if 1 char execData[2048]; sprintf(execData,"%s.EXE restart %s",exename, luaFileToBoot?luaFileToBoot:""); STARTUPINFO si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si)); si.cb = sizeof(si); memset(&pi, 0, sizeof(pi)); if (!CreateProcess(NULL, execData, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) { char info[2048]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), LANG_NEUTRAL, info, 2048, NULL); } API_EXIT(); #else #ifndef USER_MODE strcpy(BATPath, "U.BAT"); #else sprintf(BATPath, "%s\\U.BAT", AppDataPath); #endif if (fileExists(BATPath)) { SetFileAttributes(BATPath, GetFileAttributes(BATPath) & ~FILE_ATTRIBUTE_READONLY); DeleteFile(BATPath); } BAT = CC_fopen(BATPath,"wt"); if (BAT) { fprintf(BAT,"XCOPY /Y %s.EXE *.BXE\n",exename); fprintf(BAT,":start\n"); fprintf(BAT,"del /F /Q %s.EXE\n",exename); fprintf(BAT,"if exist %s.EXE goto start\n",exename); fprintf(BAT,"XCOPY /Y *.BXE *.EXE\n",exename); fprintf(BAT,"del /F /Q *.BXE\n",exename); fprintf(BAT,"START %s.EXE %s\n",exename, luaFileToBoot?luaFileToBoot:""); fprintf(BAT,"\n",exename); CC_fclose(BAT); WinExec(BATPath,SW_HIDE); API_EXIT(); } CC_free(exepathname); exepathname = 0; exename = 0; LocalFree(szArglist); #endif } #ifndef USER_MODE u32 CheckVer(char *FilnameA,char *FilnameServeur,char *StringDest) { static u32 Loosed = 0; u32 Ret = 0; if (Loosed) return 0; FILE *F1,*F2; F1 = CC_fopen(FilnameA,"rb"); F2 = CC_fopen(FilnameServeur,"rb"); if (F1 && F2) { u32 ValueF1; do { ValueF1 = fread(StringDest,1,2047,F1); fread(StringDest,1,ValueF1,F2); } while (ValueF1); memset(StringDest,0,2048); Ret = fread(StringDest,1,2047,F2); } else Loosed = 1; if (F1) CC_fclose(F1); if (F2) CC_fclose(F2); return Ret; } u32 NewVersionIsAvailable = 0; char UpdateTextTEXT[2048*4] = ""; void API_UPDATE_EXE() { FILE *BAT; #ifdef SIMUP #define EXENAME "TestApp_FS" #else #ifdef _DEBUG #define EXENAME "TestAppD" #else #define EXENAME "TestApp" #endif #endif //SIMUP BAT = CC_fopen("U.BAT","wb"); if (BAT) { CC_fclose(BAT); WinExec("del u.bat",SW_HIDE); }; BAT = CC_fopen("U.BAT","wt"); if (BAT) { fprintf(BAT,"COPY /Y \\\\mtp-infr-data01\\Projets\\CamCam\\SimConnect.dll SimConnect.dll\n"); fprintf(BAT,"COPY /Y \\\\mtp-infr-data01\\Projets\\CamCam\\CamcamDLLHook.dll CamcamDLLHook.dll\n"); fprintf(BAT,":start\n"); fprintf(BAT,"COPY /Y %s.exe %s_%d.exe\n",EXENAME,EXENAME,VersionNumber); fprintf(BAT,"del /F /Q %s.exe\n",EXENAME); fprintf(BAT,"if exist %s.exe goto start\n",EXENAME); fprintf(BAT,"COPY /Y \\\\mtp-infr-data01\\Projets\\CamCam\\%s.exe %s.exe\n",EXENAME,EXENAME); fprintf(BAT,"COPY /Y \\\\mtp-infr-data01\\Projets\\CamCam\\Camcam.ver Camcam.ver\n",EXENAME,EXENAME); fprintf(BAT,"COPY /Y \\\\mtp-infr-data01\\Projets\\CamCam\\SimConnect.dll SimConnect.dll\n"); fprintf(BAT,"COPY /Y \\\\mtp-infr-data01\\Projets\\CamCam\\ids\\*.feat ids\\*.feat\n"); fprintf(BAT,"START %s.exe\n",EXENAME); fprintf(BAT,"\n",EXENAME); CC_fclose(BAT); WinExec("U.BAT",SW_HIDE); API_EXIT(); } } void API_IMPORTALLMEDIA() { FILE *BAT; BAT = CC_fopen("U.BAT","wt"); if (BAT) { fprintf(BAT,"XCOPY /Y %s *.BXE\n",EXENAME); fprintf(BAT,":start\n"); fprintf(BAT,"del /F /Q %s\n",EXENAME); fprintf(BAT,"if exist %s goto start\n",EXENAME); fprintf(BAT,"XCOPY /Y *.BXE *.EXE\n",EXENAME); fprintf(BAT,"del /F /Q *.BXE\n",EXENAME); fprintf(BAT,"START %s\n",EXENAME); fprintf(BAT,"\n",EXENAME); CC_fclose(BAT); WinExec("U.BAT",SW_HIDE); API_EXIT(); } } #endif // USER_MODE void WINMAIN_SETCAPTURE(u32 OnOff) { if (OnOff) { SetCapture(hWnd); } else ReleaseCapture(); } extern u32 FILEIO_Binarize(); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //Well, solution waiting for a good cmd analysis extern bool debuggingLua; extern bool debuggingFile; extern bool noCompression; u32 waitTime = 500; u32 IsServiceLaunch = 0; mainThread = GetCurrentThreadId(); //#ifdef _DEBUG debuggingFile = 1; // let it set during the beta //#endif ProcessBase(); #ifdef ONLINE_MODE void UncryptAll(); UncryptAll(); #ifdef USER_MODE // Make sure the list of file is unaltered char *fileAllowedAndSecret = new char[30000]; fileAllowedAndSecret[0] = '\0'; for (int i=0; i (Rect3.right-Rect3.left) * 0.75f) TEST_SX = (Rect3.right-Rect3.left) * 0.75f; if (TEST_SY > (Rect3.bottom-Rect3.top) * 0.75f) TEST_SY = (Rect3.bottom-Rect3.top) * 0.75f; #ifdef ONLINE_MODE hideWindow = true; #endif if (lpCmdLine && *lpCmdLine) { char *LPParse; LPParse = lpCmdLine; if (*LPParse == '"') { while (*LPParse) { *LPParse = *(LPParse+1); LPParse++; } if ((LPParse-2) >= lpCmdLine) { if (*(LPParse-2) == '"') *(LPParse-2) = 0; } } } //#ifndef USER_MODE if (lpCmdLine && !strncmp(lpCmdLine, "camcam://", 9)) // when called from a browser, make sure we start properly //#endif // Set current directory to current .EXE { char *pConv,CurrentDir[2048]; GetModuleFileName(NULL,CurrentDir,2048); pConv = (char*)CurrentDir + strlen(CurrentDir); while (pConv > (char*)CurrentDir) { if ((*pConv == '\\') || (*pConv == '/')) { *pConv = 0; pConv = (char*)CurrentDir; // Break loop } pConv--; } SetCurrentDirectory(CurrentDir); }//*/ GetCurrentDirectory(1024, CurrentDir); // First of all prevent multiple application opening //AppAccesMutex = CreateMutex(NULL, FALSE, "CamCamMutex"); //if (WAIT_OBJECT_0 != WaitForSingleObject(AppAccesMutex, waitTime) || (lpCmdLine && !strcmp(lpCmdLine, "exit"))) //{ // if (IsServiceLaunch) // return 0; // if (!lpCmdLine || !*lpCmdLine) // lpCmdLine = "camcam.lua"; // make sure the sleeping instance receives the default script // if (lpCmdLine && ((*lpCmdLine && (GetFileNameExtend(lpCmdLine) == '.LUA')) || (GetFileNameExtend(lpCmdLine) == '.ZCC') || !strcmp(lpCmdLine, "exit") || !strncmp(lpCmdLine, "camcam://", 9))) // { // WORD sockVersion = MAKEWORD(1,1); // WSADATA wsaData; // WSAStartup(sockVersion, &wsaData); // SOCKET ServerSock; // // unsigned int port = 10000; // while (port < 10004) // { // ServerSock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); // if(ServerSock == INVALID_SOCKET) // { // WSACleanup(); // return 0; // } // sockaddr_in sinDistant; // sinDistant.sin_family = AF_INET; // sinDistant.sin_addr.s_addr = inet_addr("127.0.0.1"); // sinDistant.sin_port = htons(port); // if(!connect(ServerSock, (sockaddr*)&sinDistant, sizeof(sockaddr_in))) // { // char TEXT[] = "WHO_ARE_YOU"; // send(ServerSock, TEXT, strlen(TEXT) +1, 0); // char response [5]; // struct timeval tv; // // // tv.tv_sec = 3; /* 3 Secs Timeout */ // int sopt = setsockopt(ServerSock, SOL_SOCKET /*IPPROTO_TCP*/, SO_RCVTIMEO, (const char *)&tv, sizeof(struct timeval)); // if (sopt == 0) // { // int res = recv (ServerSock, response, 4, 0); // if (res <= 0 || // strcmp(response, "CCOK") != 0) // { // port ++; // continue; // } // } // // char command[1024]; // if (GetFileNameExtend(lpCmdLine) == '.ZCC') // sprintf(command, "ZCC_Load %s", lpCmdLine); // else // sprintf(command, "LUA_Load %s", lpCmdLine); // send(ServerSock, command, (int)strlen(command)+1, 0); // closesocket(ServerSock); // break; // } else // { // port ++; // } // } // WSAStartup(sockVersion, &wsaData); // } // CloseHandle(AppAccesMutex); // return 0; //} //else // TODO: handle "camcam://" when starting with a fresh instance //{ // if (!strncmp(lpCmdLine, "camcam://", 9)) // in USER_MODE, this would be considered as a non-authorized file // lpCmdLine = "camcam.lua"; // if (waitTime > 500) // Sleep(500); //} #if _DEBUG //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif SHGetFolderPath( NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE , NULL, SHGFP_TYPE_CURRENT, AppDataPath); SHGetFolderPath( NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE , NULL, SHGFP_TYPE_CURRENT, MyDocsPath); SHGetFolderPath( NULL, CSIDL_MYMUSIC|CSIDL_FLAG_CREATE , NULL, SHGFP_TYPE_CURRENT, MyMusicsPath); SHGetFolderPath( NULL, CSIDL_MYPICTURES|CSIDL_FLAG_CREATE , NULL, SHGFP_TYPE_CURRENT, MyPicturesPath); #ifndef NO_DIR_CREATE if (!FILEIO_IsModePackedEXE()) { strcat(AppDataPath, "\\YouUp\\"); CreateDirectory(AppDataPath, NULL); strcat(MyDocsPath, "\\YouUp\\"); CreateDirectory(MyDocsPath, NULL); strcat(MyMusicsPath, "\\"); CreateDirectory(MyMusicsPath, NULL); strcat(MyPicturesPath, "\\"); CreateDirectory(MyPicturesPath, NULL); // PL AddUserNameInRegistry(); } #endif #ifndef USER_MODE strcpy(CamcamCCM, "Camcam.ccm"); #else sprintf(CamcamCCM, "%sCamcam.ccm", AppDataPath); #endif MSG msg; u32 FrmaeNum = 0; RECT Rect1,Rect2; /* Auto update */ // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_WINMPG, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); if (!InitInstance (hInstance, SW_HIDE)) return FALSE; #ifdef RENDER_OVER_ACTIVEX_WINDOW extern HWND getActiveXhWnd(); if (getActiveXhWnd()) { SetParent(hWnd, getActiveXhWnd()); SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } #elif defined(RENDER_INTO_ACTIVEX_WINDOW) // Redirect display output to ActiveX window (does not handle inputs though) extern HWND getActiveXhWnd(); if (getActiveXhWnd()) hWnd = getActiveXhWnd(); #endif GetClientRect(hWnd , &Rect1); GetWindowRect(hWnd , &Rect2); Rect1 . bottom -= Rect1 . top; Rect2 . bottom -= Rect2 . top; Rect1 . right -= Rect1 . left; Rect2 . right -= Rect2 . left; SetWindowPos(hWnd , NULL , 0 , 0 , TEST_SX + Rect2 . right - Rect1 . right , TEST_SY + Rect2 . bottom - Rect1 . bottom , SWP_NOMOVE); CoInitialize(0); #ifdef ONLINE_MODE if (!Account.init()) { MessageBox(hWnd, Account.getErrorStr(), "CamCam message", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); API_EXIT(); } // BACK to rev#9740 // Get hardware Info (must be called after CurrWebCam is known) Account.storeHardwareSnapshot(); #endif TheScene = MyCreateWORLD(hWnd,TEST_SX,TEST_SY,CamcamCCM); #ifndef BEGIN_MINIMIZED if (!hideWindow) ShowWindow(hWnd, SW_SHOW); else ShowWindow(hWnd, SW_HIDE); #endif #ifdef SOUND_ON if ( Audio.Initialisation( hWnd ) ) { Audio.Start(); } #endif //chargement des infos char MicroSound[64]; GetWebCamNames(WebCamNames, &NbWebCams, 64); TheScene->GetIniValue(CamcamCCM, "CurrWebCam", CurrWebCam); TheScene->GetIniValue(CamcamCCM, "AVICompressor", AVICompressor); TheScene->GetIniValue(CamcamCCM, "AVIMicroSound", MicroSound); AVIMicroSound = atoi(MicroSound); if (*CurrWebCam) { int GetWebCamByName(char *compressorsName); int defaultCam = GetWebCamByName(CurrWebCam); if (defaultCam == -1 && NbWebCams > 0) strcpy(CurrWebCam, WebCamNames[0]); } else if (NbWebCams > 0) strcpy(CurrWebCam, WebCamNames[0]); #ifndef USER_MODE VersionNumber = 0; if (!FILEIO_IsModePackedEXE()) { FILE *F; F = CC_fopen("Camcam.ver","wt"); if (F) { char string[2048]; VersionNumber = 0; #define DEFINE_VERSION(a) \ sprintf(string,"N°%d:%s\n",VersionNumber++,a);\ fwrite(string,strlen(string),1,F); #include "version.h" CC_fclose(F); } } { if(TheScene->GetIniValue(CamcamCCM, "debuggingLua")) debuggingLua = true; if(TheScene->GetIniValue(CamcamCCM, "debuggingFile")) debuggingFile = true; if(TheScene->GetIniValue(CamcamCCM, "noCompression")) noCompression = true; if(TheScene->GetIniValue(CamcamCCM, "wndNotOnTop")) { SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); AlwaysOnTop = 0; } //vérification de la présence du fichier Camcam.INI et création en cas d'absence FILE *iniFile = CC_fopen(CamcamCCM,"at"); if(iniFile) CC_fclose(iniFile); //récupération du chemin du dernier script chargé char Name[2048]; bool needToSave = false; TheScene->GetIniValue(CamcamCCM, "lastScriptPath", Name); //... et gestion de l'absence de ce fichier script FILE* scriptFile = 0; if(*Name) scriptFile = CC_fopen(Name,"rt"); if(scriptFile) CC_fclose(scriptFile); else { if(!(scriptFile = CC_fopen("COMMAND.LUA","rt"))) system("COPY /Y INIT.LUA COMMAND.LUA"); else CC_fclose(scriptFile); strcpy(Name, "COMMAND.LUA\0"); needToSave = true; } if (lpCmdLine && *lpCmdLine && GetFileNameExtend(lpCmdLine) == '.LUA') { strcpy(Name, lpCmdLine); } if (needToSave) { TheScene->SetIniValue(CamcamCCM, "lastScriptPath", Name); TheScene->SaveIniFile(CamcamCCM); } //copie des fichiers utiles pour Lua dans Notepad++ //if (!FILEIO_IsModePackedEXE()) { extern void LuaSupportForNotepadPP(); LuaSupportForNotepadPP(); } //conversion d'un fichier SVG en fichier MAD #ifdef USE_SVG if(TheScene->GetIniValue(CamcamCCM, "svg2Mad") && TheScene->GetIniValue(CamcamCCM, "svgFilename")) { char svgFilename[260]; TheScene->GetIniValue(CamcamCCM, "svgFilename", svgFilename); char svgCompleteFilename[260]; sprintf(svgCompleteFilename, "SVG\\%s", svgFilename); char madCompleteFilename[260]; sprintf(madCompleteFilename, "Mads\\%s.mad", svgFilename); extern bool svg2mad(char* svgFilename, char* destMadFilename); svg2mad(svgCompleteFilename, madCompleteFilename); } #endif //chargement du dernier script u32 ZCCL = 0; if (lpCmdLine && *lpCmdLine && GetFileNameExtend(lpCmdLine) == '.ZCC') { ZCCL = TheScene->UNPACK(lpCmdLine,1,FILEIO_IsModePackedEXE()); } if (!ZCCL) { TheScene->currentScript = 0; sprintf(TheScene->ScriptNameStack[TheScene->currentScript],"%s", Name); bnoBlitte++; if (GetFileNameExtend(TheScene->ScriptNameStack[TheScene->currentScript]) == '.LUA') { TheScene->LoadLua(TheScene->ScriptNameStack[TheScene->currentScript], 1); } bnoBlitte--; } } #else { if (!*lpCmdLine) lpCmdLine = "camcam.lua"; if (IsFileAllowed(lpCmdLine,0)) { sprintf(TheScene->ScriptNameStack[TheScene->currentScript],"%s", lpCmdLine); bnoBlitte++; TheScene->LoadLua(TheScene->ScriptNameStack[TheScene->currentScript], 1); bnoBlitte--; } else { void displayIntegrityError(int num); displayIntegrityError(1); return 0; } } #endif // USER_MODE char Fusk[2048]; // HINSTANCE LodedD = LoadDriver("CamCamDrv.sys"); while (FinishApp) { //if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) //if (PeekMessage(&msg, NULL, 0, 0 ,PM_REMOVE) ) while (PeekMessage(&msg, NULL, 0, 0 ,PM_REMOVE) ) { TranslateMessage(&msg); DispatchMessage(&msg); } #ifdef RENDER_OVER_ACTIVEX_WINDOW /*RECT hostRect, myRect; GetWindowRect(HostHWnd, &hostRect); GetWindowRect(hWnd, &myRect); if (hostRect.left != myRect.left || hostRect.top != myRect.top || hostRect.right != myRect.right || hostRect.bottom != myRect.bottom) { MoveWindow(hWnd, hostRect.left, hostRect.top, hostRect.right-hostRect.left, hostRect.bottom-hostRect.top, TRUE); //SetWindowPos(hWnd, HostHWnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); }*/ #endif static u32 tLastAccountCheck = 0; u32 tNow = timeGetTime(); #ifdef ONLINE_MODE if (tNow - tLastAccountCheck > 249) // check 4 times per second { // Check completed download for lua callbacks in main thread Account.checkCompletedDownloads(); tLastAccountCheck = tNow; // Track video driver usage extern INPUT_IO *MainDriver; extern u32 DRVO_ISLINKED(INPUT_IO *pDRO); static bool prevDriverIsLinked = false; bool driverIsLinked = MainDriver && DRVO_ISLINKED(MainDriver); if (driverIsLinked ^ prevDriverIsLinked) Account.addBufferedRequest("trk-time", 0, driverIsLinked ? "1" : "0"); prevDriverIsLinked = driverIsLinked; } #endif if ((IconTime != -1) && (tNow - IconTime > 5000)) AnimateIcon(NULL, hWnd, NIM_MODIFY,0,""); #ifndef SKIMMED_NET //TheScene->ClearConsole(); #ifdef NET_DBUG sprintf(Fusk,"SYE %s(%s):%d -> UDP = %dK",TheScene->NetObj->MyComputerName,TheScene->NetObj->MyIP,TheScene->NetObj->MyPort,TheScene->NetObj->RATE_UP >> 10); TheScene->OutputConsole(Fusk); sprintf(Fusk,"RateUp = %dK , RateDown = %dK ",TheScene->NetObj->ACTUAL_RATE_UP>>10,TheScene->NetObj->ACTUAL_RATE_DOWN>>10); TheScene->OutputConsole(Fusk); for (u32 CCC = 0 ; CCC < 32 ; CCC ++) { if (TheScene->NetObj->LinkedIP[CCC].ulIP != 0) { sprintf(Fusk,"Linked to %s %d.%d.%d.%d (SS=%d CPN=%d lost=%d%%))", TheScene->NetObj->LinkedIP[CCC].ComputerName, (TheScene->NetObj->LinkedIP[CCC].ulIP>>24)&0xff, (TheScene->NetObj->LinkedIP[CCC].ulIP>>16)&0xff, (TheScene->NetObj->LinkedIP[CCC].ulIP>>8)&0xff, (TheScene->NetObj->LinkedIP[CCC].ulIP>>0)&0xff, TheScene->NetObj->LinkedIP[CCC].Number, TheScene->NetObj->LinkedIP[CCC].CurrentPacketNumber, (100*TheScene->NetObj->LinkedIP[CCC].LostPackets) / (TheScene->NetObj->LinkedIP[CCC].GoodPackets + TheScene->NetObj->LinkedIP[CCC].LostPackets) ); TheScene->OutputConsole(Fusk); } } sprintf(Fusk,"KOOL = %d,ITN = %d",TheScene->NetObj->CoolNotifycation,TheScene->NetObj->InTheNet); TheScene->OutputConsole(Fusk); #endif #endif if (UpdateLocked) LockWindowUpdate(hWnd); else LockWindowUpdate(NULL); #ifndef _DEBUG #ifdef USER_MODE if (IsDebuggerPresent()) exit(0); #endif #endif Blitte(); // OnFocus event bool CheckFocus(); static bool prevHasFocus = CheckFocus(); TheScene->hasFocus = CheckFocus(); #ifdef ONLINE_MODE // From now, the card refresh is called by the Flash web with Socket, // but if the current socket communication port is different from 10000 (def one) // the shop will not communicate with us extern unsigned int FLASHPORT ; if (TheScene->hasFocus && !prevHasFocus && FLASHPORT != 10000) Account.checkRefreshCards(); // Relaunch CamCam if needed (even in USER_MODE after disconnection due to dual log-in) extern volatile int NeedRelaunching; if (NeedRelaunching > 0) { if (NeedRelaunching == ERROR_INVALID_TOKEN) { // In main thread, in order to block application usage MessageBox(NULL, Account.getLocErrorMsg(YOUR_ACCOUNT_IS_BEING_USED_ON_ANOTHER_COMPUTER___), "YouUp", MB_OK | MB_ICONWARNING); } if (NeedRelaunching == ERROR_MANDATORY_PATCH) API_EXIT(); else API_RESTART(NULL); } extern volatile bool NeedExit; if (NeedExit) API_EXIT(); Account.sendMessageReceived(); Account.checkFacebookThread(); #endif prevHasFocus = TheScene->hasFocus; } #ifdef SOUND_ON Audio.Stop(); Audio.Liberations(); #endif return msg.wParam; } ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_ICON1); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = NULL;//(HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = NULL; return RegisterClassEx(&wcex); } BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { u32 VersionNumber = 0; #define DEFINE_VERSION(a) VersionNumber++; #include "version.h" char WindowName[2048]; //sprintf(WindowName,"YouUp V1.%d",VersionNumber); #if YOUUP_IN_BETA == 1 strcpy(WindowName,"YouUp Beta"); #else strcpy(WindowName,"GenAnim"); #endif DWORD WND_ON_TOP = WS_EX_TOPMOST; AlwaysOnTop = 0; //création de la fenetre #ifndef USER_MODE #ifdef RENDER_OVER_ACTIVEX_WINDOW u32 flag = WS_POPUP /*| WS_CLIPCHILDREN*/ ; #else u32 flag = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; #endif #else #ifdef RENDER_OVER_ACTIVEX_WINDOW u32 flag = WS_CHILD /*| WS_CLIPCHILDREN*/; #else u32 flag = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_CLIPCHILDREN; #endif #endif hWnd = CreateWindowEx(WS_EX_WINDOWEDGE, szWindowClass, WindowName, flag, CW_USEDEFAULT, CW_USEDEFAULT, 400, 400, NULL, NULL, hInstance, NULL ); if (!hWnd) { return FALSE; } ShowWindow(hWnd, /*SW_HIDE);//*/nCmdShow); UpdateWindow(hWnd); /* TASK ICON CREATION *********************************************************************************/ AnimateIcon(hInstance, hWnd, NIM_ADD,0,""); WINDOWPLACEMENT lpwndpl; GetWindowPlacement(hWnd,&lpwndpl); return TRUE; } void CheckMenu(HMENU hMenu) { if (!hMenu) return; CheckMenuItem(hMenu,ID_TRAYICONMENU_AUTORELOADMADS,MF_CHECKED); char Text[2048]; #ifdef VERSION_STR sprintf(Text, "Version n°%s", VERSION_STR); #else sprintf(Text, "Version n°%d", VersionNumber); #endif if (MenuListNb) { for (int i=0; iSkipFunctions & SKIP_NO_60hz_LIMIT)) CheckMenuItem(hMenu,ID_SKIPFUNCTION_LIMITFRAMERATETO60HZ,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_LIMITFRAMERATETO60HZ,MF_UNCHECKED); if (TheScene->WFlags & MAD_AUTO_RELOAD) CheckMenuItem(hMenu,ID_TRAYICONMENU_AUTORELOADMADS,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRAYICONMENU_AUTORELOADMADS,MF_UNCHECKED); if (TheScene->ID_TABLE[TheScene->CurrentID] && TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.DrawMesh) CheckMenuItem(hMenu,ID_TRAYICONMENU_SHOWMESH,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRAYICONMENU_SHOWMESH,MF_UNCHECKED); if (bSurchargeMouseCursor) CheckMenuItem(hMenu,ID_TRAYICONMENU_USEHEADMOUSE,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRAYICONMENU_USEHEADMOUSE,MF_UNCHECKED); if (TheScene->WebCamXInvert) CheckMenuItem(hMenu,ID_CAMCAM_INVERTWEBCAMHORIZONTALLY,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_INVERTWEBCAMHORIZONTALLY,MF_UNCHECKED); if (TheScene->ulForceWireFrame) CheckMenuItem(hMenu,ID_CAMCAM_FORCEWIREFRAME,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_FORCEWIREFRAME,MF_UNCHECKED); if (TheScene->WebCamYInvert) CheckMenuItem(hMenu,ID_CAMCAM_INVERTWEBCAMVERTICALLY,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_INVERTWEBCAMVERTICALLY,MF_UNCHECKED); if (aviEncoder) CheckMenuItem(hMenu,ID_CAMCAM_EXPORTAVI,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_EXPORTAVI,MF_UNCHECKED); if (TheScene->WSPC) { if (TheScene->WSPC->DrawDebug) CheckMenuItem(hMenu,ID_TRACKEUR_DRAWDEBUG1,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRACKEUR_DRAWDEBUG1,MF_UNCHECKED); } if (TheScene->WSPC) { if (TheScene->WSPC->DrawDebug2) CheckMenuItem(hMenu,ID_TRACKEUR_DRAWDEBUG2,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRACKEUR_DRAWDEBUG2,MF_UNCHECKED); } if (TheScene->bDrawRasters) CheckMenuItem(hMenu,ID_TRACKEUR_DRAWRASTERS,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRACKEUR_DRAWRASTERS,MF_UNCHECKED); if (TheScene->bDrawConsole) CheckMenuItem(hMenu,ID_CAMCAM_DRAWCONSOLE,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_DRAWCONSOLE,MF_UNCHECKED); if (HideBorders) CheckMenuItem(hMenu,ID_CAMCAM_HIDEBORDERS,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_HIDEBORDERS,MF_UNCHECKED); if (IsMaximized) CheckMenuItem(hMenu,ID_CAMCAM_FULLSCREEN,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_FULLSCREEN,MF_UNCHECKED); if (TheScene->bShowSceneInfo) CheckMenuItem(hMenu,ID_CAMCAM_DRAWSCENEINFOS,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_DRAWSCENEINFOS,MF_UNCHECKED); if (TheScene->bDrawSound) CheckMenuItem(hMenu,ID_CAMCAM_SHOWSOUND,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_SHOWSOUND,MF_UNCHECKED); if (TheScene->WSPC && TheScene->WSPC->bDrawHands) CheckMenuItem(hMenu,ID_CAMCAM_SHOWHANDS,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_SHOWHANDS,MF_UNCHECKED); if (AlwaysOnTop) CheckMenuItem(hMenu,ID_CAMCAM_ALWAYSONTOP,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_ALWAYSONTOP,MF_UNCHECKED); #ifndef SKIMMED_NET if (TheScene->NetObj && TheScene->NetObj->NET_SendToMe) CheckMenuItem(hMenu,ID_DEBUG_NETSENDTOME,MF_CHECKED); else CheckMenuItem(hMenu,ID_DEBUG_NETSENDTOME,MF_UNCHECKED); #endif if (TheScene->SkipFunctions & SKIP_NOFPS) CheckMenuItem(hMenu,ID_DEBUG_FPS,MF_CHECKED); else CheckMenuItem(hMenu,ID_DEBUG_FPS,MF_UNCHECKED); if (TheScene->UseGDI) CheckMenuItem(hMenu,ID_DEBUG_USEGDI,MF_CHECKED); else CheckMenuItem(hMenu,ID_DEBUG_USEGDI,MF_UNCHECKED); #ifdef ONLINE_MODE if (Account.isYouUpAdVisible()) CheckMenuItem(hMenu,ID_DEBUG_DRAWADVERTISING,MF_CHECKED); else CheckMenuItem(hMenu,ID_DEBUG_DRAWADVERTISING,MF_UNCHECKED); if (!Account.isYouUpAdInit()) CheckMenuItem(hMenu,ID_DEBUG_CLOSEADVERTISING,MF_CHECKED); else CheckMenuItem(hMenu,ID_DEBUG_CLOSEADVERTISING,MF_UNCHECKED); #endif if (TheScene->LayederWindow) CheckMenuItem(hMenu,ID_CAMCAM_TRANSPARENTWINDOW,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_TRANSPARENTWINDOW,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_NODEBUG) CheckMenuItem(hMenu,ID_SKIPFUNCTION_DEBUGRASTERLUA,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_DEBUGRASTERLUA,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_NOMOSAIC) CheckMenuItem(hMenu,ID_SKIPFUNCTION_MOSAIC,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_MOSAIC,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_TRACKER) CheckMenuItem(hMenu,ID_SKIPFUNCTION_TRACKER,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_TRACKER,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_SKINNING) CheckMenuItem(hMenu,ID_SKIPFUNCTION_SKINNING,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_SKINNING,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_LIGHTING) CheckMenuItem(hMenu,ID_SKIPFUNCTION_LIGHTS,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_LIGHTS,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_SWITCH_NEW_INTEREST) CheckMenuItem(hMenu,ID_SKIPFUNCTION_SWITCHTONEWINTEREST,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_SWITCHTONEWINTEREST,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_RENDER) CheckMenuItem(hMenu,ID_SKIPFUNCTION_RENDERS,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_RENDERS,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_PICKING) CheckMenuItem(hMenu,ID_SKIPFUNCTION_PICKING,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_PICKING,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_DRAWING) CheckMenuItem(hMenu,ID_SKIPFUNCTION_DRAWINGS,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_DRAWINGS,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_MEDIA) CheckMenuItem(hMenu,ID_SKIPFUNCTION_MEDIAS,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_MEDIAS,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_REVERSE) CheckMenuItem(hMenu,ID_SKIPFUNCTION_REVERSE,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_REVERSE,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_AVI) CheckMenuItem(hMenu,ID_SKIPFUNCTION_AVI,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_AVI,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_CAMERA) CheckMenuItem(hMenu,ID_SKIPFUNCTION_CAMERA,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_CAMERA,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_EFFECTS) CheckMenuItem(hMenu,ID_SKIPFUNCTION_EFFECTS,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_EFFECTS,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_SOUND) CheckMenuItem(hMenu,ID_SKIPFUNCTION_SOUND,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_SOUND,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_PARTICLES) CheckMenuItem(hMenu,ID_SKIPFUNCTION_PARTICLES,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_PARTICLES,MF_UNCHECKED); if (TheScene->ID_TABLE[TheScene->CurrentID] && TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.ComputeMask) CheckMenuItem(hMenu,ID_TRACKEUR_ACTIVEMASK,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRACKEUR_ACTIVEMASK,MF_UNCHECKED); if (TheScene->WFlags & LUA_AUTO_RELOAD) CheckMenuItem(hMenu,ID_TRAYICONMENU_LUAAUTORELOAD,MF_CHECKED); else CheckMenuItem(hMenu,ID_TRAYICONMENU_LUAAUTORELOAD,MF_UNCHECKED); #ifdef ONLINE_MODE if (Account.isShopVisible()) CheckMenuItem(hMenu,ID_CAMCAM_OPENINTERNALBROWSER,MF_CHECKED); else CheckMenuItem(hMenu,ID_CAMCAM_OPENINTERNALBROWSER,MF_UNCHECKED); #endif if (TheScene->SkipFunctions & SKIP_GLWRITE) CheckMenuItem(hMenu,ID_SKIPFUNCTION_GLWRITE,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_GLWRITE,MF_UNCHECKED); if (TheScene->SkipFunctions & SKIP_GLREAD) CheckMenuItem(hMenu,ID_SKIPFUNCTION_GLREAD,MF_CHECKED); else CheckMenuItem(hMenu,ID_SKIPFUNCTION_GLREAD,MF_UNCHECKED); CheckMenuItem(hMenu,ID_DRIVER_D3D,MF_UNCHECKED); CheckMenuItem(hMenu,ID_DRIVER_OPENGL,MF_UNCHECKED); CheckMenuItem(hMenu,ID_DRIVER_NULL,MF_UNCHECKED); if (TheScene->DI->GetDriverType() == 0) CheckMenuItem(hMenu,ID_DRIVER_OPENGL,MF_CHECKED); if (TheScene->DI->GetDriverType() == 1) CheckMenuItem(hMenu,ID_DRIVER_D3D,MF_CHECKED); if (TheScene->DI->GetDriverType() == 2) CheckMenuItem(hMenu,ID_DRIVER_NULL,MF_CHECKED); } void ContextualMenu() { HMENU hMenu; if (!TheScene) return; ShowCursor(true); #ifndef USER_MODE if(hMenu = LoadMenu(hBigInstance, (LPCTSTR) MAKEINTRESOURCE(IDR_MENU1))) #else if(hMenu = LoadMenu(hBigInstance, (LPCTSTR) MAKEINTRESOURCE(IDR_MENU2))) #endif // USER_MODE { ULONG uIDNewItem; uIDNewItem = 0xC0DE2004; hMenu = GetSubMenu(hMenu, 0); CheckMenu(hMenu); if(hMenu != NULL) { POINT pt; GetCursorPos(&pt); SetForegroundWindow(hWnd); TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON , pt.x, pt.y, 0, hWnd, NULL); } } ShowCursor(0); } TCHAR NameText[1024]; INT_PTR CALLBACK DialogProcName( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch (uMsg) { case WM_CLOSE: EndDialog(hwndDlg, wParam); return TRUE; case WM_MOVING: //Blitte(); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: GetDlgItemText(hwndDlg,IDC_EDIT1,NameText,1024); EndDialog(hwndDlg, wParam); return TRUE; } } return 0; } INT_PTR CALLBACK DialogVideoCapture( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int curSel = -1; char AVILocalCompressor[256]; switch (uMsg) { case WM_INITDIALOG: GetVideoEncodersNames(CompressorsNames, &NbCompressorsNames, 64); for (int i=0; iSetIniValue(CamcamCCM, "AVICompressor", AVICompressor); sprintf(MicroSound, "%i", AVIMicroSound); TheScene->SetIniValue(CamcamCCM, "AVIMicroSound", MicroSound); TheScene->SaveIniFile(CamcamCCM); } else return false; } if (AVICompressorStr != NULL) strcpy(AVICompressorStr, AVICompressor); return true; } INT_PTR CALLBACK DialogWebcamSelect( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int curSel = -1; char CurrLocalWebCam[256]; switch (uMsg) { case WM_INITDIALOG: for (int i=0; iID_TABLE[TheScene->CurrentID]) { TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.Booted = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.Ready2Learn = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.DrawMesh = 0; TheScene->bManualBoot = 0; } } void WindowToggleHideBorders() { HideBorders ^= 1; int Res = GetWindowLong(hWnd, GWL_STYLE); static RECT wDelta; RECT wRect; RECT wBounds; BOOL GetWindowClientRect(HWND wnd, RECT *clientRect); GetWindowClientRect(hWnd, &wBounds); GetWindowRect(hWnd, &wRect); if (HideBorders) { SetRect(&wDelta,wBounds.left - wRect.left, wBounds.top - wRect.top, wRect.right - wBounds.right, wRect.bottom - wBounds.bottom); Res &= ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU|WS_CAPTION | WS_THICKFRAME | WS_BORDER ); // Turn it off SetWindowLong(hWnd, GWL_STYLE, Res); SetWindowPos(hWnd, NULL, wBounds.left, wBounds.top, wBounds.right - wBounds.left, wBounds.bottom - wBounds.top, SWP_SHOWWINDOW); } else { Res |= (WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU|WS_CAPTION | WS_THICKFRAME | WS_BORDER ); // Turn it on SetWindowLong(hWnd, GWL_STYLE, Res); SetWindowPos(hWnd, NULL,wBounds.left - wDelta.left, wBounds.top - wDelta.top, wBounds.right - wBounds.left + wDelta.left + wDelta.right, wBounds.bottom - wBounds.top + wDelta.top + wDelta.bottom, SWP_SHOWWINDOW); } MustUpdate = 1; } void WindowToggleTopMost() { if (AlwaysOnTop) { SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); AlwaysOnTop = 0; } else { SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); AlwaysOnTop = 1; } } int WindowToggleFullScreen(int Mode) { if (Mode == -1) return IsMaximized; if (IsMaximized == Mode) return IsMaximized; if (IsMaximized) { ShowWindow(hWnd,SW_RESTORE); UpdateAllBack(TheScene); IsMaximized = 0; } else { if (!AlwaysOnTop) { WindowToggleTopMost(); ShowWindow(hWnd,SW_MAXIMIZE); WindowToggleTopMost(); } else ShowWindow(hWnd,SW_MAXIMIZE); UpdateAllBack(TheScene); IsMaximized = 1; } return IsMaximized; } BOOL GetDrawWindowRect(RECT *winRect, int XSize, int YSize, HWND hWnd) ; void VectInMouseEnv(Vector *T, int mouseX, int mouseY, float focale, HWND hWnd) { float OldLenght = T->Norm(); RECT SmalwinRect; int LX,LY; GetDrawWindowRect(&SmalwinRect, TheScene->XSize, TheScene->YSize, hWnd); LX = SmalwinRect.right - SmalwinRect.left; LY = SmalwinRect.bottom - SmalwinRect.top; T->z = 5.0f; T->x = ((float)(TheScene->MouseX - SmalwinRect.left)) / (float)LX - 0.5f; T->y = ((float)(LX + LY)*0.5f + -(TheScene->MouseY-SmalwinRect.top)) / (float)LX - 0.5f; *T *= 2.0f; T->z = focale; T->Normalize(); *T *= OldLenght; } char* GetShortcutTarget(char* Link) { HRESULT hres; Link = strlwr(Link); IShellLink* psl; //Create the ShellLink object hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*) &psl); if (SUCCEEDED(hres)) { IPersistFile* ppf; //Bind the ShellLink object to the Persistent File hres = psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf); if (SUCCEEDED(hres)) { WORD wsz[MAX_PATH]; //Get a UNICODE wide string wsz from the Link path MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, Link, -1, (LPWSTR)wsz, MAX_PATH); //Read the link into the persistent file hres = ppf->Load((LPWSTR)wsz, 0); if (SUCCEEDED(hres)) { //Read the target information from the link object //UNC paths are supported (SLGP_UNCPRIORITY) Link = (char*)CC_realloc(Link, 1024); psl->GetPath(Link, 1024, NULL, SLGP_UNCPRIORITY); } } } psl->Release(); //Return the Target and the Argument as a CString return Link; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { ::hWnd = hWnd; if (!(TheScene && (TheScene->InputHook(message, wParam, lParam) || TheScene->LuaHandle(message, wParam, lParam)))) switch (message) { #ifndef USER_MODE case WM_CREATE: DragAcceptFiles(hWnd,TRUE); return 0; break; case WM_DROPFILES: { HDROP hDropFiles; int nChar; char* nameFile; hDropFiles = (HDROP)wParam; nChar = 1 + DragQueryFile(hDropFiles,0,NULL,0); nameFile = (char*)CC_malloc(nChar); DragQueryFile(hDropFiles,0,nameFile,nChar); if (GetFileNameExtend(nameFile) == '.LNK') { nameFile = GetShortcutTarget(nameFile); } if (GetFileNameExtend(nameFile) == '.LUA') { TheScene->currentScript = 0; sprintf(TheScene->ScriptNameStack[TheScene->currentScript],"%s", nameFile); TheScene->SetIniValue(CamcamCCM, "lastScriptPath", nameFile); TheScene->SaveIniFile(CamcamCCM); TheScene->LoadLua(TheScene->ScriptNameStack[TheScene->currentScript], 1); } if (GetFileNameExtend(nameFile) == '.ZCC') { TheScene->UNPACK(nameFile,1,0); } CC_free(nameFile); DragFinish(hDropFiles); } break; #endif // USER_MODE case WM_SYSCOMMAND: if (wParam==SC_KEYMENU) { // do nothing when alt key or F10 key is pressed return TRUE; } return DefWindowProc(hWnd, message, wParam, lParam); break; case MYMSG_NOTIFYICON: switch(lParam) { #ifndef USER_MODE case 1029: if (MessageBox(hWnd,UpdateTextTEXT,"Camcam message",MB_YESNO|MB_SYSTEMMODAL|MB_ICONWARNING) == IDYES) API_UPDATE_EXE(); return TRUE; #endif // USER_MODE case WM_RBUTTONDOWN: ContextualMenu(); break ; } return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_CLOSE: API_EXIT(); return TRUE; case WM_COMMAND: int wmId, wmEvent; wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { // Common Menu case ID_TRAYICONMENU_EXIT: #ifdef USER_MODE TheScene->LuaProcessEvent(EVT_onExit); #else DestroyWindow(hWnd); API_EXIT(); #endif break; case ID_CAMCAM_CONFIGURE_AVI: GetAVICompressor(true, NULL); break; case ID_CAMCAM_SELECTDEFAULTWEBCAM: if (TheScene) { TheScene->ulLockMode++; if (DialogBox(hBigInstance,MAKEINTRESOURCE(IDD_DIALOG_WEBCAM_SELECTION), hWnd, DialogWebcamSelect) == IDOK) { if (*CurrWebCam) { TheScene->SetIniValue(CamcamCCM, "CurrWebCam", CurrWebCam); TheScene->SaveIniFile(CamcamCCM); } } TheScene->ulLockMode--; if (TheScene->ulLockMode == -1) TheScene->ulLockMode = 0; } break; case ID_TRAYICONMENU_OPENMEDIADIRECTORY: { char FullName[2048]; sprintf(FullName,"explorer %s", CurrentDir); WinExec(FullName,SW_SHOW); } break; case ID_CAMCAM_EXPORTAVI: if (aviEncoder == 0) { char Compressor[256]; if (!TheScene->UseGDI) { TheScene->ChangeGDIMode(!TheScene->UseGDI); TheScene->ulFullRefresh = true; } if (GetAVICompressor(false, Compressor)) { char Name[2048]; memset(Name, 0, sizeof(Name)); CDLG_USR_GetFileName(Name, "AVI File|*.AVI",hWnd,0); if (Name[0] == 0) break; AddFileNameExtend(Name, '.AVI'); if (SaveInFile_Config(Name, AVIMicroSound, Compressor)) { SaveInFile_Run(); aviEncoder = 1; } else { *AVICompressor = 0; MessageBox(hWnd, "Error creating avi file\nPlease change compressor filter","Camcam message",MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); } } } else { SaveInFile_Stop(); aviEncoder = 0; } break; case ID_TRACKEUR_LOADID: { char Name[2048]; CDLG_USR_GetFileName(Name, "ID file|*.IDx",hWnd,0,"IDS"); TheScene->ID_Load(0,Name); break; } case ID_TRACKEUR_SAVEID: { char Name[2048]; CDLG_USR_GetFileName(Name, "ID file|*.IDx",hWnd,0,"IDS"); TheScene->ID_Save(0,Name); break; } case ID_CAMCAM_INVERTWEBCAMHORIZONTALLY: { TheScene->WebCamXInvert ^= 1; break; } case ID_CAMCAM_INVERTWEBCAMVERTICALLY: { TheScene->WebCamYInvert ^= 1; break; } case ID_CAMCAM_FORCEWIREFRAME: { TheScene->ulForceWireFrame ^= 1; break; } case ID_CAMCAM_TRANSPARENTWINDOW: { TransparentWindowSet(!TheScene->LayederWindow); break; } case ID_DEBUG_USEGDI: { TheScene->ChangeGDIMode(!TheScene->UseGDI); TheScene->ulFullRefresh = true; } break; #ifdef ONLINE_MODE case ID_DEBUG_DRAWADVERTISING: { Account.setYouUpAdPageVisible( !Account.isYouUpAdVisible() ); TheScene->forceAdVisibility = true; } break; case ID_DEBUG_CLOSEADVERTISING: { Account.closeYouUpAdPage(); } break; #endif case ID_CAMCAM_SHOWHANDS: { TheScene->WSPC->bDrawHands ^= 1; break; } case ID_CAMCAM_ALWAYSONTOP: { WindowToggleTopMost(); break; } case ID_SKIPFUNCTION_MOSAIC: TheScene->SkipFunctions ^= SKIP_NOMOSAIC; break; case ID_SKIPFUNCTION_DEBUGRASTERLUA: TheScene->SkipFunctions ^= SKIP_NODEBUG; break; case ID_SKIPFUNCTION_TRACKER: TheScene->SkipFunctions ^= SKIP_TRACKER; break; case ID_SKIPFUNCTION_RENDERS: TheScene->SkipFunctions ^= SKIP_RENDER; break; case ID_SKIPFUNCTION_PICKING: TheScene->SkipFunctions ^= SKIP_PICKING; break; case ID_SKIPFUNCTION_DRAWINGS: TheScene->SkipFunctions ^= SKIP_DRAWING; break; case ID_SKIPFUNCTION_MEDIAS: TheScene->SkipFunctions ^= SKIP_MEDIA; break; case ID_SKIPFUNCTION_REVERSE: TheScene->SkipFunctions ^= SKIP_REVERSE; break; case ID_SKIPFUNCTION_AVI: TheScene->SkipFunctions ^= SKIP_AVI; break; case ID_SKIPFUNCTION_CAMERA: TheScene->SkipFunctions ^= SKIP_CAMERA; break; case ID_SKIPFUNCTION_EFFECTS: TheScene->SkipFunctions ^= SKIP_EFFECTS; break; case ID_SKIPFUNCTION_SOUND: TheScene->SkipFunctions ^= SKIP_SOUND; break; case ID_SKIPFUNCTION_PARTICLES: TheScene->SkipFunctions ^= SKIP_PARTICLES; break; case ID_SKIPFUNCTION_SKINNING: TheScene->SkipFunctions ^= SKIP_SKINNING; break; case ID_SKIPFUNCTION_LIGHTS: TheScene->SkipFunctions ^= SKIP_LIGHTING; break; case ID_SKIPFUNCTION_SWITCHTONEWINTEREST: TheScene->SkipFunctions ^= SKIP_SWITCH_NEW_INTEREST; break; case ID_SKIPFUNCTION_GLWRITE: TheScene->SkipFunctions ^= SKIP_GLWRITE; break; case ID_SKIPFUNCTION_GLREAD: TheScene->SkipFunctions ^= SKIP_GLREAD; break; case ID_TRACKEUR_ACTIVEMASK: if (TheScene && TheScene->ID_TABLE[TheScene->CurrentID]) { TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.ComputeMask ^= 1; } break; case ID_TRAYICONMENU_RESETTRACKEUR: if (TheScene->ID_TABLE[TheScene->CurrentID]) { TheScene->ID_Reset(TheScene->CurrentID); TheScene->ID_AutoStart(TheScene->CurrentID); } break; case ID_CAMCAM_HIDEBORDERS: WindowToggleHideBorders(); break; case ID_CAMCAM_FULLSCREEN: WindowToggleFullScreen(1-IsMaximized); break; case ID_TRACKEUR_MANUALBOOT: if (TheScene->ID_TABLE[TheScene->CurrentID]) { TheScene->ID_Reset(TheScene->CurrentID); TheScene->oldManualBoot = 0; TheScene->bManualBoot = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.DrawMesh = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.CamPlaced = 0; TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.T.z = 90.0f; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.FromScratch = 0; } break; case ID_TRACKEUR_MANUALBOOT_OLD: if (TheScene->ID_TABLE[TheScene->CurrentID]) { TheScene->ID_Reset(TheScene->CurrentID); TheScene->oldManualBoot = 1; TheScene->bManualBoot = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.DrawMesh = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.CamPlaced = 0; TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.T.z = 90.0f; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.FromScratch = 0; } break; case ID_TRACKEUR_MANUALADJUST: if (TheScene && TheScene->ID_TABLE[TheScene->CurrentID]) { RECT Rect1, Rect2; int newMouseX, newMouseY; MATRIX curMatrix; Vector Scale(1,1,1); GetDrawWindowRect(&Rect1, TheScene->XSize, TheScene->YSize, hWnd); GetWindowRect(hWnd , &Rect2); if (TheScene->ID_MEDIA[TheScene->MediaToTrack] && TheScene->ID_MEDIA[TheScene->MediaToTrack]->Tracks && TheScene->MediaCurrentTrack < TheScene->ID_MEDIA[TheScene->MediaToTrack]->Tracks->ulNumberOfTracks) { int frIdx; int curValidity; frIdx = min(TheScene->ID_MEDIA[TheScene->MediaToTrack]->Tracks->TracksPtrs[TheScene->MediaCurrentTrack].ulNumberOfMC - 1, TheScene->ID_MEDIA[TheScene->MediaToTrack]->ulCurrentFrame); for (; frIdx > 0; frIdx--) { if (IsMatriceCompressedNull(&TheScene->ID_MEDIA[TheScene->MediaToTrack]->Tracks->TracksPtrs[TheScene->MediaCurrentTrack].pAnimation[frIdx])) continue; curValidity = TheScene->ID_MEDIA[TheScene->MediaToTrack]->Tracks->Get(TheScene->MediaCurrentTrack, (u32)frIdx, &curMatrix); TheScene->ID_MEDIA[TheScene->MediaToTrack]->Tracks->GetScale(TheScene->MediaCurrentTrack, &Scale); if ((curValidity & 0xFFFFFE) == 0) break; } if (frIdx == 0) { curMatrix = TheScene->ID_TABLE[TheScene->CurrentID]->PrevMatrixOK; Scale = TheScene->ID_TABLE[TheScene->CurrentID]->vModelScale; } } else { curMatrix = TheScene->ID_TABLE[TheScene->CurrentID]->PrevMatrixOK; Scale = TheScene->ID_TABLE[TheScene->CurrentID]->vModelScale; } TheScene->ID_Reset(TheScene->CurrentID); TheScene->bManualBoot = 1; TheScene->oldManualBoot = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.Booted=0; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.DrawMesh = 1; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.CamPlaced = 0; TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.FromScratch = 0; TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U = curMatrix; TheScene->ID_SetScale(TheScene->CurrentID, &Scale); int LX, LY; LX = Rect1.right - Rect1.left; LY = Rect1.bottom - Rect1.top; newMouseX = Rect2.left + Rect1.left + (float)LX/2.0f + (TheScene->GetCurrentFocale() * (float)LX * curMatrix.T.x/(2.0f*curMatrix.T.z)); newMouseY = Rect2.top + Rect1.bottom - ((float)LY/2.0f + (TheScene->GetCurrentFocale() * (float)LX * curMatrix.T.y/(2.0f*curMatrix.T.z))); SetCursorPos(newMouseX, newMouseY); } break; #ifndef USER_MODE //case ID_TRACKEUR_GENERATETAG: //extern void CreateTags(); //CreateTags(); // break; case ID_TRAYICONMENU_RESTARTAPI: API_RESTART(NULL); break; case ID_TRAYICONMENU_RESTARTDRIVERAPI: API_RESTART("driver.lua"); break; case ID_TRAYICONMENU_ReloadallTEXTURES: for (int i = 0 ; i < MAX_INPMED ; i++) { if (TheScene->ID_MEDIA[i]) TheScene->ID_MEDIA[i]->ulFileAsbeenTouched = 2; } break; case ID_CAMCAM_REMOVEWRITEONLY: WinExec("ATTRIB -R /S .\\Media\\*.*",SW_SHOW); break; case ID_CAMCAM_SHOWSOUND: TheScene->bDrawSound ^= 1; break; #ifndef SKIMMED_NET case ID_DEBUG_NETSENDTOME: if (TheScene->NetObj) TheScene->NetObj->NET_SendToMe ^= 1; break; #endif case ID_DEBUG_FPS: TheScene->SkipFunctions ^= SKIP_NOFPS; break; case ID_CAMCAM_DRAWSCENEINFOS: TheScene->bShowSceneInfo ^= 1; break; case ID_TRACKEUR_DRAWDEBUG1: if (TheScene->WSPC) TheScene->WSPC->DrawDebug ^= 1; break; case ID_TRACKEUR_DRAWDEBUG2: if (TheScene->WSPC) TheScene->WSPC->DrawDebug2 ^= 1; break; case ID_TRACKEUR_DRAWRASTERS: TheScene->bDrawRasters ^= 1; break; case ID_CAMCAM_DRAWCONSOLE: TheScene->bDrawConsole ^= 1; break; case ID_SCRIPT_CHANGESCRIPT: { char Name[2048]; memset(Name, 0, sizeof(Name)); CDLG_USR_GetFileName(Name, "Script file|*.LUA",hWnd,0); if (Name[0] == 0) break; TheScene->currentScript = 0; sprintf(TheScene->ScriptNameStack[TheScene->currentScript],"%s", Name); TheScene->SetIniValue(CamcamCCM, "lastScriptPath", Name); TheScene->SaveIniFile(CamcamCCM); if (GetFileNameExtend(TheScene->ScriptNameStack[TheScene->currentScript]) == '.LUA') { TheScene->LoadLua(TheScene->ScriptNameStack[TheScene->currentScript], 1); } break; } case ID_TRAYICONMENU_EDITSCRIPT: ShellExecute(NULL, "open", TheScene->ScriptNameStack[TheScene->currentScript], NULL, NULL, SW_SHOW); break; case ID_TRAYICONMENU_SHOWSCRIPTHELP: ShellExecute(NULL, "open", ".\\Script_Help.xml", NULL, NULL, SW_SHOW); break; case ID_TRAYICONMENU_LUAAUTORELOAD: extern bool MonitorLuaChanges; TheScene->WFlags ^= LUA_AUTO_RELOAD; break; case ID_SCRIPT_SHOWLOG: { char TEXT[2048]; sprintf(TEXT,"CMD /C START %s", ".\\Script_log.log"); WinExec(TEXT,SW_HIDE); } break; case ID_RECORD_PACKCURRENT: if (TheScene) { char Name[2048]; memset(Name, 0, sizeof(Name)); CDLG_USR_GetFileName(Name, "PACK File|*.ZCC",hWnd,0); if (Name[0] == 0) break; TheScene->PACK(Name,1); } break; case ID_CAMCAM_PACKINTOEXE: if (TheScene) { u32 FILEIO_PackIntoExe(WORLD *pScene,char *EXEname,char *DSTname); char Name[2048]; memset(Name, 0, sizeof(Name)); CDLG_USR_GetFileName(Name, "EXE File|*.EXE",hWnd,0); if (Name[0] == 0) break; // FILEIO_PackIntoExe(char *EXEname); char CurrentDir[2048]; GetModuleFileName(NULL,CurrentDir,2048); FILEIO_PackIntoExe(TheScene,CurrentDir,Name); } break; case ID_TRAYICONMENU_UNPACK: if (TheScene) { char Name[2048]; memset(Name, 0, sizeof(Name)); CDLG_USR_GetFileName(Name, "PACK File|*.ZCC",hWnd,0); if (Name[0] == 0) break; TheScene->UNPACK(Name,1,0); } break; case ID_CAMCAM_IMPORTALLMEDIAFROMY: WinExec("XCOPY /Y /S Y:\\CAMCAM\\MEDIA\\*.* .\\MEDIA\\*.*",SW_HIDE); break; case ID_EDIT_THISMEDIA: if (TheScene && TheScene->PickReportFinal.CollidedMediaName[0]) { char TEXT[2048]; char TEXTCALL[2048]; FILE *F; sprintf(TEXT,"%s", TheScene->PickReportFinal.CollidedMediaName); F = CC_fopen(TEXT,"rb"); if (F) { CC_fclose(F); sprintf(TEXTCALL,"CMD /C START %s", TEXT); WinExec(TEXTCALL,SW_HIDE); } } break; case ID_EDIT_THISMATERIAL: if (TheScene && TheScene->PickReportFinal.CollidedSmallMaterialName[0]) { char TEXT[2048]; char TEXT2[2048]; FILE *F; sprintf(TEXT,".\\media\\%s\\MODIFIED\\%s", TheScene->PickReportFinal.CollidedSmallSceneName , TheScene->PickReportFinal.CollidedSmallMaterialName); F = CC_fopen(TEXT,"rb"); if (!F) { sprintf(TEXT2,".\\media\\%s\\%s", TheScene->PickReportFinal.CollidedSmallSceneName , TheScene->PickReportFinal.CollidedSmallMaterialName); F = CC_fopen(TEXT2,"rb"); if (F) { CC_fclose(F); CopyFile(TEXT2, TEXT,0); F = CC_fopen(TEXT,"rb"); } } if (F) { CC_fclose(F); sprintf(TEXT2,"CMD /C START %s", TEXT); WinExec(TEXT2,SW_HIDE); } } break; case ID_EDIT_THISSMALLSCENE: if (TheScene && TheScene->PickReportFinal.CollidedSmallSceneName[0]) { char TEXT[2048]; char TEXT2[2048]; FILE *F; sprintf(TEXT,".\\media\\%s\\MODIFIED\\SMSC.SSC", TheScene->PickReportFinal.CollidedSmallSceneName); F = CC_fopen(TEXT,"rb"); if (!F) { sprintf(TEXT2,".\\media\\%s\\SMSC.SSC", TheScene->PickReportFinal.CollidedSmallSceneName); F = CC_fopen(TEXT2,"rb"); if (F) { CC_fclose(F); CopyFile(TEXT2, TEXT,0); F = CC_fopen(TEXT,"rb"); } } if (F) { CC_fclose(F); sprintf(TEXT2,"CMD /C START %s", TEXT); WinExec(TEXT2,SW_HIDE); } } break; case ID_EDIT_THISOBJECT: if (TheScene && TheScene->PickReportFinal.CollidedSmallSceneGameObjectName[0]) { char TEXT[2048]; char TEXT2[2048]; FILE *F; sprintf(TEXT,".\\media\\%s\\modified\\%s.OBJ", TheScene->PickReportFinal.CollidedSmallSceneName, TheScene->PickReportFinal.CollidedSmallSceneGameObjectName); F = CC_fopen(TEXT,"rb"); if (!F) { sprintf(TEXT2,".\\media\\%s\\%s.OBJ", TheScene->PickReportFinal.CollidedSmallSceneName, TheScene->PickReportFinal.CollidedSmallSceneGameObjectName); F = CC_fopen(TEXT2,"rb"); if (F) { CC_fclose(F); CopyFile(TEXT2, TEXT,0); F = CC_fopen(TEXT2,"rb"); } } if (F) { CC_fclose(F); sprintf(TEXT2,"CMD /C START %s", TEXT); WinExec(TEXT2,SW_HIDE); } } break; case ID_CAMCAM_IMPORTALLMEDIAFROMY32806: WinExec("CM1.BAT",SW_SHOW); break; case ID_CAMCAM_CALLY: WinExec("CM2.BAT",SW_SHOW); break; case ID_TRAYICONMENU_AUTORELOADMADS: TheScene->WFlags ^= MAD_AUTO_RELOAD; break; case ID_SKIPFUNCTION_LIMITFRAMERATETO60HZ: TheScene->SkipFunctions ^= SKIP_NO_60hz_LIMIT; break; #endif //USERMODE case ID_DRIVER_D3D: TheScene->ChangeDriver(1); break; case ID_DRIVER_OPENGL: TheScene->ChangeDriver(0); break; case ID_DRIVER_NULL: TheScene->ChangeDriver(2); break; case ID_TRAYICONMENU_USEHEADMOUSE: bSurchargeMouseCursor ^= 1; break; case ID_TRAYICONMENU_SHOWMESH: if (TheScene->ID_TABLE[TheScene->CurrentID]) TheScene->ID_TABLE[TheScene->CurrentID]->SF_U.DrawMesh ^= 1; break; case ID_TRAYICONMENU_SETNAME: NameText[0] = 0; DialogBox(hBigInstance,MAKEINTRESOURCE(IDD_DIALOG1),hWnd,DialogProcName); if (NameText[0]) { strcpy(TheScene->ID_TABLE[TheScene->CurrentID]->ID_Name,NameText); } break; #ifdef ONLINE_MODE case ID_CAMCAM_OPENINTERNALBROWSER: Account.setShopVisible(!Account.isShopVisible(), "tests/shop_test?bla"); #endif } return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_SETCURSOR: if (LOWORD (lParam) == HTCLIENT && currentCursor) { if (currentCursorType == 0) SetCursor(LoadCursor(NULL, currentCursor)); else SetCursor(LoadCursorFromFile(currentCursor)); return true; } break; case WM_PAINT: //#ifdef ONLINE_MODE // SendMessage(BrowserWnd, WM_PAINT, wParam, lParam); //#endif if (TheScene && TheScene->ulLockMode) { if (TheScene->UseGDI) TheScene->Flip_DIB(false); else { TheScene->DI->LayerOperation(1,TheScene->WMPaintLayer,0xffffffff,0,0.0f); TheScene->DI->Flip(1); } } break; case WM_NCPAINT: break; case 0x020A://WM_MOUSEWHEEL: if (TheScene) { if(TheScene->pLDS && TheScene->pLDS->showFileList) { if ((int) wParam < 0) TheScene->pLDS->fileListStartDelta -= (wParam & MK_MBUTTON) ? 20 : 4; else TheScene->pLDS->fileListStartDelta += (wParam & MK_MBUTTON) ? 20 : 4; } else { if ((int) wParam < 0) TheScene->LUA_DEBUG_BaseDisplay += (wParam & MK_MBUTTON) ? 20 : 4; else TheScene->LUA_DEBUG_BaseDisplay -= (wParam & MK_MBUTTON) ? 20 : 4; } } if (TheScene && TheScene->bManualBoot) { if ((int) wParam < 0) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.T *= 0.95f; else TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.T *= 1.0f/ 0.95f; } break; case WM_MOUSEMOVE: if (TheScene) { RECT Rect1; POINT Origin; float CX,CY; GetClientRect(hWnd , &Rect1); CX = (float)TheScene->XSize / (float)(Rect1.right - Rect1.left); CY = (float)TheScene->YSize / (float)(Rect1.bottom - Rect1.top); if (LOWORD(lParam) & 0x8000) TheScene->MouseX = 0xFFFF0000 | LOWORD(lParam); else TheScene->MouseX = LOWORD(lParam); if (HIWORD(lParam) & 0x8000) TheScene->MouseY = 0xFFFF0000 | HIWORD(lParam); else TheScene->MouseY = HIWORD(lParam); mouseX = (int)(CX * (float)TheScene->MouseX); // horizontal position of cursor mouseY = (int)(CY * (float)TheScene->MouseY); // vertical position of cursor GetClientRect(hWnd , &Rect1); Origin.x = Rect1.left; Origin.y = Rect1.top; ClientToScreen(hWnd , &Origin); if (TheScene->bManualBoot) { VectInMouseEnv(&TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.T, mouseX, mouseY, TheScene->GetCurrentFocale(), hWnd); } } break; case WM_ERASEBKGND: return TRUE; case WM_RBUTTONDOWN: // if (TheScene) TheScene->MouseButton |= 1; if (TheScene->bManualBoot) ManualBootStart(); else { // Process lua Button up in button down has been pressed ... if (*TheScene->PickReportClick.PickingClass) TheScene->LuaHandle(WM_LBUTTONUP, wParam, lParam); // Process Lua End if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { ContextualMenu(); } } break; case WM_LBUTTONDOWN: if (TheScene) TheScene->MouseButton |= 2; if (TheScene->bManualBoot) ManualBootStart(); break; case WM_MBUTTONDOWN: // if (TheScene) TheScene->MouseButton |= 4; if (TheScene->bManualBoot) ManualBootStart(); break; case WM_RBUTTONUP: // if (TheScene) TheScene->MouseButton &= ~1; break; case WM_LBUTTONUP: if (TheScene) TheScene->MouseButton &= ~2; break; case WM_MBUTTONUP: // if (TheScene) TheScene->MouseButton &= ~4; break; case WM_SYSKEYDOWN: case WM_KEYDOWN: //extern u32 FinFace; if (TheScene && TheScene->pLDS) TheScene->pLDS->LastKeyIn = wParam; if (TheScene && (wParam == VK_F1)) TheScene->LUA_DEBUG_Flags ^= 1; else if (TheScene && TheScene->pLDS && (wParam == VK_F5)) TheScene->pLDS->DeubgTraceMode = 0; else if (TheScene) TheScene->PressKey(wParam); if ((wParam >= '0' && wParam <= '9') || (wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9)) { int len = strlen(LuaDebugGotoLine); if (len < 8) { if (wParam >= '0' && wParam <= '9') { LuaDebugGotoLine[len] = wParam; } else { LuaDebugGotoLine[len] = wParam - VK_NUMPAD0 + '0'; } LuaDebugGotoLine[len+1] = 0; TheScene->LUA_DEBUG_BaseDisplay = atoi(LuaDebugGotoLine)-1; } } else { *LuaDebugGotoLine = 0; } if (TheScene && (TheScene->SkipFunctions & SKIP_NOMOSAIC)) { int currentPage = TheScene->MosaicInfo >> 16; int mosaicSize = TheScene->MosaicInfo & 0x7fff; int MosaicAlpha = TheScene->MosaicInfo & 0x8000; if (wParam == 107) { currentPage = 0; mosaicSize = mosaicSize*2; } if (wParam == 109) { currentPage = 0; mosaicSize = mosaicSize/2; } if (wParam == 'A' || wParam == 'a') { MosaicAlpha ^= 0x8000; } if (wParam == VK_PRIOR) currentPage--; if (wParam == VK_NEXT) currentPage++; if (currentPage < 0) currentPage = 0; if (mosaicSize < 8) mosaicSize = 8; if (mosaicSize > 512) mosaicSize = 512; TheScene->MosaicInfo = (currentPage << 16 | mosaicSize) | MosaicAlpha; } /* if ((wParam == 27) && (IsMaximized))// ESCAPE { ShowWindow(hWnd,SW_RESTORE); IsMaximized = 0; }*/ if (TheScene->bManualBoot && TheScene) { if (wParam == ' ') TheScene->bManualBoot ^= 2; #define RSTEP 0.033333f if (GetAsyncKeyState(VK_SHIFT) & 0x8000) { Vector SCale; SCale = TheScene->ID_TABLE[TheScene->CurrentID]->vModelScale; if (wParam == VK_RIGHT) SCale.x *= 1.05f; if (wParam == VK_LEFT) SCale.x *= 1.0f / 1.05f; if (wParam == VK_UP) SCale.y *= 1.05f; if (wParam == VK_DOWN) SCale.y *= 1.0f / 1.05f; TheScene->ID_SetScale(0 , &SCale); } else { if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { if (wParam == VK_RIGHT) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.RotateAround(0,-RSTEP); if (wParam == VK_LEFT) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.RotateAround(0,RSTEP); } else { if (wParam == VK_RIGHT) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.RotateAround(1,-RSTEP); if (wParam == VK_LEFT) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.RotateAround(1,RSTEP); } if (wParam == VK_UP) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.RotateAround(2,RSTEP); if (wParam == VK_DOWN) TheScene->ID_TABLE[TheScene->CurrentID]->CurrentMatrix_U.RotateAround(2,-RSTEP); } } break; case WM_KEYUP: if (TheScene) TheScene->UnPressKey(wParam); break; case WM_DESTROY: FinishApp = 0; AnimateIcon(NULL, hWnd, NIM_DELETE, 0 , "App killed"); PostQuitMessage(0); break; case WM_LBUTTONDBLCLK: { int Res = GetWindowLong(hWnd, GWL_STYLE); if (Res & WS_CAPTION) SendMessage(hWnd,WM_SIZE,SIZE_MAXIMIZED,0); else SendMessage(hWnd,WM_SIZE,SIZE_RESTORED,0); } break; case WM_NCCALCSIZE: return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_SIZE: /* Check to see if we are losing or gaining our window. */ { if (wParam == SIZE_MAXIMIZED ) { IsMaximized = 1; } else if (wParam == SIZE_MINIMIZED ) { ShowWindow(hWnd,SW_HIDE); } } case WM_SIZING: case WM_MOVING: case WM_MOVE: case WM_DISPLAYCHANGE: if (TheScene) { RECT CR; GetClientRect(hWnd , &CR); if (CR.right != CR.left && CR.bottom != CR.top) TheScene->ChangeResolution(CR.right - CR.left, CR.bottom - CR.top); } Blitte(); return TRUE; case WM_SETFOCUS: UpdateAllBack(TheScene); break; case EVENT_SYSTEM_CAPTUREEND: break; default: //#ifdef ONLINE_MODE // Account.processWindowsMessage(hWnd, message, wParam, lParam); //#endif break; } return DefWindowProc(hWnd, message, wParam, lParam); } void TrackerSetWindow(s32 X,s32 Y,s32 SizeX , s32 SizeY , s32 Visible , s32 HBorder, HWND PlaceAfter ) { if (HBorder != -1) { HBorder = HBorder ? 0 : 1; if (HideBorders ^ HBorder) WindowToggleHideBorders(); } if (Visible != -1) { RECT rect, *rectPtr = NULL; if ((X == -1) && (Y == -1) && (SizeX == -1) && (SizeY == -1)) { SetRect(&rect, X, Y, X+SizeX, Y+SizeY); rectPtr = ▭ } Visible = Visible ? 0 : 1; } u32 Flags; Flags = SWP_NOACTIVATE; if ((X == -1) && (Y == -1)) Flags |= SWP_NOMOVE; if ((SizeX == -1) && (SizeY == -1)) Flags |= SWP_NOSIZE; if (PlaceAfter != (HWND)-1) SetWindowPos(hWnd , PlaceAfter, X , Y , SizeX , SizeY , Flags); else { Flags |= SWP_NOZORDER; SetWindowPos(hWnd , NULL , X , Y , SizeX , SizeY , Flags); } UpdateAllBack(TheScene); } void TransparentWindowSet(bool enable, bool force) { if (!TheScene) return; int WindowStyle = GetWindowLong(hWnd, GWL_EXSTYLE); if (force) SetWindowLong(hWnd, GWL_EXSTYLE, 0); if (enable) { if (!TheScene->LayederWindow || force) { TheScene->LayederWindow = 1; SetWindowLong(hWnd, GWL_EXSTYLE, WindowStyle | (WS_EX_LAYERED)); UpdateLocked = 1; } } else { if (TheScene->LayederWindow || force) { TheScene->LayederWindow = 0; SetWindowLong(hWnd, GWL_EXSTYLE, WindowStyle & (~(WS_EX_LAYERED))); UpdateLocked = 0; } } } bool launchOption(WORLD* TheScene, char* optionTitle, int optionID) { int wmId = -1; if(strlen(optionTitle)!=0) { extern HINSTANCE hBigInstance; #define NB_MENU 2 static HMENU hMenuBase = LoadMenu(hBigInstance, (LPCTSTR) MAKEINTRESOURCE(IDR_MENU1)); static HMENU hMenuBase2 = LoadMenu(hBigInstance, (LPCTSTR) MAKEINTRESOURCE(IDR_MENU2)); static HMENU hMenuTab[NB_MENU] = { hMenuBase, hMenuBase2 }; strlwr(optionTitle); char itemTitle[256]; for (int mIdx=0; mIdxSX*scale + 0.5f, img->SY*scale + 0.5f); imgPtr = &imgIn; COPY_OX_RGBA(img, imgPtr); } BasePtr = imgPtr->GetBase(); pData->rdh.dwSize = sizeof(RGNDATAHEADER); pData->rdh.iType = RDH_RECTANGLES; pData->rdh.nCount = pData->rdh.nRgnSize = 0; SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0); for (int y=imgPtr->SY-1; y>=0; y--) { for (int x=0; xSX; x++, BasePtr++) { int x0 = x; for (;x < imgPtr->SX && (((*BasePtr) & mask) >> component) >= threshhold; x++, BasePtr++); if (x == imgPtr->SX) { x--; BasePtr--; } if (x > x0) { if (pData->rdh.nCount >= maxRects) { maxRects += ALLOC_UNIT; pData = (RGNDATA *)CC_realloc(pData, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects)); } RECT *pr = (RECT *)&pData->Buffer; SetRect(&pr[pData->rdh.nCount], x0, y, x, y+1); if (x0 < pData->rdh.rcBound.left) pData->rdh.rcBound.left = x0; if (y < pData->rdh.rcBound.top) pData->rdh.rcBound.top = y; if (x > pData->rdh.rcBound.right) pData->rdh.rcBound.right = x; if (y+1 > pData->rdh.rcBound.bottom) pData->rdh.rcBound.bottom = y+1; pData->rdh.nCount++; } } BasePtr += imgPtr->PITCH - imgPtr->SX; } HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData); //CC_free(pData); return h; } void ChangeCursor(char *cursor) { currentCursor = cursor; currentCursorType = 0; SetCursor(LoadCursor(NULL, currentCursor)); } void ChangeCursorFromFile(char *cursor) { currentCursor = cursor; currentCursorType = 1; SetCursor(LoadCursorFromFile(cursor)); } int AVI2FLV(char *avi, char *flv, bool *Aborted = NULL) { #ifdef VIDEO_OPENLIB int AVIToFlv(char *avi, char *flv, bool *Aborted = NULL); return AVIToFlv(avi, flv, Aborted); #else return 0; #endif //char command[2048]; // //sprintf(command, "ffmpeg -i \"%s\" -ar 22050 -ab 32k -v 0 -sameq -f flv \"%s\"", avi, flv); //STARTUPINFO si; //PROCESS_INFORMATION pi; //memset(&si, 0, sizeof(si)); //si.cb = sizeof(si); //memset(&pi, 0, sizeof(pi)); //if(!CreateProcess( NULL, // command, // NULL, // Process handle not inheritable. // NULL, // Thread handle not inheritable. // FALSE, // Set handle inheritance to FALSE. // CREATE_NO_WINDOW, // CREATE_NO_WINDOW, // No creation flags. // NULL, // Use parent's environment block. // NULL, // Use parent's starting directory. // &si, // Pointer to STARTUPINFO structure. // &pi ) // Pointer to PROCESS_INFORMATION structure. // ) return 0; //// Wait until child process exits. //WaitForSingleObject( pi.hProcess, INFINITE ); //CloseHandle( pi.hProcess ); //CloseHandle( pi.hThread ); //return 1; } #ifdef ONLINE_MODE int RegisterBoot(u32 add) { HKEY keyDir; HKEY keyRun; char bufferDir[256] = ""; DWORD bufferDirLen = 256; DWORD bufferDirType = NULL; char bufferRun[256] = ""; int ret = -1; if (add == -1) { if (RegOpenKeyEx(HKEY_CURRENT_USER, AUTORUN_KEY, 0, KEY_ALL_ACCESS, &keyRun) != ERROR_SUCCESS) return -1; ret = RegQueryValueEx(keyRun, AUTORUN_KEY_CAMCAM, 0, &bufferDirType, (BYTE *)bufferDir, &bufferDirLen) != ERROR_SUCCESS; RegCloseKey(keyRun); return ret; } if (add == 0) { if (RegOpenKeyEx(HKEY_CURRENT_USER, AUTORUN_KEY, 0, KEY_ALL_ACCESS, &keyRun) != ERROR_SUCCESS) return -1; RegDeleteValue(keyRun, AUTORUN_KEY_CAMCAM); RegCloseKey(keyRun); return 1; } if (add == 1) { if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (std::string(CAMCAM_REG_KEY)+std::string(GAME_UPDATE_SUBKEY)).c_str(), 0, KEY_READ, &keyDir) != ERROR_SUCCESS) return -1; ret = RegQueryValueEx(keyDir, CAMCAM_KEY_INSTALL, 0, &bufferDirType, (BYTE *)bufferDir, &bufferDirLen) != ERROR_SUCCESS; RegCloseKey(keyDir); if (!ret) return -1; sprintf(bufferRun, "%s\\%s %s", bufferDir, CAMCAM_EXE, CAMCAM_LUA); if (RegOpenKeyEx(HKEY_CURRENT_USER, AUTORUN_KEY, 0, KEY_ALL_ACCESS, &keyRun) != ERROR_SUCCESS) return -1; RegSetValueEx(keyRun, AUTORUN_KEY_CAMCAM, 0, REG_EXPAND_SZ, (BYTE *)bufferRun, strlen(bufferRun)+1); RegCloseKey(keyRun); return 1; } return -1; } #endif // PL : added to help the installer to remove all youUp Folders created by the users bool AddUserNameInRegistry() { char szUserName[256]; DWORD dwSize = 256; bool result = false; if (GetUserName(szUserName, &dwSize))//the username windows, not the login of YouUp { HKEY hk; char szKeyName[1024]; sprintf(szKeyName, "%s%s\\%s", CAMCAM_REG_KEY, GAME_UPDATE_SUBKEY, "Users"); if (RegCreateKey(HKEY_LOCAL_MACHINE, szKeyName, &hk) == ERROR_SUCCESS) { if (RegSetValueEx(hk, szUserName, 0, REG_SZ, (BYTE*)"", 0) == ERROR_SUCCESS) result = true; RegCloseKey(hk); } } return result; } // Useful for LUA HKEY _RegGetHandleKey(int key) { HKEY hk; switch(key) { case 0: hk = HKEY_CLASSES_ROOT; break; case 1: hk = HKEY_CURRENT_CONFIG; break; case 2: hk = HKEY_CURRENT_USER; break; case 3: hk = HKEY_LOCAL_MACHINE; break; case 4: hk = HKEY_PERFORMANCE_DATA; break; case 5: hk = HKEY_PERFORMANCE_NLSTEXT; break; case 6: hk = HKEY_PERFORMANCE_TEXT; break; case 7: hk = HKEY_USERS; break; default: hk = HKEY_LOCAL_MACHINE; break; } return hk; } /* * if RegReadKeyValue returns NULL, you dont have to Free the (char*) */ char* _RegReadKeyValue(int HandleKey, const char* SubKey, const char* NameKey) { HKEY keyRun; HKEY hk = _RegGetHandleKey(HandleKey); DWORD bufferDirLen = 0; DWORD bufferDirType = REG_SZ; int ret; char* RtValue; if (RegOpenKeyEx(hk, SubKey, 0, KEY_ALL_ACCESS, &keyRun) != ERROR_SUCCESS) return NULL; // If lpData is NULL, and lpcbData is non-NULL, the function returns ERROR_SUCCESS and stores the size of the data, // in bytes, in the variable pointed to by lpcbData. This enables an application to determine the best way // to allocate a buffer for the value's data. ret = RegQueryValueEx (keyRun, NameKey, 0, &bufferDirType, NULL, &bufferDirLen) ; if (ret != ERROR_SUCCESS) { RegCloseKey(keyRun); return NULL; } RtValue = (char*) CC_malloc(bufferDirLen+1); ret = RegQueryValueEx (keyRun, NameKey, 0, &bufferDirType, (BYTE*)RtValue, &bufferDirLen) ; RegCloseKey(keyRun); if (ret != ERROR_SUCCESS) { CC_free (RtValue); return NULL; } // Note: Therefore, even if the function returns ERROR_SUCCESS, // the application should ensure that the string is properly terminated before using it; // otherwise, it may overwrite a buffer RtValue[bufferDirLen] = '\0'; return RtValue; } bool _RegSetKeyValue(int HandleKey, const char* SubKey, const char* NameKey, const char* Value) { HKEY keyRun; HKEY hk = _RegGetHandleKey(HandleKey); DWORD bufferDirType = REG_SZ; int ret; if (RegOpenKeyEx(hk, SubKey, 0, KEY_ALL_ACCESS, &keyRun) != ERROR_SUCCESS) return false; int size = strlen(Value)+1; ret = RegSetValueEx(keyRun, NameKey, 0, REG_SZ, (BYTE*)Value, size); RegCloseKey(keyRun); return ret == ERROR_SUCCESS; } void LaunchExe(char *name) { WinExec(name, SW_HIDE); //STARTUPINFO si; //PROCESS_INFORMATION pi; //memset(&si, 0, sizeof(si)); //si.cb = sizeof(si); //memset(&pi, 0, sizeof(pi)); //if (!CreateProcess(NULL, name, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) //{ // char info[2048]; // FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), // LANG_NEUTRAL, info, 2048, NULL); // info[2047] = 0; //} }