News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

A new shuffle program.

Started by hutch--, December 14, 2006, 02:06:30 PM

Previous topic - Next topic

hutch--

I did one of these a while ago in high level basic and it worked OK, here is a low level one in MASM that is both small and fast. It does effectively the reverse of sorting lines of text, it randomises the lines instead. It uses an old card shuffling technique of swapping every pointer in the array read from the bottom up with a randomly selected pointer within the same array.

My own use for it is to shuffle lines in include files for applications where i want a unique binary image each time the app is built. It works just as well on .DATA section data. The virtue of this technique is it makes static patching highly unreliable as every version is different. Interestingly enough its useful elsewhere, I have someone who can use it who wants to randomise large quantities of text so it loads into a tree structure in a more balanced form.

Speed seems to be reasonable, running it once is probably good enough but to time it and get some idea of its speed, I run the shuffle algo 100 times on the same array of pointers and it is still reasonably fast.

There are two small apps in the zip file, one is a test piece for the algo, the other is a working application for shuffling an external file and writing the results to disk with a file name of the users choice.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ecube

Nice work! This code is useful indeed  :bg