diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d4f347b --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: Microsoft diff --git a/BrainLILO.cpp b/BrainLILO.cpp index b8dd098..2f976f0 100644 --- a/BrainLILO.cpp +++ b/BrainLILO.cpp @@ -1,32 +1,32 @@ /* * BrainLILO * U-Boot loader for electric dictionary. - * + * * Copyright (C) 2019 C. Shirasaka * based on ** ResetKitHelper ** Soft/hard reset the electronic dictionary. - ** + ** ** Copyright (C) 2012 T. Kawada * * This file is licensed in MIT license. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the "Software"), + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in + * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ @@ -36,188 +36,198 @@ #include "BrainLILODrv.h" #include -static bool g_initialized=false; -static HANDLE g_helperHandle=NULL; +static bool g_initialized = false; +static HANDLE g_helperHandle = NULL; static HINSTANCE g_hInstance; -static void initialize(){ - if(g_initialized) +static void initialize() +{ + if (g_initialized) return; - - g_initialized=true; + + g_initialized = true; } -static void getThisDllDirectoryPath(LPWSTR buffer){ - // retrive the path of the application. - GetModuleFileName(g_hInstance, buffer, 512); - - const size_t notFound=(size_t)-1; - size_t i=0; - size_t j=notFound; - - while(buffer[i]){ - if(buffer[i]==L'/' || buffer[i]==L'\\'){ - j=i; +static void getThisDllDirectoryPath(LPWSTR buffer) +{ + // retrive the path of the application. + GetModuleFileName(g_hInstance, buffer, 512); + + const size_t notFound = (size_t)-1; + size_t i = 0; + size_t j = notFound; + + while (buffer[i]) + { + if (buffer[i] == L'/' || buffer[i] == L'\\') + { + j = i; } i++; } - - if(j==notFound) + + if (j == notFound) return; - - buffer[j]=0; - + + buffer[j] = 0; } -static bool isDriverLoaded(){ +static bool isDriverLoaded() +{ HANDLE handle; - handle=CreateFile(L"LIN0:", GENERIC_READ|GENERIC_WRITE|FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL); - if(handle==INVALID_HANDLE_VALUE) - handle=NULL; - if(handle){ + handle = + CreateFile(L"LIN0:", GENERIC_READ | GENERIC_WRITE | FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL); + if (handle == INVALID_HANDLE_VALUE) + handle = NULL; + if (handle) + { CloseHandle(handle); return true; } return false; } -static bool addDriverToRegistry(){ - HKEY hKey; - DWORD dw; - RegCreateKeyEx(HKEY_LOCAL_MACHINE, (L"Drivers\\BuiltIn\\LILODrv"), 0, NULL, REG_OPTION_NON_VOLATILE, 0, NULL, &hKey, &dw); +static bool addDriverToRegistry() +{ + HKEY hKey; + DWORD dw; + RegCreateKeyEx(HKEY_LOCAL_MACHINE, (L"Drivers\\BuiltIn\\LILODrv"), 0, NULL, REG_OPTION_NON_VOLATILE, 0, NULL, &hKey, + &dw); - - dw = 0x0000; - if(RegSetValueEx(hKey, (L"Index"), 0, REG_DWORD, (BYTE*)&dw, sizeof(DWORD)) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return false; - } - - dw = 0x0100; - if(RegSetValueEx(hKey, (L"Order"), 0, REG_DWORD, (BYTE*)&dw, sizeof(DWORD)) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return false; - } - - if(RegSetValueEx(hKey, (L"Dll"), 0, REG_SZ, (BYTE*)(L"\\Windows\\BrainLILODrv.dll"), sizeof(TCHAR) * ((DWORD)wcslen((L"\\Windows\\BrainLILODrv.dll")) + 1)) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return false; - } - - if(RegSetValueEx(hKey, (L"Prefix"), 0, REG_SZ, (BYTE*)(L"LIN"), sizeof(TCHAR) * ((DWORD)wcslen((L"LIN")) + 1)) != ERROR_SUCCESS) - { - RegCloseKey(hKey); - return false; - } - - return true; + dw = 0x0000; + if (RegSetValueEx(hKey, (L"Index"), 0, REG_DWORD, (BYTE *)&dw, sizeof(DWORD)) != ERROR_SUCCESS) + { + RegCloseKey(hKey); + return false; + } + + dw = 0x0100; + if (RegSetValueEx(hKey, (L"Order"), 0, REG_DWORD, (BYTE *)&dw, sizeof(DWORD)) != ERROR_SUCCESS) + { + RegCloseKey(hKey); + return false; + } + + if (RegSetValueEx(hKey, (L"Dll"), 0, REG_SZ, (BYTE *)(L"\\Windows\\BrainLILODrv.dll"), + sizeof(TCHAR) * ((DWORD)wcslen((L"\\Windows\\BrainLILODrv.dll")) + 1)) != ERROR_SUCCESS) + { + RegCloseKey(hKey); + return false; + } + + if (RegSetValueEx(hKey, (L"Prefix"), 0, REG_SZ, (BYTE *)(L"LIN"), sizeof(TCHAR) * ((DWORD)wcslen((L"LIN")) + 1)) != + ERROR_SUCCESS) + { + RegCloseKey(hKey); + return false; + } + + return true; } -static void loadDriverIfNeeded(){ - if(isDriverLoaded()) +static void loadDriverIfNeeded() +{ + if (isDriverLoaded()) return; - - OutputDebugString(L"BrainLILO: installing LILODriver..."); - - DWORD err; - HANDLE driver=NULL; - + + OutputDebugString(L"BrainLILO: installing LILODriver..."); + + DWORD err; + HANDLE driver = NULL; + wchar_t driverPath[1024]; - - getThisDllDirectoryPath(driverPath); - - TCHAR newDriverPath[128]; - + + getThisDllDirectoryPath(driverPath); + + TCHAR newDriverPath[128]; + getThisDllDirectoryPath(driverPath); wcscat(driverPath, L"\\BrainLILODrv.dll"); - wcscpy(newDriverPath,L"\\Windows\\BrainLILODrv.dll"); - + wcscpy(newDriverPath, L"\\Windows\\BrainLILODrv.dll"); + { wchar_t buf[1024]; - swprintf(buf, L"BrainLILO: copying \"%ls\" to \"%ls\"", - driverPath, newDriverPath); + swprintf(buf, L"BrainLILO: copying \"%ls\" to \"%ls\"", driverPath, newDriverPath); OutputDebugString(buf); } - - if(!CopyFile(driverPath,newDriverPath, FALSE)){ - - - if(GetFileAttributes(newDriverPath)==(DWORD)-1){ - OutputDebugString(L"BrainLILO: failed to copy"); - return; - } - - } - - OutputDebugString(L"BrainLILO: registering BrainLILODriver..."); - - try{ - driver=RegisterDevice(L"LIN", 0, L"\\Windows\\BrainLILODrv.dll", 0); - - if(driver==INVALID_HANDLE_VALUE) - driver=NULL; - - if(!driver){ - - driver=RegisterDevice(L"LIN", 0, L"BrainLILODrv.dll", 0); - - if(driver==INVALID_HANDLE_VALUE) - driver=NULL; - - } - - err=GetLastError(); - }catch(DWORD e){ - err=e; - } - if(!driver && (err!=0x964)){ - OutputDebugString(L"BrainLILO: failed to install..."); - return; - } - -} -static void openDriver(){ - if(g_helperHandle) + if (!CopyFile(driverPath, newDriverPath, FALSE)) + { + + if (GetFileAttributes(newDriverPath) == (DWORD)-1) + { + OutputDebugString(L"BrainLILO: failed to copy"); + return; + } + } + + OutputDebugString(L"BrainLILO: registering BrainLILODriver..."); + + try + { + driver = RegisterDevice(L"LIN", 0, L"\\Windows\\BrainLILODrv.dll", 0); + + if (driver == INVALID_HANDLE_VALUE) + driver = NULL; + + if (!driver) + { + + driver = RegisterDevice(L"LIN", 0, L"BrainLILODrv.dll", 0); + + if (driver == INVALID_HANDLE_VALUE) + driver = NULL; + } + + err = GetLastError(); + } + catch (DWORD e) + { + err = e; + } + if (!driver && (err != 0x964)) + { + OutputDebugString(L"BrainLILO: failed to install..."); return; - g_helperHandle=CreateFile(L"LIN0:", GENERIC_READ|GENERIC_WRITE|FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL); - if(g_helperHandle==INVALID_HANDLE_VALUE) - g_helperHandle=NULL; + } } -extern "C" BOOL APIENTRY DllMain(HINSTANCE hInstance, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) +static void openDriver() +{ + if (g_helperHandle) + return; + g_helperHandle = + CreateFile(L"LIN0:", GENERIC_READ | GENERIC_WRITE | FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL); + if (g_helperHandle == INVALID_HANDLE_VALUE) + g_helperHandle = NULL; +} + +extern "C" BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - - g_hInstance=hInstance; - - initialize(); - loadDriverIfNeeded(); - openDriver(); - - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + + g_hInstance = hInstance; + + initialize(); + loadDriverIfNeeded(); + openDriver(); + + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; } return TRUE; } -BRAINLILO_API BOOL RKDoSoftReset(){ - - initialize(); +BRAINLILO_API BOOL RKDoSoftReset() +{ + + initialize(); loadDriverIfNeeded(); openDriver(); - - return DeviceIoControl(g_helperHandle, IOCTL_LIN_DO_LINUX, - NULL, 0, NULL, 0, - NULL, NULL); + + return DeviceIoControl(g_helperHandle, IOCTL_LIN_DO_LINUX, NULL, 0, NULL, 0, NULL, NULL); } \ No newline at end of file diff --git a/BrainLILO.h b/BrainLILO.h index c6e3475..bc47120 100644 --- a/BrainLILO.h +++ b/BrainLILO.h @@ -9,11 +9,11 @@ #endif #ifdef __cplusplus -extern "C"{ +extern "C" +{ #endif - + BRAINLILO_API BOOL RKDoSoftReset(); - #ifdef __cplusplus }; diff --git a/BrainLILODrv.cpp b/BrainLILODrv.cpp index 30e9a83..9c6fb82 100644 --- a/BrainLILODrv.cpp +++ b/BrainLILODrv.cpp @@ -1,63 +1,56 @@ /* * BrainLILODrv * U-Boot loader for electric dictionary. - * + * * Copyright (C) 2019 C. Shirasaka * based on ** ResetKitHelper ** Soft/hard reset the electronic dictionary. - ** + ** ** Copyright (C) 2012 T. Kawada * * This file is licensed in MIT license. * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the "Software"), + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in + * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ -#include #include +#include -#define FSNOTIFY_POWER_OFF 1 -#define FSNOTIFY_POWER_ON 0 - +#define FSNOTIFY_POWER_OFF 1 +#define FSNOTIFY_POWER_ON 0 #define BRAINLILODRV_API __declspec(dllexport) #include "BrainLILODrv.h" -#define FILE_DEVICE_POWER FILE_DEVICE_ACPI +#define FILE_DEVICE_POWER FILE_DEVICE_ACPI -#define IOCTL_POWER_CAPABILITIES \ -CTL_CODE(FILE_DEVICE_POWER, 0x400, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_POWER_GET \ -CTL_CODE(FILE_DEVICE_POWER, 0x401, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_POWER_SET \ -CTL_CODE(FILE_DEVICE_POWER, 0x402, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_POWER_QUERY \ -CTL_CODE(FILE_DEVICE_POWER, 0x403, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_POWER_CAPABILITIES CTL_CODE(FILE_DEVICE_POWER, 0x400, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_POWER_GET CTL_CODE(FILE_DEVICE_POWER, 0x401, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_POWER_SET CTL_CODE(FILE_DEVICE_POWER, 0x402, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_POWER_QUERY CTL_CODE(FILE_DEVICE_POWER, 0x403, METHOD_BUFFERED, FILE_ANY_ACCESS) - -typedef BOOL (*KernelIoControlProc)(DWORD dwIoControlCode, LPVOID lpInBuf, - DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize,LPDWORD lpBytesReturned); +typedef BOOL (*KernelIoControlProc)(DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, + DWORD nOutBufSize, LPDWORD lpBytesReturned); static KernelIoControlProc KernelIoControl; - typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; typedef PVOID (*MmMapIoSpaceProc)(PHYSICAL_ADDRESS, ULONG, BOOL); @@ -66,238 +59,238 @@ static MmMapIoSpaceProc MmMapIoSpace; typedef void (*FileSystemPowerFunctionProc)(DWORD); static FileSystemPowerFunctionProc FileSystemPowerFunction; -typedef LPVOID (*AllocPhysMemProc)(DWORD,DWORD,DWORD,DWORD,PULONG); +typedef LPVOID (*AllocPhysMemProc)(DWORD, DWORD, DWORD, DWORD, PULONG); DWORD FileSize; -static void disableInterrupts(){ - asm volatile("mrs r0, cpsr\n" - "orr r0,r0,#0x80\n" - "msr cpsr_c,r0\n" - "mov r0,#1":::"r0"); -} - -static void EDNA2_physicalInvoker(){ - // r0-r7=params - // r8=proc address - asm volatile("nop\n" // who cares interrupt vectors? - "nop\n" - "nop\n" - "nop\n" - "nop\n" - "nop\n" - "nop\n" - "nop\n" - "nop\n" - "nop\n" - "msr cpsr_c, #211\n" // to supervisor mode - "mov r9, #0\n" - "mcr p15,0,r9,c13,c0,0\n" // clear fcse PID - "mrc p15,0,r9,c1,c0,0\n" // read ctrl regs - "bic r9, r9, #5\n" // disable MMU/DCache - "bic r9, r9, #4096\n" // disable ICache - "orr r9, r9, #8192\n" // and reset vectors to upper - "mcr p15,0,r9,c1,c0,0\n" // write ctrl regs - "mov r9, #0\n" - "mcr p15,0,r9,c7,c7,0\n" // invalidate cache - "mcr p15,0,r9,c8,c7,0\n" // invalidate tlb - "mov pc, r8\n" - "nop\n" - "nop\n" - ); -} - - -static void EDNA2_installPhysicalInvoker(){ - void *ptr=(void *)0xa8000000; - wchar_t buf[256]; - swprintf(buf, L"BrainLILO: copying PhysicalInvoker to 0x%08x from 0x%08x\n", - (int)(ptr), (int)(&EDNA2_physicalInvoker)); - OutputDebugString(buf); - memcpy(ptr, (const void *)&EDNA2_physicalInvoker, 64*4); - //clearCache(); -} - - -__attribute__((noreturn)) -static void EDNA2_runPhysicalInvoker(){ - // r0=info - asm volatile("msr cpsr_c, #211\n" // to supervisor mode - "mrc p15,0,r0,c1,c0,0\n" // read ctrl regs - "bic r0, r0, #8192\n" // reset vector to lower - "mcr p15,0,r0,c1,c0,0\n" // write ctrl regs - ); - - for(DWORD i=0;i -#define _LIN_ACCESS_CTL_CODE(_Function) \ -CTL_CODE(FILE_DEVICE_UNKNOWN, _Function, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define _LIN_ACCESS_CTL_CODE(_Function) CTL_CODE(FILE_DEVICE_UNKNOWN, _Function, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_LIN_DO_LINUX _LIN_ACCESS_CTL_CODE(0x804) diff --git a/bootloader.cpp b/bootloader.cpp index 5614530..f80269f 100644 --- a/bootloader.cpp +++ b/bootloader.cpp @@ -1,80 +1,80 @@ // This file is in public domain. -#include -#include #include #include +#include +#include #define MainWindowClassName L"SelectorMainWindowClass" -#define DataTypeAlertError 0x1000 -#define DataTypeAlertInformation 0x1001 -#define DataTypeAlertWarning 0x1002 +#define DataTypeAlertError 0x1000 +#define DataTypeAlertInformation 0x1001 +#define DataTypeAlertWarning 0x1002 -static void showAlertWarning(LPCWSTR message, - LPCWSTR title){ - - HWND selectorMainWindow=FindWindow(MainWindowClassName, NULL); - - if(!selectorMainWindow){ - MessageBox(NULL, message, title, - MB_ICONWARNING); +static void showAlertWarning(LPCWSTR message, LPCWSTR title) +{ + + HWND selectorMainWindow = FindWindow(MainWindowClassName, NULL); + + if (!selectorMainWindow) + { + MessageBox(NULL, message, title, MB_ICONWARNING); return; - } - + wchar_t data[2048]; wcscpy(data, message); - data[wcslen(message)]=0; - wcscpy(data+wcslen(message)+1, title); - - size_t dataLen=wcslen(message)+wcslen(title)+1; - + data[wcslen(message)] = 0; + wcscpy(data + wcslen(message) + 1, title); + + size_t dataLen = wcslen(message) + wcslen(title) + 1; + COPYDATASTRUCT info; - info.dwData=DataTypeAlertWarning; - info.cbData=dataLen*sizeof(wchar_t); - - HGLOBAL global=GlobalAlloc(GPTR, info.cbData); + info.dwData = DataTypeAlertWarning; + info.cbData = dataLen * sizeof(wchar_t); + + HGLOBAL global = GlobalAlloc(GPTR, info.cbData); memcpy((LPVOID)global, data, info.cbData); - - info.lpData=(LPVOID)global; - - - - SendMessage(selectorMainWindow, WM_COPYDATA, NULL, - (LPARAM)&info); - + + info.lpData = (LPVOID)global; + + SendMessage(selectorMainWindow, WM_COPYDATA, NULL, (LPARAM)&info); + GlobalFree(global); - } -int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow){ - HINSTANCE lib=LoadLibrary(L"BrainLILO"); - if(!lib){ - wchar_t buf[256]; - swprintf(buf, L"Cannot perform a soft reset.\n" - L"BrainLILO was not loaded (0x%08x).", - GetLastError()); +int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow) +{ + HINSTANCE lib = LoadLibrary(L"BrainLILO"); + if (!lib) + { + wchar_t buf[256]; + swprintf(buf, + L"Cannot perform a soft reset.\n" + L"BrainLILO was not loaded (0x%08x).", + GetLastError()); showAlertWarning(buf, L"Error"); return 1; } - - + typedef BOOL (*RKDoSoftResetProc)(); - RKDoSoftResetProc RKDoSoftReset= - (RKDoSoftResetProc)GetProcAddress(lib, L"RKDoSoftReset"); - if(!RKDoSoftReset){ + RKDoSoftResetProc RKDoSoftReset = (RKDoSoftResetProc)GetProcAddress(lib, L"RKDoSoftReset"); + if (!RKDoSoftReset) + { wchar_t buf[256]; - swprintf(buf, L"Cannot perform a soft reset.\n" + swprintf(buf, + L"Cannot perform a soft reset.\n" L"RKDoSoftReset not found (0x%08x).", GetLastError()); showAlertWarning(buf, L"Error"); return 1; } - - if(!RKDoSoftReset()){ + + if (!RKDoSoftReset()) + { wchar_t buf[256]; - swprintf(buf, L"Cannot perform a soft reset.\n" + swprintf(buf, + L"Cannot perform a soft reset.\n" L"Operation failed (0x%08x).", GetLastError()); showAlertWarning(buf, L"Error"); @@ -82,5 +82,3 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow){ } return 0; } - -