def Read(self, this, pv, cb, pRead): try: bytes = self.data[:cb] self.data = self.data[cb:] memmove(pv, bytes, cb) return S_OK except: return S_FALSE
def ReadSnapshot(data): """extracts TBBUTTON and string array from the passed data.""" error = True data = create_string_buffer(data) if len(data) > (len(SNAP_COOKIE) + 12): # test for cookie if data[:3] == SNAP_COOKIE: n = len(SNAP_COOKIE) + 1 # version and sizeof ver = UINT.from_address(addressof(data) + n) n += 4 szeof = UINT.from_address(addressof(data) + n) n += 4 # get button array nButtons = UINT.from_address(addressof(data) + n) n += 4 szeofBt = nButtons.value * sizeof(TBBUTTON) if len(data) > szeofBt + n: arrBt = (TBBUTTON * nButtons.value)() memmove(addressof(arrBt), addressof(data) + n, szeofBt) n += szeofBt # get text array cchText = UINT.from_address(int(addressof(data) + n)) n += 4 if len(data) == n + cchText.value + 1: text = data[n:n + cchText.value] error = False if error: raise ValueError("invalid data") return arrBt, text
def ReadSnapshot(data): """extracts TBBUTTON and string array from the passed data.""" error = True data= create_string_buffer(data) if len(data) > (len(SNAP_COOKIE)+12): # test for cookie if data[:3]==SNAP_COOKIE: n= len(SNAP_COOKIE)+1 # version and sizeof ver= UINT.from_address(addressof(data)+n) n += 4 szeof= UINT.from_address(addressof(data)+n) n += 4 # get button array nButtons= UINT.from_address(addressof(data)+n) n += 4 szeofBt= nButtons.value*sizeof(TBBUTTON) if len(data) > szeofBt+n: arrBt= (TBBUTTON*nButtons.value)() memmove(addressof(arrBt), addressof(data)+n, szeofBt) n+= szeofBt # get text array cchText= UINT.from_address(int(addressof(data)+n)) n+= 4 if len(data)== n + cchText.value+1: text= data[n:n+cchText.value] error= False if error: raise ValueError("invalid data") return arrBt, text
def Write(self, this, pv, cb, pWritten): try: p = create_string_buffer(cb) memmove(p, pv, cb) self.data = self.data + p.raw # imagelists don't seem to care #try: pWritten[0] # NULL pointer test #except: pass return S_OK except: return STG_E_CANTSAVE