c++ - How convert char * (char pointer) to PCSZ? -


i have method has mandatory parameter char* , want convert pcsz before rtlinitiansistring() , result of uname after rtlansistringtounicodestring() correct value.

how can this?

ntstatus mymethod(char *myname) {             ansi_string aname;     unicode_string uname;     object_attributes objattr;      rtlinitansistring(&aname, myname);     status = rtlansistringtounicodestring(&uname, &aname, true);     if(!nt_success(status))     {        dbgprint("rtlansistringtounicodestring error");        return status;     }      initializeobjectattributes(&objattr, &uname, obj_kernel_handle | obj_case_insensitive, null, null);      // code here     //...     rtlfreeunicodestring(&uname);     return status;     } 

edition 01:

to better understand here how mymethod() used in kernel driver:

struct mydata {     ulong value[3];     char *str1;     char *str2; };  ntstatus function_irp_device_control(pdevice_object pdeviceobject, pirp irp) {     pio_stack_location piostacklocation;     struct mydata *pdata = (struct mydata*) irp->associatedirp.systembuffer;     piostacklocation = iogetcurrentirpstacklocation(irp);     switch (piostacklocation->parameters.deviceiocontrol.iocontrolcode)     {         case ioctl_data :             dbgprint("ioctl data");             dbgprint("%lu \n %lu \n %lu \n %s \n %s", pdata->value[0], pdata->value[1], pdata->value[2], pdata->str1, pdata->str2);             ...             break;     }  ...  //////////// calling mymethod() //////////////  mymethod(pdata->str1); 

there's nothing convert. pcsz pointer constant string zero-terminated. so, it's const char *. char * implicitly convertible const char *.

i consider such typedefs horrible, unfortunately, microsoft apis make heavy use of them.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -