How to use the ptype.type function in ptype

To help you get started, we’ve selected a few ptype examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arizvisa / syringe / lib / ptypes / parray.py View on Github external
def deserialize_stream(self, stream):
        ofs = self.getoffset()
        try:
            return super(infinite, self).deserialize_stream(stream)
        except StopIteration:
            pass
        return self

if __name__ == '__main__':
    import ptype,parray

    string = 'A'*100
    class qword(ptype.type): length = 8
    class dword(ptype.type): length = 4
    class word(ptype.type): length = 2
    class byte(ptype.type): length = 1
   
    import random
    def function(self):
#        if len(self.value) > 0:
#            self[0].load()
#            print self[0]
        return random.sample([byte, word, dword, function2], 1)[0]

    def function2(self):
        return qword()

    class myarray(parray.type):
        length = 5
        _object_ = dword

    x = myarray()
github arizvisa / syringe / lib / ptypes / parray.py View on Github external
del( self[-1] )     # XXX: hopefully this isn't partially initialzied...
        return self

    def deserialize_stream(self, stream):
        ofs = self.getoffset()
        try:
            return super(infinite, self).deserialize_stream(stream)
        except StopIteration:
            pass
        return self

if __name__ == '__main__':
    import ptype,parray

    string = 'A'*100
    class qword(ptype.type): length = 8
    class dword(ptype.type): length = 4
    class word(ptype.type): length = 2
    class byte(ptype.type): length = 1
   
    import random
    def function(self):
#        if len(self.value) > 0:
#            self[0].load()
#            print self[0]
        return random.sample([byte, word, dword, function2], 1)[0]

    def function2(self):
        return qword()

    class myarray(parray.type):
        length = 5
github arizvisa / syringe / lib / ptypes / parray.py View on Github external
def deserialize_stream(self, stream):
        ofs = self.getoffset()
        try:
            return super(infinite, self).deserialize_stream(stream)
        except StopIteration:
            pass
        return self

if __name__ == '__main__':
    import ptype,parray

    string = 'A'*100
    class qword(ptype.type): length = 8
    class dword(ptype.type): length = 4
    class word(ptype.type): length = 2
    class byte(ptype.type): length = 1
   
    import random
    def function(self):
#        if len(self.value) > 0:
#            self[0].load()
#            print self[0]
        return random.sample([byte, word, dword, function2], 1)[0]

    def function2(self):
        return qword()

    class myarray(parray.type):
        length = 5
        _object_ = dword
github arizvisa / syringe / lib / ptypes / parray.py View on Github external
return self

    def deserialize_stream(self, stream):
        ofs = self.getoffset()
        try:
            return super(infinite, self).deserialize_stream(stream)
        except StopIteration:
            pass
        return self

if __name__ == '__main__':
    import ptype,parray

    string = 'A'*100
    class qword(ptype.type): length = 8
    class dword(ptype.type): length = 4
    class word(ptype.type): length = 2
    class byte(ptype.type): length = 1
   
    import random
    def function(self):
#        if len(self.value) > 0:
#            self[0].load()
#            print self[0]
        return random.sample([byte, word, dword, function2], 1)[0]

    def function2(self):
        return qword()

    class myarray(parray.type):
        length = 5
        _object_ = dword