October 30, 2025, 07:19:43 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Dereferencing issue

Started by Peter, April 21, 2008, 11:06:36 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Peter

I have data located in my programs memory at a certain address. I used the assemblerdirective "incbin" to include this into my executable.
Anyways, I need to scramble the data and this is accomplished using a simple xor, and before I use it, I want to "unscramble" it. I have no idea how this is supposed to be done since this code just won't work. What am I doing wrong? If I want to write this info into an executable, what would be the easiest way to do this?

for i = 0 to filesize -1
     *<CHAR>(pFile+i) = *<CHAR>(pFile+i) || 6   ' read the byte located at pFile+i and XOR with 6
next i

sapero

Place the raw data in read/write section, assigning a label to the first byte:
_asm
segment .data ; read/write access

align 4 ; optional, use 4 to access the data as array of INT's, 2 for WORD's, 1 for bytes (default)
raw_data_1: ; any label here

incbin "c:\folder\filename.extension"

raw_data_1_end: ; optional label that can be used to calculate size of incbin'ed file (size= &raw_data_1_end - &raw_data_1)

segment .text ; back to the default code segment
_endasm

/* make the label visible for EB */
declare raw_data_1()

/* access the data */

pointer pFile
pFile = &raw_data_1;

print 0 + *<char>pFile /*force print to display integer*/
*<char>pFile++
print 0 + *<char>pFile


There is an option to place the file in a resource, it can be later accessed by LoadResource command.

Peter

Brilliant sapero! You come to the rescue once again!

Having the data stored as a resource is unfortunately not an alternative because of resourceeditors making it extremely easy to locate where the information is stored. Using incbin, the location of the data is very easy to obfuscate.

It works like a charm thanks to you. Thanks again!