- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ladies an gentlemen,
I have the following problem. I have an ascii text file, that is normally loaded during the runtime of my program.
Due to the fact that the file is a text file, everybody who runs this program could directly look at the contents of the file.
I don't want this because it contains inforamtion that should not be published.
That's why I tought it would be possible to add this textfile to the resources of my program.
I had to crate a new group (I named it "File") and added the file to this group.
In theresource.rc my file is shown with its ID and when I double click on the file I can see the contents in HEX and ASCII.
When I compile mywhole program it seems that the text file has also been compiled into the executable without a problem refering too the size of the .exe.
So far so good.
Unfortunately I have some troublein accessing the file during runtime.
I tried "LoadString", but this doesn't seem to work for text files.
When I tried to use LoadString to load text from a string table everything is fine.
Converting my text file to a stringtable would make no sense because it's way to big.
Is there a chance to add a text file to the resources and to access this textfile during runtime?
Thanks for your help.
Best regards,
Christian
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you note, even if you were to add your text as a resource or as an internal character constant, the original contents can be viewed by inspecting the .exe with an editor, and would thus not achieve your security objective.
You could easily make a (weakly) encrypted version of your text file (eg, add a constant integer offset to each char value), then have your .exe read the text at runtime and remove the encryption, so the original content is never directly exposed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]subroutine extractBinary(codeWort,zielDatei) use ifwin ! implicit none ! character*(*) codeWort,zielDatei integer(kind=4) dwResourceSize,hRes,hGlob integer(1)::sVoidData(*); pointer(lpVoidData,sVoidData) hRes=FindResource(null,loc(codeWort),loc("binarydata"c)) hGlob=LoadResource(null,hRes); dwResourceSize=SizeofResource(NULL,hRes); lpVoidData=LockResource(hGlob); open(11,file=zielDatei,form="Binary") write(11) sVoidData(1:dwResourceSize) close(11) return end subroutine extractBinary [/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]subroutine extractBinary(codeWort,zielDatei)
CHARACTER::sVoidData(*); pointer(lpVoidData,sVoidData)
lpVoidData=LockResource(hGlob);
! open(11,file=zielDatei,form="Binary")
! write(11) sVoidData(1:dwResourceSize)
! close(11)
return
end subroutine extractBinary
[/cpp]
Note, also, that with minor change I introduced above, the character array sVoidData(1:dwResourceSize) now contains the full text of your original file (well, including line endings -- char(13)//char(10)) so you can parse it using statements such as READ and INDEX, without the need to actually save it to disk.
The point that the data remain visible if someone wants to peek into the .exe file using a hex editor still stands, though.
You can also add a level of obfuscating if you use a binary file, or e.g. pack your data into a big TYPE. That all depends on how much time you want to invest in changing and which obfuscation level is necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I got as afar as 'upload' there, then everything went quiet. Here goes on attempt #3...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That looks like the sample provided with IVF. I don't recall that CVF had such a sample.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That looks like the sample provided with IVF. I don't recall that CVF had such a sample.
You are correct - the Fortran Code is Intel's, as the text clearly states, so it is Intel's property ultimately I guess. We can still use it, no?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, you can use it. I was just confused by your saying it came from CVF and could be "modified" to use with IVF.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But what is the point of adding 500 lines of complex code calling multiple APIs, when the actual problem can be solved simply by
[cpp]DO j = 1, buflen buf(j) = CHAR(ICHAR(buf(j)) - offset) END DO[/cpp]
which probably won't fool the NSA but certainly ensures the content of the (modified) text is not directly human-readable, which is all the OP asked for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or you could XOR the characters with some bit pattern, For better security, use the ROT13 cipher - just don't use it twice! :-)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page