2 * SetupAPI virtual copy operations
4 * Copyright 2001 Andreas Mohr
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * FIXME: we now rely on builtin setupapi.dll for dialog resources.
21 * This is bad ! We ought to have 16bit resource handling working.
24 #include "setupapi_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(setupapi
);
28 static FARPROC16 VCP_Proc
= NULL
;
29 static LPARAM VCP_MsgRef
= 0;
31 static BOOL VCP_opened
= FALSE
;
33 static VCPSTATUS vcp_status
;
35 static HINSTANCE SETUPAPI_hInstance
;
37 static WORD
VCP_Callback( LPVOID obj
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
, LPARAM lParamRef
)
43 args
[7] = HIWORD(obj
);
44 args
[6] = LOWORD(obj
);
47 args
[3] = HIWORD(lParam
);
48 args
[2] = LOWORD(lParam
);
49 args
[1] = HIWORD(lParamRef
);
50 args
[0] = LOWORD(lParamRef
);
51 WOWCallback16Ex( (DWORD
)VCP_Proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
56 /****************************** VHSTR management ******************************/
59 * This is a totally braindead implementation for now;
60 * I don't care about speed at all ! Size and implementation time
61 * is much more important IMHO. I could have created some sophisticated
62 * tree structure, but... what the hell ! :-)
69 static VHSTR_STRUCT
**vhstrlist
= NULL
;
70 static VHSTR vhstr_alloc
= 0;
72 #define VALID_VHSTR(x) ((x < vhstr_alloc) && (vhstrlist[x]) && (vhstrlist[x]->refcount))
74 /***********************************************************************
75 * vsmStringAdd (SETUPX.207)
77 VHSTR WINAPI
vsmStringAdd16(LPCSTR lpszName
)
83 TRACE("add string '%s'\n", lpszName
);
84 /* search whether string already inserted */
85 TRACE("searching for existing string...\n");
86 for (n
= 0; n
< vhstr_alloc
; n
++)
88 if ((vhstrlist
[n
]) && (vhstrlist
[n
]->refcount
))
90 TRACE("checking item: %d\n", n
);
91 if (!strcmp(vhstrlist
[n
]->pStr
, lpszName
))
94 vhstrlist
[n
]->refcount
++;
100 /* hmm, not found yet, let's insert it */
101 TRACE("inserting item\n");
102 for (n
= 0; n
< vhstr_alloc
; n
++)
104 if ((!(vhstrlist
[n
])) || (!(vhstrlist
[n
]->refcount
)))
110 heap
= GetProcessHeap();
111 if (n
== vhstr_alloc
) /* hmm, no free index found yet */
117 vhstrlist
= HeapReAlloc(heap
, HEAP_ZERO_MEMORY
, vhstrlist
,
118 sizeof(VHSTR_STRUCT
*) * vhstr_alloc
);
120 vhstrlist
= HeapAlloc(heap
, HEAP_ZERO_MEMORY
,
121 sizeof(VHSTR_STRUCT
*) * vhstr_alloc
);
124 return 0xffff; /* failure */
125 if (!vhstrlist
[index
])
126 vhstrlist
[index
] = HeapAlloc(heap
, HEAP_ZERO_MEMORY
, sizeof(VHSTR_STRUCT
));
127 vhstrlist
[index
]->refcount
= 1;
128 vhstrlist
[index
]->pStr
= HeapAlloc(heap
, 0, strlen(lpszName
)+1);
129 strcpy((LPSTR
)vhstrlist
[index
]->pStr
, lpszName
);
133 /***********************************************************************
134 * vsmStringDelete (SETUPX.206)
136 INT16 WINAPI
vsmStringDelete16(VHSTR vhstr
)
138 if (VALID_VHSTR(vhstr
))
140 vhstrlist
[vhstr
]->refcount
--;
141 if (!vhstrlist
[vhstr
]->refcount
)
143 HeapFree(GetProcessHeap(), 0, (LPSTR
)vhstrlist
[vhstr
]->pStr
);
144 vhstrlist
[vhstr
]->pStr
= NULL
;
149 /* string not found */
154 * vsmStringFind() - not exported from a standard SETUPX.DLL, it seems
156 VHSTR WINAPI
vsmStringFind16(LPCSTR lpszName
)
159 for (n
= 0; n
< vhstr_alloc
; n
++)
160 if ((vhstrlist
[n
]) && (vhstrlist
[n
]->refcount
) && (!strcmp(vhstrlist
[n
]->pStr
, lpszName
)))
165 /***********************************************************************
166 * vsmGetStringName (SETUPX.205)
168 * Pretty correct, I guess
170 INT16 WINAPI
vsmGetStringName16(VHSTR vhstr
, LPSTR lpszBuffer
, int cbBuffer
)
172 if (VALID_VHSTR(vhstr
))
174 int len
= strlen(vhstrlist
[vhstr
]->pStr
)+1;
178 strcpy(lpszBuffer
, vhstrlist
[vhstr
]->pStr
);
185 /***********************************************************************
186 * vsmStringCompare (not exported from a standard SETUPX.DLL, it seems)
188 INT16 WINAPI
vsmStringCompare16(VHSTR vhstrA
, VHSTR vhstrB
)
190 if ((!VALID_VHSTR(vhstrA
)) || (!VALID_VHSTR(vhstrB
)))
191 return VCPN_FAIL
; /* correct ? */
192 return strcmp(vhstrlist
[vhstrA
]->pStr
, vhstrlist
[vhstrB
]->pStr
);
195 /***********************************************************************
196 * vsmGetStringRawName (SETUPX.208)
198 LPCSTR WINAPI
vsmGetStringRawName16(VHSTR vhstr
)
200 return (VALID_VHSTR(vhstr
)) ? vhstrlist
[vhstr
]->pStr
: NULL
;
204 /***************************** VIRTNODE management ****************************/
205 static LPVIRTNODE
*pvnlist
= NULL
;
206 static DWORD vn_num
= 0;
207 static DWORD vn_last
= 0;
209 static RETERR16
VCP_VirtnodeCreate(LPVCPFILESPEC vfsSrc
, LPVCPFILESPEC vfsDst
, WORD fl
, LPARAM lParam
, LPEXPANDVTBL lpExpandVtbl
)
215 while (vn_last
< vn_num
)
217 if (pvnlist
[vn_last
] == NULL
)
221 heap
= GetProcessHeap();
222 if (vn_last
== vn_num
)
226 pvnlist
= HeapReAlloc(heap
, HEAP_ZERO_MEMORY
, pvnlist
,
227 sizeof(LPVIRTNODE
*) * vn_num
);
229 pvnlist
= HeapAlloc(heap
, HEAP_ZERO_MEMORY
,
230 sizeof(LPVIRTNODE
*) * vn_num
);
232 pvnlist
[vn_last
] = HeapAlloc(heap
, HEAP_ZERO_MEMORY
, sizeof(VIRTNODE
));
233 lpvn
= pvnlist
[vn_last
];
236 lpvn
->cbSize
= sizeof(VIRTNODE
);
239 memcpy(&lpvn
->vfsSrc
, vfsSrc
, sizeof(VCPFILESPEC
));
242 memcpy(&lpvn
->vfsDst
, vfsDst
, sizeof(VCPFILESPEC
));
245 lpvn
->lParam
= lParam
;
246 lpvn
->lpExpandVtbl
= lpExpandVtbl
;
248 lpvn
->vhstrDstFinalName
= 0xffff; /* FIXME: what is this ? */
250 cbres
= VCP_Callback(lpvn
, VCPM_NODECREATE
, 0, 0, VCP_MsgRef
);
251 lpvn
->fl
|= VFNL_CREATED
;
252 cbres
= VCP_Callback(lpvn
, VCPM_NODEACCEPT
, 0, 0, VCP_MsgRef
);
258 static BOOL
VCP_VirtnodeDelete(LPVIRTNODE lpvnDel
)
263 for (n
= 0; n
< vn_last
; n
++)
265 if (pvnlist
[n
] == lpvnDel
)
267 cbres
= VCP_Callback(lpvnDel
, VCPM_NODEDESTROY
, 0, 0, VCP_MsgRef
);
268 HeapFree(GetProcessHeap(), 0, lpvnDel
);
277 /***********************************************************************
278 * VcpOpen (SETUPX.200)
280 * Sets up a virtual copy operation.
281 * This means that functions such as GenInstall()
282 * create a VIRTNODE struct for every file to be touched in a .INF file
283 * instead of actually touching the file.
284 * The actual copy/move/rename gets started when VcpClose or
285 * VcpFlush is called; several different callbacks are made
286 * (copy, rename, open, close, version conflicts, ...) on every file copied.
288 RETERR16 WINAPI
VcpOpen16(VIFPROC vifproc
, LPARAM lparamMsgRef
)
290 TRACE("(%p, %08lx)\n", vifproc
, lparamMsgRef
);
294 VCP_Proc
= (FARPROC16
)vifproc
;
295 VCP_MsgRef
= lparamMsgRef
;
297 /* load SETUPAPI needed for dialog resources etc. */
298 SETUPAPI_hInstance
= GetModuleHandleA("setupapi.dll");
299 if (!SETUPAPI_hInstance
)
301 ERR("Could not load sibling setupapi.dll\n");
302 return ERR_VCP_NOMEM
;
308 /***********************************************************************
309 * VcpQueueCopy [SETUPX.13]
311 * lpExpandVtbl seems to be deprecated.
312 * fl are the CNFL_xxx and VNFL_xxx flags.
313 * lParam are the VNLP_xxx flags.
315 RETERR16 WINAPI
VcpQueueCopy16(
316 LPCSTR lpszSrcFileName
, LPCSTR lpszDstFileName
,
317 LPCSTR lpszSrcDir
, LPCSTR lpszDstDir
,
318 LOGDISKID16 ldidSrc
, LOGDISKID16 ldidDst
,
319 LPEXPANDVTBL lpExpandVtbl
,
320 WORD fl
, LPARAM lParam
323 VCPFILESPEC vfsSrc
, vfsDst
;
326 return ERR_VCP_NOTOPEN
;
328 TRACE("srcdir: %s, srcfile: %s, dstdir: %s, dstfile: %s\n",
329 lpszSrcDir
, lpszSrcFileName
, lpszDstDir
, lpszDstFileName
);
331 TRACE("ldidSrc == %d, ldidDst == %d\n", ldidSrc
, ldidDst
);
333 vfsSrc
.ldid
= ldidSrc
;
334 vfsSrc
.vhstrDir
= vsmStringAdd16(lpszSrcDir
);
335 vfsSrc
.vhstrFileName
= vsmStringAdd16(lpszSrcFileName
);
337 vfsDst
.ldid
= ldidDst
;
338 vfsDst
.vhstrDir
= vsmStringAdd16(lpszDstDir
);
339 vfsDst
.vhstrFileName
= vsmStringAdd16(lpszDstFileName
);
341 return VCP_VirtnodeCreate(&vfsSrc
, &vfsDst
, fl
, lParam
,
345 /***********************************************************************
346 * VcpQueueDelete [SETUPX.17]
348 * Is lParamRef the same as lParam in VcpQueueCopy ?
349 * Damn docu !! Err... which docu ?
351 RETERR16 WINAPI
VcpQueueDelete16(
352 LPCSTR lpszDstFileName
,
361 return ERR_VCP_NOTOPEN
;
363 vfsDst
.ldid
= ldidDst
;
364 vfsDst
.vhstrDir
= vsmStringAdd16(lpszDstDir
);
365 vfsDst
.vhstrFileName
= vsmStringAdd16(lpszDstFileName
);
367 return VCP_VirtnodeCreate(NULL
, &vfsDst
, VNFL_DELETE
, lParamRef
, 0);
370 /***********************************************************************
371 * VcpQueueRename [SETUPX.204]
374 RETERR16 WINAPI
VcpQueueRename16(
375 LPCSTR lpszSrcFileName
, LPCSTR lpszDstFileName
,
376 LPCSTR lpszSrcDir
, LPCSTR lpszDstDir
,
377 LOGDISKID16 ldidSrc
, LOGDISKID16 ldidDst
,
381 VCPFILESPEC vfsSrc
, vfsDst
;
384 return ERR_VCP_NOTOPEN
;
386 vfsSrc
.ldid
= ldidSrc
;
387 vfsSrc
.vhstrDir
= vsmStringAdd16(lpszSrcDir
);
388 vfsSrc
.vhstrFileName
= vsmStringAdd16(lpszSrcFileName
);
390 vfsDst
.ldid
= ldidDst
;
391 vfsDst
.vhstrDir
= vsmStringAdd16(lpszDstDir
);
392 vfsDst
.vhstrFileName
= vsmStringAdd16(lpszDstFileName
);
394 return VCP_VirtnodeCreate(&vfsSrc
, &vfsDst
, VNFL_RENAME
, lParam
,
398 /***********************************************************************
399 * VcpEnumFiles (SETUPX.@)
401 INT16 WINAPI
VcpEnumFiles(VCPENUMPROC vep
, LPARAM lParamRef
)
405 for (n
= 0; n
< vn_last
; n
++)
406 vep(pvnlist
[n
], lParamRef
);
408 return 0; /* FIXME: return value ? */
411 /***********************************************************************
412 * VcpExplain (SETUPX.411)
414 LPCSTR WINAPI
VcpExplain16(LPVIRTNODE lpVn
, DWORD dwWhat
)
416 static char buffer
[MAX_PATH
]; /* FIXME: is this how it's done ? */
423 LPVCPFILESPEC lpvfs
=
424 (dwWhat
== VCPEX_SRC_FULL
) ? &lpVn
->vfsSrc
: &lpVn
->vfsDst
;
426 /* if we have an ldid, use it, otherwise use the string */
427 /* from the vhstrlist array */
428 if (lpvfs
->ldid
!= 0xffff)
429 CtlGetLddPath16(lpvfs
->ldid
, buffer
);
431 strcat(buffer
, vsmGetStringRawName16(lpvfs
->vhstrDir
));
433 strcat(buffer
, "\\");
434 strcat(buffer
, vsmGetStringRawName16(lpvfs
->vhstrFileName
));
438 FIXME("%ld unimplemented !\n", dwWhat
);
439 strcpy(buffer
, "Unknown error");
445 static RETERR16
VCP_CheckPaths(void)
451 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATPATHCHECKSTART
, 0, 0, VCP_MsgRef
);
452 for (n
= 0; n
< vn_num
; n
++)
456 /* FIXME: check paths of all VIRTNODEs here ! */
457 cbres
= VCP_Callback(&lpvn
->vfsDst
, VCPM_CHECKPATH
, 0, (DWORD
)lpvn
, VCP_MsgRef
);
459 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATPATHCHECKEND
, 0, 0, VCP_MsgRef
);
463 static RETERR16
VCP_CopyFiles(void)
465 char fn_src
[MAX_PATH
], fn_dst
[MAX_PATH
];
466 RETERR16 res
= OK
, cbres
;
470 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATCOPYSTART
, 0, 0, VCP_MsgRef
);
471 for (n
= 0; n
< vn_num
; n
++)
474 if ((!lpvn
) || ((lpvn
->fl
& VNFL_NODE_TYPE
) != VNFL_COPY
)) continue;
475 /* FIXME: need to send VCPM_VSTATNEWDISK notification sometimes */
476 strcpy(fn_src
, VcpExplain16(lpvn
, VCPEX_SRC_FULL
));
477 strcpy(fn_dst
, VcpExplain16(lpvn
, VCPEX_DST_FULL
));
478 /* FIXME: what is this VCPM_VSTATWRITE here for ?
479 * I guess it's to signal successful destination file creation */
480 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATWRITE
, 0, 0, VCP_MsgRef
);
482 /* FIXME: need to do the file copy in small chunks for notifications */
483 TRACE("copying '%s' to '%s'\n", fn_src
, fn_dst
);
484 /* perform the file copy */
485 if (!(CopyFileA(fn_src
, fn_dst
,
486 (lpvn
->fl
& VNLP_COPYIFEXISTS
) ? FALSE
: TRUE
)))
488 ERR("error copying, src: %s -> dst: %s\n", fn_src
, fn_dst
);
489 res
= ERR_VCP_IOFAIL
;
492 vcp_status
.prgFileRead
.dwSoFar
++;
493 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATREAD
, 0, 0, VCP_MsgRef
);
494 vcp_status
.prgFileWrite
.dwSoFar
++;
495 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATWRITE
, 0, 0, VCP_MsgRef
);
498 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATCOPYEND
, 0, 0, VCP_MsgRef
);
502 /***********************************************************************
503 * VcpFlush - internal (not exported), but documented
505 * VNFL_NOW is used for VcpFlush.
507 RETERR16
VcpFlush16(WORD fl
, LPCSTR lpszBackupDest
)
512 /***********************************************************************
513 * VcpClose (SETUPX.201)
515 * Does callbacks (-> vifproc) with VCPM_VSTATCLOSESTART,
516 * VCPM_VSTATCLOSEEND.
518 * fl gets VCPFL_xxx flags to indicate what to do with the
519 * VIRTNODEs (files to mess with) created by e.g. GenInstall()
521 RETERR16 WINAPI
VcpClose16(WORD fl
, LPCSTR lpszBackupDest
)
524 WORD cbres
= VCPN_PROCEED
;
526 TRACE("(%04x, '%s')\n", fl
, lpszBackupDest
);
528 /* FIXME: needs to sort virtnodes in case VCPFL_INSPECIFIEDORDER
529 * is not set. This is done by VCP_Callback(VCPM_NODECOMPARE) */
532 memset(&vcp_status
, 0, sizeof(VCPSTATUS
));
533 /* yes, vcp_status.cbSize is 0 ! */
535 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATCLOSESTART
, 0, 0, VCP_MsgRef
);
538 res
= VCP_CheckPaths();
541 return res
; /* is this ok ? */
545 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATCLOSEEND
, 0, 0, VCP_MsgRef
);
553 static RETERR16
VCP_RenameFiles(void)
555 char fn_src
[MAX_PATH
], fn_dst
[MAX_PATH
];
556 RETERR16 res
= OK
, cbres
;
560 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATRENAMESTART
, 0, 0, VCP_MsgRef
);
561 for (n
= 0; n
< vn_num
; n
++)
564 if ((!lpvn
) || ((lpvn
->fl
& VNFL_NODE_TYPE
) != VNFL_RENAME
)) continue;
565 strcpy(fn_src
, VcpExplain16(lpvn
, VCPEX_SRC_FULL
));
566 strcpy(fn_dst
, VcpExplain16(lpvn
, VCPEX_DST_FULL
));
567 cbres
= VCP_Callback(&lpvn
->vfsDst
, VCPM_FILEOPENOUT
, 0, (LPARAM
)lpvn
, VCP_MsgRef
);
568 if (!(MoveFileExA(fn_src
, fn_dst
, MOVEFILE_REPLACE_EXISTING
)))
569 res
= ERR_VCP_IOFAIL
;
571 VCP_VirtnodeDelete(lpvn
);
573 cbres
= VCP_Callback(&vcp_status
, VCPM_VSTATRENAMEEND
, 0, 0, VCP_MsgRef
);
578 /***********************************************************************
579 * vcpDefCallbackProc (SETUPX.202)
581 RETERR16 WINAPI
vcpDefCallbackProc16(LPVOID lpvObj
, UINT16 uMsg
, WPARAM wParam
,
582 LPARAM lParam
, LPARAM lParamRef
)
584 static int count
= 0;
586 FIXME("(%p, %04x, %04x, %08lx, %08lx) - what to do here ?\n",
587 lpvObj
, uMsg
, wParam
, lParam
, lParamRef
);
592 /********************* point-and-click stuff from here ***********************/
594 static HWND hDlgCopy
= 0;
595 static HKEY hKeyFiles
= 0, hKeyRename
= 0, hKeyConflict
= 0;
596 static char BackupDir
[12];
598 static INT_PTR CALLBACK
VCP_UI_FileCopyDlgProc(HWND hWndDlg
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
)
600 INT_PTR retval
= FALSE
;
602 if (iMsg
== WM_INITDIALOG
)
604 ShowWindow(hWndDlg
, SW_SHOWNORMAL
);
605 UpdateWindow(hWndDlg
);
611 static BOOL
VCP_UI_GetDialogTemplate(LPCVOID
*template32
)
616 if (!(hResInfo
= FindResourceA(SETUPAPI_hInstance
, MAKEINTRESOURCEA(COPYFILEDLGORD
), (LPSTR
)RT_DIALOG
)))
618 if (!(hDlgTmpl32
= LoadResource(SETUPAPI_hInstance
, hResInfo
)) ||
619 !(*template32
= LockResource( hDlgTmpl32
)))
624 static LRESULT WINAPI
625 VCP_UI_FileCopyWndProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
627 if (uMsg
!= WM_CREATE
)
628 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
635 FIXME("%04x: unhandled.\n", uMsg
);
641 static void VCP_UI_RegisterProgressClass(void)
643 static BOOL registered
= FALSE
;
650 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
651 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
;
652 wndClass
.lpfnWndProc
= VCP_UI_FileCopyWndProc
;
653 wndClass
.cbClsExtra
= 0;
654 wndClass
.cbWndExtra
= 0;
655 wndClass
.hCursor
= LoadCursorA (0, (LPSTR
)IDC_ARROW
);
656 wndClass
.hbrBackground
= NULL
;
657 wndClass
.lpszClassName
= "setupx_progress";
659 RegisterClassA (&wndClass
);
662 static RETERR16
VCP_UI_NodeCompare(LPVIRTNODE vn1
, LPVIRTNODE vn2
)
665 file1
= vsmGetStringRawName16(vn1
->vfsSrc
.vhstrFileName
);
666 file2
= vsmGetStringRawName16(vn2
->vfsSrc
.vhstrFileName
);
667 return (RETERR16
)strcmp(file1
, file2
);
670 static RETERR16
VCP_UI_CopyStart(void)
673 char buf
[256]; /* plenty */
677 /* FIXME: should be registered at DLL startup instead */
678 VCP_UI_RegisterProgressClass();
679 if (!(VCP_UI_GetDialogTemplate(&template32
)))
682 if (vn_num
> 10) /* hack */
684 hDlgCopy
= CreateDialogIndirectParamA(SETUPAPI_hInstance
, template32
, 0,
685 VCP_UI_FileCopyDlgProc
, 0);
688 SetDlgItemTextA(hDlgCopy
, SOURCESTRORD
, "Scanning ...");
689 SetDlgItemTextA(hDlgCopy
, DESTSTRORD
, "NOT_IMPLEMENTED_YET");
691 strcpy(buf
, REG_INSTALLEDFILES
);
692 if (RegCreateKeyA(HKEY_LOCAL_MACHINE
, buf
, &hKeyFiles
))
694 strcat(buf
, REGPART_RENAME
);
695 if (RegCreateKeyA(HKEY_LOCAL_MACHINE
, buf
, &hKeyRename
))
697 if (RegCreateKeyA(HKEY_LOCAL_MACHINE
, REG_VERSIONCONFLICT
, &hKeyConflict
))
700 if (!(RegQueryValueExA(hKeyConflict
, "Dirty", NULL
, 0, (LPBYTE
)&dirty
, &len
)))
702 /* FIXME: what does SETUPX.DLL do in this case ? */
703 MESSAGE("Warning: another program using SETUPX is already running ! Failed.\n");
707 if (RegSetValueExA(hKeyConflict
, "Dirty", 0, REG_BINARY
, (LPBYTE
)&dirty
, 1))
710 if (!(RegQueryValueExA(hKeyConflict
, "BackupDirectory", NULL
, 0, (LPBYTE
)BackupDir
, &len
)))
711 strcpy(BackupDir
, "VCM");
713 /* create C:\WINDOWS\[BackupDir] and set registry key to it */
714 GetWindowsDirectoryA(buf
, 256);
716 strcat(buf
, BackupDir
);
717 if (!(CreateDirectoryA(buf
, NULL
)))
719 if (RegSetValueExA(hKeyConflict
, "BackupDirectory", 0, REG_SZ
, (LPBYTE
)buf
, strlen(buf
)+1))
721 RegCloseKey(hKeyConflict
);
726 /***********************************************************************
727 * vcpUICallbackProc (SETUPX.213)
729 RETERR16 WINAPI
vcpUICallbackProc16(LPVOID lpvObj
, UINT16 uMsg
, WPARAM wParam
,
730 LPARAM lParam
, LPARAM lParamRef
)
732 static int count
= 0;
733 RETERR16 res
= VCPN_OK
, cbres
;
736 FIXME("(%p, %04x, %04x, %08lx, %08lx) - semi-stub\n",
737 lpvObj
, uMsg
, wParam
, lParam
, lParamRef
);
741 /* unused messages, it seems */
742 case VCPM_DISKPREPINFO
:
744 case VCPM_FILENEEDED
:
746 case VCPM_NODECREATE
:
747 case VCPM_NODEACCEPT
:
749 case VCPM_VSTATCLOSESTART
:
750 case VCPM_VSTATPATHCHECKSTART
:
751 case VCPM_VSTATPATHCHECKEND
:
757 case VCPM_NODECOMPARE
:
758 res
= VCP_UI_NodeCompare((LPVIRTNODE
)lpvObj
, (LPVIRTNODE
)lParam
);
762 case VCPM_VSTATWRITE
:
763 cbres
= VCP_Callback(&vcp_status
, VCPM_DISKPREPINFO
, 0, 0, VCP_MsgRef
);
765 case VCPM_VSTATCLOSEEND
:
766 RegCloseKey(hKeyFiles
);
767 RegCloseKey(hKeyRename
);
768 RegDeleteKeyA(HKEY_LOCAL_MACHINE
, REG_VERSIONCONFLICT
);
770 case VCPM_VSTATCOPYSTART
:
771 res
= VCP_UI_CopyStart();
773 case VCPM_VSTATCOPYEND
:
774 if (hDlgCopy
) DestroyWindow(hDlgCopy
);
777 FIXME("unhandled msg 0x%04x\n", uMsg
);