static ENGINE_ERROR_CODE fs_get(ENGINE_HANDLE* handle, const void* cookie, item** item, const void* key, const int nkey, uint16_t vbucket) { struct stat st; if (stat(get_file_name(&key, nkey), &st) == -1) return ENGINE_NOT_STORED; struct fs_item* it = NULL; ENGINE_ERROR_CODE ret = fs_allocate(handle, cookie, (void**)&it, key, nkey, st.st_size, 0, 0); if (ret != ENGINE_SUCCESS) return ENGINE_ENOMEM; FILE *fp = fopen(get_file_name(it->key, it->nkey), "r"); if (fp == NULL) { perror("Error get"); fs_item_release(handle, cookie, it); return ENGINE_FAILED; } size_t nr = fread(it->data, 1, it->ndata, fp); fclose(fp); if (nr != it->ndata) { fs_item_release(handle, cookie, it); return ENGINE_FAILED; } *item = it; return ENGINE_SUCCESS; }
BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) { TCHAR filename[MAX_PATH]; TCHAR reg_key_name[KEY_MAX_LEN]; switch (action) { case ACTION_ADD: get_file_name(&s, filename, MAX_PATH); if (!filename[0]) { printf("No file name is specified\n%s", usage); return FALSE; //exit(1); } while (filename[0]) { if (!import_registry_file(filename)) { perror(""); printf("Can't open file \"%s\"\n", filename); return FALSE; //exit(1); } get_file_name(&s, filename, MAX_PATH); } break; case ACTION_DELETE: get_file_name(&s, reg_key_name, KEY_MAX_LEN); if (!reg_key_name[0]) { printf("No registry key is specified for removal\n%s", usage); return FALSE; //exit(1); } delete_registry_key(reg_key_name); break; case ACTION_EXPORT: filename[0] = '\0'; get_file_name(&s, filename, MAX_PATH); if (!filename[0]) { printf("No file name is specified\n%s", usage); return FALSE; //exit(1); } if (s[0]) { get_file_name(&s, reg_key_name, KEY_MAX_LEN); export_registry_key(filename, reg_key_name); } else { export_registry_key(filename, NULL); } break; default: printf("Unhandled action!\n"); return FALSE; } return TRUE; }
LASwaveform13writer* LASwriteOpener::open_waveform13(const LASheader* lasheader) { if (lasheader->point_data_format < 4) return 0; if (lasheader->vlr_wave_packet_descr == 0) return 0; if (get_file_name() == 0) return 0; LASwaveform13writer* waveform13writer = new LASwaveform13writer(); if (waveform13writer->open(get_file_name(), lasheader->vlr_wave_packet_descr)) { return waveform13writer; } delete waveform13writer; return 0; }
key_t get_key(char sym, key_t *key) { char* path = malloc(FILE_NAME_LEN); char pathtmpl[16]; switch(sym) { case 's': { strcpy(pathtmpl, "wala_sem_XXXXXX"); break; } case 'm': { strcpy(pathtmpl, "wala_shm_XXXXXX"); break; } case 'q': { strcpy(pathtmpl, "wala_msq_XXXXXX"); break; } default: { strcpy(pathtmpl, "wala_def_XXXXXX"); } } strcpy(path, get_file_name(mkstemp(pathtmpl))); *key = ftok(path, sym); free(path); return *key; }
int backup_top(){ int i; char fname[256]; char dirname[256]; char aname[256]; struct tm t; time_t tt; FILE *fp; printf("backup_top\n"); tt=time(0); localtime_r(&tt, &t); sprintf(dirname, "bonlinelog/top/%04d%02d%02d/",1900+t.tm_year, t.tm_mon+1, t.tm_mday); sprintf(fname, "mkdir -p %s", dirname); system(fname); sprintf(fname, "%sindex.html", dirname); if((fp=fopen(fname, "w"))==NULL) return -1; printf("backup_t1op\n"); for(i=0;i<topnum;i++){ sprintf(fname,"boards/%s/%s",top[i].board, get_file_name(top[i].board, top[i].groupid, aname)); if(aname[0]=='\0') continue; sprintf(aname, "cp -f %s %s/%d.txt", fname, dirname, i); system(aname); fprintf(fp,"<a href=%d.txt>%d:%s</a>\n",i,i+1,top[i].title); } fclose(fp); return 0; }
void image_get() { int i, t, index; char *filename; for (t = 0; t < IMAGE_QUERY_TURN; t++) { printf("%d .. ", IMAGE_QUERY_TURN - t); fflush(stdout); for (i = 0; i < video.buffer.req.count; i++) { buffer_dequeue(i); buffer_enqueue(i); } } printf("%d ..\n", IMAGE_QUERY_TURN - t); fflush(stdout); index = 0; buffer_dequeue(index); update_image_pixels(index); filename = get_file_name("swc", "jpeg"); save_image(filename); printf("%s saved.\n", filename); free(filename); buffer_enqueue(index); }
/** Changes the directory to the given path @param fat_fs FS_Instance to find all the information from @param current_directory The location of the current directory @param path The name of the directory we want to change into @return Location of the new directory we are in **/ FS_CurrentDir change_dir(FS_Instance *fat_fs, FS_CurrentDir current_directory, char *path){ char *tokens = strtok(path, "/\\"); uint32_t directory = current_directory; while(NULL != tokens) { current_directory = directory; FS_EntryList *list = get_entries(fat_fs, (uint32_t)directory); uint8_t found = 0; while(NULL != list) { FS_Entry *entry = list->node; if((current_directory == directory) && (check_mask(entry->entry->DIR_Attr, ATTR_DIRECTORY))) { char *file_name = get_file_name(entry->entry); if(strcmp(tokens, file_name) == 0) { found = 1; directory = (entry->entry->DIR_FstClusHI << 8) + entry->entry->DIR_FstClusLO; } free(file_name); } FS_EntryList *curr = list; list = list->next; entry_list_cleanup(curr); } if(!found) { printf("Couldn't find directory.\n"); directory = current_directory; break; } tokens = strtok(NULL, "/\\"); } return directory; }
int cue(const char *name) { char *rval; char *last_slash; if (!name || !*name) return -1; rval = get_file_name(name); if (rval == NULL) { last_slash = strrchr(name, '/'); last_slash++; fprintf(stderr, "\n'%s': lossless file NOT found\n\n", last_slash); return -1; } analyze_cue(name); cue_play(rval); wait(NULL); free(rval); free(cue_index); return 0; }
/* * Public function that loops until command line options were parsed */ void jsoncat_options_parser (int argc, char* argv[], options_t* options) { set_default_options(options); int arg; /* Current option */ /* getopt allowed options */ static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {"no-colors", no_argument, 0, 0}, {"tab-stop", required_argument, 0, 't'} }; while (true) { int option_index = 0; arg = getopt_long(argc, argv, "hvt:", long_options, &option_index); /* End of the options? */ if (arg == -1) break; /* Find the matching case of the argument */ switch_options(arg, options); } /* Gets the file name or exits with error */ get_file_name(argc, argv, options); }
std::string LogRecord::to_string() const { std::string s = "["; s += _time.to_string(); s += "] "; s += log_level_to_str(_level); if (nullptr != _tag) { s.push_back(' '); s += _tag; } s += " ("; s += get_file_name(); s.push_back(':'); s += int_to_str(_line); s.push_back(')'); if (nullptr != _func) { s.push_back(' '); s += _func; s += "()"; } s.push_back(' '); s += _message; return s; }
/* carrega uma nova cena */ int load_cb(void) { char* filename = get_file_name(); /* chama o dialogo de abertura de arquivo */ char buffer[30]; if (filename==NULL) return 0; /* Le a cena especificada */ scene = sceLoad( filename ); if( scene == NULL ) return IUP_DEFAULT; sceGetCamera( scene, &camera ); camGetEye( camera, eye ); camGetScreenWidth( camera, &width ); camGetScreenHeight( camera, &height ); yc=0; if (image) imgDestroy(image); image = imgCreate( width, height ); IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height); sprintf(buffer,"%3dx%3d", width, height); IupSetAttribute(canvas,IUP_RASTERSIZE,buffer); IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb); start_time = clock(); return IUP_DEFAULT; }
/* * read and transfer the firmware binary */ static int load_firmware(snd_hwdep_t *hw, const char *id, unsigned int idx, int is_pcmcia) { int err; char fname[MAX_PATH]; int is_xilinx = 0; snd_hwdep_dsp_image_t *dsp; if (get_file_name(id, idx, fname) < 0) return -EINVAL; if (is_pcmcia) { if (idx == 1) is_xilinx = 1; } else { if (idx == 0) is_xilinx = 1; } snd_hwdep_dsp_image_alloca(&dsp); snd_hwdep_dsp_image_set_index(dsp, idx); if (is_xilinx) err = read_xilinx_image(dsp, fname); else err = read_boot_image(dsp, fname); if (err < 0) return err; err = snd_hwdep_dsp_load(hw, dsp); if (err < 0) error("error in loading %s\n", fname); return err; }
/* Opens the file with the given NAME. Returns the new file if successful or a null pointer otherwise. Fails if no file named NAME exists, or if an internal memory allocation fails. */ struct file * filesys_open (const char *name) { char s[100]; char *save_ptr; // printf("%s \n",name); memcpy(s,name,strlen(name)+1); struct inode *inode = NULL; char *file_name = get_file_name(name); // printf("file name : %s\n",file_name); if( strtok_r(s,"/",&save_ptr) ==NULL&&strlen(name)>0 ) { // printf("aaa\n"); free(file_name); return file_open(inode_open(1)); } if( strcmp(file_name,"")==0 ) return NULL; struct dir *dir = get_directory(name); // printf("sector of dir : %d\n", inode_get_inumber(dir_get_inode(dir))); // printf("lookup start\n"); if (dir != NULL) { // printf("here?\n"); if(strcmp(file_name,".")==0) { // printf("here\n"); inode = dir_get_inode(dir); // printf("ohhhhhh\n"); // dir_close (dir); free(file_name); if(inode_is_removed(inode)) return NULL; else return file_open (inode); } else if( strcmp(file_name,"..")==0) { inode = dir_get_inode(inode); // dir_close (dir); free(file_name); return file_open (inode); } else dir_lookup (dir, file_name, &inode); dir_close (dir); if(inode==NULL) return NULL; free(file_name); return file_open (inode); } else { // printf("here\n"); return NULL; } // if(inode_is_removed(inode)) // return NULL; // return file_open (inode); }
t_lst *manage_av_file(char *path, t_lst *lst, DIR *dir) { char *formated; struct dirent *ret; formated = format_path(path); if (!formated) return (NULL); if (!(dir = opendir(formated))) { ft_error(path); return (NULL); } else { while ((ret = readdir(dir))) if ((ft_strcmp(ret->d_name, get_file_name(path)) == 0)) { lst = ft_get_data(lst, ret->d_name, path); break ; } if (!lst) return (NULL); closedir(dir); return (lst); } return (NULL); }
/* * NTSTATUS ZwSetInformationFile( * HANDLE FileHandle, * PIO_STATUS_BLOCK IoStatusBlock, * PVOID FileInformation, * ULONG Length, * FILE_INFORMATION_CLASS FileInformationClass * ); * * When FileInformationClass is FileDispositionInformation then FileInformation points to * struct _FILE_DISPOSITION_INFORMATION { * BOOLEAN DeleteFile; * } */ static event_response_t setinformation_cb(drakvuf_t drakvuf, drakvuf_trap_info_t* info) { filedelete* f = (filedelete*)info->trap->data; vmi_instance_t vmi = drakvuf_lock_and_get_vmi(drakvuf); addr_t handle = drakvuf_get_function_argument(drakvuf, info, 1); addr_t fileinfo = drakvuf_get_function_argument(drakvuf, info, 3); uint32_t fileinfoclass = drakvuf_get_function_argument(drakvuf, info, 5); event_response_t response = 0; if (fileinfoclass == FILE_DISPOSITION_INFORMATION) { uint8_t del = 0; access_context_t ctx; ctx.translate_mechanism = VMI_TM_PROCESS_DTB; ctx.dtb = info->regs->cr3; ctx.addr = fileinfo; if ( VMI_FAILURE == vmi_read_8(vmi, &ctx, &del) ) goto done; if (del) { auto filename = get_file_name(f, drakvuf, vmi, info, handle, nullptr, nullptr); if (filename.empty()) filename = "<UNKNOWN>"; f->files[std::make_pair(info->proc_data.pid, handle)] = filename; } } done: drakvuf_release_vmi(drakvuf); return response; }
/* carrega uma nova cena */ int load_cb(void) { char* filename = get_file_name(); /* chama o dialogo de abertura de arquivo */ char buffer[30]; if (filename==NULL) return 0; /* Le a cena especificada */ scene = sceLoad( filename ); if( scene == NULL ) return IUP_DEFAULT; camera = sceGetCamera( scene ); eye = camGetEye( camera ); width = camGetScreenWidth( camera ); height = camGetScreenHeight( camera ); yc=0; if (image) imgDestroy(image); image = imgCreate( width, height ); IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height); sprintf(buffer,"%3dx%3d", width, height); IupSetAttribute(canvas,IUP_RASTERSIZE,buffer); IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb); start_time = clock(); IupGLMakeCurrent(canvas); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glEnd(); glFlush(); IupGLSwapBuffers(canvas); /* change the back buffer with the front buffer */ return IUP_DEFAULT; }
static event_response_t createsection_cb(drakvuf_t drakvuf, drakvuf_trap_info_t* info) { filedelete* f = (filedelete*)info->trap->data; vmi_instance_t vmi = drakvuf_lock_and_get_vmi(drakvuf); handle_t handle = drakvuf_get_function_argument(drakvuf, info, 7); uint32_t access_mask = drakvuf_get_function_argument(drakvuf, info, 2); std::string filename; // Filter out system handles: those having high bits rised // WARNING Without this target VM could freeze or crash! if (static_cast<int64_t>(handle) < 0LL) goto done; if ( !(0x2 & access_mask) ) // SECTION_MAP_WRITE goto done; filename = get_file_name(f, drakvuf, vmi, info, handle, nullptr, nullptr); if (filename.empty()) filename = "<UNKNOWN>"; f->files[std::make_pair(info->proc_data.pid, handle)] = filename; done: drakvuf_release_vmi(drakvuf); return 0; }
/* * The approach where the system process list es enumerated looking for * the matching cr3 value in each _EPROCESS struct is not going to work * if a DKOM attack unhooks the _EPROCESS struct. * * We can access the _EPROCESS structure by reading the FS_BASE register on x86 * or the GS_BASE register on x64, which contains the _KPCR. * * FS/GS -> _KPCR._KPRCB.CurrentThread -> _ETHREAD._KTHREAD.Process = _EPROCESS * * Also see: http://www.csee.umbc.edu/~stephens/SECURITY/491M/HiddenProcesses.ppt */ static void grab_file_by_handle(filedelete* f, drakvuf_t drakvuf, vmi_instance_t vmi, drakvuf_trap_info_t* info, addr_t handle) { addr_t file = 0; addr_t filetype = 0; std::string filename = get_file_name(f, drakvuf, vmi, info, handle, &file, &filetype); if (filename.empty()) return; uint64_t fo_flags = 0; get_file_object_flags(drakvuf, info, vmi, f, handle, &fo_flags); print_filedelete_information(f, drakvuf, info, filename.c_str(), 0 /*TODO: print file size*/, fo_flags); if (f->dump_folder) { access_context_t ctx = { .translate_mechanism = VMI_TM_PROCESS_DTB, .addr = filetype, .dtb = info->regs->cr3, }; extract_file(f, drakvuf, info, vmi, file, &ctx, filename.c_str(), fo_flags); } }
int SqliteDao::get_data(db_mm::TableSchema* table_schema, int& row_num) { int ret = 0; int table_id = table_schema->get_table_id(); std::string file_name = get_file_name(table_id); db_mm::TableIndex* table_index = table_manager_->get_table_index(table_id); row_num = 0; table_index->set_data_path(file_name); FILE* file = fopen(file_name.c_str(), "w+"); do { char** res = NULL; int rows = 0; int columns = 0; if (SQLITE_OK != (ret = sqlite3_get_table(sqlite_, sql_, &res, &rows, &columns, NULL))) { COM_WRITELOG(COMLOG_WARNING, "sqlite get_data error [%s]", sqlite3_errmsg(sqlite_)); break; } //row_num = rows - 1 > 0 ? rows - 1 : 0; row_num = rows; for (int i = 1; i <= rows; i++) { for (int j = 0; j < columns; j++) { int index = i * columns + j; //printf("i = %d j = %d res[] = %s\n", i, j, res[index]); if (NULL != res[index]) { fwrite(res[index], strlen(res[index]) + 1, 1, file); } else { fwrite("\0", 1, 1, file); } index++; } fwrite("\n", 1, 1, file); } sqlite3_free_table(res); } while (0); if (NULL != file) { fclose(file); } return ret; }
char* get_filename_bypath(char* name_replaced, char* ext_replaced) { char szfilename[256]; GetModuleFileName(NULL, szfilename, sizeof(szfilename)); return get_file_name(szfilename, name_replaced, ext_replaced); }
void send_file(char *path_to_file_name,int sockfd){ FILE *fd = fopen(path_to_file_name,"r"); fseek(fd,0,SEEK_END); int size = ftell(fd); fseek(fd,0,SEEK_SET); if (size%MAXMSG) size = size/MAXMSG + 1; else size = size/MAXMSG; fprintf(stdout,"Packets : %i\n",size); char msg[30]; memset(&msg,'\0', sizeof(msg)); snprintf(msg,sizeof(msg),"%s",get_file_name(path_to_file_name)); fprintf(stdout,"%s\n",msg); if(send(sockfd,msg,strlen(msg),0)<0) fprintf(stdout,"send name fail"); usleep(1000); memset(&msg,'\0', sizeof(msg)); snprintf(msg,sizeof(msg),"%i",size); if (send(sockfd,msg,strlen(msg),0)<0) fprintf(stdout,"send size loi"); usleep(1000); int count = 0; while(!feof(fd)){ int wasRead = fread(packet,sizeof(char),MAXMSG,fd); send(sockfd,packet,(sizeof(char)*wasRead),0); fprintf(stdout,"Count: %i\n",count); count++; usleep(1000); } }
static int unlink_config_file( const char *filename) { char buff[255]; int err_code; extern int use_config_directory; /* miscell.c */ get_file_name( buff, filename); if( use_config_directory) { char cpath[255]; make_config_dir_name( cpath, buff); #ifdef _WIN32 /* MS is different. */ err_code = _unlink( cpath); #else err_code = unlink( cpath); #endif } else #ifdef _WIN32 err_code = _unlink( buff); #else err_code = unlink( buff); #endif return( err_code); }
uint32_t install_(const std::string& fpath) { unit_map_cit cit = unit_map_.find(fpath); if(cit != unit_map_.end()) { // find it !, To be not install. return 0; } auto tpath = strip_last_of_delimita_path(fpath); auto bpath = get_file_path(tpath); bpath += '/'; unit_map_it it = unit_map_.find(bpath); if(it != unit_map_.end()) { unit_t& t = it->second; std::string name = get_file_name(tpath); if(fpath.back() == '/') name += '/'; t.install_child(name); } uint32_t hnd = handle_set_.create(); unit_t u; u.set_id(hnd); unit_map_.emplace(fpath, u); return hnd; }
void open_cli_file (char *extension) { String filename; get_file_name (filename, extension); printf("open file\n"); open_file (filename); }
BOOL CCmdLineParser::ExpandExtNames(LPTSTR lpFilePath, LPCTSTR lpExtNames) { BOOL bResult = FALSE; if ( get_path_type(lpFilePath) != 1 ) { LPCTSTR lpFileName = get_file_name(lpFilePath); LPTSTR lpExtName = (TCHAR*)_tcsrchr(lpFileName, _T('.')); if ( lpExtName == NULL ) { lpExtName = lpFilePath + _tcslen(lpFilePath); *lpExtName++ = _T('.'); *lpExtName = _T('\0'); LPCTSTR lpFixExtName = lpExtNames; while ( !is_empty_str(lpFixExtName) ) { size_t nFixExtNameLen = 0; LPTSTR lpNextFixExtName = (LPTSTR)_tcschr(lpFixExtName, _T(';')); if ( lpNextFixExtName != NULL ) { nFixExtNameLen = lpNextFixExtName - lpFixExtName; lpNextFixExtName++; } else { nFixExtNameLen = _tcslen(lpFixExtName); } if ( lpExtName + nFixExtNameLen < lpFilePath + MAX_PATH ) { _tcsncpy(lpExtName, lpFixExtName, nFixExtNameLen); lpExtName[nFixExtNameLen] = 0; if ( get_path_type(lpFilePath) == 1 ) { bResult = TRUE; break; } } lpFixExtName = lpNextFixExtName; } if ( !bResult ) { lpExtName[-1] = _T('\0'); } } } else { bResult = TRUE; } return bResult; }
/* Creates a file named NAME with the given INITIAL_SIZE. Returns true if successful, false otherwise. Fails if a file named NAME already exists, or if internal memory allocation fails. */ bool filesys_create (const char *name, off_t initial_size,bool is_dir) { // printf("create start: %s\n",name); // printf("%s size: %d\n",name,initial_size); disk_sector_t inode_sector = 0; char *file_name = get_file_name(name); bool success=true; if( strcmp(file_name,"")==0 ) { return false; } // if( is_dir) // printf("mkdir!\n"); // printf("file name : %s\n",file_name); struct dir *dir = get_directory(name); // printf("sector of dir : %d\n", inode_get_inumber(dir_get_inode(dir))); // if( inode_get_parent(dir_get_inode(dir)) ==0 ) // { // printf("its on root directory!\n"); // } /* if(dir == NULL) { printf("no directory\n"); success=false; } if(!free_map_allocate(1,&inode_sector)) { printf("no free map\n"); success=false; } if(!inode_create(inode_sector,initial_size,is_dir)) { printf("inode create fail\n"); success=false; } if(!dir_add(dir,file_name,inode_sector)) { printf("dir add fail\n"); success=false; }*/ // printf("file name:%s\n",file_name); success = (dir != NULL && free_map_allocate (1, &inode_sector) && inode_create (inode_sector, initial_size, is_dir) && dir_add (dir, file_name, inode_sector)); if (!success && inode_sector != 0) { // printf("haha\n"); free_map_release (inode_sector, 1); } dir_close (dir); // printf("create end sector num : %d\n",inode_sector); free(file_name); return success; }
time_t get_mtime (int qtype, unsigned char *s) { struct stat st; char buf[1024]; if (get_file_name (buf, sizeof (buf), qtype, s)) abort (); if (stat (buf, &st)) return (time_t) 1000000000UL; return st.st_mtime; }
std::string get_file_name(boost::exception_ptr const& e) { try { boost::rethrow_exception(e); } catch (boost::exception const& be) { return get_file_name(be); } }
int main(int argc, char *argv[]) { if (argc < 2) { std::cout << "args: <input exe> [timeout: ms]" << std::endl; system("pause"); return 0; } DWORD flags = DETACHED_PROCESS | CREATE_NO_WINDOW; char* file_path = argv[1]; std::cout << "Starting the process: " << file_path << std::endl; char* file_name = get_file_name(file_path); std::cout << "Exe name: " << file_name << std::endl; DWORD timeout = (-1); //INFINITE if (argc >= 3) { timeout = atol(argv[2]); } HANDLE proc = make_new_process(file_path, flags); if (!proc) { std::cerr << "Could not start the process!" << std::endl; return -1; } t_hh_params hh_args; hh_args_init(hh_args); hh_args.kill_suspicious = true; hh_args.loop_scanning = true; hh_args.pname = file_name; DWORD start_tick = GetTickCount(); size_t count = 0; bool is_unpacked = false; do { DWORD curr_time = GetTickCount() - start_tick; if ((timeout != -1 && timeout > 0) && curr_time > timeout) { std::cout << "Timeout passed!" << std::endl; return 1; } count++; size_t res = deploy_scan(hh_args); if (res > 0) { is_unpacked = true; break; } } while (hh_args.loop_scanning); if (is_unpacked) { DWORD total_time = GetTickCount() - start_tick; std::cout << "Unpacked in: " << std::dec << total_time << " milliseconds; " << count << " attempts." << std::endl; } return 0; }
HRESULT Camera::takePicture(HWND hwndOwner,LPTSTR pszFilename) { HRESULT hResult = S_OK; #if defined(_WIN32_WCE) //&& !defined( OS_PLATFORM_MOTCE ) if(RHO_IS_WMDEVICE) { SHCAMERACAPTURE shcc; StringW imageDir; convertToStringW(rho_rhodesapp_getblobsdirpath(), imageDir); StringW strFileName = generate_filename(L".jpg"); // Set the SHCAMERACAPTURE structure. ZeroMemory(&shcc, sizeof(shcc)); shcc.cbSize = sizeof(shcc); shcc.hwndOwner = hwndOwner; shcc.pszInitialDir = imageDir.c_str(); shcc.pszDefaultFileName = strFileName.c_str(); shcc.pszTitle = TEXT("Camera"); shcc.VideoTypes = CAMERACAPTURE_VIDEOTYPE_MESSAGING; shcc.nResolutionWidth = 176; shcc.nResolutionHeight = 144; shcc.StillQuality = CAMERACAPTURE_STILLQUALITY_LOW; shcc.nVideoTimeLimit = 15; shcc.Mode = CAMERACAPTURE_MODE_STILL; // Display the Camera Capture dialog. hResult = lpfn_Camera_Capture(&shcc); // The next statements will execute only after the user takes // a picture or video, or closes the Camera Capture dialog. if (S_OK == hResult) { LOG(INFO) + "takePicture get file: " + shcc.szFile; LPTSTR fname = get_file_name( shcc.szFile, imageDir.c_str() ); if (fname) { StringCchCopy( pszFilename, MAX_PATH, fname ); free(fname); } else { LOG(ERROR) + "takePicture error get file: " + shcc.szFile; hResult = E_INVALIDARG; } }else { LOG(ERROR) + "takePicture failed with code: " + LOGFMT("0x%X") + hResult; } } #endif //_WIN32_WCE return hResult; }