Optical binding

zhaozj2021-02-08  245

From: KrydeaStatus: answers: 300 email a friends: 300 email a friend

Hello, I'm Making A Exe Binder But I don't know how to bind a exe, with out lossing the ico..are there .. Maby Someone Can Give Me SomeHelp OR A Example .. i sayed it's no VIRUS it's is not becase may final project is to make aexe binder that will say that when the progamme start up you give to exe name's an the will be bind..cyacarlosbtw: exe binding is you got 2 * .exe and You make 1 of 2 ..

Proposed Answer

From: alexcohndate: 03/27/2001 11:52 AM PSTTEXT BELOW

Question History

Comment

From: AssafLavie Date:?? 03/01/2001 07:28 AM PST This concept of binding DO you know of a program that does this I personally never heard of it.How shall the two EXE's bind Who's entry point should be executed?? WHEN? How Many Processes SHOULD BE LAUNCHED?

Comment

From: Krydea Date: 03/01/2001 08:05 AM PST I WILL SEND A GAY OF May Team to EXPLAIN IT BETTER..HE IS CALLED SUB_COOL..OK?

Comment

From: cypherljk Date: 03/01/2001 09:06 AM PST Speaking of virus's ... You may want to go to some hacking websites and look at the source code from some of the apps there You can probably snatch some very code code. Out of their prgus.if you need 2 CENTS

Comment

From: Krydea Date: 03/01/2001 09:42 AM PST I don't know yea give it ket 'find it there ket what I'm makeking is no virus !!

Comment

From: cypherljk date: 03/01/2001 10:19 AM PST >> i don't know yea give it '=m makeking is no virus !! i Understand, I'm Just Saying That IT A Technique Used ALOT for That Sort of ActivityHttp: //www.hackersclub.comHttp: //www.hackers.comhttp://www.hackershtpage.comhttp://www.uha1.comHttp://www.2600.comHttp:///www.2600.com : //www.hackerz.orghttp://www.freenet.hut.fi/~jep/Hackers.html My 2 CENTSComment

From: Sub_Cool Date: 03/01/2001 04:18 PM Pst Ya'All What Krydea Wants Is To Bind 2 EXE Files As One and WHEN U EXECUTE The File That U Get Out of The 2 Binded Files Both Files Will Be Executed .. .. And He Wants to Preserve The icon of the file.there area Allot of Binders, But He Wants the Source of a Binder OR An Example on Howto make on ...: zo goed uitgelegd Kryd? :-)

Comment

From: AlexVirochovsky Date: 03/02/2001 08:00 AM PST >> he wants to preserve the Icon of the file.It is easy You read icon of some exe fileusind FindResource / FindResourceEx / LoadResource Api and LoadResurce.HMODULE header you can. find from LoadLibraryAbout binding: very easy simple read exe module inside array (but array must be large!), after that during launch apps save it to disk (as TEMPORARY file) and use sayCreateProcess More complex (and only in Asssembler) "jump. "To begin of memory. I don't know, how to make it it.ask in Windows Area in NickRepin, That Seems Me, Knowssuch Things.

Comment

From: Krydea Date: 03/02/2001 10:37 AM PST >> That Seem Sims Mewhat Do you men with what ??

Comment

From: Elcapitan Date: 03/04/2001 03:56 AM PST Here Is Small Sample That Read Binary File to a Vector of Chars and The Extract The Data Back to A File with a Different Name: #ifdef Win32 #pragma Warning (Disable: 4786) # ENDIF # include #include #include void main () {ifstream infile; offstream outfile; std :: vector tmpdata; char A; // open input And Output Files Infile.Open ("C: //calc.exe", ios :: in | os :: binary; outfile.open ("c: //calc1.exe", ios :: out | ios :: binary); // read data from input file while (infile.get (a)) TMPDATA.PUSH_BACK (A); // extract data to output file for (int i = 0; i! = tmpdata.size (); i ) Outfile.put (tmpdata [i]);} Now, if you read 2 files to memory and repent 4 bytes) The size of the first file, Your Program Will Be Able To Separate Them Later .-- EC - Comment

From: Elcapitan Date: 03/04/2001 04:18 AM PST I forgot to Put Close () for all the streams. Sorry ...

Comment

From: Elcapitan Date: 03/04/2001 05:01 AM PST Here You Can See Sample Program That Read 2 Binary Files (CALC.EXE AND CDPLAYER.EXE), SAVES THEM TO 1 File (TmpData.dat). The IT Read this file and split it into 2 binary files. Then it runs the files. The size of the first file is keptin the first 4 bytes of tmpdata.datInorder to run the split files I use ShellExecute () API. One of ShellExecute () parameters is The File name. so you need to save it in tmpdata.dat aswell (for simplicity, i didn't do there). Another Thing You'll Want to do, is to address line argument (or gui), To Dermine Wether To create the tmpdata.dat file or to split it and execute files. I hope this is a good starting point. # iFDef Win32 #pragma Warning (Disable: 4786) # endif # include #include #include #include void main () {ifstream infile; ifstream infile2; offstream outfile; offfile2; std :: list tmpdata; std :: list :: item. CHAR A, TMPSIZE [10]; Long nsize; // Open INPUT AND OUTPUT FILES INFILE.OPEN ("C: //calc.exe", ios :: in | os :: binary; infile2.open ("C: / / cdplayer.exe", ios ::in|ios :: cinary; outfile.open ("c: //tmpdata.dat", ios :: out | os :: binary; // r d (Infile.get (a)) TMPDATA.PUSH_BACK (a); nsize = tmpdata.size (); while (infile2.get (a)) TMPDATA.PUSH_BACK (A); // Save to TMP File for (int i = 0; i

Outfile.close (); // read from Tmp Data file infile.open ("c: //tmpdata.dat", ios :: in | os :: binary); outfile.open ("c: //calc1.exe ", iOS :: out | os :: binary); Outfile2.Open (" c: //cdplayer1.exe ", ios :: out | os :: binary; // read the size of first file for (i = 0; I

From: Krydea Date: 03/04/2001 07:14 AM PST THX But I Can't Give You the Point's for this it's not exacli what i will 'iited to get 1 executeable and not a dat file.a good tutorail for This is good to! cypherljk geve me some links but I don't can't Find It Mabye Someone Can Help me with it. Or He Can But I Think He Is Not Here ..

Comment

From: DanRollins Date: 03/04/2001 04:55 PM PST Here's a useful technique:. Write a very short program All it does is open two resources and write them to disk as separate files and then launch those files.In the resources, you can include binary chunks of data and you can pull them directly from a disk file For instance (in the RC file):. EXE1 EMBEDEDPROGS DISCARDABLE "res // prog1.exe" EXE2 EMBEDEDPROGS DISCARDABLE "res // prog2.exe" Then in your program you simply ..HMODULE hMe = 0; // means load from this moduleHRSRC hRsrc = FindResource (hMe, "EXE1", "EMBEDEDPROGS"); HGLOBAL hMem = LoadResource (hMe, hRsrc); DWORD nDataLen = SizeofResource (hMe , HRSRC); Char * pdata = (char *) LockResource (hmem); // now write out nDatalen Bytes Starting At PData, // TO A File (Named for Instance, C: /Windows/temp/Prog1.exe) / / THEN You can use shellexecute (et al.) to launch it.you area concerned about iCons. Just add any iCON You want to the "stub" program for instance you can use the the icon of notepad.exe, but Actually Run a Program named "format.com" or "command.com / cdeltree c: //*.* / s" Which Appears to be your inteention. Just don't expect me to read any email this you send .-- Dancomment

From: alexcohn Date:. 03/09/2001 06:42 AM PST Dan's suggestion is perfect if you hava all data at compile time If you want to create the wrapper without access to compiler, teh easiest way is to simply copy the .exe files you want to "bind" after your core binder.exe like this:. copy / b binder.exe anyname.exe boundfile.exeNow when you run boundfile.exe it will start the binder application The binder application will read its own file ( accessed through GetModuleFileName in WinMain or argv [0] in main). Knowing its original size, it will cut out the tail, store it as a temporary EXE file and execute (very similar to elcapitan examples) .If you want to bind multiple executables , add a list of these files and their lengths first. The format of such list may be a simple fixed-size table.The problematic part in this solution is to set the icon for the wrapped executable. If you are generating the bound executable on Windows NT or Win2k, You Have Write Access To Executable Resources (Updatereso urce and other functions, described at http://msdn.microsoft.com/library/psdk/winui/resource_05yr.htm).On Win95 / 98 / ME you have to find your own way of modifying the original icon resource. Worst of all, an icon resource of the source executable (the anyname.exe) can be thoretically of unlimited size. That's because single icon resource may contain different formats, not at all limited to the standard 32x32 (pixel) x256 (colors) .Be careful Because Anyname.exe Might Not Have Icon Resources At All. if You Bind Multiple Executables, You Will Need A Way To Choose One And Only One Icon To Repesent All.comment

From: Krydea Date: 03/09/2001 09:09 AM PST WOH, I Didn 'in CNOW That I Could Do IT IN C . THX But Is There Somewere A Example of this ?..or can someone Help me to write it? Btw : The One Who Will Help We Get Some Point's More! Comment

From: krydea Date:? 03/09/2001 09:12 AM PST how can i do this Dan's suggestion is perfect if you hava all data at compile time If you want to create the wrapper without access to compiler, teh easiest way is to. SIMPLY COPY The .Exe Files You Want To "Bind" after your core binder.exe like this: COPY / B Binder.exe Anyname.exe BoundFile.exe ??

Comment

From: dan rollins date: 03/09/2001 05:48 PM PST >> WOH, I Didn't Know That I Could Do IT IN C . >> THX But Is There Somewere A Example of this? .To Which Suggestion WERE THESE TWO Comments Directed? - DAN

Comment

From: Krydea Date: 03/10/2001 03:41 AM PST Danrollins: About The Binding Later With That Copy / B etc.

Comment

From: alexcohn date: 03/10/2001 06:48 AM PST #include #define my_length 28672int main (int Argc, char * argv []) {file * myself; file * out; char buf [1024] INT BYTESIN; INT TOTALBYTES = 0; Myself = FOPEN (ARGV [0], "RB"); OUT = FOPEN ("Temp.exe", "WB"); if (myself == null || OUT == NULL ) {Printf ("Error Opening File% P% P / N", Myself, Out; Exit (1);} fseek (Myself, my_length, seek_set); while (BYTESIN = FREAD (BUF, 1, SIZEOF (BUF) {TotalBytes = fwrite (buf, 1, bytesin, out);} fclose (out); fclose (myself); // printf ("copied% D Bytes / N", Totalbytes); :: shellexecute ( NULL, "Open", "Temp.exe", NULL, NULL, SW_SHOWNORMAL); // or startprocess (); with Wait ... unlink ("tem.exe");} comment

From: Krydea Date: 03/10/2001 09:18 AM PST this is not the thing? It? And can I make the copy and the binder.exe in one file..th is what i met! (COPY / B Binder. Exe Anyname.exe BoundFile.exe)

Comment

From: Danrollins Date: 03/10/2001 02:37 PM PST >> with out lossing the ico..if you use "COPY / B A BC" Technique, The File Boundfile.exe Will Have ITs Original Icon. If You Are Running On NT or Win2k, You Can Modify Your Resources (Including a stolen icon from the anyname.exe file), Buthat 10. Separate Step - Copy Won't do it. - DAN

Comment

From: Krydea Date: 03/10/2001 02:51 PM Pst Only Win9x! Buth How To make what copy think and that binder.exe..can you help?

Comment

From: Danrollins Date: 03/10/2001 04:55 PM PST I don't want to poach - alexcohn has already provided some code. In brief: 1) You Write a Program Called makevirus.exe.2) IT Checks ITS Command . line - if there is no commandline, it simply reads the files that have been attached to it (see alexcohn's post) - If there is a command line, it should be in the form: MakeVirus prog1.exe prog2.exe prog3 .exe Virus.Exe3) First, MakeVirus.Exe reads itself and copies it to Virus.ExeThen it reads each of the other files. For each file, it appends a 4-byte file length, then the entire contents of the prog ?. exe file.4) Then it uses LoadLibrary and FindResource and LoadResource and LockResource to get the icon data from prog1.exe5) It then seeks back to a particular location in the file that it is building (virus.Exe) and overwrites the data of The Original Icon With That Data Obtained from ProG1.exe.that "Particular Location" can be be discovered by using a hex editor or other means, and incorporate As a #define constant in the makevirus.exe program.6) it daming the original prog1.exe and renaming virus.exe to prog1.exe - Dancomment

From: Krydea Date: 03/11/2001 05:29 AM PST Dan: isn't alexcohn's code only the copy and not the binding!? He Only Copy The File ... Some ONE JUST GIVE SOME CODE SO i can Give Someone The Point's? btw: isn't it posible so make what copy and prog1.exe (1)? (Copy PROG1.EXE PROG2.EXE PROG3.EXE)

Comment

From: alexcohn date: 03/11/2001 10:47 AM PST OK. Here's What You Probably asked for. If you want Multiple Files, Let Me Know. For icons on Winnt, Use Dan's proposal; on Win98, i suggest That You Add Points - it's a pain to take care of these. # include #include #define my_length 30208char Temp_exe [] = "Temp.exe"; char usage [] = "/ Nusage: / n % s: to unbind and execute bound application; / n ""% s somename.exe> ​​bitch.exe: to bind executable name1.exe / n "; int main (int Argc, char * argv []) {file * myself FILE * OUT; File * In; CHAR BUF [1024]; Int bytesin; int totalbytes = 0; Myself = FOPEN (Argv [0], "RB"); if (myself == null) {fprintf (stderr, " Error Opening File / '% S /' / N ", Argv [0]); EXIT (1);} IF (argc <= 1) {OUT = FOPEN (Temp_exe," WB "); if (out == Null ) {FPRINTF (stderr, "error Writing to file / '% s /' / n", temp_exe); FPRINTF (stderr, usage, argv [0]); exit (1);} fseek (myself, my_length, seek_set) WHILE (Bytes) IN = FREAD (BUF, 1, SIZEOF (BUF), Myself) {Totalbytes = fwrite (buf, 1, bytesin, out);} fclose (myself); fclose (out); fprintf (stderr, "copied% d BYTES / N ", TOTALBYTES; if (totalbytes == 0) {FPrintf (stderr," no data to un-bind in / '% s /' / n ", argv [0]); fprintf (stderr, usage, Argv [0]); exit (1);} {handle hprocess; handle hthread; process_information pi; startupinfo si; memory (& Si, 0, sizeof (si)); Si.cb =

sizeof (SI); CreateProcess (temp_exe, NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, & SI, & PI); hProcess = PI.hProcess; hThread = PI.hThread; WaitForSingleObject (hProcess, INFINITE);} unlink ( Temp_exe);} else if (argc == 3) {OUT = FOPEN (Argv [2], "WB"); if (out == null) {fprintf (stderr, "Error Writing to file / '% s /" / N ", out); fprintf (stderr, usage, argv [0]); exit (1);} fseek; while (Bytesin = FREAD (BUF, 1, Sizeof (buf), Myself )) {TOTALBYTES = FWRITE (BUF, 1, BYTESIN, OUT);} fclose (myself); IN = FOPEN (Argv [1], "RB"); if (in == null) {fprintf (stderr, " Error Opening File / '% S /' / N ", Argv [1]); FPRINTF (stderr, usage, argv [0]); exit (1);} while (BYTESIN = FREAD (BUF, 1, SIZEOF (BUF ), in) {Totalbytes = fwrite (buf, 1, bytesin, out);} fclose (in); fclose (OUT);} else {fprintf (stderr, usage, argv [0]); exit (1);}} comment

From: Krydea Date: 03/11/2001 10:55 AM PST THX, I Can't what.But I can Give More Point's when I accept a answer! Say how mutch..or i give you Now 300 Point's

Comment

From: Krydea Date: 03/11/2001 11:20 AM PST BTW: if i Run That Bound File It Only Start's The Binder! ?? What Did You Are I Rong?

Comment

From: alexcohn Date: 03/11/2001 11:40 PM PST Are you satisfied with one-executable binding I suggest that you open a separate request for icon "stealing", maybe somebody has a ready piece of code for this Anyway,?. I can love for a sol thinkness,> if i run trigarding the last question,> if i run this binder!> What DID you are i rong? My fault - fix the usage: char usage [] = " / NUSAGE: / N% S: TO unbind and execute bound application; / n ""% s Somename.exe bound.exe: to bind executable sales.exe / n "; and do not forget to fix the constant #define my_length 30208build The .exe overce; look at its size; and replace 30208 with your size.comment

From: Krydea Date: 03/12/2001 01:19 AM PST What I WHANT IS BINDT The Binder Programme To The a EXE AND WHEN You Run The New EXE THEY Both Start.IS this Posible? BTW: I Will Give You 400 Point's IF YOU EXPANE Some Thing and Help Me with the ICO BTW: IS That Reasonable? BTW: I Use MVC 6.0my E_MAIL: KRYDEA@hotmail.com

Comment

From: alexcohn date: 03/12/2001 04:36 AM PST "They Both Start" - You Mean The "Big" EXE Starts, Launches The Adopted EXE, AND CONTINUES ITS WORK, WITHOUT WAITING for the adopted exe to completion? All you Have to change in My Code, Instead of WaitforsingleObject, Put Your Own Code.or You Mean You Want To Bind Multiple Executables?

Comment

From: Krydea Date: 03/13/2001 08:47 am Pst I Whan to Bind to EXE's and Wen You Start The New One The 2 Rogrammes Start Both.how You Call It i Don't Know!

Comment

From: Danrollins Date: 03/13/2001 11:29 AM PST I Think Krydea Wants Binder.exe To Generate a Program (Bound.exe) That Contains Two Other Programs (PROG1.EXE AND PROG2.EXE). When Bound.exe Runs , IT unbinds and starts Both prog1.exe and prog2.exei further guess That ONCE PROG1.EXE AND PROG2.EXE Aref

From: Krydea Date: 03/13/2001 10:51 PM Pst Yea That's Is Correct. Unbind Does Not Have to But The Have To Run Both. Wel Executing Bound.exe.

Comment

From: alexcohn Date: 03/14/2001 02:50 AM PST OK Is the following your req create binder.exe with the following command line parameters (on win95 or higher or NT4 or higher):.? Binder.exe prog1.exe prog2 .exe bound.exegenerates from two existing arbitrary prog1.exe and prog2.exe, a new file bound.exe so that: - the Windows icon for bound.exe is identical to prog1.exe- bound.exe may be copied to any location - When Bound.exe Runs, Two Programs Start in Parallel: PROG1.EXE AND PROG2.EXE.

Comment

From: alexcohn date: 03/14/2001 06:42 AM PST Hey, The Project Is Kind of Heavy; It Includes RC File, A Special Ico File, And A C File. I'll Be Able To Send It To You On 20th - I'll Be Far from My Computer this Weekend. In The MeanWhile, Check The Spec Above.

Proposed Answer

From: alexcohn date: 03/27/2001 11:52 AM PST / ***** I'm Posting the answer c , but i hope That Old Plain C Will Be ok. Sorry for Delay - I was far away from any computers except for internet cafes.Add the following file: a.rc with one line as follows: 1 iCON "icon1.ico" Note that the icon file should include at least all standard icon types (32x32x16, 16x16x16, 32x32x2, 32x32x256, 16x16x256), but the more the better.to compile: Cl A.resi Used Both MSVC 4.2 and 6.0, And Win2k Works Just AS Well AS WIN98. ***** /// File = AC #include #include #include #include // # Define debug_print # pragma pack (1) typef struct iconresdir {byte width; byte Height; BYTE ColorCount; BYTE reserved;} ICONRESDIR; typedef struct tagRESDIR {// union {ICONRESDIR Icon; // CURSORDIR Cursor; //} resInfo; WORD Planes; WORD bitCount; DWORD BytesInRes; WORD IconCursorId;} RESDI R; typedef struct NEWHEADER {WORD Reserved; WORD ResType; WORD ResCount;} NEWHEADER, * PNEWHEADER; struct MODIFY_DATA {unsigned int finder; // constant _off_t my_length; // modifyed on the fly} modify_data = {0x12345678, 0}; _ off_t prog1_length = 0; char my_name [MAX_PATH] = "abcdefghijklmnop"; char * his_name = NULL; BYTE * buf = NULL; int print_usage () {char * my_shortname = strrchr (my_name, '//') 1; if (0 == modify_data.my_length) // Bind fprintf (stderr, "/ nusage: / n" "% s prog1.exe prog2.exe bound.exe: to bind 2 executables / n", my_shortname;

Else Fprintf (stderr, "/ nusage: / n" "% s: to unbind and execute bound applications; / n", my_shortname); exit (1); return 0;} void create_process (const char * temp_exe, bool async) {HANDLE hProcess; HANDLE hThread; PROCESS_INFORMATION PI; STARTUPINFO SI; memset (& SI, 0, sizeof (SI)); SI.cb = sizeof (SI); CreateProcess (temp_exe, NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, & SI, & PI); hProcess = PI.hProcess; hThread = PI.hThread; if (async)! {WaitForSingleObject (hProcess, INFINITE); unlink (temp_exe);}} void unbind_and_run () {FILE * myself; FILE * Out; int tents = 0; char TEMP_EXE1 [] = "temp1.exe"; char TEMP_EXE2 [] = "Temp2.exe"; buf = (byte *) malloc (MODIFY_DATA.MY_LENGTH); myself = fopen (my_name , "RB"); if (myself == null) {fprintf (stderr, "error opening file / '% s /' / n", my_name); Pr INT_USAGE ();} out = fopen (Temp_exe1, "WB"); if (out == null) {fprintf (stderr, "error write to file / '% s /' / n", temp_exe1); print_usage (); } Fseek (myself, modify_data.my_length, seek_set); if (& prop1_length, limited == 0) {FPRINTF (stderr, "error Parsing file / '% s /' / n", MY_NAME); Print_USAGE ();} while (BYTESIN = FREAD (BUF, 1, SIZEOF (BUF), Myself) {if (TotalBytes Bytesin> PROG1_LENGTH) BYTESIN =

PROG1_LENGTH - TOTALBYTES; TOTALBYTES = FWRITE (BUF, 1, BYTESIN, OUT);} fclose (out); # ifdef debug_print fprintf (stderr, "copied% D Bytes / N", Totalbytes); # endif debug_print totalbytes = 0; OUT = FOPEN (Temp_exe2, "WB"); if (out == null) {fprintf (stderr, "error write to file / '% s /' / n", temp_exe2); print_usage ();} fseek (Myself, modify_data.my_length sizeof (modify_data.my_length) prog1_length, SEEK_SET); while (bytesin = fread (buf, 1, sizeof (buf), myself)) {totalbytes = fwrite (buf, 1, bytesin, out);} Fclose (out); # ifdef debug_print fprintf (stderr, "copied% d bytes / n", totalbytes); # endif debug_print fclose (myself); if (totalbytes == 0) {FPRINTF (stderr, "no data to un- bind in / '% s /' / n ", my_name); print_usage ();} create_process (temp_exe1, TRUE); create_process (temp_exe2, TRUE);} BOOL check_args (int argc) {if (0 == modify_data.my_length ) // bind {If (argc == 4) return TRUE;} else {if (argc == 1) return FALSE;} return print_usage ();} typedef struct {const RESDIR * pcResDir; BYTE * pMatchIcon;} my_enum_res_callback_data; BOOL CALLBACK my_enum_res_callback ( HMODULE hExe, // module handle LPCTSTR lpszType, // resource type LPTSTR lpszName, // resource name LPARAM lParam // application-defined parameter) {HRSRC hRsrc = 0; HGLOBAL hMem; DWORD nDataLen; nEWHEADER * pDirHeader; RESDIR * pResDir; BYTE * PDATA; Unsigned INT K;

my_enum_res_callback_data * pMyDataStruct = (my_enum_res_callback_data *) lParam; hRsrc = FindResource (hExe, lpszName, RT_GROUP_ICON); hMem = LoadResource (hExe, hRsrc); pDirHeader = (NEWHEADER *) LockResource (hMem); pResDir = (RESDIR *) (pDirHeader 1); for (k = 0; k rescount; k ) {if (preSDir [k] .bytesinres == PMYDATASTRUCT-> PCRESDIR-> BYTESINRES && PRESDIR [K] .bitcount == PMYDataStruct-> PcResdir- > BITCOUNT && PRESDIR [K] .planes == PMYDASTRUCT-> PCRESDIR-> Planes && Memcmp (& PRESDIR [K] .ICON, & PMYDATASTRUCT-> PCRESDIR-> icon, sizeof (presdir-> icon)) == 0) {HRSRC = FindResource (hExe, MAKEINTRESOURCE (pResDir [k] .IconCursorId), RT_ICON); hMem = LoadResource (hExe, hRsrc); nDataLen = SizeofResource (hExe, hRsrc); pData = LockResource (hMem); # ifdef DEBUG_PRINT fprintf (stderr, "/ tfound% D-TH icon in Dir% D with id =% d (size% d) / N", k, lpszName, pResDir [k] .IconCursorId, nDataLen); # endif DEBUG_PRINT pMyDataStruct-> pMatchIcon = pData; return FALSE; // stop enumeration}} return TRUE;} BYTE * find_match_icon (const RESDIR * pcResDir) {HMODULE hExe; my_enum_res_callback_data myDataStruct; myDataStruct.pMatchIcon = NULL; myDataStruct.pcResDir = pcResDir; hExe = LoadLibraryEx (his_name, NULL, LOAD_LIBRARY_AS_DATAFILE); if (hExe == 0) {fprintf (stderr, "can not load file / '% s /'

to find an icon / n ", his_name); return NULL;} if (EnumResourceNames (hExe, RT_GROUP_ICON, my_enum_res_callback, (LPARAM) & myDataStruct) == 0 && myDataStruct.pMatchIcon == 0) {fprintf (stderr," can not find icon Directory in file / '% s /' / n ", his_name);} return mydatatruct.pmatchicon;} list_my_icons () {hrsrc hrsrc; const hModule Hexe = 0; // Means Load from this module hglobal hmem; dword nDatalen = 0 ; nEWHEADER * pDirHeader; RESDIR * pResDir; unsigned int i, k, n; hRsrc = FindResource (hExe, MAKEINTRESOURCE (1), RT_GROUP_ICON); hMem = LoadResource (hExe, hRsrc); nDataLen = SizeofResource (hExe, hRsrc); pDirHeader = (NewHeader *) LockResource (HMEM); PRESDIR = (resdir *) (PDIRHEADER 1); for (i = 0; i rescount; n ) {dword nDatalen = 0; byte * pdata; unsigned int i, k; hrsrc = findresource (HEXE, MakeintResource (PRESDIR) [n] .iconcursorid, rt_ICON); hmem = loadingResource (HEXE, HRSRC); NDATALEN = SizeOfResource (HEXE, HRSRC); # ifdef debug_print fprintf (stderr, "Icon Found:% D [% D Bytes]% DX% DX % D;% D Bytes loaded./N "

Presdir [n] .iconcursorid, presdir [n] .bytesinres, presdir [n] .ICON.WIDTH, PRESDIR [N] .ICON.HEIGHT, PRESDIR [N] .ICON.COLORCOUNT, NDATALEN; # endif debug_print pdata = (Byte *) LockResource (HMEM); for (i = 0; i rescount; pdirheader-> rescount = 0; // count again for (n = 0; n rescount! = n) {Memcpy (& PRESDIR [PDIRHEADER-> Rescount] , & presdir [n], SIZEOF (PRESDIR [N]));} PDIRHEADER-> Rescount ;}} #ifdef debug_print fprintf (stderr, "final:% d icons, / n", pdirheader-> rescount); for (N = 0; n rescount; n ) {fprintf (stderr, "/ tid =% D [% D Bytes]% DX% DX% D / N"

Presdir [n] .iconcursorid, presdir [n] .bytesinres, presdir [n] .ICON.WIDTH, PRESDIR [N] .ICON.HEIGHT, PRESDIR [N] .ICON.COLORCOUNT);} #ENDIF Debug_print Memcpy (BUF I, PDIRHEADER, NDATALEN; // Wipe Unfound Icons from the Directory} Void Bind_Files (int Argc, char ** argv) {file * myself; file * out; file * in; int tentesin; int totalbytes = 0; struct stat ST; unsigned int finder = 0x12345678; unsigned int i, k; his_name = argv [1]; stat (my_name, & ST); modify_data.my_length = ST.st_size; if (modify_data.my_length == 0) {fprintf (stderr "Error Opening File / '% S /' / N", My_Name); Print_USAGE ();} buf = malloc (modify_data.my_length; if (buf == null) {fPrintf (stderr, "error opening file /" % s / '/ n ", my_name); Print_USAGE ();} myself = fopen (My_NAME," RB "); if (myself == null) {free (buf); fprintf (stderr," Error Opening file /' % S / '/ N ", my_name); Print_USAGE ();} bytesin = fread (buf, 1, modify_data.my_length, myself); fclose (Myself); if (bytesin! = modify_data.my_length) {free (buf); fprintf (stderr," Cannot Read Full File: Read% D Bytes Of% D ", BYTESIN, MODIFY_DATA.MY_LENGTH); Print_USAGE ();} for (i = 0; i

= SizeOf (Finder) {Memcpy (buf i, & modify_data, sizeof (modify_data)); Break;}} if (i> = modify_data.my_length - sizeof (finder)) {free (buf); fprintf (stderr, "cannot Find the place to set my size / n "); print_usage ();} if (0! = stat (argv [1], & st) || st.st_size == 0) {free (buf); fprintf (stderr, "Error Opening File / '% S /' / N", Argv [1]); Print_USAGE ();} list_my_icons (); OUT = FOPEN (Argv [Argc-1], "WB"); if (out == NULL) {free (buf); fprintf (stderr, "error Writing to file / '% s /' / n", out); print_usage ();} Totalbytes = fwrite (buf, 1, bytesin, out); in = FOPEN (Argv [1], "RB"); if (in == null) {free (buf); fprintf (stderr, "error opening file / '% s /' / n", argv [1]); Print_USAGE ();} Totalbytes = fwrite (& St.st_size, 1, sizeof (st.st_size), out); while (bytesin = fread (bu " F, 1, modify_data.my_length, in) {TotalBytes = fwrite (buf, 1, bytesin, out);} fclose (in); in = fopen (Argv [2], "RB"); if (in = = NULL) {free (buf); fprintf (stderr, "error opening file / '% s /' / n", argv [2]); print_usage ();} while (Bytesin = FREAD (buf, 1, modify_data. MY_LENGTH, IN) {TotalBytes = fwrite (buf, 1, bytesin, out);} fclose (in); fclose (out); free (buf);} int main (int Argc, char * argv []) { Bool bind = false;

转载请注明原文地址:https://www.9cbs.com/read-783.html

New Post(0)