function_name
stringlengths 1
80
| function
stringlengths 14
10.6k
| comment
stringlengths 12
8.02k
| normalized_comment
stringlengths 6
6.55k
|
|---|---|---|---|
CbFindData
|
UINT CbFindData(HWND hWnd, UINT id, UINT data)
{
UINT i, num;
// Validate arguments
if (hWnd == NULL)
{
return INFINITE;
}
num = CbNum(hWnd, id);
if (num == INFINITE)
{
return INFINITE;
}
for (i = 0;i < num;i++)
{
if (CbGetData(hWnd, id, i) == data)
{
return i;
}
}
return INFINITE;
}
|
/* Search for the data*/
|
Search for the data
|
CbSetHeight
|
void CbSetHeight(HWND hWnd, UINT id, UINT value)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
SendMsg(hWnd, id, CB_SETITEMHEIGHT, 0, (UINT)(GetTextScalingFactor() * (double)value));
}
|
/* Set the height of the item*/
|
Set the height of the item
|
CbSelect
|
void CbSelect(HWND hWnd, UINT id, int data)
{
UINT index;
// Validate arguments
if (hWnd == NULL)
{
return;
}
if (data == INFINITE)
{
// Get the first item
CbSelectIndex(hWnd, id, 0);
return;
}
index = CbFindData(hWnd, id, data);
if (index == INFINITE)
{
// Can not be found
return;
}
// Select
CbSelectIndex(hWnd, id, index);
}
|
/* Search by specifying the data*/
|
Search by specifying the data
|
CbGetSelectIndex
|
UINT CbGetSelectIndex(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return INFINITE;
}
return SendMsg(hWnd, id, CB_GETCURSEL, 0, 0);
}
|
/* Get the currently selected item*/
|
Get the currently selected item
|
CbGetSelect
|
UINT CbGetSelect(HWND hWnd, UINT id)
{
UINT index;
// Validate arguments
if (hWnd == NULL)
{
return INFINITE;
}
index = CbGetSelectIndex(hWnd, id);
if (index == INFINITE)
{
return INFINITE;
}
return CbGetData(hWnd, id, index);
}
|
/* Get the value that is currently selected*/
|
Get the value that is currently selected
|
PasswordDlgOnOk
|
void PasswordDlgOnOk(HWND hWnd, UI_PASSWORD_DLG *p)
{
// Validate arguments
if (hWnd == NULL || p == NULL)
{
return;
}
GetTxtA(hWnd, E_USERNAME, p->Username, sizeof(p->Username));
GetTxtA(hWnd, E_PASSWORD, p->Password, sizeof(p->Password));
p->Type = CbGetSelect(hWnd, C_TYPE);
if (p->ShowNoSavePassword)
{
p->NoSavePassword = IsChecked(hWnd, R_NO_SAVE_PASSWORD);
}
EndDialog(hWnd, true);
}
|
/* OK button is pressed*/
|
OK button is pressed
|
PasswordDlg
|
bool PasswordDlg(HWND hWnd, UI_PASSWORD_DLG *p)
{
// Validate arguments
if (p == NULL)
{
return false;
}
p->StartTick = Tick64();
return Dialog(hWnd, D_PASSWORD, PasswordDlgProc, p);
}
|
/* Password input dialog*/
|
Password input dialog
|
MakeFilter
|
wchar_t *MakeFilter(wchar_t *str)
{
UINT i;
wchar_t *ret;
// Validate arguments
if (str == NULL)
{
return NULL;
}
ret = ZeroMalloc(UniStrSize(str) + 32);
for (i = 0;i < UniStrLen(str);i++)
{
if (str[i] == L'|')
{
ret[i] = L'\0';
}
else
{
ret[i] = str[i];
}
}
return ret;
}
|
/* Generate the filter string*/
|
Generate the filter string
|
SecureDeviceBatch
|
void SecureDeviceBatch(HWND hWnd, SECURE *sec, SECURE_DEVICE_THREAD *p, SECURE_DEVICE *dev)
{
UINT i;
// Validate arguments
if (hWnd == NULL || p == NULL || dev == NULL || sec == NULL)
{
return;
}
// Sequential processing
for (i = 0;i < p->w->num_batch;i++)
{
WINUI_SECURE_BATCH *batch = &p->w->batch[i];
if (ExecuteSecureDeviceBatch(hWnd, sec, p, dev, batch) == false)
{
// If fail even one, abort immediately
return;
}
}
// All batch job succeeded
p->Succeed = true;
}
|
/* Run the secure device operations as a batch job*/
|
Run the secure device operations as a batch job
|
StartSecureDevice
|
void StartSecureDevice(HWND hWnd, SECURE_DEVICE_WINDOW *w)
{
SECURE_DEVICE_THREAD *p;
// Validate arguments
if (hWnd == NULL || w == NULL)
{
return;
}
// Disable the control
EnableSecureDeviceWindowControls(hWnd, false);
// Start the thread
p = ZeroMalloc(sizeof(SECURE_DEVICE_THREAD));
p->w = w;
p->hWnd = hWnd;
w->p = p;
p->pin = GetTextA(hWnd, E_PIN);
ReleaseThread(NewThread(SecureDeviceThread, p));
}
|
/* Start a secure device operation*/
|
Start a secure device operation
|
Command
|
void Command(HWND hWnd, UINT id)
{
SendMessage(hWnd, WM_COMMAND, id, 0);
}
|
/* Send a WM_COMMAND*/
|
Send a WM_COMMAND
|
SecureDeviceWindow
|
bool SecureDeviceWindow(HWND hWnd, WINUI_SECURE_BATCH *batch, UINT num_batch, UINT device_id, UINT bitmap_id)
{
SECURE_DEVICE_WINDOW w;
UINT i;
// Validate arguments
if (batch == NULL || num_batch == 0 || device_id == 0)
{
return false;
}
// Initialize the success flag
for (i = 0;i < num_batch;i++)
{
batch[i].Succeed = false;
}
Zero(&w, sizeof(w));
w.batch = batch;
w.device_id = device_id;
w.num_batch = num_batch;
w.BitmapId = bitmap_id;
// Open a dialog
return (bool)Dialog(hWnd, D_SECURE, SecureDeviceWindowProc, &w);
}
|
/* Show the secure device window*/
|
Show the secure device window
|
StopAvi
|
void StopAvi(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
Animate_Stop(DlgItem(hWnd, id));
Hide(hWnd, id);
}
|
/* Stop playing the AVI*/
|
Stop playing the AVI
|
PlayAvi
|
void PlayAvi(HWND hWnd, UINT id, bool repeat)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
Show(hWnd, id);
Animate_Play(DlgItem(hWnd, id), 0, -1, (repeat ? -1 : 0));
}
|
/* Play an AVI*/
|
Play an AVI
|
CloseAvi
|
void CloseAvi(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
StopAvi(hWnd, id);
Animate_Close(DlgItem(hWnd, id));
}
|
/* Close the AVI file*/
|
Close the AVI file
|
OpenAvi
|
void OpenAvi(HWND hWnd, UINT id, UINT avi_id)
{
// Validate arguments
if (hWnd == NULL || avi_id == 0)
{
return;
}
Hide(hWnd, id);
Animate_OpenEx(DlgItem(hWnd, id), hDll, MAKEINTRESOURCE(avi_id));
}
|
/* Open an AVI file*/
|
Open an AVI file
|
DlgFont
|
void DlgFont(HWND hWnd, UINT id, UINT size, UINT bold)
{
DIALOG_PARAM *param = (DIALOG_PARAM *)GetParam(hWnd);
if (param == NULL || param->meiryo == false)
{
SetFont(hWnd, id, Font(size, bold));
}
else
{
SetFont(hWnd, id, GetFont((_GETLANG() == 2 ? "Microsoft YaHei" : GetMeiryoFontName()), size, bold, false, false, false));
}
}
|
/* Set the font to the control*/
|
Set the font to the control
|
Font
|
HFONT Font(UINT size, UINT bold)
{
return GetFont(NULL, size, bold, false, false, false);
}
|
/* Generate a standard font*/
|
Generate a standard font
|
Dialog
|
UINT Dialog(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param)
{
bool white = true;
return DialogEx(hWnd, id, proc, param, white);
}
|
/* Show a dialog box*/
|
Show a dialog box
|
InitIconCache
|
void InitIconCache()
{
if (icon_cache_list != NULL)
{
return;
}
icon_cache_list = NewList(NULL);
}
|
/* Initialize the icon cache*/
|
Initialize the icon cache
|
FreeIconCache
|
void FreeIconCache()
{
UINT i;
if (icon_cache_list == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(icon_cache_list);i++)
{
ICON_CACHE *c = LIST_DATA(icon_cache_list, i);
DestroyIcon(c->hIcon);
Free(c);
}
ReleaseList(icon_cache_list);
icon_cache_list = NULL;
}
|
/* Release the icon cache*/
|
Release the icon cache
|
LoadLargeIcon
|
HICON LoadLargeIcon(UINT id)
{
return LoadIconEx(id, false);
}
|
/* Get a large Icon*/
|
Get a large Icon
|
LoadSmallIcon
|
HICON LoadSmallIcon(UINT id)
{
return LoadIconEx(id, true);
}
|
/* Get a small icon*/
|
Get a small icon
|
LoadLargeIconInner
|
HICON LoadLargeIconInner(UINT id)
{
HICON ret;
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 32, 32, 0);
if (ret == NULL)
{
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 32, 32, LR_VGACOLOR);
if (ret == NULL)
{
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0);
if (ret == NULL)
{
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_VGACOLOR);
if (ret == NULL)
{
ret = LoadIcon(hDll, MAKEINTRESOURCE(id));
}
}
}
}
return ret;
}
|
/* Get a large icon*/
|
Get a large icon
|
LoadSmallIconInner
|
HICON LoadSmallIconInner(UINT id)
{
HICON ret;
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 16, 16, 0);
if (ret == NULL)
{
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 16, 16, LR_VGACOLOR);
if (ret == NULL)
{
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0);
if (ret == NULL)
{
ret = LoadImage(hDll, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_VGACOLOR);
if (ret == NULL)
{
ret = LoadLargeIconInner(id);
}
}
}
}
return ret;
}
|
/* Get a small icon*/
|
Get a small icon
|
IsChecked
|
bool IsChecked(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return false;
}
return IsDlgButtonChecked(hWnd, id) == BST_CHECKED ? true : false;
}
|
/* Check whether the radio button is checked*/
|
Check whether the radio button is checked
|
Check
|
void Check(HWND hWnd, UINT id, bool b)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
if ((!(!IsChecked(hWnd, id))) != (!(!b)))
{
CheckDlgButton(hWnd, id, b ? BST_CHECKED : BST_UNCHECKED);
}
}
|
/* Check the radio button*/
|
Check the radio button
|
LimitText
|
void LimitText(HWND hWnd, UINT id, UINT count)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
SendMsg(hWnd, id, EM_LIMITTEXT, count, 0);
}
|
/* Limit the number of characters that can be entered into the text-box*/
|
Limit the number of characters that can be entered into the text-box
|
GetTextScalingFactor
|
double GetTextScalingFactor()
{
static int cached_dpi = 0;
double ret = 1.0;
if (MsIsVista() == false)
{
// It's always 1.0 in Windows XP or earlier
return 1.0;
}
if (cached_dpi == 0)
{
HDC hDC = CreateCompatibleDC(NULL);
if (hDC != NULL)
{
cached_dpi = GetDeviceCaps(hDC, LOGPIXELSY);
DeleteDC(hDC);
}
}
if (cached_dpi != 0)
{
ret = (double)cached_dpi / 96.0;
if (ret < 0)
{
ret = -ret;
}
}
return ret;
}
|
/* Get the font magnification*/
|
Get the font magnification
|
GetFontParam
|
bool GetFontParam(HFONT hFont, struct FONT *f)
{
bool ret = false;
// Validate arguments
if (hFont == NULL || f == NULL)
{
return false;
}
// Search for the existing font
LockList(font_list);
{
UINT i;
for (i = 0;i < LIST_NUM(font_list);i++)
{
FONT *n = LIST_DATA(font_list, i);
if (n->hFont == hFont)
{
Copy(f, n, sizeof(FONT));
ret = true;
break;
}
}
}
UnlockList(font_list);
return ret;
}
|
/* Get the parameters of the font that was created in the past*/
|
Get the parameters of the font that was created in the past
|
InitFont
|
void InitFont()
{
if (font_list != NULL)
{
return;
}
font_list = NewList(CompareFont);
}
|
/* Initialize the font*/
|
Initialize the font
|
FreeFont
|
void FreeFont()
{
UINT i;
if (font_list == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(font_list);i++)
{
FONT *f = LIST_DATA(font_list, i);
Free(f->Name);
DeleteObject((HGDIOBJ)f->hFont);
Free(f);
}
ReleaseList(font_list);
font_list = NULL;
}
|
/* Release the font*/
|
Release the font
|
EnableClose
|
void EnableClose(HWND hWnd)
{
HMENU h;
// Validate arguments
if (hWnd == NULL)
{
return;
}
h = GetSystemMenu(hWnd, false);
EnableMenuItem(h, SC_CLOSE, MF_ENABLED);
DrawMenuBar(hWnd);
}
|
/* Show a button to close the window*/
|
Show a button to close the window
|
DisableClose
|
void DisableClose(HWND hWnd)
{
HMENU h;
// Validate arguments
if (hWnd == NULL)
{
return;
}
h = GetSystemMenu(hWnd, false);
EnableMenuItem(h, SC_CLOSE, MF_GRAYED);
DrawMenuBar(hWnd);
}
|
/* Hide the button to close the window*/
|
Hide the button to close the window
|
FormatText
|
void FormatText(HWND hWnd, UINT id, ...)
{
va_list args;
wchar_t *buf;
UINT size;
wchar_t *str;
// Validate arguments
if (hWnd == NULL)
{
return;
}
str = GetText(hWnd, id);
if (str == NULL)
{
return;
}
size = MAX(UniStrSize(str) * 10, MAX_SIZE * 10);
buf = MallocEx(size, true);
va_start(args, id);
UniFormatArgs(buf, size, str, args);
SetText(hWnd, id, buf);
Free(buf);
Free(str);
va_end(args);
}
|
/* Format the string in the window*/
|
Format the string in the window
|
MsgBoxEx
|
UINT MsgBoxEx(HWND hWnd, UINT flag, wchar_t *msg, ...)
{
va_list args;
wchar_t *buf;
UINT size;
UINT ret;
// Validate arguments
if (msg == NULL)
{
msg = L"MessageBox";
}
size = MAX(UniStrSize(msg) * 10, MAX_SIZE * 10);
buf = MallocEx(size, true);
va_start(args, msg);
UniFormatArgs(buf, size, msg, args);
ret = MsgBox(hWnd, flag, buf);
Free(buf);
va_end(args);
return ret;
}
|
/* Show the variable-length message box*/
|
Show the variable-length message box
|
MsgBox
|
UINT MsgBox(HWND hWnd, UINT flag, wchar_t *msg)
{
UINT ret;
wchar_t *title;
// Validate arguments
if (msg == NULL)
{
msg = L"MessageBox";
}
if (title_bar != NULL)
{
title = CopyUniStr(title_bar);
}
else
{
title = CopyStrToUni(CEDAR_PRODUCT_STR);
}
if (hWnd)
{
// Raise the message box to top-level if the parent window is the top-level window
if (GetExStyle(hWnd, 0) & WS_EX_TOPMOST)
{
flag |= MB_SYSTEMMODAL;
}
}
ret = MessageBoxW(hWnd, msg, title, flag);
Free(title);
return ret;
}
|
/* Show the message box*/
|
Show the message box
|
DialogInternal
|
UINT DialogInternal(HWND hWnd, UINT id, DIALOG_PROC *proc, void *param)
{
// Validate arguments
if (proc == NULL)
{
return 0;
}
if (MsIsNt() == false)
{
// Win9x
return (UINT)DialogBoxParam(hDll, MAKEINTRESOURCE(id), hWnd, (DLGPROC)proc, (LPARAM)param);
}
else
{
// WinNT
return (UINT)DialogBoxParamW(hDll, MAKEINTRESOURCEW(id), hWnd, (DLGPROC)proc, (LPARAM)param);
}
}
|
/* Create a dialog (internal)*/
|
Create a dialog (internal)
|
SetParam
|
void SetParam(HWND hWnd, void *param)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)param);
}
|
/* Set the parameters of the dialog box*/
|
Set the parameters of the dialog box
|
GetParam
|
void *GetParam(HWND hWnd)
{
void *ret;
// Validate arguments
if (hWnd == NULL)
{
return NULL;
}
ret = (void *)GetWindowLongPtr(hWnd, DWLP_USER);
return ret;
}
|
/* Get the parameters of the dialog box*/
|
Get the parameters of the dialog box
|
Top
|
void Top(HWND hWnd)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
|
/* Show the windows as foreground*/
|
Show the windows as foreground
|
GetTextLen
|
UINT GetTextLen(HWND hWnd, UINT id, bool unicode)
{
wchar_t *s;
UINT ret;
// Validate arguments
if (hWnd == NULL)
{
return 0;
}
s = GetText(hWnd, id);
if (s == NULL)
{
return 0;
}
if (unicode)
{
ret = UniStrLen(s);
}
else
{
char *tmp = CopyUniToStr(s);
ret = StrLen(tmp);
Free(tmp);
}
Free(s);
return ret;
}
|
/* Get the number of characters in the text*/
|
Get the number of characters in the text
|
IsEmpty
|
bool IsEmpty(HWND hWnd, UINT id)
{
bool ret;
wchar_t *s;
// Validate arguments
if (hWnd == NULL)
{
return true;
}
s = GetText(hWnd, id);
UniTrim(s);
if (UniStrLen(s) == 0)
{
ret = true;
}
else
{
ret = false;
}
Free(s);
return ret;
}
|
/* Check whether the text is blank*/
|
Check whether the text is blank
|
GetClass
|
wchar_t *GetClass(HWND hWnd, UINT id)
{
wchar_t tmp[MAX_SIZE];
if (MsIsNt() == false)
{
wchar_t *ret;
char *s;
s = GetClassA(hWnd, id);
ret = CopyStrToUni(s);
Free(s);
return ret;
}
// Validate arguments
if (hWnd == NULL)
{
return CopyUniStr(L"");
}
GetClassNameW(DlgItem(hWnd, id), tmp, sizeof(tmp));
return UniCopyStr(tmp);
}
|
/* Get the window class*/
|
Get the window class
|
SendMsg
|
UINT SendMsg(HWND hWnd, UINT id, UINT msg, WPARAM wParam, LPARAM lParam)
{
// Validate arguments
if (hWnd == NULL)
{
return 0;
}
if (MsIsNt())
{
return (UINT)SendMessageW(DlgItem(hWnd, id), msg, wParam, lParam);
}
else
{
return (UINT)SendMessageA(DlgItem(hWnd, id), msg, wParam, lParam);
}
}
|
/* Transmit a message to the control*/
|
Transmit a message to the control
|
SetCursorOnRight
|
void SetCursorOnRight(HWND hWnd, UINT id)
{
wchar_t *class_name;
// Validate arguments
if (hWnd == NULL)
{
return;
}
class_name = GetClass(hWnd, id);
if (class_name != NULL)
{
if (UniStrCmpi(class_name, L"edit") == 0)
{
wchar_t *str = GetText(hWnd, id);
if (str != NULL)
{
UINT len = UniStrLen(str);
SendMsg(hWnd, id, EM_SETSEL, len, len);
Free(str);
}
}
Free(class_name);
}
}
|
/* Move the cursor to the right edge of the text in the EDIT*/
|
Move the cursor to the right edge of the text in the EDIT
|
SelectEdit
|
void SelectEdit(HWND hWnd, UINT id)
{
wchar_t *class_name;
// Validate arguments
if (hWnd == NULL)
{
return;
}
class_name = GetClass(hWnd, id);
if (class_name != NULL)
{
if (UniStrCmpi(class_name, L"edit") == 0)
{
SendMsg(hWnd, id, EM_SETSEL, 0, -1);
}
Free(class_name);
}
}
|
/* Select entire the text in the EDIT*/
|
Select entire the text in the EDIT
|
UnselectEdit
|
void UnselectEdit(HWND hWnd, UINT id)
{
wchar_t *class_name;
// Validate arguments
if (hWnd == NULL)
{
return;
}
class_name = GetClass(hWnd, id);
if (class_name != NULL)
{
if (UniStrCmpi(class_name, L"edit") == 0)
{
SendMsg(hWnd, id, EM_SETSEL, -1, 0);
}
Free(class_name);
}
}
|
/* Deselect the text of EDIT*/
|
Deselect the text of EDIT
|
FocusEx
|
void FocusEx(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
if (IsEnable(hWnd, id) == false || IsShow(hWnd, id) == false)
{
return;
}
SelectEdit(hWnd, id);
Focus(hWnd, id);
}
|
/* Select all by setting the focus to the EDIT*/
|
Select all by setting the focus to the EDIT
|
IsFocus
|
bool IsFocus(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return false;
}
if (GetFocus() == DlgItem(hWnd, id))
{
return true;
}
return false;
}
|
/* Get whether the specified window has focus*/
|
Get whether the specified window has focus
|
Focus
|
void Focus(HWND hWnd, UINT id)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
if (IsEnable(hWnd, id) == false || IsShow(hWnd, id) == false)
{
return;
}
SetFocus(DlgItem(hWnd, id));
}
|
/* Set the focus*/
|
Set the focus
|
SetInt
|
void SetInt(HWND hWnd, UINT id, UINT value)
{
wchar_t tmp[MAX_SIZE];
// Validate arguments
if (hWnd == NULL)
{
return;
}
UniToStru(tmp, value);
SetText(hWnd, id, tmp);
}
|
/* Set the value of the int type*/
|
Set the value of the int type
|
GetInt
|
UINT GetInt(HWND hWnd, UINT id)
{
wchar_t *s;
UINT ret;
// Validate arguments
if (hWnd == NULL)
{
return 0;
}
s = GetText(hWnd, id);
if (s == NULL)
{
return 0;
}
ret = UniToInt(s);
Free(s);
return ret;
}
|
/* Get the value of the int type*/
|
Get the value of the int type
|
Close
|
void Close(HWND hWnd)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
SendMessage(hWnd, WM_CLOSE, 0, 0);
}
|
/* Close the window*/
|
Close the window
|
SetEnable
|
void SetEnable(HWND hWnd, UINT id, bool b)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
if (b == false)
{
if (IsEnable(hWnd, id))
{
if (id != 0 && IsFocus(hWnd, id))
{
Focus(hWnd, IDCANCEL);
Focus(hWnd, IDOK);
}
EnableWindow(DlgItem(hWnd, id), false);
Refresh(DlgItem(hWnd, id));
}
}
else
{
if (IsDisable(hWnd, id))
{
EnableWindow(DlgItem(hWnd, id), true);
Refresh(DlgItem(hWnd, id));
}
}
}
|
/* Set the enabled state of a window*/
|
Set the enabled state of a window
|
SetText
|
void SetText(HWND hWnd, UINT id, wchar_t *str)
{
// Validate arguments
if (hWnd == NULL || str == NULL)
{
return;
}
SetTextInner(hWnd, id, str);
}
|
/* Set a text string*/
|
Set a text string
|
GetTxt
|
bool GetTxt(HWND hWnd, UINT id, wchar_t *str, UINT size)
{
wchar_t *s;
// Validate arguments
if (hWnd == NULL || str == NULL)
{
return false;
}
s = GetText(hWnd, id);
if (s == NULL)
{
UniStrCpy(str, size, L"");
return false;
}
UniStrCpy(str, size, s);
Free(s);
return true;
}
|
/* Get the text string to the buffer*/
|
Get the text string to the buffer
|
GetText
|
wchar_t *GetText(HWND hWnd, UINT id)
{
wchar_t *ret;
UINT size, len;
// Validate arguments
if (hWnd == NULL)
{
return NULL;
}
if (MsIsNt() == false)
{
char *s = GetTextA(hWnd, id);
ret = CopyStrToUni(s);
Free(s);
return ret;
}
len = GetWindowTextLengthW(DlgItem(hWnd, id));
if (len == 0)
{
return CopyUniStr(L"");
}
size = (len + 1) * 2;
ret = ZeroMallocEx(size, true);
GetWindowTextW(DlgItem(hWnd, id), ret, size);
return ret;
}
|
/* Get the text string*/
|
Get the text string
|
FreeWinUi
|
void FreeWinUi()
{
if ((--init_winui_counter) != 0)
{
return;
}
if (hDll == NULL)
{
return;
}
FreeImageList();
FreeFont();
FreeIconCache();
FreeLibrary(hDll);
hDll = NULL;
Free(title_bar);
title_bar = NULL;
Free(font_name);
font_name = NULL;
if (hCommonDC != NULL)
{
DeleteDC(hCommonDC);
hCommonDC = NULL;
}
DeleteLock(lock_common_dc);
lock_common_dc = NULL;
}
|
/* Release the WinUi*/
|
Release the WinUi
|
PPPContinueUntilFinishAllLCPOptionRequestsDetermined
|
bool PPPContinueUntilFinishAllLCPOptionRequestsDetermined(PPP_SESSION *p)
{
USHORT received_protocol = 0;
// Validate arguments
if (p == NULL)
{
return false;
}
PPPRecvResponsePacket(p, NULL, PPP_PROTOCOL_LCP, &received_protocol, true, false);
return p->ClientLCPOptionDetermined;
}
|
/* Wait until all pending LCP option are determined*/
|
Wait until all pending LCP option are determined
|
PPPContinueCurrentProtocolRequestListening
|
USHORT PPPContinueCurrentProtocolRequestListening(PPP_SESSION *p, USHORT protocol)
{
USHORT received_protocol = 0;
// Validate arguments
if (p == NULL)
{
return 0;
}
PPPRecvResponsePacket(p, NULL, protocol, &received_protocol, false, false);
return received_protocol;
}
|
/* Continue the processing of the request packet protocol on the current PPP*/
|
Continue the processing of the request packet protocol on the current PPP
|
PPPSendEchoRequest
|
void PPPSendEchoRequest(PPP_SESSION *p)
{
PPP_PACKET *pp;
char echo_data[]= "\0\0\0\0Aho Baka Manuke";
// Validate arguments
if (p == NULL)
{
return;
}
pp = ZeroMalloc(sizeof(PPP_PACKET));
pp->Protocol = PPP_PROTOCOL_LCP;
pp->IsControl = true;
pp->Lcp = NewPPPLCP(PPP_LCP_CODE_ECHO_REQUEST, p->NextId++);
pp->Lcp->Data = Clone(echo_data, sizeof(echo_data));
pp->Lcp->DataSize = sizeof(echo_data);
PPPSendPacket(p, pp);
FreePPPPacket(pp);
}
|
/* Send the PPP Echo Request*/
|
Send the PPP Echo Request
|
IsHubExistsWithLock
|
bool IsHubExistsWithLock(CEDAR *cedar, char *hubname)
{
bool ret = false;
// Validate arguments
if (cedar == NULL || hubname == NULL)
{
return false;
}
LockList(cedar->HubList);
{
ret = IsHub(cedar, hubname);
}
UnlockList(cedar->HubList);
return ret;
}
|
/* Check whether the Virtual HUB with the specified name exist?*/
|
Check whether the Virtual HUB with the specified name exist?
|
PPPSetIPOptionToLCP
|
bool PPPSetIPOptionToLCP(PPP_IPOPTION *o, PPP_LCP *c, bool only_modify)
{
bool ret = false;
// Validate arguments
if (c == NULL || o == NULL)
{
return false;
}
ret = PPPSetIPAddressValueToLCP(c, PPP_IPCP_OPTION_IP, &o->IpAddress, only_modify);
PPPSetIPAddressValueToLCP(c, PPP_IPCP_OPTION_DNS1, &o->DnsServer1, only_modify);
PPPSetIPAddressValueToLCP(c, PPP_IPCP_OPTION_DNS2, &o->DnsServer2, only_modify);
PPPSetIPAddressValueToLCP(c, PPP_IPCP_OPTION_WINS1, &o->WinsServer1, only_modify);
PPPSetIPAddressValueToLCP(c, PPP_IPCP_OPTION_WINS2, &o->WinsServer2, only_modify);
return ret;
}
|
/* Set the IP options of PPP to LCP*/
|
Set the IP options of PPP to LCP
|
PPPGetIPOptionFromLCP
|
bool PPPGetIPOptionFromLCP(PPP_IPOPTION *o, PPP_LCP *c)
{
bool ret;
// Validate arguments
if (c == NULL || o == NULL)
{
return false;
}
Zero(o, sizeof(PPP_IPOPTION));
ret = PPPGetIPAddressValueFromLCP(c, PPP_IPCP_OPTION_IP, &o->IpAddress);
PPPGetIPAddressValueFromLCP(c, PPP_IPCP_OPTION_DNS1, &o->DnsServer1);
PPPGetIPAddressValueFromLCP(c, PPP_IPCP_OPTION_DNS2, &o->DnsServer2);
PPPGetIPAddressValueFromLCP(c, PPP_IPCP_OPTION_WINS1, &o->WinsServer1);
PPPGetIPAddressValueFromLCP(c, PPP_IPCP_OPTION_WINS2, &o->WinsServer2);
return ret;
}
|
/* Get the IP options of PPP from LCP*/
|
Get the IP options of PPP from LCP
|
PPPGetIPAddressValueFromLCP
|
bool PPPGetIPAddressValueFromLCP(PPP_LCP *c, UINT type, IP *ip)
{
PPP_OPTION *opt;
UINT ui;
// Validate arguments
if (c == NULL || ip == NULL)
{
return false;
}
opt = GetOptionValue(c, type);
if (opt == NULL)
{
return false;
}
if (opt->DataSize != 4)
{
return false;
}
opt->IsSupported = true;
ui = *((UINT *)opt->Data);
UINTToIP(ip, ui);
return true;
}
|
/* Get the IP address data from the option list of the LCP*/
|
Get the IP address data from the option list of the LCP
|
PPPStoreLastPacket
|
void PPPStoreLastPacket(PPP_SESSION *p, PPP_PACKET *pp)
{
// Validate arguments
if (p == NULL)
{
return;
}
if (p->LastStoredPacket != NULL)
{
FreePPPPacket(p->LastStoredPacket);
}
p->LastStoredPacket = pp;
}
|
/* Store the last packet in the session (to be read the next time)*/
|
Store the last packet in the session (to be read the next time)
|
PPPRecvPacketForCommunication
|
PPP_PACKET *PPPRecvPacketForCommunication(PPP_SESSION *p)
{
// Validate arguments
if (p == NULL)
{
return NULL;
}
if (p->LastStoredPacket != NULL)
{
PPP_PACKET *pp = p->LastStoredPacket;
p->LastStoredPacket = NULL;
return pp;
}
return PPPRecvPacketWithLowLayerProcessing(p, true);
}
|
/* Receive a PPP communication packet*/
|
Receive a PPP communication packet
|
PPPRecvPacket
|
PPP_PACKET *PPPRecvPacket(PPP_SESSION *p, bool async)
{
TUBEDATA *d;
PPP_PACKET *pp;
// Validate arguments
if (p == NULL)
{
return NULL;
}
LABEL_LOOP:
if (async == false)
{
d = TubeRecvSync(p->TubeRecv, PPP_PACKET_RECV_TIMEOUT);
}
else
{
d = TubeRecvAsync(p->TubeRecv);
}
if (d == NULL)
{
return NULL;
}
pp = ParsePPPPacket(d->Data, d->DataSize);
FreeTubeData(d);
if (pp == NULL)
{
// A broken packet is received
goto LABEL_LOOP;
}
p->LastRecvTime = Tick64();
return pp;
}
|
/* Receive a PPP packet*/
|
Receive a PPP packet
|
PPPSendPacket
|
bool PPPSendPacket(PPP_SESSION *p, PPP_PACKET *pp)
{
return PPPSendPacketEx(p, pp, false);
}
|
/* Send the PPP packet*/
|
Send the PPP packet
|
NewPPPOption
|
PPP_OPTION *NewPPPOption(UCHAR type, void *data, UINT size)
{
PPP_OPTION *o;
// Validate arguments
if (size != 0 && data == NULL)
{
return NULL;
}
o = ZeroMalloc(sizeof(PPP_OPTION));
o->Type = type;
Copy(o->Data, data, size);
o->DataSize = size;
return o;
}
|
/* Create a new PPP options*/
|
Create a new PPP options
|
BuildPPPPacketData
|
BUF *BuildPPPPacketData(PPP_PACKET *pp)
{
BUF *ret;
UCHAR c;
USHORT us;
// Validate arguments
if (pp == NULL)
{
return NULL;
}
ret = NewBuf();
// Address
c = 0xff;
WriteBuf(ret, &c, 1);
// Control
c = 0x03;
WriteBuf(ret, &c, 1);
// Protocol
us = Endian16(pp->Protocol);
WriteBuf(ret, &us, 2);
if (pp->IsControl)
{
// LCP
BUF *b = BuildLCPData(pp->Lcp);
WriteBufBuf(ret, b);
FreeBuf(b);
}
else
{
// Data
WriteBuf(ret, pp->Data, pp->DataSize);
}
SeekBuf(ret, 0, 0);
return ret;
}
|
/* Build a PPP packet data*/
|
Build a PPP packet data
|
FreePPPPacket
|
void FreePPPPacket(PPP_PACKET *pp)
{
FreePPPPacketEx(pp, false);
}
|
/* Release the PPP packet*/
|
Release the PPP packet
|
FreePPPSession
|
void FreePPPSession(PPP_SESSION *p)
{
// Validate arguments
if (p == NULL)
{
return;
}
if (p->TubeRecv != NULL)
{
// Record the PPP disconnect reason code for L2TP
p->TubeRecv->IntParam1 = p->DisconnectCauseCode;
p->TubeRecv->IntParam2 = p->DisconnectCauseDirection;
}
FreeTubeFlushList(p->FlushList);
TubeDisconnect(p->TubeRecv);
TubeDisconnect(p->TubeSend);
ReleaseCedar(p->Cedar);
ReleaseTube(p->TubeRecv);
ReleaseTube(p->TubeSend);
PPPStoreLastPacket(p, NULL);
if (p->Ipc != NULL)
{
FreeIPC(p->Ipc);
}
PPPFreeEapClient(p);
Free(p);
}
|
/* Release the PPP session*/
|
Release the PPP session
|
PPPFreeEapClient
|
void PPPFreeEapClient(PPP_SESSION *p)
{
if (p == NULL)
{
return;
}
if (p->EapClient != NULL)
{
ReleaseEapClient(p->EapClient);
p->EapClient = NULL;
}
}
|
/* Free the associated EAP client*/
|
Free the associated EAP client
|
GetOptionValue
|
PPP_OPTION *GetOptionValue(PPP_LCP *c, UCHAR type)
{
UINT i;
// Validate arguments
if (c == NULL)
{
return NULL;
}
for (i = 0;i < LIST_NUM(c->OptionList);i++)
{
PPP_OPTION *t = LIST_DATA(c->OptionList, i);
if (t->Type == type)
{
return t;
}
}
return NULL;
}
|
/* Get the option value*/
|
Get the option value
|
NewPPPLCP
|
PPP_LCP *NewPPPLCP(UCHAR code, UCHAR id)
{
PPP_LCP *c = ZeroMalloc(sizeof(PPP_LCP));
c->Code = code;
c->Id = id;
c->OptionList = NewListFast(NULL);
return c;
}
|
/* Create the LCP*/
|
Create the LCP
|
FreePPPLCP
|
void FreePPPLCP(PPP_LCP *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
FreePPPOptionList(c->OptionList);
Free(c->Data);
Free(c);
}
|
/* Release the LCP*/
|
Release the LCP
|
FreePPPOptionList
|
void FreePPPOptionList(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
PPP_OPTION *t = LIST_DATA(o, i);
Free(t);
}
ReleaseList(o);
}
|
/* Release the PPP options list*/
|
Release the PPP options list
|
GenerateNtPasswordHash
|
void GenerateNtPasswordHash(UCHAR *dst, char *password)
{
UCHAR *tmp;
UINT tmp_size;
UINT i, len;
// Validate arguments
if (dst == NULL || password == NULL)
{
return;
}
// Generate a Unicode password
len = StrLen(password);
tmp_size = len * 2;
tmp = ZeroMalloc(tmp_size);
for (i = 0;i < len;i++)
{
tmp[i * 2] = password[i];
}
// Hashing
HashMd4(dst, tmp, tmp_size);
Free(tmp);
}
|
/* Generate the NT hash of the password*/
|
Generate the NT hash of the password
|
MsChapV2Server_GenerateChallenge
|
void MsChapV2Server_GenerateChallenge(UCHAR *dst)
{
// Validate arguments
if (dst == NULL)
{
return;
}
Rand(dst, 16);
}
|
/* Generate the MS-CHAPv2 server-side challenge*/
|
Generate the MS-CHAPv2 server-side challenge
|
GenerateNtPasswordHashHash
|
void GenerateNtPasswordHashHash(UCHAR *dst_hash, UCHAR *src_hash)
{
// Validate arguments
if (dst_hash == NULL || src_hash == NULL)
{
return;
}
HashMd4(dst_hash, src_hash, 16);
}
|
/* Generate a hash of the hash of the NT password*/
|
Generate a hash of the hash of the NT password
|
MsChapV2VerityPassword
|
bool MsChapV2VerityPassword(IPC_MSCHAP_V2_AUTHINFO *d, char *password)
{
UCHAR ntlm_hash[MD5_SIZE];
UCHAR challenge8[8];
UCHAR client_response[24];
// Validate arguments
if (d == NULL || password == NULL)
{
return false;
}
GenerateNtPasswordHash(ntlm_hash, password);
MsChapV2_GenerateChallenge8(challenge8, d->MsChapV2_ClientChallenge, d->MsChapV2_ServerChallenge, d->MsChapV2_PPPUsername);
MsChapV2Client_GenerateResponse(client_response, challenge8, ntlm_hash);
if (Cmp(client_response, d->MsChapV2_ClientResponse, 24) != 0)
{
return false;
}
return true;
}
|
/* Verify whether the password matches one that is specified by the user in the MS-CHAPv2*/
|
Verify whether the password matches one that is specified by the user in the MS-CHAPv2
|
IsNeedWinPcap
|
bool IsNeedWinPcap()
{
if (IsBridgeSupported() == false)
{
// Not in Windows
return false;
}
else
{
// Windows
if (IsEthSupported())
{
// Already success to access the Ethernet device
return false;
}
else
{
// Failed to access the Ethernet device
return true;
}
}
}
|
/* Get whether WinPcap is needed*/
|
Get whether WinPcap is needed
|
IsBridgeSupported
|
bool IsBridgeSupported()
{
UINT type = GetOsInfo()->OsType;
if (OS_IS_WINDOWS(type))
{
if (IsEthSupported())
{
return true;
}
else
{
bool ret = false;
#ifdef OS_WIN32
ret = MsIsAdmin();
#endif // OS_WIN32
return ret;
}
}
else
{
return IsEthSupported();
}
}
|
/* Get whether the local-bridging is supported by current OS*/
|
Get whether the local-bridging is supported by current OS
|
InitLocalBridgeList
|
void InitLocalBridgeList(CEDAR *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
c->LocalBridgeList = NewList(NULL);
}
|
/* Initialize the local-bridge list*/
|
Initialize the local-bridge list
|
FreeLocalBridgeList
|
void FreeLocalBridgeList(CEDAR *c)
{
UINT i;
// Validate arguments
if (c == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(c->LocalBridgeList);i++)
{
LOCALBRIDGE *br = LIST_DATA(c->LocalBridgeList, i);
Free(br);
}
ReleaseList(c->LocalBridgeList);
c->LocalBridgeList = NULL;
}
|
/* Free the local-bridge list*/
|
Free the local-bridge list
|
BrFreeBridge
|
void BrFreeBridge(BRIDGE *b)
{
// Validate arguments
if (b == NULL)
{
return;
}
if (b->ParentLocalBridge != NULL)
{
b->ParentLocalBridge = NULL;
}
// Stop session thread
StopSession(b->Session);
ReleaseSession(b->Session);
Free(b);
}
|
/* Free the local-bridge object*/
|
Free the local-bridge object
|
IsRawIpBridgeSupported
|
bool IsRawIpBridgeSupported()
{
#ifdef UNIX_LINUX
return true;
#else // UNIX_LINUX
return false;
#endif // UNIX_LINUX
}
|
/* Raw IP bridge is supported only on Linux*/
|
Raw IP bridge is supported only on Linux
|
UdpAccelSendBlock
|
void UdpAccelSendBlock(UDP_ACCEL *a, BLOCK *b)
{
// Validate arguments
if (a == NULL || b == NULL)
{
return;
}
UdpAccelSend(a, b->Buf, b->Size, b->Compressed ? 1 : 0, a->MaxUdpPacketSize, b->PriorityQoS);
}
|
/* Send a packet block*/
|
Send a packet block
|
UdpAccelCalcKeyV1
|
void UdpAccelCalcKeyV1(UCHAR *key, UCHAR *common_key, UCHAR *iv)
{
UCHAR tmp[UDP_ACCELERATION_COMMON_KEY_SIZE_V1 + UDP_ACCELERATION_PACKET_IV_SIZE_V1];
// Validate arguments
if (key == NULL || common_key == NULL || iv == NULL)
{
return;
}
Copy(tmp, common_key, UDP_ACCELERATION_COMMON_KEY_SIZE_V1);
Copy(tmp + UDP_ACCELERATION_COMMON_KEY_SIZE_V1, iv, UDP_ACCELERATION_PACKET_IV_SIZE_V1);
Sha1(key, tmp, sizeof(tmp));
}
|
/* Calculate V1 key*/
|
Calculate V1 key
|
UdpAccelSetTick
|
void UdpAccelSetTick(UDP_ACCEL *a, UINT64 tick64)
{
// Validate arguments
if (a == NULL)
{
return;
}
a->Now = tick64;
}
|
/* Set the current time*/
|
Set the current time
|
NewKeepPacket
|
BUF *NewKeepPacket(bool server_mode)
{
BUF *b = NewBuf();
char *string = KEEP_ALIVE_STRING;
WriteBuf(b, string, StrLen(string));
SeekBuf(b, 0, 0);
return b;
}
|
/* Generate the next packet*/
|
Generate the next packet
|
StopKeep
|
void StopKeep(KEEP *k)
{
// Validate arguments
if (k == NULL)
{
return;
}
k->Halt = true;
Set(k->HaltEvent);
Cancel(k->Cancel);
WaitThread(k->Thread, INFINITE);
ReleaseThread(k->Thread);
DeleteLock(k->lock);
ReleaseCancel(k->Cancel);
ReleaseEvent(k->HaltEvent);
Free(k);
}
|
/* Stop the KEEP*/
|
Stop the KEEP
|
StartKeep
|
KEEP *StartKeep()
{
KEEP *k = ZeroMalloc(sizeof(KEEP));
k->lock = NewLock();
k->HaltEvent = NewEvent();
k->Cancel = NewCancel();
// Thread start
k->Thread = NewThread(KeepThread, k);
return k;
}
|
/* Start the KEEP*/
|
Start the KEEP
|
WriteSendFifo
|
void WriteSendFifo(SESSION *s, TCPSOCK *ts, void *data, UINT size)
{
// Validate arguments
if (s == NULL || ts == NULL || data == NULL)
{
return;
}
WriteFifo(ts->SendFifo, data, size);
}
|
/* Write data to the transmit FIFO (automatic encryption)*/
|
Write data to the transmit FIFO (automatic encryption)
|
WriteRecvFifo
|
void WriteRecvFifo(SESSION *s, TCPSOCK *ts, void *data, UINT size)
{
// Validate arguments
if (s == NULL || ts == NULL || data == NULL)
{
return;
}
WriteFifo(ts->RecvFifo, data, size);
}
|
/* Write data to the reception FIFO (automatic decryption)*/
|
Write data to the reception FIFO (automatic decryption)
|
TcpSockRecv
|
UINT TcpSockRecv(SESSION *s, TCPSOCK *ts, void *data, UINT size)
{
// Receive
return Recv(ts->Sock, data, size, s->UseEncrypt);
}
|
/* TCP socket receive*/
|
TCP socket receive
|
TcpSockSend
|
UINT TcpSockSend(SESSION *s, TCPSOCK *ts, void *data, UINT size)
{
// Transmission
return Send(ts->Sock, data, size, s->UseEncrypt);
}
|
/* TCP socket send*/
|
TCP socket send
|
GenNextKeepAliveSpan
|
UINT GenNextKeepAliveSpan(CONNECTION *c)
{
UINT a, b;
// Validate arguments
if (c == NULL)
{
return INFINITE;
}
a = c->Session->Timeout;
b = rand() % (a / 2);
b = MAX(b, a / 5);
return b;
}
|
/* (This should be a random number for the network load reduction)*/
|
(This should be a random number for the network load reduction)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.