Exemple #1
0
    def CoCreateInstance(self, emu, argv, ctx={}):
        """
        HRESULT CoCreateInstance(
          REFCLSID  rclsid,
          LPUNKNOWN pUnkOuter,
          DWORD     dwClsContext,
          REFIID    riid,
          LPVOID    *ppv
        );
        """
        rclsid, pUnkOuter, dwClsContext, riid, ppv = argv
        rv = windefs.S_OK

        clsid_bytes = self.mem_read(rclsid, self.sizeof(windefs.GUID()))
        clsid_str = com.convert_guid_bytes_to_str(clsid_bytes)
        clsid_name = com.get_clsid(clsid_str)
        if clsid_name:
            argv[0] = clsid_name

        riid_bytes = self.mem_read(riid, self.sizeof(windefs.GUID()))
        riid_str = com.convert_guid_bytes_to_str(riid_bytes)
        iid_name = com.get_iid(riid_str)
        if iid_name:
            argv[3] = iid_name

        return rv
Exemple #2
0
    def CoCreateInstance(self, emu, argv, ctx={}):
        """
        HRESULT CoCreateInstance(
          REFCLSID  rclsid,
          LPUNKNOWN pUnkOuter,
          DWORD     dwClsContext,
          REFIID    riid,
          LPVOID    *ppv
        );
        """
        rclsid, pUnkOuter, dwClsContext, riid, ppv = argv
        rv = windefs.S_OK

        clsid_bytes = self.mem_read(rclsid, self.sizeof(windefs.GUID()))
        clsid_str = com.convert_guid_bytes_to_str(clsid_bytes)
        clsid_name = com.get_clsid(clsid_str)
        if clsid_name:
            argv[0] = clsid_name
            riid_bytes = self.mem_read(riid, self.sizeof(windefs.GUID()))
            riid_str = com.convert_guid_bytes_to_str(riid_bytes)
            iid_name = com.get_iid(riid_str)
            if iid_name:
                argv[3] = iid_name
                if ppv:
                    ci = emu.com.get_interface(emu, emu.get_ptr_size(),
                                               iid_name.replace("IID_", ""))
                    pv = self.mem_alloc(emu.get_ptr_size(),
                                        tag="emu.COM.pv_%s" % iid_name)
                    self.mem_write(
                        pv, ci.address.to_bytes(emu.get_ptr_size(), "little"))
                    self.mem_write(ppv,
                                   pv.to_bytes(emu.get_ptr_size(), "little"))
            else:
                self.emu.logger.info("Unsupported COM IID %s", riid)
        else:
            self.emu.logger.info("Unsupported COM CLSID %s", clsid_str)

        return rv
Exemple #3
0
    def UuidToStringA(self, emu, argv, ctx={}):
        """
        RPC_STATUS UuidToStringA(
          const UUID *Uuid,
          RPC_CSTR   *StringUuid
        );
        """
        uuidp, stringp = argv

        if not uuidp or not stringp:
            return 1

        uuid_bytes = self.mem_read(uuidp, windefs.GUID().sizeof())
        uuid_obj = uuid.UUID(bytes=uuid_bytes)

        string = str(uuid_obj)

        self.mem_write(stringp, string.encode("utf-8"))

        return 0
Exemple #4
0
    def UuidCreate(self, emu, argv, ctx={}):
        """
        RPC_STATUS UuidCreate(
          UUID *Uuid
        );
        """
        uuidp, = argv

        if not uuidp:
            return 1

        new_uuid = windefs.GUID()
        new_uuid.Data1 = random.randint(0, 0xffffffff)
        new_uuid.Data2 = random.randint(0, 0xffffffff) & 0xffff
        new_uuid.Data3 = random.randint(0, 0xffffffff) & 0xffff
        new_uuid.Data4 = random.randbytes(8)

        self.mem_write(uuidp, new_uuid.get_bytes())

        return 0
Exemple #5
0
    def StringFromCLSID(self, emu, argv, ctx={}):
        """
        HRESULT StringFromCLSID(
        REFCLSID rclsid,
        LPOLESTR *lplpsz
        );
        """

        rclsid, lplpsz = argv
        rv = windefs.S_OK

        guid = self.mem_read(rclsid, self.sizeof(windefs.GUID()))
        u = com.convert_guid_bytes_to_str(guid)
        argv[1] = u
        u = (u + '\x00').encode('utf-16le')

        ptr = self.mem_alloc(len(u), tag='api.StringFromCLSID')

        if lplpsz:
            self.mem_write(lplpsz, ptr.to_bytes(emu.get_ptr_size(), 'little'))

        return rv