Вопрос

I am new to python, in fact i am just using it for IDA pro script making, so its fairly easy to understand but i am struggling to convert a long type to a unicode string, here is a snippet of my script:

def get_ModAddr(list, modname):
    flink = Dword(list)
    original = Dword(list)
    while True:
        pbasename = Dword(flink+0x30)
        ############################################################
        # pbasename now is type long and points to a UNICODE string
        ############################################################
        if modname == pbasename:
            return Dword(list+0x18)
        flink = Dword(flink)
        if ((flink == original) or (flink == BADADDR)):
            break
    Message("Could not find module.")
    return None


#DO ALL
list = get_PsLoadedModuleList()
if list:
    print "PsLoadedModuleList: %x"%(list)
    modname = unicode("DHSD.sys")
    print "Searching for module %s"%(modname)
    modaddr = get_ModAddr(list, modname)
    if modaddr:
        print "module addr: %x"%(modaddr)

So what i want to do is to convert reference "pbasename" (type long) to UNICODE string and compare it with the "modname" reference to see if they are equal.

Thanks.

Это было полезно?

Решение

I believe what you're looking for is

GetString(pbasename, -1, ASCSTR_UNICODE)

assuming pbasename is a pointer to the memory location of the unicode string. Note that this returns a string of type 'str' (not unicode) so you wouldn't have to convert modname to unicode.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top