424,836 Members | 1,840 Online
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

# un-obsfuscating -> into pascal an IOCCC obsfuscated program

14 Replies

 P: n/a On Sun, 06 Mar 2005 07:12:35 GMT, in comp.lang.c , "Peter Williams" wrote: Hi All, I am attempting to reverse-obsfuscate an IOCCC entry, and my ultimategoal is to convert the code into Delphi (OO Pascal). I don't understand what the question-mark (?) operator, ?...: is more or less equivalent to if.. else... and the percent (%) operator does. remainder operator. 6%4 = 2 How do I translate this line (obviously declaring some integers) intopascal ??? int c = 0, *n = v + 100, j = d < u - 1 ? a : - 9000, w, z, i, g, q = 3-f; this declares a bunch of ints and one pointer to an int. What does "<<" do ? e.g. how do I translate the next line??? bit left-shift operator. 0x01 << 4 = 0x10 -- Mark McIntyre CLC FAQ CLC readme: Nov 14 '05 #2

 P: n/a Peter Williams wrote: I am attempting to reverse-obsfuscate an IOCCC entry, and my ultimate goal is to convert the code into Delphi (OO Pascal). I don't understand what the question-mark (?) operator, and the percent (%) operator does. How do I translate this line (obviously declaring some integers) into pascal ??? int c = 0, *n = v + 100, j = d < u - 1 ? a : - 9000, w, z, i, g, q = 3-f; VAR c, j, w, z, i, q : integer; n : ^integer; c := 0; n := v + 100; (* Very questionable operation, Pascal doesn't bandy pointers about *) IF d < u-l THEN j := a ELSE j := -9000; q := 3 - f; -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson Nov 14 '05 #3

 P: n/a Peter Williams wrote: Hi All, I am attempting to reverse-obsfuscate an IOCCC entry, and my ultimate goal is to convert the code into Delphi (OO Pascal). What's that 'Delphi (OO Pascal)'? P.Krumins Nov 14 '05 #4

 P: n/a "Peteris Krumins" writes: Peter Williams wrote: Hi All, I am attempting to reverse-obsfuscate an IOCCC entry, and my ultimate goal is to convert the code into Delphi (OO Pascal). What's that 'Delphi (OO Pascal)'? This is comp.lang.c, so we can't give you a good answer to that question. I note, however, that there are at least 10 newsgroups concerned with Delphi and that a Google search for "Delphi" will give you more and better information than you could possibly get here. -- Keith Thompson (The_Other_Keith) ks***@mib.org San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this. Nov 14 '05 #5

 P: n/a Hi All, I can't quite figure out how to convert this line: while(j != k)*((j -= w) + o) = f; into pascal. Can someone please help? Regards, Peter W. :-))) Sandy Bay, Hobart, Tas, AU. Nov 14 '05 #6

 P: n/a Peter Williams wrote: I can't quite figure out how to convert this line: while(j != k)*((j -= w) + o) = f; An alternative way to write this is... while (j != k) { j = j - w; j[o] = f; } -- Peter Nov 14 '05 #7

 P: n/a On Sun, 06 Mar 2005 23:13:52 GMT, in comp.lang.c , "Peter Williams" wrote: Hi All, I can't quite figure out how to convert this line:while(j != k)*((j -= w) + o) = f; it says while j is not equal to k, set whatever is pointed to by (j-w+o) equal to f, and subtract w from j. -- Mark McIntyre CLC FAQ CLC readme: Nov 14 '05 #8

 P: n/a "Peter Nilsson" writes: Peter Williams wrote: I can't quite figure out how to convert this line: while(j != k)*((j -= w) + o) = f; An alternative way to write this is... while (j != k) { j = j - w; j[o] = f; } Which requires pointer arithmetic. Last time I looked, Pascal didn't support pointer arithmetic. Then again, the last time I looked was a very long time ago. -- Keith Thompson (The_Other_Keith) ks***@mib.org San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this. Nov 14 '05 #9

 P: n/a CBFalconer, Sun20050306@15:00:05(CET): Peter Williams wrote: int c = 0, *n = v + 100, j = d < u - 1 ? a : - 9000, w, z, i, g, q = 3-f; IF d < u-l THEN j := a Oops, that "l" should be a "1". -- David Serrano Nov 14 '05 #10

 P: n/a Keith Thompson wrote: "Peter Nilsson" writes: Peter Williams wrote: I can't quite figure out how to convert this line: while(j != k)*((j -= w) + o) = f; An alternative way to write this is... while (j != k) { j = j - w; j[o] = f; } Which requires pointer arithmetic. Last time I looked, Pascal didn't support pointer arithmetic. True, but that's not clc's problem. However, judging from the original post, the OP has already realised that a conversion in methodology is required for things like: while(*j == q)j += w; Since they likely got past that line, I figured it was only the *(x + y) to x[y] bit they were having problems with. I simply supplied alternative C. You have already pointed out elsethread that there are other groups available which could no doubt assist with the actual translation to Delphi. -- Peter Nov 14 '05 #11

 P: n/a Keith Thompson wrote: I can't quite figure out how to convert this line: while(j != k)*((j -= w) + o) = f; An alternative way to write this is... while (j != k) { j = j - w; j[o] = f; } Which requires pointer arithmetic. Last time I looked, Pascal didn't support pointer arithmetic. Then again, the last time I looked was a very long time ago. The last pre-Delphi version of Borland Pascal did support C-style pointer arithmetic, although at that time it was an undocumented feature of the compiler. If Delphi inherited this feature from BP, the OP can convert this code without any serious problems. -- Best regards, Andrey Tarasevich Nov 14 '05 #12

 P: n/a Andrey Tarasevich wrote: Keith Thompson wrote: I can't quite figure out how to convert this line: while(j != k)*((j -= w) + o) = f; An alternative way to write this is... while (j != k) { j = j - w; j[o] = f; } Which requires pointer arithmetic. Last time I looked, Pascal didn't support pointer arithmetic. Then again, the last time I looked was a very long time ago. The last pre-Delphi version of Borland Pascal did support C-style pointer arithmetic, although at that time it was an undocumented feature of the compiler. If Delphi inherited this feature from BP, the OP can convert this code without any serious problems. No Pascal ever supported pointer arithmetic. Turbo/Borland/Delphi is not Pascal. They all fail to meet even the minimum requirements of the language. However the point is to convert the C statement "while (j != k) *((j -= w) + o) = f;" into Pascal, which requires knowledge of both languages. Even in C there exists the requirement that all the pointers point into the same object, which means that each pointer can be replaced by a base pointer and an index value. Thus replace *j by p[j], *k by p[k], etc for dereferencing purposes, and detect equality etc by operations on the indices. So: VAR p : ARRAY [someindex] OF sometype; j, k : someindex; w, o : integer; f : sometype; .... WHILE j <> k DO BEGIN j := j - w + o; p[j] := f; END; which isn't very frightening once you type the variables properly. -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson Nov 14 '05 #13

 P: n/a CBFalconer wrote:> ...> I can't quite figure out how to convert this line:>> while(j != k)*((j -= w) + o) = f; An alternative way to write this is... while (j != k) { j = j - w; j[o] = f; } Which requires pointer arithmetic. Last time I looked, Pascal didn't support pointer arithmetic. Then again, the last time I looked was a very long time ago. The last pre-Delphi version of Borland Pascal did support C-style pointer arithmetic, although at that time it was an undocumented feature of the compiler. If Delphi inherited this feature from BP, the OP can convert this code without any serious problems. No Pascal ever supported pointer arithmetic. Turbo/Borland/Delphi is not Pascal. They all fail to meet even the minimum requirements of the language. ... Yes, but the OP's question is about translating the original code into Delphi, not into formal "Pascal". -- Best regards, Andrey Tarasevich Nov 14 '05 #14

 P: n/a Andrey Tarasevich wrote: CBFalconer wrote:>> ...>> I can't quite figure out how to convert this line:>>>> while(j != k)*((j -= w) + o) = f;>> An alternative way to write this is...>> while (j != k)> {> j = j - w;> j[o] = f;> } Which requires pointer arithmetic. Last time I looked, Pascal didn't support pointer arithmetic. Then again, the last time I looked was a very long time ago. The last pre-Delphi version of Borland Pascal did support C-style pointer arithmetic, although at that time it was an undocumented feature of the compiler. If Delphi inherited this feature from BP, the OP can convert this code without any serious problems. No Pascal ever supported pointer arithmetic. Turbo/Borland/Delphi is not Pascal. They all fail to meet even the minimum requirements of the language. ... Yes, but the OP's question is about translating the original code into Delphi, not into formal "Pascal". But Delphi does support arrays and indexes into such. So why not use that and eliminate the insecurities of pointer arithmetic. -- Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net) Available for consulting/temporary embedded and systems. USE worldnet address! Nov 14 '05 #15

### This discussion thread is closed

Replies have been disabled for this discussion.