本文整理汇总了C++中qstring::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ qstring::c_str方法的具体用法?C++ qstring::c_str怎么用?C++ qstring::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstring
的用法示例。
在下文中一共展示了qstring::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reconstruct_type
bool idaapi reconstruct_type(cfuncptr_t cfunc, qstring var_name, qstring type_name)
{
bool bResult = false;
// initialize type rebuilder
type_builder_t type_bldr;
type_bldr.expression_to_match.push_back(var_name.c_str());
// traverse the ctree structure
type_bldr.apply_to(&cfunc->body, NULL);
if (type_bldr.structure.size() != 0) {
tid_t struct_type_id = type_bldr.get_structure(type_name.c_str());
if(struct_type_id != 0 || struct_type_id != -1) {
tinfo_t new_type = create_typedef(type_name.c_str());
if(new_type.is_correct()) {
qstring type_str = type_name.c_str();
//if (new_type.print(&type_str, NULL, PRTYPE_DEF | PRTYPE_MULTI))
logmsg(DEBUG, ("New type created: %s\n", type_str.c_str()));
bResult = true;
}
}
} else {
warning("Failed to reconstruct type, no field references have been found...");
logmsg(DEBUG, "Failed to reconstruct type, no field references have been found...");
}
return bResult;
}
示例2: dump_type_info
void idaapi dump_type_info(int file_id, const VTBL_info_t& vtbl_info, const qstring& type_name, const std::map<ea_t, VTBL_info_t>& vtbl_map) {
struc_t * struc_type = get_struc(get_struc_id(type_name.c_str()));
if (!struc_type)
return;
qstring file_entry_key;
qstring key_hash;
bool filtered = false;
get_struct_key(struc_type, vtbl_info, file_entry_key, filtered, vtbl_map);
get_hash_of_string(file_entry_key, key_hash);
if (filtered)
return;
qstring file_entry_val;
tinfo_t new_type = create_typedef(type_name.c_str());
if (new_type.is_correct() && new_type.print(&file_entry_val, NULL, PRTYPE_DEF | PRTYPE_1LINE)) {
qstring line;
line = key_hash + ";" + file_entry_key + ";";
line.cat_sprnt("%a;", vtbl_info.ea_begin);
line += file_entry_val + ";";
if (rtti_vftables.count(vtbl_info.ea_begin) != 0) {
VTBL_info_t vi = rtti_vftables[vtbl_info.ea_begin];
line += vi.vtbl_name;
}
line.rtrim();
line += "\r\n";
qwrite(file_id, line.c_str(), line.length());
}
}
示例3: FromBMP
bool FromBMP(quint8** out, int& outwidth, int& outheight, int& outbytes, const qstring& file)
{
FILE* infile = fopen(file.c_str(), "rb");;
if( !infile )
return false;
fseek(infile, 0, SEEK_END);
long length = ftell(infile);
fseek(infile, 0, SEEK_SET);
char* data = (char*)malloc(length);
if( !data )
{
fclose(infile);
return false;
}
fread(data, 1, length, infile);
fclose(infile);
size_t size = FromBMP(out, outwidth, outheight, outbytes, (size_t)length, data);
free(data);
return (0 != size);
}
示例4: show_citem_custom_view
bool idaapi show_citem_custom_view(void *ud, qstring ctree_item, qstring item_name)
{
HWND hwnd = NULL;
qstring form_name = "Ctree Item View: ";
form_name.append(item_name);
TForm *form = create_tform(form_name.c_str(), &hwnd);
func_ctree_info_t *si = new func_ctree_info_t(form);
istringstream s_citem_str(ctree_item.c_str());
string tmp_str;
while (getline(s_citem_str, tmp_str, ';'))
{
qstring tmp_qstr = tmp_str.c_str();
si->sv.push_back(simpleline_t(tmp_qstr));
}
simpleline_place_t s1;
simpleline_place_t s2(ctree_item.size());
si->cv = create_custom_viewer("Ctree Item View: ", NULL, &s1, &s2, &s1, 0, &si->sv);
si->codeview = create_code_viewer(form, si->cv, CDVF_NOLINES);
set_custom_viewer_handlers(si->cv, NULL, NULL, NULL, NULL, NULL, NULL, si);
open_tform(form, FORM_ONTOP | FORM_RESTORE);
return false;
}
示例5: check_subtype
bool idaapi check_subtype(const VTBL_info_t &vtbl_info, const qstring &subtype_name) {
bool bResult = false;
qstring search_str;
search_str.sprnt("_%p", vtbl_info.ea_begin);
tid_t type_id = get_struc_id(subtype_name.c_str());
if (type_id != BADADDR) {
struc_t * struc_type = get_struc(type_id);
if (struc_type != NULL) {
// enumerate members
for (ea_t offset = get_struc_first_offset(struc_type); offset != BADADDR; offset = get_struc_next_offset(struc_type, offset)) {
member_t * member_info = get_member(struc_type, offset);
if (member_info != NULL) {
qstring member_name = get_member_name2(member_info->id);
if (member_name.find(search_str, 0) != -1) {
bResult = true;
break;
}
}
}
}
}
return bResult;
}
示例6: get_structure
tid_t type_builder_t::get_structure(const qstring name)
{
tid_t struct_type_id = add_struc(BADADDR, name.c_str());
if (struct_type_id != 0 || struct_type_id != -1)
{
struc_t * struc = get_struc(struct_type_id);
if(struc != NULL)
{
opinfo_t opinfo;
opinfo.tid = struct_type_id;
int j = 0;
for(std::map<int, struct_filed>::iterator i = structure.begin(); i != structure.end() ; i ++)
{
VTBL_info_t vtbl;
flags_t member_flgs = 0;
if(i->second.size == 1)
member_flgs = byteflag();
else if (i->second.size == 2)
member_flgs = wordflag();
else if (i->second.size == 4)
member_flgs = dwrdflag();
else if (i->second.size == 8)
member_flgs = qwrdflag();
char field_name[258];
memset(field_name, 0x00, sizeof(field_name));
if((i->second.vftbl != BADADDR) && get_vbtbl_by_ea(i->second.vftbl, vtbl))
{
qstring vftbl_name = name;
vftbl_name.cat_sprnt("_VTABLE_%X_%p", i->second.offset, i->second.vftbl);
tid_t vtbl_str_id = create_vtbl_struct(vtbl.ea_begin, vtbl.ea_end, (char *)vftbl_name.c_str(), 0);
if (vtbl_str_id != BADADDR) {
sprintf_s(field_name, sizeof(field_name), "vftbl_%d_%p", j, i->second.vftbl);
int iRet = add_struc_member(struc, field_name, i->second.offset, member_flgs, NULL, i->second.size);
member_t * membr = get_member_by_name(struc, field_name);
if (membr != NULL) {
tinfo_t new_type = create_typedef((char *)vftbl_name.c_str());
if(new_type.is_correct()) {
smt_code_t dd = set_member_tinfo2(struc, membr, 0, make_pointer(new_type), SET_MEMTI_COMPATIBLE);
}
}
}
}
else
{
sprintf_s(field_name, sizeof(field_name), "field_%X", i->second.offset);
int iRet = add_struc_member(struc, field_name, i->second.offset, member_flgs, NULL, i->second.size);
}
j ++;
}
}
}
return struct_type_id;
}
示例7: ToTGA
bool ToTGA(quint8* data, int width, int height, int bytes, const qstring& file)
{
FILE* outfile = fopen(file.c_str(), "wb");
if (!outfile)
return false;
quint8 header[18];
memset(header, 0, 18);
header[2] = 2; // type
*((quint16*)(&header[12])) = (quint16)width;
*((quint16*)(&header[14])) = (quint16)height;
header[16] = bytes * 8;
fwrite(header, 1, 18, outfile);
if( bytes == 3 )
fwrite(data, 1, width * height * 3, outfile);
else
fwrite(data, 1, width * height * 4, outfile);
fclose(outfile);
return true;
}
示例8: send_request
//--------------------------------------------------------------------------
// returns error code
int rpc_engine_t::send_request(qstring &s)
{
// if nothing is initialized yet or error occurred, silently fail
if ( irs == NULL || network_error_code != 0 )
return -1;
finalize_packet(s);
const char *ptr = s.c_str();
ssize_t left = s.length();
#ifdef DEBUG_NETWORK
rpc_packet_t *rp = (rpc_packet_t *)ptr;
int len = qntohl(rp->length);
show_hex(rp+1, len, "SEND %s %d bytes:\n", get_rpc_name(rp->code), len);
// msg("SEND %s\n", get_rpc_name(rp->code));
#endif
while ( left > 0 )
{
ssize_t code = irs_send(irs, ptr, left);
if ( code == -1 )
{
code = irs_error(irs);
network_error_code = code;
warning("irs_send: %s", winerr((int)code));
return (int)code;
}
left -= code;
ptr += code;
}
return 0;
}
示例9: merge_types
tid_t idaapi merge_types(qvector<qstring> types_to_merge, qstring type_name) {
tid_t struct_type_id = BADADDR;
std::set<ea_t> offsets;
if (types_to_merge.size() != 0) {
struct_type_id = add_struc(BADADDR, type_name.c_str());
if (struct_type_id != 0 || struct_type_id != BADADDR)
{
struc_t * struc = get_struc(struct_type_id);
if (struc != NULL) {
qvector<qstring>::iterator types_iter;
for (types_iter = types_to_merge.begin(); types_iter != types_to_merge.end(); types_iter++) {
tid_t type_id = get_struc_id((*types_iter).c_str());
if (type_id != BADADDR) {
struc_t * struc_type = get_struc(type_id);
if (struc_type != NULL) {
// enumerate members
for (ea_t offset = get_struc_first_offset(struc_type); offset != BADADDR; offset = get_struc_next_offset(struc_type, offset)) {
member_t * member_info = get_member(struc_type, offset);
if (member_info != NULL) {
if (offsets.count(member_info->soff) == 0) {
qstring member_name = get_member_name2(member_info->id);
asize_t member_size = get_member_size(member_info);
if (member_name.find("vftbl_", 0) != -1) {
tinfo_t tif;
if (get_member_tinfo2(member_info, &tif)) {
add_struc_member(struc, member_name.c_str(), member_info->soff, dwrdflag(), NULL, member_size);
member_t * membr = get_member(struc, member_info->soff);
if (membr != NULL) {
set_member_tinfo2(struc, membr, 0, tif, SET_MEMTI_COMPATIBLE);
}
}
}
else {
add_struc_member(struc, member_name.c_str(), member_info->soff, member_info->flag, NULL, member_size);
}
offsets.insert(member_info->soff);
}
}
}
}
}
}
}
}
}
return struct_type_id;
}
示例10: merge_types
tid_t idaapi merge_types(const qvector<qstring>& types_to_merge, const qstring& type_name) {
tid_t struct_type_id = BADADDR;
if (types_to_merge.empty())
return struct_type_id;
std::set<ea_t> offsets;
struct_type_id = add_struc(BADADDR, type_name.c_str());
if (struct_type_id == BADADDR)
return struct_type_id;
struc_t * struc = get_struc(struct_type_id);
if (!struc)
return struct_type_id;
for (auto types_iter = types_to_merge.begin(), end = types_to_merge.end(); types_iter != end; ++types_iter) {
struc_t * struc_type = get_struc(get_struc_id(types_iter->c_str()));
if (!struc_type)
continue;
// enumerate members
for ( ea_t offset = get_struc_first_offset(struc_type) ; offset != BADADDR ; offset = get_struc_next_offset(struc_type, offset)) {
member_t * member_info = get_member(struc_type, offset);
if (!member_info)
continue;
if (offsets.count(member_info->soff) == 0) {
qstring member_name = get_member_name(member_info->id);
asize_t member_size = get_member_size(member_info);
if (member_name.find("vftbl_", 0) != -1) {
tinfo_t tif;
if (get_member_tinfo(&tif, member_info)) {
add_struc_member(struc, member_name.c_str(), member_info->soff, dword_flag(), NULL, member_size);
if (member_t * membr = get_member(struc, member_info->soff)) {
set_member_tinfo(struc, membr, 0, tif, SET_MEMTI_COMPATIBLE);
}
}
}
else {
add_struc_member(struc, member_name.c_str(), member_info->soff, member_info->flag, NULL, member_size);
}
offsets.insert(member_info->soff);
}
}
}
return struct_type_id;
}
示例11: find_var
bool idaapi find_var(cfuncptr_t cfunc, qstring vtbl_name, qstring &var_name)
{
obj_fint_t obj_find;
int offs = 0;
if (!strncmp(vtbl_name.c_str(), "const ", 6))
offs = 6;
obj_find.vtbl_name = vtbl_name.c_str() + offs;
bool bResult = false;
// traverse the ctree structure
obj_find.apply_to(&cfunc->body, NULL);
if (obj_find.bFound) {
var_name = obj_find.var_name.c_str();
reset_pointer_type(cfunc, var_name);
bResult = true;
} else {
logmsg(DEBUG, "Failed to find variable...");
}
return bResult;
}
示例12: dump_type_info
void idaapi dump_type_info(int file_id, VTBL_info_t vtbl_info, qstring type_name, std::map<ea_t, VTBL_info_t> vtbl_map) {
tid_t type_id = get_struc_id(type_name.c_str());
if (type_id != BADADDR) {
struc_t * struc_type = get_struc(type_id);
if(struc_type != NULL) {
qstring file_entry_key;
qstring key_hash;
bool filtered = false;
get_struct_key(struc_type, vtbl_info, file_entry_key, filtered, vtbl_map);
get_hash_of_string(file_entry_key, key_hash);
if (!filtered) {
qstring file_entry_val;
tinfo_t new_type = create_typedef(type_name.c_str());
if(new_type.is_correct()) {
if (new_type.print(&file_entry_val, NULL, PRTYPE_DEF | PRTYPE_1LINE)) {
qstring line;
line = key_hash + ";" + file_entry_key + ";";
line.cat_sprnt("%p;", vtbl_info.ea_begin);
line += file_entry_val + ";";
if (rtti_vftables.count(vtbl_info.ea_begin) != 0) {
vftable::vtinfo vi = rtti_vftables[vtbl_info.ea_begin];
line += vi.type_info;
}
line.rtrim();
line += "\r\n";
qwrite(file_id, line.c_str(), line.length());
}
}
}
}
}
}
示例13: reset_pointer_type
void idaapi reset_pointer_type(const cfuncptr_t &cfunc, qstring &var_name) {
lvars_t * locals = cfunc->get_lvars();
if (locals != NULL) {
qvector<lvar_t>::iterator locals_iter;
for (locals_iter = locals->begin(); locals_iter != locals->end(); locals_iter++) {
if (!strcmp(var_name.c_str(), (*locals_iter).name.c_str())) {
tinfo_t int_type = tinfo_t(BT_INT32);
(*locals_iter).set_final_lvar_type(int_type);
(*locals_iter).set_user_type();
cfunc->build_c_tree();
break;
}
}
}
}
示例14: func_name_has_prefix
inline bool func_name_has_prefix(qstring &prefix, ea_t startEA) {
qstring func_name;
if (prefix.length() <= 0)
return false;
if (get_func_name2(&func_name, startEA) == 0)
return false;
if (func_name.length() <= 0)
return false;
if (func_name.find(prefix.c_str(), 0) != 0)
return false;
return true;
}
示例15: check_subtype
bool idaapi check_subtype(VTBL_info_t vtbl_info, qstring subtype_name) {
qstring search_str;
search_str.sprnt("_%a", vtbl_info.ea_begin);
struc_t * struc_type = get_struc(get_struc_id(subtype_name.c_str()));
if (!struc_type)
return false;
// enumerate members
for ( ea_t offset = get_struc_first_offset(struc_type) ; offset != BADADDR ; offset = get_struc_next_offset(struc_type, offset)) {
member_t * member_info = get_member(struc_type, offset);
if (!member_info)
continue;
qstring member_name = get_member_name(member_info->id);
if (member_name.find(search_str, 0) != member_name.npos)
return true;
}
return false;
}